use of com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData in project cloudbreak by hortonworks.
the class HostMetadataSetup method setupNewHostMetadata.
public void setupNewHostMetadata(Long stackId, Collection<String> newAddresses) {
try {
transactionService.required(() -> {
LOGGER.info("Extending host metadata: {}", newAddresses);
Stack stack = stackService.getByIdWithListsInTransaction(stackId);
Set<InstanceMetaData> newInstanceMetadata = instanceMetaDataService.getNotDeletedAndNotZombieInstanceMetadataByStackId(stackId).stream().filter(instanceMetaData -> newAddresses.contains(instanceMetaData.getPrivateIp())).collect(Collectors.toSet());
updateWithHostData(stack, newInstanceMetadata);
instanceMetaDataService.saveAll(newInstanceMetadata);
});
} catch (TransactionExecutionException e) {
throw new CloudbreakRuntimeException(e.getCause());
}
}
use of com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData in project cloudbreak by hortonworks.
the class MetadataSetupService method cleanupRequestedInstancesIfNotInList.
public void cleanupRequestedInstancesIfNotInList(Long stackId, Set<String> instanceGroups, Set<Long> privateIds) {
LOGGER.info("Cleanup the requested instances if private id not in {}", privateIds);
for (String instanceGroupName : instanceGroups) {
Optional<InstanceGroup> instanceGroup = instanceGroupService.findOneByStackIdAndGroupName(stackId, instanceGroupName);
instanceGroup.ifPresent(ig -> {
List<InstanceMetaData> requestedInstanceMetaDatas = instanceMetaDataService.findAllByInstanceGroupAndInstanceStatus(ig, InstanceStatus.REQUESTED);
LOGGER.info("Instances in requested state: {}", requestedInstanceMetaDatas);
List<InstanceMetaData> removableInstanceMetaDatas = requestedInstanceMetaDatas.stream().filter(instanceMetaData -> !privateIds.contains(instanceMetaData.getPrivateId())).collect(Collectors.toList());
LOGGER.info("Cleanup the following instances: {}", requestedInstanceMetaDatas);
for (InstanceMetaData removableInstanceMetaData : removableInstanceMetaDatas) {
removableInstanceMetaData.setTerminationDate(clock.getCurrentTimeMillis());
removableInstanceMetaData.setInstanceStatus(InstanceStatus.TERMINATED);
}
instanceMetaDataService.saveAll(removableInstanceMetaDatas);
});
}
}
use of com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData in project cloudbreak by hortonworks.
the class MountDisks method mountDisks.
private void mountDisks(Stack stack, Set<Node> nodesWithDiskData, Set<Node> allNodes) throws CloudbreakException {
Cluster cluster = stack.getCluster();
try {
List<GatewayConfig> gatewayConfigs = gatewayConfigService.getAllGatewayConfigs(stack);
ExitCriteriaModel exitCriteriaModel = clusterDeletionBasedModel(stack.getId(), cluster.getId());
Map<String, Map<String, String>> mountInfo;
if (isCbVersionPostOptimisation(stack)) {
mountInfo = hostOrchestrator.formatAndMountDisksOnNodes(stack, gatewayConfigs, nodesWithDiskData, allNodes, exitCriteriaModel, stack.getPlatformVariant());
} else {
mountInfo = hostOrchestrator.formatAndMountDisksOnNodesLegacy(gatewayConfigs, nodesWithDiskData, allNodes, exitCriteriaModel, stack.getPlatformVariant());
}
mountInfo.forEach((hostname, value) -> {
Optional<String> instanceIdOptional = stack.getInstanceMetaDataAsList().stream().filter(instanceMetaData -> hostname.equals(instanceMetaData.getDiscoveryFQDN())).filter(instanceMetaData -> InstanceStatus.CREATED.equals(instanceMetaData.getInstanceStatus())).map(InstanceMetaData::getInstanceId).findFirst();
if (instanceIdOptional.isPresent()) {
String uuids = value.getOrDefault("uuids", "");
String fstab = value.getOrDefault("fstab", "");
if (!StringUtils.isEmpty(uuids) && !StringUtils.isEmpty(fstab)) {
persistUuidAndFstab(stack, instanceIdOptional.get(), hostname, uuids, fstab);
}
}
});
} catch (CloudbreakOrchestratorFailedException e) {
LOGGER.error("Failed to mount disks", e);
throw new CloudbreakSecuritySetupException(e);
}
}
use of com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData in project cloudbreak by hortonworks.
the class StackOperationService method removeInstance.
public FlowIdentifier removeInstance(Stack stack, String instanceId, boolean forced) {
InstanceMetaData metaData = updateNodeCountValidator.validateInstanceForDownscale(instanceId, stack);
String instanceGroupName = metaData.getInstanceGroupName();
int scalingAdjustment = -1;
updateNodeCountValidator.validateServiceRoles(stack, instanceGroupName, scalingAdjustment);
if (!forced) {
updateNodeCountValidator.validateScalabilityOfInstanceGroup(stack, instanceGroupName, scalingAdjustment);
updateNodeCountValidator.validateScalingAdjustment(instanceGroupName, scalingAdjustment, stack);
}
return flowManager.triggerStackRemoveInstance(stack.getId(), instanceGroupName, metaData.getPrivateId(), forced);
}
use of com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData in project cloudbreak by hortonworks.
the class TerminationService method terminateMetaDataInstances.
private void terminateMetaDataInstances(Stack stack) {
List<InstanceMetaData> instanceMetaDatas = new ArrayList<>();
Set<InstanceMetaData> notDeletedInstanceMetadataSet = instanceMetaDataService.getNotDeletedInstanceMetadataByStackId(stack.getId());
for (InstanceMetaData metaData : notDeletedInstanceMetadataSet) {
metaData.setTerminationDate(clock.getCurrentTimeMillis());
metaData.setInstanceStatus(InstanceStatus.TERMINATED);
instanceMetaDatas.add(metaData);
}
instanceMetaDataService.saveAll(instanceMetaDatas);
}
Aggregations