Package voldemort.store.stats

Examples of voldemort.store.stats.StatTrackingStore


                                                               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));
    }
View Full Code Here


        // First, the transport layer
        Store<ByteArray, byte[], byte[]> store = r2store;

        // TODO: Add identifierString to the Mbean name
        if(this.config.isEnableJmx()) {
            StatTrackingStore statStore = new StatTrackingStore(store, this.stats);
            store = statStore;
            JmxUtils.registerMbean(new StoreStatsJmx(statStore.getStats()),
                                   JmxUtils.createObjectName(JmxUtils.getPackageName(store.getClass()),
                                                             store.getName()));
        }

        // Add compression layer
View Full Code Here

        FileBackedCachingStorageEngine quotaStore = new FileBackedCachingStorageEngine("quota-usage-test-store",
                                                                                       tempDir.getAbsolutePath());
        InMemoryStorageEngine<ByteArray, byte[], byte[]> inMemoryEngine = new InMemoryStorageEngine<ByteArray, byte[], byte[]>("inMemoryBackingStore");
        QuotaLimitStats quotaStats = new QuotaLimitStats(null, 1000);
        StatTrackingStore statTrackingStore = new StatTrackingStore(inMemoryEngine, null);

        QuotaLimitingStore quotaLimitingStore = new QuotaLimitingStore(statTrackingStore,
                                                                       statTrackingStore.getStats(),
                                                                       quotaStats,
                                                                       quotaStore);

        int targetRate = 50;
        // provide a quota of 100 gets/sec
        quotaStore.put(new ByteArray(QuotaUtils.makeQuotaKey(statTrackingStore.getName(),
                                                             QuotaType.GET_THROUGHPUT).getBytes()),
                       new Versioned<byte[]>("100.0".getBytes()),
                       null);

        long testIntervalMs = 5000;
        long timeToSleepMs = 1000 / targetRate;
        long startMs = System.currentTimeMillis();
        ByteArray key = new ByteArray("some key".getBytes());
        while((System.currentTimeMillis() - startMs) <= testIntervalMs) {
            quotaLimitingStore.get(key, null);
            Thread.sleep(timeToSleepMs);
        }

        assertEquals("No get operations should be throttled", 0, quotaStats.getRateLimitedGets());
        assertEquals("Put usage should be 0", 0, quotaStats.getQuotaPctUsedPut());
        assertEquals("delete usage should be 0", 0, quotaStats.getQuotaPctUsedDelete());
        assertEquals("getall usage should be 0", 0, quotaStats.getQuotaPctUsedGetAll());

        assertEquals("Computed usage pct must be close to actual observed qps",
                     statTrackingStore.getStats().getThroughput(Tracked.GET),
                     quotaStats.getQuotaPctUsedGet(),
                     1.0);

    }
View Full Code Here

        if(voldemortConfig.isMetadataCheckingEnabled())
            store = new InvalidMetadataCheckingStore(metadata.getNodeId(), store, metadata);

        if(voldemortConfig.isStatTrackingEnabled()) {
            StatTrackingStore statStore = new StatTrackingStore(store, this.storeStats);
            store = statStore;
            if(voldemortConfig.isJmxEnabled()) {

                MBeanServer mbeanServer = ManagementFactory.getPlatformMBeanServer();
                ObjectName name = null;
                if(this.voldemortConfig.isEnableJmxClusterName())
                    name = JmxUtils.createObjectName(metadata.getCluster().getName()
                                                             + "."
                                                             + JmxUtils.getPackageName(store.getClass()),
                                                     store.getName());
                else
                    name = JmxUtils.createObjectName(JmxUtils.getPackageName(store.getClass()),
                                                     store.getName());

                synchronized(mbeanServer) {
                    if(mbeanServer.isRegistered(name))
                        JmxUtils.unregisterMbean(mbeanServer, name);

                    JmxUtils.registerMbean(mbeanServer,
                                           JmxUtils.createModelMBean(new StoreStatsJmx(statStore.getStats())),
                                           name);
                }
            }
        }
