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