use of com.sequenceiq.datalake.flow.cert.rotation.event.SdxStartCertRotationEvent in project cloudbreak by hortonworks.
the class CertRotationActions method starCertRotationAction.
@Bean(name = "START_CERT_ROTATION_STATE")
public Action<?, ?> starCertRotationAction() {
return new AbstractSdxAction<>(SdxStartCertRotationEvent.class) {
@Override
protected SdxContext createFlowContext(FlowParameters flowParameters, StateContext<FlowState, FlowEvent> stateContext, SdxStartCertRotationEvent payload) {
return SdxContext.from(flowParameters, payload);
}
@Override
protected void doExecute(SdxContext context, SdxStartCertRotationEvent payload, Map<Object, Object> variables) {
LOGGER.info("Start cert rotation with request: {}", payload.getRequest());
certRotationService.startCertRotation(context.getSdxId(), payload.getRequest());
SdxEvent sdxEvent = new SdxEvent(SdxCertRotationEvent.CERT_ROTATION_STARTED_EVENT.event(), payload.getResourceId(), payload.getUserId());
sendEvent(context, sdxEvent);
}
@Override
protected Object getFailurePayload(SdxStartCertRotationEvent payload, Optional<SdxContext> flowContext, Exception ex) {
return new SdxCertRotationFailedEvent(payload, ex);
}
};
}
use of com.sequenceiq.datalake.flow.cert.rotation.event.SdxStartCertRotationEvent in project cloudbreak by hortonworks.
the class CertRotationServiceTest method testFlowTrigger.
@Test
public void testFlowTrigger() {
SdxCluster cluster = new SdxCluster();
cluster.setId(1L);
cluster.setClusterName("testclustername");
CertificatesRotationV4Request request = new CertificatesRotationV4Request();
ArgumentCaptor<SdxStartCertRotationEvent> eventArgumentCaptor = ArgumentCaptor.forClass(SdxStartCertRotationEvent.class);
FlowIdentifier flowIdentifier = new FlowIdentifier(FlowType.FLOW, "pollid");
when(flowManager.triggerCertRotation(eventArgumentCaptor.capture(), anyString())).thenReturn(flowIdentifier);
FlowIdentifier result = ThreadBasedUserCrnProvider.doAs(TEST_USER_CRN, () -> underTest.rotateAutoTlsCertificates(cluster, request));
assertEquals(flowIdentifier, result);
SdxStartCertRotationEvent event = eventArgumentCaptor.getValue();
assertEquals(request, event.getRequest());
assertEquals(1L, event.getResourceId());
assertEquals(TEST_USER_CRN, event.getUserId());
}
use of com.sequenceiq.datalake.flow.cert.rotation.event.SdxStartCertRotationEvent in project cloudbreak by hortonworks.
the class CertRotationService method rotateAutoTlsCertificates.
public FlowIdentifier rotateAutoTlsCertificates(SdxCluster sdxCluster, CertificatesRotationV4Request rotateCertificateRequest) {
MDCBuilder.buildMdcContext(sdxCluster);
String initiatorUserCrn = ThreadBasedUserCrnProvider.getUserCrn();
SdxStartCertRotationEvent event = new SdxStartCertRotationEvent(sdxCluster.getId(), initiatorUserCrn, rotateCertificateRequest);
return flowManager.triggerCertRotation(event, sdxCluster.getClusterName());
}
Aggregations