Example #1
0
  LaunchThread(ProjectLauncher pl, RunSession session, ILaunch launch) {
    super("bnd::launch-" + pl.getProject());

    super.setDaemon(true);

    this.launcher = pl;
    this.launch = launch;
    this.session = session;

    attributes.put(IProcess.ATTR_PROCESS_TYPE, session.getName());
    attributes.put(IProcess.ATTR_PROCESS_LABEL, session.getLabel());
    attributes.put(IProcess.ATTR_CMDLINE, session.getLabel());
  }
Example #2
0
  /*
   * Launches against the agent& main
   */
  public void testAgentAndMain() throws Exception {
    Project project = workspace.getProject("p1");
    Run bndrun = new Run(workspace, project.getBase(), project.getFile("one.bndrun"));
    bndrun.setProperty("-runpath", "biz.aQute.remote.launcher");
    bndrun.setProperty("-runbundles", "bsn-1,bsn-2");
    bndrun.setProperty("-runremote", "agent,main;agent=1090");

    final RemoteProjectLauncherPlugin pl =
        (RemoteProjectLauncherPlugin) bndrun.getProjectLauncher();
    pl.prepare();

    List<? extends RunSession> sessions = pl.getRunSessions();
    assertEquals(2, sessions.size());

    RunSession agent = sessions.get(0);
    RunSession main = sessions.get(1);

    CountDownLatch agentLatch = launch(agent);
    CountDownLatch mainLatch = launch(main);

    agent.waitTillStarted(1000);
    main.waitTillStarted(1000);
    Thread.sleep(500);

    agent.cancel();
    main.cancel();

    agentLatch.await();
    mainLatch.await();
    assertEquals(-3, agent.getExitCode());
    assertEquals(-3, main.getExitCode());

    bndrun.close();
  }
Example #3
0
  /** This is the reason for this thread. We launch the remote process and wait until it returns. */
  @Override
  public void run() {
    fireCreationEvent();

    //
    // We wait for build changes. We never update during a build
    // and we will wait a bit after a build ends.
    //

    UpdateGuard guard =
        new UpdateGuard(context) {
          @Override
          protected void update() {
            LaunchThread.this.update();
          }
        };

    guard.open();

    try {
      exitValue = session.launch();
    } catch (Exception e) {
      logger.logWarning("Exception from launcher", e);
      e.printStackTrace();
    } finally {
      guard.close();
      terminate();
    }
  }
Example #4
0
  void doDebug(IProgressMonitor monitor) throws InterruptedException {
    monitor.setTaskName(
        "Connecting debugger "
            + session.getName()
            + " to "
            + session.getHost()
            + ":"
            + session.getJdb());

    Map<String, String> parameters = new HashMap<String, String>();
    parameters.put("hostname", session.getHost());
    parameters.put("port", session.getJdb() + "");
    parameters.put("timeout", session.getTimeout() + "");
    IVMConnector connector = JavaRuntime.getDefaultVMConnector();

    while (!monitor.isCanceled()) {

      try {
        connector.connect(parameters, monitor, launch);
        break;
      } catch (Exception e) {
        Thread.sleep(500);
      }
    }
  }