@Override public void activateContainer(ContainerSpecKey containerSpecKey) { makePostRequestAndCreateCustomResponse(controllerBaseUrl + MANAGEMENT_URI_PART + containerSpecKey.getServerTemplateKey().getId() + CONTAINERS_URI_PART + containerSpecKey.getId() + ACTIVATED_STATUS_URI_PART, "", null); }
@Override public void startContainer(ContainerSpecKey containerSpecKey) { makePostRequestAndCreateCustomResponse(controllerBaseUrl + MANAGEMENT_URI_PART + containerSpecKey.getServerTemplateKey().getId() + CONTAINERS_URI_PART + containerSpecKey.getId() + STARTED_STATUS_URI_PART, "", null); }
@Override public void stopContainer(ContainerSpecKey containerSpecKey) { makePostRequestAndCreateCustomResponse(controllerBaseUrl + MANAGEMENT_URI_PART + containerSpecKey.getServerTemplateKey().getId() + CONTAINERS_URI_PART + containerSpecKey.getId() + STOPPED_STATUS_URI_PART, "", null); }
@Override public void deactivateContainer(ContainerSpecKey containerSpecKey) { makePostRequestAndCreateCustomResponse(controllerBaseUrl + MANAGEMENT_URI_PART + containerSpecKey.getServerTemplateKey().getId() + CONTAINERS_URI_PART + containerSpecKey.getId() + DEACTIVATED_STATUS_URI_PART, "", null); }
public void onContainerSelect( @Observes final ContainerSpecSelected containerSpecSelected ) { if ( containerSpecSelected != null && containerSpecSelected.getContainerSpecKey() != null && containerSpecSelected.getContainerSpecKey().getServerTemplateKey() != null && containerSpecSelected.getContainerSpecKey().getServerTemplateKey().getId() != null && containerSpecSelected.getContainerSpecKey().getId() != null ) { view.selectContainer( containerSpecSelected.getContainerSpecKey().getServerTemplateKey().getId(), containerSpecSelected.getContainerSpecKey().getId() ); } else { logger.warn( "Illegal event argument." ); } }
@Test public void testSaveError() { final String templateKey = "templateKey"; final String containerKey = "containerKey"; when( serverTemplateKey.getId() ).thenReturn( templateKey ); when( containerSpecKey.getId() ).thenReturn( containerKey ); when( view.getSaveErrorMessage() ).thenReturn( "ERROR" ); doThrow( new RuntimeException() ).when( specManagementService ).updateContainerConfig( anyString(), anyString(), any( Capability.class ), any( ContainerConfig.class ) ); presenter.save(); verify( notification ).fire( new NotificationEvent( "ERROR", NotificationEvent.NotificationType.ERROR ) ); verify( view ).disableActions(); verify( view ).enableActions(); verify( processConfigPresenter ).setProcessConfig( processConfig ); }
@Test public void testSave() { final String templateKey = "templateKey"; final String containerKey = "containerKey"; when( serverTemplateKey.getId() ).thenReturn( templateKey ); when( containerSpecKey.getId() ).thenReturn( containerKey ); when( view.getSaveSuccessMessage() ).thenReturn( "SUCCESS" ); presenter.save(); verify( notification ).fire( new NotificationEvent( "SUCCESS", NotificationEvent.NotificationType.SUCCESS ) ); verify( view ).disableActions(); verify( processConfigPresenter ).buildProcessConfig(); final ArgumentCaptor<ProcessConfig> processConfigCaptor = ArgumentCaptor.forClass( ProcessConfig.class ); verify( specManagementService ).updateContainerConfig( eq( templateKey ), eq( containerKey ), eq( Capability.PROCESS ), processConfigCaptor.capture() ); verify( view ).enableActions(); verify( processConfigPresenter ).setProcessConfig( processConfigCaptor.getValue() ); }
@Override public void scanNow(final ContainerSpecKey containerSpecKey) { ServerTemplate serverTemplate = templateStorage.load(containerSpecKey.getServerTemplateKey().getId()); if (serverTemplate == null) { throw new KieServerControllerIllegalArgumentException("No server template found for id " + containerSpecKey.getServerTemplateKey().getId()); } ContainerSpec containerSpec = serverTemplate.getContainerSpec(containerSpecKey.getId()); if (containerSpec == null) { throw new KieServerControllerIllegalArgumentException("No container spec found for id " + containerSpecKey.getId()); } List<Container> containers = kieServerInstanceManager.scanNow(serverTemplate, containerSpec); notificationService.notify(serverTemplate, containerSpec, containers); }
@Override public synchronized void deactivateContainer(ContainerSpecKey containerSpecKey) { ServerTemplate serverTemplate = templateStorage.load(containerSpecKey.getServerTemplateKey().getId()); if (serverTemplate == null) { throw new KieServerControllerIllegalArgumentException("No server template found for id " + containerSpecKey.getServerTemplateKey().getId()); } ContainerSpec containerSpec = serverTemplate.getContainerSpec(containerSpecKey.getId()); if (containerSpec == null) { throw new KieServerControllerIllegalArgumentException("No container spec found for id " + containerSpecKey.getId() + " within server template with id " + serverTemplate.getId()); } if (!containerSpec.getStatus().equals(KieContainerStatus.STARTED)) { throw new KieServerControllerIllegalArgumentException("Container " + containerSpecKey.getId() + " cannot be deactivated because it's not in started state, actual state " + containerSpec.getStatus()); } containerSpec.setStatus(KieContainerStatus.DEACTIVATED); templateStorage.update(serverTemplate); List<Container> containers = kieServerInstanceManager.deactivateContainer(serverTemplate, containerSpec); notificationService.notify(serverTemplate, containerSpec, containers); }
@Override public synchronized void activateContainer(ContainerSpecKey containerSpecKey) { ServerTemplate serverTemplate = templateStorage.load(containerSpecKey.getServerTemplateKey().getId()); if (serverTemplate == null) { throw new KieServerControllerIllegalArgumentException("No server template found for id " + containerSpecKey.getServerTemplateKey().getId()); } final ContainerSpec containerSpec = serverTemplate.getContainerSpec(containerSpecKey.getId()); if (containerSpec == null) { throw new KieServerControllerIllegalArgumentException("No container spec found for id " + containerSpecKey.getId() + " within server template with id " + serverTemplate.getId()); } if (!containerSpec.getStatus().equals(KieContainerStatus.DEACTIVATED)) { throw new KieServerControllerIllegalArgumentException("Container " + containerSpecKey.getId() + " cannot be activated because it's not in deactivated state, actual state " + containerSpec.getStatus()); } containerSpec.setStatus(KieContainerStatus.STARTED); templateStorage.update(serverTemplate); List<Container> containers = kieServerInstanceManager.activateContainer(serverTemplate, containerSpec); notificationService.notify(serverTemplate, containerSpec, containers); }
@Override public synchronized void startContainer(ContainerSpecKey containerSpecKey) { ServerTemplate serverTemplate = templateStorage.load(containerSpecKey.getServerTemplateKey().getId()); if (serverTemplate == null) { throw new KieServerControllerIllegalArgumentException("No server template found for id " + containerSpecKey.getServerTemplateKey().getId()); } final ContainerSpec containerSpec = serverTemplate.getContainerSpec(containerSpecKey.getId()); if (containerSpec == null) { throw new KieServerControllerIllegalArgumentException("No container spec found for id " + containerSpecKey.getId() + " within server template with id " + serverTemplate.getId()); } containerSpec.setStatus(KieContainerStatus.STARTED); templateStorage.update(serverTemplate); List<Container> containers = kieServerInstanceManager.startContainer(serverTemplate, containerSpec); notificationService.notify(serverTemplate, containerSpec, containers); }
@Override public synchronized void stopContainer(ContainerSpecKey containerSpecKey) { ServerTemplate serverTemplate = templateStorage.load(containerSpecKey.getServerTemplateKey().getId()); if (serverTemplate == null) { throw new KieServerControllerIllegalArgumentException("No server template found for id " + containerSpecKey.getServerTemplateKey().getId()); } ContainerSpec containerSpec = serverTemplate.getContainerSpec(containerSpecKey.getId()); if (containerSpec == null) { throw new KieServerControllerIllegalArgumentException("No container spec found for id " + containerSpecKey.getId() + " within server template with id " + serverTemplate.getId()); } containerSpec.setStatus(KieContainerStatus.STOPPED); templateStorage.update(serverTemplate); List<Container> containers = kieServerInstanceManager.stopContainer(serverTemplate, containerSpec); notificationService.notify(serverTemplate, containerSpec, containers); }
@Override public void startScanner(final ContainerSpecKey containerSpecKey, final Long interval) { ServerTemplate serverTemplate = templateStorage.load(containerSpecKey.getServerTemplateKey().getId()); if (serverTemplate == null) { throw new KieServerControllerIllegalArgumentException("No server template found for id " + containerSpecKey.getServerTemplateKey().getId()); } ContainerSpec containerSpec = serverTemplate.getContainerSpec(containerSpecKey.getId()); if (containerSpec == null) { throw new KieServerControllerIllegalArgumentException("No container spec found for id " + containerSpecKey.getId()); } ContainerConfig containerConfig = containerSpec.getConfigs().get(Capability.RULE); if (containerConfig == null) { containerConfig = new RuleConfig(); containerSpec.getConfigs().put(Capability.RULE, containerConfig); } ((RuleConfig) containerConfig).setPollInterval(interval); ((RuleConfig) containerConfig).setScannerStatus(KieScannerStatus.STARTED); templateStorage.update(serverTemplate); List<Container> containers = kieServerInstanceManager.startScanner(serverTemplate, containerSpec, interval); notificationService.notify(serverTemplate, containerSpec, containers); }
@Override public void stopScanner(final ContainerSpecKey containerSpecKey) { ServerTemplate serverTemplate = templateStorage.load(containerSpecKey.getServerTemplateKey().getId()); if (serverTemplate == null) { throw new KieServerControllerIllegalArgumentException("No server template found for id " + containerSpecKey.getServerTemplateKey().getId()); } ContainerSpec containerSpec = serverTemplate.getContainerSpec(containerSpecKey.getId()); if (containerSpec == null) { throw new KieServerControllerIllegalArgumentException("No container spec found for id " + containerSpecKey.getId()); } ContainerConfig containerConfig = containerSpec.getConfigs().get(Capability.RULE); if (containerConfig == null) { containerConfig = new RuleConfig(); containerSpec.getConfigs().put(Capability.RULE, containerConfig); } if(((RuleConfig) containerConfig).getScannerStatus() == KieScannerStatus.STOPPED){ return; } ((RuleConfig) containerConfig).setPollInterval(null); ((RuleConfig) containerConfig).setScannerStatus(KieScannerStatus.STOPPED); templateStorage.update(serverTemplate); List<Container> containers = kieServerInstanceManager.stopScanner(serverTemplate, containerSpec); notificationService.notify(serverTemplate, containerSpec, containers); }
public void load(final ContainerSpecKey containerSpecKey) { checkNotNull("containerSpecKey", containerSpecKey); runtimeManagementService.call((RemoteCallback<ContainerSpecData>) content -> { checkNotNull("content", content); setContainerSpec(content.getContainerSpec()); loadContainers(content); }).getContainersByContainerSpec(containerSpecKey.getServerTemplateKey().getId(), containerSpecKey.getId()); }
@Test public void testOnContainerSelect() { final ServerTemplateKey serverTemplateKey = new ServerTemplateKey( "ServerTemplateKeyId", "ServerTemplateKeyName" ); final ContainerSpecKey containerSpecKey = new ContainerSpecKey( "containerId", "containerName", serverTemplateKey ); presenter.onContainerSelect( new ContainerSpecSelected( containerSpecKey ) ); verify( view ).selectContainer( serverTemplateKey.getId(), containerSpecKey.getId() ); }
public void save() { view.disableActions(); final ProcessConfig newProcessConfig = processConfigPresenter.buildProcessConfig(); specManagementService.call( new RemoteCallback<Void>() { @Override public void callback( final Void containerConfig ) { notification.fire( new NotificationEvent( view.getSaveSuccessMessage(), NotificationEvent.NotificationType.SUCCESS ) ); setupView( newProcessConfig ); } }, new ErrorCallback<Object>() { @Override public boolean error( final Object o, final Throwable throwable ) { notification.fire( new NotificationEvent( view.getSaveErrorMessage(), NotificationEvent.NotificationType.ERROR ) ); setupView( processConfigPresenter.getProcessConfig() ); return false; } } ) .updateContainerConfig( processConfigPresenter.getContainerSpecKey().getServerTemplateKey().getId(), processConfigPresenter.getContainerSpecKey().getId(), Capability.PROCESS, newProcessConfig ); }
@Override public void upgradeContainer(final ContainerSpecKey containerSpecKey, ReleaseId releaseId) { ServerTemplate serverTemplate = templateStorage.load(containerSpecKey.getServerTemplateKey().getId()); if (serverTemplate == null) { throw new KieServerControllerIllegalArgumentException("No server template found for id " + containerSpecKey.getServerTemplateKey().getId()); } ContainerSpec containerSpec = serverTemplate.getContainerSpec(containerSpecKey.getId()); if (containerSpec == null) { throw new KieServerControllerIllegalArgumentException("No container spec found for id " + containerSpecKey.getId()); } if (releaseId.getGroupId() == null) { releaseId.setGroupId(containerSpec.getReleasedId().getGroupId()); } if (releaseId.getArtifactId() == null) { releaseId.setArtifactId(containerSpec.getReleasedId().getArtifactId()); } final List<Container> containers; containerSpec.setReleasedId(releaseId); if (containerSpec.getStatus() == KieContainerStatus.STARTED) { containers = kieServerInstanceManager.upgradeContainer(serverTemplate, containerSpec); } else { containers = kieServerInstanceManager.startContainer(serverTemplate, containerSpec); } containerSpec.setStatus(KieContainerStatus.STARTED); templateStorage.update(serverTemplate); notificationService.notify(serverTemplate, containerSpec, containers); }