void run()

in harness/src/main/java/org/apache/geode/perftest/jvms/rmi/ChildJVM.java [50:98]


  void run() {
    try {
      String RMI_HOST = system.getProperty(RemoteJVMFactory.RMI_HOST);
      String RMI_PORT = system.getProperty(RemoteJVMFactory.RMI_PORT_PROPERTY);
      String OUTPUT_DIR = system.getProperty(RemoteJVMFactory.OUTPUT_DIR);
      int id = system.getInteger(RemoteJVMFactory.JVM_ID);
      String role = system.getProperty(RemoteJVMFactory.ROLE);

      if (RMI_HOST == null || RMI_PORT == null || OUTPUT_DIR == null) {
        throw new IllegalStateException(
            "ChildJVM must be launched with all required system properties set.");
      }

      File outputDir = new File(OUTPUT_DIR);
      try (PrintStream out = new PrintStream(new File(outputDir, "system.log"))) {
        system.setOut(out);
        system.setErr(out);

        ControllerRemote controller = (ControllerRemote) rmi
            .lookup("//" + RMI_HOST + ":" + RMI_PORT + "/" + RemoteJVMFactory.CONTROLLER);

        SharedContext sharedContext = controller.getsharedContext();
        DefaultTestContext context =
            new DefaultTestContext(sharedContext, outputDir, id, role, controller);

        Worker worker = new Worker(context);

        controller.addWorker(id, worker);

        // Wait until the controller shuts down
        // If the controller shuts down, this will throw an exception
        try {
          while (controller.ping()) {
            Thread.sleep(pingTime);
          }
        } catch (RemoteException e) {
          // If we get a RemoteException, the controller has shut down
          // exit gracefully
        }

        system.exit(0);
      }
    } catch (Throwable t) {
      t.printStackTrace();
      // Force a system exit. Because we created an RMI object, an exception from the main
      // thread would not otherwise cause this process to exit
      system.exit(1);
    }
  }