StringSerializer ss = StringSerializer.get();
LongSerializer ls = LongSerializer.get();
- // connect to the cluster
+ /*
+ * connect to the cluster and look weather the dababase has any data inside
+ */
public void Connection() {
cluster = HFactory.getOrCreateCluster("Protein Cluster", "127.0.0.1:9160");
KeyspaceDefinition keyspaceDef = cluster.describeKeyspace("ProteinKeyspace");
}
/*
- * parsing data from
- * http://www.compbio.dundee.ac.uk/www-jpred/results/usage-new/alljobs.dat
+ * parsing data source and filling the database
*/
- public void Parsing() {
- /* CF ProteinRow store protein and prediction */
+ public void Parsing(String source) {
+ /*
+ * CF ProteinRow store protein and prediction
+ */
mutatorString = HFactory.createMutator(ksp, ss);
/*
*/
mutatorLog = HFactory.createMutator(ksp, ss);
- /* CF ProteinData store id and protein per data */
+ /*
+ * CF ProteinData store id and protein per data
+ */
mutatorLong = HFactory.createMutator(ksp, ls);
- System.out.println("Parsing......");
- String in = "http://www.compbio.dundee.ac.uk/www-jpred/results/usage-new/alljobs.dat";
- DataParsing datParsing = new DataParsing();
- datParsing.Parsing(in, 4);
- flushData();
+ if (source.equals("http")) {
+ // get data from real Jpred production server
+ System.out.println("Parsing web data source......");
+ String datasrc = "http://www.compbio.dundee.ac.uk/www-jpred/results/usage-new/alljobs.dat";
+ String prefix = "http://www.compbio.dundee.ac.uk/www-jpred/results";
+ JpredParserHTTP parser = new JpredParserHTTP(prefix);
+ parser.setSource("");
+ parser.Parsing(datasrc, 4);
+ flushData();
+ } else if (source.equals("file")) {
+ // get irtifical data generated for the DB stress tests
+ System.out.println("Parsing local file data source......");
+ String datasrc = "/home/asherstnev/Projects/Java.projects/proteocache/data_stress_test/data.dat";
+ String prefix = "/home/asherstnev/Projects/Java.projects/proteocache/data_stress_test/Jpreddata";
+ JpredParserLocalFile parser = new JpredParserLocalFile(prefix);
+ parser.Parsing(datasrc, 365);
+ flushData();
+ } else {
+ System.out.println("Unknown data source......");
+ }
}
public void flushData() {
mutatorString.execute();
mutatorLong.execute();
mutatorLog.execute();
- //System.out.println("Flush new data...");
+ // System.out.println("Flush new data...");
}
public void Closing() {
System.out.println("Cassandra has been shut down");
}
- // check whether the job id exists in the DB
+ /*
+ * check whether the job id exists in the DB
+ */
public boolean CheckID(String jobid) {
SliceQuery<String, String, String> sliceQuery = HFactory.createSliceQuery(ksp, ss, ss, ss);
sliceQuery.setColumnFamily("ProteinLog").setKey(jobid).setRange("", "", false, 100);
return false;
}
+ /*
+ * prepare data for insertion into the db
+ */
public void InsertData(long dataWork, String dataBegin, String dataEnd, String ip, String id, String statusEx, String statusFinal,
String protein, List<FastaSequence> jnetpred) {
mutatorLog.addInsertion(id, "ProteinLog", HFactory.createColumn("ip", ip, ss, ss))