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


Java DataTreeModification类代码示例

本文整理汇总了Java中org.opendaylight.controller.md.sal.binding.api.DataTreeModification的典型用法代码示例。如果您正苦于以下问题:Java DataTreeModification类的具体用法?Java DataTreeModification怎么用?Java DataTreeModification使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


DataTreeModification类属于org.opendaylight.controller.md.sal.binding.api包,在下文中一共展示了DataTreeModification类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onDataTreeChanged

import org.opendaylight.controller.md.sal.binding.api.DataTreeModification; //导入依赖的package包/类
@Override
public void onDataTreeChanged(Collection<DataTreeModification<Descriptors>> changes) {
    for (DataTreeModification<Descriptors> descModification : changes) {
        LOG.info("Descriptor Change has occured for Tenant-Id {} / Descriptor-Id {}",tenantId,
                descModification.getRootPath().toString());
        if (descModification.getRootNode().getModificationType() == ModificationType.DELETE) {
            removeDescriptor(descModification.getRootNode().getDataBefore());
        } else {
            try {
               addDescriptor(descModification.getRootNode().getDataAfter());
           } catch (Exception e) {
               ErrorLog.logError("DescriptorChangeManager - Error occured during Descriptor Create/Write - " + e.getLocalizedMessage(), e.getStackTrace());
           }
        }

    }
}
 
开发者ID:opendaylight,项目名称:fpc,代码行数:18,代码来源:PolicyManager.java

示例2: onDataTreeChanged

import org.opendaylight.controller.md.sal.binding.api.DataTreeModification; //导入依赖的package包/类
@Override
public void onDataTreeChanged(Collection<DataTreeModification<Contexts>> changes) {
    for (DataTreeModification<Contexts> cntxModification : changes) {
        LOG.info("Descriptor Change has occured for Tenant-Id {} / Descriptor-Id {}",tenantId,
                cntxModification.getRootPath().toString());
        if (cntxModification.getRootNode().getModificationType() == ModificationType.DELETE) {
            removeContext(cntxModification.getRootNode().getDataBefore());
        } else {
            try {
               addContext(cntxModification.getRootNode().getDataAfter());
           } catch (Exception e) {
               ErrorLog.logError("DescriptorChangeManager - Error occured during Descriptor Create/Write - " + e.getLocalizedMessage(), e.getStackTrace());
           }
        }

    }
}
 
开发者ID:opendaylight,项目名称:fpc,代码行数:18,代码来源:PortManager.java

示例3: onDataTreeChanged

