Search in sources :

Example 6 with StatTrackingStore

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));
}
Also used : StatTrackingStore(voldemort.store.stats.StatTrackingStore) InMemoryStorageEngine(voldemort.store.memory.InMemoryStorageEngine) StoreDefinition(voldemort.store.StoreDefinition) Store(voldemort.store.Store) SleepyStore(voldemort.store.SleepyStore) StatTrackingStore(voldemort.store.stats.StatTrackingStore) InconsistencyResolvingStore(voldemort.store.versioned.InconsistencyResolvingStore) FailingStore(voldemort.store.FailingStore) FailingReadsStore(voldemort.store.FailingReadsStore) ByteArray(voldemort.utils.ByteArray) AbstractByteArrayStoreTest(voldemort.store.AbstractByteArrayStoreTest) Test(org.junit.Test)

Example 7 with StatTrackingStore

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);
    }
}
Also used : VoldemortException(voldemort.VoldemortException) Date(java.util.Date) ServletException(javax.servlet.ServletException) VoldemortException(voldemort.VoldemortException) IOException(java.io.IOException) UnknownHostException(java.net.UnknownHostException) StatTrackingStore(voldemort.store.stats.StatTrackingStore) Tracked(voldemort.store.stats.Tracked) RequestCounter(voldemort.store.stats.RequestCounter) ByteArray(voldemort.utils.ByteArray) QuotaLimitingStore(voldemort.store.quota.QuotaLimitingStore) OutputStreamWriter(java.io.OutputStreamWriter)

Aggregations

StatTrackingStore (voldemort.store.stats.StatTrackingStore)7 ByteArray (voldemort.utils.ByteArray)7 LoggingStore (voldemort.store.logging.LoggingStore)3 QuotaLimitingStore (voldemort.store.quota.QuotaLimitingStore)3 StoreStatsJmx (voldemort.store.stats.StoreStatsJmx)3 MBeanServer (javax.management.MBeanServer)2 ObjectName (javax.management.ObjectName)2 Test (org.junit.Test)2 Cluster (voldemort.cluster.Cluster)2 Serializer (voldemort.serialization.Serializer)2 SerializerDefinition (voldemort.serialization.SerializerDefinition)2 Store (voldemort.store.Store)2 StoreDefinition (voldemort.store.StoreDefinition)2 CompressingStore (voldemort.store.compress.CompressingStore)2 FileBackedCachingStorageEngine (voldemort.store.configuration.FileBackedCachingStorageEngine)2 InvalidMetadataCheckingStore (voldemort.store.invalidmetadata.InvalidMetadataCheckingStore)2 InMemoryStorageEngine (voldemort.store.memory.InMemoryStorageEngine)2 QuotaLimitStats (voldemort.store.quota.QuotaLimitStats)2 ChainedResolver (voldemort.versioning.ChainedResolver)2 Versioned (voldemort.versioning.Versioned)2