コード例 #1
0
ファイル: test_reorder.py プロジェクト: bingyuac/kafka-tools
    def test_process_cluster_no_change(self):
        action = ActionReorder(self.args, self.cluster)
        action.process_cluster()

        b1 = self.cluster.brokers[1]
        b2 = self.cluster.brokers[2]
        assert self.cluster.topics['testTopic1'].partitions[0].replicas == [b1, b2]
        assert self.cluster.topics['testTopic1'].partitions[1].replicas == [b2, b1]
        assert self.cluster.topics['testTopic2'].partitions[0].replicas == [b2, b1]
        assert self.cluster.topics['testTopic2'].partitions[1].replicas == [b1, b2]
コード例 #2
0
ファイル: test_reorder.py プロジェクト: bingyuac/kafka-tools
    def test_process_cluster(self):
        b1 = self.cluster.brokers[1]
        b2 = self.cluster.brokers[2]
        self.cluster.topics['testTopic1'].partitions[0].swap_replica_positions(b1, b2)

        action = ActionReorder(self.args, self.cluster)
        action.process_cluster()

        assert self.cluster.topics['testTopic1'].partitions[0].replicas == [b2, b1]
        assert self.cluster.topics['testTopic1'].partitions[1].replicas == [b1, b2]
        assert self.cluster.topics['testTopic2'].partitions[0].replicas == [b2, b1]
        assert self.cluster.topics['testTopic2'].partitions[1].replicas == [b1, b2]
コード例 #3
0
class ActionBalanceLeader(ActionBalanceModule):
    name = "leader"
    helpstr = "Balance the cluster leadership by reordering the partition replica lists"

    def __init__(self, args, cluster):
        super(ActionBalanceLeader, self).__init__(args, cluster)

        # This module merely calls the main "reorder" module, so we're going to instantiate a copy of that
        self._reorder = ActionReorder(args, cluster)

    def process_cluster(self):
        # Call the reorder module
        self._reorder.process_cluster()
コード例 #4
0
    def test_process_cluster_no_change(self):
        action = ActionReorder(self.args, self.cluster)
        action.process_cluster()

        b1 = self.cluster.brokers[1]
        b2 = self.cluster.brokers[2]
        assert self.cluster.topics['testTopic1'].partitions[0].replicas == [
            b1, b2
        ]
        assert self.cluster.topics['testTopic1'].partitions[1].replicas == [
            b2, b1
        ]
        assert self.cluster.topics['testTopic2'].partitions[0].replicas == [
            b2, b1
        ]
        assert self.cluster.topics['testTopic2'].partitions[1].replicas == [
            b1, b2
        ]
コード例 #5
0
    def test_process_cluster(self):
        b1 = self.cluster.brokers[1]
        b2 = self.cluster.brokers[2]
        self.cluster.topics['testTopic1'].partitions[0].swap_replica_positions(
            b1, b2)

        action = ActionReorder(self.args, self.cluster)
        action.process_cluster()

        assert self.cluster.topics['testTopic1'].partitions[0].replicas == [
            b2, b1
        ]
        assert self.cluster.topics['testTopic1'].partitions[1].replicas == [
            b1, b2
        ]
        assert self.cluster.topics['testTopic2'].partitions[0].replicas == [
            b2, b1
        ]
        assert self.cluster.topics['testTopic2'].partitions[1].replicas == [
            b1, b2
        ]
コード例 #6
0
    def __init__(self, args, cluster):
        super(ActionBalanceLeader, self).__init__(args, cluster)

        # This module merely calls the main "reorder" module, so we're going to instantiate a copy of that
        self._reorder = ActionReorder(args, cluster)
コード例 #7
0
 def test_configure_args(self):
     ActionReorder.configure_args(self.subparsers)
     sys.argv = ['kafka-assigner', 'reorder']
     parsed_args = self.parser.parse_args()
     assert parsed_args.action == 'reorder'
コード例 #8
0
 def test_create_class(self):
     action = ActionReorder(self.args, self.cluster)
     assert isinstance(action, ActionReorder)
コード例 #9
0
ファイル: test_reorder.py プロジェクト: bingyuac/kafka-tools
 def test_configure_args(self):
     ActionReorder.configure_args(self.subparsers)
     sys.argv = ['kafka-assigner', 'reorder']
     parsed_args = self.parser.parse_args()
     assert parsed_args.action == 'reorder'