X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=datadb%2Fcompbio%2Fcassandra%2FCassandraCreate.java;fp=datadb%2Fcompbio%2Fcassandra%2FCassandraCreate.java;h=ad1fcbe37db855d96658ceb702904102c1748b9b;hb=6a81b75c020845f9bb94c307a66347e4362da85f;hp=54fffaced07cfe28ac897b6f892dda83c2de3102;hpb=764f0d166bb7651490cbd5181063b6dd00042b07;p=proteocache.git diff --git a/datadb/compbio/cassandra/CassandraCreate.java b/datadb/compbio/cassandra/CassandraCreate.java index 54fffac..ad1fcbe 100644 --- a/datadb/compbio/cassandra/CassandraCreate.java +++ b/datadb/compbio/cassandra/CassandraCreate.java @@ -26,7 +26,9 @@ public class CassandraCreate { 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"); @@ -60,11 +62,12 @@ public class CassandraCreate { } /* - * 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); /* @@ -72,21 +75,38 @@ public class CassandraCreate { */ 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() { @@ -94,7 +114,9 @@ public class CassandraCreate { 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 sliceQuery = HFactory.createSliceQuery(ksp, ss, ss, ss); sliceQuery.setColumnFamily("ProteinLog").setKey(jobid).setRange("", "", false, 100); @@ -105,6 +127,9 @@ public class CassandraCreate { 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 jnetpred) { mutatorLog.addInsertion(id, "ProteinLog", HFactory.createColumn("ip", ip, ss, ss))