Search in sources :

Example 6 with Container

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

the class RuntimeManagementServiceCDITest method getContainersByServerInstance_returnsListOfContainers_whenInstanceWithIdExists.

@Test
public void getContainersByServerInstance_returnsListOfContainers_whenInstanceWithIdExists() {
    final String templateId = "templateId";
    final String templateName = "templateName";
    final String serverInstanceId = "serverInstanceId";
    ServerInstanceKey serverInstanceKey = new ServerInstanceKey(templateId, templateName, serverInstanceId, "dummyUrl");
    ServerTemplate serverTemplate = new ServerTemplate(templateId, templateName, Collections.emptyList(), Collections.emptyMap(), Collections.emptyList(), Collections.singletonList(serverInstanceKey));
    final List<Container> containersInServerInstance = Arrays.asList(new Container(), new Container());
    KieServerTemplateStorage templateStorageMock = createMockStorageWithOneTemplate(serverTemplate);
    // Instance with 2 dummy containers
    KieServerInstanceManager instanceMangerMock = mock(KieServerInstanceManager.class);
    when(instanceMangerMock.getContainers(eq(serverInstanceKey))).thenReturn(containersInServerInstance);
    runtimeManagementService.setTemplateStorage(templateStorageMock);
    runtimeManagementService.setKieServerInstanceManager(instanceMangerMock);
    specManagementService.setTemplateStorage(templateStorageMock);
    specManagementService.setKieServerInstanceManager(instanceMangerMock);
    Collection<Container> containers = runtimeManagementServiceCDI.getContainersByServerInstance(templateId, serverInstanceId);
    assertThat(containers).as("Should return list of containers from server instance id").hasSameSizeAs(containersInServerInstance);
}
Also used : Container(org.kie.server.controller.api.model.runtime.Container) ServerTemplate(org.kie.server.controller.api.model.spec.ServerTemplate) KieServerInstanceManager(org.kie.server.controller.impl.KieServerInstanceManager) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) ServerInstanceKey(org.kie.server.controller.api.model.runtime.ServerInstanceKey) KieServerTemplateStorage(org.kie.server.controller.api.storage.KieServerTemplateStorage) Test(org.junit.Test)

Example 7 with Container

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

the class ContainerRemoteStatusPresenter method onServerInstanceUpdated.

public void onServerInstanceUpdated(@Observes final ServerInstanceUpdated serverInstanceUpdated) {
    if (serverInstanceUpdated != null && serverInstanceUpdated.getServerInstance() != null) {
        final String updatedServerInstanceKey = serverInstanceUpdated.getServerInstance().getServerInstanceId();
        if (index.containsKey(updatedServerInstanceKey)) {
            final Map<String, ContainerCardPresenter> oldIndex = new HashMap<String, ContainerCardPresenter>(index.remove(updatedServerInstanceKey));
            final Map<String, ContainerCardPresenter> newIndexIndex = new HashMap<String, ContainerCardPresenter>(serverInstanceUpdated.getServerInstance().getContainers().size());
            index.put(updatedServerInstanceKey, newIndexIndex);
            for (final Container container : serverInstanceUpdated.getServerInstance().getContainers()) {
                ContainerCardPresenter presenter = oldIndex.remove(container.getContainerName());
                if (!container.getStatus().equals(KieContainerStatus.STOPPED)) {
                    if (presenter != null) {
                        presenter.updateContent(serverInstanceUpdated.getServerInstance(), container);
                    } else {
                        presenter = buildContainer(container);
                    }
                    newIndexIndex.put(container.getContainerName(), presenter);
                }
            }
            for (final ContainerCardPresenter presenter : oldIndex.values()) {
                presenter.delete();
            }
        } else {
            for (final Container container : serverInstanceUpdated.getServerInstance().getContainers()) {
                if (container.getServerTemplateId().equals(containerSpec.getServerTemplateKey().getId()) && container.getContainerSpecId().equals(containerSpec.getId())) {
                    buildAndIndexContainer(container);
                }
            }
        }
    } else {
        logger.warn("Illegal event argument.");
    }
}
Also used : ContainerCardPresenter(org.kie.workbench.common.screens.server.management.client.container.status.card.ContainerCardPresenter) Container(org.kie.server.controller.api.model.runtime.Container) HashMap(java.util.HashMap)

Example 8 with Container

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

the class ContainerRemoteStatusPresenter method setup.

public void setup(final ContainerSpec containerSpec, final Collection<Container> containers) {
    this.containerSpec = containerSpec;
    this.view.clear();
    for (Container container : containers) {
        if (!container.getStatus().equals(KieContainerStatus.STOPPED)) {
            buildAndIndexContainer(container);
        }
    }
}
Also used : Container(org.kie.server.controller.api.model.runtime.Container)

Example 9 with Container

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

the class RemoteStatusPresenter method setup.

public void setup(final Collection<Container> containers) {
    view.clear();
    for (final Container container : containers) {
        final ContainerCardPresenter newCard = presenterProvider.get();
        newCard.setup(container);
        view.addCard(newCard.getView().asWidget());
    }
}
Also used : ContainerCardPresenter(org.kie.workbench.common.screens.server.management.client.remote.card.ContainerCardPresenter) Container(org.kie.server.controller.api.model.runtime.Container)

Example 10 with Container

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

the class ContainerPresenterTest method testLoadContainers.

@Test
public void testLoadContainers() {
    final Container container = new Container("containerSpecId", "containerName", new ServerInstanceKey(), Collections.<Message>emptyList(), null, null);
    containerSpecData.getContainers().add(container);
    presenter.loadContainers(containerSpecData);
    verifyLoad(true, 1);
}
Also used : Container(org.kie.server.controller.api.model.runtime.Container) ServerInstanceKey(org.kie.server.controller.api.model.runtime.ServerInstanceKey) Test(org.junit.Test)

Aggregations

Container (org.kie.server.controller.api.model.runtime.Container)21 Test (org.junit.Test)13 ServerInstanceKey (org.kie.server.controller.api.model.runtime.ServerInstanceKey)12 ContainerSpec (org.kie.server.controller.api.model.spec.ContainerSpec)7 ReleaseId (org.kie.server.api.model.ReleaseId)6 ServerTemplate (org.kie.server.controller.api.model.spec.ServerTemplate)5 ServerTemplateKey (org.kie.server.controller.api.model.spec.ServerTemplateKey)5 ContainerCardPresenter (org.kie.workbench.common.screens.server.management.client.container.status.card.ContainerCardPresenter)4 HashMap (java.util.HashMap)3 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)3 Message (org.kie.server.api.model.Message)3 ServerInstance (org.kie.server.controller.api.model.runtime.ServerInstance)3 KieServerTemplateStorage (org.kie.server.controller.api.storage.KieServerTemplateStorage)3 ContainerSpecData (org.kie.workbench.common.screens.server.management.model.ContainerSpecData)3 ArrayList (java.util.ArrayList)2 ServerInstanceUpdated (org.kie.server.controller.api.model.events.ServerInstanceUpdated)2 Capability (org.kie.server.controller.api.model.spec.Capability)2 ContainerConfig (org.kie.server.controller.api.model.spec.ContainerConfig)2 ProcessConfig (org.kie.server.controller.api.model.spec.ProcessConfig)2 RuleConfig (org.kie.server.controller.api.model.spec.RuleConfig)2