Search in sources :

Example 6 with LogStream

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();
}
Also used : LogStreamReader(io.zeebe.logstreams.log.LogStreamReader) LogStream(io.zeebe.logstreams.log.LogStream)

Example 7 with LogStream

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());
}
Also used : ActorScheduler(io.zeebe.util.sched.ActorScheduler) SnapshotStorage(io.zeebe.logstreams.spi.SnapshotStorage) LogStream(io.zeebe.logstreams.log.LogStream)

Example 8 with LogStream

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();
}
Also used : CommandResponseWriter(io.zeebe.broker.transport.clientapi.CommandResponseWriter) ServerTransport(io.zeebe.transport.ServerTransport) StreamProcessorController(io.zeebe.logstreams.processor.StreamProcessorController) LogStream(io.zeebe.logstreams.log.LogStream) WorkflowInstanceStreamProcessor(io.zeebe.broker.workflow.processor.WorkflowInstanceStreamProcessor) CreateWorkflowResponseSender(io.zeebe.broker.system.deployment.handler.CreateWorkflowResponseSender) StreamProcessorService(io.zeebe.broker.logstreams.processor.StreamProcessorService)

Example 9 with LogStream

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;
            }
        }
    });
}
Also used : LogStream(io.zeebe.logstreams.log.LogStream) Raft(io.zeebe.raft.Raft)

Example 10 with LogStream

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);
        }
    }
}
Also used : RaftPersistentFileStorage(io.zeebe.broker.clustering.raft.RaftPersistentFileStorage) DirectBuffer(org.agrona.DirectBuffer) IOException(java.io.IOException) SocketBindingCfg(io.zeebe.broker.transport.cfg.SocketBindingCfg) LogStream(io.zeebe.logstreams.log.LogStream) LogStreamsManager(io.zeebe.broker.logstreams.LogStreamsManager) File(java.io.File)

Aggregations

LogStream (io.zeebe.logstreams.log.LogStream)13 StreamProcessorService (io.zeebe.broker.logstreams.processor.StreamProcessorService)3 StreamProcessorController (io.zeebe.logstreams.processor.StreamProcessorController)3 TypedStreamEnvironment (io.zeebe.broker.logstreams.processor.TypedStreamEnvironment)2 TypedStreamProcessor (io.zeebe.broker.logstreams.processor.TypedStreamProcessor)2 SocketBindingCfg (io.zeebe.broker.transport.cfg.SocketBindingCfg)2 ServerTransport (io.zeebe.transport.ServerTransport)2 RaftPersistentFileStorage (io.zeebe.broker.clustering.raft.RaftPersistentFileStorage)1 IncidentStreamProcessor (io.zeebe.broker.incident.processor.IncidentStreamProcessor)1 LogStreamService (io.zeebe.broker.logstreams.LogStreamService)1 LogStreamsManager (io.zeebe.broker.logstreams.LogStreamsManager)1 CreateWorkflowResponseSender (io.zeebe.broker.system.deployment.handler.CreateWorkflowResponseSender)1 CommandResponseWriter (io.zeebe.broker.transport.clientapi.CommandResponseWriter)1 WorkflowInstanceStreamProcessor (io.zeebe.broker.workflow.processor.WorkflowInstanceStreamProcessor)1 FsLogStreamBuilder (io.zeebe.logstreams.fs.FsLogStreamBuilder)1 LogStreamReader (io.zeebe.logstreams.log.LogStreamReader)1 SnapshotStorage (io.zeebe.logstreams.spi.SnapshotStorage)1 UnpackedObject (io.zeebe.msgpack.UnpackedObject)1 Raft (io.zeebe.raft.Raft)1 BufferUtil.bufferAsString (io.zeebe.util.buffer.BufferUtil.bufferAsString)1