SDN Controller Programming Guide

98
protected Collection<String> findRows(CassandraAlertFilter filter,
final DataStoreContext context)
throws PersistenceException, Exception {
Collection<String> rowsSet = new ArrayList<String>();
if (filter == null) {
Collection<String> id = new ArrayList<String>();
Procedure<CassandraStorable<String, String>> procedure = new
Procedure<CassandraStorable<String, String>>() {
@Override
public CassandraStorable<String, String> execute()
throws Exception {
return (context.getContext().get(
AlertsCount.COL_FAMILY, AlertsCount.COUNT_DECODER,
AlertsCount.ROW_KEY));
}
};
context.getTransactionContext()
.prepareTransaction(AlertsCount.COL_FAMILY.getName(),
AlertsCount.ROW_KEY);
CassandraStorable<String, String> row =
context.getTransactionContext().
executeCriticalSection(procedure);
for (Column<String, ?> col : row.getColumns()) {
id.add(col.getName().getValue());
}
return id;
}
if (filter.getOriginCondition() != null) {
final ByteBufferRange range;
switch (filter.getOriginCondition().getMode()) {
case EQUAL:
range = AlertsByOrigin.serializer.buildRange()
.withPrefix(filter.getOriginCondition()
.getValue());
break;
case STARTS_WITH:
range = AlertsByOrigin.serializer.buildRange()
.greaterThanEquals(filter
.getOriginCondition()
.getValue())
.lessThan("~");
break;