diff --git a/src/main/java/org/gcube/contentmanager/storageserver/data/ReadingMongoOplog.java b/src/main/java/org/gcube/contentmanager/storageserver/data/ReadingMongoOplog.java index f8fbd88..89f75bb 100644 --- a/src/main/java/org/gcube/contentmanager/storageserver/data/ReadingMongoOplog.java +++ b/src/main/java/org/gcube/contentmanager/storageserver/data/ReadingMongoOplog.java @@ -78,8 +78,9 @@ public class ReadingMongoOplog extends Thread{ if(x.containsField("o")){ // c1 buffer for suer accounting c1.put(x); - // c2 buffer for folder accounting (TODO) - c2.put(x); + // c2 buffer for folder accounting (TODO) + if(c2 !=null) + c2.put(x); // parser.runWithoutThread(x); logger.debug("Producer #" + this.number + " put: " + x); }else{ @@ -88,12 +89,6 @@ public class ReadingMongoOplog extends Thread{ }else{ logger.debug("record discarded: \t"+x); } - try { - Thread.sleep(20000); - } catch (InterruptedException e1) { - // TODO Auto-generated catch block - e1.printStackTrace(); - } } try { Thread.sleep(1000); diff --git a/src/main/java/org/gcube/contentmanager/storageserver/startup/Startup.java b/src/main/java/org/gcube/contentmanager/storageserver/startup/Startup.java index ccbef62..ff69266 100644 --- a/src/main/java/org/gcube/contentmanager/storageserver/startup/Startup.java +++ b/src/main/java/org/gcube/contentmanager/storageserver/startup/Startup.java @@ -33,7 +33,6 @@ public class Startup { return; } - scope=args[0]; String oplogServer= args[1]; if(args.length == 4){ @@ -44,26 +43,41 @@ public class Startup { String[] server=retrieveServerConfiguration(cfg); List dtsHosts=retrieveDTSConfiguration(cfg); CubbyHole c1 = new CubbyHole(); - CubbyHole c2 = new CubbyHole(); - ReadingMongoOplog producer=null; + CubbyHole c2 = null;//new CubbyHole(); + startProducer(args, oplogServer, server, c1, c2); + startUserAccountingConsumer(args, server, dtsHosts, c1); +// startFolderAccountingConsumer(args, server, c2); + } + + private static void startFolderAccountingConsumer(String[] args, + String[] server, CubbyHole c2) { + FolderAccountingConsumer fsConsumer=null; if(args.length == 3) - producer=new ReadingMongoOplog( Arrays.asList(oplogServer), args[1], args[2], c1, c2, 1 ); + fsConsumer=new FolderAccountingConsumer(server, c2, 1); else - producer=new ReadingMongoOplog( Arrays.asList(server), c1, c2, 1 ); - UserAccountingConsumer ssConsumer=null; + fsConsumer=new FolderAccountingConsumer(server, args[1], args[2], c2, 1); + fsConsumer.start(); + } + + private static void startUserAccountingConsumer(String[] args, + String[] server, List dtsHosts, CubbyHole c1) { + UserAccountingConsumer ssConsumer=null; if(args.length == 3) ssConsumer=new UserAccountingConsumer(server, c1, 1, dtsHosts); else ssConsumer=new UserAccountingConsumer(server, args[1], args[2], c1, 1, dtsHosts); -// FolderAccountingConsumer fsConsumer=null; -// if(args.length == 3) -// fsConsumer=new FolderAccountingConsumer(server, c2, 1); -// else -// fsConsumer=new FolderAccountingConsumer(server, args[1], args[2], c2, 1); - producer.start(); ssConsumer.start(); -// fsConsumer.start(); - } + } + + private static void startProducer(String[] args, String oplogServer, + String[] server, CubbyHole c1, CubbyHole c2) { + ReadingMongoOplog producer=null; + if(args.length == 3) + producer=new ReadingMongoOplog( Arrays.asList(oplogServer), args[1], args[2], c1, c2, 1 ); + else + producer=new ReadingMongoOplog( Arrays.asList(server), c1, c2, 1 ); + producer.start(); + } private static String[] retrieveServerConfiguration(Configuration c) { return c.getServerAccess();