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


Java DataBroker.newReadOnlyTransaction方法代码示例

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


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

示例1: testToasterInitOnStartUp

import org.opendaylight.controller.md.sal.binding.api.DataBroker; //导入方法依赖的package包/类
@Test
public void testToasterInitOnStartUp() throws Exception {
    DataBroker broker = getDataBroker();

    ReadOnlyTransaction readTx = broker.newReadOnlyTransaction();
    Optional<Toaster> optional = readTx.read(LogicalDatastoreType.OPERATIONAL, TOASTER_IID).get();
    assertNotNull(optional);
    assertTrue("Operational toaster not present", optional.isPresent());

    Toaster toasterData = optional.get();

    assertEquals(Toaster.ToasterStatus.Up, toasterData.getToasterStatus());
    assertEquals(new DisplayString("Opendaylight"), toasterData.getToasterManufacturer());
    assertEquals(new DisplayString("Model 1 - Binding Aware"), toasterData.getToasterModelNumber());

    Optional<Toaster> configToaster = readTx.read(LogicalDatastoreType.CONFIGURATION, TOASTER_IID).get();
    assertFalse("Didn't expect config data for toaster.", configToaster.isPresent());
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:19,代码来源:OpenDaylightToasterTest.java

示例2: getSubnetMapBuilder

import org.opendaylight.controller.md.sal.binding.api.DataBroker; //导入方法依赖的package包/类
private SubnetmapBuilder getSubnetMapBuilder(DataBroker broker, Uuid subnetId) {
    SubnetmapBuilder builder = null ;
    InstanceIdentifier<Subnetmap> id = InstanceIdentifier.builder(Subnetmaps.class)
            .child(Subnetmap.class, new SubnetmapKey(subnetId)).build();
    ReadOnlyTransaction tx = broker.newReadOnlyTransaction();

    Optional<Subnetmap> sn ;
    try {
        sn = tx.read(LogicalDatastoreType.CONFIGURATION, id).get();
    } catch (InterruptedException | ExecutionException e) {
        throw new RuntimeException(e);
    }

    if (sn.isPresent()) {
        builder = new SubnetmapBuilder(sn.get());
    } else {
        builder = new SubnetmapBuilder().setKey(new SubnetmapKey(subnetId)).setId(subnetId);
    }
    return builder;
}
 
开发者ID:opendaylight,项目名称:netvirt,代码行数:21,代码来源:DhcpSubnetListener.java

示例3: validateGreetingRegistry

import org.opendaylight.controller.md.sal.binding.api.DataBroker; //导入方法依赖的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());
}
 
开发者ID:lrodrin,项目名称:opendaylight,代码行数:16,代码来源:HelloIT.java

示例4: readInitialAppConfig

import org.opendaylight.controller.md.sal.binding.api.DataBroker; //导入方法依赖的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());
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:29,代码来源:DataStoreAppConfigMetadata.java

示例5: read

import org.opendaylight.controller.md.sal.binding.api.DataBroker; //导入方法依赖的package包/类
/**
 * Retrieves the object from the datastore.
 * @param broker the data broker.
 * @param datastoreType the data store type.
 * @param path the wild card path.
 * @param <T> type of DataObject
 * @return the required object.
 */
public static <T extends DataObject> Optional<T> read(
        DataBroker broker, LogicalDatastoreType datastoreType, InstanceIdentifier<T> path) {
    try (ReadOnlyTransaction tx = broker.newReadOnlyTransaction()) {
        return tx.read(datastoreType, path).checkedGet();
    } catch (ReadFailedException e) {
        LOG.error("Failed to read InstanceIdentifier {} from {}", path, datastoreType, e);
        return Optional.absent();
    }
}
 
开发者ID:opendaylight,项目名称:netvirt,代码行数:18,代码来源:AclServiceUtils.java

示例6: read

import org.opendaylight.controller.md.sal.binding.api.DataBroker; //导入方法依赖的package包/类
@SuppressWarnings("checkstyle:IllegalCatch")
public static <T extends DataObject> Optional<T> read(DataBroker broker, LogicalDatastoreType datastoreType,
                                                      InstanceIdentifier<T> path) {
    ReadOnlyTransaction tx = broker.newReadOnlyTransaction();

    try {
        return tx.read(datastoreType, path).get();
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:opendaylight,项目名称:netvirt,代码行数:12,代码来源:ExternalRoutersListener.java

示例7: read

import org.opendaylight.controller.md.sal.binding.api.DataBroker; //导入方法依赖的package包/类
private static <T extends DataObject> com.google.common.base.Optional<T> read(DataBroker broker,
        LogicalDatastoreType datastoreType, InstanceIdentifier<T> path) {
    try (ReadOnlyTransaction tx = broker.newReadOnlyTransaction()) {
        return tx.read(datastoreType, path).get();
    } catch (InterruptedException | ExecutionException e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:opendaylight,项目名称:netvirt,代码行数:9,代码来源:FibHelper.java

示例8: read

import org.opendaylight.controller.md.sal.binding.api.DataBroker; //导入方法依赖的package包/类
public static <T extends DataObject> Optional<T> read(DataBroker broker, LogicalDatastoreType datastoreType,
                                                      InstanceIdentifier<T> path) {
    try (ReadOnlyTransaction tx = broker.newReadOnlyTransaction()) {
        return tx.read(datastoreType, path).get();
    } catch (InterruptedException | ExecutionException e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:opendaylight,项目名称:netvirt,代码行数:9,代码来源:VpnUtil.java

示例9: read

import org.opendaylight.controller.md.sal.binding.api.DataBroker; //导入方法依赖的package包/类
public static <T extends DataObject> Optional<T> read(DataBroker dataBroker, LogicalDatastoreType datastoreType,
        InstanceIdentifier<T> path) {

    ReadOnlyTransaction tx = dataBroker.newReadOnlyTransaction();

    Optional<T> result;
    try {
        result = tx.read(datastoreType, path).get();
    } catch (InterruptedException | ExecutionException e) {
        LOG.debug("read: Error while reading data from path {}", path);
        throw new RuntimeException(e);
    }
    return result;
}
 
开发者ID:opendaylight,项目名称:netvirt,代码行数:15,代码来源:TransactionUtil.java

示例10: read

import org.opendaylight.controller.md.sal.binding.api.DataBroker; //导入方法依赖的package包/类
/**
 * Read utility.
 *
 * @deprecated Consider using {@link #read2(LogicalDatastoreType, InstanceIdentifier)} with proper exception
 *             handling instead
 */
@Deprecated
@SuppressWarnings("checkstyle:IllegalCatch")
public static <T extends DataObject> Optional<T> read(@Nonnull DataBroker broker,
        LogicalDatastoreType datastoreType, InstanceIdentifier<T> path) {
    try (ReadOnlyTransaction tx = broker.newReadOnlyTransaction()) {
        return tx.read(datastoreType, path).get();
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:opendaylight,项目名称:netvirt,代码行数:17,代码来源:ElanUtils.java


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