Search in sources :

Example 1 with NetworkCfg

use of io.camunda.zeebe.broker.system.configuration.NetworkCfg in project zeebe by zeebe-io.

the class EmbeddedBrokerRule method assignSocketAddresses.

public static void assignSocketAddresses(final BrokerCfg brokerCfg) {
    final NetworkCfg network = brokerCfg.getNetwork();
    brokerCfg.getGateway().getNetwork().setPort(SocketUtil.getNextAddress().getPort());
    network.getCommandApi().setPort(SocketUtil.getNextAddress().getPort());
    network.getInternalApi().setPort(SocketUtil.getNextAddress().getPort());
}
Also used : NetworkCfg(io.camunda.zeebe.broker.system.configuration.NetworkCfg)

Example 2 with NetworkCfg

use of io.camunda.zeebe.broker.system.configuration.NetworkCfg in project zeebe by camunda-cloud.

the class EmbeddedBrokerRule method assignSocketAddresses.

public static void assignSocketAddresses(final BrokerCfg brokerCfg) {
    final NetworkCfg network = brokerCfg.getNetwork();
    brokerCfg.getGateway().getNetwork().setPort(SocketUtil.getNextAddress().getPort());
    network.getCommandApi().setPort(SocketUtil.getNextAddress().getPort());
    network.getInternalApi().setPort(SocketUtil.getNextAddress().getPort());
}
Also used : NetworkCfg(io.camunda.zeebe.broker.system.configuration.NetworkCfg)

Example 3 with NetworkCfg

use of io.camunda.zeebe.broker.system.configuration.NetworkCfg in project zeebe by zeebe-io.

the class RaftPartitionGroupFactory method buildRaftPartitionGroup.

RaftPartitionGroup buildRaftPartitionGroup(final BrokerCfg configuration, final ReceivableSnapshotStoreFactory snapshotStoreFactory) {
    final DataCfg dataConfiguration = configuration.getData();
    final String rootDirectory = dataConfiguration.getDirectory();
    final var rootPath = Paths.get(rootDirectory);
    try {
        FileUtil.ensureDirectoryExists(rootPath);
    } catch (final IOException e) {
        throw new UncheckedIOException("Failed to create data directory", e);
    }
    final var raftDataDirectory = rootPath.resolve(PartitionManagerImpl.GROUP_NAME);
    try {
        FileUtil.ensureDirectoryExists(raftDataDirectory);
    } catch (final IOException e) {
        throw new UncheckedIOException("Failed to create Raft data directory", e);
    }
    final ClusterCfg clusterCfg = configuration.getCluster();
    final var experimentalCfg = configuration.getExperimental();
    final DataCfg dataCfg = configuration.getData();
    final NetworkCfg networkCfg = configuration.getNetwork();
    final var partitionDistributor = buildPartitionDistributor(configuration.getExperimental().getPartitioning());
    final Builder partitionGroupBuilder = RaftPartitionGroup.builder(PartitionManagerImpl.GROUP_NAME).withNumPartitions(clusterCfg.getPartitionsCount()).withPartitionSize(clusterCfg.getReplicationFactor()).withMembers(getRaftGroupMembers(clusterCfg)).withDataDirectory(raftDataDirectory.toFile()).withSnapshotStoreFactory(snapshotStoreFactory).withMaxAppendBatchSize((int) experimentalCfg.getMaxAppendBatchSizeInBytes()).withMaxAppendsPerFollower(experimentalCfg.getMaxAppendsPerFollower()).withEntryValidator(new ZeebeEntryValidator()).withFlushExplicitly(!experimentalCfg.isDisableExplicitRaftFlush()).withFreeDiskSpace(dataCfg.getFreeDiskSpaceReplicationWatermark()).withJournalIndexDensity(dataCfg.getLogIndexDensity()).withPriorityElection(clusterCfg.getRaft().isEnablePriorityElection()).withPartitionDistributor(partitionDistributor).withElectionTimeout(clusterCfg.getElectionTimeout()).withHeartbeatInterval(clusterCfg.getHeartbeatInterval()).withRequestTimeout(experimentalCfg.getRaft().getRequestTimeout()).withMaxQuorumResponseTimeout(experimentalCfg.getRaft().getMaxQuorumResponseTimeout()).withMinStepDownFailureCount(experimentalCfg.getRaft().getMinStepDownFailureCount()).withPreferSnapshotReplicationThreshold(experimentalCfg.getRaft().getPreferSnapshotReplicationThreshold());
    final int maxMessageSize = (int) networkCfg.getMaxMessageSizeInBytes();
    final var segmentSize = dataCfg.getLogSegmentSizeInBytes();
    if (segmentSize < maxMessageSize) {
        throw new IllegalArgumentException(String.format("Expected the raft segment size greater than the max message size of %s, but was %s.", maxMessageSize, segmentSize));
    }
    partitionGroupBuilder.withSegmentSize(segmentSize);
    return partitionGroupBuilder.build();
}
Also used : ZeebeEntryValidator(io.camunda.zeebe.broker.raft.ZeebeEntryValidator) NetworkCfg(io.camunda.zeebe.broker.system.configuration.NetworkCfg) DataCfg(io.camunda.zeebe.broker.system.configuration.DataCfg) Builder(io.atomix.raft.partition.RaftPartitionGroup.Builder) FixedPartitionDistributorBuilder(io.camunda.zeebe.broker.partitioning.distribution.FixedPartitionDistributorBuilder) ClusterCfg(io.camunda.zeebe.broker.system.configuration.ClusterCfg) UncheckedIOException(java.io.UncheckedIOException) IOException(java.io.IOException) UncheckedIOException(java.io.UncheckedIOException)

Example 4 with NetworkCfg

