1414import org .eclipse .jgit .api .errors .GitAPIException ;
1515import org .eclipse .jgit .api .errors .InvalidRemoteException ;
1616import org .eclipse .jgit .api .errors .TransportException ;
17- import org .eclipse .jgit .events .ListenerHandle ;
18-
19- import com .beust .jcommander .Parameter ;
20-
21-
2217
2318import java .lang .StringBuilder ;
2419
25- //import com.datastax.loader.CqlDelimLoadTask;
26-
2720import java .io .*;
2821import java .net .URL ;
2922import java .nio .charset .Charset ;
@@ -48,16 +41,22 @@ public class InvalidArgsException extends Exception {
4841 private Session session ;
4942 private String cassandraContactPoint ;
5043 private String host ;
51-
44+ private CDMArgs args ;
5245
5346
5447 CassandraDatasetManager () {
48+ String [] args = {};
49+ CDMArgs parsedArgs = new CDMArgs ();
50+ new JCommander (parsedArgs , args );
51+
5552 this .host = "localhost" ;
53+ this .args = parsedArgs ;
5654 }
5755
58- CassandraDatasetManager (String host , Map <String , Dataset > datasets ) {
56+ CassandraDatasetManager (CDMArgs args , Map <String , Dataset > datasets ) {
5957 this .datasets = datasets ;
60- this .host = host ;
58+ this .host = args .host ;
59+ this .args = args ;
6160 }
6261
6362
@@ -89,7 +88,7 @@ public static void main(String[] args) throws IOException, InterruptedException,
8988 Map <String , Dataset > data = mapper .readValue (yaml , new TypeReference <Map <String , Dataset >>() {} );
9089
9190 // debug: show all datasets no matter what
92- CassandraDatasetManager cdm = new CassandraDatasetManager (parsedArgs . host , data );
91+ CassandraDatasetManager cdm = new CassandraDatasetManager (parsedArgs , data );
9392
9493 // create a cluster and session
9594
@@ -236,14 +235,19 @@ void install(String name) throws IOException, InterruptedException, GitAPIExcept
236235 Cluster cluster = Cluster .builder ().addContactPoint (address ).build ();
237236 Session session = cluster .connect ();
238237
238+ Integer rf = this .args .rf ;
239239 StringBuilder createKeyspace = new StringBuilder ();
240240 createKeyspace .append (" CREATE KEYSPACE " )
241241 .append (config .keyspace )
242- .append (" WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 1}" );
242+ .append (" WITH replication = {'class': 'SimpleStrategy', 'replication_factor': " )
243+ .append (rf )
244+ .append ("}" );
243245
244- System .out .println (createKeyspace );
246+ System .out .println ("Dropping keyspace" );
245247 session .execute ("DROP KEYSPACE IF EXISTS " + config .keyspace );
246248 Thread .sleep (2000 );
249+
250+ System .out .println (createKeyspace );
247251 session .execute (createKeyspace .toString ());
248252
249253 session .execute ("USE " + config .keyspace );
@@ -254,18 +258,17 @@ void install(String name) throws IOException, InterruptedException, GitAPIExcept
254258 byte [] bytes = Files .readAllBytes (Paths .get (schema ));
255259 String [] create_tables = new String (bytes ).split (";" );
256260 for (String c : create_tables ) {
261+ System .out .println ("Letting schema settle..." );
257262 Thread .sleep (2000 );
258263 String tmp = c .trim ();
259264 if (tmp .length () > 0 ) {
265+ System .out .println (tmp );
260266 session .execute (tmp );
261267 }
262268 }
263269
264- // Runtime.getRuntime().exec(new String[]{"bash", "-c", loadSchema}).waitFor();
265-
266270 System .out .println ("Loading data" );
267271
268-
269272 this .session = session ;
270273
271274 for (String table : config .tables ) {
0 commit comments