Source:
<code>public Cluster importClusterServices(ServiceNodeDiscoverer serviceNodeDiscoverer, Cluster cluster) throws Exception { ObjectMapper objectMapper = new ObjectMapper(); Collection<Service> services = listServices(cluster.getId()); for (Service service : services) { Collection<Component> components = listComponents(service.getId()); for (Component component : components) { removeComponent(component.getId()); } removeService(service.getId()); } List<String> availableServices = serviceNodeDiscoverer.getServices(); for (ServiceConfigurations svcConfMap : ServiceConfigurations.values()) { String serviceName = svcConfMap.name(); if (availableServices.contains(serviceName)) { Map<String, Object> flattenConfigurations = new HashMap<>(); Map<String, Map<String, Object>> configurations = serviceNodeDiscoverer.getConfigurations(serviceName); Service service = initializeService(cluster, serviceName); <START> addService(service.getClusterId(), service); <END> for (Map.Entry<String, Map<String, Object>> confTypeToConfiguration : configurations .entrySet()) { String confType = confTypeToConfiguration.getKey(); Map<String, Object> configuration = confTypeToConfiguration.getValue(); String actualFileName = serviceNodeDiscoverer.getActualFileName(confType); ServiceConfiguration serviceConfiguration = initializeServiceConfiguration(objectMapper, service.getId(), confType, actualFileName, configuration); addServiceConfiguration(service.getId(), serviceConfiguration); flattenConfigurations.putAll(configuration); } List<String> components = serviceNodeDiscoverer.getComponents(serviceName); for (String componentName : components) { List<String> hosts = serviceNodeDiscoverer.getComponentNodes(serviceName, componentName); Component component = initializeComponent(service, componentName, hosts); setProtocolAndPortIfAvailable(flattenConfigurations, component); addComponent(service.getId(), component); } } } return cluster; }</code><technical_language>this code reading clusterId Service setting clusterId Service object</technical_language>

Target:
public Cluster importClusterServices(ServiceNodeDiscoverer serviceNodeDiscoverer, Cluster cluster) throws Exception { ObjectMapper objectMapper = new ObjectMapper(); Collection<Service> services = listServices(cluster.getId()); for (Service service : services) { Collection<Component> components = listComponents(service.getId()); for (Component component : components) { removeComponent(component.getId()); } removeService(service.getId()); } List<String> availableServices = serviceNodeDiscoverer.getServices(); for (ServiceConfigurations svcConfMap : ServiceConfigurations.values()) { String serviceName = svcConfMap.name(); if (availableServices.contains(serviceName)) { Map<String, Object> flattenConfigurations = new HashMap<>(); Map<String, Map<String, Object>> configurations = serviceNodeDiscoverer.getConfigurations(serviceName); Service service = initializeService(cluster, serviceName); addService(service); for (Map.Entry<String, Map<String, Object>> confTypeToConfiguration : configurations .entrySet()) { String confType = confTypeToConfiguration.getKey(); Map<String, Object> configuration = confTypeToConfiguration.getValue(); String actualFileName = serviceNodeDiscoverer.getActualFileName(confType); ServiceConfiguration serviceConfiguration = initializeServiceConfiguration(objectMapper, service.getId(), confType, actualFileName, configuration); addServiceConfiguration(serviceConfiguration); flattenConfigurations.putAll(configuration); } List<String> components = serviceNodeDiscoverer.getComponents(serviceName); for (String componentName : components) { List<String> hosts = serviceNodeDiscoverer.getComponentNodes(serviceName, componentName); Component component = initializeComponent(service, componentName, hosts); setProtocolAndPortIfAvailable(flattenConfigurations, component); addComponent(component); } } } return cluster; }