20
20
21
21
import static com .google .common .util .concurrent .Uninterruptibles .sleepUninterruptibly ;
22
22
import static java .nio .charset .StandardCharsets .UTF_8 ;
23
- import static java .util .concurrent .TimeUnit .HOURS ;
24
23
25
24
import java .net .InetAddress ;
26
25
import java .net .URL ;
27
26
import java .net .UnknownHostException ;
28
- import java .util .ArrayList ;
29
27
import java .util .Arrays ;
30
28
import java .util .Collections ;
31
29
import java .util .HashMap ;
32
30
import java .util .HashSet ;
33
31
import java .util .Iterator ;
34
- import java .util .LinkedList ;
35
32
import java .util .List ;
36
33
import java .util .Map ;
37
34
import java .util .Map .Entry ;
@@ -137,35 +134,6 @@ public static void main(String[] args) throws Exception {
137
134
private int totalTables = 0 ;
138
135
private final AtomicBoolean monitorInitialized = new AtomicBoolean (false );
139
136
140
- private static <T > List <Pair <Long ,T >> newMaxList () {
141
- return Collections .synchronizedList (new LinkedList <>() {
142
-
143
- private static final long serialVersionUID = 1L ;
144
- private final long maxDelta = HOURS .toMillis (1 );
145
-
146
- @ Override
147
- public boolean add (Pair <Long ,T > obj ) {
148
- boolean result = super .add (obj );
149
- if (obj .getFirst () - get (0 ).getFirst () > maxDelta ) {
150
- remove (0 );
151
- }
152
- return result ;
153
- }
154
-
155
- });
156
- }
157
-
158
- private final List <Pair <Long ,Double >> loadOverTime = newMaxList ();
159
- private final List <Pair <Long ,Double >> ingestRateOverTime = newMaxList ();
160
- private final List <Pair <Long ,Double >> ingestByteRateOverTime = newMaxList ();
161
- private final List <Pair <Long ,Integer >> minorCompactionsOverTime = newMaxList ();
162
- private final List <Pair <Long ,Integer >> majorCompactionsOverTime = newMaxList ();
163
- private final List <Pair <Long ,Double >> lookupsOverTime = newMaxList ();
164
- private final List <Pair <Long ,Long >> queryRateOverTime = newMaxList ();
165
- private final List <Pair <Long ,Long >> scanRateOverTime = newMaxList ();
166
- private final List <Pair <Long ,Double >> queryByteRateOverTime = newMaxList ();
167
- private final List <Pair <Long ,Double >> indexCacheHitRateOverTime = newMaxList ();
168
- private final List <Pair <Long ,Double >> dataCacheHitRateOverTime = newMaxList ();
169
137
private EventCounter lookupRateTracker = new EventCounter ();
170
138
private EventCounter indexCacheHitTracker = new EventCounter ();
171
139
private EventCounter indexCacheRequestTracker = new EventCounter ();
@@ -250,9 +218,7 @@ synchronized long calculateCount() {
250
218
public void fetchData () {
251
219
ServerContext context = getContext ();
252
220
double totalIngestRate = 0. ;
253
- double totalIngestByteRate = 0. ;
254
221
double totalQueryRate = 0. ;
255
- double totalQueryByteRate = 0. ;
256
222
double totalScanRate = 0. ;
257
223
long totalEntries = 0 ;
258
224
int totalTabletCount = 0 ;
@@ -298,8 +264,6 @@ public void fetchData() {
298
264
}
299
265
}
300
266
if (mmi != null ) {
301
- int majorCompactions = 0 ;
302
- int minorCompactions = 0 ;
303
267
304
268
lookupRateTracker .startingUpdates ();
305
269
indexCacheHitTracker .startingUpdates ();
@@ -310,15 +274,11 @@ public void fetchData() {
310
274
for (TabletServerStatus server : mmi .tServerInfo ) {
311
275
TableInfo summary = TableInfoUtil .summarizeTableStats (server );
312
276
totalIngestRate += summary .ingestRate ;
313
- totalIngestByteRate += summary .ingestByteRate ;
314
277
totalQueryRate += summary .queryRate ;
315
278
totalScanRate += summary .scanRate ;
316
- totalQueryByteRate += summary .queryByteRate ;
317
279
totalEntries += summary .recs ;
318
280
totalHoldTime += server .holdTime ;
319
281
totalLookups += server .lookups ;
320
- majorCompactions += summary .majors .running ;
321
- minorCompactions += summary .minors .running ;
322
282
lookupRateTracker .updateTabletServer (server .name , server .lastContact , server .lookups );
323
283
indexCacheHitTracker .updateTabletServer (server .name , server .lastContact ,
324
284
server .indexCacheHits );
@@ -343,40 +303,13 @@ public void fetchData() {
343
303
}
344
304
this .totalIngestRate = totalIngestRate ;
345
305
this .totalTables = totalTables ;
346
- totalIngestByteRate = totalIngestByteRate / 1000000.0 ;
347
306
this .totalQueryRate = totalQueryRate ;
348
307
this .totalScanRate = totalScanRate ;
349
- totalQueryByteRate = totalQueryByteRate / 1000000.0 ;
350
308
this .totalEntries = totalEntries ;
351
309
this .totalTabletCount = totalTabletCount ;
352
310
this .totalHoldTime = totalHoldTime ;
353
311
this .totalLookups = totalLookups ;
354
312
355
- ingestRateOverTime .add (new Pair <>(currentTime , totalIngestRate ));
356
- ingestByteRateOverTime .add (new Pair <>(currentTime , totalIngestByteRate ));
357
-
358
- double totalLoad = 0. ;
359
- for (TabletServerStatus status : mmi .tServerInfo ) {
360
- if (status != null ) {
361
- totalLoad += status .osLoad ;
362
- }
363
- }
364
- loadOverTime .add (new Pair <>(currentTime , totalLoad ));
365
-
366
- minorCompactionsOverTime .add (new Pair <>(currentTime , minorCompactions ));
367
- majorCompactionsOverTime .add (new Pair <>(currentTime , majorCompactions ));
368
-
369
- lookupsOverTime .add (new Pair <>(currentTime , lookupRateTracker .calculateRate ()));
370
-
371
- queryRateOverTime .add (new Pair <>(currentTime , (long ) totalQueryRate ));
372
- queryByteRateOverTime .add (new Pair <>(currentTime , totalQueryByteRate ));
373
-
374
- scanRateOverTime .add (new Pair <>(currentTime , (long ) totalScanRate ));
375
-
376
- calcCacheHitRate (indexCacheHitRateOverTime , currentTime , indexCacheHitTracker ,
377
- indexCacheRequestTracker );
378
- calcCacheHitRate (dataCacheHitRateOverTime , currentTime , dataCacheHitTracker ,
379
- dataCacheRequestTracker );
380
313
}
381
314
try {
382
315
this .problemSummary = ProblemReports .getInstance (context ).summarize ();
@@ -411,17 +344,6 @@ public void fetchData() {
411
344
}
412
345
}
413
346
414
- private static void calcCacheHitRate (List <Pair <Long ,Double >> hitRate , long currentTime ,
415
- EventCounter cacheHits , EventCounter cacheReq ) {
416
- long req = cacheReq .calculateCount ();
417
- if (req > 0 ) {
418
- hitRate .add (
419
- new Pair <>(currentTime , cacheHits .calculateCount () / (double ) cacheReq .calculateCount ()));
420
- } else {
421
- hitRate .add (new Pair <>(currentTime , null ));
422
- }
423
- }
424
-
425
347
private GCStatus fetchGcStatus () {
426
348
ServerContext context = getContext ();
427
349
GCStatus result = null ;
@@ -983,54 +905,10 @@ public long getStartTime() {
983
905
return START_TIME ;
984
906
}
985
907
986
- public List <Pair <Long ,Double >> getLoadOverTime () {
987
- return new ArrayList <>(loadOverTime );
988
- }
989
-
990
- public List <Pair <Long ,Double >> getIngestRateOverTime () {
991
- return new ArrayList <>(ingestRateOverTime );
992
- }
993
-
994
- public List <Pair <Long ,Double >> getIngestByteRateOverTime () {
995
- return new ArrayList <>(ingestByteRateOverTime );
996
- }
997
-
998
- public List <Pair <Long ,Integer >> getMinorCompactionsOverTime () {
999
- return new ArrayList <>(minorCompactionsOverTime );
1000
- }
1001
-
1002
- public List <Pair <Long ,Integer >> getMajorCompactionsOverTime () {
1003
- return new ArrayList <>(majorCompactionsOverTime );
1004
- }
1005
-
1006
- public List <Pair <Long ,Double >> getLookupsOverTime () {
1007
- return new ArrayList <>(lookupsOverTime );
1008
- }
1009
-
1010
908
public double getLookupRate () {
1011
909
return lookupRateTracker .calculateRate ();
1012
910
}
1013
911
1014
- public List <Pair <Long ,Long >> getQueryRateOverTime () {
1015
- return new ArrayList <>(queryRateOverTime );
1016
- }
1017
-
1018
- public List <Pair <Long ,Long >> getScanRateOverTime () {
1019
- return new ArrayList <>(scanRateOverTime );
1020
- }
1021
-
1022
- public List <Pair <Long ,Double >> getQueryByteRateOverTime () {
1023
- return new ArrayList <>(queryByteRateOverTime );
1024
- }
1025
-
1026
- public List <Pair <Long ,Double >> getIndexCacheHitRateOverTime () {
1027
- return new ArrayList <>(indexCacheHitRateOverTime );
1028
- }
1029
-
1030
- public List <Pair <Long ,Double >> getDataCacheHitRateOverTime () {
1031
- return new ArrayList <>(dataCacheHitRateOverTime );
1032
- }
1033
-
1034
912
@ Override
1035
913
public boolean isActiveService () {
1036
914
return monitorInitialized .get ();
0 commit comments