public Builder(Partition partition, ServiceName<Partition> serviceName) { this.logStream = partition.getLogStream(); this.additionalDependencies.add(serviceName); }
public Builder(Partition partition, ServiceName<Partition> serviceName) { this.logStream = partition.getLogStream(); this.additionalDependencies.add(serviceName); }
private boolean writeCreatingDeployment( final Partition partition, final long key, final UnpackedObject event) { final RecordType recordType = RecordType.COMMAND; final ValueType valueType = ValueType.DEPLOYMENT; final Intent intent = DeploymentIntent.CREATE; logStreamWriter.wrap(partition.getLogStream()); recordMetadata.reset().recordType(recordType).valueType(valueType).intent(intent); final long position = logStreamWriter.key(key).metadataWriter(recordMetadata).valueWriter(event).tryWrite(); return position > 0; } }
private boolean writeCreatingDeployment( final Partition partition, final long key, final UnpackedObject event) { final RecordType recordType = RecordType.COMMAND; final ValueType valueType = ValueType.DEPLOYMENT; final Intent intent = DeploymentIntent.CREATE; logStreamWriter.wrap(partition.getLogStream()); recordMetadata.reset().recordType(recordType).valueType(valueType).intent(intent); final long position = logStreamWriter.key(key).metadataWriter(recordMetadata).valueWriter(event).tryWrite(); return position > 0; } }
private boolean writeCommand( int partitionId, ValueType valueType, Intent intent, UnpackedObject command) { final Partition partition = leaderPartitions.get(partitionId); if (partition == null) { // ignore message if you are not the leader of the partition return true; } logStreamWriter.wrap(partition.getLogStream()); recordMetadata.reset().recordType(RecordType.COMMAND).valueType(valueType).intent(intent); final long position = logStreamWriter .positionAsKey() .metadataWriter(recordMetadata) .valueWriter(command) .tryWrite(); return position > 0; } }
private boolean writeCommand( int partitionId, ValueType valueType, Intent intent, UnpackedObject command) { final Partition partition = leaderPartitions.get(partitionId); if (partition == null) { // ignore message if you are not the leader of the partition return true; } logStreamWriter.wrap(partition.getLogStream()); recordMetadata.reset().recordType(RecordType.COMMAND).valueType(valueType).intent(intent); final long position = logStreamWriter .positionAsKey() .metadataWriter(recordMetadata) .valueWriter(command) .tryWrite(); return position > 0; } }
public void startStreamProcessors( final ServiceName<Partition> partitionServiceName, final Partition partition) { final int partitionId = partition.getInfo().getPartitionId(); final Builder streamProcessorServiceBuilder = streamProcessorServiceFactory .createService(partition, partitionServiceName) .processorId(partitionId) .processorName(PROCESSOR_NAME); final StateStorage stateStorage = partition.getStateStorageFactory().create(partitionId, PROCESSOR_NAME); final StateSnapshotController stateSnapshotController = new StateSnapshotController(DefaultZeebeDbFactory.DEFAULT_DB_FACTORY, stateStorage); streamProcessorServiceBuilder .snapshotController(stateSnapshotController) .streamProcessorFactory( (zeebeDb) -> { final ZeebeState zeebeState = new ZeebeState(partitionId, zeebeDb); final TypedStreamEnvironment streamEnvironment = new TypedStreamEnvironment( partition.getLogStream(), clientApiTransport.getOutput()); return createTypedStreamProcessor( partitionServiceName, partitionId, streamEnvironment, zeebeState); }) .build(); }
public void startStreamProcessors( final ServiceName<Partition> partitionServiceName, final Partition partition) { final int partitionId = partition.getInfo().getPartitionId(); final Builder streamProcessorServiceBuilder = streamProcessorServiceFactory .createService(partition, partitionServiceName) .processorId(partitionId) .processorName(PROCESSOR_NAME); final StateStorage stateStorage = partition.getStateStorageFactory().create(partitionId, PROCESSOR_NAME); final StateSnapshotController stateSnapshotController = new StateSnapshotController(DefaultZeebeDbFactory.DEFAULT_DB_FACTORY, stateStorage); streamProcessorServiceBuilder .snapshotController(stateSnapshotController) .streamProcessorFactory( (zeebeDb) -> { final ZeebeState zeebeState = new ZeebeState(partitionId, zeebeDb); final TypedStreamEnvironment streamEnvironment = new TypedStreamEnvironment( partition.getLogStream(), clientApiTransport.getOutput()); return createTypedStreamProcessor( partitionServiceName, partitionId, streamEnvironment, zeebeState); }) .build(); }
eventMetadata.valueType(eventType); logStreamWriter.wrap(partition.getLogStream());
eventMetadata.valueType(eventType); logStreamWriter.wrap(partition.getLogStream());