@NotNull
  private Runner launchRunner(@NotNull Runner runner) {
    if (runActionPermit.isAllowed()) {

      CurrentProject currentProject = appContext.getCurrentProject();

      if (currentProject == null) {
        throw new IllegalStateException(
            "Can't launch runner for current project. Current project is absent...");
      }

      selectedEnvironment = null;

      panelState.setState(RUNNERS);
      view.showOtherButtons();

      history.addRunner(runner);

      runnerInQueueTimer.schedule(ONE_SEC.getValue());

      CheckRamAndRunAction checkRamAndRunAction = actionFactory.createCheckRamAndRun();
      checkRamAndRunAction.perform(runner);

      runnerActions.put(runner, checkRamAndRunAction);

      runner.resetCreationTime();
      runnerTimer.schedule(ONE_SEC.getValue());
    } else {
      runActionDenyAccessDialog.show();
    }
    return runner;
  }
  /**
   * Adds already running runner.
   *
   * @param processDescriptor The descriptor of new runner
   * @return instance of new runner
   */
  @NotNull
  public Runner addRunner(@NotNull ApplicationProcessDescriptor processDescriptor) {
    RunOptions runOptions = dtoFactory.createDto(RunOptions.class);
    Runner runner = modelsFactory.createRunner(runOptions);

    String environmentId = processDescriptor.getEnvironmentId();

    if (environmentId != null && environmentId.startsWith(PROJECT_PREFIX)) {
      runner.setScope(PROJECT);
    }

    runnersId.add(processDescriptor.getProcessId());

    runner.setProcessDescriptor(processDescriptor);
    runner.setRAM(processDescriptor.getMemorySize());
    runner.setStatus(Runner.Status.DONE);
    runner.resetCreationTime();

    history.addRunner(runner);

    onSelectionChanged(RUNNER);

    runnerTimer.schedule(ONE_SEC.getValue());

    LaunchAction launchAction = actionFactory.createLaunch();
    runnerActions.put(runner, launchAction);

    launchAction.perform(runner);

    selectHistoryTab();

    return runner;
  }
示例#3
0
 /** {@inheritDoc} */
 @NotNull
 @Override
 public String getActiveTime() {
   return isAlive()
       ? StringUtils.timeSecToHumanReadable(
           (System.currentTimeMillis() - creationTime) / ONE_SEC.getValue())
       : TIMER_STUB;
 }
  /** {@inheritDoc} */
  @Override
  public void onProjectReady(@NotNull ProjectActionEvent projectActionEvent) {
    view.setEnableReRunButton(false);
    view.setEnableStopButton(false);
    view.setEnableLogsButton(false);

    templateContainer.setVisible(true);

    getRunningProcessAction = actionFactory.createGetRunningProcess();

    boolean isRunOperationAvailable = runnerUtil.hasRunPermission();
    view.setEnableRunButton(isRunOperationAvailable);

    if (!isRunOperationAvailable) {
      return;
    }

    templateContainer.showEnvironments();

    getRunningProcessAction.perform();
    getSystemEnvironmentsAction.perform();

    runnerTimer.schedule(ONE_SEC.getValue());
  }