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();
}
}
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));
}
}
}
}
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);
}
}
Aggregations