use of org.guvnor.ala.runtime.Runtime in project kie-wb-common by kiegroup.
the class RuntimeEndpointsTestIT method checkDockerService.
@Ignore
public void checkDockerService() {
Client client = ClientBuilder.newClient();
WebTarget target = client.target(APP_URL);
ResteasyWebTarget restEasyTarget = (ResteasyWebTarget) target;
RuntimeProvisioningService proxy = restEasyTarget.proxy(RuntimeProvisioningService.class);
ProviderTypeList allProviderTypes = proxy.getProviderTypes(0, 10, "", true);
assertNotNull(allProviderTypes);
assertEquals(3, allProviderTypes.getItems().size());
DockerProviderConfig dockerProviderConfig = new DockerProviderConfigImpl();
proxy.registerProvider(dockerProviderConfig);
ProviderList allProviders = proxy.getProviders(0, 10, "", true);
assertEquals(1, allProviders.getItems().size());
assertTrue(allProviders.getItems().get(0) instanceof DockerProvider);
DockerProvider dockerProvider = (DockerProvider) allProviders.getItems().get(0);
DockerRuntimeConfig runtimeConfig = new DockerRuntimeConfigImpl(dockerProvider, "kitematic/hello-world-nginx", "8080", true);
RuntimeList allRuntimes = proxy.getRuntimes(0, 10, "", true);
assertEquals(0, allRuntimes.getItems().size());
String newRuntime = proxy.newRuntime(runtimeConfig);
allRuntimes = proxy.getRuntimes(0, 10, "", true);
assertEquals(1, allRuntimes.getItems().size());
Runtime runtime = allRuntimes.getItems().get(0);
assertTrue(runtime instanceof DockerRuntime);
DockerRuntime dockerRuntime = (DockerRuntime) runtime;
assertEquals("Running", dockerRuntime.getState().getState());
proxy.stopRuntime(newRuntime);
allRuntimes = proxy.getRuntimes(0, 10, "", true);
assertEquals(1, allRuntimes.getItems().size());
runtime = allRuntimes.getItems().get(0);
assertTrue(runtime instanceof DockerRuntime);
dockerRuntime = (DockerRuntime) runtime;
assertEquals("Stopped", dockerRuntime.getState().getState());
proxy.destroyRuntime(newRuntime, true);
allRuntimes = proxy.getRuntimes(0, 10, "", true);
assertEquals(0, allRuntimes.getItems().size());
}
use of org.guvnor.ala.runtime.Runtime 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());
}
}
use of org.guvnor.ala.runtime.Runtime 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);
}
use of org.guvnor.ala.runtime.Runtime 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);
}
use of org.guvnor.ala.runtime.Runtime in project kie-wb-common by kiegroup.
the class InMemoryRuntimeRegistryTest method mockRuntime.
protected Runtime mockRuntime(ProviderId providerId, String suffix) {
Runtime runtime = mock(Runtime.class);
when(runtime.getId()).thenReturn("Runtime.id." + suffix);
when(runtime.getName()).thenReturn("Runtime.name." + suffix);
when(runtime.getProviderId()).thenReturn(providerId);
return runtime;
}
Aggregations