Reference Guide

Table Of Contents
ReadQuery<CassandraAlert, C> getFindAlertByUidAndSysIdQuery(
String uid, String sysId);
WriteQuery<CassandraAlert, C> getUpdateAlertStateQuery(
CassandraAlert alert);
WriteQuery<Long, C> getTrimAlertQuery(CassandraAlertFilter alertFilter);
WriteQuery<Long, C> getAddAlertListQuery(List<CassandraAlert> alerts);
WriteQuery<Long, C> getUpdateAlertListQuery(
List<String> uids, String sysId, boolean state);
WriteQuery<Long, C> getDeleteAlertListQuery(
List<String> uids, String sysId);
ReadQuery<Long, C> getCountAlertQuery();
}
This interface has all the queries that are to be used by the demo application. Here is an
implementation example of the interface shown above.
The DistQueryManager provides all queries required by the business logic without exposing the
underlying generic queries directly. This also helps the application to keep a check on the queries
that can be issued to the database. Random queries are not to be accepted. The business logic
uses one of the interface API listed in the interface to perform persistence operations at a given
point in time. An example is shown below. Earlier examples showed that business logic references
distributed data store service and distributed query service. The following example shows how
these references are put to use.
CassandraAlertManager.java Posting Alert:
@Override
public CassandraAlert post(Severity severity, CassandraAlertTopic topic,
String origin, String data) throws PersistenceException {
if (topic == null) {
throw new NullPointerException(...);
}
CassandraAlert alert = new CassandraAlert(sysId, true, topic.id(),
origin, new Date(), severity, data);
WriteQuery<CassandraAlert, DataStoreContext> postAlertQuery =
queryService.getAddAlertQuery(alert);
try {
alert = dataStoreService.execute(postAlertQuery);
} catch (Exception e) {
...
}
92