use of io.zeebe.logstreams.log.LogStream in project zeebe by zeebe-io.
the class TopicSubscriptionPushProcessor method onOpen.
@Override
public void onOpen(StreamProcessorContext context) {
this.context = context;
final LogStreamReader logReader = context.getLogStreamReader();
final LogStream logStream = context.getLogStream();
this.logStreamPartitionId = logStream.getPartitionId();
setToStartPosition(logReader);
context.suspendController();
}
use of io.zeebe.logstreams.log.LogStream in project zeebe by zeebe-io.
the class StreamProcessorService method start.
@Override
public void start(ServiceStartContext ctx) {
final LogStream logStream = logStreamInjector.getValue();
final SnapshotStorage snapshotStorage = snapshotStorageInjector.getValue();
final ActorScheduler actorScheduler = ctx.getScheduler();
MetadataFilter metadataFilter = versionFilter;
if (customEventFilter != null) {
metadataFilter = metadataFilter.and(customEventFilter);
}
final EventFilter eventFilter = new MetadataEventFilter(metadataFilter);
streamProcessorController = LogStreams.createStreamProcessor(name, id, streamProcessor).logStream(logStream).snapshotStorage(snapshotStorage).snapshotPeriod(Duration.ofMinutes(15)).actorScheduler(actorScheduler).eventFilter(eventFilter).readOnly(readOnly).build();
ctx.async(streamProcessorController.openAsync());
}
use of io.zeebe.logstreams.log.LogStream in project zeebe by zeebe-io.
the class WorkflowQueueManagerService method installWorkflowStreamProcessor.
private void installWorkflowStreamProcessor(final LogStream logStream) {
final ServiceName<StreamProcessorController> streamProcessorServiceName = workflowInstanceStreamProcessorServiceName(logStream.getLogName());
final String streamProcessorName = streamProcessorServiceName.getName();
final ServerTransport transport = clientApiTransportInjector.getValue();
final CommandResponseWriter responseWriter = new CommandResponseWriter(transport.getOutput());
final ServiceName<LogStream> logStreamServiceName = logStreamServiceName(logStream.getLogName());
final ServerTransport managementServer = managementServerInjector.getValue();
final CreateWorkflowResponseSender createWorkflowResponseSender = new CreateWorkflowResponseSender(managementServer);
final WorkflowInstanceStreamProcessor workflowInstanceStreamProcessor = new WorkflowInstanceStreamProcessor(responseWriter, createWorkflowResponseSender, workflowCfg.deploymentCacheSize, workflowCfg.payloadCacheSize);
final StreamProcessorService workflowStreamProcessorService = new StreamProcessorService(streamProcessorName, StreamProcessorIds.WORKFLOW_INSTANCE_PROCESSOR_ID, workflowInstanceStreamProcessor).eventFilter(WorkflowInstanceStreamProcessor.eventFilter());
serviceContext.createService(streamProcessorServiceName, workflowStreamProcessorService).dependency(logStreamServiceName, workflowStreamProcessorService.getLogStreamInjector()).dependency(SNAPSHOT_STORAGE_SERVICE, workflowStreamProcessorService.getSnapshotStorageInjector()).install();
}
use of io.zeebe.logstreams.log.LogStream in project zeebe by zeebe-io.
the class ClusterManager method removeRaftCallback.
/**
* This method is called, if a RAFT is removed from the service group.
*/
public void removeRaftCallback(final Raft raft) {
final LogStream logStream = raft.getLogStream();
final int partitionId = logStream.getPartitionId();
actor.call(() -> {
for (int i = 0; i < rafts.size(); i++) {
final Raft r = rafts.get(i);
final LogStream stream = r.getLogStream();
if (partitionId == stream.getPartitionId()) {
rafts.remove(i);
break;
}
}
});
}
use of io.zeebe.logstreams.log.LogStream in project zeebe by zeebe-io.
the class ClusterManager method open.
private void open() {
final List<SocketAddress> collect = Arrays.stream(transportComponentCfg.gossip.initialContactPoints).map(SocketAddress::from).collect(Collectors.toList());
if (!collect.isEmpty()) {
context.getGossip().join(collect);
}
clusterMemberListManager.publishNodeAPIAddresses();
final LogStreamsManager logStreamManager = context.getLogStreamsManager();
final File storageDirectory = new File(transportComponentCfg.management.directory);
if (!storageDirectory.exists()) {
try {
storageDirectory.getParentFile().mkdirs();
Files.createDirectory(storageDirectory.toPath());
} catch (final IOException e) {
LOG.error("Unable to create directory {}", storageDirectory, e);
}
}
final SocketBindingCfg replicationApi = transportComponentCfg.replicationApi;
final SocketAddress socketAddress = new SocketAddress(replicationApi.getHost(transportComponentCfg.host), replicationApi.port);
final File[] storageFiles = storageDirectory.listFiles();
if (storageFiles != null && storageFiles.length > 0) {
for (int i = 0; i < storageFiles.length; i++) {
final File storageFile = storageFiles[i];
final RaftPersistentFileStorage storage = new RaftPersistentFileStorage(storageFile.getAbsolutePath());
final DirectBuffer topicName = storage.getTopicName();
final int partitionId = storage.getPartitionId();
LogStream logStream = logStreamManager.getLogStream(partitionId);
if (logStream == null) {
final String directory = storage.getLogDirectory();
logStream = logStreamManager.createLogStream(topicName, partitionId, directory);
}
storage.setLogStream(logStream);
createRaft(socketAddress, logStream, storage.getMembers(), storage);
}
} else {
if (transportComponentCfg.gossip.initialContactPoints.length == 0) {
LOG.debug("Broker bootstraps the system topic");
createPartition(Protocol.SYSTEM_TOPIC_BUF, Protocol.SYSTEM_PARTITION);
}
}
}
Aggregations