keith-turner commented on a change in pull request #1187: Log busy tablets by 
ingest and query at a configurable time duration
URL: https://github.com/apache/accumulo/pull/1187#discussion_r307369386
 
 

 ##########
 File path: 
server/tserver/src/main/java/org/apache/accumulo/tserver/TabletServer.java
 ##########
 @@ -358,6 +364,79 @@ public TabletServer(ServerConfigurationFactory 
confFactory, VolumeManager fs) th
     this.logSorter = new LogSorter(instance, fs, aconf);
     this.replWorker = new ReplicationWorker(this, fs);
     this.statsKeeper = new TabletStatsKeeper();
+    final int numBusyTabletsToLog = 
aconf.getCount(Property.TSERV_LOG_BUSY_TABLETS_COUNT);
+    final long logBusyTabletsDelay =
+        aconf.getTimeInMillis(Property.TSERV_LOG_BUSY_TABLETS_INTERVAL);
+
+    // This thread will calculate and log out the busiest tablets based on 
ingest count and
+    // query count every #{logBusiestTabletsDelay}
+    if (numBusyTabletsToLog > 0) {
+      SimpleTimer.getInstance(aconf).schedule(new Runnable() {
+        @Override
+        public void run() {
+          Comparator<Pair<String,Double>> busiestTabletComparator =
+              new Comparator<Pair<String,Double>>() {
+                @Override
+                public int compare(Pair<String,Double> first, 
Pair<String,Double> second) {
+                  return second.getSecond().compareTo(first.getSecond());
+                }
+              };
+          Map<String,PriorityQueue<Pair<String,Double>>> busyTabletMap = new 
HashMap<>();
+          busyTabletMap.put(INGEST_COUNT,
+              new PriorityQueue<>(numBusyTabletsToLog, 
busiestTabletComparator));
+          busyTabletMap.put(INGEST_RATE,
+              new PriorityQueue<>(numBusyTabletsToLog, 
busiestTabletComparator));
+          busyTabletMap.put(QUERY_COUNT,
+              new PriorityQueue<>(numBusyTabletsToLog, 
busiestTabletComparator));
+          busyTabletMap.put(QUERY_RATE,
+              new PriorityQueue<>(numBusyTabletsToLog, 
busiestTabletComparator));
+          List<Tablet> tablets;
+          synchronized (onlineTablets) {
+            tablets = new ArrayList<>(onlineTablets.values());
+          }
+          for (Tablet tablet : tablets) {
+            String extentString = tablet.getExtent().toString();
+            addToBusiestTablets(extentString, tablet.totalQueries(), 
busyTabletMap.get(QUERY_COUNT),
+                numBusyTabletsToLog);
+            addToBusiestTablets(extentString, tablet.queryRate(), 
busyTabletMap.get(QUERY_RATE),
+                numBusyTabletsToLog);
+            addToBusiestTablets(extentString, tablet.totalIngest(), 
busyTabletMap.get(INGEST_COUNT),
+                numBusyTabletsToLog);
+            addToBusiestTablets(extentString, tablet.ingestRate(), 
busyTabletMap.get(INGEST_RATE),
+                numBusyTabletsToLog);
+          }
+
+          logBusyTablets(busyTabletMap, QUERY_COUNT);
+          logBusyTablets(busyTabletMap, QUERY_RATE);
+          logBusyTablets(busyTabletMap, INGEST_COUNT);
+          logBusyTablets(busyTabletMap, INGEST_RATE);
+        }
+
+        private void addToBusiestTablets(String extent, double count,
+            PriorityQueue<Pair<String,Double>> busiestTabletsQueue, int 
numBusiestTabletsToLog) {
+          if (busiestTabletsQueue.size() < numBusiestTabletsToLog
 
 Review comment:
   @alerman while I was writing unit test for #1291 I found that this algorithm 
does not work computing the top k.  After the queue is full it only adds items 
that are greater than the max in the queue.  However, something could be less 
than the max in the queue and still in the top K.  I just wanted to let you 
know about this in case you were using this patch.
   
   Before writing unit test, I thought the algorithm was fine.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to