@Test @SuppressWarnings("unchecked") public void testReadSynchronous() throws Exception { InstanceIdentifier path = InstanceIdentifier.create(SxpNodeIdentity.class); ReadTransaction readTransaction = mock(ReadTransaction.class); when(transactionChain.newReadOnlyTransaction()).thenReturn(readTransaction); when(readTransaction.read(eq(LogicalDatastoreType.CONFIGURATION), eq(path))) .thenReturn(FluentFutures.immediateFluentFuture(Optional.of(mock(SxpNodeIdentity.class)))); Assert.assertNotNull(access.readSynchronous(path, LogicalDatastoreType.CONFIGURATION)); }
public synchronized <T extends DataObject> T readSynchronous( final InstanceIdentifier<T> path, final LogicalDatastoreType logicalDatastoreType) { LOG.debug("Read synchronous {}", path); try { final Optional<T> result = read(path, logicalDatastoreType).get(); return result.orElse(null); } catch (final InterruptedException e) { Thread.currentThread().interrupt(); LOG.error("Failed to read {} from {}, exception: {}", path, logicalDatastoreType, e); return null; } catch (final ExecutionException e) { LOG.error("Failed to read {} from {}, exception: {}", path, logicalDatastoreType, e); return null; } }
DatastoreAccess implements AutoCloseable { public synchronized <T extends DataObject> T readSynchronous( final InstanceIdentifier<T> path, final LogicalDatastoreType logicalDatastoreType) { LOG.debug("Read synchronous {}", path); try { final Optional<T> result = read(path, logicalDatastoreType).get(); return result.orElse(null); } catch (final InterruptedException e) { Thread.currentThread().interrupt(); LOG.error("Failed to read {} from {}, exception: {}", path, logicalDatastoreType, e); return null; } catch (final ExecutionException e) { LOG.error("Failed to read {} from {}, exception: {}", path, logicalDatastoreType, e); return null; } } }
DatastoreAccess implements AutoCloseable { public synchronized <T extends DataObject> T readSynchronous( final InstanceIdentifier<T> path, final LogicalDatastoreType logicalDatastoreType) { LOG.debug("Read synchronous {}", path); try { final Optional<T> result = read(path, logicalDatastoreType).get(); return result.orElse(null); } catch (final InterruptedException e) { Thread.currentThread().interrupt(); LOG.error("Failed to read {} from {}, exception: {}", path, logicalDatastoreType, e); return null; } catch (final ExecutionException e) { LOG.error("Failed to read {} from {}, exception: {}", path, logicalDatastoreType, e); return null; } } private  DatastoreAccess(final DataBroker dataBroker); }
DatastoreAccess implements AutoCloseable { public synchronized <T extends DataObject> T readSynchronous( final InstanceIdentifier<T> path, final LogicalDatastoreType logicalDatastoreType) { LOG.debug("Read synchronous {}", path); try { final Optional<T> result = read(path, logicalDatastoreType).get(); return result.orElse(null); } catch (final InterruptedException e) { Thread.currentThread().interrupt(); LOG.error("Failed to read {} from {}, exception: {}", path, logicalDatastoreType, e); return null; } catch (final ExecutionException e) { LOG.error("Failed to read {} from {}, exception: {}", path, logicalDatastoreType, e); return null; } } private  DatastoreAccess(final DataBroker dataBroker); static DatastoreAccess getInstance(final DataBroker dataBroker); static DatastoreAccess getInstance(final DatastoreAccess datastoreAccess); synchronized FluentFuture<? extends CommitInfo> delete(
            final InstanceIdentifier<T> path, final LogicalDatastoreType logicalDatastoreType); synchronized FluentFuture<? extends CommitInfo> merge(
            final InstanceIdentifier<T> path, final T data, final LogicalDatastoreType logicalDatastoreType); synchronized FluentFuture<? extends CommitInfo> put(
            final InstanceIdentifier<T> path, final T data, final LogicalDatastoreType logicalDatastoreType); synchronized FluentFuture<java.util.Optional<T>> read(
            final InstanceIdentifier<T> path, final LogicalDatastoreType logicalDatastoreType); synchronized boolean mergeSynchronous(
            final InstanceIdentifier<T> path, final T data, final LogicalDatastoreType logicalDatastoreType); synchronized boolean putSynchronous(
            final InstanceIdentifier<T> path, final T data, final LogicalDatastoreType logicalDatastoreType); synchronized boolean deleteSynchronous(
            final InstanceIdentifier<T> path, final LogicalDatastoreType logicalDatastoreType); synchronized T readSynchronous(
            final InstanceIdentifier<T> path, final LogicalDatastoreType logicalDatastoreType); synchronized boolean checkAndPut(
            final InstanceIdentifier<T> identifier, final T data, final LogicalDatastoreType datastoreType,
            final boolean isUpdating); synchronized boolean checkAndMerge(
            final InstanceIdentifier<T> identifier, final T data, final LogicalDatastoreType datastoreType,
            final boolean isUpdating); synchronized boolean checkAndDelete(
            final InstanceIdentifier<T> identifier, final LogicalDatastoreType datastoreType); synchronized boolean putIfNotExists(
            final InstanceIdentifier<T> identifier, final T data, final LogicalDatastoreType datastoreType); synchronized void reinitializeChain(); @Override synchronized void close(); }
