accumulo-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [accumulo] alerman commented on a change in pull request #1187: Log top tablets by ingest and query at a configurable time duration
Date Fri, 07 Jun 2019 14:15:03 GMT
alerman commented on a change in pull request #1187: Log top tablets by ingest and query at
a configurable time duration
URL: https://github.com/apache/accumulo/pull/1187#discussion_r291611090
 
 

 ##########
 File path: server/tserver/src/main/java/org/apache/accumulo/tserver/TabletServer.java
 ##########
 @@ -358,6 +359,53 @@ 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 numTopTabletsToLog = aconf.getCount(Property.TSERV_LOG_TOP_TABLETS_COUNT);
+    final long logTopTabletsDelay = aconf.getTimeInMillis(Property.TSERV_LOG_TOP_TABLETS_INTERVAL);
+    if (numTopTabletsToLog > 0) {
+      SimpleTimer.getInstance(aconf).schedule(new Runnable() {
+        @Override
+        public void run() {
+          Comparator<Pair<String,Long>> topTabletComparator = new Comparator<Pair<String,Long>>()
{
+            @Override
+            public int compare(Pair<String,Long> first, Pair<String,Long> second)
{
+              return second.getSecond().compareTo(first.getSecond());
+            }
+          };
+          PriorityQueue<Pair<String,Long>> topTabletsByIngestCount =
+              new PriorityQueue<>(numTopTabletsToLog, topTabletComparator);
+          PriorityQueue<Pair<String,Long>> topTabletsByQueryCount =
+              new PriorityQueue<>(numTopTabletsToLog, topTabletComparator);
+          synchronized (onlineTablets) {
+            for (Tablet tablet : onlineTablets.values()) {
+              addToTopTablets(tablet.totalIngest(), topTabletsByIngestCount, numTopTabletsToLog);
+              addToTopTablets(tablet.totalQueries(), topTabletsByQueryCount, numTopTabletsToLog);
+            }
+            logTopTablets(topTabletsByIngestCount, "QUERY", numTopTabletsToLog);
+            logTopTablets(topTabletsByQueryCount, "INGEST", numTopTabletsToLog);
+          }
+        }
+
+        private void addToTopTablets(long count,
+            PriorityQueue<Pair<String,Long>> topTabletsQueue, int numTopTabletsToLog)
{
+          if (topTabletsQueue.size() < numTopTabletsToLog
+              || topTabletsQueue.peek().getSecond() < count) {
+            if (topTabletsQueue.size() == numTopTabletsToLog) {
+              topTabletsQueue.remove();
+            }
+          }
+        }
+
+        private void logTopTablets(PriorityQueue<Pair<String,Long>> topTabletsQueue,
+            String label, int numTopTabletsToLog) {
+          for (int i = 0; i < numTopTabletsToLog; i++) {
 
 Review comment:
   ill refactor to make it more clear

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message