Search in sources :

Example 1 with Container

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

the class RemotePresenterTest method testSelectAndRefresh.

@Test
public void testSelectAndRefresh() {
    final ServerInstanceKey serverInstanceKey = new ServerInstanceKey("templateId", "serverName", "serverInstanceId", "url");
    final Container container = new Container("containerSpecId", "containerName", serverInstanceKey, Collections.<Message>emptyList(), null, null);
    final List<Container> containers = Collections.singletonList(container);
    when(runtimeManagementService.getContainersByServerInstance(serverInstanceKey.getServerTemplateId(), serverInstanceKey.getServerInstanceId())).thenReturn(containers);
    presenter.onSelect(new ServerInstanceSelected(serverInstanceKey));
    verify(view).clear();
    verify(view).setServerName(serverInstanceKey.getServerName());
    verify(view).setServerURL(serverInstanceKey.getUrl());
    verify(remoteStatusPresenter).setup(containers);
    verify(view).setStatusPresenter(remoteStatusPresenter.getView());
}
Also used : Container(org.kie.server.controller.api.model.runtime.Container) ServerInstanceKey(org.kie.server.controller.api.model.runtime.ServerInstanceKey) ServerInstanceSelected(org.kie.workbench.common.screens.server.management.client.events.ServerInstanceSelected) Test(org.junit.Test)

Example 2 with Container

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

the class ContainerCardPresenterTest method testSetup.

@Test
public void testSetup() {
    final InfoTitlePresenter infoTitlePresenter = mock(InfoTitlePresenter.class);
    when(infoTitlePresenterProvider.get()).thenReturn(infoTitlePresenter);
    final LinkTitlePresenter linkTitlePresenter = spy(new LinkTitlePresenter(mock(LinkTitlePresenter.View.class)));
    when(linkTitlePresenterProvider.get()).thenReturn(linkTitlePresenter);
    final BodyPresenter bodyPresenter = mock(BodyPresenter.class);
    when(bodyPresenterProvider.get()).thenReturn(bodyPresenter);
    final FooterPresenter footerPresenter = mock(FooterPresenter.class);
    when(footerPresenterProvider.get()).thenReturn(footerPresenter);
    final CardPresenter.View cardPresenterView = mock(CardPresenter.View.class);
    final CardPresenter cardPresenter = spy(new CardPresenter(cardPresenterView));
    when(cardPresenterProvider.get()).thenReturn(cardPresenter);
    final ServerInstanceKey serverInstanceKey = new ServerInstanceKey("templateId", "serverName", "serverInstanceId", "url");
    final Message message = new Message(Severity.INFO, "testMessage");
    final ReleaseId resolvedReleasedId = new ReleaseId("org.kie", "container", "1.0.0");
    final Container container = new Container("containerSpecId", "containerName", serverInstanceKey, Collections.singletonList(message), resolvedReleasedId, null);
    presenter.setup(container);
    verify(linkTitlePresenter).setup(eq(container.getContainerName()), any(Command.class));
    verify(infoTitlePresenter).setup(container.getResolvedReleasedId());
    verify(bodyPresenter).setup(Arrays.asList(message));
    verify(footerPresenter).setup(container.getUrl(), resolvedReleasedId.getVersion());
    verify(cardPresenter).addTitle(linkTitlePresenter);
    verify(cardPresenter).addTitle(infoTitlePresenter);
    verify(cardPresenter).addBody(bodyPresenter);
    verify(cardPresenter).addFooter(footerPresenter);
    verify(view).setCard(cardPresenterView);
    linkTitlePresenter.onSelect();
    final ContainerSpecKey containerSpecKey = new ContainerSpecKey(container.getContainerSpecId(), container.getContainerName(), new ServerTemplateKey(container.getServerInstanceKey().getServerTemplateId(), ""));
    verify(containerSpecSelectedEvent).fire(eq(new ContainerSpecSelected(containerSpecKey)));
}
Also used : ServerTemplateKey(org.kie.server.controller.api.model.spec.ServerTemplateKey) Message(org.kie.server.api.model.Message) FooterPresenter(org.kie.workbench.common.screens.server.management.client.widget.card.footer.FooterPresenter) ReleaseId(org.kie.server.api.model.ReleaseId) ContainerSpecKey(org.kie.server.controller.api.model.spec.ContainerSpecKey) InfoTitlePresenter(org.kie.workbench.common.screens.server.management.client.widget.card.title.InfoTitlePresenter) Container(org.kie.server.controller.api.model.runtime.Container) Command(org.uberfire.mvp.Command) CardPresenter(org.kie.workbench.common.screens.server.management.client.widget.card.CardPresenter) ContainerSpecSelected(org.kie.workbench.common.screens.server.management.client.events.ContainerSpecSelected) ServerInstanceKey(org.kie.server.controller.api.model.runtime.ServerInstanceKey) LinkTitlePresenter(org.kie.workbench.common.screens.server.management.client.widget.card.title.LinkTitlePresenter) BodyPresenter(org.kie.workbench.common.screens.server.management.client.widget.card.body.BodyPresenter) Test(org.junit.Test)

Example 3 with Container

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

the class AsyncKieServerInstanceManager method produceContainerUpdateEvent.

