use of io.zeebe.broker.transport.cfg.SocketBindingCfg in project zeebe by zeebe-io.
the class ClusterManager method createPartition.
/**
* Creates log stream and sets up raft service to participate in raft group
*/
protected void createPartition(DirectBuffer topicName, int partitionId, List<SocketAddress> members) {
final LogStream logStream = logStreamsManager.createLogStream(topicName, partitionId);
final SocketBindingCfg replicationApi = transportComponentCfg.replicationApi;
final SocketAddress socketAddress = new SocketAddress(replicationApi.getHost(transportComponentCfg.host), replicationApi.port);
createRaft(socketAddress, logStream, members);
}
use of io.zeebe.broker.transport.cfg.SocketBindingCfg in project zeebe by zeebe-io.
the class SystemContext method readBrokerId.
protected static String readBrokerId(ConfigurationManager configurationManager) {
final TransportComponentCfg transportComponentCfg = configurationManager.readEntry("network", TransportComponentCfg.class);
final SocketBindingCfg clientApiCfg = transportComponentCfg.clientApi;
return clientApiCfg.getHost(transportComponentCfg.host) + ":" + clientApiCfg.getPort();
}
use of io.zeebe.broker.transport.cfg.SocketBindingCfg 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