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 static org.junit.Assert.assertEquals;
22 import static org.junit.Assert.assertNotEquals;
23 import static org.junit.Assert.assertTrue;
24
25 import java.util.Map;
26
27 import org.apache.commons.math.stat.descriptive.DescriptiveStatistics;
28 import org.apache.hadoop.hbase.CompatibilitySingletonFactory;
29 import org.junit.Test;
30
31 public class TestMetricsRegionSourceImpl {
32
33 @Test
34 public void testCompareToHashCodeEquals() throws Exception {
35 MetricsRegionServerSourceFactory fact = CompatibilitySingletonFactory.getInstance(MetricsRegionServerSourceFactory.class);
36
37 MetricsRegionSource one = fact.createRegion(new RegionWrapperStub("TEST"));
38 MetricsRegionSource oneClone = fact.createRegion(new RegionWrapperStub("TEST"));
39 MetricsRegionSource two = fact.createRegion(new RegionWrapperStub("TWO"));
40
41 assertEquals(0, one.compareTo(oneClone));
42 assertEquals(one.hashCode(), oneClone.hashCode());
43 assertNotEquals(one, two);
44
45 assertTrue( one.compareTo(two) < 0);
46 assertTrue( two.compareTo(one) > 0);
47 }
48
49
50 @Test(expected = RuntimeException.class)
51 public void testNoGetRegionServerMetricsSourceImpl() throws Exception {
52
53
54 CompatibilitySingletonFactory.getInstance(MetricsRegionSource.class);
55 }
56
57 static class RegionWrapperStub implements MetricsRegionWrapper {
58
59 private String regionName;
60
61 public RegionWrapperStub(String regionName) {
62
63
64 this.regionName = regionName;
65 }
66
67 @Override
68 public String getTableName() {
69 return null;
70 }
71
72 @Override
73 public String getNamespace() {
74 return null;
75 }
76
77 @Override
78 public String getRegionName() {
79 return this.regionName;
80 }
81
82 @Override
83 public long getNumStores() {
84 return 0;
85 }
86
87 @Override
88 public long getNumStoreFiles() {
89 return 0;
90 }
91
92 @Override
93 public long getMemstoreSize() {
94 return 0;
95 }
96
97 @Override
98 public long getStoreFileSize() {
99 return 0;
100 }
101
102 @Override
103 public long getReadRequestCount() {
104 return 0;
105 }
106
107 @Override
108 public long getWriteRequestCount() {
109 return 0;
110 }
111
112 @Override
113 public long getNumFilesCompacted() {
114 return 0;
115 }
116
117 @Override
118 public long getNumBytesCompacted() {
119 return 0;
120 }
121
122 @Override
123 public long getNumCompactionsCompleted() {
124 return 0;
125 }
126
127 @Override
128 public Map<String, DescriptiveStatistics> getCoprocessorExecutionStatistics() {
129 return null;
130 }
131 }
132 }