use of org.apache.storm.elasticsearch.common.EsConfig in project storm by apache.
the class TridentEsTopology method main.
public static void main(String[] args) throws Exception {
int batchSize = 100;
FixedBatchSpout spout = new FixedBatchSpout(batchSize);
spout.setCycle(true);
TridentTopology topology = new TridentTopology();
Stream stream = topology.newStream("spout", spout);
EsConfig esConfig = new EsConfig(EsConstants.clusterName, new String[] { "localhost:9300" });
Fields esFields = new Fields("index", "type", "source");
EsTupleMapper tupleMapper = EsTestUtil.generateDefaultTupleMapper();
StateFactory factory = new EsStateFactory(esConfig, tupleMapper);
TridentState state = stream.partitionPersist(factory, esFields, new EsUpdater(), new Fields());
EsTestUtil.startEsNode();
EsTestUtil.waitForSeconds(5);
try (LocalCluster cluster = new LocalCluster();
LocalTopology topo = cluster.submitTopology(TOPOLOGY_NAME, null, topology.build())) {
EsTestUtil.waitForSeconds(20);
}
System.exit(0);
}
use of org.apache.storm.elasticsearch.common.EsConfig in project storm by apache.
the class EsIndexTopology method main.
public static void main(String[] args) throws Exception {
Config config = new Config();
config.setNumWorkers(1);
TopologyBuilder builder = new TopologyBuilder();
UserDataSpout spout = new UserDataSpout();
builder.setSpout(SPOUT_ID, spout, 1);
EsTupleMapper tupleMapper = EsTestUtil.generateDefaultTupleMapper();
EsConfig esConfig = new EsConfig(EsConstants.clusterName, new String[] { "localhost:9300" });
builder.setBolt(BOLT_ID, new EsIndexBolt(esConfig, tupleMapper), 1).shuffleGrouping(SPOUT_ID);
EsTestUtil.startEsNode();
EsTestUtil.waitForSeconds(5);
try (LocalCluster cluster = new LocalCluster();
LocalTopology topo = cluster.submitTopology(TOPOLOGY_NAME, config, builder.createTopology())) {
EsTestUtil.waitForSeconds(20);
}
System.exit(0);
}
Aggregations