@Test public void readDataReattemptTest() { doThrow(new IllegalStateException()).when(rTx).read(LogicalDatastoreType.CONFIGURATION, nodeIid); final Optional<Node> result = GbpNetconfTransaction.read(nodeIid, LogicalDatastoreType.CONFIGURATION, nodeIid, (byte)5); verify(dataBroker, times(6)).newReadOnlyTransaction(); assertFalse(result.isPresent()); }
public static synchronized <T extends DataObject> Optional<T> read(final InstanceIdentifier<Node> vppIid, final LogicalDatastoreType datastoreType, final InstanceIdentifier<T> iid, byte retryCounter) { LOG.trace("Netconf READ transaction started. RetryCounter: {}", retryCounter); Preconditions.checkNotNull(vppIid); DataBroker mountpoint = VbdNetconfTransaction.NODE_DATA_BROKER_MAP.get(vppIid).getKey(); final ReadOnlyTransaction rTx = mountpoint.newReadOnlyTransaction(); Optional<T> data; try { final CheckedFuture<Optional<T>, ReadFailedException> futureData = rTx.read(datastoreType, iid); data = futureData.get(); LOG.trace("Netconf READ transaction done. Data present: {}", data.isPresent()); return data; } catch (Exception e) { if (retryCounter > 0) { LOG.warn("Netconf READ transaction failed to {}. Restarting transaction ... ", e.getMessage()); rTx.close(); return read(vppIid, datastoreType, iid, --retryCounter); } else { LOG.warn("Netconf READ transaction unsuccessful. Maximal number of attempts reached. Trace: {}", e); return Optional.absent(); } } }
GbpNetconfTransaction { public static synchronized <T extends DataObject> Optional<T> read(final InstanceIdentifier<Node> vppIid, final LogicalDatastoreType datastoreType, final InstanceIdentifier<T> iid, byte retryCounter) { LOG.trace("Netconf READ transaction started. RetryCounter: {}", retryCounter); Preconditions.checkNotNull(vppIid); DataBroker mountpoint = VbdNetconfTransaction.NODE_DATA_BROKER_MAP.get(vppIid).getKey(); final ReadOnlyTransaction rTx = mountpoint.newReadOnlyTransaction(); Optional<T> data; try { final CheckedFuture<Optional<T>, ReadFailedException> futureData = rTx.read(datastoreType, iid); data = futureData.get(); LOG.trace("Netconf READ transaction done. Data present: {}", data.isPresent()); return data; } catch (Exception e) { if (retryCounter > 0) { LOG.warn("Netconf READ transaction failed to {}. Restarting transaction ... ", e.getMessage()); rTx.close(); return read(vppIid, datastoreType, iid, --retryCounter); } else { LOG.warn("Netconf READ transaction unsuccessful. Maximal number of attempts reached. Trace: {}", e); return Optional.absent(); } } } }
GbpNetconfTransaction { public static synchronized <T extends DataObject> Optional<T> read(final InstanceIdentifier<Node> vppIid, final LogicalDatastoreType datastoreType, final InstanceIdentifier<T> iid, byte retryCounter) { LOG.trace("Netconf READ transaction started. RetryCounter: {}", retryCounter); Preconditions.checkNotNull(vppIid); DataBroker mountpoint = VbdNetconfTransaction.NODE_DATA_BROKER_MAP.get(vppIid).getKey(); final ReadOnlyTransaction rTx = mountpoint.newReadOnlyTransaction(); Optional<T> data; try { final CheckedFuture<Optional<T>, ReadFailedException> futureData = rTx.read(datastoreType, iid); data = futureData.get(); LOG.trace("Netconf READ transaction done. Data present: {}", data.isPresent()); return data; } catch (Exception e) { if (retryCounter > 0) { LOG.warn("Netconf READ transaction failed to {}. Restarting transaction ... ", e.getMessage()); rTx.close(); return read(vppIid, datastoreType, iid, --retryCounter); } else { LOG.warn("Netconf READ transaction unsuccessful. Maximal number of attempts reached. Trace: {}", e); return Optional.absent(); } } }  }
GbpNetconfTransaction { public static synchronized <T extends DataObject> Optional<T> read(final InstanceIdentifier<Node> vppIid, final LogicalDatastoreType datastoreType, final InstanceIdentifier<T> iid, byte retryCounter) { LOG.trace("Netconf READ transaction started. RetryCounter: {}", retryCounter); Preconditions.checkNotNull(vppIid); DataBroker mountpoint = VbdNetconfTransaction.NODE_DATA_BROKER_MAP.get(vppIid).getKey(); final ReadOnlyTransaction rTx = mountpoint.newReadOnlyTransaction(); Optional<T> data; try { final CheckedFuture<Optional<T>, ReadFailedException> futureData = rTx.read(datastoreType, iid); data = futureData.get(); LOG.trace("Netconf READ transaction done. Data present: {}", data.isPresent()); return data; } catch (Exception e) { if (retryCounter > 0) { LOG.warn("Netconf READ transaction failed to {}. Restarting transaction ... ", e.getMessage()); rTx.close(); return read(vppIid, datastoreType, iid, --retryCounter); } else { LOG.warn("Netconf READ transaction unsuccessful. Maximal number of attempts reached. Trace: {}", e); return Optional.absent(); } } }  static boolean netconfSyncedWrite(@Nonnull final InstanceIdentifier<Node> vppIid,
        @Nonnull final InstanceIdentifier<T> iid, @Nonnull final T data, byte retryCounter); static boolean netconfSyncedWrite(@Nonnull final InstanceIdentifier<Node> vppIid,
            @Nonnull final Map<InstanceIdentifier<T>,T> data, byte retryCounter); static boolean netconfSyncedMerge(@Nonnull final InstanceIdentifier<Node> vppIid,
        @Nonnull final InstanceIdentifier<T> iid, @Nonnull final T data, byte retryCounter); static boolean netconfSyncedMerge(@Nonnull final InstanceIdentifier<Node> vppIid,
        @Nonnull final ConfigCommand command, byte retryCounter); static boolean netconfSyncedWrite(@Nonnull final InstanceIdentifier<Node> vppIid,
        @Nonnull final ConfigCommand command, byte retryCounter); static boolean netconfSyncedWrite(@Nonnull final InstanceIdentifier<Node> vppIid,
        @Nonnull final RoutingCommand command, byte retryCounter); static boolean netconfSyncedDelete(@Nonnull final InstanceIdentifier<Node> vppIid,
        @Nonnull final InstanceIdentifier<T> iid, byte retryCounter); static boolean netconfSyncedDelete(@Nonnull final InstanceIdentifier<Node> vppIid,
            @Nonnull Set<InstanceIdentifier<T>> iids , byte retryCounter); static boolean netconfSyncedDelete(@Nonnull final InstanceIdentifier<Node> vppIid,
        @Nonnull final ConfigCommand command, byte retryCounter); static boolean netconfSyncedDelete(@Nonnull final InstanceIdentifier<Node> vppIid,
        @Nonnull final RoutingCommand command, byte retryCounter); static synchronized Optional<T> read(final InstanceIdentifier<Node> vppIid,
        final LogicalDatastoreType datastoreType, final InstanceIdentifier<T> iid, byte retryCounter); }
