本文整理汇总了Java中org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction.submit方法的典型用法代码示例。如果您正苦于以下问题:Java ReadWriteTransaction.submit方法的具体用法?Java ReadWriteTransaction.submit怎么用?Java ReadWriteTransaction.submit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction
的用法示例。
在下文中一共展示了ReadWriteTransaction.submit方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: copyToParent
import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction; //导入方法依赖的package包/类
void copyToParent(InstanceIdentifier<T> identifier, T data, boolean create,
ReadWriteTransaction tx) throws ReadFailedException {
InstanceIdentifier<Node> parent = getHAParent(identifier);
if (parent == null) {
return;
}
if (clazz == RemoteUcastMacs.class) {
LOG.trace("Skipping remote ucast macs to parent");
}
LOG.trace("Copy child op data {} to parent {} create:{}", mergeCommand.getDescription(),
getNodeId(parent), create);
data = (T) mergeCommand.transform(parent, data);
identifier = mergeCommand.generateId(parent, data);
writeToMdsal(create, tx, data, identifier, false);
tx.submit();
}
示例3: copyToChild
import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction; //导入方法依赖的package包/类
void copyToChild(final InstanceIdentifier<T> parentIdentifier,final T parentData,
final boolean create,final ReadWriteTransaction tx)
throws ReadFailedException {
Set<InstanceIdentifier<Node>> children = getChildrenForHANode(parentIdentifier);
if (children == null) {
return;
}
for (InstanceIdentifier<Node> child : children) {
LOG.trace("Copy parent config data {} to child {} create:{} ", mergeCommand.getDescription(),
getNodeId(child), create);
final T childData = (T) mergeCommand.transform(child, parentData);
final InstanceIdentifier<T> identifier = mergeCommand.generateId(child, childData);
writeToMdsal(create, tx, childData, identifier, true);
}
tx.submit();
}
示例4: onParentAdded
import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction; //导入方法依赖的package包/类
@Override
protected void onParentAdded(final DataTreeModification<Node> modification) {
InstanceIdentifier<Node> nodeIid = modification.getRootPath().getRootIdentifier();
if (IS_PS_NODE_IID.test(nodeIid)) {
return;
}
ReadWriteTransaction tx = dataBroker.newReadWriteTransaction();
haOpClusteredListener.onGlobalNodeAdd(nodeIid, modification.getRootNode().getDataAfter(), tx);
tx.submit();
if (IS_HA_CHILD.test(nodeIid)) {
return;
}
LOG.trace("On parent add {}", nodeIid);
Node operNode = modification.getRootNode().getDataAfter();
Optional<Node> configNode = MDSALUtil.read(dataBroker, LogicalDatastoreType.CONFIGURATION, nodeIid);
Set<LocalUcastMacs> configMacs = getMacs(configNode);
Set<LocalUcastMacs> operMacs = getMacs(Optional.of(operNode));
Set<LocalUcastMacs> staleMacs = Sets.difference(configMacs, operMacs);
staleMacs.forEach(staleMac -> removed(getMacIid(nodeIid, staleMac), staleMac));
}
示例5: unregisterEndpoint
import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction; //导入方法依赖的package包/类
@Override
public Future<RpcResult<Void>> unregisterEndpoint(UnregisterEndpointInput input) {
final RpcResult<Void> result = RpcResultBuilder.<Void>success().build();
if ( input == null) {
return Futures.immediateFailedCheckedFuture(new IllegalArgumentException("Endpoint can not be empty!"));
}
final List<Uuid> toBeDeletedList = input.getIds();
if ( toBeDeletedList == null || toBeDeletedList.isEmpty()) {
return Futures.immediateFuture(result);
}
ReadWriteTransaction trans = dataBroker.newReadWriteTransaction();
for (Uuid ep : toBeDeletedList) {
InstanceIdentifier<Endpoint> eppath = Constants.DOM_ENDPOINTS_PATH
.child(Endpoint.class, new EndpointKey(ep));
trans.delete(LogicalDatastoreType.OPERATIONAL, eppath);
}
CheckedFuture<Void,TransactionCommitFailedException> future = trans.submit();
return Futures.transformAsync(future, (AsyncFunction<Void, RpcResult<Void>>) input1 -> Futures.immediateFuture(result), executor);
}
示例6: writeGroup
import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction; //导入方法依赖的package包/类
private void writeGroup(GroupBuilder groupBuilder, NodeBuilder nodeBuilder) {
DataBroker databroker = getDataBroker();
ReadWriteTransaction modification = databroker.newReadWriteTransaction();
InstanceIdentifier<Group> path1 = InstanceIdentifier.builder(Nodes.class)
.child(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node.class,
nodeBuilder.getKey())
.augmentation(FlowCapableNode.class).child(Group.class, new GroupKey(groupBuilder.getGroupId()))
.build();
// modification.put(LogicalDatastoreType.CONFIGURATION, path1,
// groupBuilder.build(), true /*createMissingParents*/);
modification.merge(LogicalDatastoreType.CONFIGURATION, path1, groupBuilder.build(),
true /* createMissingParents */);
CheckedFuture<Void, TransactionCommitFailedException> commitFuture = modification.submit();
try {
commitFuture.get();
LOG.debug("Transaction success for write of Group " + groupBuilder.getGroupName());
} catch (InterruptedException | ExecutionException e) {
LOG.error(e.getMessage(), e);
}
}
示例7: 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);
}
}
示例8: 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);
}
}
示例9: updateElanWithVpnInfo
import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction; //导入方法依赖的package包/类
public void updateElanWithVpnInfo(String elanInstanceName, VpnInstance vpnInstance, Operation operation) {
String vpnName = vpnInstance.getVpnInstanceName();
InstanceIdentifier<ElanInstance> elanIid = ElanHelper.getElanInstanceConfigurationDataPath(elanInstanceName);
ReadWriteTransaction transaction = dataBroker.newReadWriteTransaction();
Optional<ElanInstance> elanInstanceOptional = Optional.absent();
try {
elanInstanceOptional = transaction.read(LogicalDatastoreType.CONFIGURATION, elanIid).checkedGet();
} catch (ReadFailedException e) {
LOG.error("updateElanWithVpnInfo throws ReadFailedException e {}", e);
}
if (!elanInstanceOptional.isPresent()) {
return;
}
EvpnAugmentationBuilder evpnAugmentationBuilder = new EvpnAugmentationBuilder();
ElanInstanceBuilder elanInstanceBuilder = new ElanInstanceBuilder(elanInstanceOptional.get());
if (elanInstanceBuilder.getAugmentation(EvpnAugmentation.class) != null) {
evpnAugmentationBuilder =
new EvpnAugmentationBuilder(elanInstanceBuilder.getAugmentation(EvpnAugmentation.class));
}
if (operation == Operation.ADD) {
evpnAugmentationBuilder.setEvpnName(vpnName);
LOG.debug("Writing Elan-EvpnAugmentation with key {}", elanInstanceName);
} else {
evpnAugmentationBuilder.setEvpnName(null);
LOG.debug("Deleting Elan-EvpnAugmentation with key {}", elanInstanceName);
}
elanInstanceBuilder.addAugmentation(EvpnAugmentation.class, evpnAugmentationBuilder.build());
transaction.put(LogicalDatastoreType.CONFIGURATION, elanIid, elanInstanceBuilder.build(),
WriteTransaction.CREATE_MISSING_PARENTS);
transaction.submit();
}
示例10: locateEndpoint
import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction; //导入方法依赖的package包/类
@Override
public Future<RpcResult<Void>> locateEndpoint(LocateEndpointInput input) {
final RpcResult<Void> result = RpcResultBuilder.<Void>success().build();
if ( input == null) {
return Futures.immediateFailedCheckedFuture(new IllegalArgumentException("endpoint can not be empty!"));
}
final Uuid epId = input.getEndpointId();
if ( epId == null ) {
return Futures.immediateFailedCheckedFuture(new IllegalArgumentException("endpoint can not be empty!"));
}
final FabricId fabricid = input.getFabricId();
final FabricInstance fabricObj = FabricInstanceCache.INSTANCE.retrieveFabric(fabricid);
if (fabricObj == null) {
return Futures.immediateFailedFuture(new IllegalArgumentException("fabric is not exist!"));
}
ReadWriteTransaction trans = dataBroker.newReadWriteTransaction();
EndpointBuilder epBuilder = new EndpointBuilder();
LocationBuilder locBuilder = new LocationBuilder(input.getLocation());
epBuilder.setEndpointUuid(epId);
epBuilder.setLocation(locBuilder.build());
final InstanceIdentifier<Endpoint> eppath = Constants.DOM_ENDPOINTS_PATH
.child(Endpoint.class, new EndpointKey(epId));
trans.merge(LogicalDatastoreType.OPERATIONAL, eppath, epBuilder.build());
CheckedFuture<Void,TransactionCommitFailedException> future = trans.submit();
return Futures.transformAsync(future, (AsyncFunction<Void, RpcResult<Void>>) input1 -> Futures.immediateFuture(result), executor);
}
示例11: removeDpnFromDataStore
import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction; //导入方法依赖的package包/类
/**
* Removes a DPN from the data store
* @param dsType - Data store type
* @param nodeId - Node Id of the DPN
* @param networkId - Network Id of the DPN
*/
private void removeDpnFromDataStore(LogicalDatastoreType dsType, String nodeId, String networkId){
if(dataBroker!=null){
FpcTopology topo = tenant.getFpcTopology();
if(topo != null){
FpcDpnId dpnId = getDpnId(nodeId,networkId);
if(dpnId == null)
return;
ReadWriteTransaction dpnTx = dataBroker.newReadWriteTransaction();
try {
Optional<Dpns> dpn = dpnTx.read(dsType, InstanceIdentifier.builder(Tenants.class)
.child(Tenant.class, tenant.getKey())
.child(FpcTopology.class)
.child(Dpns.class, new DpnsKey(new FpcDpnId(dpnId)))
.build()).get();
dpnTx.delete(dsType, InstanceIdentifier.builder(Tenants.class)
.child(Tenant.class, tenant.getKey())
.child(FpcTopology.class)
.child(Dpns.class, new DpnsKey(new FpcDpnId(dpnId)))
.build());
CheckedFuture<Void,TransactionCommitFailedException> submitFuture = dpnTx.submit();
Futures.addCallback(submitFuture, new FutureCallback<Void>() {
@Override
public void onSuccess(final Void result) {
// Commited successfully
LOG.info("Dpn (nodeId = "+nodeId+") was deleted successfully");
// ArrayList<Uri> uris = new ArrayList<Uri>();
// for( Entry<String, TenantManager> entry: clientIdToTenants.entrySet()){
// if(entry.getValue().getTenant().getTenantId().getString().equals(FpcProvider.getInstance().getConfig().getDefaultTenantId())){
// uris.add(FpcServiceImpl.getNotificationUri(entry.getKey()));
// }
// }
if(dsType.equals(LogicalDatastoreType.CONFIGURATION))
Notifier.issueDpnAvailabilityNotification(
new DpnAvailabilityBuilder()
.setMessageType("Dpn-Availability")
.setDpnStatus(DpnStatusValue.DpnStatus.Unavailable)
.setDpnId(new FpcDpnId(dpnId))
.setDpnGroups(dpn.get().getDpnGroups())
.setDpnName(dpn.get().getDpnName())
.setNetworkId(networkId)
.setNodeId(nodeId)
.build()
);
}
@Override
public void onFailure(final Throwable t) {
// Transaction failed
if(t instanceof OptimisticLockFailedException) {
// Failed because of concurrent transaction modifying same data
LOG.info("OptimisticLockFailedException while deleteing the DPN (nodeId = "+nodeId+") from the Data store.");
} else {
// Some other type of TransactionCommitFailedException
LOG.info("Other exception while deleteing the DPN (nodeId = "+nodeId+") from the Data store.");
}
}
});
} catch (InterruptedException | ExecutionException e) {
ErrorLog.logError(e.getStackTrace());
}
}
}
}
示例12: 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();
}
示例13: composeFabric
import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction; //导入方法依赖的package包/类
@Override
public Future<RpcResult<ComposeFabricOutput>> composeFabric(final ComposeFabricInput input) {
ComposeFabricInputBuilder inputBuilder = new ComposeFabricInputBuilder(input);
String msg = null;
if ((msg = checkFabricOptions(inputBuilder)) != null) {
return Futures.immediateFailedCheckedFuture(new IllegalArgumentException(msg));
}
final FabricId fabricId = new FabricId(String.format("fabric:%d", this.genNextFabricNum()));
final InstanceIdentifier<Node> fnodepath = MdSalUtils.createFNodeIId(fabricId);
final InstanceIdentifier<FabricNode> fabricpath = fnodepath.augmentation(FabricNode.class);
NodeBuilder fnodeBuilder = new NodeBuilder();
buildNodeAttribute(fnodeBuilder, input, fabricId);
FabricNodeBuilder fabricBuilder = new FabricNodeBuilder();
FabricAttributeBuilder attrBuilder = new FabricAttributeBuilder();
buildFabricAttribute(attrBuilder, inputBuilder);
FabricRendererFactory rendererFactory = rendererMgr.getFabricRendererFactory(input.getType());
FabricRenderer renderer = rendererFactory.composeFabric(fabricpath, attrBuilder, input);
if (renderer == null) {
return Futures.immediateFailedCheckedFuture(
new RuntimeException("Can not compose fabric due the renderer return false."));
}
fabricBuilder.setFabricAttribute(attrBuilder.build());
FabricInstance fabric = FabricInstanceCache.INSTANCE.addFabric(fabricId, input.getType(), renderer);
fabric.addListener(rendererFactory.createListener(fabricpath, fabricBuilder.getFabricAttribute()));
final FabricNode fabricNode = fabricBuilder.build();
fnodeBuilder.addAugmentation(FabricNode.class, fabricNode);
ReadWriteTransaction trans = dataBroker.newReadWriteTransaction();
trans.put(LogicalDatastoreType.OPERATIONAL, fnodepath, fnodeBuilder.build(), true);
trans.put(LogicalDatastoreType.CONFIGURATION, fnodepath, fnodeBuilder.build(), true);
trans.put(LogicalDatastoreType.OPERATIONAL, MdSalUtils.createTopoIId(fabricId.getValue()),
MdSalUtils.newTopo(fabricId.getValue()));
CheckedFuture<Void,TransactionCommitFailedException> future = trans.submit();
return Futures.transform(future, submitResult -> {
RpcResultBuilder<ComposeFabricOutput> resultBuilder = RpcResultBuilder.<ComposeFabricOutput>success();
ComposeFabricOutputBuilder outputBuilder = new ComposeFabricOutputBuilder();
outputBuilder.setFabricId(fabricId);
FabricInstanceCache.INSTANCE.retrieveFabric(fabricId).notifyFabricCreated(fabricNode);
return resultBuilder.withResult(outputBuilder.build()).build();
}, MoreExecutors.directExecutor());
}
示例14: rmNodeFromFabric
import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction; //导入方法依赖的package包/类
@Override
public Future<RpcResult<Void>> rmNodeFromFabric(RmNodeFromFabricInput input) {
final RpcResult<Void> result = RpcResultBuilder.<Void>success().build();
FabricId fabricId = input.getFabricId();
final NodeRef device = input.getNodeRef();
final FabricInstance fabricObj = FabricInstanceCache.INSTANCE.retrieveFabric(fabricId);
if (fabricObj == null) {
return Futures.immediateFailedFuture(new IllegalArgumentException("fabric is not exist!"));
}
ReadWriteTransaction trans = dataBroker.newReadWriteTransaction();
// del fabric attribute
InstanceIdentifier<DeviceNodes> devicepath = Constants.DOM_FABRICS_PATH
.child(Node.class, new NodeKey(fabricId)).augmentation(FabricNode.class)
.child(FabricAttribute.class)
.child(DeviceNodes.class, new DeviceNodesKey(device));
trans.delete(LogicalDatastoreType.OPERATIONAL, devicepath);
// del node attribute
@SuppressWarnings("unchecked")
InstanceIdentifier<Node> noderef = (InstanceIdentifier<Node>) device.getValue();
NodeId deviceid = noderef.firstKeyOf(Node.class).getNodeId();
TopologyId topoid = noderef.firstKeyOf(Topology.class).getTopologyId();
InstanceIdentifier<SupportingNode> suplNodeIid = MdSalUtils.createFNodeIId(input.getFabricId())
.child(SupportingNode.class, new SupportingNodeKey(deviceid, topoid));
trans.delete(LogicalDatastoreType.OPERATIONAL, suplNodeIid);
CheckedFuture<Void,TransactionCommitFailedException> future = trans.submit();
return Futures.transformAsync(future, new AsyncFunction<Void, RpcResult<Void>>() {
@SuppressWarnings("unchecked")
@Override
public ListenableFuture<RpcResult<Void>> apply(Void submitResult) throws Exception {
fabricObj.notifyDeviceRemoved((InstanceIdentifier<Node>) device.getValue());
return Futures.immediateFuture(result);
}
});
}
示例15: registerEndpoint
import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction; //导入方法依赖的package包/类
@Override
public Future<RpcResult<RegisterEndpointOutput>> registerEndpoint(RegisterEndpointInput input) {
final RpcResultBuilder<RegisterEndpointOutput> resultBuilder =
RpcResultBuilder.<RegisterEndpointOutput>success();
final RegisterEndpointOutputBuilder outputBuilder = new RegisterEndpointOutputBuilder();
final FabricId fabricid = input.getFabricId();
final FabricInstance fabricObj = FabricInstanceCache.INSTANCE.retrieveFabric(fabricid);
if (fabricObj == null) {
return Futures.immediateFailedFuture(new IllegalArgumentException("fabric is not exist!"));
}
Uuid epId = input.getEndpointUuid();
if (epId == null) {
epId = new Uuid(UUID.randomUUID().toString());
}
final Uuid newepId = epId;
final InstanceIdentifier<Endpoint> eppath = Constants.DOM_ENDPOINTS_PATH
.child(Endpoint.class, new EndpointKey(newepId));
EndpointBuilder epBuilder = new EndpointBuilder();
epBuilder.setEndpointUuid(newepId);
epBuilder.setGateway(input.getGateway());
epBuilder.setIpAddress(input.getIpAddress());
epBuilder.setLocation(input.getLocation());
epBuilder.setLogicalLocation(input.getLogicalLocation());
epBuilder.setMacAddress(input.getMacAddress());
epBuilder.setPublicIp(input.getPublicIp());
epBuilder.setOwnFabric(fabricid);
ReadWriteTransaction trans = dataBroker.newReadWriteTransaction();
trans.put(LogicalDatastoreType.OPERATIONAL, eppath, epBuilder.build(), true);
CheckedFuture<Void,TransactionCommitFailedException> future = trans.submit();
return Futures.transformAsync(future, input1 -> {
outputBuilder.setEndpointId(newepId);
return Futures.immediateFuture(resultBuilder.withResult(outputBuilder.build()).build());
}, executor);
}