use of io.zeebe.broker.logstreams.LogStreamsManager in project zeebe by zeebe-io.
the class ClusterManagerContextService method start.
@Override
public void start(ServiceStartContext startContext) {
final ClientTransport clientTransport = managementClientInjector.getValue();
final BufferingServerTransport serverTransport = managementApiTransportInjector.getValue();
final ActorScheduler actorScheduler = startContext.getScheduler();
final LogStreamsManager logStreamsManager = logStreamsManagerInjector.getValue();
final WorkflowRequestMessageHandler workflowRequestMessageHandler = workflowRequestMessageHandlerInjector.getValue();
context = new ClusterManagerContext();
context.setGossip(gossipInjector.getValue());
context.setActorScheduler(actorScheduler);
context.setManagementClient(clientTransport);
context.setReplicationClient(replicationClientInjector.getValue());
context.setServerTransport(serverTransport);
context.setMemberListService(memberListServiceInjector.getValue());
context.setLogStreamsManager(logStreamsManager);
context.setWorkflowRequestMessageHandler(workflowRequestMessageHandler);
}
use of io.zeebe.broker.logstreams.LogStreamsManager 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