use of org.apache.nifi.controller.Counter in project nifi by apache.
the class StandardNiFiServiceFacade method getCounters.
@Override
public CountersDTO getCounters() {
final List<Counter> counters = controllerFacade.getCounters();
final Set<CounterDTO> counterDTOs = new LinkedHashSet<>(counters.size());
for (final Counter counter : counters) {
counterDTOs.add(dtoFactory.createCounterDto(counter));
}
final CountersSnapshotDTO snapshotDto = dtoFactory.createCountersDto(counterDTOs);
final CountersDTO countersDto = new CountersDTO();
countersDto.setAggregateSnapshot(snapshotDto);
return countersDto;
}
use of org.apache.nifi.controller.Counter 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;
}
use of org.apache.nifi.controller.Counter 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;
}
use of org.apache.nifi.controller.Counter in project nifi by apache.
the class StandardCounterRepository method getCounters.
@Override
public List<Counter> getCounters(final String counterContext) {
final List<Counter> counters = new ArrayList<>();
final Map<String, Counter> map = processorCounters.get(counterContext);
if (map == null) {
return counters;
}
for (final Counter counter : map.values()) {
counters.add(StandardCounter.unmodifiableCounter(counter));
}
return counters;
}
Aggregations