use of org.opendaylight.controller.cluster.datastore.exceptions.TimeoutException in project controller by opendaylight.
the class PrefixLeaderHandler method makeLeaderLocal.
public ListenableFuture<RpcResult<Void>> makeLeaderLocal(final BecomePrefixLeaderInput input) {
final YangInstanceIdentifier yid = serializer.toYangInstanceIdentifier(input.getPrefix());
final DOMDataTreeIdentifier prefix = new DOMDataTreeIdentifier(LogicalDatastoreType.CONFIGURATION, yid);
try (CDSDataTreeProducer producer = (CDSDataTreeProducer) domDataTreeService.createProducer(Collections.singleton(prefix))) {
final CDSShardAccess shardAccess = producer.getShardAccess(prefix);
final CompletionStage<Void> completionStage = shardAccess.makeLeaderLocal();
completionStage.exceptionally(throwable -> {
LOG.error("Leader movement failed.", throwable);
return null;
});
} catch (final DOMDataTreeProducerException e) {
LOG.warn("Error while closing producer", e);
} catch (final TimeoutException e) {
LOG.warn("Timeout while on producer operation", e);
Futures.immediateFuture(RpcResultBuilder.failed().withError(RpcError.ErrorType.RPC, "resource-denied-transport", "Timeout while opening producer please retry.", "clustering-it", "clustering-it", e));
}
return Futures.immediateFuture(RpcResultBuilder.<Void>success().build());
}
Aggregations