use of io.camunda.zeebe.broker.system.configuration.NetworkCfg in project zeebe by camunda-cloud.

the class RaftPartitionGroupFactory method buildRaftPartitionGroup.

RaftPartitionGroup buildRaftPartitionGroup(final BrokerCfg configuration, final ReceivableSnapshotStoreFactory snapshotStoreFactory) {
    final DataCfg dataConfiguration = configuration.getData();
    final String rootDirectory = dataConfiguration.getDirectory();
    final var rootPath = Paths.get(rootDirectory);
    try {
        FileUtil.ensureDirectoryExists(rootPath);
    } catch (final IOException e) {
        throw new UncheckedIOException("Failed to create data directory", e);
    }
    final var raftDataDirectory = rootPath.resolve(PartitionManagerImpl.GROUP_NAME);
    try {
        FileUtil.ensureDirectoryExists(raftDataDirectory);
    } catch (final IOException e) {
        throw new UncheckedIOException("Failed to create Raft data directory", e);
    }
    final ClusterCfg clusterCfg = configuration.getCluster();
    final var experimentalCfg = configuration.getExperimental();
    final DataCfg dataCfg = configuration.getData();
    final NetworkCfg networkCfg = configuration.getNetwork();
    final var partitionDistributor = buildPartitionDistributor(configuration.getExperimental().getPartitioning());
    final Builder partitionGroupBuilder = RaftPartitionGroup.builder(PartitionManagerImpl.GROUP_NAME).withNumPartitions(clusterCfg.getPartitionsCount()).withPartitionSize(clusterCfg.getReplicationFactor()).withMembers(getRaftGroupMembers(clusterCfg)).withDataDirectory(raftDataDirectory.toFile()).withSnapshotStoreFactory(snapshotStoreFactory).withMaxAppendBatchSize((int) experimentalCfg.getMaxAppendBatchSizeInBytes()).withMaxAppendsPerFollower(experimentalCfg.getMaxAppendsPerFollower()).withEntryValidator(new ZeebeEntryValidator()).withFlushExplicitly(!experimentalCfg.isDisableExplicitRaftFlush()).withFreeDiskSpace(dataCfg.getFreeDiskSpaceReplicationWatermark()).withJournalIndexDensity(dataCfg.getLogIndexDensity()).withPriorityElection(clusterCfg.getRaft().isEnablePriorityElection()).withPartitionDistributor(partitionDistributor).withElectionTimeout(clusterCfg.getElectionTimeout()).withHeartbeatInterval(clusterCfg.getHeartbeatInterval()).withRequestTimeout(experimentalCfg.getRaft().getRequestTimeout()).withMaxQuorumResponseTimeout(experimentalCfg.getRaft().getMaxQuorumResponseTimeout()).withMinStepDownFailureCount(experimentalCfg.getRaft().getMinStepDownFailureCount()).withPreferSnapshotReplicationThreshold(experimentalCfg.getRaft().getPreferSnapshotReplicationThreshold());
    final int maxMessageSize = (int) networkCfg.getMaxMessageSizeInBytes();
    final var segmentSize = dataCfg.getLogSegmentSizeInBytes();
    if (segmentSize < maxMessageSize) {
        throw new IllegalArgumentException(String.format("Expected the raft segment size greater than the max message size of %s, but was %s.", maxMessageSize, segmentSize));
    }
    partitionGroupBuilder.withSegmentSize(segmentSize);
    return partitionGroupBuilder.build();
}
Also used : ZeebeEntryValidator(io.camunda.zeebe.broker.raft.ZeebeEntryValidator) NetworkCfg(io.camunda.zeebe.broker.system.configuration.NetworkCfg) DataCfg(io.camunda.zeebe.broker.system.configuration.DataCfg) Builder(io.atomix.raft.partition.RaftPartitionGroup.Builder) FixedPartitionDistributorBuilder(io.camunda.zeebe.broker.partitioning.distribution.FixedPartitionDistributorBuilder) ClusterCfg(io.camunda.zeebe.broker.system.configuration.ClusterCfg) UncheckedIOException(java.io.UncheckedIOException) IOException(java.io.IOException) UncheckedIOException(java.io.UncheckedIOException)

Example 5 with NetworkCfg

use of io.camunda.zeebe.broker.system.configuration.NetworkCfg in project zeebe by camunda.

the class EmbeddedBrokerRule method assignSocketAddresses.

public static void assignSocketAddresses(final BrokerCfg brokerCfg) {
    final NetworkCfg network = brokerCfg.getNetwork();
    brokerCfg.getGateway().getNetwork().setPort(SocketUtil.getNextAddress().getPort());
    network.getCommandApi().setPort(SocketUtil.getNextAddress().getPort());
    network.getInternalApi().setPort(SocketUtil.getNextAddress().getPort());
}
Also used : NetworkCfg(io.camunda.zeebe.broker.system.configuration.NetworkCfg)

Aggregations

NetworkCfg (io.camunda.zeebe.broker.system.configuration.NetworkCfg)6 Builder (io.atomix.raft.partition.RaftPartitionGroup.Builder)3 FixedPartitionDistributorBuilder (io.camunda.zeebe.broker.partitioning.distribution.FixedPartitionDistributorBuilder)3 ClusterCfg (io.camunda.zeebe.broker.system.configuration.ClusterCfg)3 DataCfg (io.camunda.zeebe.broker.system.configuration.DataCfg)3 IOException (java.io.IOException)3 UncheckedIOException (java.io.UncheckedIOException)3 ZeebeEntryValidator (io.camunda.zeebe.broker.raft.ZeebeEntryValidator)2 ZeebeEntryValidator (io.camunda.zeebe.logstreams.impl.log.ZeebeEntryValidator)1