Esempio n. 1
0
 def _remove_key_from_group(self, key, group_id):
     """
     Creates task for gatling gun on destination group,
     updates key in meta database
     """
     if not self.dryrun:
         cache_task_manager.put_task(
             self._gatlinggun_task(key, group_id, [], 'remove'))
     key['cache_groups'].remove(group_id)
     if len(key['cache_groups']):
         self.keys_db.update({'id': key['id'], 'couple': key['couple']}, key)
     else:
         self.keys_db.remove({'id': key['id'], 'couple': key['couple']})
Esempio n. 2
0
 def _add_key_to_group(self, key, group_id, data_groups, tx_rate, size):
     """
     Creates task for gatling gun on destination group,
     updates key in meta database
     """
     task = self._gatlinggun_task(key, group_id, data_groups, 'add',
                                  tx_rate=tx_rate, size=size)
     if not self.dryrun:
         cache_task_manager.put_task(task)
         logger.debug('Key {}, task for gatlinggun created for cache '
                      'group {}'.format(key['id'], group_id))
     key['cache_groups'].append(group_id)
     key['expand_ts'] = int(time.time())
     self.keys_db.update({'id': key['id'], 'couple': key['couple']},
                         key, upsert=True)
     return task