private void installPartition(final int partitionId, final List<Integer> members) { final RaftPersistentConfiguration configuration = configurationManager .createConfiguration( partitionId, brokerCfg.getCluster().getReplicationFactor(), members) .join(); installPartition(startContext, configuration); }
private void installPartition(final int partitionId, final List<Integer> members) { final RaftPersistentConfiguration configuration = configurationManager .createConfiguration( partitionId, brokerCfg.getCluster().getReplicationFactor(), members) .join(); installPartition(startContext, configuration); }
@Test public void shouldOverridePartitionsCountViaEnvironment() { // given environment.put(ENV_PARTITIONS_COUNT, "2"); // when final BrokerCfg cfg = readConfig("cluster-cfg"); final ClusterCfg cfgCluster = cfg.getCluster(); // then assertThat(cfgCluster.getPartitionsCount()).isEqualTo(2); }
@Test public void shouldOverrideClusterSizeViaEnvironment() { // given environment.put(ENV_CLUSTER_SIZE, "2"); // when final BrokerCfg cfg = readConfig("cluster-cfg"); final ClusterCfg cfgCluster = cfg.getCluster(); // then assertThat(cfgCluster.getClusterSize()).isEqualTo(2); }
@Test public void shouldOverrideReplicationFactorViaEnvironment() { // given environment.put(ENV_REPLICATION_FACTOR, "2"); // when final BrokerCfg cfg = readConfig("cluster-cfg"); final ClusterCfg cfgCluster = cfg.getCluster(); // then assertThat(cfgCluster.getReplicationFactor()).isEqualTo(2); }
@Test public void shouldOverrideClusterSizeViaEnvironment() { // given environment.put(ENV_CLUSTER_SIZE, "2"); // when final BrokerCfg cfg = readConfig("cluster-cfg"); final ClusterCfg cfgCluster = cfg.getCluster(); // then assertThat(cfgCluster.getClusterSize()).isEqualTo(2); }
@Test public void shouldReadDefaultSystemClusterConfiguration() { // given final BrokerCfg cfg = readConfig("default"); final ClusterCfg cfgCluster = cfg.getCluster(); // when - then assertThat(cfgCluster.getInitialContactPoints()).isEmpty(); assertThat(cfgCluster.getNodeId()).isEqualTo(DEFAULT_NODE_ID); assertThat(cfgCluster.getPartitionsCount()).isEqualTo(DEFAULT_PARTITIONS_COUNT); assertThat(cfgCluster.getReplicationFactor()).isEqualTo(DEFAULT_REPLICATION_FACTOR); assertThat(cfgCluster.getClusterSize()).isEqualTo(DEFAULT_CLUSTER_SIZE); }
@Test public void shouldReadSpecificSystemClusterConfiguration() { // given final BrokerCfg cfg = readConfig("cluster-cfg"); final ClusterCfg cfgCluster = cfg.getCluster(); // when - then assertThat(cfgCluster.getInitialContactPoints()).isEmpty(); assertThat(cfgCluster.getNodeId()).isEqualTo(2); assertThat(cfgCluster.getPartitionsCount()).isEqualTo(3); assertThat(cfgCluster.getReplicationFactor()).isEqualTo(4); assertThat(cfgCluster.getClusterSize()).isEqualTo(5); }
@Test public void shouldReadDefaultSystemClusterConfiguration() { // given final BrokerCfg cfg = readConfig("default"); final ClusterCfg cfgCluster = cfg.getCluster(); // when - then assertThat(cfgCluster.getInitialContactPoints()).isEmpty(); assertThat(cfgCluster.getNodeId()).isEqualTo(DEFAULT_NODE_ID); assertThat(cfgCluster.getPartitionsCount()).isEqualTo(DEFAULT_PARTITIONS_COUNT); assertThat(cfgCluster.getReplicationFactor()).isEqualTo(DEFAULT_REPLICATION_FACTOR); assertThat(cfgCluster.getClusterSize()).isEqualTo(DEFAULT_CLUSTER_SIZE); }
@Test public void shouldReadSpecificSystemClusterConfiguration() { // given final BrokerCfg cfg = readConfig("cluster-cfg"); final ClusterCfg cfgCluster = cfg.getCluster(); // when - then assertThat(cfgCluster.getInitialContactPoints()).isEmpty(); assertThat(cfgCluster.getNodeId()).isEqualTo(2); assertThat(cfgCluster.getPartitionsCount()).isEqualTo(3); assertThat(cfgCluster.getReplicationFactor()).isEqualTo(4); assertThat(cfgCluster.getClusterSize()).isEqualTo(5); }
@Test public void shouldCreatePartitionIds() { // given final BrokerCfg cfg = readConfig("cluster-cfg"); final ClusterCfg cfgCluster = cfg.getCluster(); // when - then assertThat(cfgCluster.getPartitionsCount()).isEqualTo(3); final List<Integer> partitionIds = cfgCluster.getPartitionIds(); assertThat(partitionIds).contains(0, 1, 2); }
public BootstrapPartitions(final BrokerCfg brokerCfg) { this.brokerCfg = brokerCfg; final ClusterCfg cluster = brokerCfg.getCluster(); partitionsLeaderMatrix = new PartitionsLeaderMatrix( cluster.getPartitionsCount(), cluster.getClusterSize(), cluster.getReplicationFactor()); final int nodeId = cluster.getNodeId(); followingPartitions = partitionsLeaderMatrix.getFollowingPartitions(nodeId); leadingPartitions = partitionsLeaderMatrix.getLeadingPartitions(nodeId); }
@Test public void shouldThrowExceptionIfPartitionsCountIsNegative() { // given final BrokerCfg brokerCfg = new BrokerCfg(); brokerCfg.getCluster().setPartitionsCount(-1); // expect expectedException.expect(IllegalArgumentException.class); expectedException.expectMessage("Partition count must not be smaller then 1."); initSystemContext(brokerCfg); }
@Test public void shouldThrowExceptionIfReplicationFactorIsLargerThenClusterSize() { // given final BrokerCfg brokerCfg = new BrokerCfg(); brokerCfg.getCluster().setReplicationFactor(2); // expect expectedException.expect(IllegalArgumentException.class); expectedException.expectMessage( "Replication factor 2 needs to be larger then zero and not larger then cluster size 1."); initSystemContext(brokerCfg); }
@Test public void shouldThrowExceptionIfNodeIdIsNegative() { // given final BrokerCfg brokerCfg = new BrokerCfg(); brokerCfg.getCluster().setNodeId(-1); // expect expectedException.expect(IllegalArgumentException.class); expectedException.expectMessage( "Node id -1 needs to be non negative and smaller then cluster size 1."); initSystemContext(brokerCfg); }
@Test public void shouldThrowExceptionIfNodeIdIsLargerThenClusterSize() { // given final BrokerCfg brokerCfg = new BrokerCfg(); brokerCfg.getCluster().setNodeId(2); // expect expectedException.expect(IllegalArgumentException.class); expectedException.expectMessage( "Node id 2 needs to be non negative and smaller then cluster size 1."); initSystemContext(brokerCfg); }
@Test public void shouldThrowExceptionIfReplicationFactorIsNegative() { // given final BrokerCfg brokerCfg = new BrokerCfg(); brokerCfg.getCluster().setReplicationFactor(-1); // expect expectedException.expect(IllegalArgumentException.class); expectedException.expectMessage( "Replication factor -1 needs to be larger then zero and not larger then cluster size 1."); initSystemContext(brokerCfg); }
@Test public void shouldThrowExceptionIfPartitionsCountIsNegative() { // given final BrokerCfg brokerCfg = new BrokerCfg(); brokerCfg.getCluster().setPartitionsCount(-1); // expect expectedException.expect(IllegalArgumentException.class); expectedException.expectMessage("Partition count must not be smaller then 1."); initSystemContext(brokerCfg); }
@Test public void shouldThrowExceptionIfNodeIdIsLargerThenClusterSize() { // given final BrokerCfg brokerCfg = new BrokerCfg(); brokerCfg.getCluster().setNodeId(2); // expect expectedException.expect(IllegalArgumentException.class); expectedException.expectMessage( "Node id 2 needs to be non negative and smaller then cluster size 1."); initSystemContext(brokerCfg); }
@Test public void shouldThrowExceptionIfReplicationFactorIsLargerThenClusterSize() { // given final BrokerCfg brokerCfg = new BrokerCfg(); brokerCfg.getCluster().setReplicationFactor(2); // expect expectedException.expect(IllegalArgumentException.class); expectedException.expectMessage( "Replication factor 2 needs to be larger then zero and not larger then cluster size 1."); initSystemContext(brokerCfg); }