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


Java DataBroker.newWriteOnlyTransaction方法代码示例

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


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

示例1: testSeparateWrites

import org.opendaylight.controller.md.sal.binding.api.DataBroker; //导入方法依赖的package包/类
@Test
public void testSeparateWrites() throws InterruptedException, TimeoutException, ExecutionException {

    DataBroker dataBroker = testContext.getDataBroker();

    final SettableFuture<AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject>> eventFuture =
            SettableFuture.create();
    dataBroker.registerDataChangeListener(LogicalDatastoreType.OPERATIONAL, DEEP_WILDCARDED_PATH,
        dataChangeEvent -> eventFuture.set(dataChangeEvent), DataChangeScope.SUBTREE);

    final WriteTransaction transaction = dataBroker.newWriteOnlyTransaction();
    transaction.put(LogicalDatastoreType.OPERATIONAL, NODE_0_CWU_PATH, CWU, true);
    transaction.put(LogicalDatastoreType.OPERATIONAL, NODE_0_LVU_PATH, LVU, true);
    transaction.put(LogicalDatastoreType.OPERATIONAL, NODE_1_LVU_PATH, LVU, true);
    transaction.submit().get(5, TimeUnit.SECONDS);

    AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> event = eventFuture.get(1000, TimeUnit.MILLISECONDS);

    validateEvent(event);
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:21,代码来源:WildcardedDataChangeListenerTest.java

示例2: deleteChildListenParent

import org.opendaylight.controller.md.sal.binding.api.DataBroker; //导入方法依赖的package包/类
@Test
public void deleteChildListenParent() throws InterruptedException, ExecutionException, TimeoutException {
    DataBroker dataBroker = testContext.getDataBroker();
    final WriteTransaction initTx = dataBroker.newWriteOnlyTransaction();

    initTx.put(LogicalDatastoreType.OPERATIONAL, LIST11_PATH, createList11(), true);
    initTx.submit().get(5, TimeUnit.SECONDS);

    final SettableFuture<AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject>> event = SettableFuture.create();
    dataBroker.registerDataChangeListener(LogicalDatastoreType.OPERATIONAL, LIST11_PATH,
        change -> event.set(change), DataChangeScope.SUBTREE);

    final WriteTransaction deleteTx = dataBroker.newWriteOnlyTransaction();
    deleteTx.delete(LogicalDatastoreType.OPERATIONAL, LIST11_PATH.augmentation(List11SimpleAugment.class));
    deleteTx.submit().get(5, TimeUnit.SECONDS);

    AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> receivedEvent = event.get();
    assertFalse(receivedEvent.getRemovedPaths().contains(TLL_COMPLEX_AUGMENT_PATH));
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:20,代码来源:DeleteNestedAugmentationListenParentTest.java

示例3: removeVrfEntriesByOrigin

import org.opendaylight.controller.md.sal.binding.api.DataBroker; //导入方法依赖的package包/类
/**
 * Remove from MDSAL all those VrfEntries in a VPN that have an specific RouteOrigin.
 *
 * @param broker dataBroker service reference
 * @param rd Route Distinguisher
 * @param origin Origin of the Routes to be removed (see {@link RouteOrigin})
 */
public static void removeVrfEntriesByOrigin(DataBroker broker, String rd, RouteOrigin origin) {
    InstanceIdentifier<VrfTables> vpnVrfTableIid =
        InstanceIdentifier.builder(FibEntries.class).child(VrfTables.class, new VrfTablesKey(rd)).build();
    Optional<VrfTables> vrfTablesOpc = read(broker, LogicalDatastoreType.CONFIGURATION, vpnVrfTableIid);
    if (vrfTablesOpc.isPresent()) {
        VrfTables vrfTables = vrfTablesOpc.get();
        WriteTransaction tx = broker.newWriteOnlyTransaction();
        for (VrfEntry vrfEntry : vrfTables.getVrfEntry()) {
            if (origin == RouteOrigin.value(vrfEntry.getOrigin())) {
                tx.delete(LogicalDatastoreType.CONFIGURATION,
                        vpnVrfTableIid.child(VrfEntry.class, vrfEntry.getKey()));
            }
        }
        tx.submit();
    }
}
 
开发者ID:opendaylight,项目名称:netvirt,代码行数:24,代码来源:VpnUtil.java

示例4: populateL3Vpns

import org.opendaylight.controller.md.sal.binding.api.DataBroker; //导入方法依赖的package包/类
public void populateL3Vpns(DataBroker broker, List<L3VpnComposite> vpns)
    throws TransactionCommitFailedException {
    for (L3VpnComposite vpn : vpns) {
        VpnInstance vpnInstance = new VpnInstanceBuilder().setVpnId(vpn.vpnOpData.getVpnId())
            .setVpnInstanceName(vpn.vpnOpData.getVpnInstanceName())
            .setVrfId(vpn.vpnOpData.getVrfId())
            .build();
        WriteTransaction writeTx1 = broker.newWriteOnlyTransaction();
        writeTx1.merge(LogicalDatastoreType.CONFIGURATION,
                      VpnOperDsUtils.getVpnInstanceToVpnIdIdentifier(vpn.vpnCfgData.getVpnInstanceName()),
                      vpnInstance, true);
        writeTx1.submit().checkedGet();
        WriteTransaction writeTx2 = broker.newWriteOnlyTransaction();
        writeTx2.merge(LogicalDatastoreType.OPERATIONAL,
                      VpnUtil.getVpnInstanceOpDataIdentifier(vpn.vpnOpData.getVrfId()), vpn.vpnOpData, true);
        writeTx2.submit().checkedGet();
    }
}
 
开发者ID:opendaylight,项目名称:netvirt,代码行数:19,代码来源:InterVpnLinkLocatorTest.java

示例5: populateIvpnLinks

import org.opendaylight.controller.md.sal.binding.api.DataBroker; //导入方法依赖的package包/类
public static void populateIvpnLinks(DataBroker broker2, List<InterVpnLinkDataComposite> ivpnLinks)
    throws TransactionCommitFailedException {

    for (InterVpnLinkDataComposite ivpnLink : ivpnLinks) {
        WriteTransaction writeTx1 = broker2.newWriteOnlyTransaction();
        writeTx1.merge(LogicalDatastoreType.CONFIGURATION,
                      InterVpnLinkUtil.getInterVpnLinkPath(ivpnLink.getInterVpnLinkName()),
                      ivpnLink.getInterVpnLinkConfig());
        writeTx1.submit().checkedGet();
        WriteTransaction writeTx2 = broker2.newWriteOnlyTransaction();
        writeTx2.merge(LogicalDatastoreType.OPERATIONAL,
                       InterVpnLinkUtil.getInterVpnLinkStateIid(ivpnLink.getInterVpnLinkName()),
                       ivpnLink.getInterVpnLinkState());
        writeTx2.submit().checkedGet();
    }
}
 
开发者ID:opendaylight,项目名称:netvirt,代码行数:17,代码来源:InterVpnLinkTestCatalog.java

示例6: cleanIvpnLinks

import org.opendaylight.controller.md.sal.binding.api.DataBroker; //导入方法依赖的package包/类
public static void cleanIvpnLinks(DataBroker broker2, InterVpnLinkDataComposite... ivpnLinks)
    throws TransactionCommitFailedException {

    for (InterVpnLinkDataComposite ivpnLink : ivpnLinks) {
        WriteTransaction writeTx1 = broker2.newWriteOnlyTransaction();
        writeTx1.delete(LogicalDatastoreType.OPERATIONAL,
                        InterVpnLinkUtil.getInterVpnLinkStateIid(ivpnLink.getInterVpnLinkName()));
        writeTx1.submit().checkedGet();

        WriteTransaction writeTx2 = broker2.newWriteOnlyTransaction();
        writeTx2.delete(LogicalDatastoreType.CONFIGURATION,
                        InterVpnLinkUtil.getInterVpnLinkPath(ivpnLink.getInterVpnLinkName()));
        writeTx2.submit().checkedGet();

    }
}
 
开发者ID:opendaylight,项目名称:netvirt,代码行数:17,代码来源:InterVpnLinkTestCatalog.java

示例7: initializeDataTree

import org.opendaylight.controller.md.sal.binding.api.DataBroker; //导入方法依赖的package包/类
private void initializeDataTree(DataBroker db) {
    LOG.info("Preparing to initialize the greeting registry");
    WriteTransaction transaction = db.newWriteOnlyTransaction();
    InstanceIdentifier<GreetingRegistry> iid = InstanceIdentifier.create(GreetingRegistry.class);
    GreetingRegistry greetingRegistry = new GreetingRegistryBuilder()
            .build();
    transaction.put(LogicalDatastoreType.OPERATIONAL, iid, greetingRegistry);
    CheckedFuture<Void, TransactionCommitFailedException> future = transaction.submit();
    Futures.addCallback(future, new LoggingFuturesCallBack<>("Failed to create greeting registry", LOG));
}
 
开发者ID:lrodrin,项目名称:opendaylight,代码行数:11,代码来源:HelloProvider.java

示例8: testConcurrentCreate

import org.opendaylight.controller.md.sal.binding.api.DataBroker; //导入方法依赖的package包/类
@Test
public void testConcurrentCreate() throws InterruptedException, ExecutionException, TimeoutException {

    DataBroker dataBroker = testContext.getDataBroker();
    WriteTransaction fooTx = dataBroker.newWriteOnlyTransaction();
    WriteTransaction barTx = dataBroker.newWriteOnlyTransaction();

    fooTx.put(LogicalDatastoreType.OPERATIONAL, FOO_PATH, new TopLevelListBuilder().setKey(FOO_KEY).build());
    barTx.put(LogicalDatastoreType.OPERATIONAL, BAR_PATH, new TopLevelListBuilder().setKey(BAR_KEY).build());

    fooTx.submit().get(5, TimeUnit.SECONDS);
    barTx.submit().get(5, TimeUnit.SECONDS);
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:14,代码来源:ConcurrentImplicitCreateTest.java

示例9: testWriteByReplace

import org.opendaylight.controller.md.sal.binding.api.DataBroker; //导入方法依赖的package包/类
@Test
public void testWriteByReplace() throws InterruptedException, TimeoutException, ExecutionException {

    DataBroker dataBroker = testContext.getDataBroker();

    final SettableFuture<AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject>> eventFuture =
            SettableFuture.create();
    dataBroker.registerDataChangeListener(LogicalDatastoreType.OPERATIONAL, DEEP_WILDCARDED_PATH,
        dataChangeEvent -> eventFuture.set(dataChangeEvent), DataChangeScope.SUBTREE);

    final WriteTransaction cwuTx = dataBroker.newWriteOnlyTransaction();
    cwuTx.put(LogicalDatastoreType.OPERATIONAL, NODE_0_CWU_PATH, CWU, true);
    cwuTx.submit().get(5, TimeUnit.SECONDS);

    assertFalse(eventFuture.isDone());

    final WriteTransaction lvuTx = dataBroker.newWriteOnlyTransaction();

    TreeComplexUsesAugment tcua = new TreeComplexUsesAugmentBuilder()
            .setListViaUses(Collections.singletonList(LVU)).build();

    lvuTx.put(LogicalDatastoreType.OPERATIONAL, NODE_0_TCU_PATH, tcua, true);
    lvuTx.put(LogicalDatastoreType.OPERATIONAL, NODE_1_LVU_PATH, LVU, true);
    lvuTx.submit().get(5, TimeUnit.SECONDS);

    validateEvent(eventFuture.get(1000, TimeUnit.MILLISECONDS));
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:28,代码来源:WildcardedDataChangeListenerTest.java

示例10: testNoChangeOnReplaceWithSameValue

import org.opendaylight.controller.md.sal.binding.api.DataBroker; //导入方法依赖的package包/类
@Test
public void testNoChangeOnReplaceWithSameValue() throws InterruptedException, TimeoutException, ExecutionException {

    DataBroker dataBroker = testContext.getDataBroker();

    // We wrote initial state NODE_0_FLOW
    final WriteTransaction transaction = dataBroker.newWriteOnlyTransaction();
    transaction.put(LogicalDatastoreType.OPERATIONAL, NODE_0_LVU_PATH, LVU, true);
    transaction.submit().get(5, TimeUnit.SECONDS);

    // We registered DataChangeListener
    final SettableFuture<AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject>> eventFuture =
            SettableFuture.create();
    dataBroker.registerDataChangeListener(LogicalDatastoreType.OPERATIONAL, DEEP_WILDCARDED_PATH,
        dataChangeEvent -> eventFuture.set(dataChangeEvent), DataChangeScope.SUBTREE);
    assertFalse(eventFuture.isDone());

    final WriteTransaction secondTx = dataBroker.newWriteOnlyTransaction();
    secondTx.put(LogicalDatastoreType.OPERATIONAL, NODE_0_LVU_PATH, LVU, true);
    secondTx.put(LogicalDatastoreType.OPERATIONAL, NODE_1_LVU_PATH, LVU, true);
    secondTx.submit().get(5, TimeUnit.SECONDS);

    AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> event = eventFuture.get(1000, TimeUnit.MILLISECONDS);
    assertNotNull(event);
    // Data change should contains NODE_1 Flow - which was added
    assertTrue(event.getCreatedData().containsKey(NODE_1_LVU_PATH));
    // Data change must not containe NODE_0 Flow which was replaced with same value.
    assertFalse(event.getUpdatedData().containsKey(NODE_0_LVU_PATH));
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:30,代码来源:WildcardedDataChangeListenerTest.java

示例11: writeNodeListenAugment

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

    final SettableFuture<AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject>> event = SettableFuture.create();
    DataBroker dataBroker = testContext.getDataBroker();
    ListenerRegistration<org.opendaylight.controller.md.sal.binding.api.DataChangeListener> dclRegistration =
            dataBroker.registerDataChangeListener(LogicalDatastoreType.OPERATIONAL, AUGMENT_WILDCARDED_PATH,
                change -> event.set(change), DataChangeScope.SUBTREE);

    final WriteTransaction transaction = dataBroker.newWriteOnlyTransaction();

    TopLevelList tll = new TopLevelListBuilder() //
            .setKey(TLL_KEY) //
            .addAugmentation(TreeComplexUsesAugment.class, treeComplexUsesAugment("one")).build();
    transaction.put(LogicalDatastoreType.OPERATIONAL, TLL_INSTANCE_ID_BA, tll, true);
    transaction.submit().get(5, TimeUnit.SECONDS);

    AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> receivedEvent = event.get(1000, TimeUnit.MILLISECONDS);
    assertTrue(receivedEvent.getCreatedData().containsKey(AUGMENT_TLL_PATH));

    dclRegistration.close();

    final WriteTransaction transaction2 = dataBroker.newWriteOnlyTransaction();
    transaction2.put(LogicalDatastoreType.OPERATIONAL, AUGMENT_TLL_PATH, treeComplexUsesAugment("two"));
    transaction2.submit().get(5, TimeUnit.SECONDS);

    TreeComplexUsesAugment readedAug = dataBroker.newReadOnlyTransaction().read(
            LogicalDatastoreType.OPERATIONAL, AUGMENT_TLL_PATH).checkedGet(5, TimeUnit.SECONDS).get();
    assertEquals("two", readedAug.getContainerWithUses().getLeafFromGrouping());
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:31,代码来源:WriteParentListenAugmentTest.java

示例12: writeParentReadChild

import org.opendaylight.controller.md.sal.binding.api.DataBroker; //导入方法依赖的package包/类
/**
 * The scenario tests writing parent node, which also contains child items
 * and then reading child directly, by specifying path to the child.
 * Expected behaviour is child is returned.
 */
@Test
public void writeParentReadChild() throws Exception {

    DataBroker dataBroker = testContext.getDataBroker();
    final WriteTransaction transaction = dataBroker.newWriteOnlyTransaction();

    List11 list11 = new List11Builder() //
            .setKey(LIST11_KEY) //
            .setAttrStr("primary")
            .build();

    List1 list1 = new List1Builder().setKey(LIST1_KEY).setList11(ImmutableList.of(list11)).build();

    transaction.put(LogicalDatastoreType.OPERATIONAL, LIST1_INSTANCE_ID_BA, list1, true);
    transaction.submit().get(5, TimeUnit.SECONDS);

    Optional<List1> readList1 = dataBroker.newReadOnlyTransaction().read(LogicalDatastoreType.OPERATIONAL,
            LIST1_INSTANCE_ID_BA).checkedGet(1000, TimeUnit.MILLISECONDS);
    assertTrue(readList1.isPresent());

    Optional<? extends DataObject> readList11 = dataBroker.newReadOnlyTransaction().read(
            LogicalDatastoreType.OPERATIONAL, LIST11_INSTANCE_ID_BA).checkedGet(5, TimeUnit.SECONDS);
    assertNotNull("Readed flow should not be null.",readList11);
    assertTrue(readList11.isPresent());
    assertEquals(list11, readList11.get());
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:32,代码来源:WriteParentReadChildTest.java

示例13: asyncWrite

import org.opendaylight.controller.md.sal.binding.api.DataBroker; //导入方法依赖的package包/类
private static <T extends DataObject> void asyncWrite(LogicalDatastoreType datastoreType,
                                                      InstanceIdentifier<T> path, T data, DataBroker broker,
                                                      FutureCallback<Void> callback) {
    WriteTransaction tx = broker.newWriteOnlyTransaction();
    tx.put(datastoreType, path, data, WriteTransaction.CREATE_MISSING_PARENTS);
    Futures.addCallback(tx.submit(), callback, MoreExecutors.directExecutor());
}
 
开发者ID:opendaylight,项目名称:netvirt,代码行数:8,代码来源:QosAlertManager.java

示例14: installRouterGwFlows

import org.opendaylight.controller.md.sal.binding.api.DataBroker; //导入方法依赖的package包/类
public static void installRouterGwFlows(DataBroker dataBroker, IVpnManager vpnManager, Routers router,
        BigInteger primarySwitchId, int addOrRemove) {
    WriteTransaction writeTx = dataBroker.newWriteOnlyTransaction();
    List<ExternalIps> externalIps = router.getExternalIps();
    List<String> externalIpsSting = new ArrayList<>();

    if (externalIps.isEmpty()) {
        LOG.error("installRouterGwFlows: setupRouterGwFlows no externalIP present");
        return;
    }
    for (ExternalIps externalIp : externalIps) {
        externalIpsSting.add(externalIp.getIpAddress());
    }
    Uuid subnetVpnName = externalIps.get(0).getSubnetId();
    if (addOrRemove == NwConstants.ADD_FLOW) {
        vpnManager.addRouterGwMacFlow(router.getRouterName(), router.getExtGwMacAddress(), primarySwitchId,
                router.getNetworkId(), subnetVpnName.getValue(), writeTx);
        vpnManager.addArpResponderFlowsToExternalNetworkIps(router.getRouterName(), externalIpsSting,
                router.getExtGwMacAddress(), primarySwitchId,
                router.getNetworkId(), writeTx);
    } else {
        vpnManager.removeRouterGwMacFlow(router.getRouterName(), router.getExtGwMacAddress(), primarySwitchId,
                router.getNetworkId(), subnetVpnName.getValue(), writeTx);
        vpnManager.removeArpResponderFlowsToExternalNetworkIps(router.getRouterName(), externalIpsSting,
                router.getExtGwMacAddress(), primarySwitchId,
                router.getNetworkId(), writeTx);
    }
    writeTx.submit();
}
 
开发者ID:opendaylight,项目名称:netvirt,代码行数:30,代码来源:NatUtil.java

示例15: removeVrfEntries

import org.opendaylight.controller.md.sal.binding.api.DataBroker; //导入方法依赖的package包/类
public static void removeVrfEntries(DataBroker broker, String rd, List<VrfEntry> vrfEntries) {
    InstanceIdentifier<VrfTables> vpnVrfTableIid =
        InstanceIdentifier.builder(FibEntries.class).child(VrfTables.class, new VrfTablesKey(rd)).build();
    WriteTransaction tx = broker.newWriteOnlyTransaction();
    for (VrfEntry vrfEntry : vrfEntries) {
        tx.delete(LogicalDatastoreType.CONFIGURATION, vpnVrfTableIid.child(VrfEntry.class, vrfEntry.getKey()));
    }
    tx.submit();
}
 
开发者ID:opendaylight,项目名称:netvirt,代码行数:10,代码来源:VpnUtil.java


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