Search in sources :

Example 1 with OccurenceCounterEntry

use of org.opendaylight.infrautils.counters.impl.service.OccurenceCounterEntry in project infrautils by opendaylight.

the class CountersMain method dumpCounters.

public String dumpCounters(String regex) {
    if (regex == null) {
        regex = "";
    }
    Pattern pattern = Pattern.compile(regex);
    int sortByColumn = 0;
    TablePrinter printer = new TablePrinter(sortByColumn);
    printer.setColumnNames("Counter name", "Value");
    for (OccurenceCounterEntry entry : countersRunnable.getCounters()) {
        String counterName = getCounterFullName(entry.counter.group, entry.counter.name);
        Matcher matcher = pattern.matcher(counterName);
        if (matcher.find()) {
            printer.addRow(counterName, Long.toString(entry.counter.get()));
        }
    }
    return printer.toString();
}
Also used : Pattern(java.util.regex.Pattern) OccurenceCounterEntry(org.opendaylight.infrautils.counters.impl.service.OccurenceCounterEntry) Matcher(java.util.regex.Matcher) TablePrinter(org.opendaylight.infrautils.utils.TablePrinter)

Aggregations

Matcher (java.util.regex.Matcher)1 Pattern (java.util.regex.Pattern)1 OccurenceCounterEntry (org.opendaylight.infrautils.counters.impl.service.OccurenceCounterEntry)1 TablePrinter (org.opendaylight.infrautils.utils.TablePrinter)1