当前位置: 首页>>代码示例>>Java>>正文


Java ReadOnlyTransaction.close方法代码示例

本文整理汇总了Java中org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction.close方法的典型用法代码示例。如果您正苦于以下问题:Java ReadOnlyTransaction.close方法的具体用法?Java ReadOnlyTransaction.close怎么用?Java ReadOnlyTransaction.close使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction的用法示例。


在下文中一共展示了ReadOnlyTransaction.close方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: readNodes

import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction; //导入方法依赖的package包/类
public void readNodes() throws Exception {
    ReadOnlyTransaction tx = this.dataBroker.newReadOnlyTransaction();
    d1GlobalOpNode = TestUtil.readNode(OPERATIONAL, d1NodePath, tx);
    d2GlobalOpNode = TestUtil.readNode(OPERATIONAL, d2NodePath, tx);
    haGlobalOpNode = TestUtil.readNode(OPERATIONAL, haNodePath, tx);

    d1PsOpNode = TestUtil.readNode(OPERATIONAL, d1PsNodePath, tx);
    d2PsOpNode = TestUtil.readNode(OPERATIONAL, d2PsNodePath, tx);
    haPsOpNode = TestUtil.readNode(OPERATIONAL, haPsNodePath, tx);

    haGlobalConfigNode = TestUtil.readNode(CONFIGURATION, haNodePath, tx);
    d1GlobalConfigNode = TestUtil.readNode(CONFIGURATION, d1NodePath, tx);
    d2GlobalConfigNode = TestUtil.readNode(CONFIGURATION, d2NodePath, tx);

    haPsConfigNode = TestUtil.readNode(CONFIGURATION, haPsNodePath, tx);
    d1PsConfigNode = TestUtil.readNode(CONFIGURATION, d1PsNodePath, tx);
    d2PsConfigNode = TestUtil.readNode(CONFIGURATION, d2PsNodePath, tx);

    tx.close();
}
 
开发者ID:opendaylight,项目名称:netvirt,代码行数:21,代码来源:NodeConnectedHandlerTest.java

示例2: 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;
}
 
开发者ID:opendaylight,项目名称:faas,代码行数:29,代码来源:MdsalUtils.java

示例3: 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;
}
 
开发者ID:opendaylight,项目名称:nic,代码行数:31,代码来源:MdsalUtils.java

示例4: 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;
}
 
开发者ID:opendaylight,项目名称:neutron,代码行数:21,代码来源:NeutronLoadBalancerPoolInterface.java

示例5: 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;
}
 
开发者ID:opendaylight,项目名称:ovsdb,代码行数:33,代码来源:MdsalUtilsAsync.java

示例6: 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;
}
 
开发者ID:opendaylight,项目名称:ovsdb,代码行数:29,代码来源:MdsalUtils.java

示例7: 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;
    }
}
 
开发者ID:opendaylight,项目名称:ovsdb,代码行数:19,代码来源:OvsdbConnectionManager.java

示例8: 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;
}
 
开发者ID:opendaylight,项目名称:ovsdb,代码行数:24,代码来源:TerminationPointCreateCommand.java

示例9: getLinksFromTopology

import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction; //导入方法依赖的package包/类
private List<Link> getLinksFromTopology() {
    InstanceIdentifier<Topology> topologyInstanceIdentifier = InstanceIdentifier.builder(NetworkTopology.class)
            .child(Topology.class, new TopologyKey(new TopologyId("flow:1")))
            .build();
    Topology topology = null;
    ReadOnlyTransaction readOnlyTransaction = db.newReadOnlyTransaction();
    try {
        Optional<Topology> topologyOptional = readOnlyTransaction.read(LogicalDatastoreType.OPERATIONAL, topologyInstanceIdentifier).get();
        if(topologyOptional.isPresent()) {
            topology = topologyOptional.get();
        }
    } catch(Exception e) {
        LOG.error("Error reading topology {}", topologyInstanceIdentifier);
        readOnlyTransaction.close();
        throw new RuntimeException("Error reading from operational store, topology : " + topologyInstanceIdentifier, e);
    }
    readOnlyTransaction.close();
    if(topology == null) {
        return null;
    }
    List<Link> links = topology.getLink();
    if(links == null || links.isEmpty()) {
        return null;
    }
    List<Link> internalLinks = new ArrayList<>();
    for(Link link : links) {
        if(!(link.getLinkId().getValue().contains("host"))) {
            internalLinks.add(link);
        }
    }

    return internalLinks;
}
 
开发者ID:geopet85,项目名称:odlexample,代码行数:34,代码来源:NetworkGraphImpl.java

示例10: readData

import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction; //导入方法依赖的package包/类
public static <T extends DataObject> T readData(DataBroker dataBroker, LogicalDatastoreType dataStoreType, InstanceIdentifier<T> iid) {
    Preconditions.checkNotNull(dataBroker);
    ReadOnlyTransaction readTransaction = dataBroker.newReadOnlyTransaction();
    try {
        Optional<T> optionalData = readTransaction.read(dataStoreType, iid).get();
        if (optionalData.isPresent()) {
            return (T)optionalData.get();
        }
    } catch (ExecutionException | InterruptedException e) {
        logger.error("Read transaction for identifier {} failed with error {}", iid, e.getMessage());
        readTransaction.close();
    }
    return null;
}
 
开发者ID:sdnhub,项目名称:SDNHub_Opendaylight_Tutorial,代码行数:15,代码来源:GenericTransactionUtils.java

示例11: getManagingNode

import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction; //导入方法依赖的package包/类
public static Optional<HwvtepGlobalAugmentation> getManagingNode(DataBroker db, HwvtepGlobalRef ref) {
    try {
        ReadOnlyTransaction transaction = db.newReadOnlyTransaction();
        @SuppressWarnings("unchecked")
        // Note: erasure makes this safe in combination with the typecheck
        // below
        InstanceIdentifier<Node> path = (InstanceIdentifier<Node>) ref.getValue();

        CheckedFuture<Optional<Node>, ReadFailedException> nf =
                        transaction.read(LogicalDatastoreType.OPERATIONAL, path);
        transaction.close();
        Optional<Node> optional = nf.get();
        if (optional != null && optional.isPresent()) {
            HwvtepGlobalAugmentation hwvtepNode = null;
            Node node = optional.get();
            if (node instanceof HwvtepGlobalAugmentation) {
                hwvtepNode = (HwvtepGlobalAugmentation) node;
            } else if (node != null) {
                hwvtepNode = node.getAugmentation(HwvtepGlobalAugmentation.class);
            }
            if (hwvtepNode != null) {
                return Optional.of(hwvtepNode);
            } else {
                LOG.warn("Hwvtep switch claims to be managed by {} but " + "that HwvtepNode does not exist",
                                ref.getValue());
                return Optional.absent();
            }
        } else {
            LOG.warn("Mysteriously got back a thing which is *not* a topology Node: {}", optional);
            return Optional.absent();
        }
    } catch (Exception e) {
        LOG.warn("Failed to get HwvtepNode {}", ref, e);
        return Optional.absent();
    }
}
 
开发者ID:opendaylight,项目名称:ovsdb,代码行数:37,代码来源:HwvtepSouthboundUtil.java


注:本文中的org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction.close方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。