public Builder transition(SchemaVersionLifecycleStateTransition transition, SchemaVersionLifecycleStateAction action) { Byte sourceStateId = transition.getSourceStateId(); Byte targetStateId = transition.getTargetStateId(); checkStatesRegistered(sourceStateId, targetStateId); SchemaVersionLifecycleStateAction existingTransitionAction = transitionsWithActions.putIfAbsent(transition, action); if (existingTransitionAction != null) { throw new IllegalArgumentException("Given transition already exists, from: [" + sourceStateId + "] to: [" + targetStateId + "]"); } return this; }
public Builder transition(SchemaVersionLifecycleStateTransition transition, SchemaVersionLifecycleStateAction action) { Byte sourceStateId = transition.getSourceStateId(); Byte targetStateId = transition.getTargetStateId(); checkStatesRegistered(sourceStateId, targetStateId); SchemaVersionLifecycleStateAction existingTransitionAction = transitionsWithActions.putIfAbsent(transition, action); if (existingTransitionAction != null) { throw new IllegalArgumentException("Given transition already exists, from: [" + sourceStateId + "] to: [" + targetStateId + "]"); } return this; }
public void registerNotificationsWithSchemaEnabled(SchemaVersionLifecycleStateMachine.Builder builder, Map<String, ?> props) { builder.getTransitionsWithActions().entrySet().stream(). filter(transitionAction -> transitionAction.getKey().getTargetStateId().equals(SchemaVersionLifecycleStates.ENABLED.getId())). forEach(transitionAction -> builder.registerListener(transitionAction.getKey(), new SchemaVersionLifecycleStateTransitionListener() { @Override public void preStateTransition(SchemaVersionLifecycleContext context) { LOG.debug("preStateTransition() does nothing for this state transition"); } @Override public void postStateTransition(SchemaVersionLifecycleContext context) { LOG.debug("postStateTransition() calling external review service to notify the state transition"); Long schemaVersionId = context.getSchemaVersionId(); WebTarget webTarget = ClientBuilder.newClient().target(props.get("review.service.url").toString()). path("/v1/transition/schema/"+schemaVersionId+"/notify"); webTarget.request().post(null); } })); }
List<SchemaVersionLifecycleStateTransition> nextTransitions = nextTransitionsForStateIds.get(stateId); Byte targetStateId = nextTransitions.get(0).getTargetStateId(); SCHEMA_REGISTRY_CLIENT.transitionState(schemaVersionInfo.getId(), targetStateId, null);