1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.hadoop.hbase.regionserver;
20
21 import org.apache.hadoop.hbase.CompatibilitySingletonFactory;
22 import org.junit.Test;
23
24 import static org.junit.Assert.assertEquals;
25 import static org.junit.Assert.assertTrue;
26
27 public class TestMetricsRegionSourceImpl {
28
29 @Test
30 public void testCompareTo() throws Exception {
31 MetricsRegionServerSourceFactory fact = CompatibilitySingletonFactory.getInstance(MetricsRegionServerSourceFactory.class);
32
33 MetricsRegionSource one = fact.createRegion(new RegionWrapperStub("TEST"));
34 MetricsRegionSource oneClone = fact.createRegion(new RegionWrapperStub("TEST"));
35 MetricsRegionSource two = fact.createRegion(new RegionWrapperStub("TWO"));
36
37 assertEquals(0, one.compareTo(oneClone));
38
39 assertTrue( one.compareTo(two) < 0);
40 assertTrue( two.compareTo(one) > 0);
41 }
42
43
44 @Test(expected = RuntimeException.class)
45 public void testNoGetRegionServerMetricsSourceImpl() throws Exception {
46
47
48 CompatibilitySingletonFactory.getInstance(MetricsRegionSource.class);
49 }
50
51 class RegionWrapperStub implements MetricsRegionWrapper {
52
53 private String regionName;
54
55 public RegionWrapperStub(String regionName) {
56
57
58 this.regionName = regionName;
59 }
60
61 @Override
62 public String getTableName() {
63 return null;
64 }
65
66 @Override
67 public String getRegionName() {
68 return this.regionName;
69 }
70
71 @Override
72 public long getNumStores() {
73 return 0;
74 }
75
76 @Override
77 public long getNumStoreFiles() {
78 return 0;
79 }
80
81 @Override
82 public long getMemstoreSize() {
83 return 0;
84 }
85
86 @Override
87 public long getStoreFileSize() {
88 return 0;
89 }
90
91 @Override
92 public long getReadRequestCount() {
93 return 0;
94 }
95
96 @Override
97 public long getWriteRequestCount() {
98 return 0;
99 }
100 }
101 }