use of com.hortonworks.registries.schemaregistry.state.SchemaVersionLifecycleStateTransition in project registry by hortonworks.
the class CustomReviewCycleExecutor method registerReviewedState.
public void registerReviewedState(SchemaVersionLifecycleStateMachine.Builder builder) {
builder.transition(new SchemaVersionLifecycleStateTransition(CustomReviewCycleStates.TECHNICAL_LEAD_REVIEW_STATE.getId(), SchemaVersionLifecycleStates.REVIEWED.getId(), SchemaVersionLifecycleStates.REVIEWED.getName(), SchemaVersionLifecycleStates.REVIEWED.getDescription()), (SchemaVersionLifecycleContext context) -> {
// Plugin a custom code to trigger as a part of the state transition, here we just record the state change in the database
LOG.debug("Making a transition from 'TECHNICAL LEAD REVIEW' to 'REVIEWED' state");
transitionToState(context, SchemaVersionLifecycleStates.REVIEWED);
});
}
use of com.hortonworks.registries.schemaregistry.state.SchemaVersionLifecycleStateTransition in project registry by hortonworks.
the class CustomReviewCycleExecutor method registerTechnicalLeadReviewState.
public void registerTechnicalLeadReviewState(SchemaVersionLifecycleStateMachine.Builder builder) {
builder.register(CustomReviewCycleStates.TECHNICAL_LEAD_REVIEW_STATE);
builder.transition(new SchemaVersionLifecycleStateTransition(CustomReviewCycleStates.PEER_REVIEW_STATE.getId(), CustomReviewCycleStates.TECHNICAL_LEAD_REVIEW_STATE.getId(), CustomReviewCycleStates.TECHNICAL_LEAD_REVIEW_STATE.getName(), CustomReviewCycleStates.TECHNICAL_LEAD_REVIEW_STATE.getDescription()), (SchemaVersionLifecycleContext context) -> {
// Plugin a custom code to trigger as a part of the state transition, here we just record the state change in the database
LOG.debug("Making a transition from 'PEER REVIEW' to 'TECHNICAL LEAD REVIEW' state");
transitionToState(context, CustomReviewCycleStates.TECHNICAL_LEAD_REVIEW_STATE);
});
}
use of com.hortonworks.registries.schemaregistry.state.SchemaVersionLifecycleStateTransition in project registry by hortonworks.
the class CustomReviewCycleExecutor method registerChangesRequiredState.
public void registerChangesRequiredState(SchemaVersionLifecycleStateMachine.Builder builder) {
builder.transition(new SchemaVersionLifecycleStateTransition(CustomReviewCycleStates.PEER_REVIEW_STATE.getId(), SchemaVersionLifecycleStates.CHANGES_REQUIRED.getId(), SchemaVersionLifecycleStates.CHANGES_REQUIRED.getName(), SchemaVersionLifecycleStates.CHANGES_REQUIRED.getDescription()), (SchemaVersionLifecycleContext context) -> {
// Plugin a custom code to trigger as a part of the state transition, here we just record the state change in the database
LOG.debug("Making a transition from 'PEER REVIEW' to 'REJECTED' state");
transitionToState(context, SchemaVersionLifecycleStates.CHANGES_REQUIRED);
});
builder.transition(new SchemaVersionLifecycleStateTransition(CustomReviewCycleStates.TECHNICAL_LEAD_REVIEW_STATE.getId(), SchemaVersionLifecycleStates.CHANGES_REQUIRED.getId(), SchemaVersionLifecycleStates.CHANGES_REQUIRED.getName(), SchemaVersionLifecycleStates.CHANGES_REQUIRED.getDescription()), (SchemaVersionLifecycleContext context) -> {
// Plugin a custom code to trigger as a part of the state transition, here we just record the state change in the database
LOG.debug("Making a transition from 'TECHNICAL LEAD REVIEW' to 'REJECTED' state");
transitionToState(context, SchemaVersionLifecycleStates.CHANGES_REQUIRED);
});
}
use of com.hortonworks.registries.schemaregistry.state.SchemaVersionLifecycleStateTransition in project registry by hortonworks.
the class CustomReviewCycleExecutor method registerRejectedState.
public void registerRejectedState(SchemaVersionLifecycleStateMachine.Builder builder) {
builder.register(CustomReviewCycleStates.REJECTED_REVIEW_STATE);
builder.transition(new SchemaVersionLifecycleStateTransition(CustomReviewCycleStates.PEER_REVIEW_STATE.getId(), CustomReviewCycleStates.REJECTED_REVIEW_STATE.getId(), CustomReviewCycleStates.REJECTED_REVIEW_STATE.getName(), CustomReviewCycleStates.REJECTED_REVIEW_STATE.getDescription()), (SchemaVersionLifecycleContext context) -> {
// Plugin a custom code to trigger as a part of the state transition, here we just record the state change in the database
LOG.debug("Making a transition from 'PEER REVIEW' to 'REJECTED' state");
transitionToState(context, CustomReviewCycleStates.REJECTED_REVIEW_STATE);
});
builder.transition(new SchemaVersionLifecycleStateTransition(CustomReviewCycleStates.TECHNICAL_LEAD_REVIEW_STATE.getId(), CustomReviewCycleStates.REJECTED_REVIEW_STATE.getId(), CustomReviewCycleStates.REJECTED_REVIEW_STATE.getName(), CustomReviewCycleStates.REJECTED_REVIEW_STATE.getDescription()), (SchemaVersionLifecycleContext context) -> {
// Plugin a custom code to trigger as a part of the state transition, here we just record the state change in the database
LOG.debug("Making a transition from 'TECHNICAL LEAD REVIEW' to 'REJECTED' state");
transitionToState(context, CustomReviewCycleStates.REJECTED_REVIEW_STATE);
});
}
use of com.hortonworks.registries.schemaregistry.state.SchemaVersionLifecycleStateTransition in project registry by hortonworks.
the class AvroSchemaRegistryClientTest method testSchemaVersionStatesThroughIds.
@Test
public void testSchemaVersionStatesThroughIds() throws Exception {
SchemaMetadata schemaMetadata = new SchemaMetadata.Builder(TEST_NAME_RULE.getMethodName() + "-schema").type(AvroSchemaProvider.TYPE).schemaGroup("group").compatibility(SchemaCompatibility.BOTH).build();
String schemaName = schemaMetadata.getName();
// build nextTransitions from state machine
SchemaVersionLifecycleStateMachineInfo stateMachine = SCHEMA_REGISTRY_CLIENT.getSchemaVersionLifecycleStateMachineInfo();
Map<Byte, List<SchemaVersionLifecycleStateTransition>> nextTransitionsForStateIds = new HashMap<>();
for (SchemaVersionLifecycleStateTransition transition : stateMachine.getTransitions()) {
List<SchemaVersionLifecycleStateTransition> nextTransitions = nextTransitionsForStateIds.computeIfAbsent(transition.getSourceStateId(), aByte -> new ArrayList<>());
nextTransitions.add(transition);
}
Long id = SCHEMA_REGISTRY_CLIENT.registerSchemaMetadata(schemaMetadata);
SchemaIdVersion schemaIdVersion_1 = SCHEMA_REGISTRY_CLIENT.addSchemaVersion(schemaName, new SchemaVersion(AvroSchemaRegistryClientUtil.getSchema("/schema-1.avsc"), "Initial version of the schema"));
SchemaIdVersion schemaIdVersion_2 = SCHEMA_REGISTRY_CLIENT.addSchemaVersion(schemaName, new SchemaVersion(AvroSchemaRegistryClientUtil.getSchema("/schema-2.avsc"), "Second version of the schema"));
// disable version 2
SchemaVersionInfo schemaVersionInfo = SCHEMA_REGISTRY_CLIENT.getSchemaVersionInfo(schemaIdVersion_2);
Byte stateId = schemaVersionInfo.getStateId();
List<SchemaVersionLifecycleStateTransition> nextTransitions = nextTransitionsForStateIds.get(stateId);
Byte targetStateId = nextTransitions.get(0).getTargetStateId();
SCHEMA_REGISTRY_CLIENT.transitionState(schemaVersionInfo.getId(), targetStateId, null);
Assert.assertEquals(targetStateId, SCHEMA_REGISTRY_CLIENT.getSchemaVersionInfo(schemaIdVersion_2).getStateId());
}
Aggregations