DatastoreAccess implements AutoCloseable { public synchronized <T extends DataObject> T readSynchronous( final InstanceIdentifier<T> path, final LogicalDatastoreType logicalDatastoreType) { LOG.debug("Read synchronous {}", path); try { final Optional<T> result = read(path, logicalDatastoreType).get(); return result.orElse(null); } catch (final InterruptedException e) { Thread.currentThread().interrupt(); LOG.error("Failed to read {} from {}, exception: {}", path, logicalDatastoreType, e); return null; } catch (final ExecutionException e) { LOG.error("Failed to read {} from {}, exception: {}", path, logicalDatastoreType, e); return null; } } private  DatastoreAccess(final DataBroker dataBroker); static DatastoreAccess getInstance(final DataBroker dataBroker); static DatastoreAccess getInstance(final DatastoreAccess datastoreAccess); synchronized FluentFuture<? extends CommitInfo> delete(
            final InstanceIdentifier<T> path, final LogicalDatastoreType logicalDatastoreType); synchronized FluentFuture<? extends CommitInfo> merge(
            final InstanceIdentifier<T> path, final T data, final LogicalDatastoreType logicalDatastoreType); synchronized FluentFuture<? extends CommitInfo> put(
            final InstanceIdentifier<T> path, final T data, final LogicalDatastoreType logicalDatastoreType); synchronized FluentFuture<java.util.Optional<T>> read(
            final InstanceIdentifier<T> path, final LogicalDatastoreType logicalDatastoreType); synchronized boolean mergeSynchronous(
            final InstanceIdentifier<T> path, final T data, final LogicalDatastoreType logicalDatastoreType); synchronized boolean putSynchronous(
            final InstanceIdentifier<T> path, final T data, final LogicalDatastoreType logicalDatastoreType); synchronized boolean deleteSynchronous(
            final InstanceIdentifier<T> path, final LogicalDatastoreType logicalDatastoreType); synchronized T readSynchronous(
            final InstanceIdentifier<T> path, final LogicalDatastoreType logicalDatastoreType); synchronized boolean checkAndPut(
            final InstanceIdentifier<T> identifier, final T data, final LogicalDatastoreType datastoreType,
            final boolean isUpdating); synchronized boolean checkAndMerge(
            final InstanceIdentifier<T> identifier, final T data, final LogicalDatastoreType datastoreType,
            final boolean isUpdating); synchronized boolean checkAndDelete(
            final InstanceIdentifier<T> identifier, final LogicalDatastoreType datastoreType); synchronized boolean putIfNotExists(
            final InstanceIdentifier<T> identifier, final T data, final LogicalDatastoreType datastoreType); synchronized void reinitializeChain(); @Override synchronized void close();  }