本文整理汇总了Java中org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction.read方法的典型用法代码示例。如果您正苦于以下问题:Java ReadOnlyTransaction.read方法的具体用法?Java ReadOnlyTransaction.read怎么用?Java ReadOnlyTransaction.read使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction
的用法示例。
在下文中一共展示了ReadOnlyTransaction.read方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: readFromGreetingRegistry
import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction; //导入方法依赖的package包/类
private String readFromGreetingRegistry(HelloWorldInput input) {
String result = "Hello " + input.getName();
ReadOnlyTransaction transaction = db.newReadOnlyTransaction();
InstanceIdentifier<GreetingRegistryEntry> iid = toInstanceIdentifier(input);
CheckedFuture<Optional<GreetingRegistryEntry>, ReadFailedException> future =
transaction.read(LogicalDatastoreType.CONFIGURATION, iid);
Optional<GreetingRegistryEntry> optional = Optional.absent();
try {
optional = future.checkedGet();
} catch (ReadFailedException e) {
LOG.warn("Reading greeting failed:",e);
}
if(optional.isPresent()) {
result = optional.get().getGreeting();
}
return result;
}
示例2: checkPoolExists
import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction; //导入方法依赖的package包/类
private boolean checkPoolExists() {
ReadOnlyTransaction roTransaction = db.newReadOnlyTransaction();
InstanceIdentifier<IdPool> path = InstanceIdentifier.create(IdPools.class).child(IdPool.class,
new IdPoolKey(CountersServiceUtils.COUNTERS_PULL_NAME));
CheckedFuture<Optional<IdPool>, ReadFailedException> pool =
roTransaction.read(LogicalDatastoreType.CONFIGURATION, path);
try {
Optional<IdPool> poolOpt = pool.get();
if (poolOpt.isPresent()) {
return true;
}
} catch (InterruptedException | ExecutionException e) {
return false;
}
return false;
}
示例3: readFromApplicationRegistry
import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction; //导入方法依赖的package包/类
public AddApplicationInput readFromApplicationRegistry(int appId) {
LOG.info("Reading from application registry for appID {}.", appId);
AddApplicationInput application = null;
ReadOnlyTransaction transaction = db.newReadOnlyTransaction();
InstanceIdentifier<ApplicationRegistryEntry> iid = toInstanceIdentifier(appId);
CheckedFuture<Optional<ApplicationRegistryEntry>, ReadFailedException> future =
transaction.read(LogicalDatastoreType.OPERATIONAL, iid);
Optional<ApplicationRegistryEntry> optional = Optional.absent();
try {
optional = future.checkedGet();
} catch (ReadFailedException e) {
LOG.error("Reading application failed:",e);
}
if(optional.isPresent()) {
application = new AddApplicationInputBuilder()
.setAppId(optional.get().getAppId())
.setJitter(optional.get().getJitter())
.setPacketLoss(optional.get().getPacketLoss())
.setPacketDelay(optional.get().getPacketDelay())
.setBandwidth(optional.get().getBandwidth())
.build();
}
return application;
}
示例4: read
import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction; //导入方法依赖的package包/类
/**
* Executes read as a blocking transaction.
*
* @param store {@link LogicalDatastoreType} to read
* @param path {@link InstanceIdentifier} for path to read
* @param <D> the data object type
* @return the result as the data object requested
*/
public static <D extends org.opendaylight.yangtools.yang.binding.DataObject> D read(
final LogicalDatastoreType store, final InstanceIdentifier<D> path, DataBroker databroker) {
D result = null;
final ReadOnlyTransaction transaction = databroker.newReadOnlyTransaction();
Optional<D> optionalDataObject;
CheckedFuture<Optional<D>, ReadFailedException> future = transaction.read(store, path);
try {
optionalDataObject = future.checkedGet();
if (optionalDataObject.isPresent()) {
result = optionalDataObject.get();
} else {
LOG.debug("{}: Failed to read {}",
Thread.currentThread().getStackTrace()[1], path);
}
} catch (ReadFailedException e) {
LOG.warn("Failed to read {} ", path, e);
}
transaction.close();
return result;
}
示例5: read
import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction; //导入方法依赖的package包/类
/**
* Executes read as a blocking transaction.
*
* @param store
* {@link LogicalDatastoreType} to read
* @param path
* {@link InstanceIdentifier} for path to read
* @param <D>
* the data object type
* @return the result as the data object requested
*/
public <D extends org.opendaylight.yangtools.yang.binding.DataObject> D read(final LogicalDatastoreType store,
final InstanceIdentifier<D> path) {
D result = null;
final ReadOnlyTransaction transaction = databroker.newReadOnlyTransaction();
Optional<D> optionalDataObject;
CheckedFuture<Optional<D>, ReadFailedException> future = transaction.read(store, path);
try {
optionalDataObject = future.checkedGet();
if (optionalDataObject.isPresent()) {
result = optionalDataObject.get();
} else {
LOG.debug("{}: Failed to read {}", Thread.currentThread().getStackTrace()[1], path);
}
} catch (ReadFailedException e) {
LOG.warn("Failed to read {} ", path, e);
}
transaction.close();
return result;
}
示例6: readMemberMd
import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction; //导入方法依赖的package包/类
protected <
T extends org.opendaylight.yangtools.yang.binding.DataObject> T readMemberMd(InstanceIdentifier<T> path) {
T result = null;
final ReadOnlyTransaction transaction = getDataBroker().newReadOnlyTransaction();
final CheckedFuture<Optional<T>,
ReadFailedException> future = transaction.read(LogicalDatastoreType.CONFIGURATION, path);
if (future != null) {
Optional<T> optional;
try {
optional = future.checkedGet();
if (optional.isPresent()) {
result = optional.get();
}
} catch (final ReadFailedException e) {
LOG.warn("Failed to read {}", path, e);
}
}
transaction.close();
return result;
}
示例7: read
import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction; //导入方法依赖的package包/类
/**
* Executes read as non blocking transaction and assign a default callback
* to close the transaction.
*
* @param store
* {@link LogicalDatastoreType} to read
* @param path
* {@link InstanceIdentifier} for path to read
* @param <D>
* The data object type
* @return The {@link CheckedFuture} object to which you can assign a
* callback
*/
public <D extends DataObject> CheckedFuture<Optional<D>, ReadFailedException> read(
final LogicalDatastoreType store,
final InstanceIdentifier<D> path) {
final ReadOnlyTransaction transaction = databroker.newReadOnlyTransaction();
final CheckedFuture<Optional<D>, ReadFailedException> future = transaction.read(store, path);
final FutureCallback<Optional<D>> closeTransactionCallback = new FutureCallback<Optional<D>>() {
@Override
public void onSuccess(final Optional<D> result) {
transaction.close();
}
@Override
public void onFailure(final Throwable t) {
transaction.close();
}
};
Futures.addCallback(future, closeTransactionCallback);
return future;
}
示例8: read
import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction; //导入方法依赖的package包/类
/**
* Executes read as a blocking transaction.
*
* @param store {@link LogicalDatastoreType} to read
* @param path {@link InstanceIdentifier} for path to read
* @param <D> the data object type
* @return the result as the data object requested
*/
public <D extends org.opendaylight.yangtools.yang.binding.DataObject> D read(
final LogicalDatastoreType store, final InstanceIdentifier<D> path) {
D result = null;
final ReadOnlyTransaction transaction = databroker.newReadOnlyTransaction();
Optional<D> optionalDataObject;
CheckedFuture<Optional<D>, ReadFailedException> future = transaction.read(store, path);
try {
optionalDataObject = future.checkedGet();
if (optionalDataObject.isPresent()) {
result = optionalDataObject.get();
} else {
LOG.debug("{}: Failed to read {}",
Thread.currentThread().getStackTrace()[1], path);
}
} catch (ReadFailedException e) {
LOG.warn("Failed to read {} ", path, e);
}
transaction.close();
return result;
}
示例9: getConnectionInstance
import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction; //导入方法依赖的package包/类
public OvsdbConnectionInstance getConnectionInstance(InstanceIdentifier<Node> nodePath) {
try {
ReadOnlyTransaction transaction = db.newReadOnlyTransaction();
CheckedFuture<Optional<Node>, ReadFailedException> nodeFuture = transaction.read(
LogicalDatastoreType.OPERATIONAL, nodePath);
transaction.close();
Optional<Node> optional = nodeFuture.get();
if (optional.isPresent()) {
return this.getConnectionInstance(optional.get());
} else {
LOG.debug("Node was not found on the path in the operational DS: {}", nodePath);
return null;
}
} catch (InterruptedException | ExecutionException e) {
LOG.warn("Failed to get Ovsdb Node {}",nodePath, e);
return null;
}
}
示例10: getBridge
import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction; //导入方法依赖的package包/类
private OvsdbBridgeAugmentation getBridge(InstanceIdentifier<?> key, Map<InstanceIdentifier<Node>, Node> nodes) {
OvsdbBridgeAugmentation bridge = null;
InstanceIdentifier<Node> nodeIid = key.firstIdentifierOf(Node.class);
if (nodes != null && nodes.get(nodeIid) != null) {
Node node = nodes.get(nodeIid);
bridge = node.getAugmentation(OvsdbBridgeAugmentation.class);
if (bridge == null) {
ReadOnlyTransaction transaction = SouthboundProvider.getDb().newReadOnlyTransaction();
CheckedFuture<Optional<Node>, ReadFailedException> future =
transaction.read(LogicalDatastoreType.OPERATIONAL, nodeIid);
try {
Optional<Node> nodeOptional = future.get();
if (nodeOptional.isPresent()) {
bridge = nodeOptional.get().getAugmentation(OvsdbBridgeAugmentation.class);
}
} catch (InterruptedException | ExecutionException e) {
LOG.warn("Error reading from datastore",e);
}
transaction.close();
}
}
return bridge;
}
示例11: getOperNode
import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction; //导入方法依赖的package包/类
private OvsdbNodeAugmentation getOperNode(final OvsdbBridgeAugmentation operBridge) {
@SuppressWarnings("unchecked")
InstanceIdentifier<Node> iidNode = (InstanceIdentifier<Node>)operBridge.getManagedBy().getValue();
OvsdbNodeAugmentation operNode = null;
ReadOnlyTransaction transaction = SouthboundProvider.getDb().newReadOnlyTransaction();
CheckedFuture<Optional<Node>, ReadFailedException> future =
transaction.read(LogicalDatastoreType.OPERATIONAL, iidNode);
try {
Optional<Node> nodeOptional = future.get();
if (nodeOptional.isPresent()) {
operNode = nodeOptional.get().getAugmentation(OvsdbNodeAugmentation.class);
}
} catch (InterruptedException | ExecutionException e) {
LOG.warn("Error reading from datastore", e);
}
return operNode;
}
示例12: validateGreetingRegistry
import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction; //导入方法依赖的package包/类
private void validateGreetingRegistry(String name) {
InstanceIdentifier<GreetingRegistryEntry> iid = InstanceIdentifier.create(GreetingRegistry.class)
.child(GreetingRegistryEntry.class, new GreetingRegistryEntryKey(name));
DataBroker db = getSession().getSALService(DataBroker.class);
ReadOnlyTransaction transaction = db.newReadOnlyTransaction();
CheckedFuture<Optional<GreetingRegistryEntry>, ReadFailedException> future =
transaction.read(LogicalDatastoreType.OPERATIONAL, iid);
Optional<GreetingRegistryEntry> optional = Optional.absent();
try {
optional = future.checkedGet();
} catch (ReadFailedException e) {
LOG.warn("Reading greeting failed:",e);
}
Assert.assertTrue(name + " not recorded in greeting registry",optional.isPresent());
}
示例13: readInitialAppConfig
import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction; //导入方法依赖的package包/类
private void readInitialAppConfig(final DataBroker dataBroker) {
final ReadOnlyTransaction readOnlyTx = dataBroker.newReadOnlyTransaction();
ListenableFuture<Optional<DataObject>> future = readOnlyTx.read(
LogicalDatastoreType.CONFIGURATION, bindingContext.appConfigPath);
Futures.addCallback(future, new FutureCallback<Optional<DataObject>>() {
@Override
public void onSuccess(final Optional<DataObject> possibleAppConfig) {
LOG.debug("{}: Read of app config {} succeeded: {}", logName(), bindingContext
.appConfigBindingClass.getName(), possibleAppConfig);
readOnlyTx.close();
setInitialAppConfig(possibleAppConfig);
}
@Override
public void onFailure(final Throwable failure) {
readOnlyTx.close();
// We may have gotten the app config via the data tree change listener so only retry if not.
if (readingInitialAppConfig.get()) {
LOG.warn("{}: Read of app config {} failed - retrying", logName(),
bindingContext.appConfigBindingClass.getName(), failure);
readInitialAppConfig(dataBroker);
}
}
}, MoreExecutors.directExecutor());
}
示例14: notifyExistingNodes
import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction; //导入方法依赖的package包/类
private void notifyExistingNodes(final EventSourceTopology eventSourceTopology){
LOG.debug("Notify existing nodes");
final Pattern nodeRegex = this.nodeIdPattern;
final ReadOnlyTransaction tx = eventSourceTopology.getDataBroker().newReadOnlyTransaction();
final CheckedFuture<Optional<Topology>, ReadFailedException> future =
tx.read(LogicalDatastoreType.OPERATIONAL, EventSourceTopology.EVENT_SOURCE_TOPOLOGY_PATH);
Futures.addCallback(future, new FutureCallback<Optional<Topology>>(){
@Override
public void onSuccess(final Optional<Topology> data) {
if(data.isPresent()) {
final List<Node> nodes = data.get().getNode();
if(nodes != null){
for (final Node node : nodes) {
if (nodeRegex.matcher(node.getNodeId().getValue()).matches()) {
notifyNode(EventSourceTopology.EVENT_SOURCE_TOPOLOGY_PATH.child(Node.class, node.getKey()));
}
}
}
}
tx.close();
}
@Override
public void onFailure(final Throwable t) {
LOG.error("Can not notify existing nodes", t);
tx.close();
}
});
}
示例15: onDataChanged
import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction; //导入方法依赖的package包/类
@Override
public void onDataChanged(AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> change) {
Map<InstanceIdentifier<?>, DataObject> createdData = change.getCreatedData();
for (Map.Entry<InstanceIdentifier<?>, DataObject> entrySet : createdData.entrySet()) {
InstanceIdentifier<?> iiD = entrySet.getKey();
final DataObject dataObject = entrySet.getValue();
if (dataObject instanceof FlowCapableNode) {
final InstanceIdentifier<Node> path = iiD.firstIdentifierOf(Node.class);
ReadOnlyTransaction readOnlyTransaction = dataBroker.newReadOnlyTransaction();
final CheckedFuture<Optional<Node>, ReadFailedException> readFuture = readOnlyTransaction
.read(LogicalDatastoreType.OPERATIONAL, path);
Futures.addCallback(readFuture, new FutureCallback<Optional<Node>>() {
@Override
public void onSuccess(Optional<Node> result) {
if (result.isPresent()) {
bgpRouter.processNodeAdd(result.get().getId());
LOG.info("Node discovered and passed to processNodeAdd : " + result.get().getId());
} else {
LOG.info("Read succeeded, node doesn't exist: {}", path);
}
}
@Override
public void onFailure(Throwable t) {
LOG.info("Failed to read Node: {}", path, t);
}
});
}
}
}