use of co.cask.cdap.api.retry.RetryableException 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));
}
use of co.cask.cdap.api.retry.RetryableException in project cdap by caskdata.
the class DistributedStreamService method createHeartbeatsFeed.
/**
* Create Notification feed for stream's heartbeats, if it does not already exist.
*/
private void createHeartbeatsFeed() throws NotificationFeedException {
NotificationFeedInfo streamHeartbeatsFeed = new NotificationFeedInfo(NamespaceId.SYSTEM.getEntityName(), Constants.Notification.Stream.STREAM_INTERNAL_FEED_CATEGORY, Constants.Notification.Stream.STREAM_HEARTBEAT_FEED_NAME, "Stream heartbeats feed.");
LOG.debug("Ensuring Stream HeartbeatsFeed exists.");
boolean isRetry = false;
while (true) {
try {
feedManager.getFeed(streamHeartbeatsFeed);
LOG.debug("Stream HeartbeatsFeed exists.");
return;
} catch (NotificationFeedNotFoundException notFoundException) {
if (!isRetry) {
LOG.debug("Creating Stream HeartbeatsFeed.");
}
feedManager.createFeed(streamHeartbeatsFeed);
LOG.info("Stream HeartbeatsFeed created.");
return;
} catch (NotificationFeedException | RetryableException e) {
if (!isRetry) {
LOG.warn("Could not ensure existence of HeartbeatsFeed. Will retry until successful. " + "Retry failures will be logged at debug level.", e);
} else {
LOG.debug("Could not ensure existence of HeartbeatsFeed. Will retry until successful.", e);
}
isRetry = true;
waitBeforeRetryHeartbeatsFeedOperation();
}
}
}
Aggregations