import org.opendaylight.controller.md.sal.binding.api.DataTreeModification; //导入依赖的package包/类
@Override
public void onDataTreeChanged(Collection<DataTreeModification<DpnGroups>> changes) {
    for (DataTreeModification<DpnGroups> dpnGroupModification : changes) {
        LOG.info("Dpn Groups Change has occured for " + dpnGroupModification.getRootPath().toString());
        if (dpnGroupModification.getRootNode().getModificationType() == ModificationType.DELETE) {
            removeDpnGroup(dpnGroupModification.getRootNode().getDataBefore());
        } else {
            try {
                loadDpnGroup(dpnGroupModification.getRootNode().getDataAfter());
           } catch (Exception e) {
               ErrorLog.logError("DpnChangeManager - Error occured during DPN Create/Write - " + e.getLocalizedMessage(), e.getStackTrace());
           }
        }

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

示例4: logDataTreeChangeEvent

import org.opendaylight.controller.md.sal.binding.api.DataTreeModification; //导入依赖的package包/类
private static synchronized void logDataTreeChangeEvent(final int eventNum,
        final Collection<DataTreeModification<TestExec>> changes) {
    LOG.debug("DsbenchmarkListener-onDataTreeChanged: Event {}", eventNum);

    for (DataTreeModification<TestExec> change : changes) {
        final DataObjectModification<TestExec> rootNode = change.getRootNode();
        final ModificationType modType = rootNode.getModificationType();
        final PathArgument changeId = rootNode.getIdentifier();
        final Collection<DataObjectModification<? extends DataObject>> modifications =
                rootNode.getModifiedChildren();

        LOG.debug("    changeId {}, modType {}, mods: {}", changeId, modType, modifications.size());

        for (DataObjectModification<? extends DataObject> mod : modifications) {
            LOG.debug("      mod-getDataAfter: {}", mod.getDataAfter());
        }
    }
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:19,代码来源:DsbenchmarkListener.java

示例5: onDataTreeChanged

import org.opendaylight.controller.md.sal.binding.api.DataTreeModification; //导入依赖的package包/类
@Override
public void onDataTreeChanged(Collection<DataTreeModification<Node>> changes) {
    for (DataTreeModification<Node> change: changes) {
        final DataObjectModification<Node> rootNode = change.getRootNode();
        switch (rootNode.getModificationType()) {
            case WRITE:
            case SUBTREE_MODIFIED:
                final Node node = rootNode.getDataAfter();
                if (getNodeIdRegexPattern().matcher(node.getNodeId().getValue()).matches()) {
                    notifyNode(change.getRootPath().getRootIdentifier());
                }
                break;
            default:
                break;
        }
    }
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:18,代码来源:EventSourceTopic.java

示例6: onDataTreeChangedTest

import org.opendaylight.controller.md.sal.binding.api.DataTreeModification; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void onDataTreeChangedTest() {
    InstanceIdentifier<Node> instanceIdentifierMock = mock(InstanceIdentifier.class);
    DataTreeModification<Node> mockDataTreeModification = mock(DataTreeModification.class);
    DataObjectModification<Node> mockModification = mock(DataObjectModification.class);
    doReturn(mockModification).when(mockDataTreeModification).getRootNode();
    doReturn(new DataTreeIdentifier<>(LogicalDatastoreType.OPERATIONAL, instanceIdentifierMock))
            .when(mockDataTreeModification).getRootPath();
    doReturn(DataObjectModification.ModificationType.WRITE).when(mockModification).getModificationType();

    Node dataObjectNodeMock = mock(Node.class);
    doReturn(getNodeKey("testNodeId01")).when(dataObjectNodeMock).getKey();
    NodeId nodeIdMock = mock(NodeId.class);
    doReturn(nodeIdMock).when(dataObjectNodeMock).getNodeId();
    doReturn("nodeIdPattern1").when(nodeIdMock).getValue();

    doReturn(dataObjectNodeMock).when(mockModification).getDataAfter();

    eventSourceTopic.onDataTreeChanged(Collections.singletonList(mockDataTreeModification));
    verify(dataObjectNodeMock).getNodeId();
    verify(nodeIdMock).getValue();
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:24,代码来源:EventSourceTopicTest.java

示例7: testWildcardedListListener

import org.opendaylight.controller.md.sal.binding.api.DataTreeModification; //导入依赖的package包/类
@Test
public void testWildcardedListListener() throws Exception {
    final EventCapturingListener<TopLevelList> listener = new EventCapturingListener<>();
    final DataTreeIdentifier<TopLevelList> wildcard = new DataTreeIdentifier<>(LogicalDatastoreType.OPERATIONAL, TOP_PATH.child(TopLevelList.class));
    dataBrokerImpl.registerDataTreeChangeListener(wildcard, listener);

    putTx(TOP_PATH, TOP_INITIAL_DATA).submit().checkedGet();

    final DataTreeModification<TopLevelList> fooWriteEvent = Iterables.getOnlyElement(listener.nextEvent());
    assertEquals(FOO_PATH, fooWriteEvent.getRootPath().getRootIdentifier());
    verifyModification(fooWriteEvent.getRootNode(), FOO_ARGUMENT, ModificationType.WRITE);

    putTx(BAR_PATH, BAR_DATA).submit().checkedGet();
    final DataTreeModification<TopLevelList> barWriteEvent = Iterables.getOnlyElement(listener.nextEvent());
    assertEquals(BAR_PATH, barWriteEvent.getRootPath().getRootIdentifier());
    verifyModification(barWriteEvent.getRootNode(), BAR_ARGUMENT, ModificationType.WRITE);

    deleteTx(BAR_PATH).submit().checkedGet();
    final DataTreeModification<TopLevelList> barDeleteEvent = Iterables.getOnlyElement(listener.nextEvent());
    assertEquals(BAR_PATH, barDeleteEvent.getRootPath().getRootIdentifier());
    verifyModification(barDeleteEvent.getRootNode(), BAR_ARGUMENT, ModificationType.DELETE);
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:23,代码来源:DataTreeChangeListenerTest.java

示例8: testDataTreeChangeListener

import org.opendaylight.controller.md.sal.binding.api.DataTreeModification; //导入依赖的package包/类
@SuppressWarnings({ "rawtypes", "unchecked" })
@Test
public void testDataTreeChangeListener() throws Exception {
    DataBroker dataBroker = getDataBroker();

    DataTreeChangeListener<ListItem> listener = mock(DataTreeChangeListener.class);
    InstanceIdentifier<ListItem> wildCard = InstanceIdentifier.builder(ListenerTest.class)
            .child(ListItem.class).build();
    ListenerRegistration<DataTreeChangeListener<ListItem>> reg = dataBroker.registerDataTreeChangeListener(
            new DataTreeIdentifier(LogicalDatastoreType.OPERATIONAL, wildCard), listener);

    final ListItem item = writeListItem();

    ArgumentCaptor<Collection> captor = ArgumentCaptor.forClass(Collection.class);

    verify(listener, timeout(100)).onDataTreeChanged(captor.capture());

    Collection<DataTreeModification<ListItem>> mods = captor.getValue();
    assertEquals("ListItem", item, mods.iterator().next().getRootNode().getDataAfter());
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:21,代码来源:Bug4513Test.java

示例9: ouputChanges

import org.opendaylight.controller.md.sal.binding.api.DataTreeModification; //导入依赖的package包/类
private static void ouputChanges(final DataTreeModification<Cars> change) {
    final DataObjectModification<Cars> rootNode = change.getRootNode();
    final ModificationType modificationType = rootNode.getModificationType();
    final InstanceIdentifier<Cars> rootIdentifier = change.getRootPath().getRootIdentifier();
    switch (modificationType) {
        case WRITE:
        case SUBTREE_MODIFIED: {
            final Cars dataBefore = rootNode.getDataBefore();
            final Cars dataAfter = rootNode.getDataAfter();
            LOG.trace("onDataTreeChanged - Cars config with path {} was added or changed from {} to {}",
                    rootIdentifier, dataBefore, dataAfter);
            break;
        }
        case DELETE: {
            LOG.trace("onDataTreeChanged - Cars config with path {} was deleted", rootIdentifier);
            break;
        }
        default: {
            LOG.trace("onDataTreeChanged called with unknown modificationType: {}", modificationType);
            break;
        }
    }
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:24,代码来源:CarDataTreeChangeListener.java

示例10: onDataTreeChanged

import org.opendaylight.controller.md.sal.binding.api.DataTreeModification; //导入依赖的package包/类
/**
 * Implemented from the DataTreeChangeListener interface.
 */
@Override
public void onDataTreeChanged(Collection<DataTreeModification<Toaster>> changes) {
    for (DataTreeModification<Toaster> change: changes) {
        DataObjectModification<Toaster> rootNode = change.getRootNode();
        if (rootNode.getModificationType() == WRITE) {
            Toaster oldToaster = rootNode.getDataBefore();
            Toaster newToaster = rootNode.getDataAfter();
            LOG.info("onDataTreeChanged - Toaster config with path {} was added or replaced: "
                    + "old Toaster: {}, new Toaster: {}", change.getRootPath().getRootIdentifier(),
                    oldToaster, newToaster);

            Long darkness = newToaster.getDarknessFactor();
            if (darkness != null) {
                darknessFactor.set(darkness);
            }
        } else if (rootNode.getModificationType() == DELETE) {
            LOG.info("onDataTreeChanged - Toaster config with path {} was deleted: old Toaster: {}",
                    change.getRootPath().getRootIdentifier(), rootNode.getDataBefore());
        }
    }
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:25,代码来源:OpendaylightToaster.java

示例11: processChanges

import org.opendaylight.controller.md.sal.binding.api.DataTreeModification; //导入依赖的package包/类
private void processChanges(Collection<DataTreeModification<T>> changes) {
    LOG.info("onDataTreeChanged: Received Data Tree Changed {}", changes);
    for (DataTreeModification<T> change : changes) {
        final InstanceIdentifier<T> key = change.getRootPath().getRootIdentifier();
        final DataObjectModification<T> mod = change.getRootNode();
        LOG.info("onDataTreeChanged: Received Data Tree Changed Update of Type={} for Key={}",
                mod.getModificationType(), key);
        switch (mod.getModificationType()) {
            case DELETE:
                dataProcessor.remove(key, mod.getDataBefore());
                break;
            case SUBTREE_MODIFIED:
                dataProcessor.update(key, mod.getDataBefore(), mod.getDataAfter());
                break;
            case WRITE:
                if (mod.getDataBefore() == null) {
                    dataProcessor.add(key, mod.getDataAfter());
                } else {
                    dataProcessor.update(key, mod.getDataBefore(), mod.getDataAfter());
                }
                break;
            default:
                throw new IllegalArgumentException("Unhandled modification type " + mod.getModificationType());
        }
    }
}
 
开发者ID:opendaylight,项目名称:netvirt,代码行数:27,代码来源:DelegatingDataTreeListener.java

示例12: onDataTreeChanged

import org.opendaylight.controller.md.sal.binding.api.DataTreeModification; //导入依赖的package包/类
@Override
public void onDataTreeChanged(@Nonnull Collection<DataTreeModification<Services>> changes) {
    for (DataTreeModification<Services> change : changes) {
        final DataObjectModification<Services> mod = change.getRootNode();

        switch (mod.getModificationType()) {
            case DELETE:
                LOG.info("Service deleted {}", mod.getDataBefore());
                break;
            case SUBTREE_MODIFIED:
                LOG.info("Service updated old : {}, new : {}", mod.getDataBefore(), mod.getDataAfter());
                break;
            case WRITE:
                if (mod.getDataBefore() == null) {
                    LOG.info("Service added {}", mod.getDataAfter());
                } else {
                    LOG.info("Service updated old : {}, new : {}", mod.getDataBefore(), mod.getDataAfter());
                }
                break;
            default:
                // FIXME: May be not a good idea to throw.
                throw new IllegalArgumentException("Unhandled modification type " + mod.getModificationType());
        }
    }
}
 
开发者ID:opendaylight,项目名称:netvirt,代码行数:26,代码来源:ServiceListener.java

示例13: onDataTreeChanged

import org.opendaylight.controller.md.sal.binding.api.DataTreeModification; //导入依赖的package包/类
@Override
public void onDataTreeChanged(Collection<DataTreeModification<VrfEntry>> changes) {
    for (DataTreeModification<VrfEntry> change : changes) {
        final InstanceIdentifier<VrfEntry> key = change.getRootPath().getRootIdentifier();
        final DataObjectModification<VrfEntry> mod = change.getRootNode();

        switch (mod.getModificationType()) {
            case DELETE:
                numFibEntries -= 1;
                break;
            case WRITE:
                if (mod.getDataBefore() == null) {
                    numFibEntries += 1;
                } else {
                    // UPDATE COUNT UNCHANGED
                }
                break;
            default:
                throw new IllegalArgumentException("Unhandled modification  type " + mod.getModificationType());
        }
    }
}
 
开发者ID:opendaylight,项目名称:netvirt,代码行数:23,代码来源:MockFibManager.java

示例14: onDataTreeChanged

import org.opendaylight.controller.md.sal.binding.api.DataTreeModification; //导入依赖的package包/类
@Override
public void onDataTreeChanged(final Collection<DataTreeModification<Node>> changes) {
    HAJobScheduler.getInstance().submitJob(() -> {
        ReadWriteTransaction tx = getTx();
        try {
            processConnectedNodes(changes, tx);
            processUpdatedNodes(changes, tx);
            processDisconnectedNodes(changes, tx);
            tx.submit().get();
        } catch (InterruptedException e1) {
            LOG.error("InterruptedException " + e1.getMessage());
        } catch (ExecutionException e2) {
            LOG.error("ExecutionException" + e2.getMessage());
        } catch (ReadFailedException e3) {
            LOG.error("ReadFailedException" + e3.getMessage());
        }
    });
}
 
开发者ID:opendaylight,项目名称:netvirt,代码行数:19,代码来源:HwvtepNodeBaseListener.java

示例15: processUpdatedNodes

import org.opendaylight.controller.md.sal.binding.api.DataTreeModification; //导入依赖的package包/类
private void processUpdatedNodes(Collection<DataTreeModification<Node>> changes,
                                 ReadWriteTransaction tx)
        throws ReadFailedException, ExecutionException, InterruptedException {
    for (DataTreeModification<Node> change : changes) {
        final InstanceIdentifier<Node> key = change.getRootPath().getRootIdentifier();
        final DataObjectModification<Node> mod = change.getRootNode();
        String nodeId = key.firstKeyOf(Node.class).getNodeId().getValue();
        Node updated = HwvtepHAUtil.getUpdated(mod);
        Node original = HwvtepHAUtil.getOriginal(mod);
        if (updated != null && original != null) {
            if (!nodeId.contains(HwvtepHAUtil.PHYSICALSWITCH)) {
                onGlobalNodeUpdate(key, updated, original, tx);
            } else {
                onPsNodeUpdate(key, updated, original, tx);
            }
        }
    }
}
 
开发者ID:opendaylight,项目名称:netvirt,代码行数:19,代码来源:HwvtepNodeBaseListener.java


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