use of org.apache.tephra.TransactionAware in project cdap by caskdata.
the class UnitTestManager method getDataset.
@Override
public <T> DataSetManager<T> getDataset(DatasetId datasetInstanceId) throws Exception {
@SuppressWarnings("unchecked") final T dataSet = datasetFramework.getDataset(datasetInstanceId, new HashMap<String, String>(), null);
try {
final TransactionContext txContext;
// not every dataset is TransactionAware. FileSets for example, are not transactional.
if (dataSet instanceof TransactionAware) {
TransactionAware txAwareDataset = (TransactionAware) dataSet;
txContext = new TransactionContext(txSystemClient, Lists.newArrayList(txAwareDataset));
txContext.start();
} else {
txContext = null;
}
return new UnitTestDatasetManager<>(dataSet, txContext);
} catch (Exception e) {
throw Throwables.propagate(e);
}
}
Aggregations