Package org.apache.sirona.math

Examples of org.apache.sirona.math.M2AwareStatisticalSummary


        } else if (n == 1) {
            variance = 0d;
        } else {
            variance = m2 / (n - 1);
        }
        return new M2AwareStatisticalSummary(mean, variance, n, max, min, sum, m2);
    }
View Full Code Here


    @Override
    public void reset() {
        final Lock workLock = lock.writeLock();
        workLock.lock();
        try {
            statistics = new M2AwareStatisticalSummary(Double.NaN, Double.NaN, 0, Double.NaN, Double.NaN, Double.NaN, Double.NaN);
        } finally {
            workLock.unlock();
        }
    }
View Full Code Here

    public void counterStore() {
        final Counter.Key key = new Counter.Key(new Role("r", Unit.UNARY), "n");

        // note: the input data are maybe not that consistent (min > max) but this test just checks computations
        final CollectorCounterStore store = new InMemoryCollectorCounterStore();
        store.update(key, "client1", new M2AwareStatisticalSummary(1, 2, 5, 0, 10, 6, 7), 4);
        store.update(key, "client2", new M2AwareStatisticalSummary(2, 4, 8, 1, 15, 9, 5), 2);

        assertEquals(2, store.markers().size());
        assertTrue(store.markers().contains("client1"));
        assertTrue(store.markers().contains("client2"));
View Full Code Here

    protected CassandraLeafCounter counter(final Counter.Key ckey,
                                           final DynamicDelegatedSerializer<Object> serializer,
                                           final ColumnSlice<String, Object> map,
                                           final String marker) {
        return new CassandraLeafCounter(ckey, this, marker)
            .sync(new M2AwareStatisticalSummary(
                getOrDefault( serializer, map.getColumnByName( "mean" ), DoubleSerializer.get() ).doubleValue(),
                getOrDefault( serializer, map.getColumnByName( "variance" ), DoubleSerializer.get() ).doubleValue(),
                getOrDefault( serializer, map.getColumnByName( "n" ), LongSerializer.get() ).longValue(),
                getOrDefault( serializer, map.getColumnByName( "max" ), DoubleSerializer.get() ).doubleValue(),
                getOrDefault( serializer, map.getColumnByName( "min" ), DoubleSerializer.get() ).doubleValue(),
View Full Code Here

    @Override
    protected void pushCountersByBatch(final Collection<Counter> instances) {
        for (final Counter counter : instances) {
            delegate.getOrCreateCounter(counter.getKey(), marker)
                .update(new M2AwareStatisticalSummary(
                        counter.getMean(), counter.getVariance(), counter.getHits(),
                        counter.getMax(), counter.getMin(), counter.getSum(), counter.getSecondMoment()),
                    counter.currentConcurrency().get());
        }
    }
View Full Code Here

        }

        @Override
        public void run() {
            for (final Counter aggregate : aggregator.getCounters()) {
                final M2AwareStatisticalSummary stats = new M2AwareStatisticalSummary(
                    aggregate.getMean(), aggregate.getVariance(), aggregate.getHits(),
                    aggregate.getMax(), aggregate.getMin(), aggregate.getSum(),
                    aggregate.getSecondMoment()
                );
                collectorCounterStore.update(aggregate.getKey(), BOOMERANG_MARKER, stats, aggregate.getMaxConcurrency());
View Full Code Here

    @Test
    public void getAggregatedCountersByKey() {
        final Counter.Key key = new Counter.Key(new Role("cassandra", Unit.MEGA), "k");
        final CassandraCollectorCounterDataStore store = new CassandraCollectorCounterDataStore();
        final CassandraLeafCounter counter1 = new CassandraLeafCounter(key, store, "node1").sync(new M2AwareStatisticalSummary(1, 1, 1, 1, 1, 1, 1), 1);
        final CassandraLeafCounter counter2 = new CassandraLeafCounter(key, store, "node2").sync(new M2AwareStatisticalSummary(3, 4, 4, 4, 4, 4, 4), 2);

        new CassandraCollectorCounterDataStore().getOrCreateCounter(key, "node1").update(counter1.getStatistics(), counter1.getMaxConcurrency());
        new CassandraCollectorCounterDataStore().getOrCreateCounter(key, "node2").update(counter2.getStatistics(), counter2.getMaxConcurrency());

        final AggregatedCollectorCounter aggregation = new CassandraCollectorCounterDataStore().getOrCreateCounter(key);
View Full Code Here

    @Test
    public void getAggregatedCounters() {
        final Counter.Key key1 = new Counter.Key(new Role("cassandra", Unit.MEGA), "k1");
        final Counter.Key key2 = new Counter.Key(new Role("cassandra", Unit.MEGA), "k2");

        new CassandraCollectorCounterDataStore().getOrCreateCounter(key1, "node1").update(new M2AwareStatisticalSummary(1, 1, 1, 1, 1, 1, 1), 1);
        new CassandraCollectorCounterDataStore().getOrCreateCounter(key1, "node2").update(new M2AwareStatisticalSummary(3, 4, 4, 4, 4, 4, 4), 2);
        new CassandraCollectorCounterDataStore().getOrCreateCounter(key2, "node1").update(new M2AwareStatisticalSummary(1, 1, 1, 1, 1, 1, 1), 1);
        new CassandraCollectorCounterDataStore().getOrCreateCounter(key2, "node2").update(new M2AwareStatisticalSummary(3, 4, 4, 4, 4, 4, 4), 2);

        final Collection<Counter> aggregations = new CassandraCollectorCounterDataStore().getCounters();
        assertEquals(2, aggregations.size());

        for (final Counter aggregation : aggregations) {
View Full Code Here

    public void update() {
        final Counter.Key key = new Counter.Key(new Role("K100Drap", Unit.UNARY), "K100Drap#1");

        new CassandraCollectorCounterDataStore().getOrCreateCounter(key, "node1");
        assertNotNull(new CassandraCollectorCounterDataStore().findByKey(key, "node1"));
        new CassandraCollectorCounterDataStore().update(key, "node1", new M2AwareStatisticalSummary(3, 4, 4, 4, 4, 4, 4), 2);

        final LeafCollectorCounter counter = new CassandraCollectorCounterDataStore().getOrCreateCounter(key, "node1");
        assertEquals("K100Drap#1", counter.getKey().getName());
        assertEquals("K100Drap", counter.getKey().getRole().getName());
        assertEquals(4, counter.getMax(), 0.);
View Full Code Here

    private void updateCounter(final Event event) {
        final Map<String, Object> data = event.getData();

        counterDataStore.update( new Counter.Key( role( data ), String.class.cast( data.get( "name" ) ) ),
                                 String.class.cast( data.get( "marker" ) ), new M2AwareStatisticalSummary( data ),
                                 Number.class.cast( data.get( "concurrency" ) ).intValue() );
    }
View Full Code Here

TOP

Related Classes of org.apache.sirona.math.M2AwareStatisticalSummary

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.