Search in sources :

Example 1 with ContainerList

use of org.kie.server.controller.api.model.runtime.ContainerList in project kie-wb-common by kiegroup.

the class RuntimeManagementServiceCDI method getContainersByContainerSpec.

@Override
public ContainerSpecData getContainersByContainerSpec(final String serverTemplateId, final String containerSpecId) {
    final ServerTemplate serverTemplate = specManagementService.getServerTemplate(serverTemplateId);
    if (serverTemplate == null) {
        throw new RuntimeException("Server template with id " + serverTemplateId + " not found");
    }
    final ContainerSpec containerSpec = serverTemplate.getContainerSpec(containerSpecId);
    if (containerSpec == null) {
        throw new RuntimeException("Container with id " + containerSpecId + " not found");
    }
    final ContainerList containerList = service.getContainers(serverTemplate, containerSpec);
    final List<Container> containers = Arrays.asList(containerList.getContainers());
    return new ContainerSpecData(containerSpec, containers);
}
Also used : Container(org.kie.server.controller.api.model.runtime.Container) ServerTemplate(org.kie.server.controller.api.model.spec.ServerTemplate) ContainerSpec(org.kie.server.controller.api.model.spec.ContainerSpec) ContainerList(org.kie.server.controller.api.model.runtime.ContainerList) ContainerSpecData(org.kie.workbench.common.screens.server.management.model.ContainerSpecData)

Example 2 with ContainerList

use of org.kie.server.controller.api.model.runtime.ContainerList in project kie-wb-common by kiegroup.

the class EmbeddedControllerIT method testEmbeddedEndpoints.

protected void testEmbeddedEndpoints(final KieServerControllerClient client) {
    try {
        final ServerTemplateList serverTemplateList = client.listServerTemplates();
        assertServerTemplateList(serverTemplateList);
        final ServerInstanceKeyList instances = client.getServerInstances(serverTemplateList.getServerTemplates()[0].getId());
        assertNotNull(instances);
        assertEquals(1, instances.getServerInstanceKeys().length);
        final ServerTemplate serverTemplate = serverTemplateList.getServerTemplates()[0];
        // Deploy container for kie server instance.
        ContainerSpec containerToDeploy = new ContainerSpec(CONTAINER_ID, CONTAINER_NAME, serverTemplate, RELEASE_ID, KieContainerStatus.STARTED, new HashMap());
        client.saveContainerSpec(serverTemplate.getId(), containerToDeploy);
        ContainerList containers = client.getContainers(instances.getServerInstanceKeys()[0]);
        assertNotNull(containers);
        assertEquals(1, containers.getContainers().length);
        client.deleteContainerSpec(serverTemplate.getId(), containerToDeploy.getId());
        containers = client.getContainers(instances.getServerInstanceKeys()[0]);
        assertNotNull(containers);
        assertEquals(0, containers.getContainers().length);
    } finally {
        if (client != null) {
            try {
                client.close();
            } catch (IOException ex) {
                LOGGER.warn("Error trying to close client connection: {}", ex.getMessage(), ex);
            }
        }
    }
}
Also used : ServerTemplate(org.kie.server.controller.api.model.spec.ServerTemplate) HashMap(java.util.HashMap) ServerTemplateList(org.kie.server.controller.api.model.spec.ServerTemplateList) ContainerSpec(org.kie.server.controller.api.model.spec.ContainerSpec) ContainerList(org.kie.server.controller.api.model.runtime.ContainerList) ServerInstanceKeyList(org.kie.server.controller.api.model.runtime.ServerInstanceKeyList) IOException(java.io.IOException)

Aggregations

ContainerList (org.kie.server.controller.api.model.runtime.ContainerList)2 ContainerSpec (org.kie.server.controller.api.model.spec.ContainerSpec)2 ServerTemplate (org.kie.server.controller.api.model.spec.ServerTemplate)2 IOException (java.io.IOException)1 HashMap (java.util.HashMap)1 Container (org.kie.server.controller.api.model.runtime.Container)1 ServerInstanceKeyList (org.kie.server.controller.api.model.runtime.ServerInstanceKeyList)1 ServerTemplateList (org.kie.server.controller.api.model.spec.ServerTemplateList)1 ContainerSpecData (org.kie.workbench.common.screens.server.management.model.ContainerSpecData)1