Search in sources :

Example 1 with NoTxKeyValueTable

use of co.cask.cdap.data2.dataset2.lib.kv.NoTxKeyValueTable in project cdap by caskdata.

the class DatasetServiceStore method startUp.

@Override
protected void startUp() throws Exception {
    final DatasetId serviceStoreDatasetInstanceId = NamespaceId.SYSTEM.dataset(Constants.Service.SERVICE_INSTANCE_TABLE_NAME);
    table = Retries.supplyWithRetries(new Supplier<NoTxKeyValueTable>() {

        @Override
        public NoTxKeyValueTable get() {
            try {
                return DatasetsUtil.getOrCreateDataset(dsFramework, serviceStoreDatasetInstanceId, NoTxKeyValueTable.class.getName(), DatasetProperties.EMPTY, null);
            } catch (Exception e) {
                // Throwing RetryableException here is just to make it retry getting the dataset
                // an exception here usually means there is an hbase problem
                LOG.warn("Error getting service store dataset {}. Will retry after some time: {}", serviceStoreDatasetInstanceId, e.getMessage());
                throw new RetryableException(e);
            }
        }
    }, RetryStrategies.exponentialDelay(1, 30, TimeUnit.SECONDS));
}
Also used : RetryableException(co.cask.cdap.api.retry.RetryableException) NoTxKeyValueTable(co.cask.cdap.data2.dataset2.lib.kv.NoTxKeyValueTable) Supplier(com.google.common.base.Supplier) RetryableException(co.cask.cdap.api.retry.RetryableException) DatasetId(co.cask.cdap.proto.id.DatasetId)

Aggregations

RetryableException (co.cask.cdap.api.retry.RetryableException)1 NoTxKeyValueTable (co.cask.cdap.data2.dataset2.lib.kv.NoTxKeyValueTable)1 DatasetId (co.cask.cdap.proto.id.DatasetId)1 Supplier (com.google.common.base.Supplier)1