@SuppressWarnings({ "unchecked", "rawtypes" })
public void update(List<TridentTuple> tuples, TridentCollector collector, TridentTupleMapper mapper) {
LOG.debug("updating with {} tuples", tuples.size());
try {
if (this.maxBatchSize > 0) {
int size = tuples.size();
int batchCount = size / this.maxBatchSize;
int count = 0;
for (int i = 0; i < batchCount; i++) {
this.client.writeTuples(tuples.subList(i * this.maxBatchSize, (i + 1) * this.maxBatchSize), mapper);
count++;
}
this.client.writeTuples(tuples.subList(count * this.maxBatchSize, size), mapper);
for (TridentTuple tuple : tuples) {
collector.emit(tuple.getValues());
}
} else {
this.client.writeTuples(tuples, mapper);
}
} catch (Exception e) {
if (this.exceptionHandler != null) {
this.exceptionHandler.onException(e, collector);
} else {
LOG.warn("Batch write failed. Triggering replay.", e);
throw new FailedException(e);
}
}
}