Search in sources :

Example 1 with ContainerUpdateEvent

use of org.kie.workbench.common.screens.server.management.model.ContainerUpdateEvent 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 2 with ContainerUpdateEvent

use of org.kie.workbench.common.screens.server.management.model.ContainerUpdateEvent in project kie-wb-common by kiegroup.

the class AsyncKieServerInstanceManagerTest method testContainerOperationFailure.

private void testContainerOperationFailure(ContainerRuntimeOperation operation) {
    List<Message> messages = new ArrayList<Message>();
    messages.add(new Message(Severity.ERROR, "No kmodule found"));
    returnedContainers.addAll(createContainers(KieContainerStatus.FAILED, messages, 1));
    switch(operation) {
        case STOP_CONTAINER:
            this.kieServerInstanceManager.stopContainer(serverTemplate, containerSpec);
            break;
        case START_CONTAINER:
            this.kieServerInstanceManager.startContainer(serverTemplate, containerSpec);
            break;
        case UPGRADE_CONTAINER:
            this.kieServerInstanceManager.upgradeContainer(serverTemplate, containerSpec);
            break;
        case SCAN:
            this.kieServerInstanceManager.scanNow(serverTemplate, containerSpec);
            break;
        case START_SCANNER:
            this.kieServerInstanceManager.startScanner(serverTemplate, containerSpec, 10);
            break;
        case STOP_SCANNER:
            this.kieServerInstanceManager.stopScanner(serverTemplate, containerSpec);
            break;
    }
    assertFalse(receivedEvents.isEmpty());
    assertEquals(1, receivedEvents.size());
    ContainerUpdateEvent updateEvent = receivedEvents.get(0);
    assertContainerUpdateEvent(updateEvent, ContainerRuntimeState.OFFLINE, 1);
}
Also used : Message(org.kie.server.api.model.Message) ArrayList(java.util.ArrayList) ContainerUpdateEvent(org.kie.workbench.common.screens.server.management.model.ContainerUpdateEvent)

Example 3 with ContainerUpdateEvent

use of org.kie.workbench.common.screens.server.management.model.ContainerUpdateEvent in project kie-wb-common by kiegroup.

the class ServerManagementBrowserPresenterTest method testOnContainerUpdateWarn.

@Test
public void testOnContainerUpdateWarn() {
    when(view.getWarnMessage(ClientContainerRuntimeOperation.START_CONTAINER, 2)).thenReturn("Warn");
    presenter.onContainerUpdate(new ContainerUpdateEvent(mock(ServerTemplateKey.class), mock(ContainerSpec.class), new ArrayList<ServerInstanceKey>() {

        {
            add(mock(ServerInstanceKey.class));
            add(mock(ServerInstanceKey.class));
        }
    }, ContainerRuntimeState.PARTIAL_ONLINE, ContainerRuntimeOperation.START_CONTAINER));
    verify(notification).fire(new NotificationEvent("Warn", NotificationEvent.NotificationType.WARNING));
}
Also used : ArrayList(java.util.ArrayList) NotificationEvent(org.uberfire.workbench.events.NotificationEvent) ServerInstanceKey(org.kie.server.controller.api.model.runtime.ServerInstanceKey) ContainerUpdateEvent(org.kie.workbench.common.screens.server.management.model.ContainerUpdateEvent) Test(org.junit.Test)

Example 4 with ContainerUpdateEvent

use of org.kie.workbench.common.screens.server.management.model.ContainerUpdateEvent in project kie-wb-common by kiegroup.

the class ContainerPresenterTest method testRefreshOnContainerUpdateEvent.

@Test
public void testRefreshOnContainerUpdateEvent() {
    final ContainerUpdateEvent updateEvent = mock(ContainerUpdateEvent.class);
    doNothing().when(presenter).refresh();
    presenter.refreshOnContainerUpdateEvent(updateEvent);
    verify(presenter).refresh();
}
Also used : ContainerUpdateEvent(org.kie.workbench.common.screens.server.management.model.ContainerUpdateEvent) Test(org.junit.Test)

Example 5 with ContainerUpdateEvent

use of org.kie.workbench.common.screens.server.management.model.ContainerUpdateEvent in project kie-wb-common by kiegroup.

the class AsyncKieServerInstanceManagerTest method testContainerOperationPartialFailure.

private void testContainerOperationPartialFailure(ContainerRuntimeOperation operation) {
    List<Message> messages = new ArrayList<Message>();
    messages.add(new Message(Severity.ERROR, "No kmodule found"));
    returnedContainers.addAll(createContainers(KieContainerStatus.FAILED, messages, 1));
    messages.clear();
    returnedContainers.addAll(createContainers(KieContainerStatus.STARTED, messages, 1));
    switch(operation) {
        case STOP_CONTAINER:
            this.kieServerInstanceManager.stopContainer(serverTemplate, containerSpec);
            break;
        case START_CONTAINER:
            this.kieServerInstanceManager.startContainer(serverTemplate, containerSpec);
            break;
        case UPGRADE_CONTAINER:
            this.kieServerInstanceManager.upgradeContainer(serverTemplate, containerSpec);
            break;
        case SCAN:
            this.kieServerInstanceManager.scanNow(serverTemplate, containerSpec);
            break;
        case START_SCANNER:
            this.kieServerInstanceManager.startScanner(serverTemplate, containerSpec, 10);
            break;
        case STOP_SCANNER:
            this.kieServerInstanceManager.stopScanner(serverTemplate, containerSpec);
            break;
    }
    assertFalse(receivedEvents.isEmpty());
    assertEquals(1, receivedEvents.size());
    ContainerUpdateEvent updateEvent = receivedEvents.get(0);
    assertContainerUpdateEvent(updateEvent, ContainerRuntimeState.PARTIAL_ONLINE, 1);
}
Also used : Message(org.kie.server.api.model.Message) ArrayList(java.util.ArrayList) ContainerUpdateEvent(org.kie.workbench.common.screens.server.management.model.ContainerUpdateEvent)

Aggregations

ContainerUpdateEvent (org.kie.workbench.common.screens.server.management.model.ContainerUpdateEvent)10 ArrayList (java.util.ArrayList)7 Test (org.junit.Test)6 ServerInstanceKey (org.kie.server.controller.api.model.runtime.ServerInstanceKey)4 Message (org.kie.server.api.model.Message)3 NotificationEvent (org.uberfire.workbench.events.NotificationEvent)3 Container (org.kie.server.controller.api.model.runtime.Container)1 ContainerRuntimeState (org.kie.workbench.common.screens.server.management.model.ContainerRuntimeState)1