Search in sources :

Example 1 with Results

use of org.apache.metron.performance.load.monitor.Results in project metron by apache.

the class CSVWriter method accept.

@Override
public void accept(Writable writable) {
    if (pw.isPresent()) {
        List<String> parts = new ArrayList<>();
        parts.add("" + writable.getDate().getTime());
        for (Results r : writable.getResults()) {
            parts.add(r.getName());
            parts.add(r.getEps() == null ? "" : (r.getEps() + ""));
            if (r.getHistory().isPresent()) {
                parts.add("" + (int) r.getHistory().get().getMean());
                parts.add("" + (int) Math.sqrt(r.getHistory().get().getVariance()));
            } else {
                parts.add("");
                parts.add("");
            }
        }
        pw.get().println(Joiner.on(",").join(parts));
        pw.get().flush();
    }
}
Also used : Results(org.apache.metron.performance.load.monitor.Results) ArrayList(java.util.ArrayList)

Example 2 with Results

use of org.apache.metron.performance.load.monitor.Results in project metron by apache.

the class ConsoleWriter method accept.

@Override
public void accept(Writable writable) {
    List<String> parts = new ArrayList<>();
    Date date = writable.getDate();
    for (Results r : writable.getResults()) {
        Long eps = r.getEps();
        if (eps != null) {
            String part = String.format(r.getFormat(), eps);
            if (r.getHistory().isPresent()) {
                part += " (" + getSummary(r.getHistory().get()) + ")";
            }
            parts.add(part);
        }
    }
    if (date != null) {
        DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
        String header = dateFormat.format(date) + " - ";
        String emptyHeader = StringUtils.repeat(" ", header.length());
        for (int i = 0; i < parts.size(); ++i) {
            String part = parts.get(i);
            if (i == 0) {
                System.out.println(header + (part == null ? "" : part));
            } else {
                System.out.println(emptyHeader + (part == null ? "" : part));
            }
        }
    }
}
Also used : Results(org.apache.metron.performance.load.monitor.Results) SimpleDateFormat(java.text.SimpleDateFormat) DateFormat(java.text.DateFormat) ArrayList(java.util.ArrayList) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date)

Example 3 with Results

use of org.apache.metron.performance.load.monitor.Results in project metron by apache.

the class Writer method writeAll.

public void writeAll() {
    int i = 0;
    Date dateOf = new Date();
    List<Results> results = new ArrayList<>();
    for (AbstractMonitor m : monitors) {
        Long eps = m.get();
        if (eps != null && summaryLookback > 0) {
            LinkedList<Double> summary = summaries.get(i);
            addToLookback(eps.doubleValue(), summary);
            results.add(new Results(m.format(), m.name(), eps, Optional.of(getStats(summary))));
        } else {
            results.add(new Results(m.format(), m.name(), eps, Optional.empty()));
        }
        i++;
    }
    Writable writable = new Writable(dateOf, results);
    for (Consumer<Writable> writer : writers) {
        writer.accept(writable);
    }
}
Also used : AbstractMonitor(org.apache.metron.performance.load.monitor.AbstractMonitor) Results(org.apache.metron.performance.load.monitor.Results) ArrayList(java.util.ArrayList) Date(java.util.Date)

Aggregations

ArrayList (java.util.ArrayList)3 Results (org.apache.metron.performance.load.monitor.Results)3 Date (java.util.Date)2 DateFormat (java.text.DateFormat)1 SimpleDateFormat (java.text.SimpleDateFormat)1 AbstractMonitor (org.apache.metron.performance.load.monitor.AbstractMonitor)1