def __init__(self, source_id, payload, payload_type='json'): Message.__init__( self, target=mesos_messages.MESOS_REGISTER_FRAMEWORK_MESSAGE, source_id=source_id, payload=payload, payload_type=payload_type)
def __init__(self, source_id, payload, payload_type='json'): Message.__init__( self, target=mesos_messages.MESOS_EXECUTOR_REGISTERED_MESSAGE, source_id=source_id, payload=payload, payload_type=payload_type)
def __init__(self, source_id, payload, payload_type='json'): Message.__init__( self, target=mesos_messages.MESOS_RESCIND_RESOURCE_OFFER_MESSAGE, source_id=source_id, payload=payload, payload_type=payload_type)
def __init__(self, source_id, payload, payload_type='json'): Message.__init__( self, target=mesos_messages.MESOS_STATUS_UPDATE_ACKNOWLEDGEMENT_MESSAGE, source_id=source_id, payload=payload, payload_type=payload_type)
def handle(self, message): try: # Convert message from json. request = Message.from_json(message[1]) response = None # Check target. self.logger.trace('Got request: %s' % request) target = request.get('target') if target is None: self.logger.error('Wrong target: %s in request: %s' % (target, request)) # Assign message id. request['message_id'] = str(uuid.uuid1()) # Preprocess request. try: target_preprocessor = self.get_target_preprocessor(target) if target_preprocessor is not None: self.logger.debug( 'Preprocessing target %s using preprocessor %s' % (target, target_preprocessor)) target_preprocessor(request) except URBException, ex: self.logger.error(ex) except Exception, ex: errMsg = 'Cannot preprocess target %s: %s' % (target, ex) self.logger.error(errMsg) self.logger.exception(ex)
def manage(self): """ Managment thread. """ self.logger.debug('Entering retry channel management loop') while True: if not self.__manage: break self.__thread_event.clear() (name, message_list) = self.retry_channel.read_timestamp_range() self.logger.debug('Message list: %s', message_list) for message_string in message_list: try: message = Message.from_json(message_string) retry_count = message.get('retry_count', 0) self.logger.debug('Retry count is %s for message %s' % (retry_count, message)) if retry_count > self.max_retry_count: self.logger.warn( 'Max. retry count exceded for message %s' % message) continue self.channel.write(message.to_json()) except Exception, ex: self.logger.error( 'Error writing message (%s) to channel %s: %s' % (message_string, self.channel.name, ex)) # Must allow other greenlets to run. gevent.sleep(RetryManager.GREENLET_SLEEP_PERIOD_IN_SECONDS) # Monitoring thread sleep self.__thread_event.wait( RetryManager.MANAGER_SLEEP_PERIOD_IN_SECONDS)
def __init__(self, source_id, payload, payload_type='json'): Message.__init__(self, target=mesos_messages.MESOS_LAUNCH_TASKS_MESSAGE, source_id=source_id, payload=payload, payload_type=payload_type)
'Preprocessing target %s using preprocessor %s' % (target, target_preprocessor)) target_preprocessor(request) except URBException, ex: self.logger.error(ex) except Exception, ex: errMsg = 'Cannot preprocess target %s: %s' % (target, ex) self.logger.error(errMsg) self.logger.exception(ex) # Process request. target_executor = self.get_target_executor(target) if target_executor is None: errMsg = 'Unsupported target: %s' % target self.logger.error(errMsg) response = Message(payload=InvalidCommand(errMsg).to_dict()) else: try: self.logger.debug('Processing request with: %s' % target_executor) _, response = target_executor(request) # target_executor(request) self.logger.trace('Response message: %s' % response) except URBException, ex: response = Message(payload=ex.to_dict()) self.logger.error(ex) except Exception, ex: response = Message(payload={'error': '%s' % ex}) errMsg = 'Cannot handle message: %s' % ex self.logger.error(errMsg) self.logger.exception(ex)
def __init__(self, source_id, payload, payload_type='json'): Message.__init__(self, target=internal_messages.SLAVE_SHUTDOWN_MESSAGE, source_id=source_id, payload=payload, payload_type=payload_type)
def ping(self, request=None): self.logger.debug("ping: request=%s" % request) timestamp = time.strftime('%Y/%m/%d %H:%M:%S') payload = { 'ack' : 'URB Service is alive @ %s' % timestamp } return None, Message(payload=payload)
def ping(self, request=None): timestamp = time.strftime('%Y/%m/%d %H:%M:%S') payload = { 'ack' : 'URB Service is alive @ %s' % timestamp } return Message(payload=payload)
def __init__(self, source_id, payload, payload_type='json'): Message.__init__(self, target=internal_messages.HEARTBEAT_MESSAGE, source_id=source_id, payload=payload, payload_type=payload_type)
def __init__(self, source_id, payload, payload_type='json'): Message.__init__(self, target=internal_messages.SERVICE_DISCONNECTED_MESSAGE, source_id=source_id, payload=payload, payload_type=payload_type)