use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.AutoscaleStackV4Response in project cloudbreak by hortonworks.
the class StackService method getAllForAutoscale.
public Set<AutoscaleStackV4Response> getAllForAutoscale() {
try {
return transactionService.required(() -> {
Set<AutoscaleStack> aliveOnes = stackRepository.findAliveOnesWithClusterManager();
Set<AutoscaleStack> aliveNotUnderDeletion = Optional.ofNullable(aliveOnes).orElse(Set.of()).stream().filter(stack -> !DELETE_IN_PROGRESS.equals(stack.getStackStatus())).collect(Collectors.toSet());
return aliveNotUnderDeletion.stream().map(a -> autoscaleStackToAutoscaleStackResponseJsonConverter.convert(a)).collect(Collectors.toSet());
});
} catch (TransactionExecutionException e) {
throw new TransactionRuntimeExecutionException(e);
}
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.AutoscaleStackV4Response in project cloudbreak by hortonworks.
the class RejectedThreadServiceTest method testCreateWhenAutoscaleStackResponse.
@Test
public void testCreateWhenAutoscaleStackResponse() {
AutoscaleStackV4Response response = new AutoscaleStackV4Response();
response.setStackId(1L);
EvaluatorExecutor task = new TestEvaluatorExecutor(getContext(response));
underTest.create(task);
List<RejectedThread> allRejectedCluster = underTest.getAllRejectedCluster();
Assert.assertFalse(allRejectedCluster.isEmpty());
Assert.assertEquals(1L, allRejectedCluster.get(0).getId());
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.AutoscaleStackV4Response in project cloudbreak by hortonworks.
the class RejectedThreadService method create.
public void create(EvaluatorExecutor task) {
Object data = task.getContext().getData();
RejectedThread rejectedThread;
if (data instanceof AutoscaleStackV4Response) {
Long stackId = ((AutoscaleStackV4Response) data).getStackId();
rejectedThread = createOrUpdateRejectedThread(data, stackId);
} else if (data instanceof Long) {
rejectedThread = createOrUpdateRejectedThread(Collections.singletonMap("id", data), (Long) data);
} else {
throw new IllegalArgumentException("The given data is not match to AutoscaleStackResponse or Long, not possible to create");
}
LOGGER.debug("Rejected task: {}, count: {}", rejectedThread.getJson(), rejectedThread.getRejectedCount());
rejectedThread.setType(task.getClass().getName());
save(rejectedThread);
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.AutoscaleStackV4Response in project cloudbreak by hortonworks.
the class StackToAutoscaleStackV4ResponseConverter method convert.
public AutoscaleStackV4Response convert(Stack source) {
AutoscaleStackV4Response result = new AutoscaleStackV4Response();
result.setTenant(source.getWorkspace().getTenant().getName());
result.setWorkspaceId(source.getWorkspace().getId());
result.setUserId(source.getCreator().getUserId());
result.setStackId(source.getId());
result.setName(source.getName());
result.setGatewayPort(source.getGatewayPort());
result.setCreated(source.getCreated());
result.setStatus(source.getStatus());
result.setStackCrn(source.getResourceCrn());
result.setTunnel(source.getTunnel());
result.setCloudPlatform(source.getCloudPlatform());
result.setUserCrn(source.getCreator().getUserCrn());
result.setStackType(source.getType());
result.setEnvironmentCrn(source.getEnvironmentCrn());
if (source.getCluster() != null) {
Cluster cluster = source.getCluster();
result.setClusterManagerIp(cluster.getClusterManagerIp());
result.setUserNamePath(cluster.getCloudbreakAmbariUserSecret());
result.setPasswordPath(cluster.getCloudbreakAmbariPasswordSecret());
result.setClusterStatus(source.getStatus());
}
return result;
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.AutoscaleStackV4Response in project cloudbreak by hortonworks.
the class AutoscaleStackToAutoscaleStackResponseJsonConverter method convert.
public AutoscaleStackV4Response convert(AutoscaleStack source) {
AutoscaleStackV4Response result = new AutoscaleStackV4Response();
result.setTenant(source.getTenantName());
result.setWorkspaceId(source.getWorkspaceId());
result.setUserId(source.getUserId());
result.setUserCrn(source.getUserCrn());
result.setStackId(source.getId());
result.setName(source.getName());
result.setGatewayPort(source.getGatewayPort());
result.setCreated(source.getCreated());
result.setStatus(source.getStackStatus());
result.setStackCrn(source.getCrn());
result.setCloudPlatform(source.getCloudPlatform());
result.setStackType(source.getType());
result.setTunnel(source.getTunnel());
if (source.getClusterStatus() != null) {
String gatewayIp = gatewayConfigService.getPrimaryGatewayIp(source);
result.setClusterManagerIp(gatewayIp);
result.setUserNamePath(source.getCloudbreakAmbariUser().getSecret());
result.setPasswordPath(source.getCloudbreakAmbariPassword().getSecret());
result.setClusterStatus(source.getClusterStatus());
result.setClusterManagerVariant(source.getClusterManagerVariant());
}
return result;
}
Aggregations