public class BatchCassandraWriterBolt extends BaseCassandraBolt<List<Tuple>>
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_EMIT_FREQUENCY |
cassandraConf, client, clientProvider, outputCollector, session, topoConfig
Constructor and Description |
---|
BatchCassandraWriterBolt(CQLStatementTupleMapper tupleMapper)
Creates a new
CassandraWriterBolt instance. |
BatchCassandraWriterBolt(CQLStatementTupleMapper tupleMapper,
int tickFrequencyInSeconds)
Creates a new
CassandraWriterBolt instance. |
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) |
cleanup, declareOutputFields, execute, getAsyncExecutor, getMapper, getResultHandler, withCassandraConfig, withOutputFields, withResultHandler, withStreamOutputFields
public static final int DEFAULT_EMIT_FREQUENCY
public BatchCassandraWriterBolt(CQLStatementTupleMapper tupleMapper)
Creates a new CassandraWriterBolt
instance.
public BatchCassandraWriterBolt(CQLStatementTupleMapper tupleMapper, int tickFrequencyInSeconds)
Creates a new CassandraWriterBolt
instance.
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:
prepare
in interface IBolt
prepare
in class BaseCassandraBolt<List<Tuple>>
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.protected AsyncResultHandler<List<Tuple>> getAsyncHandler()
getAsyncHandler
in class BaseCassandraBolt<List<Tuple>>
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)
.
process
in class BaseTickTupleAwareRichBolt
input
- The input tuple to be processed.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)
.
onTickTuple
in class BaseTickTupleAwareRichBolt
tuple
- The input tuple to be processed.public void prepareAndExecuteStatement()
public BatchCassandraWriterBolt withTickFrequency(long time, TimeUnit unit)
public BatchCassandraWriterBolt withQueueSize(int size)
Maximum number of tuple kept in memory before inserting batches to cassandra.
size
- the max queue size.this
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
getComponentConfiguration
in interface IComponent
getComponentConfiguration
in class BaseCassandraBolt<List<Tuple>>
Copyright © 2019 The Apache Software Foundation. All rights reserved.