+
+ protected static Integer getUniqueRDId(IdManagerService idManager, String poolName, String idKey) {
+ AllocateIdInput getIdInput = new AllocateIdInputBuilder().setPoolName(poolName).setIdKey(idKey).build();
+ try {
+ Future<RpcResult<AllocateIdOutput>> result = idManager.allocateId(getIdInput);
+ RpcResult<AllocateIdOutput> rpcResult = result.get();
+ if (rpcResult.isSuccessful()) {
+ return rpcResult.getResult().getIdValue().intValue();
+ } else {
+ logger.debug("RPC Call to Get Unique Id returned with Errors", rpcResult.getErrors());
+ }
+ } catch (InterruptedException | ExecutionException e) {
+ logger.debug("Exception when getting Unique Id", e);
+ }
+ return null;
+ }
+
+ protected static void releaseRDId(IdManagerService idManager, String poolName, String idKey) {
+ ReleaseIdInput idInput = new ReleaseIdInputBuilder().setPoolName(poolName).setIdKey(idKey).build();
+ try {
+ Future<RpcResult<Void>> result = idManager.releaseId(idInput);
+ RpcResult<Void> rpcResult = result.get();
+ if (!rpcResult.isSuccessful()) {
+ logger.debug("RPC Call to Get Unique Id returned with Errors", rpcResult.getErrors());
+ } else {
+ logger.info("ID for RD " + idKey + " released successfully");
+ }
+ } catch (InterruptedException | ExecutionException e) {
+ logger.debug("Exception when trying to release ID into the pool", idKey, e);
+ }
+ }
+