1 package compbio.cassandra.readers;
3 import org.apache.log4j.Logger;
5 import com.datastax.driver.core.ResultSet;
6 import com.datastax.driver.core.Session;
7 import com.datastax.driver.core.exceptions.QueryExecutionException;
8 import com.datastax.driver.core.exceptions.QueryValidationException;
10 import compbio.cassandra.CassandraNativeConnector;
12 public class CassandraReader {
13 protected static long earlestDate = 0;
14 protected Session session;
15 protected static Logger log = Logger.getLogger(CassandraNativeConnector.class);
17 public CassandraReader() {
18 Session inis = CassandraNativeConnector.getSession();
22 public void setSession(Session s) {
27 protected ResultSet CassandraQuery(String command) {
29 ResultSet results = session.execute(command);
31 } catch (QueryExecutionException e) {
32 String mess = "ProteoCache Cassandra DB interface: query execution exception...\n Command: " + command;
33 System.out.println(mess);
35 log.error(e.getLocalizedMessage(), e.getCause());
37 } catch (QueryValidationException e) {
38 String mess = "CProteoCache Cassandra DB interface: query validation exception...\n Command: " + command;
39 System.out.println(mess);
41 log.error(e.getLocalizedMessage(), e.getCause());
48 * find the earliest date in the database
50 public static long earliestDate() {
51 earlestDate = CassandraNativeConnector.getEarliestDateInDB();
56 * prepares an example of either job id or IP for the DB
59 * defines which example you need (an existing job from the DB -
60 * jobid, an IP - "ip")
61 * @return a string representation of the requested example, if the example
62 * type is not known empty string is returned
64 public String getExample(String exampletype) {
65 if (exampletype.equals("jobid")) {
67 } else if (exampletype.equals("ip")) {