Search in sources :

Example 1 with Counter

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;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) CounterDTO(org.apache.nifi.web.api.dto.CounterDTO) Counter(org.apache.nifi.controller.Counter) CountersDTO(org.apache.nifi.web.api.dto.CountersDTO) CountersSnapshotDTO(org.apache.nifi.web.api.dto.CountersSnapshotDTO)

Example 2 with Counter

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;
}
Also used : Counter(org.apache.nifi.controller.Counter) StandardCounter(org.apache.nifi.controller.StandardCounter) StandardCounter(org.apache.nifi.controller.StandardCounter)

Example 3 with 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;
}
Also used : Counter(org.apache.nifi.controller.Counter) StandardCounter(org.apache.nifi.controller.StandardCounter) StandardCounter(org.apache.nifi.controller.StandardCounter)

Example 4 with 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;
}
Also used : Counter(org.apache.nifi.controller.Counter) StandardCounter(org.apache.nifi.controller.StandardCounter) ArrayList(java.util.ArrayList)

Aggregations

Counter (org.apache.nifi.controller.Counter)4 StandardCounter (org.apache.nifi.controller.StandardCounter)3 ArrayList (java.util.ArrayList)1 LinkedHashSet (java.util.LinkedHashSet)1 CounterDTO (org.apache.nifi.web.api.dto.CounterDTO)1 CountersDTO (org.apache.nifi.web.api.dto.CountersDTO)1 CountersSnapshotDTO (org.apache.nifi.web.api.dto.CountersSnapshotDTO)1