Search in sources :

Example 1 with BusinessException

use of org.guvnor.ala.services.exceptions.BusinessException in project kie-wb-common by kiegroup.

the class RestPipelineServiceImpl method runPipeline.

@Override
public String runPipeline(final String pipelineId, final Input input, final boolean async) throws BusinessException {
    final Pipeline pipeline = pipelineRegistry.getPipelineByName(pipelineId);
    if (pipeline == null) {
        throw new BusinessException("Pipeline: " + pipelineId + " was not found.");
    }
    String providerName = input.get(ProviderConfig.PROVIDER_NAME);
    Provider provider = null;
    ProviderType providerType = null;
    PipelineExecutorTaskDef taskDef;
    if (providerName != null && !providerName.isEmpty()) {
        provider = runtimeRegistry.getProvider(providerName);
    }
    if (provider == null) {
        providerType = pipelineRegistry.getProviderType(pipelineId);
    }
    if (provider != null) {
        taskDef = new PipelineExecutorTaskDefImpl(pipeline, input, provider);
    } else if (providerType != null) {
        taskDef = new PipelineExecutorTaskDefImpl(pipeline, input, providerType);
    } else {
        taskDef = new PipelineExecutorTaskDefImpl(pipeline, input);
    }
    return executorTaskManager.execute(taskDef, async ? PipelineExecutorTaskManager.ExecutionMode.ASYNCHRONOUS : PipelineExecutorTaskManager.ExecutionMode.SYNCHRONOUS);
}
Also used : PipelineExecutorTaskDefImpl(org.guvnor.ala.pipeline.execution.impl.PipelineExecutorTaskDefImpl) BusinessException(org.guvnor.ala.services.exceptions.BusinessException) ProviderType(org.guvnor.ala.runtime.providers.ProviderType) ConfigBasedPipeline(org.guvnor.ala.pipeline.ConfigBasedPipeline) Pipeline(org.guvnor.ala.pipeline.Pipeline) Provider(org.guvnor.ala.runtime.providers.Provider) PipelineExecutorTaskDef(org.guvnor.ala.pipeline.execution.PipelineExecutorTaskDef)

Example 2 with BusinessException

use of org.guvnor.ala.services.exceptions.BusinessException in project kie-wb-common by kiegroup.

the class RestRuntimeProvisioningServiceImpl method destroyRuntime.

@Override
public void destroyRuntime(String runtimeId, boolean forced) throws BusinessException {
    final Runtime runtimeById = runtimeRegistry.getRuntimeById(runtimeId);
    if (runtimeById == null) {
        throw new BusinessException("No runtime was found for runtimeId: " + runtimeId);
    }
    final PipelineExecutorTrace pipelineTrace = pipelineExecutorRegistry.getExecutorTrace(runtimeById);
    try {
        runtimeFactory.destroyRuntime(runtimeById);
    } catch (Exception e) {
        if (forced) {
            LOG.warn("Runtime destroy raised the following error for runtime: " + runtimeId + " but forced destroy will still remove the runtime from registry.", e);
            runtimeRegistry.deregisterRuntime(runtimeById);
        } else {
            throw e;
        }
    }
    if (pipelineTrace != null) {
        pipelineExecutorRegistry.deregister(pipelineTrace.getTaskId());
    }
}
Also used : Runtime(org.guvnor.ala.runtime.Runtime) BusinessException(org.guvnor.ala.services.exceptions.BusinessException) PipelineExecutorTrace(org.guvnor.ala.pipeline.execution.PipelineExecutorTrace) BusinessException(org.guvnor.ala.services.exceptions.BusinessException)

Example 3 with BusinessException

use of org.guvnor.ala.services.exceptions.BusinessException in project kie-wb-common by kiegroup.

the class RestRuntimeProvisioningServiceImpl method restartRuntime.

@Override
public void restartRuntime(String runtimeId) throws BusinessException {
    final Runtime runtimeById = runtimeRegistry.getRuntimeById(runtimeId);
    if (runtimeById == null) {
        throw new BusinessException("No runtime was found for runtimeId: " + runtimeId);
    }
    runtimeManagerFactory.restartRuntime(runtimeById);
}
Also used : Runtime(org.guvnor.ala.runtime.Runtime) BusinessException(org.guvnor.ala.services.exceptions.BusinessException)

Example 4 with BusinessException

use of org.guvnor.ala.services.exceptions.BusinessException in project kie-wb-common by kiegroup.

the class RestRuntimeProvisioningServiceImpl method startRuntime.

@Override
public void startRuntime(String runtimeId) throws BusinessException {
    final Runtime runtimeById = runtimeRegistry.getRuntimeById(runtimeId);
    if (runtimeById == null) {
        throw new BusinessException("No runtime was found for runtimeId: " + runtimeId);
    }
    runtimeManagerFactory.startRuntime(runtimeById);
}
Also used : Runtime(org.guvnor.ala.runtime.Runtime) BusinessException(org.guvnor.ala.services.exceptions.BusinessException)

Example 5 with BusinessException

use of org.guvnor.ala.services.exceptions.BusinessException in project kie-wb-common by kiegroup.

the class RestRuntimeProvisioningServiceImpl method stopRuntime.

@Override
public void stopRuntime(String runtimeId) throws BusinessException {
    final Runtime runtimeById = runtimeRegistry.getRuntimeById(runtimeId);
    if (runtimeById == null) {
        throw new BusinessException("No runtime was found for runtimeId: " + runtimeId);
    }
    runtimeManagerFactory.stopRuntime(runtimeById);
}
Also used : Runtime(org.guvnor.ala.runtime.Runtime) BusinessException(org.guvnor.ala.services.exceptions.BusinessException)

Aggregations

BusinessException (org.guvnor.ala.services.exceptions.BusinessException)5 Runtime (org.guvnor.ala.runtime.Runtime)4 ConfigBasedPipeline (org.guvnor.ala.pipeline.ConfigBasedPipeline)1 Pipeline (org.guvnor.ala.pipeline.Pipeline)1 PipelineExecutorTaskDef (org.guvnor.ala.pipeline.execution.PipelineExecutorTaskDef)1 PipelineExecutorTrace (org.guvnor.ala.pipeline.execution.PipelineExecutorTrace)1 PipelineExecutorTaskDefImpl (org.guvnor.ala.pipeline.execution.impl.PipelineExecutorTaskDefImpl)1 Provider (org.guvnor.ala.runtime.providers.Provider)1 ProviderType (org.guvnor.ala.runtime.providers.ProviderType)1