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);
}
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);
}
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));
}
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();
}
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);
}
Aggregations