Package org.apache.sirona.store.gauge

Examples of org.apache.sirona.store.gauge.CollectorGaugeDataStore


        if (!Environment.isCollector()) {
            final SortedMap<Long, Double> gaugeValues = Repository.INSTANCE.getGaugeValues(start, end, role);
            return "[" + Graphs.toJson(label, Graphs.DEFAULT_COLOR, aggregate(gaugeValues)) + "]";
        }

        final CollectorGaugeDataStore gaugeStore = IoCs.findOrCreateInstance(CollectorGaugeDataStore.class);
        final Iterator<String> markers = gaugeStore.markers().iterator();
        final StringBuilder builder = new StringBuilder("[");
        final Iterator<String> colors = COLORS.iterator();
        while (markers.hasNext()) {
            final String marker = markers.next();
            final String color;
            if (colors.hasNext()) {
                color = colors.next();
            } else {
                color = generateColor();
                COLORS.add(color);
            }

            final SortedMap<Long, Double> gaugeValues = gaugeStore.getGaugeValues(new GaugeValuesRequest(start, end, role), marker);
            builder.append(
                toJson(
                    label + " (" + marker + ")",
                    color,
                    aggregate(gaugeValues)
View Full Code Here


    @Test
    public void gaugeStore() {
        final Role role = new Role("gauge", Unit.UNARY);

        final CollectorGaugeDataStore store = new DelegatedCollectorGaugeDataStore();
        store.addToGauge(role, 1234, 5678, "client1");
        store.addToGauge(role, 987, 654, "client2");

        final GaugeValuesRequest request = new GaugeValuesRequest(0, Integer.MAX_VALUE, role);
        final Map<Long, Double> result = store.getGaugeValues(request);
        final Map<Long, Double> client1 = store.getGaugeValues(request, "client1");
        final Map<Long, Double> client2 = store.getGaugeValues(request, "client2");

        assertNotNull(result);
        assertNotNull(client1);
        assertNotNull(client2);
View Full Code Here

        // force init to ensure we have stores
        IoCs.findOrCreateInstance(Repository.class);

        {
            final CollectorGaugeDataStore gds = IoCs.findOrCreateInstance(CollectorGaugeDataStore.class);
            if (gds == null) {
                throw new IllegalStateException("Collector only works with " + CollectorGaugeDataStore.class.getName());
            }
            this.gaugeDataStore = CollectorGaugeDataStore.class.cast(gds);
        }
View Full Code Here

                    .build());
            }
            doPost(events2);
        }

        final CollectorGaugeDataStore store = IoCs.getInstance(CollectorGaugeDataStore.class);
        final GaugeValuesRequest gaugeValuesRequest = new GaugeValuesRequest(0, System.currentTimeMillis() + 1000, new Role("event-role", Unit.UNARY));
        final Map<Long, Double> aggregated = store.getGaugeValues(gaugeValuesRequest);
        final Map<Long, Double> node1 = store.getGaugeValues(gaugeValuesRequest, "node1");
        final Map<Long, Double> node2 = store.getGaugeValues(gaugeValuesRequest, "node2");
        assertEquals(1, aggregated.size());
        assertTrue(aggregated.containsValue(20.));
        assertTrue(node1.containsValue(5.));
        assertTrue(node2.containsValue(15.));
    }
View Full Code Here

        // force init to ensure we have stores
        IoCs.findOrCreateInstance(Repository.class);

        {
            final CollectorGaugeDataStore gds = IoCs.findOrCreateInstance(CollectorGaugeDataStore.class);
            if (gds == null) {
                throw new IllegalStateException("Collector only works with " + CollectorGaugeDataStore.class.getName());
            }
            this.gaugeDataStore = CollectorGaugeDataStore.class.cast(gds);
        }
View Full Code Here

TOP

Related Classes of org.apache.sirona.store.gauge.CollectorGaugeDataStore

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.