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