当前位置: 首页>>代码示例>>Python>>正文


Python storm.log函数代码示例

本文整理汇总了Python中storm.log函数的典型用法代码示例。如果您正苦于以下问题:Python log函数的具体用法?Python log怎么用?Python log使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了log函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: process

    def process(self, tup):
        message_buf = tup.values[0]
        message = json.loads(message_buf)

        message_id = message.get('message_id')
        if message_id == PUT_METRIC_DATA_MSG_ID:
            metric_key = str(self.get_metric_key(message))
            storm.emit([metric_key, message_buf])
        elif message_id == PUT_METRIC_ALARM_MSG_ID:
            metric_key = message.get('metric_key')
            storm.emit([metric_key, message_buf])
        elif message_id == DELETE_ALARMS_MSG_ID:
            project_id = message.get('project_id')
            alarmkeys = message.get('alarmkeys')
            for alarmkey in alarmkeys:
                try:
                    alarmkey_uuid = UUID(alarmkey)
                    metric_key = self.get_alarm_metric_key(alarmkey_uuid)
                    metric_key = str(metric_key)
                    if metric_key:
                        message['alarmkey'] = alarmkey
                        storm.emit([metric_key, json.dumps(message)])
                except Exception as e:
                    storm.log("Alarm %s does not exists" % alarmkey)
                    storm.log(traceback.format_exc(e))
        elif message_id == SET_ALARM_STATE_MSG_ID:
            project_id = message.get('project_id')
            alarm_name = message.get('alarm_name')
            alarm_key = self.cass.get_metric_alarm_key(project_id,
                                                       alarm_name)
            if alarm_key:
                alarm = self.cass.get_metric_alarm(alarm_key)
                metric_key = str(alarm.get('metric_key'))
                storm.emit([metric_key, json.dumps(message)])
开发者ID:eglynn,项目名称:synaps,代码行数:34,代码来源:unpack_bolt.py

示例2: nextTuple

 def nextTuple(self):
     try:
         input_tuple = None
         try:
             if self.counter >= self.script._num_iterations:
                 return
         except:
             try:
                 input_tuple = self.script._static_input.pop(0)
             except AttributeError:
                 # there is no static input
                 pass
             except IndexError:
                 # static input is empty - no more processing
                 return
         outputs = self.script.process(input_tuple)
         if outputs is None:
             return
         for streamname, output in outputs.iteritems():
             result = output if isinstance(output, list) else [output]
             storm.emit(result, stream=streamname, id=self.counter)
             storm.log("Dispel4Py ------> %s: emitted tuple %s to stream %s" % (self.script.id, result, streamname))
             self.counter += 1
     except:
         # logging the error but it should be passed to client somehow
         storm.log("Dispel4Py ------> %s: %s" % (self.scriptname, traceback.format_exc(), ))
开发者ID:akrause2014,项目名称:dispel4py,代码行数:26,代码来源:source_wrapper.py

示例3: process

 def process(self, tup):
     url = tup.values[0]
     storm.log("HARing "+url)
     output = self.get_har_with_image(url)
     if output is not "FAIL":
         storm.emit(output, anchors=[tup])
         storm.ack(tup)
开发者ID:ukwa,项目名称:wren,代码行数:7,代码来源:webrenderer.py

示例4: received_message

 def received_message(self, message):
     uid = str(message)
     if len(uid) and _server:
         log('[OutletWebSocket] Client connected: %s' % uid)
         index = _server.manager.websockets.values().index(self)
         _clients[uid] = _server.manager.websockets.keys()[index]
         emitBolt(['connect', uid], stream='control')
开发者ID:cutoffthetop,项目名称:recommender,代码行数:7,代码来源:outlet.py

示例5: process

 def process(self, tup):
     word = tup.values[0];
     if (random() < 0.75):
         storm.emit([word + 'lalala'], anchors=[tup])
         storm.ack(tup)
     else:
         storm.log(word + ' randomly skipped!')
开发者ID:ChongerJin,项目名称:storm,代码行数:7,代码来源:tester_bolt.py

示例6: process_set_alarm_state_msg

    def process_set_alarm_state_msg(self, metric_key, message):
        project_id = message.get('project_id')
        alarm_name = message.get('alarm_name')
        state_reason_data = message.get('state_reason_data')
                      
        if metric_key not in self.metrics:
            self.metrics[metric_key] = MetricMonitor(metric_key, self.cass)

        metric = self.metrics[metric_key]
        
        ret = self.cass.get_metric_alarm_key(project_id, alarm_name)
        if ret:
            alarm_key = ret
            try:
                metricalarm = metric.alarms[alarm_key]
            except KeyError:
                storm.log("alarm key [%s] is found, but alarm is not found." % alarm_key)
                return            
        else:
            storm.log("alarm key [%s] is not found." % alarm_key)
            return
        
        metricalarm['state_reason'] = message.get('state_reason')
        metricalarm['state_value'] = message.get('state_value')
        metricalarm['state_reason_data'] = message.get('state_reason_data')

        # write into database
        alarm_columns = {'state_reason':message.get('state_reason'),
                         'state_value':message.get('state_value')}
        if state_reason_data:
            alarm_columns['state_reason_data'] = state_reason_data
        
        self.cass.put_metric_alarm(alarm_key, alarm_columns)
