Asserts the process instance with the provided id is ended.

@param processInstanceId
the process instance's id to check for. May not be <code>null</code>
12682
public static final void assertProcessEnded(final String processInstanceId) {
        Validate.notNull(processInstanceId);

        apiCallback.debug(LogMessage.PROCESS_5, processInstanceId);
        try {
            getProcessInstanceAssertable().processIsEnded(processInstanceId);
        } catch (final AssertionError ae) {
            apiCallback.fail(ae, LogMessage.ERROR_PROCESS_2, processInstanceId);
        }
    }
509909
def stop_instance(self, instance_id):
        
        instance = self._load_instance(instance_id)
        instance.terminate()
        del self._instances[instance_id]
469943
def _TerminateProcessByPid(self, pid):
    
    self._RaiseIfNotRegistered(pid)

    process = self._processes_per_pid[pid]

    self._TerminateProcess(process)
    self._StopMonitoringProcess(process)
432910
private void onCleanExit(final String processId) {
    this.onResourceStatus(
        ResourceStatusEventImpl.newBuilder()
            .setIdentifier(processId)
            .setState(State.DONE)
            .setExitCode(0)
            .build()
    );
  }
914021
public static DataSourceBackendId getInstance(String id) {
        DataSourceBackendId result = cache.get(id);
        if (result == null) {
            id = id.intern();
            result = new DataSourceBackendId(id);
            cache.put(id, result);
        }
        return result;
    }
401598
private boolean validateProcessInstance(ProcessInstance processInst) {
        Integer status = processInst.getStatusCode();
        if (WorkStatus.STATUS_CANCELLED.equals(status)) {
            logger.info("ProcessInstance has been cancelled. ProcessInstanceId = " + processInst.getId());
            return false;
        } else if (WorkStatus.STATUS_COMPLETED.equals(status)) {
            logger.info("ProcessInstance has been completed. ProcessInstanceId = " + processInst.getId());
            return false;
        } else return true;
    }
1008499
public void terminateWorkflow(String workflowId, String reason) {
        Preconditions.checkArgument(StringUtils.isNotBlank(workflowId), "workflow id cannot be blank");
        delete(new Object[]{"reason", reason}, "workflow/{workflowId}", workflowId);
    }
580940
public static ProcessReturn procWaitWithProcessReturn (Process process, final long timeout) throws OSHelperException {
		long endTime = Calendar.getInstance ().getTimeInMillis () + timeout;

		boolean terminatedByItself = false;

		ProcessReturn processReturn = new ProcessReturn ();
		while (Calendar.getInstance ().getTimeInMillis () < endTime) {
			try {
				InputStream stdoutIs = process.getInputStream ();
				processReturn.stdout = readInputStreamAsString (stdoutIs);

				InputStream stderrIs = process.getErrorStream ();
				processReturn.stderr = readInputStreamAsString (stderrIs);

				processReturn.exitCode = process.exitValue ();
				processReturn.exitStatus = ProcessReturn.osh_PROCESS_EXITED_BY_ITSELF;

				terminatedByItself = true;
			} catch (IllegalThreadStateException ex) {	// the process has not yet terminated
				terminatedByItself = false;
			}
			if (terminatedByItself) {
				break;
			}
		}
		if (!terminatedByItself) {
			process.destroy ();

			try {
				InputStream stdoutIs = process.getInputStream ();
				processReturn.stdout = readInputStreamAsString (stdoutIs);

				InputStream stderrIs = process.getErrorStream ();
				processReturn.stderr = readInputStreamAsString (stderrIs);

				processReturn.exitCode = process.waitFor ();
			} catch (InterruptedException ex) {
				throw new OSHelperException (ex);
			}

			processReturn.exitStatus = ProcessReturn.osh_PROCESS_KILLED_BY_TIMEOUT;
		}

		return processReturn;
	}
919531
public void reload(Long processId) {
        try {
            if (logger.isDebugEnabled()) {
                logger.debug("## reload Stage pipeline[{}] process[{}]", getPipelineId(), processId);
            }

            initProcessStage(processId);
        } catch (Exception cause) {
        }
    }
