package com.neverwinterdp.scribengin.dataflow.tracking;

import com.neverwinterdp.registry.Registry;
import com.neverwinterdp.scribengin.shell.ScribenginShell;
import com.neverwinterdp.vm.client.VMClient;

public class KafkaGeneratorValidatorTrackingLauncher extends TestTrackingLauncher {
  
  @Override
  public void execute(ScribenginShell shell, TrackingDataflowBuilder dflBuilder) throws Exception {
    VMClient vmClient= shell.getVMClient();
    Registry registry = vmClient.getRegistry();
    
    GeneratorThread generatorThread = new GeneratorThread(registry, dflBuilder.getTrackingConfig());
    generatorThread.start();
    
    ValidatorThread validatorThread = new ValidatorThread(shell, dflBuilder);
    validatorThread.start();
    
    while(validatorThread.isAlive()) {
      Thread.sleep(1000);
    }
  }
  
  static public class ValidatorThread extends Thread {
    ScribenginShell         shell;
    Registry                registry;
    TrackingDataflowBuilder dflBuilder;
    VMTMValidatorKafkaApp   validatorApp;

    public ValidatorThread(ScribenginShell shell, TrackingDataflowBuilder dflBuilder) {
      this.shell          = shell ;
      this.registry       = shell.getVMClient().getRegistry();
      this.dflBuilder     = dflBuilder;
    }
    
    public void run() {
      validatorApp = new VMTMValidatorKafkaApp();
      validatorApp.runValidate(registry, dflBuilder.getTrackingConfig());
    }
  }
}
@@ -50,16 +50,55 @@
 cking;%0A%0A
+import com.beust.jcommander.Parameter;%0A
 import c
@@ -133,16 +133,16 @@
 gistry;%0A
-
 import c
@@ -322,16 +322,129 @@
 ncher %7B%0A
+  @Parameter(names = %22--validator-launch-delay%22, description = %22%22)%0A  private long validatorLaunchDelay = 300000;%0A
   %0A  @Ov
@@ -744,24 +744,24 @@
 gConfig());%0A
-
     generato
@@ -778,24 +778,212 @@
 art();%0A    %0A
+    shell.console().println(%22The validator will be launched in %22 + validatorLaunchDelay + %22ms, you need to manually launch the dataflow now%22);%0A    Thread.sleep(validatorLaunchDelay);%0A    %0A
     Validato

add simple dataflow launch for vm master test