本文整理汇总了Java中org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction.merge方法的典型用法代码示例。如果您正苦于以下问题:Java ReadWriteTransaction.merge方法的具体用法?Java ReadWriteTransaction.merge怎么用?Java ReadWriteTransaction.merge使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction
的用法示例。
在下文中一共展示了ReadWriteTransaction.merge方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: copyChildPSOpToHAPS
import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction; //导入方法依赖的package包/类
/**
* Copy child physical switch node data to HA physical switch data of Operational data tree.
*
* @param childPsNode HA child PS node
* @param haPath HA node path
* @param haPspath Ha Physical Switch Node path
* @param tx Transaction
* @throws ReadFailedException Exception thrown if read fails
* @throws ExecutionException Exception thrown if Execution fail
* @throws InterruptedException Thread interrupted Exception
*/
public void copyChildPSOpToHAPS(Node childPsNode,
InstanceIdentifier<Node> haPath,
InstanceIdentifier<Node> haPspath,
ReadWriteTransaction tx)
throws InterruptedException, ExecutionException, ReadFailedException {
NodeBuilder haPSNodeBuilder = HwvtepHAUtil.getNodeBuilderForPath(haPspath);
PhysicalSwitchAugmentationBuilder dstBuilder = new PhysicalSwitchAugmentationBuilder();
PhysicalSwitchAugmentation src = childPsNode.getAugmentation(PhysicalSwitchAugmentation.class);
Node existingHAPSNode = HwvtepHAUtil.readNode(tx, OPERATIONAL, haPspath);
PhysicalSwitchAugmentation existingHAPSAugumentation =
HwvtepHAUtil.getPhysicalSwitchAugmentationOfNode(existingHAPSNode);
psAugmentationMerger.mergeOperationalData(dstBuilder, existingHAPSAugumentation, src, haPath);
psNodeMerger.mergeOperationalData(haPSNodeBuilder, existingHAPSNode, childPsNode, haPath);
mergeOpManagedByAttributes(src, dstBuilder, haPath);
haPSNodeBuilder.addAugmentation(PhysicalSwitchAugmentation.class, dstBuilder.build());
Node haPsNode = haPSNodeBuilder.build();
tx.merge(OPERATIONAL, haPspath, haPsNode, true);
}
示例2: buildGlobalConfigForHANode
import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction; //导入方法依赖的package包/类
/**
* Build HA Global node from child nodes in config data tress.
*
* @param tx Transaction
* @param childNode Child Node object
* @param haNodePath Ha node path
* @param haGlobalCfg HA global node object
*/
public static void buildGlobalConfigForHANode(ReadWriteTransaction tx,
Node childNode,
InstanceIdentifier<Node> haNodePath,
Optional<Node> haGlobalCfg) {
NodeBuilder nodeBuilder = new NodeBuilder();
HwvtepGlobalAugmentationBuilder hwvtepGlobalBuilder = new HwvtepGlobalAugmentationBuilder();
hwvtepGlobalBuilder.setSwitches(buildSwitchesForHANode(childNode, haNodePath, haGlobalCfg));
hwvtepGlobalBuilder.setManagers(buildManagersForHANode(childNode, haGlobalCfg));
nodeBuilder.setNodeId(haNodePath.firstKeyOf(Node.class).getNodeId());
nodeBuilder.addAugmentation(HwvtepGlobalAugmentation.class, hwvtepGlobalBuilder.build());
Node configHANode = nodeBuilder.build();
tx.merge(CONFIGURATION, haNodePath, configHANode,Boolean.TRUE);
}
示例3: 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);
}
}
示例4: ensureNodePresent
import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction; //导入方法依赖的package包/类
private InstanceIdentifier<IgpNodeAttributes> ensureNodePresent(final ReadWriteTransaction trans, final NodeId ni) {
final NodeUsage present = this.nodes.get(ni);
if (present != null) {
return present.attrId;
}
final KeyedInstanceIdentifier<Node, NodeKey> nii = nodeInstanceId(ni);
final InstanceIdentifier<IgpNodeAttributes> ret = nii.builder().augmentation(Node1.class)
.child(IgpNodeAttributes.class).build();
trans.merge(LogicalDatastoreType.OPERATIONAL, nii, new NodeBuilder().setKey(nii.getKey()).setNodeId(ni)
.addAugmentation(Node1.class, new Node1Builder().setIgpNodeAttributes(
new IgpNodeAttributesBuilder().setPrefix(Collections.emptyList()).build()).build()).build());
this.nodes.put(ni, new NodeUsage(ret));
return ret;
}
示例5: updateController
import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction; //导入方法依赖的package包/类
/**
* Update the ControllerEntry values for the given {@link Bridge} list.
*
* <p>
* Controller and Bridge are independent tables in the Open_vSwitch schema
* but the OVSDB yang model includes the Controller fields in the
* Bridge data. In some cases the OVSDB will send Bridge and Controller
* updates together and in other cases independently. This method here
* assumes the former.
* </p>
*
* @param transaction the {@link ReadWriteTransaction}
* @param newUpdatedControllerRows updated {@link Controller} rows
* @param newUpdatedBridgeRows updated {@link Bridge} rows
*/
private void updateController(ReadWriteTransaction transaction,
Map<UUID, Controller> newUpdatedControllerRows,
Map<UUID, Bridge> newUpdatedBridgeRows) {
for (Map.Entry<UUID, Bridge> bridgeEntry : newUpdatedBridgeRows.entrySet()) {
final List<ControllerEntry> controllerEntries =
SouthboundMapper.createControllerEntries(bridgeEntry.getValue(), newUpdatedControllerRows);
for (ControllerEntry controllerEntry : controllerEntries) {
transaction.merge(LogicalDatastoreType.OPERATIONAL,
getControllerEntryIid(controllerEntry, bridgeEntry.getValue().getNameColumn().getData()),
controllerEntry);
}
}
}
示例6: updateManagers
import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction; //导入方法依赖的package包/类
/**
* Update the Manager values for the given {@link OpenVSwitch} list.
*
* <p>
* Manager and OpenVSwitch are independent tables in the Open_vSwitch schema
* but the OVSDB yang model includes the Manager fields in the
* OVSDB Node data. In some cases the OVSDB will send OpenVSwitch and Manager
* updates together and in other cases independently. This method here
* assumes the former.
* </p>
*
* @param transaction the {@link ReadWriteTransaction}
* @param newUpdatedManagerRows updated {@link Manager} rows
* @param newUpdatedOpenVSwitchRows updated {@link OpenVSwitch} rows
*/
private void updateManagers(ReadWriteTransaction transaction,
Map<UUID, Manager> newUpdatedManagerRows,
Map<UUID, OpenVSwitch> newUpdatedOpenVSwitchRows) {
for (Map.Entry<UUID, OpenVSwitch> ovsdbNodeEntry : newUpdatedOpenVSwitchRows.entrySet()) {
final List<ManagerEntry> managerEntries =
SouthboundMapper.createManagerEntries(ovsdbNodeEntry.getValue(), newUpdatedManagerRows);
LOG.debug("Update Ovsdb Node : {} with manager entries : {}",
ovsdbNodeEntry.getValue(), managerEntries);
for (ManagerEntry managerEntry : managerEntries) {
transaction.merge(LogicalDatastoreType.OPERATIONAL,
getManagerEntryIid(managerEntry),
managerEntry);
}
}
}
示例7: execute
import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction; //导入方法依赖的package包/类
@Override
public void execute(ReadWriteTransaction transaction) {
for (Global hwvtepGlobal : updatedHwvtepRows.values()) {
final InstanceIdentifier<Node> nodePath = getInstanceIdentifier(hwvtepGlobal);
LOG.trace("Processing hardware_vtep update for nodePath: {}", nodePath);
HwvtepGlobalAugmentationBuilder hwvtepGlobalBuilder = new HwvtepGlobalAugmentationBuilder();
try {
Version version = getOvsdbConnectionInstance().getSchema(HwvtepSchemaConstants.HARDWARE_VTEP).get().getVersion();
hwvtepGlobalBuilder.setDbVersion(version.toString());
} catch (InterruptedException | ExecutionException e) {
LOG.debug("Failed to get schema version on {} due to {}",
getOvsdbConnectionInstance().getConnectionInfo(), e.getMessage());
}
hwvtepGlobalBuilder.setConnectionInfo(getConnectionInfo());
NodeBuilder nodeBuilder = new NodeBuilder();
nodeBuilder.setNodeId(getNodeId(hwvtepGlobal));
HwvtepGlobalAugmentation hwvtepGlobalAugmentation = hwvtepGlobalBuilder.build();
nodeBuilder.addAugmentation(HwvtepGlobalAugmentation.class, hwvtepGlobalAugmentation);
transaction.merge(LogicalDatastoreType.OPERATIONAL, nodePath, nodeBuilder.build());
getOvsdbConnectionInstance().setHwvtepGlobalAugmentation(hwvtepGlobalAugmentation);
}
}
示例8: mergeTopNodeSubtreeListeners
import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction; //导入方法依赖的package包/类
@Test
public void mergeTopNodeSubtreeListeners() {
TestListener topListener = createListener(CONFIGURATION, TOP, DataChangeScope.SUBTREE);
TestListener allListener = createListener(CONFIGURATION, WILDCARDED, DataChangeScope.SUBTREE, false);
TestListener fooListener = createListener(CONFIGURATION, TOP_FOO, DataChangeScope.SUBTREE);
TestListener barListener = createListener(CONFIGURATION, TOP_BAR, DataChangeScope.SUBTREE, false);
ReadWriteTransaction writeTx = getDataBroker().newReadWriteTransaction();
writeTx.merge(CONFIGURATION, TOP, top(topLevelList(TOP_BAR_KEY)));
assertCommit(writeTx.submit());
verifyBarOnlyAdded(topListener,allListener,fooListener,barListener);
}
示例9: mergeTopBarNodeSubtreeListeners
import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction; //导入方法依赖的package包/类
@Test
public void mergeTopBarNodeSubtreeListeners() {
TestListener topListener = createListener(CONFIGURATION, TOP, DataChangeScope.SUBTREE);
TestListener allListener = createListener(CONFIGURATION, WILDCARDED, DataChangeScope.SUBTREE, false);
TestListener fooListener = createListener(CONFIGURATION, TOP_FOO, DataChangeScope.SUBTREE);
TestListener barListener = createListener(CONFIGURATION, TOP_BAR, DataChangeScope.SUBTREE, false);
ReadWriteTransaction writeTx = getDataBroker().newReadWriteTransaction();
writeTx.merge(CONFIGURATION, TOP_BAR, topLevelList(TOP_BAR_KEY));
assertCommit(writeTx.submit());
verifyBarOnlyAdded(topListener,allListener,fooListener,barListener);
}
示例10: copyChildOpToHA
import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction; //导入方法依赖的package包/类
/**
* Copy HA child node to HA node of Operational data tree.
*
* @param childNode HA Child Node
* @param haNodePath HA node path
* @param tx Transaction
* @throws ReadFailedException Exception thrown if read fails
* @throws ExecutionException Exception thrown if Execution fail
* @throws InterruptedException Thread interrupted Exception
*/
private void copyChildOpToHA(Node childNode,
InstanceIdentifier<Node> haNodePath,
ReadWriteTransaction tx)
throws ReadFailedException, ExecutionException, InterruptedException {
if (childNode == null) {
return;
}
HwvtepGlobalAugmentation childData = childNode.getAugmentation(HwvtepGlobalAugmentation.class);
if (childData == null) {
return;
}
NodeBuilder haNodeBuilder = HwvtepHAUtil.getNodeBuilderForPath(haNodePath);
HwvtepGlobalAugmentationBuilder haBuilder = new HwvtepGlobalAugmentationBuilder();
Optional<Node> existingHANodeOptional = tx.read(OPERATIONAL, haNodePath).checkedGet();
Node existingHANode = existingHANodeOptional.isPresent() ? existingHANodeOptional.get() : null;
HwvtepGlobalAugmentation existingHAData = HwvtepHAUtil.getGlobalAugmentationOfNode(existingHANode);
globalAugmentationMerger.mergeOperationalData(haBuilder, existingHAData, childData, haNodePath);
globalNodeMerger.mergeOperationalData(haNodeBuilder, existingHANode, childNode, haNodePath);
haBuilder.setManagers(HwvtepHAUtil.buildManagersForHANode(childNode, existingHANodeOptional));
haBuilder.setSwitches(HwvtepHAUtil.buildSwitchesForHANode(childNode, haNodePath, existingHANodeOptional));
haNodeBuilder.addAugmentation(HwvtepGlobalAugmentation.class, haBuilder.build());
Node haNode = haNodeBuilder.build();
tx.merge(OPERATIONAL, haNodePath, haNode, true);
}
示例11: 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);
}
示例12: execute
import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction; //导入方法依赖的package包/类
@Override
public void execute(ReadWriteTransaction transaction) {
Map<UUID, OpenVSwitch> updatedOpenVSwitchRows = TyperUtils
.extractRowsUpdated(OpenVSwitch.class, getUpdates(),
getDbSchema());
Map<UUID, OpenVSwitch> deletedOpenVSwitchRows = TyperUtils
.extractRowsOld(OpenVSwitch.class, getUpdates(),
getDbSchema());
for (Entry<UUID, OpenVSwitch> entry : updatedOpenVSwitchRows.entrySet()) {
OpenVSwitch openVSwitch = entry.getValue();
final InstanceIdentifier<Node> nodePath = getInstanceIdentifier(openVSwitch);
OvsdbNodeAugmentationBuilder ovsdbNodeBuilder = new OvsdbNodeAugmentationBuilder();
setDbVersion(ovsdbNodeBuilder, openVSwitch);
setOvsVersion(ovsdbNodeBuilder, openVSwitch);
setDataPathTypes(ovsdbNodeBuilder, openVSwitch);
setInterfaceTypes(ovsdbNodeBuilder, openVSwitch);
OpenVSwitch oldEntry = deletedOpenVSwitchRows.get(entry.getKey());
setExternalIds(transaction, ovsdbNodeBuilder, oldEntry, openVSwitch);
setOtherConfig(transaction, ovsdbNodeBuilder, oldEntry, openVSwitch);
ovsdbNodeBuilder.setConnectionInfo(getConnectionInfo());
NodeBuilder nodeBuilder = new NodeBuilder();
nodeBuilder.setNodeId(getNodeId(openVSwitch));
nodeBuilder.addAugmentation(OvsdbNodeAugmentation.class,
ovsdbNodeBuilder.build());
transaction.merge(LogicalDatastoreType.OPERATIONAL, nodePath,
nodeBuilder.build());
}
}
示例13: updateQueue
import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction; //导入方法依赖的package包/类
/**
* Update the Queues values after finding the related {@OpenVSwitch} list.
* <p>
* Queue and OpenVSwitch are independent tables in the Open_vSwitch schema
* but the OVSDB yang model includes the Queue fields in the
* OvsdbNode data. In some cases the OVSDB will send OpenVSwitch and Queue
* updates together and in other cases independently. This method here
* assumes the latter.
* </p>
*
* @param transaction the {@link ReadWriteTransaction}
*/
private void updateQueue(ReadWriteTransaction transaction) {
final InstanceIdentifier<Node> nodeIId = getOvsdbConnectionInstance().getInstanceIdentifier();
final Optional<Node> ovsdbNode = SouthboundUtil.readNode(transaction, nodeIId);
if (ovsdbNode.isPresent()) {
for (Entry<UUID, Queue> entry : updatedQueueRows.entrySet()) {
Queue queue = entry.getValue();
QueuesBuilder queuesBuilder = new QueuesBuilder();
queuesBuilder.setQueueId(new Uri(getQueueId(queue)));
queuesBuilder.setQueueUuid(new Uuid(entry.getKey().toString()));
Collection<Long> dscp = queue.getDscpColumn().getData();
if (!dscp.isEmpty()) {
queuesBuilder.setDscp(dscp.iterator().next().shortValue());
}
Queue oldQueue = oldQueueRows.get(entry.getKey());
setOtherConfig(transaction, queuesBuilder, oldQueue, queue, nodeIId);
setExternalIds(transaction, queuesBuilder, oldQueue, queue, nodeIId);
Queues queues = queuesBuilder.build();
LOG.debug("Update Ovsdb Node {} with queue entries {}",ovsdbNode.get(), queues);
InstanceIdentifier<Queues> iid = nodeIId
.augmentation(OvsdbNodeAugmentation.class)
.child(Queues.class, queues.getKey());
transaction.merge(LogicalDatastoreType.OPERATIONAL,
iid, queues);
}
}
}
示例14: updateQos
import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction; //导入方法依赖的package包/类
/**
* Update the QosEntries values after finding the related
* {@link org.opendaylight.ovsdb.schema.openvswitch.OpenVSwitch} list.
* <p>
* Qos and OpenVSwitch are independent tables in the Open_vSwitch schema
* but the OVSDB yang model includes the Qos fields in the
* OvsdbNode data. In some cases the OVSDB will send OpenVSwitch and Qos
* updates together and in other cases independently. This method here
* assumes the latter.
* </p>
*
* @param transaction the {@link ReadWriteTransaction}
* @param newUpdatedQosRows updated {@link Qos} rows
*/
private void updateQos(ReadWriteTransaction transaction,
Map<UUID, Qos> newUpdatedQosRows) {
final InstanceIdentifier<Node> nodeIId = getOvsdbConnectionInstance().getInstanceIdentifier();
final Optional<Node> ovsdbNode = SouthboundUtil.readNode(transaction, nodeIId);
if (ovsdbNode.isPresent()) {
for (Entry<UUID, Qos> entry : newUpdatedQosRows.entrySet()) {
Qos qos = entry.getValue();
QosEntriesBuilder qosEntryBuilder = new QosEntriesBuilder();
qosEntryBuilder.setQosId(new Uri(getQosId(qos)));
qosEntryBuilder.setQosUuid(new Uuid(entry.getKey().toString()));
qosEntryBuilder.setQosType(
SouthboundMapper.createQosType(qos.getTypeColumn().getData()));
Qos oldQos = oldQosRows.get(entry.getKey());
setOtherConfig(transaction, qosEntryBuilder, oldQos, qos, nodeIId);
setExternalIds(transaction, qosEntryBuilder, oldQos, qos, nodeIId);
setQueueList(transaction, qosEntryBuilder, oldQos, qos, nodeIId, ovsdbNode.get());
QosEntries qosEntry = qosEntryBuilder.build();
LOG.debug("Update Ovsdb Node {} with qos entries {}",ovsdbNode.get(), qosEntry);
InstanceIdentifier<QosEntries> iid = nodeIId
.augmentation(OvsdbNodeAugmentation.class)
.child(QosEntries.class, qosEntry.getKey());
transaction.merge(LogicalDatastoreType.OPERATIONAL,
iid, qosEntry);
}
}
}
示例15: updateBridge
import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction; //导入方法依赖的package包/类
private void updateBridge(ReadWriteTransaction transaction,
Bridge bridge, InstanceIdentifier<Node> connectionIId) {
// Update the connection node to let it know it manages this bridge
Node connectionNode = buildConnectionNode(bridge);
transaction.merge(LogicalDatastoreType.OPERATIONAL, connectionIId, connectionNode);
// Update the bridge node with whatever data we are getting
InstanceIdentifier<Node> bridgeIid = getInstanceIdentifier(bridge);
Node bridgeNode = buildBridgeNode(bridge);
transaction.merge(LogicalDatastoreType.OPERATIONAL, bridgeIid, bridgeNode);
deleteEntries(transaction, protocolEntriesToRemove(bridgeIid,bridge));
deleteEntries(transaction, externalIdsToRemove(bridgeIid,bridge));
deleteEntries(transaction, bridgeOtherConfigsToRemove(bridgeIid,bridge));
}