/**
   * Sets the debug port used by the selected {@link Client}.
   *
   * <p>This change takes effect right away.
   *
   * @param port the new port to use.
   */
  public static void setSelectedDebugPort(int port) {
    sSelectedDebugPort = port;

    MonitorThread monitorThread = MonitorThread.getInstance();
    if (monitorThread != null) {
      monitorThread.setDebugSelectedPort(port);
    }
  }
 /** Register for the packets we expect to get from the client. */
 public static void register(MonitorThread mt) {
   mt.registerChunkHandler(CHUNK_HPIF, mInst);
   mt.registerChunkHandler(CHUNK_HPST, mInst);
   mt.registerChunkHandler(CHUNK_HPEN, mInst);
   mt.registerChunkHandler(CHUNK_HPSG, mInst);
   mt.registerChunkHandler(CHUNK_HPDS, mInst);
   mt.registerChunkHandler(CHUNK_REAQ, mInst);
   mt.registerChunkHandler(CHUNK_REAL, mInst);
 }
示例#3
0
 protected void reconnect() {
   if (monitorThread != null) {
     // let's end the old thread
     monitorThread.interrupt();
     monitorThread = null;
   }
   // create a new thread for listening to the FritzBox
   monitorThread = new MonitorThread(this.eventPublisher, this.providers);
   monitorThread.start();
 }
示例#4
0
  public static void finish() {
    if (!makeThunk) {
      Record.finish();

      if (monitor) monitorThread.finish();
      setExecStatus("done", false);
      outputMap.printEasy(getFile("output.map"));
      StopWatch.getStats().printEasy(getFile("time.map"));
      if (create) stderr.println(virtualExecDir);
      if (LogInfo.getNumErrors() > 0 || LogInfo.getNumWarnings() > 0)
        stderr.printf("%d errors, %d warnings\n", LogInfo.getNumErrors(), LogInfo.getNumWarnings());
      if (startMainTrack) end_track();
    }

    System.exit(exitCode);
  }
示例#5
0
 public void deactivate() {
   if (monitorThread != null) {
     monitorThread.interrupt();
   }
   monitorThread = null;
 }
示例#6
0
  public static void init(String[] args, Object... objects) {
    // Parse options
    parser = new OptionsParser();
    parser.doRegister("log", LogInfo.class);
    parser.doRegister("exec", Execution.class);
    parser.doRegisterAll(objects);
    // These options are specific to the execution, so we don't want to overwrite them
    // with a previous execution's.
    parser.setDefaultDirFileName("options.map");
    parser.setIgnoreOptsFromFileName(
        "options.map",
        ListUtils.newList(
            "log.file",
            "exec.execDir",
            "exec.execPoolDir",
            "exec.actualPoolDir",
            "exec.makeThunk"));
    if (!parser.doParse(args)) System.exit(1);

    // Load classes
    if (jarFiles.size() > 0) {
      List<String> names = new ArrayList();
      for (String jarFile : jarFiles) names.add(new File(jarFile).getName());
      stderr.println("Loading JAR files: " + StrUtils.join(names));
      for (String jarFile : jarFiles) // Load classes
      ClassInitializer.initializeJar(jarFile);
    }
    // Set character encoding
    if (charEncoding != null) CharEncUtils.setCharEncoding(charEncoding);

    if (printOptionsAndExit) { // Just print options and exit
      parser.doGetOptionPairs().print(stdout);
      System.exit(0);
    }

    // Create a new directory
    if (create) {
      createVirtualExecDir();
      stderr.println(virtualExecDir);
      if (!makeThunk) LogInfo.file = getFile("log");

      // Copy the Jar files for reference
      if (!makeThunk) {
        for (String jarFile : jarFiles)
          Utils.systemHard(String.format("cp %s %s", jarFile, virtualExecDir));
      }
    } else {
      LogInfo.file = "";
    }

    if (!makeThunk) {
      LogInfo.init();
      if (startMainTrack) track("main()", true);
    }

    // Output options
    if (!makeThunk && virtualExecDir != null) logs("Execution directory: " + virtualExecDir);
    if (!makeThunk) getInfo().printEasy(getFile("info.map"));
    printOptions();
    if (create && addToView.size() > 0)
      IOUtils.printLinesHard(Execution.getFile("addToView"), addToView);

    // Start monitoring
    if (!makeThunk && monitor) {
      monitorThread = new MonitorThread();
      monitorThread.start();
    }

    if (!makeThunk) Record.init(Execution.getFile("record"));
  }