org.apache.storm.cassandra.bolt

## Class BatchCassandraWriterBolt

- java.lang.Object
- - org.apache.storm.topology.base.BaseComponent
  - - org.apache.storm.topology.base.BaseRichBolt
    - - org.apache.storm.topology.base.BaseTickTupleAwareRichBolt
      - - org.apache.storm.cassandra.bolt.BaseCassandraBolt<List<Tuple>>
        - - org.apache.storm.cassandra.bolt.BatchCassandraWriterBolt

- All Implemented Interfaces:
    Serializable, IBolt, IComponent, IRichBolt

      public class BatchCassandraWriterBolt
      extends BaseCassandraBolt<List<Tuple>>

  See Also:
    Serialized Form

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static int` | `DEFAULT_EMIT_FREQUENCY`

    - ### Fields inherited from class org.apache.storm.cassandra.bolt.BaseCassandraBolt

      `cassandraConf, client, clientProvider, outputCollector, session, topoConfig`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `BatchCassandraWriterBolt(CQLStatementTupleMapper tupleMapper)` Creates a new `CassandraWriterBolt` instance.
    `BatchCassandraWriterBolt(CQLStatementTupleMapper tupleMapper, int tickFrequencyInSeconds)` Creates a new `CassandraWriterBolt` instance.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected AsyncResultHandler<List<Tuple>>` | `getAsyncHandler()`
    `Map<String,Object>` | `getComponentConfiguration()` Declare configuration specific to this component.
    `protected void` | `onTickTuple(Tuple tuple)` Process a single tick tuple of input.
    `void` | `prepare(Map<String,Object> topoConfig, TopologyContext topologyContext, OutputCollector outputCollector)` Called when a task for this component is initialized within a worker on the cluster.
    `void` | `prepareAndExecuteStatement()`
    `protected void` | `process(Tuple input)` Process a single non-tick tuple of input.
    `BatchCassandraWriterBolt` | `withQueueSize(int size)` Maximum number of tuple kept in memory before inserting batches to cassandra.
    `BatchCassandraWriterBolt` | `withTickFrequency(long time, TimeUnit unit)`

    - ### Methods inherited from class org.apache.storm.cassandra.bolt.BaseCassandraBolt

      `cleanup, declareOutputFields, execute, getAsyncExecutor, getMapper, getResultHandler, withCassandraConfig, withOutputFields, withResultHandler, withStreamOutputFields`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### DEFAULT_EMIT_FREQUENCY

          public static final int DEFAULT_EMIT_FREQUENCY

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### BatchCassandraWriterBolt

          public BatchCassandraWriterBolt(CQLStatementTupleMapper tupleMapper)

      Creates a new `CassandraWriterBolt` instance.

    - #### BatchCassandraWriterBolt

          public BatchCassandraWriterBolt(CQLStatementTupleMapper tupleMapper,
                                          int tickFrequencyInSeconds)

      Creates a new `CassandraWriterBolt` instance.

  - ### Method Detail

    - #### prepare

          public void prepare(Map<String,Object> topoConfig,
                              TopologyContext topologyContext,
                              OutputCollector outputCollector)

      Called when a task for this component is initialized within a worker on the cluster. It provides the bolt with the environment in which the bolt executes.

      This includes the:

      Specified by:
        `prepare` in interface `IBolt`
      Overrides:
        `prepare` in class `BaseCassandraBolt<List<Tuple>>`
      Parameters:
        `topoConfig` - The Storm configuration for this bolt. This is the configuration provided to the topology merged in with cluster configuration on this machine.
        `topologyContext` - This object can be used to get information about this task’s place within the topology, including the task id and component id of this task, input and output information, etc.
        `outputCollector` - The collector is used to emit tuples from this bolt. Tuples can be emitted at any time, including the prepare and cleanup methods. The collector is thread-safe and should be saved as an instance variable of this bolt object.

    - #### getAsyncHandler

          protected AsyncResultHandler<List<Tuple>> getAsyncHandler()

      Specified by:
        `getAsyncHandler` in class `BaseCassandraBolt<List<Tuple>>`

    - #### process

          protected void process(Tuple input)

      Process a single non-tick tuple of input. Implementation needs to handle ack manually. More details on `IBolt.execute(Tuple)`.

      Specified by:
        `process` in class `BaseTickTupleAwareRichBolt`
      Parameters:
        `input` - The input tuple to be processed.

    - #### onTickTuple

          protected void onTickTuple(Tuple tuple)

      Process a single tick tuple of input. Tick tuple doesn’t need to be acked. It provides default “DO NOTHING” implementation for convenient. Override this method if needed.

      More details on `IBolt.execute(Tuple)`.

      Overrides:
        `onTickTuple` in class `BaseTickTupleAwareRichBolt`
      Parameters:
        `tuple` - The input tuple to be processed.

    - #### prepareAndExecuteStatement

          public void prepareAndExecuteStatement()

    - #### withTickFrequency

          public BatchCassandraWriterBolt withTickFrequency(long time,
                                                            TimeUnit unit)

    - #### withQueueSize

          public BatchCassandraWriterBolt withQueueSize(int size)

      Maximum number of tuple kept in memory before inserting batches to cassandra.

      Parameters:
        `size` - the max queue size.
      Returns:
        `this`

    - #### getComponentConfiguration

          public Map<String,Object> getComponentConfiguration()

      Declare configuration specific to this component. Only a subset of the “topology.*” configs can be overridden. The component configuration can be further overridden when constructing the topology using `TopologyBuilder`

      Specified by:
        `getComponentConfiguration` in interface `IComponent`
      Overrides:
        `getComponentConfiguration` in class `BaseCassandraBolt<List<Tuple>>`

Copyright © 2019 The Apache Software Foundation. All rights reserved.