@Test public void removePluginInstanceByIdShouldSuccess() throws ScriptException { prepareDatabase(); try { pluginInstanceService.removePluginInstanceById("service-mgmt__v1.0__service-mgmt__127.0.0.1__20003"); assertThat(true); } catch (Exception e) { assertThat(false); } }
public void removePluginInstanceById(String instanceId) throws Exception { logger.info("Removing instanceId: " + instanceId); Optional<PluginInstance> instanceOptional = pluginInstanceRepository.findById(instanceId); PluginInstance instance = instanceOptional.get(); ResourceItemDto removeDockerInstanceDto = new ResourceItemDto(); removeDockerInstanceDto.setName(instance.getContainerName()); removeDockerInstanceDto.setId(instance.getDockerInstanceResourceId()); resourceManagementService.deleteItems(Lists.newArrayList(removeDockerInstanceDto)); pluginInstanceRepository.deleteById(instanceId); }
PluginInstanceService { public void removePluginInstanceById(String instanceId) throws Exception { logger.info("Removing instanceId: " + instanceId); Optional<PluginInstance> instanceOptional = pluginInstanceRepository.findById(instanceId); PluginInstance instance = instanceOptional.get(); ResourceItemDto removeDockerInstanceDto = new ResourceItemDto(); removeDockerInstanceDto.setName(instance.getContainerName()); removeDockerInstanceDto.setId(instance.getDockerInstanceResourceId()); resourceManagementService.deleteItems(Lists.newArrayList(removeDockerInstanceDto)); pluginInstanceRepository.deleteById(instanceId); } }
PluginInstanceService { public void removePluginInstanceById(String instanceId) throws Exception { logger.info("Removing instanceId: " + instanceId); Optional<PluginInstance> instanceOptional = pluginInstanceRepository.findById(instanceId); PluginInstance instance = instanceOptional.get(); ResourceItemDto removeDockerInstanceDto = new ResourceItemDto(); removeDockerInstanceDto.setName(instance.getContainerName()); removeDockerInstanceDto.setId(instance.getDockerInstanceResourceId()); resourceManagementService.deleteItems(Lists.newArrayList(removeDockerInstanceDto)); pluginInstanceRepository.deleteById(instanceId); }  }
PluginInstanceService { public void removePluginInstanceById(String instanceId) throws Exception { logger.info("Removing instanceId: " + instanceId); Optional<PluginInstance> instanceOptional = pluginInstanceRepository.findById(instanceId); PluginInstance instance = instanceOptional.get(); ResourceItemDto removeDockerInstanceDto = new ResourceItemDto(); removeDockerInstanceDto.setName(instance.getContainerName()); removeDockerInstanceDto.setId(instance.getDockerInstanceResourceId()); resourceManagementService.deleteItems(Lists.newArrayList(removeDockerInstanceDto)); pluginInstanceRepository.deleteById(instanceId); }  List<String> getAvailableContainerHosts(); Integer getAvailablePortByHostIp(String hostIp); List<PluginInstance> getAllInstances(); List<PluginInstance> getAvailableInstancesByPackageId(String packageId); PluginInstance getRunningPluginInstance(String pluginName); List<PluginInstance> getRunningPluginInstances(String pluginName); boolean versionGreaterThan(String version, String baseVersion); boolean versionEquals(String version, String baseVersion); void launchPluginInstance(String packageId, String hostIp, Integer port); PluginMysqlInstance createPluginMysqlDatabase(PluginPackageRuntimeResourcesMysql mysqlInfo,
            String currentPluginVersion); void removePluginInstanceById(String instanceId); String getInstanceAddress(PluginInstance instance); }
PluginInstanceService { public void removePluginInstanceById(String instanceId) throws Exception { logger.info("Removing instanceId: " + instanceId); Optional<PluginInstance> instanceOptional = pluginInstanceRepository.findById(instanceId); PluginInstance instance = instanceOptional.get(); ResourceItemDto removeDockerInstanceDto = new ResourceItemDto(); removeDockerInstanceDto.setName(instance.getContainerName()); removeDockerInstanceDto.setId(instance.getDockerInstanceResourceId()); resourceManagementService.deleteItems(Lists.newArrayList(removeDockerInstanceDto)); pluginInstanceRepository.deleteById(instanceId); }  List<String> getAvailableContainerHosts(); Integer getAvailablePortByHostIp(String hostIp); List<PluginInstance> getAllInstances(); List<PluginInstance> getAvailableInstancesByPackageId(String packageId); PluginInstance getRunningPluginInstance(String pluginName); List<PluginInstance> getRunningPluginInstances(String pluginName); boolean versionGreaterThan(String version, String baseVersion); boolean versionEquals(String version, String baseVersion); void launchPluginInstance(String packageId, String hostIp, Integer port); PluginMysqlInstance createPluginMysqlDatabase(PluginPackageRuntimeResourcesMysql mysqlInfo,
            String currentPluginVersion); void removePluginInstanceById(String instanceId); String getInstanceAddress(PluginInstance instance);  }