use of com.sequenceiq.cloudbreak.domain.HostGroup in project cloudbreak by hortonworks.
the class UpscaleFlowEventChainFactory method createFlowTriggerEventQueue.
@Override
public Queue<Selectable> createFlowTriggerEventQueue(StackAndClusterUpscaleTriggerEvent event) {
StackView stackView = stackService.getByIdView(event.getStackId());
ClusterView clusterView = stackView.getClusterView();
Queue<Selectable> flowEventChain = new ConcurrentLinkedQueue<>();
flowEventChain.add(new StackSyncTriggerEvent(STACK_SYNC_EVENT.event(), event.getStackId(), false, event.accepted()));
flowEventChain.add(new StackScaleTriggerEvent(ADD_INSTANCES_EVENT.event(), event.getStackId(), event.getInstanceGroup(), event.getAdjustment(), event.getHostNames()));
if (ScalingType.isClusterUpScale(event.getScalingType()) && clusterView != null) {
HostGroup hostGroup = hostGroupService.getByClusterIdAndInstanceGroupName(clusterView.getId(), event.getInstanceGroup());
flowEventChain.add(new ClusterScaleTriggerEvent(CLUSTER_UPSCALE_TRIGGER_EVENT.event(), stackView.getId(), hostGroup.getName(), event.getAdjustment()));
}
return flowEventChain;
}
use of com.sequenceiq.cloudbreak.domain.HostGroup in project cloudbreak by hortonworks.
the class ComponentLocatorServiceTest method setUp.
@Before
public void setUp() {
cluster = new Cluster();
cluster.setBlueprint(new Blueprint());
HostGroup hg1 = createHostGroup("hg1", "myhost1");
HostGroup hg2 = createHostGroup("hg2", "myhost2");
Set<String> hg1Components = set("RESOURCEMANAGER", "Service1", "HIVE_SERVER");
Set<String> hg2Components = set("NAMENODE", "Service2", "Service3");
when(hostGroupService.getByCluster(anyLong())).thenReturn(ImmutableSet.of(hg1, hg2));
when(blueprintProcessor.getComponentsInHostGroup(eq("hg1"))).thenReturn(hg1Components);
when(blueprintProcessor.getComponentsInHostGroup(eq("hg2"))).thenReturn(hg2Components);
when(blueprintProcessorFactory.get(anyString())).thenReturn(blueprintProcessor);
}
use of com.sequenceiq.cloudbreak.domain.HostGroup in project cloudbreak by hortonworks.
the class AmbariDecommissionerTest method testVerifyNodeCountWithoutReplicationFactory.
@Test
public void testVerifyNodeCountWithoutReplicationFactory() 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("NODEMANAGER"));
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(Collections.singleton(getHostMetadata(0L)));
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);
underTest.verifyNodeCount(stack, cluster, hostname);
verify(configurationService, times(0)).getConfiguration(ambariClient, hostGroupName);
}
use of com.sequenceiq.cloudbreak.domain.HostGroup 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.HostGroup in project cloudbreak by hortonworks.
the class AmbariClusterHostServiceTypeTest method testUpdateHostsForDownscaleCannotGoBelowReplication.
@Test
public void testUpdateHostsForDownscaleCannotGoBelowReplication() throws CloudbreakSecuritySetupException {
HostGroupAdjustmentJson json = new HostGroupAdjustmentJson();
json.setHostGroup("slave_1");
json.setScalingAdjustment(-1);
AmbariClient ambariClient = mock(AmbariClient.class);
HostMetadata metadata1 = mock(HostMetadata.class);
HostMetadata metadata2 = mock(HostMetadata.class);
HostMetadata metadata3 = mock(HostMetadata.class);
Set<HostMetadata> hostsMetaData = new HashSet<>();
List<HostMetadata> hostsMetadataList = asList(metadata1, metadata2, metadata3);
hostsMetaData.addAll(hostsMetadataList);
HostGroup hostGroup = new HostGroup();
hostGroup.setHostMetadata(hostsMetaData);
hostGroup.setName("slave_1");
when(ambariClientProvider.getAmbariClient(any(HttpClientConfig.class), anyInt(), any(Cluster.class))).thenReturn(ambariClient);
when(ambariClient.getComponentsCategory("multi-node-yarn", "slave_1")).thenReturn(singletonMap("DATANODE", "SLAVE"));
when(hostGroupService.getByClusterIdAndName(anyLong(), anyString())).thenReturn(hostGroup);
when(statusToPollGroupConverter.convert(any(Status.class))).thenReturn(PollGroup.POLLABLE);
underTest.updateHosts(stack.getId(), json);
verify(flowManager, times(1)).triggerClusterDownscale(stack.getId(), json);
verify(blueprintValidator, times(1)).validateHostGroupScalingRequest(stack.getCluster().getBlueprint(), hostGroup, json.getScalingAdjustment());
}
Aggregations