コード例 #1
0
    def register_migration(zk: BukuExhibitor, brokers_from: list, brokers_to: list, shrink: bool, broker_id: str,
                           throttle: int, parallelism: int):
        if len(brokers_from) != len(brokers_to):
            raise Exception('Brokers list {} and {} must have the same size'.format(brokers_from, brokers_to))
        if any(b in brokers_from for b in brokers_to) or any(b in brokers_to for b in brokers_from):
            raise Exception('Broker lists can not hold same broker ids')

        if len(set(brokers_from)) != len(brokers_from):
            raise Exception('Can not use same broker ids for source_list {}'.format(brokers_from))
        if len(set(brokers_to)) != len(brokers_to):
            raise Exception('Can not use same broker ids for source_list {}'.format(brokers_from))

        active_ids = zk.get_broker_ids()
        if any(b not in active_ids for b in brokers_from) or any(b not in active_ids for b in brokers_to):
            raise Exception('Brokers dead from: {} to: {} alive:{}'.format(brokers_from, brokers_to, active_ids))

        if broker_id and str(broker_id) not in active_ids:
            raise Exception('Broker id to run change on ({}) is not in active list {}'.format(
                broker_id, active_ids))
        if parallelism <= 0:
            raise Exception('Parallelism for migration should be greater than 0')

        with zk.lock():
            action = {'name': 'migrate', 'from': brokers_from, 'to': brokers_to, 'shrink': bool(shrink),
                      'parallelism': int(parallelism), 'throttle': int(throttle)}
            if broker_id:
                zk.register_action(action, str(broker_id))
            else:
                zk.register_action(action)
コード例 #2
0
    def register_migration(zk: BukuExhibitor, brokers_from: list, brokers_to: list, shrink: bool, broker_id: str,
                           parallelism: int):
        if len(brokers_from) != len(brokers_to):
            raise Exception('Brokers list {} and {} must have the same size'.format(brokers_from, brokers_to))
        if any(b in brokers_from for b in brokers_to) or any(b in brokers_to for b in brokers_from):
            raise Exception('Broker lists can not hold same broker ids')

        if len(set(brokers_from)) != len(brokers_from):
            raise Exception('Can not use same broker ids for source_list {}'.format(brokers_from))
        if len(set(brokers_to)) != len(brokers_to):
            raise Exception('Can not use same broker ids for source_list {}'.format(brokers_from))

        active_ids = zk.get_broker_ids()
        if any(b not in active_ids for b in brokers_from) or any(b not in active_ids for b in brokers_to):
            raise Exception('Brokers dead from: {} to: {} alive:{}'.format(brokers_from, brokers_to, active_ids))

        if broker_id and str(broker_id) not in active_ids:
            raise Exception('Broker id to run change on ({}) is not in active list {}'.format(
                broker_id, active_ids))
        if parallelism <= 0:
            raise Exception('Parallelism for migration should be greater than 0')

        with zk.lock():
            action = {'name': 'migrate', 'from': brokers_from, 'to': brokers_to, 'shrink': bool(shrink),
                      'parallelism': int(parallelism)}
            if broker_id:
                zk.register_action(action, str(broker_id))
            else:
                zk.register_action(action)
コード例 #3
0
 def register_rebalance(zk: BukuExhibitor, broker_id: str, empty_brokers: list, exclude_topics: list):
     action = {'name': 'rebalance',
               'empty_brokers': empty_brokers,
               'exclude_topics': exclude_topics}
     with zk.lock():
         if broker_id:
             zk.register_action(action, broker_id=broker_id)
         else:
             zk.register_action(action)
コード例 #4
0
 def register_fatboy_slim(zk: BukuExhibitor, threshold_kb: int):
     if zk.is_rebalancing():
         _LOG.warn(
             'Rebalance is already in progress, may be it will take time for this command to start processing'
         )
     with zk.lock():
         zk.register_action({
             'name': 'fatboyslim',
             'threshold_kb': threshold_kb
         })
コード例 #5
0
 def register_rebalance(zk: BukuExhibitor, broker_id: str, empty_brokers: list, exclude_topics: list,
                        parallelism: int, bin_packing: bool):
     if parallelism <= 0:
         raise Exception('Parallelism for rebalance should be greater than 0')
     action = {'name': 'rebalance',
               'empty_brokers': empty_brokers,
               'exclude_topics': exclude_topics,
               'parallelism': int(parallelism),
               'bin_packing': bool(bin_packing)}
     with zk.lock():
         if broker_id:
             zk.register_action(action, broker_id=broker_id)
         else:
             zk.register_action(action)
コード例 #6
0
 def register_rebalance(zk: BukuExhibitor, broker_id: str, empty_brokers: list, exclude_topics: list,
                        parallelism: int, bin_packing: bool, throttle: int):
     if parallelism <= 0:
         raise Exception('Parallelism for rebalance should be greater than 0')
     action = {'name': 'rebalance',
               'empty_brokers': empty_brokers,
               'exclude_topics': exclude_topics,
               'parallelism': int(parallelism),
               'bin_packing': bool(bin_packing),
               'throttle': int(throttle)}
     with zk.lock():
         if broker_id:
             zk.register_action(action, broker_id=broker_id)
         else:
             zk.register_action(action)
コード例 #7
0
 def register_rebalance(zk: BukuExhibitor, broker_id: str):
     with zk.lock():
         if broker_id:
             zk.register_action({'name': 'rebalance'}, broker_id=broker_id)
         else:
             zk.register_action({'name': 'rebalance'})
コード例 #8
0
 def register_restart(zk: BukuExhibitor, broker_id: str):
     with zk.lock():
         zk.register_action({'name': 'restart'}, broker_id=broker_id)
コード例 #9
0
 def register_restart(zk: BukuExhibitor, broker_id: str):
     with zk.lock():
         zk.register_action(
             {'name': 'restart'},
             broker_id=broker_id)
コード例 #10
0
 def register_fatboy_slim(zk: BukuExhibitor, threshold_kb: int):
     if zk.is_rebalancing():
         _LOG.warning('Rebalance is already in progress, may be it will take time for this command to start '
                      'processing')
     with zk.lock():
         zk.register_action({'name': 'fatboyslim', 'threshold_kb': threshold_kb})