Search in sources :

Example 1 with DefaultTupleMapper

use of com.hmsonline.storm.contrib.bolt.elasticsearch.mapper.DefaultTupleMapper in project storm-elastic-search by hmsonline.

the class ElasticSearchTest method testBolt.

@Test
public void testBolt() {
    TopologyBuilder builder = new TopologyBuilder();
    ElasticSearchBolt bolt = new ElasticSearchBolt(new DefaultTupleMapper());
    builder.setBolt("TEST_BOLT", bolt);
    TopologyContext context = new MockTopologyContext(builder.createTopology());
    Config config = new Config();
    config.put(ElasticSearchBolt.ELASTIC_LOCAL_MODE, true);
    bolt.prepare(config, context, null);
    List<Object> values = new ArrayList<Object>();
    values.add("testIndex");
    values.add("entity");
    values.add("testId");
    values.add("{\"bolt\":\"lightning\"}");
    Tuple tuple = new TupleImpl(context, values, 5, "test");
    bolt.execute(tuple);
}
Also used : DefaultTupleMapper(com.hmsonline.storm.contrib.bolt.elasticsearch.mapper.DefaultTupleMapper) TopologyBuilder(backtype.storm.topology.TopologyBuilder) Config(backtype.storm.Config) ArrayList(java.util.ArrayList) TopologyContext(backtype.storm.task.TopologyContext) TupleImpl(backtype.storm.tuple.TupleImpl) Tuple(backtype.storm.tuple.Tuple) Test(org.junit.Test)

Aggregations

Config (backtype.storm.Config)1 TopologyContext (backtype.storm.task.TopologyContext)1 TopologyBuilder (backtype.storm.topology.TopologyBuilder)1 Tuple (backtype.storm.tuple.Tuple)1 TupleImpl (backtype.storm.tuple.TupleImpl)1 DefaultTupleMapper (com.hmsonline.storm.contrib.bolt.elasticsearch.mapper.DefaultTupleMapper)1 ArrayList (java.util.ArrayList)1 Test (org.junit.Test)1