I just have some python examples:
public class ExamplePythonBolt extends ShellBolt implements IRichBolt {
private static final long serialVersionUID = 1999209252187463355L;
private TopologyConfig topologyConfig;
public ExamplePythonBolt(TopologyConfig config) {
super("python", "ExampleBolt.py", config.topologyName);
topologyConfig = config;
}
public void prepare(Map stormConf, TopologyContext context,
OutputCollector collector) {
super.prepare(stormConf, context, collector);
}
public void declareOutputFields(OutputFieldsDeclarer declarer) {
declarer.declare(new Fields("LogRecord"));
}
public Map<String, Object> getComponentConfiguration() {
return null;
}
}
================================
#!/usr/bin/env python
#coding=utf-8
import storm
import traceback
import time
import sys
import os
import types
from common import *
import logconf
from MTLogger import MTLOGGER,MTFormatter
try:
import simplejson as json
except ImportError:
import json
json_encode = lambda x: json.dumps(x)
json_decode = lambda x: json.loads(x)
class ExampleBolt(storm.BasicBolt):
def __init__(self, boltParams):
#from here, you can get params from java
pass
def initialize(self, stormconf, context):
pass
def process(self, tup):
logjson = tup.values[0];
try:
#logRecord = json_decode(logjson)
MTLOGGER.info("TestAction", "handle the json %s" % (logjson))
storm.emit([logjson])
storm.rpcMetrics("PythonBoltCount", 1)
storm.rpcMetrics("PythonBoltMean", {"abc":1000})
storm.rpcMetrics("PythonBoltMean", {"def":(long)(10000.1)})
except Exception,tx:
MTLOGGER.error("TestAction","msg=log error, %s" %
traceback.format_exc().replace("\n"," ").replace("=","_"))
if __name__ == '__main__':
def checkargv():
n=0
for i in sys.argv:
n = n+1
if n != 2:
print "the params is not right"
sys.exit(1)
return sys.argv[1]
#get params from java
param = checkargv()
bolt = ExampleBolt(param)
bolt.run()
On Mon, Mar 10, 2014 at 5:04 PM, Mohit Srivastava <
[email protected]> wrote:
> Yeah looking into it.
> Is there any examples related to that ?
>
> --
> Mohit
>
>
> On Mon, Mar 10, 2014 at 1:36 PM, 鞠大升 <[email protected]> wrote:
>
> > you can use multilang with c++ bolt or spout.
> >
> >
> > On Mon, Mar 10, 2014 at 1:51 PM, Mohit Srivastava <
> > [email protected]> wrote:
> >
> > > Hi,
> > >
> > > I like to know that is there any way , I can write the C++ Bolt for
> > storm.
> > >
> > > Thanks
> > > --
> > > Mohit
> > >
> >
> >
> >
> > --
> > dashengju
> > +86 13810875910
> > [email protected]
> >
>
--
dashengju
+86 13810875910
[email protected]