use of com.sequenceiq.cloudbreak.domain.Blueprint in project cloudbreak by hortonworks.
the class AmbariDecommissionerTest method testVerifyNodeCountWithReplicationFactory.
@Test
public void testVerifyNodeCountWithReplicationFactory() throws CloudbreakSecuritySetupException {
String hostGroupName = "hostGroupName";
String hostname = "hostname";
String ipAddress = "192.18.256.1";
int gatewayPort = 1234;
String ambariName = "ambari-name";
Map<String, List<String>> blueprintMap = new HashMap<>();
blueprintMap.put(hostGroupName, Collections.singletonList("DATANODE"));
Blueprint blueprint = new Blueprint();
blueprint.setName(ambariName);
blueprint.setAmbariName(ambariName);
Cluster cluster = new Cluster();
cluster.setAmbariIp(ipAddress);
cluster.setBlueprint(blueprint);
Stack stack = new Stack();
stack.setGatewayPort(gatewayPort);
stack.setId(100L);
HostGroup hostGroup = new HostGroup();
hostGroup.setName(hostGroupName);
hostGroup.setHostMetadata(Sets.newHashSet(getHostMetadata(0L), getHostMetadata(1L), getHostMetadata(2L), getHostMetadata(3L)));
AmbariClient ambariClient = mock(AmbariClient.class);
HttpClientConfig config = new HttpClientConfig(ipAddress);
when(tlsSecurityService.buildTLSClientConfigForPrimaryGateway(stack.getId(), cluster.getAmbariIp())).thenReturn(config);
when(ambariClientProvider.getAmbariClient(config, stack.getGatewayPort(), cluster)).thenReturn(ambariClient);
when(hostGroupService.getByClusterAndHostName(cluster, hostname)).thenReturn(hostGroup);
when(ambariClient.getBlueprintMap(ambariName)).thenReturn(blueprintMap);
when(configurationService.getConfiguration(ambariClient, hostGroupName)).thenReturn(Collections.singletonMap(ConfigParam.DFS_REPLICATION.key(), "3"));
underTest.verifyNodeCount(stack, cluster, hostname);
verify(configurationService, times(1)).getConfiguration(ambariClient, hostGroupName);
}
use of com.sequenceiq.cloudbreak.domain.Blueprint in project cloudbreak by hortonworks.
the class AmbariClusterServiceTest method setup.
@Before
public void setup() throws CloudbreakException {
Cluster cluster = new Cluster();
cluster.setId(1L);
cluster.setBlueprint(new Blueprint());
cluster.getBlueprint().setId(1L);
Stack stack = new Stack();
stack.setOrchestrator(new Orchestrator());
stack.setCluster(cluster);
when(clusterRepository.findById(any(Long.class))).thenReturn(cluster);
when(stackService.getByIdWithLists(any(Long.class))).thenReturn(stack);
when(orchestratorTypeResolver.resolveType(any(Orchestrator.class))).thenReturn(OrchestratorType.HOST);
when(orchestratorTypeResolver.resolveType(anyString())).thenReturn(OrchestratorType.HOST);
when(clusterComponentConfigProvider.getHDPRepo(any(Long.class))).thenReturn(new StackRepoDetails());
when(clusterComponentConfigProvider.store(any(ClusterComponent.class))).thenAnswer(invocation -> invocation.getArgumentAt(0, ClusterComponent.class));
when(clusterComponentConfigProvider.getComponent(any(Long.class), any(ComponentType.class))).thenReturn(new ClusterComponent());
when(blueprintService.get(any(Long.class))).thenReturn(cluster.getBlueprint());
}
use of com.sequenceiq.cloudbreak.domain.Blueprint in project cloudbreak by hortonworks.
the class AmbariClusterStatusUpdaterTest method createStack.
private Stack createStack(Status stackStatus, Status clusterStatus) {
Stack stack = createStack(stackStatus);
Cluster cluster = new Cluster();
cluster.setAmbariIp("10.0.0.1");
cluster.setId(TEST_CLUSTER_ID);
cluster.setStatus(clusterStatus);
Blueprint blueprint = new Blueprint();
blueprint.setAmbariName(TEST_BLUEPRINT);
cluster.setBlueprint(blueprint);
stack.setCluster(cluster);
return stack;
}
use of com.sequenceiq.cloudbreak.domain.Blueprint in project cloudbreak by hortonworks.
the class BlueprintLoaderService method updateDefaultBlueprints.
private Set<Blueprint> updateDefaultBlueprints(IdentityUser user, Iterable<Blueprint> blueprints) {
Set<Blueprint> resultList = new HashSet<>();
LOGGER.info("Updating default blueprints which are contains text modifications.");
Map<String, Blueprint> defaultBlueprints = defaultBlueprintCache.defaultBlueprints();
for (Blueprint blueprintFromDatabase : blueprints) {
Blueprint newBlueprint = defaultBlueprints.get(blueprintFromDatabase.getName());
if (defaultBlueprintExistInTheCache(newBlueprint) && (defaultBlueprintContainsNewTexts(blueprintFromDatabase, newBlueprint) || defaultBlueprintContainsNewDescription(blueprintFromDatabase, newBlueprint))) {
LOGGER.info("Default Blueprint '{}' needs to modify for the '{}' user because the validation text changed.", blueprintFromDatabase.getName(), user.getUserId());
resultList.add(prepateBlueprint(user, blueprintFromDatabase, newBlueprint));
}
}
LOGGER.info("Finished to Update default blueprints which are contains text modifications.");
return resultList;
}
use of com.sequenceiq.cloudbreak.domain.Blueprint in project cloudbreak by hortonworks.
the class BlueprintLoaderService method getResultSetFromUpdateAndOriginalBlueprints.
private Iterable<Blueprint> getResultSetFromUpdateAndOriginalBlueprints(Iterable<Blueprint> blueprints, Iterable<Blueprint> blueprintsWhichAreMissing) {
LOGGER.info("Updating blueprints which should be modified.");
Iterable<Blueprint> savedBlueprints = blueprintRepository.save(blueprintsWhichAreMissing);
LOGGER.info("Finished to update blueprints which should be modified.");
Map<String, Blueprint> resultBlueprints = new HashMap<>();
for (Blueprint blueprint : blueprints) {
resultBlueprints.put(blueprint.getName(), blueprint);
}
for (Blueprint savedBlueprint : savedBlueprints) {
resultBlueprints.put(savedBlueprint.getName(), savedBlueprint);
}
return resultBlueprints.values();
}
Aggregations