示例#1
0
    def register_rolling_restart(zk: BukuExhibitor, broker_id: str, image: str, instance_type: str, scalyr_key: str,
                                 scalyr_region: str, kms_key_id: str, cool_down: int):
        if zk.is_rolling_restart_in_progress():
            _LOG.warning('Rolling restart in progress, skipping')
            return

        restart_assignment = {}
        brokers = zk.get_broker_ids()
        for idx in range(len(brokers)):
            broker_to_make_restart = brokers[idx]
            if idx == len(brokers) - 1:
                broker_to_restart = brokers[0]
            else:
                broker_to_restart = brokers[idx + 1]
            restart_assignment[broker_to_make_restart] = broker_to_restart

        _LOG.info('Rolling restart assignment\n {}'.format(restart_assignment))
        action = {'name': 'rolling_restart',
                  'restart_assignment': restart_assignment,
                  'image': image,
                  'instance_type': instance_type,
                  'scalyr_key': scalyr_key,
                  'scalyr_region': scalyr_region,
                  'kms_key_id': kms_key_id,
                  'cool_down': cool_down}
        zk.register_action(action, broker_id=broker_id)
示例#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_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)
示例#4
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)
示例#5
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
         })
示例#6
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)
示例#7
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)
示例#8
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'})
示例#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_restart(zk: BukuExhibitor, broker_id: str):
     with zk.lock():
         zk.register_action(
             {'name': 'restart'},
             broker_id=broker_id)
示例#11
0
 def register_start(zk: BukuExhibitor, broker_id: str):
     zk.register_action({'name': 'start'}, broker_id=broker_id)
示例#12
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})