use of org.apache.cassandra.exceptions.CassandraException in project cassandra by apache.
the class TriggerExecutor method executeInternal.
/**
* Switch class loader before using the triggers for the column family, if
* not loaded them with the custom class loader.
*/
private List<Mutation> executeInternal(PartitionUpdate update) {
Triggers triggers = update.metadata().triggers;
if (triggers.isEmpty())
return null;
List<Mutation> tmutations = Lists.newLinkedList();
Thread.currentThread().setContextClassLoader(customClassLoader);
try {
for (TriggerMetadata td : triggers) {
ITrigger trigger = cachedTriggers.get(td.classOption);
if (trigger == null) {
trigger = loadTriggerInstance(td.classOption);
cachedTriggers.put(td.classOption, trigger);
}
Collection<Mutation> temp = trigger.augment(update);
if (temp != null)
tmutations.addAll(temp);
}
return tmutations;
} catch (CassandraException ex) {
throw ex;
} catch (Exception ex) {
throw new RuntimeException(String.format("Exception while executing trigger on table with ID: %s", update.metadata().id), ex);
} finally {
Thread.currentThread().setContextClassLoader(parent);
}
}
Aggregations