Search in sources :

Example 1 with SocketBindingCfg

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

Example 2 with SocketBindingCfg

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();
}
Also used : TransportComponentCfg(io.zeebe.broker.transport.cfg.TransportComponentCfg) SocketBindingCfg(io.zeebe.broker.transport.cfg.SocketBindingCfg)

Example 3 with SocketBindingCfg

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);
        }
    }
}
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

SocketBindingCfg (io.zeebe.broker.transport.cfg.SocketBindingCfg)3 LogStream (io.zeebe.logstreams.log.LogStream)2 RaftPersistentFileStorage (io.zeebe.broker.clustering.raft.RaftPersistentFileStorage)1 LogStreamsManager (io.zeebe.broker.logstreams.LogStreamsManager)1 TransportComponentCfg (io.zeebe.broker.transport.cfg.TransportComponentCfg)1 File (java.io.File)1 IOException (java.io.IOException)1 DirectBuffer (org.agrona.DirectBuffer)1