use of voldemort.store.stats.StatTrackingStore in project voldemort by voldemort.
the class RoutedStoreTest method testNoReadRepair.
/**
* See Issue #211: Unnecessary read repairs during getAll with more than one
* key
*/
@Test
public void testNoReadRepair() throws Exception {
cluster = VoldemortTestConstants.getThreeNodeCluster();
StoreDefinition storeDef = ServerTestUtils.getStoreDef("test", 3, 2, 1, 3, 2, RoutingStrategyType.CONSISTENT_STRATEGY);
Map<Integer, Store<ByteArray, byte[], byte[]>> subStores = Maps.newHashMap();
/* We just need to keep a store from one node */
StatTrackingStore statTrackingStore = null;
for (int i = 0; i < 3; ++i) {
int id = Iterables.get(cluster.getNodes(), i).getId();
statTrackingStore = new StatTrackingStore(new InMemoryStorageEngine<ByteArray, byte[], byte[]>("test"), null);
subStores.put(id, statTrackingStore);
}
setFailureDetector(subStores);
routedStoreThreadPool = Executors.newFixedThreadPool(1);
RoutedStoreFactory routedStoreFactory = createFactory();
RoutedStore routedStore = routedStoreFactory.create(cluster, storeDef, subStores, failureDetector, createConfig(BANNAGE_PERIOD));
ByteArray key1 = aKey;
routedStore.put(key1, Versioned.value("value1".getBytes()), null);
ByteArray key2 = TestUtils.toByteArray("voldemort");
routedStore.put(key2, Versioned.value("value2".getBytes()), null);
long putCount = statTrackingStore.getStats().getCount(Tracked.PUT);
routedStore.getAll(Arrays.asList(key1, key2), null);
/* Read repair happens asynchronously, so we wait a bit */
Thread.sleep(500);
assertEquals("put count should remain the same if there are no read repairs", putCount, statTrackingStore.getStats().getCount(Tracked.PUT));
}
use of voldemort.store.stats.StatTrackingStore in project voldemort by voldemort.
the class StatusServlet method outputJSON.
protected void outputJSON(HttpServletResponse response) {
StringBuilder sb = new StringBuilder("{\n");
sb.append(" \"servertime\": \"");
sb.append(new Date());
sb.append("\",");
sb.append("\n \"server\": \"");
sb.append(myMachine);
sb.append("\",");
sb.append("\n \"node\": \"");
sb.append(server.getMetadataStore().getNodeId());
sb.append("\",");
sb.append("\n \"uptime\": \"");
sb.append(abstractSocketService.getStatusManager().getFormattedUptime());
sb.append("\",");
sb.append("\n \"num_workers\": ");
sb.append(abstractSocketService.getStatusManager().getActiveWorkersCount());
sb.append(",");
sb.append("\n \"pool_size\": ");
sb.append(abstractSocketService.getStatusManager().getWorkerPoolSize());
sb.append(",");
sb.append("\n \"stores\": {");
int i = 0;
for (Store<ByteArray, byte[], byte[]> store : server.getStoreRepository().getAllLocalStores()) {
if (i++ > 0) {
sb.append(",");
}
sb.append("\n \"");
sb.append(store.getName());
sb.append("\" : {\n");
if (store instanceof StatTrackingStore) {
StatTrackingStore statStore = (StatTrackingStore) store;
Map<Tracked, RequestCounter> stats = statStore.getStats().getCounters();
for (Tracked t : Tracked.values()) {
if (t == Tracked.EXCEPTION) {
continue;
}
sb.append(fillCommonStats(stats, t));
}
sb.append(",\n \"num_exceptions\": ");
sb.append(statStore.getStats().getCount(Tracked.EXCEPTION));
sb.append("\n");
sb.append(" }");
}
if (store instanceof QuotaLimitingStore) {
QuotaLimitingStore quotaStore = (QuotaLimitingStore) store;
Map<Tracked, RequestCounter> stats = quotaStore.getStats().getCounters();
for (Tracked t : Tracked.values()) {
if (t == Tracked.EXCEPTION) {
continue;
}
sb.append(fillCommonStats(stats, t));
}
sb.append(",\n \"num_exceptions\": ");
sb.append(quotaStore.getStats().getCount(Tracked.EXCEPTION));
sb.append("\n");
sb.append(" }");
}
}
sb.append("\n }\n");
sb.append("}\n");
try {
response.setContentType("text/plain");
OutputStreamWriter writer = new OutputStreamWriter(response.getOutputStream());
writer.write(sb.toString());
writer.flush();
} catch (Exception e) {
throw new VoldemortException(e);
}
}
Aggregations