public void init(String kafkaServers, String dbServers, boolean restart) throws Exception { logger.info("connecting to cassandra"); conn = new CassandraConn(); conn.connect(dbServers); logger.info("create TweetDao"); tweetDao = new TweetDao(conn); segDao = new SegStateDao(conn); logger.info("connecting to kafka"); consumer = new TweetConsumer(); consumer.open( Arrays.asList(KafkaTopics.RETWEET_TOPIC), KafkaTopics.RTSERIES_GROUP, kafkaServers, restart); producer = new TweetKafkaProducer(KafkaProducerFactory.createProducer(kafkaServers)); MetricBasedPerfProfile.registerServer(controller); }
/** * @param args * @throws Exception */ public static void main(String[] args) throws Exception { PropertyConfigurator.configure("conf/log4j.properties"); // args = new String[] { "-c", "127.0.0.1", "-k", "localhost:9092" }; OptionParser parser = new OptionParser(); parser.accepts("c", "cassandra server address").withRequiredArg().ofType(String.class); parser.accepts("k", "kafka server address").withRequiredArg().ofType(String.class); parser.accepts("r", "consume topics from the beginning"); parser .accepts("g", "server address of ganglia gmond. e.g 10.11.1.212:8649") .withRequiredArg() .ofType(String.class); OptionSet set = parser.parse(args); if (!set.hasOptions()) { parser.printHelpOn(new PrintStream(System.out)); System.exit(1); } String[] fields = set.valueOf("g").toString().split(":"); MetricBasedPerfProfile.reportForGanglia(fields[0], Short.parseShort(fields[1].trim())); TimeSeriesProducer producer = new TimeSeriesProducer(); producer.init(set.valueOf("k").toString(), set.valueOf("c").toString().trim(), set.has("r")); producer.start(); }