开发者ID:OldBlackJoe,项目名称:synaps,代码行数:33,代码来源:synstorm_put_metric_bolt.py

示例7: emit

 def emit(self, record):
     from petrel import storm
     msg = self.format(record)
     for line in msg.split('\n'):
         formatted_line = self.format_string % line
         #print >> sys.stderr, "Calling storm.log with: %s" % formatted_line
         storm.log('%s' % formatted_line)
开发者ID:Cindy-Guo,项目名称:Petrel,代码行数:7,代码来源:run.py

示例8: initialize

 def initialize(self, conf, context):
     try:        
         self.counter = 0
         self.modname = conf["dispel4py.module"]
         self.scriptname = conf["dispel4py.script"]
         
         scriptconfig = pickle.loads(str(conf['dispel4py.config'])) if 'dispel4py.config' in conf else {}
         
         storm.log("Dispel4Py ------> loading script %s" % self.scriptname)
         mod = import_module(self.modname)
         self.script = getattr(mod, self.scriptname)()
         for key, value in scriptconfig.iteritems():
             storm.log("Dispel4Py ------> %s: setting attribute %s" % (self.scriptname, key))
             setattr(self.script, key, value)
         storm.log("Dispel4Py ------> loaded script %s" % self.scriptname)
             
         # attach an output writer to each output connection
         for outputname, output in self.script.outputconnections.iteritems():
             output['writer'] = OutputWriter(self.scriptname, outputname)
             
         # pre-processing if required
         self.script.preprocess()
         storm.log("Dispel4Py ------> %s: preprocess() completed." % (self.scriptname,))
     except:
         storm.log("Dispel4Py ------> %s: %s" % (self.scriptname, traceback.format_exc(),))
         raise
开发者ID:krischer,项目名称:dispel4py,代码行数:26,代码来源:source_wrapper.py

示例9: fail

 def fail(self, msg_id):
     tup, retries = self.buffer[msg_id]
     if retries >= 5:
         del self.buffer[msg_id]
         log('[RabbitMQSpout] Message %s failed for good.' % msg_id)
     else:
         self.buffer[msg_id] = (tup, retries + 1)
         emit(tup, id=msg_id)
开发者ID:cutoffthetop,项目名称:recommender,代码行数:8,代码来源:rabbitmq.py

示例10: fail

 def fail(self, cnt_id):
     tup, retries = self.buffer[cnt_id]
     if retries >= 5:
         del self.buffer[cnt_id]
         log('[ZonAPISpout] Message %s failed for good.' % cnt_id)
     else:
         self.buffer[cnt_id] = (tup, retries + 1)
         emit(tup, id=cnt_id)
开发者ID:cutoffthetop,项目名称:recommender,代码行数:8,代码来源:zonapi.py

示例11: nextTuple

 def nextTuple(self):
     if self.count < 2:
         word = choice(words)
         id = str(uuid4())
         self.pending[id] = word
         storm.rpcMetrics("my-custom-shellspout-metric", 1)
         self.count = self.count + 1
         storm.log("TesterSpout update my-custom-shellspout-metric "+str(self.count))
         storm.emit([word], id=id)
开发者ID:0110110101110111,项目名称:storm,代码行数:9,代码来源:tester_spout_metrics.py

示例12: stormLogger

def stormLogger(message):
    ''' 
    Logger implementation for Storm.
    '''
    try:
        storm.log(str(message))
    except:
        # just ignore the exception
        pass
开发者ID:Ravanon,项目名称:dispel4py,代码行数:9,代码来源:utils.py

示例13: log_tweeter_error

def log_tweeter_error(tweep_error, sleep_time=2):
    '''
    :param tweep_error: Exception dealing with twitter to log to the parent process
    :type api: tweepy.TweepError

    :param sleep_time: time in seconds to sleep before continuing the execution
    '''
    # We have hit the REST API Rate limit for Twitter https://dev.twitter.com/docs/rate-limiting/1.1, no more tweets for some time
    storm.log("Tweepy error {error}, sleeping for {secs} seconds in case Twitter rate limit has been hit".format(error=str(tweep_error), secs=sleep_time))
    time.sleep(sleep_time)
开发者ID:juanrh,项目名称:data42,代码行数:10,代码来源:twitter_components.py

示例14: process

 def process(self, tup):
     word = tup.values[0]
     if self.counts.has_key(word):
         count = self.counts[word]
     else:
         count = 0
     count += 1
     self.counts[word] = count
     storm.log(str(word)+" "+str(count))
     storm.emit([word, count])
开发者ID:charlielin,项目名称:wordcount,代码行数:10,代码来源:wordcount.py

示例15: write

 def write(self, output):
     result = output if isinstance(output, list) else [output]
     try:
         storm.emit(result, stream=self.streamname)
         storm.log("Dispel4Py ------> Emitted to stream %s." % (self.scriptname, self.streamname))
     except TypeError:
         # encode manually
         encoded = encode_types(result)
         storm.emit(encoded, stream=self.streamname)
         storm.log("Dispel4Py ------> Emitted to stream %s." % (self.scriptname, self.streamname))
开发者ID:Ravanon,项目名称:dispel4py,代码行数:10,代码来源:output_writer.py


注:本文中的storm.log函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。