protected void produceContainerUpdateEvent(ServerTemplate serverTemplate, ContainerSpec containerSpec, List<Container> containers, ContainerRuntimeOperation containerRuntimeOperation) {
    List<ServerInstanceKey> failedServerInstances = new ArrayList<ServerInstanceKey>();
    for (Container container : containers) {
        if (hasIssues(container)) {
            failedServerInstances.add(container.getServerInstanceKey());
        }
    }
    ContainerRuntimeState containerRuntimeState = ContainerRuntimeState.ONLINE;
    if (failedServerInstances.size() == containers.size()) {
        containerRuntimeState = ContainerRuntimeState.OFFLINE;
    } else if (!failedServerInstances.isEmpty()) {
        containerRuntimeState = ContainerRuntimeState.PARTIAL_ONLINE;
    }
    ContainerUpdateEvent updateEvent = new ContainerUpdateEvent(serverTemplate, containerSpec, failedServerInstances, containerRuntimeState, containerRuntimeOperation);
    containerUpdateEvent.fire(updateEvent);
}
Also used : Container(org.kie.server.controller.api.model.runtime.Container) ContainerRuntimeState(org.kie.workbench.common.screens.server.management.model.ContainerRuntimeState) ArrayList(java.util.ArrayList) ServerInstanceKey(org.kie.server.controller.api.model.runtime.ServerInstanceKey) ContainerUpdateEvent(org.kie.workbench.common.screens.server.management.model.ContainerUpdateEvent)

Example 4 with Container

use of org.kie.server.controller.api.model.runtime.Container 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);
    final ContainerSpec containerSpec = serverTemplate.getContainerSpec(containerSpecId);
    final ServerInstanceKeyList instances = service.getServerInstances(serverTemplateId);
    if (instances.getServerInstanceKeys() == null) {
        return null;
    }
    final List<Container> containers = Arrays.stream(instances.getServerInstanceKeys()).flatMap(serverInstanceKey -> Arrays.asList(service.getContainers(serverInstanceKey).getContainers()).stream()).filter(container -> containerSpecId.equals(container.getContainerSpecId())).collect(Collectors.toList());
    return new ContainerSpecData(containerSpec, containers);
}
Also used : Arrays(java.util.Arrays) ServerTemplate(org.kie.server.controller.api.model.spec.ServerTemplate) Collection(java.util.Collection) ContainerSpec(org.kie.server.controller.api.model.spec.ContainerSpec) Collectors(java.util.stream.Collectors) Inject(javax.inject.Inject) List(java.util.List) Service(org.jboss.errai.bus.server.annotations.Service) Container(org.kie.server.controller.api.model.runtime.Container) ApplicationScoped(javax.enterprise.context.ApplicationScoped) ContainerSpecData(org.kie.workbench.common.screens.server.management.model.ContainerSpecData) Any(javax.enterprise.inject.Any) ServerInstanceKeyList(org.kie.server.controller.api.model.runtime.ServerInstanceKeyList) Collections(java.util.Collections) RuntimeManagementService(org.kie.workbench.common.screens.server.management.service.RuntimeManagementService) 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) ServerInstanceKeyList(org.kie.server.controller.api.model.runtime.ServerInstanceKeyList) ContainerSpecData(org.kie.workbench.common.screens.server.management.model.ContainerSpecData)

Example 5 with Container

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

the class RuntimeManagementServiceCDITest method getContainersByContainerSpec_returnsContainerSpecData.

@Test
public void getContainersByContainerSpec_returnsContainerSpecData() {
    final String templateId = "templateId", templateName = "templateName", serverInstanceId = "serverInstanceId", containerName = "containerName1", group = "g1", artifact = "a1", version = "1", containerSpecId = String.join(":", group, artifact, version);
    final ReleaseId releaseId = new ReleaseId(group, artifact, version);
    ServerInstanceKey serverInstanceKey = new ServerInstanceKey(templateId, null, serverInstanceId, null);
    Container container = new Container(containerSpecId, containerName, serverInstanceKey, Collections.emptyList(), releaseId, null);
    ContainerSpec containerSpec = new ContainerSpec(containerSpecId, containerName, new ServerTemplateKey(templateId, templateName), releaseId, KieContainerStatus.STARTED, Collections.emptyMap());
    ServerTemplate serverTemplate = new ServerTemplate(templateId, templateName, Collections.emptyList(), Collections.emptyMap(), Collections.singletonList(containerSpec), Collections.singletonList(serverInstanceKey));
    final List<Container> containersInServerInstance = Collections.singletonList(container);
    // Setup mocks
    KieServerTemplateStorage templateStorageMock = createMockStorageWithOneTemplate(serverTemplate);
    KieServerInstanceManager instanceMangerMock = mock(KieServerInstanceManager.class);
    when(instanceMangerMock.getContainers(serverInstanceKey)).thenReturn(containersInServerInstance);
    // Setup tested object
    runtimeManagementService.setTemplateStorage(templateStorageMock);
    runtimeManagementService.setKieServerInstanceManager(instanceMangerMock);
    specManagementService.setTemplateStorage(templateStorageMock);
    specManagementService.setKieServerInstanceManager(instanceMangerMock);
    // Tested method
    ContainerSpecData containerSpecData = runtimeManagementServiceCDI.getContainersByContainerSpec(templateId, containerSpecId);
    assertThat(containerSpecData.getContainers()).contains(container);
    assertThat(containerSpecData.getContainerSpec()).isEqualTo(containerSpec);
}
Also used : Container(org.kie.server.controller.api.model.runtime.Container) ServerTemplateKey(org.kie.server.controller.api.model.spec.ServerTemplateKey) ServerTemplate(org.kie.server.controller.api.model.spec.ServerTemplate) ContainerSpec(org.kie.server.controller.api.model.spec.ContainerSpec) KieServerInstanceManager(org.kie.server.controller.impl.KieServerInstanceManager) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) ReleaseId(org.kie.server.api.model.ReleaseId) ServerInstanceKey(org.kie.server.controller.api.model.runtime.ServerInstanceKey) ContainerSpecData(org.kie.workbench.common.screens.server.management.model.ContainerSpecData) KieServerTemplateStorage(org.kie.server.controller.api.storage.KieServerTemplateStorage) 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