Beispiel #1
0
    def on_message(self, headers, message):
        '''
        on_message
        '''
        record_counter('daemons.cache.consumer2.message')
        try:
            msg = json.loads(message)
            if isinstance(msg, dict) and 'operation' in msg.keys():
                for f in msg['files']:
                    f['scope'] = InternalScope(f['scope'])
                if 'rse_id' in msg:
                    rse_id = msg['rse_id']
                else:
                    rse_id = get_rse_id(rse=msg['rse'],
                                        vo=msg.get('vo', 'def'))

                rse_vo_str = msg['rse']
                if 'vo' in msg and msg['vo'] != 'def':
                    rse_vo_str = '{} on {}'.format(rse_vo_str, msg['vo'])
                if msg['operation'] == 'add_replicas':
                    logging.info('add_replicas to RSE %s: %s ' %
                                 (rse_vo_str, str(msg['files'])))
                    add_volatile_replicas(rse_id=rse_id, replicas=msg['files'])
                elif msg['operation'] == 'delete_replicas':
                    logging.info('delete_replicas to RSE %s: %s ' %
                                 (rse_vo_str, str(msg['files'])))
                    delete_volatile_replicas(rse_id=rse_id,
                                             replicas=msg['files'])
        except:
            logging.error(str(format_exc()))
Beispiel #2
0
    def on_message(self, headers, message):
        record_counter('daemons.cache.consumer2.message')
#        id = msg['id']
#        if id % self.__num_thread == self.__id:
#            self.message_handle(msg['payload'])
        try:
            msg = json.loads(message)
            if isinstance(msg, dict) and 'operation' in msg.keys():
                if msg['operation'] == 'add_replicas':
                    logging.info('add_replicas to RSE %s: %s ' % (msg['rse'], str(msg['files'])))
                    add_volatile_replicas(rse=msg['rse'], replicas=msg['files'])
                elif msg['operation'] == 'delete_replicas':
                    logging.info('delete_replicas to RSE %s: %s ' % (msg['rse'], str(msg['files'])))
                    delete_volatile_replicas(rse=msg['rse'], replicas=msg['files'])
        except:
            logging.error(str(format_exc()))
Beispiel #3
0
    def on_message(self, frame):
        """
        on_message
        """
        record_counter('daemons.cache.consumer2.message')
        try:
            msg = json.loads(frame.body)
            self.__logger(logging.DEBUG, 'Message received: %s ' % msg)
            if isinstance(msg, dict) and 'operation' in msg.keys():
                for f in msg['files']:
                    f['scope'] = InternalScope(f['scope'])
                if 'rse_id' in msg:
                    rse_id = msg['rse_id']
                else:
                    rse_id = get_rse_id(rse=msg['rse'],
                                        vo=msg.get('vo', 'def'))

                rse_vo_str = msg['rse']
                if 'vo' in msg and msg['vo'] != 'def':
                    rse_vo_str = '{} on {}'.format(rse_vo_str, msg['vo'])
                if msg['operation'] == 'add_replicas':
                    self.__logger(
                        logging.INFO, 'add_replicas to RSE %s: %s ' %
                        (rse_vo_str, str(msg['files'])))
                    add_volatile_replicas(rse_id=rse_id, replicas=msg['files'])
                elif msg['operation'] == 'delete_replicas':
                    self.__logger(
                        logging.INFO, 'delete_replicas to RSE %s: %s ' %
                        (rse_vo_str, str(msg['files'])))
                    delete_volatile_replicas(rse_id=rse_id,
                                             replicas=msg['files'])
            else:
                self.__logger(
                    logging.DEBUG, 'Check failed: %s %s ' %
                    (isinstance(msg, dict), 'operation' in msg.keys()))
        except:
            self.__logger(logging.ERROR, str(format_exc()))
Beispiel #4
0
    def on_message(self, headers, message):
        '''
        on_message
        '''
        record_counter('daemons.cache.consumer2.message')
        try:
            msg = json.loads(message)
            if isinstance(msg, dict) and 'operation' in msg.keys():
                if 'rse_id' in msg:
                    rse_id = msg['rse_id']
                else:
                    rse_id = get_rse_id(rse=msg['rse'])

                if msg['operation'] == 'add_replicas':
                    logging.info('add_replicas to RSE %s: %s ' %
                                 (msg['rse'], str(msg['files'])))
                    add_volatile_replicas(rse_id=rse_id, replicas=msg['files'])
                elif msg['operation'] == 'delete_replicas':
                    logging.info('delete_replicas to RSE %s: %s ' %
                                 (msg['rse'], str(msg['files'])))
                    delete_volatile_replicas(rse_id=rse_id,
                                             replicas=msg['files'])
        except:
            logging.error(str(format_exc()))