use of org.openkilda.messaging.info.Datapoint in project open-kilda by telstra.
the class DatapointParseBolt method execute.
@Override
public void execute(Tuple tuple) {
final String data = tuple.getString(0);
LOGGER.debug("Processing datapoint: " + data);
try {
Datapoint datapoint = MAPPER.readValue(data, Datapoint.class);
List<Object> stream = Stream.of(datapoint.hashCode(), datapoint).collect(Collectors.toList());
collector.emit(stream);
} catch (Exception e) {
LOGGER.error("Failed reading data: " + data, e);
} finally {
collector.ack(tuple);
}
}
use of org.openkilda.messaging.info.Datapoint in project open-kilda by telstra.
the class OpenTSDBTopologyTest method shouldSendDatapointRequestsTwice.
@Ignore
@Test
public void shouldSendDatapointRequestsTwice() throws Exception {
Datapoint datapoint1 = new Datapoint("metric", timestamp, Collections.emptyMap(), 123);
String jsonDatapoint1 = MAPPER.writeValueAsString(datapoint1);
Datapoint datapoint2 = new Datapoint("metric", timestamp, Collections.emptyMap(), 456);
String jsonDatapoint2 = MAPPER.writeValueAsString(datapoint2);
MockedSources sources = new MockedSources();
sources.addMockData(Topic.OTSDB + "-spout", new Values(jsonDatapoint1), new Values(jsonDatapoint2));
completeTopologyParam.setMockedSources(sources);
Testing.withTrackedCluster(clusterParam, (cluster) -> {
OpenTSDBTopology topology = new TestingTargetTopology(new TestingKafkaBolt());
StormTopology stormTopology = topology.createTopology();
Testing.completeTopology(cluster, stormTopology, completeTopologyParam);
});
// verify that request is sent to OpenTSDB server once
mockServer.verify(HttpRequest.request(), VerificationTimes.exactly(2));
}
use of org.openkilda.messaging.info.Datapoint in project open-kilda by telstra.
the class OpenTSDBFilterBolt method isUpdateRequired.
private boolean isUpdateRequired(Datapoint datapoint) {
boolean update = true;
if (storage.containsKey(datapoint.hashCode())) {
Datapoint prevDatapoint = storage.get(datapoint.hashCode());
update = !prevDatapoint.getValue().equals(datapoint.getValue()) || datapoint.getTime() - prevDatapoint.getTime() >= TEN_MINUTES;
}
return update;
}
use of org.openkilda.messaging.info.Datapoint in project open-kilda by telstra.
the class OpenTSDBFilterBolt method execute.
@Override
public void execute(Tuple tuple) {
if (!tuple.contains("datapoint")) {
// TODO: Should make sure tuple comes from correct bolt, ie not TickTuple
collector.ack(tuple);
return;
}
Datapoint datapoint = (Datapoint) tuple.getValueByField("datapoint");
if (isUpdateRequired(datapoint)) {
addDatapoint(datapoint);
List<Object> stream = Stream.of(datapoint.getMetric(), datapoint.getTime(), datapoint.getValue(), datapoint.getTags()).collect(Collectors.toList());
LOGGER.debug("emit: " + stream);
collector.emit(stream);
}
collector.ack(tuple);
}
use of org.openkilda.messaging.info.Datapoint in project open-kilda by telstra.
the class IslStatsBoltTest method buildTsdbTuple.
@Test
public void buildTsdbTuple() throws Exception {
List<Object> tsdbTuple = statsBolt.buildTsdbTuple(islInfoData, TIMESTAMP);
assertThat(tsdbTuple.size(), is(1));
Datapoint datapoint = Utils.MAPPER.readValue(tsdbTuple.get(0).toString(), Datapoint.class);
assertEquals("pen.isl.latency", datapoint.getMetric());
assertEquals((Long) TIMESTAMP, datapoint.getTime());
assertEquals(LATENCY, datapoint.getValue());
Map<String, String> pathNode = datapoint.getTags();
assertEquals(SWITCH1_ID, pathNode.get("src_switch"));
assertEquals(SWITCH2_ID, pathNode.get("dst_switch"));
assertEquals(SWITCH1_PORT, Integer.parseInt(pathNode.get("src_port")));
assertEquals(SWITCH2_PORT, Integer.parseInt(pathNode.get("dst_port")));
}
Aggregations