GbpNetconfTransaction { public static synchronized <T extends DataObject> Optional<T> read(final InstanceIdentifier<Node> vppIid, final LogicalDatastoreType datastoreType, final InstanceIdentifier<T> iid, byte retryCounter) { LOG.trace("Netconf READ transaction started. RetryCounter: {}", retryCounter); Preconditions.checkNotNull(vppIid); DataBroker mountpoint = VbdNetconfTransaction.NODE_DATA_BROKER_MAP.get(vppIid).getKey(); final ReadOnlyTransaction rTx = mountpoint.newReadOnlyTransaction(); Optional<T> data; try { final CheckedFuture<Optional<T>, ReadFailedException> futureData = rTx.read(datastoreType, iid); data = futureData.get(); LOG.trace("Netconf READ transaction done. Data present: {}", data.isPresent()); return data; } catch (Exception e) { if (retryCounter > 0) { LOG.warn("Netconf READ transaction failed to {}. Restarting transaction ... ", e.getMessage()); rTx.close(); return read(vppIid, datastoreType, iid, --retryCounter); } else { LOG.warn("Netconf READ transaction unsuccessful. Maximal number of attempts reached. Trace: {}", e); return Optional.absent(); } } }  static boolean netconfSyncedWrite(@Nonnull final InstanceIdentifier<Node> vppIid,
        @Nonnull final InstanceIdentifier<T> iid, @Nonnull final T data, byte retryCounter); static boolean netconfSyncedWrite(@Nonnull final InstanceIdentifier<Node> vppIid,
            @Nonnull final Map<InstanceIdentifier<T>,T> data, byte retryCounter); static boolean netconfSyncedMerge(@Nonnull final InstanceIdentifier<Node> vppIid,
        @Nonnull final InstanceIdentifier<T> iid, @Nonnull final T data, byte retryCounter); static boolean netconfSyncedMerge(@Nonnull final InstanceIdentifier<Node> vppIid,
        @Nonnull final ConfigCommand command, byte retryCounter); static boolean netconfSyncedWrite(@Nonnull final InstanceIdentifier<Node> vppIid,
        @Nonnull final ConfigCommand command, byte retryCounter); static boolean netconfSyncedWrite(@Nonnull final InstanceIdentifier<Node> vppIid,
        @Nonnull final RoutingCommand command, byte retryCounter); static boolean netconfSyncedDelete(@Nonnull final InstanceIdentifier<Node> vppIid,
        @Nonnull final InstanceIdentifier<T> iid, byte retryCounter); static boolean netconfSyncedDelete(@Nonnull final InstanceIdentifier<Node> vppIid,
            @Nonnull Set<InstanceIdentifier<T>> iids , byte retryCounter); static boolean netconfSyncedDelete(@Nonnull final InstanceIdentifier<Node> vppIid,
        @Nonnull final ConfigCommand command, byte retryCounter); static boolean netconfSyncedDelete(@Nonnull final InstanceIdentifier<Node> vppIid,
        @Nonnull final RoutingCommand command, byte retryCounter); static synchronized Optional<T> read(final InstanceIdentifier<Node> vppIid,
        final LogicalDatastoreType datastoreType, final InstanceIdentifier<T> iid, byte retryCounter); static final byte RETRY_COUNT; }