use of org.openkilda.wfm.topology.stats.FlowResult in project open-kilda by telstra.
the class FlowMetricGenBolt method emit.
private void emit(FlowStatsEntry entry, long timestamp, String switchId) throws Exception {
FlowResult flow = getFlowFromCache(entry.getCookie());
Map<String, String> tags = new HashMap<>();
tags.put("switchid", switchId);
tags.put("cookie", String.valueOf(entry.getCookie()));
tags.put("tableid", String.valueOf(entry.getTableId()));
tags.put("flowid", flow.getFlowId());
collector.emit(tuple("pen.flow.raw.packets", timestamp, entry.getPacketCount(), tags));
collector.emit(tuple("pen.flow.raw.bytes", timestamp, entry.getByteCount(), tags));
collector.emit(tuple("pen.flow.raw.bits", timestamp, entry.getByteCount() * 8, tags));
/**
* If this is the destination switch for the flow, then add to TSDB for pen.flow.* stats. This is needed
* as there is needed to provide simple lookup of flow stats
*/
if (switchId.equals(flow.getDstSw().replaceAll(":", ""))) {
// Doing this to prevent creation of yet another object
tags.remove("cookie");
tags.remove("tableid");
tags.remove("switchid");
tags.put("direction", flow.getDirection());
collector.emit(tuple("pen.flow.packets", timestamp, entry.getPacketCount(), tags));
collector.emit(tuple("pen.flow.bytes", timestamp, entry.getByteCount(), tags));
collector.emit(tuple("pen.flow.bits", timestamp, entry.getByteCount() * 8, tags));
}
}
use of org.openkilda.wfm.topology.stats.FlowResult in project open-kilda by telstra.
the class FlowMetricGenBolt method getFlowFromCache.
@SuppressWarnings("unchecked")
protected FlowResult getFlowFromCache(Long cookie) throws Exception {
FlowResult flow = cookieMap.get(cookie);
if (flow == null) {
LOGGER.info("{} not found, fetching.", cookie);
try {
flow = new FlowResult((Map) getFlowWithCookie(cookie).get("r"));
} catch (ClientException e) {
LOGGER.error("error getting flow for {}", cookie);
}
cookieMap.put(flow.getCookie(), flow);
LOGGER.debug("added entry to cookieMap: {}", flow.toString());
}
return flow;
}
use of org.openkilda.wfm.topology.stats.FlowResult in project open-kilda by telstra.
the class FlowMetricGenBolt method warmCookieMap.
/**
* Pre-Populate the cookieMap from Neo4J
*/
@SuppressWarnings("unchecked")
private void warmCookieMap() {
Iterator<Map<String, Object>> result;
try {
result = cypher.query(GET_ALL_FLOWS, null);
} catch (ClientException e) {
LOGGER.error("Error warming cookieMap", e);
return;
}
while (result.hasNext()) {
Map<String, Object> row = result.next();
FlowResult flow;
try {
flow = new FlowResult(row);
cookieMap.put(flow.getCookie(), flow);
LOGGER.debug("added entry to cookieMap: {}", flow.toString());
} catch (FlowCookieException e) {
LOGGER.error("error processing cookie", e);
}
}
}
Aggregations