|
23 | 23 | import com.codahale.metrics.Timer; |
24 | 24 | import org.apache.jackrabbit.oak.commons.concurrent.ExecutorCloser; |
25 | 25 | import org.apache.jackrabbit.oak.plugins.metric.MetricStatisticsProvider; |
| 26 | +import org.apache.jackrabbit.oak.stats.CounterStats; |
26 | 27 | import org.apache.jackrabbit.oak.stats.MeterStats; |
27 | 28 | import org.junit.After; |
28 | 29 | import org.junit.Test; |
|
34 | 35 | import static java.util.concurrent.TimeUnit.MILLISECONDS; |
35 | 36 | import static java.util.concurrent.TimeUnit.NANOSECONDS; |
36 | 37 | import static org.apache.commons.lang3.reflect.FieldUtils.readField; |
| 38 | +import static org.apache.jackrabbit.oak.plugins.document.FullGCStatsCollectorImpl.BATCH_SIZE; |
37 | 39 | import static org.apache.jackrabbit.oak.plugins.document.FullGCStatsCollectorImpl.COLLECT_DELETED_OLD_REVS_TIMER; |
38 | 40 | import static org.apache.jackrabbit.oak.plugins.document.FullGCStatsCollectorImpl.COLLECT_DELETED_PROPS_TIMER; |
39 | 41 | import static org.apache.jackrabbit.oak.plugins.document.FullGCStatsCollectorImpl.COLLECT_FULL_GC_TIMER; |
40 | 42 | import static org.apache.jackrabbit.oak.plugins.document.FullGCStatsCollectorImpl.COLLECT_ORPHAN_NODES_TIMER; |
41 | 43 | import static org.apache.jackrabbit.oak.plugins.document.FullGCStatsCollectorImpl.COLLECT_UNMERGED_BC_TIMER; |
42 | 44 | import static org.apache.jackrabbit.oak.plugins.document.FullGCStatsCollectorImpl.COUNTER; |
| 45 | +import static org.apache.jackrabbit.oak.plugins.document.FullGCStatsCollectorImpl.DELAY_FACTOR; |
43 | 46 | import static org.apache.jackrabbit.oak.plugins.document.FullGCStatsCollectorImpl.DELETED_ORPHAN_NODE; |
44 | 47 | import static org.apache.jackrabbit.oak.plugins.document.FullGCStatsCollectorImpl.DELETED_PROPERTY; |
45 | 48 | import static org.apache.jackrabbit.oak.plugins.document.FullGCStatsCollectorImpl.DELETED_UNMERGED_BC; |
46 | 49 | import static org.apache.jackrabbit.oak.plugins.document.FullGCStatsCollectorImpl.DELETE_FULL_GC_DOCS_TIMER; |
| 50 | +import static org.apache.jackrabbit.oak.plugins.document.FullGCStatsCollectorImpl.EMBEDDED_VERIFICATION_ENABLED; |
| 51 | +import static org.apache.jackrabbit.oak.plugins.document.FullGCStatsCollectorImpl.ENABLED; |
47 | 52 | import static org.apache.jackrabbit.oak.plugins.document.FullGCStatsCollectorImpl.FULL_GC; |
48 | 53 | import static org.apache.jackrabbit.oak.plugins.document.FullGCStatsCollectorImpl.FULL_GC_ACTIVE_TIMER; |
49 | 54 | import static org.apache.jackrabbit.oak.plugins.document.FullGCStatsCollectorImpl.FULL_GC_TIMER; |
50 | 55 | import static org.apache.jackrabbit.oak.plugins.document.FullGCStatsCollectorImpl.FAILURE_COUNTER; |
| 56 | +import static org.apache.jackrabbit.oak.plugins.document.FullGCStatsCollectorImpl.MAX_AGE; |
| 57 | +import static org.apache.jackrabbit.oak.plugins.document.FullGCStatsCollectorImpl.MODE; |
| 58 | +import static org.apache.jackrabbit.oak.plugins.document.FullGCStatsCollectorImpl.PROGRESS_SIZE; |
51 | 59 | import static org.apache.jackrabbit.oak.plugins.document.FullGCStatsCollectorImpl.READ_DOC; |
52 | 60 | import static org.apache.jackrabbit.oak.plugins.document.FullGCStatsCollectorImpl.SKIPPED_DOC; |
53 | 61 | import static org.apache.jackrabbit.oak.plugins.document.FullGCStatsCollectorImpl.UPDATED_DOC; |
@@ -164,6 +172,71 @@ public void counters() { |
164 | 172 | assertEquals(1, failureCounter.getCount()); |
165 | 173 | } |
166 | 174 |
|
| 175 | + @Test |
| 176 | + public void getEnabled() throws IllegalAccessException { |
| 177 | + final Counter c = getCounter(ENABLED); |
| 178 | + long count = c.getCount(); |
| 179 | + stats.enabled(); |
| 180 | + assertEquals(count + 1, c.getCount()); |
| 181 | + assertEquals(count + 1, ((CounterStats) readField(stats, "enabled", true)).getCount()); |
| 182 | + } |
| 183 | + |
| 184 | + @Test |
| 185 | + public void getMode() throws IllegalAccessException { |
| 186 | + final Counter c = getCounter(MODE); |
| 187 | + long count = c.getCount(); |
| 188 | + stats.mode(4); |
| 189 | + assertEquals(count + 4, c.getCount()); |
| 190 | + assertEquals(count + 4, ((CounterStats) readField(stats, "mode", true)).getCount()); |
| 191 | + } |
| 192 | + |
| 193 | + @Test |
| 194 | + public void getDelayFactor() throws IllegalAccessException { |
| 195 | + final Counter c = getCounter(DELAY_FACTOR); |
| 196 | + long count = c.getCount(); |
| 197 | + stats.delayFactor(4.0); |
| 198 | + assertEquals(count + 4, c.getCount()); |
| 199 | + assertEquals(count + 4, ((CounterStats) readField(stats, "delayFactor", true)).getCount()); |
| 200 | + } |
| 201 | + |
| 202 | + @Test |
| 203 | + public void getBatchSize() throws IllegalAccessException { |
| 204 | + final Counter c = getCounter(BATCH_SIZE); |
| 205 | + long count = c.getCount(); |
| 206 | + stats.batchSize(400); |
| 207 | + assertEquals(count + 400, c.getCount()); |
| 208 | + assertEquals(count + 400, ((CounterStats) readField(stats, "batchSize", true)).getCount()); |
| 209 | + } |
| 210 | + |
| 211 | + @Test |
| 212 | + public void getProgressSize() throws IllegalAccessException { |
| 213 | + final Counter c = getCounter(PROGRESS_SIZE); |
| 214 | + long count = c.getCount(); |
| 215 | + stats.progressSize(4000); |
| 216 | + assertEquals(count + 4000, c.getCount()); |
| 217 | + assertEquals(count + 4000, ((CounterStats) readField(stats, "progressSize", true)).getCount()); |
| 218 | + } |
| 219 | + |
| 220 | + @Test |
| 221 | + public void getEmbeddedVerificationEnabled() throws IllegalAccessException { |
| 222 | + final Counter c = getCounter(EMBEDDED_VERIFICATION_ENABLED); |
| 223 | + long count = c.getCount(); |
| 224 | + stats.verificationEnabled(); |
| 225 | + assertEquals(count + 1, c.getCount()); |
| 226 | + assertEquals(count + 1, ((CounterStats) readField(stats, "embeddedVerificationEnabled", true)).getCount()); |
| 227 | + } |
| 228 | + |
| 229 | + @Test |
| 230 | + public void getMaxAge() throws IllegalAccessException { |
| 231 | + final Counter c = getCounter(MAX_AGE); |
| 232 | + long count = c.getCount(); |
| 233 | + stats.maxAge(86400); |
| 234 | + assertEquals(count + 86400, c.getCount()); |
| 235 | + assertEquals(count + 86400, ((CounterStats) readField(stats, "maxAge", true)).getCount()); |
| 236 | + } |
| 237 | + |
| 238 | + // helper methods |
| 239 | + |
167 | 240 | private void assertTimer(long expected, String name) { |
168 | 241 | assertEquals(expected, NANOSECONDS.toMillis(getTimer(name).getSnapshot().getMax())); |
169 | 242 | } |
|
0 commit comments