
io.zeebe.broker.system.configuration.ClusterCfg Maven / Gradle / Ivy
/*
* Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH under
* one or more contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright ownership.
* Licensed under the Zeebe Community License 1.1. You may not use this file
* except in compliance with the Zeebe Community License 1.1.
*/
package io.zeebe.broker.system.configuration;
import static io.zeebe.protocol.Protocol.START_PARTITION_ID;
import static io.zeebe.util.StringUtil.LIST_SANITIZER;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
public final class ClusterCfg implements ConfigurationEntry {
public static final List DEFAULT_CONTACT_POINTS = Collections.emptyList();
public static final int DEFAULT_NODE_ID = 0;
public static final int DEFAULT_PARTITIONS_COUNT = 1;
public static final int DEFAULT_REPLICATION_FACTOR = 1;
public static final int DEFAULT_CLUSTER_SIZE = 1;
public static final String DEFAULT_CLUSTER_NAME = "zeebe-cluster";
private List initialContactPoints = DEFAULT_CONTACT_POINTS;
private List partitionIds;
private int nodeId = DEFAULT_NODE_ID;
private int partitionsCount = DEFAULT_PARTITIONS_COUNT;
private int replicationFactor = DEFAULT_REPLICATION_FACTOR;
private int clusterSize = DEFAULT_CLUSTER_SIZE;
private String clusterName = DEFAULT_CLUSTER_NAME;
private MembershipCfg membership = new MembershipCfg();
@Override
public void init(final BrokerCfg globalConfig, final String brokerBase) {
initPartitionIds();
}
private void initPartitionIds() {
partitionIds =
IntStream.range(START_PARTITION_ID, START_PARTITION_ID + partitionsCount)
.boxed()
.collect(Collectors.toList());
}
public List getInitialContactPoints() {
return initialContactPoints;
}
public void setInitialContactPoints(final List initialContactPoints) {
this.initialContactPoints = LIST_SANITIZER.apply(initialContactPoints);
}
public int getNodeId() {
return nodeId;
}
public void setNodeId(final int nodeId) {
this.nodeId = nodeId;
}
public int getPartitionsCount() {
return partitionsCount;
}
public void setPartitionsCount(final int partitionsCount) {
this.partitionsCount = partitionsCount;
}
public List getPartitionIds() {
return partitionIds;
}
public int getReplicationFactor() {
return replicationFactor;
}
public void setReplicationFactor(final int replicationFactor) {
this.replicationFactor = replicationFactor;
}
public int getClusterSize() {
return clusterSize;
}
public void setClusterSize(final int clusterSize) {
this.clusterSize = clusterSize;
}
public String getClusterName() {
return clusterName;
}
public void setClusterName(final String clusterName) {
this.clusterName = clusterName;
}
public MembershipCfg getMembership() {
return membership;
}
public void setMembership(final MembershipCfg membership) {
this.membership = membership;
}
@Override
public String toString() {
return "ClusterCfg{"
+ "initialContactPoints="
+ initialContactPoints
+ ", partitionIds="
+ partitionIds
+ ", nodeId="
+ nodeId
+ ", partitionsCount="
+ partitionsCount
+ ", replicationFactor="
+ replicationFactor
+ ", clusterSize="
+ clusterSize
+ ", clusterName='"
+ clusterName
+ '\''
+ ", membership="
+ membership
+ '}';
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy