System.out.println(COMMENT_SEPARATOR);
System.out.println("Running a single Easy Batch instance");
System.out.println(COMMENT_SEPARATOR);
long singleInstanceStartTime = System.nanoTime();
EasyBatchEngine easyBatchEngine = new EasyBatchEngineBuilder()
.registerRecordReader(new FlatFileRecordReader(new File(args[0]))) //read data from secret-messages.txt
.registerRecordProcessor(new MessageEncrypter())
.build();
EasyBatchReport easyBatchReport = easyBatchEngine.call();
System.out.println(easyBatchReport);
long singleInstanceEndTime = TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - singleInstanceStartTime);
System.out.println(COMMENT_SEPARATOR);
System.out.println("Running two Easy Batch instances in parallel");
System.out.println(COMMENT_SEPARATOR);
long parallelInstancesStartTime = System.nanoTime();
// To avoid any thread-safety issues,
// we will create 2 engines with separate instances of record readers and processors
// Build an easy batch engine1
EasyBatchEngine easyBatchEngine1 = new EasyBatchEngineBuilder()
.registerRecordReader(new FlatFileRecordReader(new File(args[0]))) //read data from secret-messages.txt
.registerRecordFilter(new RecordNumberGreaterThanRecordFilter(5)) // filter records 6-10
.registerRecordProcessor(new MessageEncrypter())
.build();
// Build an easy batch engine2
EasyBatchEngine easyBatchEngine2 = new EasyBatchEngineBuilder()
.registerRecordReader(new FlatFileRecordReader(new File(args[0]))) //read data from secret-messages.txt
.registerRecordFilter(new RecordNumberLowerThanRecordFilter(6)) // filter records 1-5
.registerRecordProcessor(new MessageEncrypter())
.build();
//create a 2 threads pool to call Easy Batch engines in parallel