throw SoftwareManagementPluginException.CONFIGURE_SERVICE_FAILED(e);
}
}
private void addApiService(ApiServiceList serviceList, CmClusterDef cluster, CmServiceDef serviceDef, boolean servicesConfigured) {
ApiService apiService = new ApiService();
apiService.setType(serviceDef.getType().getName());
apiService.setName(serviceDef.getName());
apiService.setDisplayName(serviceDef.getDisplayName());
ApiServiceConfig apiServiceConfig = new ApiServiceConfig();
Set<String> serviceTypes = cluster.allServiceTypes();
if (serviceDef.getType().getDependencies() != null) {
for (AvailableServiceRole.Dependency dependency : serviceDef.getType().getDependencies()) {
for (String dependService : dependency.getServices()) {
if (serviceDef.getType().getDisplayName().equals("IMPALA") && dependService.equals("YARN")) {
// Impala needs Llama role to be able to use YARN for resource management, but this
// is a new added role and not yet supported well
continue;
}
if (serviceTypes.contains(dependService)) {
apiServiceConfig.add(new ApiConfig(dependency.getConfigKey(), cluster.serviceNameOfType(dependService)));
}
}
}
}
if (serviceDef.getConfiguration() != null) {
for (String key : serviceDef.getConfiguration().keySet()) {
apiServiceConfig.add(new ApiConfig(key, serviceDef.getConfiguration().get(key)));
}
}
// update configs if service already exist
if (servicesConfigured
&& apiResourceRootV6.getClustersResource().getServicesResource(cluster.getName()).readService(serviceDef.getName()) != null) {
apiResourceRootV6.getClustersResource().getServicesResource(cluster.getName())
.updateServiceConfig(serviceDef.getName(), "update configs for role " + serviceDef.getName(), apiServiceConfig);
logger.info("Finished reconfigure service " + serviceDef.getName());
}
apiService.setConfig(apiServiceConfig);
List<ApiRole> apiRoles = new ArrayList<ApiRole>();
for (CmRoleDef roleDef : serviceDef.getRoles()) {
ApiRole apiRole = createApiRole(roleDef);
/*
update configs of this role if services already exist,
the roleDef's roleName is already synced up at the beginning of this function
*/
if (servicesConfigured
&& apiResourceRootV6.getClustersResource().getServicesResource(cluster.getName()).readService(serviceDef.getName()) != null
&& apiResourceRootV6.getClustersResource().getServicesResource(cluster.getName()).getRolesResource(serviceDef.getName()).readRole(roleDef.getName()) != null) {
apiResourceRootV6.getClustersResource().getServicesResource(cluster.getName()).getRolesResource(serviceDef.getName())
.updateRoleConfig(roleDef.getName(), "update config for role " + roleDef.getDisplayName(), apiRole.getConfig());
logger.info("Finished reconfigure role " + roleDef.getDisplayName());
}
apiRoles.add(apiRole);
}
apiService.setRoles(apiRoles);
serviceList.add(apiService);
}