twitter4j - Twitter data streaming - dynamic keyword value change -


i have doing sentiment analysis on twitter data in hadoop.

i have configured flume bring data based upon keywords, have maintained in "flume.conf" file, shown below

twitteragent.sources.twitter.keywords = kitkat, nescafe, carnation, milo, cerelac 

with mentioning this, know whether possible dynamically change keywords, based upon java program pop-up asking keywords user.

also, apart method, please provide other methods folks suggest hide complexity of updating flume.conf file.

best regards, ram

flume provides application class run configuration file using java program.

public class flume{ public static void main(string[] args) throws exception { new conf().setconfiguration();   string[] args1 = new string[] { "agent","-ntwitteragent",   "-fflume.conf" }; basicconfigurator.configure(); application.main(args1); system.setproperty("hadoop.home.dir", "/");  } } 

here change edit conf file using file utils this

class conf{ int ch; string keyword =""; scanner sc= new scanner(system.in); public void setconfiguration(){     system.out.println("enter keyword");     keyword=sc.nextline();     byte[] key= keyword.getbytes();      fileoutputstream fp=null;     fileinputstream src=null;      try{         fp= new fileoutputstream("flumee.conf");         src= new fileinputstream("flume.conf");         while((ch=src.read())!=-1){             fp.write((char)ch);         }          fp.write(key);      }catch(exception e){         system.out.println("file exception:"+ e);     }finally{         try{             if(fp!=null){                 fp.close();             }             if(src!=null){                 src.close();             }         }catch(exception e){             system.out.println("file closing exception:"+ e);         }     } } } 

now need keep twitteragent.sources.twitter.keywords= line @ end of flume configuration file easier add keywords file. flume.conf file looks this

 twitteragent.sources= twitter  twitteragent.channels= memchannel  twitteragent.sinks=hdfs  twitteragent.sources.twitter.type = com.cloudera.flume.source.twittersource  twitteragent.sources.twitter.channels=memchannel   twitteragent.sources.twitter.consumerkey=xxx  twitteragent.sources.twitter.consumersecret=xxx  twitteragent.sources.twitter.accesstoken=xxx  twitteragent.sources.twitter.accesstokensecret=   twitteragent.sinks.hdfs.channel=memchannel  twitteragent.sinks.hdfs.type=hdfs  twitteragent.sinks.hdfs.hdfs.path=hdfs://localhost:9000/user/flume/direct  twitteragent.sinks.hdfs.hdfs.filetype=datastream  twitteragent.sinks.hdfs.hdfs.writeformat=text  twitteragent.sinks.hdfs.hdfs.batchsize=1000  twitteragent.sinks.hdfs.hdfs.rollsize=0  twitteragent.sinks.hdfs.hdfs.rollcount=10000  twitteragent.sinks.hdfs.hdfs.rollinterval=600  twitteragent.channels.memchannel.type=memory  twitteragent.channels.memchannel.capacity=10000  twitteragent.channels.memchannel.transactioncapacity=1000   twitteragent.sources.twitter.keywords= 

when run program ask keywords first , start collecting tweets keyword.


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -