use of org.apache.storm.topology.FailedException in project storm by apache.
the class SolrState method updateState.
public void updateState(List<TridentTuple> tuples) {
try {
SolrRequest solrRequest = solrMapper.toSolrRequest(tuples);
solrClient.request(solrRequest, solrMapper.getCollection());
solrClient.commit(solrMapper.getCollection());
} catch (Exception e) {
final String msg = String.format("%s", tuples);
logger.warn(msg);
throw new FailedException(msg, e);
}
}
use of org.apache.storm.topology.FailedException in project storm by apache.
the class MongoState method updateState.
/**
* Update Mongo state.
* @param tuples trident tuples
* @param collector trident collector
*/
public void updateState(List<TridentTuple> tuples, TridentCollector collector) {
List<Document> documents = Lists.newArrayList();
for (TridentTuple tuple : tuples) {
Document document = options.mapper.toDocument(tuple);
documents.add(document);
}
try {
this.mongoClient.insert(documents, true);
} catch (Exception e) {
LOG.warn("Batch write failed but some requests might have succeeded. Triggering replay.", e);
throw new FailedException(e);
}
}
use of org.apache.storm.topology.FailedException in project storm by apache.
the class MongoMapState method multiGet.
@Override
public List<T> multiGet(List<List<Object>> keysList) {
List<T> retval = new ArrayList<>();
try {
for (List<Object> keys : keysList) {
Bson filter = options.queryCreator.createFilterByKeys(keys);
Document doc = mongoClient.find(filter);
if (doc != null) {
retval.add(this.serializer.deserialize((byte[]) doc.get(options.serDocumentField)));
} else {
retval.add(null);
}
}
} catch (Exception e) {
LOG.warn("Batch get operation failed.", e);
throw new FailedException(e);
}
return retval;
}
use of org.apache.storm.topology.FailedException in project storm by apache.
the class HiveState method commit.
@Override
public void commit(Long txId) {
try {
flushAllWriters();
currentBatchSize = 0;
} catch (HiveWriter.TxnFailure | InterruptedException | HiveWriter.CommitFailure | HiveWriter.TxnBatchFailure ex) {
LOG.warn("Commit failed. Failing the batch.", ex);
throw new FailedException(ex);
}
}
use of org.apache.storm.topology.FailedException in project storm by apache.
the class JdbcState method batchRetrieve.
public List<List<Values>> batchRetrieve(List<TridentTuple> tridentTuples) {
List<List<Values>> batchRetrieveResult = Lists.newArrayList();
try {
for (TridentTuple tuple : tridentTuples) {
List<Column> columns = options.jdbcLookupMapper.getColumns(tuple);
List<List<Column>> rows = jdbcClient.select(options.selectQuery, columns);
for (List<Column> row : rows) {
List<Values> values = options.jdbcLookupMapper.toTuple(tuple, row);
batchRetrieveResult.add(values);
}
}
} catch (Exception e) {
LOG.warn("Batch get operation failed. Triggering replay.", e);
throw new FailedException(e);
}
return batchRetrieveResult;
}
Aggregations