use of com.sequenceiq.datalake.entity.SdxStatusEntity in project cloudbreak by hortonworks.
the class SdxStatusService method updateInMemoryStateStore.
public void updateInMemoryStateStore(SdxCluster sdxCluster) {
SdxStatusEntity actualStatusForSdx = getActualStatusForSdx(sdxCluster);
if (actualStatusForSdx != null && (actualStatusForSdx.getStatus().isDeleteInProgressOrCompleted() || DELETED_ON_PROVIDER_SIDE.equals(actualStatusForSdx.getStatus()))) {
DatalakeInMemoryStateStore.put(sdxCluster.getId(), PollGroup.CANCELLED);
LOGGER.info("Update {} datalake status in inmemory store to {}", sdxCluster.getClusterName(), PollGroup.CANCELLED.name());
} else {
DatalakeInMemoryStateStore.put(sdxCluster.getId(), PollGroup.POLLABLE);
LOGGER.info("Update {} datalake status in inmemory store to {}", sdxCluster.getClusterName(), PollGroup.POLLABLE.name());
}
}
use of com.sequenceiq.datalake.entity.SdxStatusEntity in project cloudbreak by hortonworks.
the class SdxStatusService method createStatusEntity.
private SdxStatusEntity createStatusEntity(DatalakeStatusEnum status, String statusReason, SdxCluster sdxCluster) {
SdxStatusEntity sdxStatusEntity = new SdxStatusEntity();
sdxStatusEntity.setCreated(new Date().getTime());
sdxStatusEntity.setStatus(status);
sdxStatusEntity.setStatusReason(statusReason);
sdxStatusEntity.setDatalake(sdxCluster);
return sdxStatusEntity;
}
use of com.sequenceiq.datalake.entity.SdxStatusEntity in project cloudbreak by hortonworks.
the class SdxStatusService method setStatusForDatalake.
public void setStatusForDatalake(DatalakeStatusEnum status, String statusReason, SdxCluster sdxCluster) {
try {
transactionService.required(() -> {
SdxStatusEntity previous = getActualStatusForSdx(sdxCluster);
if (statusChangeIsValid(previous, status)) {
SdxStatusEntity sdxStatusEntity = createStatusEntity(status, statusReason, sdxCluster);
if (DELETED.equals(status)) {
setDeletedTime(sdxCluster);
}
sdxStatusRepository.save(sdxStatusEntity);
updateInMemoryStateStore(sdxCluster);
LOGGER.info("Updated status of Datalake with name: {} from {} to {} with statusReason {}", sdxCluster.getClusterName(), getPreviousStatusText(previous), status, statusReason);
} else if (DELETED.equals(previous.getStatus())) {
if (sdxCluster.getDeleted() == null) {
setDeletedTime(sdxCluster);
} else {
throw notFoundException("SDX cluster", sdxCluster.getClusterName());
}
} else {
throw new DatalakeStatusUpdateException(getActualStatusForSdx(sdxCluster).getStatus(), status);
}
});
} catch (TransactionService.TransactionExecutionException e) {
LOGGER.error("Exception happened while transaction was executed", e);
throw e.getCause();
}
}
use of com.sequenceiq.datalake.entity.SdxStatusEntity in project cloudbreak by hortonworks.
the class SdxControllerTest method createTest.
@Test
void createTest() {
SdxCluster sdxCluster = getValidSdxCluster();
when(sdxService.createSdx(anyString(), anyString(), any(SdxClusterRequest.class), nullable(StackV4Request.class))).thenReturn(Pair.of(sdxCluster, new FlowIdentifier(FlowType.FLOW, "FLOW_ID")));
SdxClusterRequest createSdxClusterRequest = new SdxClusterRequest();
createSdxClusterRequest.setClusterShape(SdxClusterShape.MEDIUM_DUTY_HA);
createSdxClusterRequest.setEnvironment("test-env");
Map<String, String> tags = new HashMap<>();
tags.put("tag1", "value1");
createSdxClusterRequest.addTags(tags);
SdxStatusEntity sdxStatusEntity = new SdxStatusEntity();
sdxStatusEntity.setStatus(DatalakeStatusEnum.REQUESTED);
sdxStatusEntity.setStatusReason("statusreason");
sdxStatusEntity.setCreated(1L);
when(sdxStatusService.getActualStatusForSdx(sdxCluster)).thenReturn(sdxStatusEntity);
ReflectionTestUtils.setField(sdxClusterConverter, "sdxStatusService", sdxStatusService);
SdxClusterResponse sdxClusterResponse = ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> sdxController.create(SDX_CLUSTER_NAME, createSdxClusterRequest));
verify(sdxService).createSdx(eq(USER_CRN), eq(SDX_CLUSTER_NAME), eq(createSdxClusterRequest), nullable(StackV4Request.class));
verify(sdxStatusService, times(1)).getActualStatusForSdx(sdxCluster);
assertEquals(SDX_CLUSTER_NAME, sdxClusterResponse.getName());
assertEquals("test-env", sdxClusterResponse.getEnvironmentName());
assertEquals("crn:sdxcluster", sdxClusterResponse.getCrn());
assertEquals(SdxClusterStatusResponse.REQUESTED, sdxClusterResponse.getStatus());
assertEquals("statusreason", sdxClusterResponse.getStatusReason());
}
use of com.sequenceiq.datalake.entity.SdxStatusEntity in project cloudbreak by hortonworks.
the class RangerCloudIdentityService method isDatalakeRunning.
private boolean isDatalakeRunning(SdxCluster sdxCluster) {
SdxStatusEntity sdxStatusEntity = sdxStatusService.getActualStatusForSdx(sdxCluster);
LOGGER.debug("SDX status = {}", sdxStatusEntity.getStatus());
return sdxStatusEntity.getStatus().equals(DatalakeStatusEnum.RUNNING);
}
Aggregations