001/** 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance 008 * with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, software 013 * distributed under the License is distributed on an "AS IS" BASIS, 014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 015 * See the License for the specific language governing permissions and 016 * limitations under the License. 017 */ 018package org.apache.hadoop.hbase.hbtop; 019 020import static org.hamcrest.CoreMatchers.is; 021import static org.junit.Assert.assertThat; 022import static org.junit.Assert.fail; 023 024import java.text.ParseException; 025import java.util.ArrayList; 026import java.util.Collections; 027import java.util.HashMap; 028import java.util.List; 029import java.util.Map; 030 031import org.apache.commons.lang3.time.FastDateFormat; 032import org.apache.hadoop.hbase.ClusterMetrics; 033import org.apache.hadoop.hbase.ClusterMetricsBuilder; 034import org.apache.hadoop.hbase.RegionMetrics; 035import org.apache.hadoop.hbase.RegionMetricsBuilder; 036import org.apache.hadoop.hbase.ServerMetrics; 037import org.apache.hadoop.hbase.ServerMetricsBuilder; 038import org.apache.hadoop.hbase.ServerName; 039import org.apache.hadoop.hbase.Size; 040import org.apache.hadoop.hbase.TableName; 041import org.apache.hadoop.hbase.UserMetrics; 042import org.apache.hadoop.hbase.UserMetricsBuilder; 043import org.apache.hadoop.hbase.client.RegionInfoBuilder; 044import org.apache.hadoop.hbase.hbtop.field.Field; 045import org.apache.hadoop.hbase.hbtop.screen.top.Summary; 046import org.apache.hadoop.hbase.master.RegionState; 047import org.apache.hadoop.hbase.util.Bytes; 048 049 050public final class TestUtils { 051 052 private TestUtils() { 053 } 054 055 public static ClusterMetrics createDummyClusterMetrics() { 056 Map<ServerName, ServerMetrics> serverMetricsMap = new HashMap<>(); 057 058 // host1 059 List<RegionMetrics> regionMetricsList = new ArrayList<>(); 060 List<UserMetrics> userMetricsList = new ArrayList<>(); 061 userMetricsList.add(createUserMetrics("FOO",1,2, 4)); 062 userMetricsList.add(createUserMetrics("BAR",2,3, 3)); 063 regionMetricsList.add(createRegionMetrics( 064 "table1,,1.00000000000000000000000000000000.", 065 100, 50, 100, 066 new Size(100, Size.Unit.MEGABYTE), new Size(200, Size.Unit.MEGABYTE), 1, 067 new Size(100, Size.Unit.MEGABYTE), 0.1f, 100, 100, "2019-07-22 00:00:00")); 068 regionMetricsList.add(createRegionMetrics( 069 "table2,1,2.00000000000000000000000000000001.", 070 200, 100, 200, 071 new Size(200, Size.Unit.MEGABYTE), new Size(400, Size.Unit.MEGABYTE), 2, 072 new Size(200, Size.Unit.MEGABYTE), 0.2f, 50, 200, "2019-07-22 00:00:01")); 073 regionMetricsList.add(createRegionMetrics( 074 "namespace:table3,,3_0001.00000000000000000000000000000002.", 075 300, 150, 300, 076 new Size(300, Size.Unit.MEGABYTE), new Size(600, Size.Unit.MEGABYTE), 3, 077 new Size(300, Size.Unit.MEGABYTE), 0.3f, 100, 300, "2019-07-22 00:00:02")); 078 079 ServerName host1 = ServerName.valueOf("host1.apache.com", 1000, 1); 080 serverMetricsMap.put(host1, createServerMetrics(host1, 100, 081 new Size(100, Size.Unit.MEGABYTE), new Size(200, Size.Unit.MEGABYTE), 100, 082 regionMetricsList, userMetricsList)); 083 084 // host2 085 regionMetricsList.clear(); 086 userMetricsList.clear(); 087 userMetricsList.add(createUserMetrics("FOO",5,7, 3)); 088 userMetricsList.add(createUserMetrics("BAR",4,8, 4)); 089 regionMetricsList.add(createRegionMetrics( 090 "table1,1,4.00000000000000000000000000000003.", 091 100, 50, 100, 092 new Size(100, Size.Unit.MEGABYTE), new Size(200, Size.Unit.MEGABYTE), 1, 093 new Size(100, Size.Unit.MEGABYTE), 0.4f, 50, 100, "2019-07-22 00:00:03")); 094 regionMetricsList.add(createRegionMetrics( 095 "table2,,5.00000000000000000000000000000004.", 096 200, 100, 200, 097 new Size(200, Size.Unit.MEGABYTE), new Size(400, Size.Unit.MEGABYTE), 2, 098 new Size(200, Size.Unit.MEGABYTE), 0.5f, 150, 200, "2019-07-22 00:00:04")); 099 regionMetricsList.add(createRegionMetrics( 100 "namespace:table3,,6.00000000000000000000000000000005.", 101 300, 150, 300, 102 new Size(300, Size.Unit.MEGABYTE), new Size(600, Size.Unit.MEGABYTE), 3, 103 new Size(300, Size.Unit.MEGABYTE), 0.6f, 200, 300, "2019-07-22 00:00:05")); 104 105 ServerName host2 = ServerName.valueOf("host2.apache.com", 1001, 2); 106 serverMetricsMap.put(host2, createServerMetrics(host2, 200, 107 new Size(16, Size.Unit.GIGABYTE), new Size(32, Size.Unit.GIGABYTE), 200, 108 regionMetricsList, userMetricsList)); 109 110 ServerName host3 = ServerName.valueOf("host3.apache.com", 1002, 3); 111 return ClusterMetricsBuilder.newBuilder() 112 .setHBaseVersion("3.0.0-SNAPSHOT") 113 .setClusterId("01234567-89ab-cdef-0123-456789abcdef") 114 .setLiveServerMetrics(serverMetricsMap) 115 .setDeadServerNames(Collections.singletonList(host3)) 116 .setRegionsInTransition(Collections.singletonList( 117 new RegionState(RegionInfoBuilder.newBuilder(TableName.valueOf("table4")) 118 .setStartKey(new byte [0]) 119 .setEndKey(new byte [0]) 120 .setOffline(true) 121 .setReplicaId(0) 122 .setRegionId(0) 123 .setSplit(false) 124 .build(), 125 RegionState.State.OFFLINE, host3))) 126 .build(); 127 } 128 129 private static UserMetrics createUserMetrics(String user, long readRequestCount, 130 long writeRequestCount, long filteredReadRequestsCount) { 131 return UserMetricsBuilder.newBuilder(Bytes.toBytes(user)).addClientMetris( 132 new UserMetricsBuilder.ClientMetricsImpl("CLIENT_A_" + user, readRequestCount, 133 writeRequestCount, filteredReadRequestsCount)).addClientMetris( 134 new UserMetricsBuilder.ClientMetricsImpl("CLIENT_B_" + user, readRequestCount, 135 writeRequestCount, filteredReadRequestsCount)).build(); 136 } 137 138 private static RegionMetrics createRegionMetrics(String regionName, long readRequestCount, 139 long filteredReadRequestCount, long writeRequestCount, Size storeFileSize, 140 Size uncompressedStoreFileSize, int storeFileCount, Size memStoreSize, float locality, 141 long compactedCellCount, long compactingCellCount, String lastMajorCompactionTime) { 142 143 FastDateFormat df = FastDateFormat.getInstance("yyyy-MM-dd HH:mm:ss"); 144 try { 145 return RegionMetricsBuilder.newBuilder(Bytes.toBytes(regionName)) 146 .setReadRequestCount(readRequestCount) 147 .setFilteredReadRequestCount(filteredReadRequestCount) 148 .setWriteRequestCount(writeRequestCount).setStoreFileSize(storeFileSize) 149 .setUncompressedStoreFileSize(uncompressedStoreFileSize).setStoreFileCount(storeFileCount) 150 .setMemStoreSize(memStoreSize).setDataLocality(locality) 151 .setCompactedCellCount(compactedCellCount).setCompactingCellCount(compactingCellCount) 152 .setLastMajorCompactionTimestamp(df.parse(lastMajorCompactionTime).getTime()).build(); 153 } catch (ParseException e) { 154 throw new IllegalArgumentException(e); 155 } 156 } 157 158 private static ServerMetrics createServerMetrics(ServerName serverName, long reportTimestamp, 159 Size usedHeapSize, Size maxHeapSize, long requestCountPerSecond, 160 List<RegionMetrics> regionMetricsList, List<UserMetrics> userMetricsList) { 161 162 return ServerMetricsBuilder.newBuilder(serverName) 163 .setReportTimestamp(reportTimestamp) 164 .setUsedHeapSize(usedHeapSize) 165 .setMaxHeapSize(maxHeapSize) 166 .setRequestCountPerSecond(requestCountPerSecond) 167 .setRegionMetrics(regionMetricsList) 168 .setUserMetrics(userMetricsList).build(); 169 } 170 171 public static void assertRecordsInRegionMode(List<Record> records) { 172 assertThat(records.size(), is(6)); 173 174 for (Record record : records) { 175 switch (record.get(Field.REGION_NAME).asString()) { 176 case "table1,,1.00000000000000000000000000000000.": 177 assertRecordInRegionMode(record, "default", "1", "", "table1", 178 "00000000000000000000000000000000", "host1:1000", "host1.apache.com,1000,1",0L, 179 0L, 0L, 0L, new Size(100, Size.Unit.MEGABYTE), new Size(200, Size.Unit.MEGABYTE), 1, 180 new Size(100, Size.Unit.MEGABYTE), 0.1f, "", 100L, 100L, 100f, 181 "2019-07-22 00:00:00"); 182 break; 183 184 case "table1,1,4.00000000000000000000000000000003.": 185 assertRecordInRegionMode(record, "default", "4", "", "table1", 186 "00000000000000000000000000000003", "host2:1001", "host2.apache.com,1001,2",0L, 187 0L, 0L, 0L, new Size(100, Size.Unit.MEGABYTE), new Size(200, Size.Unit.MEGABYTE), 1, 188 new Size(100, Size.Unit.MEGABYTE), 0.4f, "1", 100L, 50L, 50f, 189 "2019-07-22 00:00:03"); 190 break; 191 192 case "table2,,5.00000000000000000000000000000004.": 193 assertRecordInRegionMode(record, "default", "5", "", "table2", 194 "00000000000000000000000000000004", "host2:1001", "host2.apache.com,1001,2",0L, 195 0L, 0L, 0L, new Size(200, Size.Unit.MEGABYTE), new Size(400, Size.Unit.MEGABYTE), 2, 196 new Size(200, Size.Unit.MEGABYTE), 0.5f, "", 200L, 150L, 75f, 197 "2019-07-22 00:00:04"); 198 break; 199 200 case "table2,1,2.00000000000000000000000000000001.": 201 assertRecordInRegionMode(record, "default", "2", "", "table2", 202 "00000000000000000000000000000001", "host1:1000", "host1.apache.com,1000,1",0L, 203 0L, 0L, 0L, new Size(200, Size.Unit.MEGABYTE), new Size(400, Size.Unit.MEGABYTE), 2, 204 new Size(200, Size.Unit.MEGABYTE), 0.2f, "1", 200L, 50L, 25f, 205 "2019-07-22 00:00:01"); 206 break; 207 208 case "namespace:table3,,6.00000000000000000000000000000005.": 209 assertRecordInRegionMode(record, "namespace", "6", "", "table3", 210 "00000000000000000000000000000005", "host2:1001", "host2.apache.com,1001,2",0L, 211 0L, 0L, 0L, new Size(300, Size.Unit.MEGABYTE), new Size(600, Size.Unit.MEGABYTE), 3, 212 new Size(300, Size.Unit.MEGABYTE), 0.6f, "", 300L, 200L, 66.66667f, 213 "2019-07-22 00:00:05"); 214 break; 215 216 case "namespace:table3,,3_0001.00000000000000000000000000000002.": 217 assertRecordInRegionMode(record, "namespace", "3", "1", "table3", 218 "00000000000000000000000000000002", "host1:1000", "host1.apache.com,1000,1",0L, 219 0L, 0L, 0L, new Size(300, Size.Unit.MEGABYTE), new Size(600, Size.Unit.MEGABYTE), 3, 220 new Size(300, Size.Unit.MEGABYTE), 0.3f, "", 300L, 100L, 33.333336f, 221 "2019-07-22 00:00:02"); 222 break; 223 224 default: 225 fail(); 226 } 227 } 228 } 229 230 private static void assertRecordInRegionMode(Record record, String namespace, String startCode, 231 String replicaId, String table, String region, String regionServer, String longRegionServer, 232 long requestCountPerSecond, long readRequestCountPerSecond, 233 long filteredReadRequestCountPerSecond, long writeCountRequestPerSecond, 234 Size storeFileSize, Size uncompressedStoreFileSize, int numStoreFiles, 235 Size memStoreSize, float locality, String startKey, long compactingCellCount, 236 long compactedCellCount, float compactionProgress, String lastMajorCompactionTime) { 237 assertThat(record.size(), is(22)); 238 assertThat(record.get(Field.NAMESPACE).asString(), is(namespace)); 239 assertThat(record.get(Field.START_CODE).asString(), is(startCode)); 240 assertThat(record.get(Field.REPLICA_ID).asString(), is(replicaId)); 241 assertThat(record.get(Field.TABLE).asString(), is(table)); 242 assertThat(record.get(Field.REGION).asString(), is(region)); 243 assertThat(record.get(Field.REGION_SERVER).asString(), is(regionServer)); 244 assertThat(record.get(Field.LONG_REGION_SERVER).asString(), is(longRegionServer)); 245 assertThat(record.get(Field.REQUEST_COUNT_PER_SECOND).asLong(), 246 is(requestCountPerSecond)); 247 assertThat(record.get(Field.READ_REQUEST_COUNT_PER_SECOND).asLong(), 248 is(readRequestCountPerSecond)); 249 assertThat(record.get(Field.FILTERED_READ_REQUEST_COUNT_PER_SECOND).asLong(), 250 is(filteredReadRequestCountPerSecond)); 251 assertThat(record.get(Field.WRITE_REQUEST_COUNT_PER_SECOND).asLong(), 252 is(writeCountRequestPerSecond)); 253 assertThat(record.get(Field.STORE_FILE_SIZE).asSize(), is(storeFileSize)); 254 assertThat(record.get(Field.UNCOMPRESSED_STORE_FILE_SIZE).asSize(), 255 is(uncompressedStoreFileSize)); 256 assertThat(record.get(Field.NUM_STORE_FILES).asInt(), is(numStoreFiles)); 257 assertThat(record.get(Field.MEM_STORE_SIZE).asSize(), is(memStoreSize)); 258 assertThat(record.get(Field.LOCALITY).asFloat(), is(locality)); 259 assertThat(record.get(Field.START_KEY).asString(), is(startKey)); 260 assertThat(record.get(Field.COMPACTING_CELL_COUNT).asLong(), is(compactingCellCount)); 261 assertThat(record.get(Field.COMPACTED_CELL_COUNT).asLong(), is(compactedCellCount)); 262 assertThat(record.get(Field.COMPACTION_PROGRESS).asFloat(), is(compactionProgress)); 263 assertThat(record.get(Field.LAST_MAJOR_COMPACTION_TIME).asString(), 264 is(lastMajorCompactionTime)); 265 } 266 267 public static void assertRecordsInNamespaceMode(List<Record> records) { 268 assertThat(records.size(), is(2)); 269 270 for (Record record : records) { 271 switch (record.get(Field.NAMESPACE).asString()) { 272 case "default": 273 assertRecordInNamespaceMode(record, 0L, 0L, 0L, 0L, new Size(600, Size.Unit.MEGABYTE), 274 new Size(1200, Size.Unit.MEGABYTE), 6, new Size(600, Size.Unit.MEGABYTE), 4); 275 break; 276 277 case "namespace": 278 assertRecordInNamespaceMode(record, 0L, 0L, 0L, 0L, new Size(600, Size.Unit.MEGABYTE), 279 new Size(1200, Size.Unit.MEGABYTE), 6, new Size(600, Size.Unit.MEGABYTE), 2); 280 break; 281 282 default: 283 fail(); 284 } 285 } 286 } 287 288 private static void assertRecordInNamespaceMode(Record record, long requestCountPerSecond, 289 long readRequestCountPerSecond, long filteredReadRequestCountPerSecond, 290 long writeCountRequestPerSecond, Size storeFileSize, Size uncompressedStoreFileSize, 291 int numStoreFiles, Size memStoreSize, int regionCount) { 292 assertThat(record.size(), is(10)); 293 assertThat(record.get(Field.REQUEST_COUNT_PER_SECOND).asLong(), 294 is(requestCountPerSecond)); 295 assertThat(record.get(Field.READ_REQUEST_COUNT_PER_SECOND).asLong(), 296 is(readRequestCountPerSecond)); 297 assertThat(record.get(Field.FILTERED_READ_REQUEST_COUNT_PER_SECOND).asLong(), 298 is(filteredReadRequestCountPerSecond)); 299 assertThat(record.get(Field.WRITE_REQUEST_COUNT_PER_SECOND).asLong(), 300 is(writeCountRequestPerSecond)); 301 assertThat(record.get(Field.STORE_FILE_SIZE).asSize(), is(storeFileSize)); 302 assertThat(record.get(Field.UNCOMPRESSED_STORE_FILE_SIZE).asSize(), 303 is(uncompressedStoreFileSize)); 304 assertThat(record.get(Field.NUM_STORE_FILES).asInt(), is(numStoreFiles)); 305 assertThat(record.get(Field.MEM_STORE_SIZE).asSize(), is(memStoreSize)); 306 assertThat(record.get(Field.REGION_COUNT).asInt(), is(regionCount)); 307 } 308 309 public static void assertRecordsInTableMode(List<Record> records) { 310 assertThat(records.size(), is(3)); 311 312 for (Record record : records) { 313 String tableName = String.format("%s:%s", record.get(Field.NAMESPACE).asString(), 314 record.get(Field.TABLE).asString()); 315 316 switch (tableName) { 317 case "default:table1": 318 assertRecordInTableMode(record, 0L, 0L, 0L, 0L, new Size(200, Size.Unit.MEGABYTE), 319 new Size(400, Size.Unit.MEGABYTE), 2, new Size(200, Size.Unit.MEGABYTE), 2); 320 break; 321 322 case "default:table2": 323 assertRecordInTableMode(record, 0L, 0L, 0L, 0L, new Size(400, Size.Unit.MEGABYTE), 324 new Size(800, Size.Unit.MEGABYTE), 4, new Size(400, Size.Unit.MEGABYTE), 2); 325 break; 326 327 case "namespace:table3": 328 assertRecordInTableMode(record, 0L, 0L, 0L, 0L, new Size(600, Size.Unit.MEGABYTE), 329 new Size(1200, Size.Unit.MEGABYTE), 6, new Size(600, Size.Unit.MEGABYTE), 2); 330 break; 331 332 default: 333 fail(); 334 } 335 } 336 } 337 338 public static void assertRecordsInUserMode(List<Record> records) { 339 assertThat(records.size(), is(2)); 340 for (Record record : records) { 341 String user = record.get(Field.USER).asString(); 342 switch (user) { 343 //readRequestPerSecond and writeRequestPerSecond will be zero 344 // because there is no change or new metrics during refresh 345 case "FOO": 346 assertRecordInUserMode(record, 0L, 0L, 0L); 347 break; 348 case "BAR": 349 assertRecordInUserMode(record, 0L, 0L, 0L); 350 break; 351 default: 352 fail(); 353 } 354 } 355 } 356 357 public static void assertRecordsInClientMode(List<Record> records) { 358 assertThat(records.size(), is(4)); 359 for (Record record : records) { 360 String client = record.get(Field.CLIENT).asString(); 361 switch (client) { 362 //readRequestPerSecond and writeRequestPerSecond will be zero 363 // because there is no change or new metrics during refresh 364 case "CLIENT_A_FOO": 365 assertRecordInClientMode(record, 0L, 0L, 0L); 366 break; 367 case "CLIENT_A_BAR": 368 assertRecordInClientMode(record, 0L, 0L, 0L); 369 break; 370 case "CLIENT_B_FOO": 371 assertRecordInClientMode(record, 0L, 0L, 0L); 372 break; 373 case "CLIENT_B_BAR": 374 assertRecordInClientMode(record, 0L, 0L, 0L); 375 break; 376 default: 377 fail(); 378 } 379 } 380 } 381 382 private static void assertRecordInUserMode(Record record, long readRequestCountPerSecond, 383 long writeCountRequestPerSecond, long filteredReadRequestsCount) { 384 assertThat(record.size(), is(6)); 385 assertThat(record.get(Field.READ_REQUEST_COUNT_PER_SECOND).asLong(), 386 is(readRequestCountPerSecond)); 387 assertThat(record.get(Field.WRITE_REQUEST_COUNT_PER_SECOND).asLong(), 388 is(writeCountRequestPerSecond)); 389 assertThat(record.get(Field.FILTERED_READ_REQUEST_COUNT_PER_SECOND).asLong(), 390 is(filteredReadRequestsCount)); 391 assertThat(record.get(Field.CLIENT_COUNT).asInt(), is(2)); 392 } 393 394 private static void assertRecordInClientMode(Record record, long readRequestCountPerSecond, 395 long writeCountRequestPerSecond, long filteredReadRequestsCount) { 396 assertThat(record.size(), is(6)); 397 assertThat(record.get(Field.READ_REQUEST_COUNT_PER_SECOND).asLong(), 398 is(readRequestCountPerSecond)); 399 assertThat(record.get(Field.WRITE_REQUEST_COUNT_PER_SECOND).asLong(), 400 is(writeCountRequestPerSecond)); 401 assertThat(record.get(Field.FILTERED_READ_REQUEST_COUNT_PER_SECOND).asLong(), 402 is(filteredReadRequestsCount)); 403 assertThat(record.get(Field.USER_COUNT).asInt(), is(1)); 404 } 405 406 private static void assertRecordInTableMode(Record record, long requestCountPerSecond, 407 long readRequestCountPerSecond, long filteredReadRequestCountPerSecond, 408 long writeCountRequestPerSecond, Size storeFileSize, Size uncompressedStoreFileSize, 409 int numStoreFiles, Size memStoreSize, int regionCount) { 410 assertThat(record.size(), is(11)); 411 assertThat(record.get(Field.REQUEST_COUNT_PER_SECOND).asLong(), 412 is(requestCountPerSecond)); 413 assertThat(record.get(Field.READ_REQUEST_COUNT_PER_SECOND).asLong(), 414 is(readRequestCountPerSecond)); 415 assertThat(record.get(Field.FILTERED_READ_REQUEST_COUNT_PER_SECOND).asLong(), 416 is(filteredReadRequestCountPerSecond)); 417 assertThat(record.get(Field.WRITE_REQUEST_COUNT_PER_SECOND).asLong(), 418 is(writeCountRequestPerSecond)); 419 assertThat(record.get(Field.STORE_FILE_SIZE).asSize(), is(storeFileSize)); 420 assertThat(record.get(Field.UNCOMPRESSED_STORE_FILE_SIZE).asSize(), 421 is(uncompressedStoreFileSize)); 422 assertThat(record.get(Field.NUM_STORE_FILES).asInt(), is(numStoreFiles)); 423 assertThat(record.get(Field.MEM_STORE_SIZE).asSize(), is(memStoreSize)); 424 assertThat(record.get(Field.REGION_COUNT).asInt(), is(regionCount)); 425 } 426 427 public static void assertRecordsInRegionServerMode(List<Record> records) { 428 assertThat(records.size(), is(2)); 429 430 for (Record record : records) { 431 switch (record.get(Field.REGION_SERVER).asString()) { 432 case "host1:1000": 433 assertRecordInRegionServerMode(record, "host1.apache.com,1000,1", 0L, 0L, 0L, 0L, 434 new Size(600, Size.Unit.MEGABYTE), new Size(1200, Size.Unit.MEGABYTE), 6, 435 new Size(600, Size.Unit.MEGABYTE), 3, new Size(100, Size.Unit.MEGABYTE), 436 new Size(200, Size.Unit.MEGABYTE)); 437 break; 438 439 case "host2:1001": 440 assertRecordInRegionServerMode(record, "host2.apache.com,1001,2", 0L, 0L, 0L, 0L, 441 new Size(600, Size.Unit.MEGABYTE), new Size(1200, Size.Unit.MEGABYTE), 6, 442 new Size(600, Size.Unit.MEGABYTE), 3, new Size(16, Size.Unit.GIGABYTE), 443 new Size(32, Size.Unit.GIGABYTE)); 444 break; 445 446 default: 447 fail(); 448 } 449 } 450 } 451 452 private static void assertRecordInRegionServerMode(Record record, String longRegionServer, 453 long requestCountPerSecond, long readRequestCountPerSecond, 454 long filteredReadRequestCountPerSecond, long writeCountRequestPerSecond, 455 Size storeFileSize, Size uncompressedStoreFileSize, int numStoreFiles, 456 Size memStoreSize, int regionCount, Size usedHeapSize, Size maxHeapSize) { 457 assertThat(record.size(), is(13)); 458 assertThat(record.get(Field.LONG_REGION_SERVER).asString(), 459 is(longRegionServer)); 460 assertThat(record.get(Field.REQUEST_COUNT_PER_SECOND).asLong(), 461 is(requestCountPerSecond)); 462 assertThat(record.get(Field.READ_REQUEST_COUNT_PER_SECOND).asLong(), 463 is(readRequestCountPerSecond)); 464 assertThat(record.get(Field.FILTERED_READ_REQUEST_COUNT_PER_SECOND).asLong(), 465 is(filteredReadRequestCountPerSecond)); 466 assertThat(record.get(Field.WRITE_REQUEST_COUNT_PER_SECOND).asLong(), 467 is(writeCountRequestPerSecond)); 468 assertThat(record.get(Field.STORE_FILE_SIZE).asSize(), is(storeFileSize)); 469 assertThat(record.get(Field.UNCOMPRESSED_STORE_FILE_SIZE).asSize(), 470 is(uncompressedStoreFileSize)); 471 assertThat(record.get(Field.NUM_STORE_FILES).asInt(), is(numStoreFiles)); 472 assertThat(record.get(Field.MEM_STORE_SIZE).asSize(), is(memStoreSize)); 473 assertThat(record.get(Field.REGION_COUNT).asInt(), is(regionCount)); 474 assertThat(record.get(Field.USED_HEAP_SIZE).asSize(), is(usedHeapSize)); 475 assertThat(record.get(Field.MAX_HEAP_SIZE).asSize(), is(maxHeapSize)); 476 } 477 478 public static void assertSummary(Summary summary) { 479 assertThat(summary.getVersion(), is("3.0.0-SNAPSHOT")); 480 assertThat(summary.getClusterId(), is("01234567-89ab-cdef-0123-456789abcdef")); 481 assertThat(summary.getServers(), is(3)); 482 assertThat(summary.getLiveServers(), is(2)); 483 assertThat(summary.getDeadServers(), is(1)); 484 assertThat(summary.getRegionCount(), is(6)); 485 assertThat(summary.getRitCount(), is(1)); 486 assertThat(summary.getAverageLoad(), is(3.0)); 487 assertThat(summary.getAggregateRequestPerSecond(), is(300L)); 488 } 489}