View Full Code Here

                store = new InvalidMetadataCheckingStore(metadata.getNodeId(), store, metadata);
            }
        }

        if(voldemortConfig.isStatTrackingEnabled()) {
            StatTrackingStore statStore = new StatTrackingStore(store, this.storeStats);
            store = statStore;
            if(voldemortConfig.isJmxEnabled()) {

                MBeanServer mbeanServer = ManagementFactory.getPlatformMBeanServer();
                ObjectName name = null;
                if(this.voldemortConfig.isEnableJmxClusterName())
                    name = JmxUtils.createObjectName(metadata.getCluster().getName()
                                                             + "."
                                                             + JmxUtils.getPackageName(store.getClass()),
                                                     store.getName());
                else
                    name = JmxUtils.createObjectName(JmxUtils.getPackageName(store.getClass()),
                                                     store.getName());

                synchronized(mbeanServer) {
                    if(mbeanServer.isRegistered(name))
                        JmxUtils.unregisterMbean(mbeanServer, name);

                    JmxUtils.registerMbean(mbeanServer,
                                           JmxUtils.createModelMBean(new StoreStatsJmx(statStore.getStats())),
                                           name);
                }
            }

            // Wrap everything under the rate limiting store (barring the
            // metadata store)
            if(voldemortConfig.isEnableQuotaLimiting() && !isMetadata) {
                StoreStats currentStoreStats = statStore.getStats();
                FileBackedCachingStorageEngine quotaStore = (FileBackedCachingStorageEngine) storeRepository.getStorageEngine(SystemStoreConstants.SystemStoreName.voldsys$_store_quotas.toString());
                QuotaLimitStats quotaStats = new QuotaLimitStats(this.aggregatedQuotaStats);
                QuotaLimitingStore rateLimitingStore = new QuotaLimitingStore(store,
                                                                              currentStoreStats,
                                                                              quotaStats,
View Full Code Here

        int i = 0;
        for(Store<ByteArray, byte[], byte[]> store: server.getStoreRepository().getAllLocalStores()) {

            if(store instanceof StatTrackingStore) {

                StatTrackingStore statStore = (StatTrackingStore) store;

                Map<Tracked, RequestCounter> stats = statStore.getStats().getCounters();

                if(i++ > 0) {
                    sb.append(",");
                }

                sb.append("\n    \"");
                sb.append(statStore.getName());
                sb.append("\" : {\n");

                int j = 0;

                for(Tracked t: Tracked.values()) {

                    if(t == Tracked.EXCEPTION) {
                        continue;
                    }

                    if(j++ > 0) {
                        sb.append(",\n");
                    }

                    sb.append("        \"");
                    sb.append(t.toString());
                    sb.append("\": { ");

                    sb.append("\"total\": ");
                    sb.append(stats.get(t).getTotalCount());
                    sb.append(", ");

                    sb.append("\"operations\": ");
                    sb.append(stats.get(t).getCount());
                    sb.append(", ");

                    sb.append("\"throughput\": ");
                    sb.append(stats.get(t).getDisplayThroughput());
                    sb.append(", ");

                    sb.append("\"avg_time_ms\": ");
                    sb.append(stats.get(t).getDisplayAverageTimeInMs());
                    sb.append(" }");
                }

                sb.append(",\n        \"num_exceptions\": ");
                sb.append(statStore.getStats().getCount(Tracked.EXCEPTION));
                sb.append("\n");

                sb.append("    }");
            }
        }
View Full Code Here

                                                                           this.routedStoreConfig);

        store = new LoggingStore(store);

        if(isJmxEnabled) {
            StatTrackingStore statStore = new StatTrackingStore(store, this.aggregateStats);
            store = statStore;
            JmxUtils.registerMbean(new StoreStatsJmx(statStore.getStats()),
                                   JmxUtils.createObjectName(JmxUtils.getPackageName(store.getClass()),
                                                             store.getName() + identifierString));
        }

        if(this.config.isEnableCompressionLayer()) {
View Full Code Here

TOP

Related Classes of voldemort.store.stats.StatTrackingStore

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.