use of org.apache.storm.LocalCluster in project storm by apache.
the class AbstractUserTopology method execute.
public void execute(String[] args) throws Exception {
if (args.length != 4 && args.length != 5) {
System.out.println("Usage: " + this.getClass().getSimpleName() + " <dataSourceClassName> <dataSource.url> " + "<user> <password> [topology name]");
System.exit(-1);
}
Map map = Maps.newHashMap();
//com.mysql.jdbc.jdbc2.optional.MysqlDataSource
map.put("dataSourceClassName", args[0]);
//jdbc:mysql://localhost/test
map.put("dataSource.url", args[1]);
//root
map.put("dataSource.user", args[2]);
if (args.length == 4) {
//password
map.put("dataSource.password", args[3]);
}
Config config = new Config();
config.put(JDBC_CONF, map);
ConnectionProvider connectionProvider = new HikariCPConnectionProvider(map);
connectionProvider.prepare();
int queryTimeoutSecs = 60;
JdbcClient jdbcClient = new JdbcClient(connectionProvider, queryTimeoutSecs);
for (String sql : setupSqls) {
jdbcClient.executeSql(sql);
}
this.userSpout = new UserSpout();
this.jdbcMapper = new SimpleJdbcMapper(TABLE_NAME, connectionProvider);
connectionProvider.cleanup();
Fields outputFields = new Fields("user_id", "user_name", "dept_name", "create_date");
List<Column> queryParamColumns = Lists.newArrayList(new Column("user_id", Types.INTEGER));
this.jdbcLookupMapper = new SimpleJdbcLookupMapper(outputFields, queryParamColumns);
this.connectionProvider = new HikariCPConnectionProvider(map);
if (args.length == 4) {
try (LocalCluster cluster = new LocalCluster();
LocalTopology topo = cluster.submitTopology("test", config, getTopology())) {
Thread.sleep(30000);
}
System.exit(0);
} else {
StormSubmitter.submitTopology(args[4], config, getTopology());
}
}
use of org.apache.storm.LocalCluster in project storm by apache.
the class WordCountTridentRedisClusterMap method main.
public static void main(String[] args) throws Exception {
if (args.length != 2) {
System.out.println("Usage: WordCountTrident 0(storm-local)|1(storm-cluster) 127.0.0.1:6379,127.0.0.1:6380");
System.exit(1);
}
Integer flag = Integer.valueOf(args[0]);
String redisHostPort = args[1];
Config conf = new Config();
conf.setMaxSpoutPending(5);
if (flag == 0) {
try (LocalCluster cluster = new LocalCluster();
LocalTopology topo = cluster.submitTopology("test_wordCounter_for_redis", conf, buildTopology(redisHostPort))) {
Thread.sleep(60 * 1000);
}
System.exit(0);
} else if (flag == 1) {
conf.setNumWorkers(3);
StormSubmitter.submitTopology("test_wordCounter_for_redis", conf, buildTopology(redisHostPort));
} else {
System.out.println("Usage: WordCountTrident 0(storm-local)|1(storm-cluster) redis-host redis-port");
}
}
use of org.apache.storm.LocalCluster in project storm by apache.
the class SolrTopology method submitTopologyLocalCluster.
protected void submitTopologyLocalCluster(StormTopology topology, Config config) throws Exception {
try (LocalCluster cluster = new LocalCluster();
LocalTopology topo = cluster.submitTopology("test", config, topology)) {
Thread.sleep(10000);
System.out.println("Killing topology per client's request");
}
System.exit(0);
}
use of org.apache.storm.LocalCluster in project storm by apache.
the class InsertWordCount method main.
public static void main(String[] args) throws Exception {
Config config = new Config();
String url = TEST_MONGODB_URL;
String collectionName = TEST_MONGODB_COLLECTION_NAME;
if (args.length >= 2) {
url = args[0];
collectionName = args[1];
}
WordSpout spout = new WordSpout();
WordCounter bolt = new WordCounter();
MongoMapper mapper = new SimpleMongoMapper().withFields("word", "count");
MongoInsertBolt insertBolt = new MongoInsertBolt(url, collectionName, mapper);
// wordSpout ==> countBolt ==> MongoInsertBolt
TopologyBuilder builder = new TopologyBuilder();
builder.setSpout(WORD_SPOUT, spout, 1);
builder.setBolt(COUNT_BOLT, bolt, 1).shuffleGrouping(WORD_SPOUT);
builder.setBolt(INSERT_BOLT, insertBolt, 1).fieldsGrouping(COUNT_BOLT, new Fields("word"));
if (args.length == 2) {
try (LocalCluster cluster = new LocalCluster();
LocalTopology topo = cluster.submitTopology("test", config, builder.createTopology())) {
Thread.sleep(30000);
}
System.exit(0);
} else if (args.length == 3) {
StormSubmitter.submitTopology(args[2], config, builder.createTopology());
} else {
System.out.println("Usage: InsertWordCount <mongodb url> <mongodb collection> [topology name]");
}
}
use of org.apache.storm.LocalCluster in project storm by apache.
the class WordCountTrident method main.
public static void main(String[] args) throws Exception {
Config conf = new Config();
conf.setMaxSpoutPending(5);
if (args.length == 2) {
try (LocalCluster cluster = new LocalCluster();
LocalTopology topo = cluster.submitTopology("wordCounter", conf, buildTopology(args[0], args[1]))) {
Thread.sleep(60 * 1000);
}
System.exit(0);
} else if (args.length == 3) {
conf.setNumWorkers(3);
StormSubmitter.submitTopology(args[2], conf, buildTopology(args[0], args[1]));
} else {
System.out.println("Usage: WordCountTrident <mongodb url> <mongodb collection> [topology name]");
}
}
Aggregations