use of org.influxdb.dto.QueryResult in project camel by apache.
the class InfluxDbProducer method doQuery.
private void doQuery(Exchange exchange, String dataBaseName, String retentionPolicy) {
String query = calculateQuery(exchange);
Query influxdbQuery = new Query(query, dataBaseName);
QueryResult resultSet = connection.query(influxdbQuery);
exchange.getOut().setBody(resultSet);
}
use of org.influxdb.dto.QueryResult in project cas by apereo.
the class InfluxDbCasEventRepository method load.
@Override
public Collection<? extends CasEvent> load() {
final List<CasEvent> events = new ArrayList<>();
final QueryResult results = influxDbConnectionFactory.query(MEASUREMENT);
results.getResults().stream().forEach(r -> r.getSeries().forEach(s -> {
try {
final Iterator<List<Object>> it = s.getValues().iterator();
while (it.hasNext()) {
final CasEvent event = new CasEvent();
final List<Object> row = it.next();
for (int i = 0; i < s.getColumns().size(); i++) {
final String colName = s.getColumns().get(i);
switch(colName) {
case "time":
break;
case "id":
event.putId(row.get(i).toString());
break;
case "type":
event.setType(row.get(i).toString());
break;
case "principalId":
event.setPrincipalId(row.get(i).toString());
break;
case "creationTime":
event.setCreationTime(row.get(i).toString());
break;
default:
event.put(colName, row.get(i).toString());
}
}
events.add(event);
}
} catch (final Exception e) {
LOGGER.error(e.getMessage(), e);
}
}));
return events;
}
use of org.influxdb.dto.QueryResult in project cas by apereo.
the class InfluxDbConnectionFactoryTests method verifyWritePoint.
@Test
public void verifyWritePoint() {
final Point p = Point.measurement("events").time(System.currentTimeMillis(), TimeUnit.MILLISECONDS).addField("hostname", "cas.example.org").build();
factory.write(p, CAS_EVENTS_DATABASE);
final QueryResult result = factory.query("*", "events", CAS_EVENTS_DATABASE);
final InfluxDBResultMapper resultMapper = new InfluxDBResultMapper();
final List<InfluxEvent> resultEvents = resultMapper.toPOJO(result, InfluxEvent.class);
assertNotNull(resultEvents);
assertEquals(1, resultEvents.size());
assertEquals("cas.example.org", resultEvents.iterator().next().hostname);
}
Aggregations