Search in sources :

Example 1 with StandardCounter

use of org.apache.nifi.controller.StandardCounter in project nifi by apache.

the class StandardCounterRepository method getModifiableCounter.

private Counter getModifiableCounter(final String counterContext, final String name) {
    ConcurrentMap<String, Counter> counters = processorCounters.get(counterContext);
    if (counters == null) {
        counters = new ConcurrentHashMap<>();
        final ConcurrentMap<String, Counter> oldProcessorCounters = processorCounters.putIfAbsent(counterContext, counters);
        if (oldProcessorCounters != null) {
            counters = oldProcessorCounters;
        }
    }
    Counter counter = counters.get(name);
    if (counter == null) {
        counter = new StandardCounter(getIdentifier(counterContext, name), counterContext, name);
        final Counter oldCounter = counters.putIfAbsent(name, counter);
        if (oldCounter != null) {
            counter = oldCounter;
        }
    }
    return counter;
}
Also used : Counter(org.apache.nifi.controller.Counter) StandardCounter(org.apache.nifi.controller.StandardCounter) StandardCounter(org.apache.nifi.controller.StandardCounter)

Example 2 with StandardCounter

use of org.apache.nifi.controller.StandardCounter in project nifi by apache.

the class CounterAdapter method unmarshal.

@Override
public Counter unmarshal(final AdaptedCounter aCounter) throws Exception {
    if (aCounter == null) {
        return null;
    }
    final Counter counter = new StandardCounter(aCounter.getIdentifier(), aCounter.getContext(), aCounter.getName());
    counter.adjust(aCounter.getValue());
    return counter;
}
Also used : Counter(org.apache.nifi.controller.Counter) StandardCounter(org.apache.nifi.controller.StandardCounter) StandardCounter(org.apache.nifi.controller.StandardCounter)

Aggregations

Counter (org.apache.nifi.controller.Counter)2 StandardCounter (org.apache.nifi.controller.StandardCounter)2