use of com.datastax.driver.core.Row in project camel by apache.
the class CassandraAggregationRepository method scan.
/**
* Get exchange IDs to be recovered
*
* @return Exchange IDs
*/
@Override
public Set<String> scan(CamelContext camelContext) {
List<Row> rows = selectKeyIds();
Set<String> exchangeIds = new HashSet<String>(rows.size());
for (Row row : rows) {
exchangeIds.add(row.getString(exchangeIdColumn));
}
return exchangeIds;
}
use of com.datastax.driver.core.Row in project camel by apache.
the class CassandraAggregationRepository method confirm.
/**
* Remove exchange by Id from aggregation table.
*/
@Override
public void confirm(CamelContext camelContext, String exchangeId) {
String keyColumn = getKeyColumn();
LOGGER.debug("Selecting Ids");
List<Row> rows = selectKeyIds();
for (Row row : rows) {
if (row.getString(exchangeIdColumn).equals(exchangeId)) {
String key = row.getString(keyColumn);
Object[] cqlParams = append(getPKValues(key), exchangeId);
LOGGER.debug("Deleting If Id {} ", cqlParams);
getSession().execute(deleteIfIdStatement.bind(cqlParams));
}
}
}
use of com.datastax.driver.core.Row in project camel by apache.
the class CassandraAggregationRepository method get.
/**
* Get exchange from aggregation table by aggregation key.
*/
@Override
public Exchange get(CamelContext camelContext, String key) {
Object[] pkValues = getPKValues(key);
LOGGER.debug("Selecting key {} ", pkValues);
Row row = getSession().execute(selectStatement.bind(pkValues)).one();
Exchange exchange = null;
if (row != null) {
try {
exchange = exchangeCodec.unmarshallExchange(camelContext, row.getBytes(exchangeColumn));
} catch (IOException iOException) {
throw new CassandraAggregationException("Failed to read exchange", exchange, iOException);
} catch (ClassNotFoundException classNotFoundException) {
throw new CassandraAggregationException("Failed to read exchange", exchange, classNotFoundException);
}
}
return exchange;
}
use of com.datastax.driver.core.Row in project camel by apache.
the class CassandraAggregationRepository method recover.
/**
* Get exchange by exchange ID.
* This is far from optimal.
*/
@Override
public Exchange recover(CamelContext camelContext, String exchangeId) {
List<Row> rows = selectKeyIds();
String keyColumnName = getKeyColumn();
String lKey = null;
for (Row row : rows) {
String lExchangeId = row.getString(exchangeIdColumn);
if (lExchangeId.equals(exchangeId)) {
lKey = row.getString(keyColumnName);
break;
}
}
return lKey == null ? null : get(camelContext, lKey);
}
use of com.datastax.driver.core.Row in project camel by apache.
the class CassandraComponentConsumerTest method testConsumeOne.
@Test
public void testConsumeOne() throws Exception {
if (!canTest()) {
return;
}
MockEndpoint mock = getMockEndpoint("mock:resultOne");
mock.expectedMinimumMessageCount(1);
mock.whenAnyExchangeReceived(new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
Object body = exchange.getIn().getBody();
assertTrue(body instanceof Row);
}
});
mock.await(1, TimeUnit.SECONDS);
assertMockEndpointsSatisfied();
}
Aggregations