169223
public boolean ack(Long processId) {
        boolean result = waitProcessIds.ack();
        if (logger.isDebugEnabled()) {
            logger.debug("## {} ack termin id [{}]", getPipelineId(), processId);
        }
        return result;
    }
1059328
@Override
  protected String generateActivityInstanceId(String activityId) {

    if (activityId.equals(processDefinitionId)) {
      return processInstanceId;

    } else {

      String nextId = Context.getProcessEngineConfiguration().getIdGenerator().getNextId();

      String compositeId = activityId + ":" + nextId;
      if (compositeId.length() > 64) {
        return String.valueOf(nextId);
      } else {
        return compositeId;
      }
    }
  }
709677
@Override
  protected void initializeVariableInstanceBackPointer(VariableInstanceEntity variableInstance) {
    if (processInstanceId != null) {
      variableInstance.setProcessInstanceId(processInstanceId);
    } else {
      variableInstance.setProcessInstanceId(id);
    }
    variableInstance.setExecutionId(id);
  }
1278593
func (s *SetTimeBasedAutoScalingInput) SetInstanceId(v string) *SetTimeBasedAutoScalingInput {
	s.InstanceId = &v
	return s
}
325681
@Override
	public final void close(@NotNull Throwable e) {
		if (isProcessComplete()) return;
		processComplete = true;
		doClose(e);
		processCompletion.trySetException(e);
		afterProcess(e);
	}
393613
@Override
    public ProcessInstanceLog findProcessInstance(long processInstanceId) {
        EntityManager em = getEntityManager();
        Object newTx = joinTransaction(em);
        try {
        	return (ProcessInstanceLog) em
        	        .createQuery("FROM ProcessInstanceLog p WHERE p.processInstanceId = :processInstanceId")
        	        .setParameter("processInstanceId", processInstanceId).getSingleResult();
        } catch (NoResultException e) {
        	return null;
        } finally {
        	closeEntityManager(em, newTx);
        }
    }
571384
private void terminateWindowsProcess(InstanceConfiguration config)
    {
        log.info("Cleaning up at application shutdown...");

        String pid;
        try
        {
            pid = ProcessUtil.getElasticsearchPid(config.getBaseDir());
            log.debug("Read PID '" + pid + "' from pid file");
        }
        catch (Exception ex)
        {
            log.debug("Cannot read the PID from file; assuming the process is not running", ex);
            return;
        }
        
        boolean isAlive;
        try
        {
            isAlive = ProcessUtil.isWindowsProcessAlive(config, pid);
            log.debug("Process is still running: " + isAlive);
        }
        catch (Exception ex)
        {
            log.debug("Cannot determine if the process is running; assuming it is", ex);
            isAlive = true;
        }
        
        if (isAlive == false)
        {
            return;
        }
        
        log.info(String.format(
                "The Elasticsearch process [%d] is still running; stopping it...",
                config.getId()));
        
        CommandLine command = ProcessUtil.buildKillCommandLine(pid);
        for (int retry = 0; retry < 3; ++retry)
        {
            try
            {
                ProcessUtil.executeScript(config, command, true);
    
                log.info(String.format(
                        "... the Elasticsearch process [%d] has stopped.",
                        config.getId()));
                ProcessUtil.cleanupPid(config.getBaseDir());
            }
            catch (Exception e)
            {
                if (e.getMessage().contains("no running instance"))
                {
                    log.info(String.format(
                            "... the Elasticsearch process [%d] has stopped.",
                            config.getId()));
                    ProcessUtil.cleanupPid(config.getBaseDir());
                }
                else
                {
                    // sometimes taskkill fails with "The operation attempted is not supported."
                    // https://blogs.technet.microsoft.com/markrussinovich/2005/08/17/unkillable-processes/
                    // in that case, retry
                    if (retry < 2) {
                        try {
                            Thread.sleep(500);
                            continue;
                        } catch (InterruptedException e1) {
                            /* ignore */
                        }
                    }
                    log.error(String.format(
                            "Error while destroying the Elasticsearch process [%d]",
                            config.getId()),
                            e);
                }
            }
            break;
        }
    }
79893
public void setExecution(ExecutionEntity execution) {
    executionId = execution.getId();
    processInstanceId = execution.getProcessInstanceId();
    processDefinitionId = execution.getProcessDefinitionId();
  }