use of com.sequenceiq.periscope.domain.ClusterManager in project cloudbreak by hortonworks.
the class ClouderaManagerCommunicator method getRoleConfigPropertiesFromCM.
public Map<String, ApiConfig> getRoleConfigPropertiesFromCM(Cluster cluster, String serviceName, String roleGroupRef, Set roleConfigPropertyNames) {
LOGGER.debug("Retrieving roleConfigProperties for cluster '{}', service '{}', roleGroupRef '{}'", cluster.getStackCrn(), serviceName, roleGroupRef);
HttpClientConfig httpClientConfig = tlsHttpClientConfigurationService.buildTLSClientConfig(cluster.getStackCrn(), cluster.getClusterManager().getHost(), cluster.getTunnel());
ClusterManager cm = cluster.getClusterManager();
String user = secretService.get(cm.getUser());
String pass = secretService.get(cm.getPass());
Map<String, ApiConfig> roleConfigProperties = requestLogging.logResponseTime(() -> {
try {
ApiClient client = clouderaManagerApiClientProvider.getV31Client(Integer.valueOf(cm.getPort()), user, pass, httpClientConfig);
client.getHttpClient().interceptors().add(cmOkHttpTracingInterceptor);
client.getHttpClient().interceptors().add(cmRequestIdProviderInterceptor);
RoleConfigGroupsResourceApi roleConfigGroupsResourceApi = clouderaManagerApiFactory.getRoleConfigGroupsResourceApi(client);
return roleConfigGroupsResourceApi.readConfig(cluster.getStackName(), roleGroupRef, serviceName, DataView.FULL.name()).getItems().stream().filter(apiConfig -> roleConfigPropertyNames.contains(apiConfig.getName())).collect(Collectors.toMap(ApiConfig::getName, apiConfig -> apiConfig));
} catch (Exception ex) {
throw new RuntimeException(String.format("Error retrieving roleConfigProperties for cluster '%s', service '%s', roleGroupRef '%s'", cluster.getStackCrn(), serviceName, roleGroupRef), ex);
}
}, String.format("getRoleConfigPropertiesFromCM for cluster crn '%s'", cluster.getStackCrn()));
LOGGER.debug("Retrieved roleConfigPropertyValues for cluster '{}', service '{}', roleGroupRef '{}', roleConfigProperties '{}", cluster.getStackCrn(), serviceName, roleGroupRef, roleConfigProperties.values().stream().map(apiConfig -> String.format("ApiConfig Name '%s, Value '%s', Default '%s", apiConfig.getName(), apiConfig.getValue(), apiConfig.getDefault())).collect(Collectors.toSet()));
return roleConfigProperties;
}
use of com.sequenceiq.periscope.domain.ClusterManager in project cloudbreak by hortonworks.
the class ClusterService method validateClusterUniqueness.
public void validateClusterUniqueness(MonitoredStack stack) {
Iterable<Cluster> clusters = clusterRepository.findAll();
boolean clusterForTheSameStackAndClusterManager = StreamSupport.stream(clusters.spliterator(), false).anyMatch(cluster -> {
boolean equalityOfStackCrn = cluster.getStackCrn() != null && Objects.equals(cluster.getStackCrn(), stack.getStackCrn());
ClusterManager clusterManager = cluster.getClusterManager();
ClusterManager newClusterManager = stack.getClusterManager();
boolean clrMgrObjectsNotNull = clusterManager != null && newClusterManager != null;
boolean clrMgrHostsNotEmpty = clrMgrObjectsNotNull && !isEmpty(clusterManager.getHost()) && !isEmpty(newClusterManager.getHost());
boolean equalityOfCMHost = clrMgrObjectsNotNull && clrMgrHostsNotEmpty && clusterManager.getHost().equals(newClusterManager.getHost());
return equalityOfStackCrn && equalityOfCMHost;
});
if (clusterForTheSameStackAndClusterManager) {
throw new BadRequestException(messagesService.getMessage(CLUSTER_EXISTS_FOR_CRN, Set.of(stack.getStackCrn(), stack.getClusterManager().getVariant().name())));
}
}
use of com.sequenceiq.periscope.domain.ClusterManager in project cloudbreak by hortonworks.
the class ClusterService method create.
public Cluster create(AutoscaleStackV4Response stack) {
Cluster cluster = new Cluster();
cluster.setStackName(stack.getName());
cluster.setStackCrn(stack.getStackCrn());
cluster.setStackId(stack.getStackId());
cluster.setStackType(stack.getStackType());
cluster.setTunnel(stack.getTunnel());
cluster.setState(ClusterState.PENDING);
cluster.setEnvironmentCrn(stack.getEnvironmentCrn());
if (stack.getCloudPlatform() != null) {
cluster.setCloudPlatform(stack.getCloudPlatform().toUpperCase());
}
String gatewayPort = String.valueOf(stack.getGatewayPort());
ClusterManager clusterManager = new ClusterManager(stack.getClusterManagerIp(), gatewayPort, stack.getUserNamePath(), stack.getPasswordPath(), ClusterManagerVariant.CLOUDERA_MANAGER);
cluster.setClusterManager(clusterManager);
ClusterPertain clusterPertain = new ClusterPertain(stack.getTenant(), stack.getWorkspaceId(), stack.getUserId(), stack.getUserCrn());
cluster.setClusterPertain(clusterPertainRepository.findByUserCrn(clusterPertain.getUserCrn()).orElseGet(() -> clusterPertainRepository.save(clusterPertain)));
cluster = save(cluster);
securityConfigService.syncSecurityConfigForCluster(cluster.getId());
altusMachineUserService.initializeMachineUserForEnvironment(cluster);
calculateClusterStateMetrics();
return cluster;
}
use of com.sequenceiq.periscope.domain.ClusterManager in project cloudbreak by hortonworks.
the class MetricTest method getACluster.
private Cluster getACluster(ClusterState clusterState) {
Cluster cluster = new Cluster();
cluster.setId(CLUSTER_ID);
cluster.setStackCrn(STACK_CRN);
cluster.setClusterPertain(getClusterPertain());
cluster.setClusterManager(new ClusterManager("host", "port", USER_A_ID, "", ClusterManagerVariant.AMBARI));
cluster.setState(clusterState);
return cluster;
}
Aggregations