本文整理汇总了Java中org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction.read方法的典型用法代码示例。如果您正苦于以下问题:Java ReadWriteTransaction.read方法的具体用法?Java ReadWriteTransaction.read怎么用?Java ReadWriteTransaction.read使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction
的用法示例。
在下文中一共展示了ReadWriteTransaction.read方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initializeCountrsConfigDataSrore
import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction; //导入方法依赖的package包/类
private void initializeCountrsConfigDataSrore() {
ReadWriteTransaction transaction = db.newReadWriteTransaction();
CheckedFuture<Optional<IngressElementCountersRequestConfig>, ReadFailedException> iecrc =
transaction.read(LogicalDatastoreType.CONFIGURATION, CountersServiceUtils.IECRC_IDENTIFIER);
CheckedFuture<Optional<EgressElementCountersRequestConfig>, ReadFailedException> eecrc =
transaction.read(LogicalDatastoreType.CONFIGURATION, CountersServiceUtils.EECRC_IDENTIFIER);
try {
Optional<IngressElementCountersRequestConfig> iecrcOpt = iecrc.get();
if (!iecrcOpt.isPresent()) {
creatIngressEelementCountersContainerInConfig(transaction, CountersServiceUtils.IECRC_IDENTIFIER);
}
Optional<EgressElementCountersRequestConfig> eecrcOpt = eecrc.get();
if (!eecrcOpt.isPresent()) {
creatEgressEelementCountersContainerInConfig(transaction, CountersServiceUtils.EECRC_IDENTIFIER);
}
transaction.submit();
} catch (InterruptedException | ExecutionException e) {
StatisticsPluginImplCounters.failed_creating_counters_config.inc();
LOG.warn("failed creating counters config data structure in DB");
}
}
示例2: genNextFabricNum
import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction; //导入方法依赖的package包/类
private long genNextFabricNum() {
long ret = 1;
FabricsSettingBuilder settingBuilder = new FabricsSettingBuilder();
ReadWriteTransaction trans = dataBroker.newReadWriteTransaction();
InstanceIdentifier<FabricsSetting> fabricImplPath = InstanceIdentifier.create(FabricsSetting.class);
ListenableFuture<Optional<FabricsSetting>> readFuture =
trans.read(LogicalDatastoreType.CONFIGURATION, fabricImplPath);
Optional<FabricsSetting> optional;
try {
optional = readFuture.get();
if (optional.isPresent()) {
ret = optional.get().getNextFabricNum();
}
} catch (InterruptedException | ExecutionException e) {
LOG.error("can not read fabric setting", e);
}
settingBuilder.setNextFabricNum(ret + 1);
trans.put(LogicalDatastoreType.CONFIGURATION, fabricImplPath, settingBuilder.build());
MdSalUtils.wrapperSubmit(trans, executor);
return ret;
}
示例3: findGWLink
import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction; //导入方法依赖的package包/类
private Link findGWLink(ReadWriteTransaction trans, FabricId fabricid, TpId tpid, NodeId routerid) {
InstanceIdentifier<Link> linkIId = InstanceIdentifier.create(NetworkTopology.class)
.child(Topology.class, new TopologyKey(new TopologyId(fabricid)))
.child(Link.class, new LinkKey(this.createGatewayLink(routerid, tpid)));
CheckedFuture<Optional<Link>,ReadFailedException> readFuture = trans.read(LogicalDatastoreType.OPERATIONAL,
linkIId);
try {
Optional<Link> optional = readFuture.get();
Link link = optional.get();
return link;
} catch (InterruptedException | ExecutionException e) {
LOG.error("", e);
}
return null;
}
示例4: initializeOvsdbTopology
import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction; //导入方法依赖的package包/类
private void initializeOvsdbTopology(LogicalDatastoreType type) {
InstanceIdentifier<Topology> path = InstanceIdentifier
.create(NetworkTopology.class)
.child(Topology.class, new TopologyKey(SouthboundConstants.OVSDB_TOPOLOGY_ID));
ReadWriteTransaction transaction = db.newReadWriteTransaction();
CheckedFuture<Optional<Topology>, ReadFailedException> ovsdbTp = transaction.read(type, path);
try {
if (!ovsdbTp.get().isPresent()) {
TopologyBuilder tpb = new TopologyBuilder();
tpb.setTopologyId(SouthboundConstants.OVSDB_TOPOLOGY_ID);
transaction.put(type, path, tpb.build(), true);
transaction.submit();
} else {
transaction.cancel();
}
} catch (InterruptedException | ExecutionException e) {
LOG.error("Error initializing ovsdb topology", e);
}
}
示例5: initializeHwvtepTopology
import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction; //导入方法依赖的package包/类
private void initializeHwvtepTopology(LogicalDatastoreType type) {
InstanceIdentifier<Topology> path = InstanceIdentifier
.create(NetworkTopology.class)
.child(Topology.class, new TopologyKey(HwvtepSouthboundConstants.HWVTEP_TOPOLOGY_ID));
ReadWriteTransaction transaction = db.newReadWriteTransaction();
CheckedFuture<Optional<Topology>, ReadFailedException> hwvtepTp = transaction.read(type, path);
try {
if (!hwvtepTp.get().isPresent()) {
TopologyBuilder tpb = new TopologyBuilder();
tpb.setTopologyId(HwvtepSouthboundConstants.HWVTEP_TOPOLOGY_ID);
transaction.put(type, path, tpb.build(), true);
transaction.submit();
} else {
transaction.cancel();
}
} catch (Exception e) {
LOG.error("Error initializing hwvtep topology", e);
}
}
示例6: decomposeFabric
import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction; //导入方法依赖的package包/类
@Override
public Future<RpcResult<Void>> decomposeFabric(DecomposeFabricInput input) {
final RpcResult<Void> result = RpcResultBuilder.<Void>success().build();
if ( input == null) {
return Futures.immediateFailedCheckedFuture(new IllegalArgumentException("fabricId can not be empty!"));
}
final FabricId fabricId = input.getFabricId();
if ( fabricId == null) {
return Futures.immediateFailedCheckedFuture(new IllegalArgumentException("fabricId can not be empty!"));
}
ReadWriteTransaction rt = dataBroker.newReadWriteTransaction();
final InstanceIdentifier<Node> fabricpath = Constants.DOM_FABRICS_PATH.child(Node.class, new NodeKey(fabricId));
CheckedFuture<Optional<Node>,ReadFailedException> readFuture =
rt.read(LogicalDatastoreType.OPERATIONAL, fabricpath);
return Futures.transform(readFuture, optional -> {
if (optional.isPresent()) {
Node fabric = optional.get();
FabricInstanceCache.INSTANCE.retrieveFabric(fabricId).notifyFabricDeleted(fabric);
WriteTransaction wt = dataBroker.newWriteOnlyTransaction();
wt.delete(LogicalDatastoreType.OPERATIONAL, fabricpath);
wt.delete(LogicalDatastoreType.CONFIGURATION, fabricpath);
wt.delete(LogicalDatastoreType.OPERATIONAL, MdSalUtils.createTopoIId(fabricId.getValue()));
MdSalUtils.wrapperSubmit(wt, executor);
FabricInstanceCache.INSTANCE.removeFabric(fabricId);
}
return result;
});
}
示例7: execute
import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction; //导入方法依赖的package包/类
@Override
public void execute(ReadWriteTransaction transaction) {
CheckedFuture<Optional<Node>, ReadFailedException> ovsdbNodeFuture = transaction.read(
LogicalDatastoreType.OPERATIONAL, getOvsdbConnectionInstance().getInstanceIdentifier());
Optional<Node> ovsdbNodeOptional;
try {
ovsdbNodeOptional = ovsdbNodeFuture.get();
if (ovsdbNodeOptional.isPresent()) {
Node ovsdbNode = ovsdbNodeOptional.get();
OvsdbNodeAugmentation ovsdbNodeAugmentation = ovsdbNode.getAugmentation(OvsdbNodeAugmentation.class);
if (checkIfOnlyConnectedManager(ovsdbNodeAugmentation)) {
if (ovsdbNodeAugmentation != null) {
if (ovsdbNodeAugmentation.getManagedNodeEntry() != null) {
for (ManagedNodeEntry managedNode : ovsdbNodeAugmentation.getManagedNodeEntry()) {
transaction.delete(
LogicalDatastoreType.OPERATIONAL, managedNode.getBridgeRef().getValue());
}
} else {
LOG.debug("{} had no managed nodes", ovsdbNode.getNodeId().getValue());
}
} else {
LOG.warn("{} had no OvsdbNodeAugmentation", ovsdbNode.getNodeId().getValue());
}
transaction.delete(LogicalDatastoreType.OPERATIONAL,
getOvsdbConnectionInstance().getInstanceIdentifier());
} else {
LOG.debug("Other southbound plugin instances in cluster are connected to the device,"
+ " not deleting OvsdbNode from operational data store.");
}
}
} catch (InterruptedException | ExecutionException e) {
LOG.warn("Failure to delete ovsdbNode", e);
}
}
示例8: execute
import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction; //导入方法依赖的package包/类
@Override
public void execute(ReadWriteTransaction transaction) {
CheckedFuture<Optional<Node>, ReadFailedException> hwvtepGlobalFuture = transaction.read(
LogicalDatastoreType.OPERATIONAL, nodeInstanceIdentifier);
try {
Optional<Node> hwvtepGlobalOptional = hwvtepGlobalFuture.get();
if (hwvtepGlobalOptional.isPresent()) {
Node hwvtepNode = hwvtepGlobalOptional.get();
HwvtepGlobalAugmentation hgAugmentation = hwvtepNode.getAugmentation(HwvtepGlobalAugmentation.class);
if (checkIfOnlyConnectedManager(hgAugmentation)) {
if (hgAugmentation != null) {
if (hgAugmentation.getSwitches() != null) {
for (Switches hwSwitch : hgAugmentation.getSwitches()) {
LOG.debug("Deleting hwvtep switch {}", hwSwitch);
transaction.delete(
LogicalDatastoreType.OPERATIONAL, hwSwitch.getSwitchRef().getValue());
}
} else {
LOG.debug("{} had no switches", hwvtepNode.getNodeId().getValue());
}
} else {
LOG.warn("{} had no HwvtepGlobalAugmentation", hwvtepNode.getNodeId().getValue());
}
transaction.delete(LogicalDatastoreType.OPERATIONAL, nodeInstanceIdentifier);
} else {
LOG.debug("Other southbound plugin instances in cluster are connected to the device,"
+ " not deleting OvsdbNode form data store.");
}
}
} catch (Exception e) {
LOG.warn("Failure to delete ovsdbNode", e);
}
}
示例9: checkStatusAndMakeToast
import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction; //导入方法依赖的package包/类
private void checkStatusAndMakeToast(final MakeToastInput input, final SettableFuture<RpcResult<Void>> futureResult,
final int tries) {
// Read the ToasterStatus and, if currently Up, try to write the status to Down.
// If that succeeds, then we essentially have an exclusive lock and can proceed
// to make toast.
final ReadWriteTransaction tx = dataBroker.newReadWriteTransaction();
ListenableFuture<Optional<Toaster>> readFuture = tx.read(OPERATIONAL, TOASTER_IID);
final ListenableFuture<Void> commitFuture =
Futures.transformAsync(readFuture, toasterData -> {
ToasterStatus toasterStatus = ToasterStatus.Up;
if (toasterData.isPresent()) {
toasterStatus = toasterData.get().getToasterStatus();
}
LOG.debug("Read toaster status: {}", toasterStatus);
if (toasterStatus == ToasterStatus.Up) {
if (outOfBread()) {
LOG.debug("Toaster is out of bread");
return Futures.immediateFailedCheckedFuture(
new TransactionCommitFailedException("", makeToasterOutOfBreadError()));
}
LOG.debug("Setting Toaster status to Down");
// We're not currently making toast - try to update the status to Down
// to indicate we're going to make toast. This acts as a lock to prevent
// concurrent toasting.
tx.put(OPERATIONAL, TOASTER_IID, buildToaster(ToasterStatus.Down));
return tx.submit();
}
LOG.debug("Oops - already making toast!");
// Return an error since we are already making toast. This will get
// propagated to the commitFuture below which will interpret the null
// TransactionStatus in the RpcResult as an error condition.
return Futures.immediateFailedCheckedFuture(
new TransactionCommitFailedException("", makeToasterInUseError()));
});
Futures.addCallback(commitFuture, new FutureCallback<Void>() {
@Override
public void onSuccess(final Void result) {
// OK to make toast
currentMakeToastTask.set(executor.submit(new MakeToastTask(input, futureResult)));
}
@Override
public void onFailure(final Throwable ex) {
if (ex instanceof OptimisticLockFailedException) {
// Another thread is likely trying to make toast simultaneously and updated the
// status before us. Try reading the status again - if another make toast is
// now in progress, we should get ToasterStatus.Down and fail.
if (tries - 1 > 0) {
LOG.debug("Got OptimisticLockFailedException - trying again");
checkStatusAndMakeToast(input, futureResult, tries - 1);
} else {
futureResult.set(RpcResultBuilder.<Void>failed()
.withError(ErrorType.APPLICATION, ex.getMessage()).build());
}
} else if (ex instanceof TransactionCommitFailedException) {
LOG.debug("Failed to commit Toaster status", ex);
// Probably already making toast.
futureResult.set(RpcResultBuilder.<Void>failed()
.withRpcErrors(((TransactionCommitFailedException)ex).getErrorList()).build());
} else {
LOG.debug("Unexpected error committing Toaster status", ex);
futureResult.set(RpcResultBuilder.<Void>failed().withError(ErrorType.APPLICATION,
"Unexpected error committing Toaster status", ex).build());
}
}
});
}
示例10: acquireElementCountersRequestHandler
import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction; //导入方法依赖的package包/类
@Override
public Future<RpcResult<AcquireElementCountersRequestHandlerOutput>> acquireElementCountersRequestHandler(
AcquireElementCountersRequestHandlerInput input) {
AcquireElementCountersRequestHandlerOutputBuilder aecrhob =
new AcquireElementCountersRequestHandlerOutputBuilder();
ReadWriteTransaction transaction = db.newReadWriteTransaction();
UUID randomNumber = UUID.randomUUID();
Integer intRequestKey = allocateId(randomNumber.toString());
if (intRequestKey == null) {
LOG.warn("failed generating unique request identifier");
StatisticsPluginImplCounters.failed_generating_unique_request_id.inc();
return RpcResultBuilder.<AcquireElementCountersRequestHandlerOutput>failed()
.withError(ErrorType.APPLICATION, "failed generating unique request identifier").buildFuture();
}
String requestKey = String.valueOf(intRequestKey);
try {
if (input.getIncomingTraffic() != null) {
CheckedFuture<Optional<EgressElementCountersRequestConfig>, ReadFailedException> eecrc =
transaction.read(LogicalDatastoreType.CONFIGURATION, CountersServiceUtils.EECRC_IDENTIFIER);
Optional<EgressElementCountersRequestConfig> eecrcOpt = eecrc.get();
if (!eecrcOpt.isPresent()) {
LOG.warn("failed creating incoming traffic counter request data container in DB");
StatisticsPluginImplCounters.failed_creating_egress_counter_data_config.inc();
return RpcResultBuilder.<AcquireElementCountersRequestHandlerOutput>failed()
.withError(ErrorType.APPLICATION,
"failed creating egress counter request data container in DB")
.buildFuture();
}
if (!isIdenticalCounterRequestExist(input.getPortId(), ElementCountersDirection.EGRESS.toString(),
input.getIncomingTraffic().getFilters(), eecrcOpt.get().getCounterRequests())) {
installCounterSpecificRules(input.getPortId(), getLportTag(input.getPortId()),
getDpn(input.getPortId()), ElementCountersDirection.EGRESS,
input.getIncomingTraffic().getFilters());
}
putEgressElementCounterRequestInConfig(input, ElementCountersDirection.EGRESS, transaction, requestKey,
CountersServiceUtils.EECRC_IDENTIFIER, eecrcOpt, randomNumber.toString());
transaction.submit();
aecrhob.setIncomingTrafficHandler(requestKey);
bindCountersServiceIfUnbound(input.getPortId(), ElementCountersDirection.EGRESS);
}
if (input.getOutgoingTraffic() != null) {
transaction = db.newReadWriteTransaction();
CheckedFuture<Optional<IngressElementCountersRequestConfig>, ReadFailedException> iecrc =
transaction.read(LogicalDatastoreType.CONFIGURATION, CountersServiceUtils.IECRC_IDENTIFIER);
Optional<IngressElementCountersRequestConfig> iecrcOpt = iecrc.get();
if (!iecrcOpt.isPresent()) {
LOG.warn("failed creating outgoing traffc counter request data container in DB");
StatisticsPluginImplCounters.failed_creating_ingress_counter_data_config.inc();
return RpcResultBuilder.<AcquireElementCountersRequestHandlerOutput>failed()
.withError(ErrorType.APPLICATION,
"failed creating ingress counter request data container in DB")
.buildFuture();
}
if (!isIdenticalCounterRequestExist(input.getPortId(), ElementCountersDirection.INGRESS.toString(),
input.getOutgoingTraffic().getFilters(), iecrcOpt.get().getCounterRequests())) {
installCounterSpecificRules(input.getPortId(), getLportTag(input.getPortId()),
getDpn(input.getPortId()), ElementCountersDirection.INGRESS,
input.getOutgoingTraffic().getFilters());
}
putIngressElementCounterRequestInConfig(input, ElementCountersDirection.INGRESS, transaction,
requestKey, CountersServiceUtils.IECRC_IDENTIFIER, iecrcOpt, randomNumber.toString());
transaction.submit();
aecrhob.setIncomingTrafficHandler(requestKey);
bindCountersServiceIfUnbound(input.getPortId(), ElementCountersDirection.INGRESS);
}
} catch (InterruptedException | ExecutionException e) {
LOG.warn("failed to get counter request data from DB");
return RpcResultBuilder.<AcquireElementCountersRequestHandlerOutput>failed()
.withError(ErrorType.APPLICATION, "failed to get counter request data from DB").buildFuture();
}
return RpcResultBuilder.success(aecrhob.build()).buildFuture();
}
示例11: releaseElementCountersRequestHandler
import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction; //导入方法依赖的package包/类
@Override
public Future<RpcResult<ReleaseElementCountersRequestHandlerOutput>> releaseElementCountersRequestHandler(
ReleaseElementCountersRequestHandlerInput input) {
InstanceIdentifier<CounterRequests> ingressPath =
InstanceIdentifier.builder(IngressElementCountersRequestConfig.class)
.child(CounterRequests.class, new CounterRequestsKey(input.getHandler())).build();
InstanceIdentifier<CounterRequests> egressPath =
InstanceIdentifier.builder(EgressElementCountersRequestConfig.class)
.child(CounterRequests.class, new CounterRequestsKey(input.getHandler())).build();
ReadWriteTransaction tx = db.newReadWriteTransaction();
CheckedFuture<Optional<CounterRequests>, ReadFailedException> ingressRequestData =
tx.read(LogicalDatastoreType.CONFIGURATION, ingressPath);
CheckedFuture<Optional<CounterRequests>, ReadFailedException> egressRequestData =
tx.read(LogicalDatastoreType.CONFIGURATION, egressPath);
CheckedFuture<Optional<IngressElementCountersRequestConfig>, ReadFailedException> iecrc =
tx.read(LogicalDatastoreType.CONFIGURATION, CountersServiceUtils.IECRC_IDENTIFIER);
CheckedFuture<Optional<EgressElementCountersRequestConfig>, ReadFailedException> eecrc =
tx.read(LogicalDatastoreType.CONFIGURATION, CountersServiceUtils.EECRC_IDENTIFIER);
try {
Optional<IngressElementCountersRequestConfig> iecrcOpt = iecrc.get();
Optional<EgressElementCountersRequestConfig> eecrcOpt = eecrc.get();
if (!iecrcOpt.isPresent() || !eecrcOpt.isPresent()) {
LOG.warn("Couldn't read element counters config data from DB");
StatisticsPluginImplCounters.failed_reading_counter_data_from_config.inc();
return RpcResultBuilder.<ReleaseElementCountersRequestHandlerOutput>failed()
.withError(ErrorType.APPLICATION, "Couldn't read element counters config data from DB")
.buildFuture();
}
if (!ingressRequestData.get().isPresent() && !egressRequestData.get().isPresent()) {
LOG.warn("Handler does not exists");
StatisticsPluginImplCounters.unknown_request_handler.inc();
return RpcResultBuilder.<ReleaseElementCountersRequestHandlerOutput>failed()
.withError(ErrorType.APPLICATION, "Handler does not exists").buildFuture();
}
String generatedKey = null;
if (ingressRequestData.get().isPresent()) {
handleReleaseTransaction(input, ingressPath, ingressRequestData, iecrcOpt.get().getCounterRequests());
generatedKey = ingressRequestData.get().get().getGeneratedUniqueId();
}
if (egressRequestData.get().isPresent()) {
handleReleaseTransaction(input, egressPath, egressRequestData, eecrcOpt.get().getCounterRequests());
generatedKey = egressRequestData.get().get().getGeneratedUniqueId();
}
releaseId(generatedKey);
} catch (InterruptedException | ExecutionException e) {
LOG.warn("failed to get counter request data from DB");
return RpcResultBuilder.<ReleaseElementCountersRequestHandlerOutput>failed()
.withError(ErrorType.APPLICATION, "failed to get counter request data from DB").buildFuture();
}
return RpcResultBuilder.<ReleaseElementCountersRequestHandlerOutput>success().buildFuture();
}