Package org.apache.sirona.counters

Examples of org.apache.sirona.counters.DefaultCounter


    protected ConcurrentMap<Counter.Key, Counter> newCounterMap() {
        return new ConcurrentHashMap<Counter.Key, Counter>(50);
    }

    protected Counter newCounter(final Counter.Key key) {
        return new DefaultCounter(key, this);
    }
View Full Code Here


    public void addToCounter(final Counter counter, final double delta) {
        if (!DefaultCounter.class.isInstance(counter)) {
            throw new IllegalArgumentException(getClass().getName() + " only supports " + DefaultCounter.class.getName());
        }

        final DefaultCounter defaultCounter = DefaultCounter.class.cast(counter);
        final Lock lock = defaultCounter.getLock().writeLock();
        lock.lock();
        try {
            defaultCounter.addInternal(delta);
        } finally {
            lock.unlock();
        }
    }
View Full Code Here

            this.counter = counter;
        }

        public synchronized void take() {
            if (called == 3 || called == -1) {
                final DefaultCounter defaultCounter = DefaultCounter.class.cast(counter);
                final Lock lock = defaultCounter.getLock().writeLock();
                lock.lock();
                try {
                    final OptimizedStatistics statistics = defaultCounter.getStatistics();
                    max = statistics.getMax();
                    sum = statistics.getSum();
                    hits = statistics.getN();
                    counter.reset();
                } finally {
View Full Code Here

    }

    private static class SeeMyProtectedStuffStore extends CubeCounterDataStore {
        public void doPush() {
            pushCountersByBatch(Arrays.<Counter>asList(
                new DefaultCounter(new Counter.Key(new Role("cube", Unit.UNARY), "client"), null) {
                    @Override
                    public long getHits() {
                        return 50;
                    }
                })
View Full Code Here

TOP

Related Classes of org.apache.sirona.counters.DefaultCounter

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.