use of com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData in project cloudbreak by hortonworks.
the class FinalizeClusterInstallHandlerService method finalizeClusterInstall.
public void finalizeClusterInstall(Set<InstanceMetaData> instances, Cluster cluster) {
LOGGER.info("Cluster created successfully. Cluster name: {}", cluster.getName());
for (InstanceMetaData instance : instances) {
instance.setInstanceStatus(InstanceStatus.SERVICES_HEALTHY);
}
instanceMetaDataService.saveAll(instances);
Long now = new Date().getTime();
cluster.setCreationFinished(now);
cluster.setUpSince(now);
clusterService.updateCluster(cluster);
}
use of com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData in project cloudbreak by hortonworks.
the class InstanceMetadataUpdater method collectPackagesWithMultipleVersions.
public List<String> collectPackagesWithMultipleVersions(Collection<InstanceMetaData> instanceMetadataList) {
try {
Multimap<String, String> pkgVersionsMMap = HashMultimap.create();
for (InstanceMetaData im : instanceMetadataList) {
Image image = im.getImage().get(Image.class);
for (Entry<String, String> packageEntry : image.getPackageVersions().entrySet()) {
pkgVersionsMMap.put(packageEntry.getKey(), packageEntry.getValue());
}
}
List<String> packagesWithMultipleVersions = new ArrayList<>();
for (String pkg : pkgVersionsMMap.keySet()) {
if (pkgVersionsMMap.get(pkg).size() > 1) {
packagesWithMultipleVersions.add(pkg);
}
}
if (!packagesWithMultipleVersions.isEmpty()) {
LOGGER.debug("Packages unfortunately do have multiple versions: {}", pkgVersionsMMap);
}
return packagesWithMultipleVersions;
} catch (IOException ex) {
LOGGER.warn("Cannot collect package versions from hosts", ex);
return Collections.emptyList();
}
}
use of com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData in project cloudbreak by hortonworks.
the class InstanceMetadataUpdater method updateInstanceMetaDataIfVersionQueryFailed.
private List<String> updateInstanceMetaDataIfVersionQueryFailed(Map<String, Map<String, String>> packageVersionsByNameByHost, Stack stack) throws IOException {
Set<InstanceMetaData> instanceMetaDataSet = stack.getNotDeletedAndNotZombieInstanceMetaDataSet();
List<String> failedVersionQueriesByHost = Lists.newArrayList();
for (InstanceMetaData im : instanceMetaDataSet) {
Map<String, String> packageVersionsOnHost = packageVersionsByNameByHost.get(im.getDiscoveryFQDN());
if (CollectionUtils.isEmpty(packageVersionsOnHost)) {
failedVersionQueriesByHost.add(im.getDiscoveryFQDN());
Image image = im.getImage().get(Image.class);
image.getPackageVersions().clear();
im.setImage(new Json(image));
im.setInstanceStatus(InstanceStatus.SERVICES_UNHEALTHY);
im.setStatusReason("Version query is failed on host");
instanceMetaDataService.save(im);
}
}
return failedVersionQueriesByHost;
}
use of com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData in project cloudbreak by hortonworks.
the class ClusterRepairService method validateRepair.
public Result<Map<HostGroupName, Set<InstanceMetaData>>, RepairValidation> validateRepair(ManualClusterRepairMode repairMode, Long stackId, Set<String> selectedParts, boolean deleteVolumes) {
Stack stack = stackService.getByIdWithListsInTransaction(stackId);
boolean reattach = !deleteVolumes;
Result<Map<HostGroupName, Set<InstanceMetaData>>, RepairValidation> repairStartResult;
List<String> stoppedInstanceIds = getStoppedNotSelectedInstanceIds(stack, repairMode, selectedParts);
if (!freeipaService.checkFreeipaRunning(stack.getEnvironmentCrn())) {
repairStartResult = Result.error(RepairValidation.of("Action cannot be performed because the FreeIPA isn't available. Please check the FreeIPA state."));
} else if (!environmentService.environmentStatusInDesiredState(stack, Set.of(EnvironmentStatus.AVAILABLE))) {
repairStartResult = Result.error(RepairValidation.of("Action cannot be performed because the Environment isn't available. Please check the Environment state."));
} else if (!stoppedInstanceIds.isEmpty()) {
repairStartResult = Result.error(RepairValidation.of("Action cannot be performed because there are stopped nodes in the cluster. " + "Stopped nodes: [" + String.join(", ", stoppedInstanceIds) + "]. " + "Please select them for repair or start the stopped nodes."));
} else if (!isReattachSupportedOnProvider(stack, reattach)) {
repairStartResult = Result.error(RepairValidation.of(String.format("Volume reattach currently not supported on %s platform!", stack.getPlatformVariant())));
} else if (hasNotAvailableDatabase(stack)) {
repairStartResult = Result.error(RepairValidation.of(String.format("Database %s is not in AVAILABLE status, could not start repair.", stack.getCluster().getDatabaseServerCrn())));
} else if (isHAClusterAndRepairNotAllowed(stack)) {
repairStartResult = Result.error(RepairValidation.of("Repair is not supported when the cluster uses cluster proxy and has multiple gateway nodes. This will be fixed in future releases."));
} else if (isAnyGWUnhealthyAndItIsNotSelected(repairMode, selectedParts, stack)) {
repairStartResult = Result.error(RepairValidation.of("Gateway node is unhealthy, it must be repaired first."));
} else {
Map<HostGroupName, Set<InstanceMetaData>> repairableNodes = selectRepairableNodes(getInstanceSelectors(repairMode, selectedParts), stack);
if (repairableNodes.isEmpty()) {
repairStartResult = Result.error(RepairValidation.of("Repairable node list is empty. Please check node statuses and try again."));
} else {
RepairValidation validationBySelectedNodes = validateSelectedNodes(stack, repairableNodes, reattach);
if (!validationBySelectedNodes.getValidationErrors().isEmpty()) {
repairStartResult = Result.error(validationBySelectedNodes);
} else {
setStackStatusAndMarkDeletableVolumes(repairMode, deleteVolumes, stack, repairableNodes);
repairStartResult = Result.success(repairableNodes);
}
}
}
return repairStartResult;
}
use of com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData in project cloudbreak by hortonworks.
the class RdsRecoverySetupService method createOrchestratorGrainRunnerParams.
private OrchestratorGrainRunnerParams createOrchestratorGrainRunnerParams(Stack stack, Cluster cluster, Set<Node> nodes, GrainOperation grainOperation) {
OrchestratorGrainRunnerParams grainRunnerParams = new OrchestratorGrainRunnerParams();
InstanceMetaData gatewayInstance = stack.getPrimaryGatewayInstance();
grainRunnerParams.setPrimaryGatewayConfig(gatewayConfigService.getGatewayConfig(stack, gatewayInstance, stack.getCluster().hasGateway()));
Set<String> targetHostNames = gatewayInstance.getDiscoveryFQDN() != null ? Set.of(gatewayInstance.getDiscoveryFQDN()) : Set.of();
grainRunnerParams.setTargetHostNames(targetHostNames);
grainRunnerParams.setAllNodes(nodes);
grainRunnerParams.setExitCriteriaModel(ClusterDeletionBasedExitCriteriaModel.clusterDeletionBasedModel(stack.getId(), cluster.getId()));
grainRunnerParams.setKey(ROLES);
grainRunnerParams.setValue(RECOVER);
grainRunnerParams.setGrainOperation(grainOperation);
return grainRunnerParams;
}
Aggregations