- try {
- commitResult.get();
- } catch (InterruptedException | ExecutionException e) {
- LOG.error("Node {} not updated.", ref.getValue(), e);
- }
-
+ listenOnTransactionState(it.getIdentifier(), commitResult, "node update", ref.getValue());
+ }
+
+ /**
+ * @param txId transaction identificator
+ * @param future transaction result
+ * @param action performed by transaction
+ * @param nodeConnectorPath target value
+ */
+ private static void listenOnTransactionState(final Object txId, Future<RpcResult<TransactionStatus>> future,
+ final String action, final InstanceIdentifier<?> nodeConnectorPath) {
+ Futures.addCallback(JdkFutureAdapters.listenInPoolThread(future),new FutureCallback<RpcResult<TransactionStatus>>() {
+
+ @Override
+ public void onFailure(Throwable t) {
+ LOG.error("Action {} [{}] failed for Tx:{}", action, nodeConnectorPath, txId, t);
+
+ }
+
+ @Override
+ public void onSuccess(RpcResult<TransactionStatus> result) {
+ if(!result.isSuccessful()) {
+ LOG.error("Action {} [{}] failed for Tx:{}", action, nodeConnectorPath, txId);
+ }
+ }
+ });