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


Java DataObjectModification类代码示例

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


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

示例1: logDataTreeChangeEvent

import org.opendaylight.controller.md.sal.binding.api.DataObjectModification; //导入依赖的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

示例2: onDataTreeChanged

import org.opendaylight.controller.md.sal.binding.api.DataObjectModification; //导入依赖的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

示例3: onDataTreeChangedTest

import org.opendaylight.controller.md.sal.binding.api.DataObjectModification; //导入依赖的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

示例4: populateList

import org.opendaylight.controller.md.sal.binding.api.DataObjectModification; //导入依赖的package包/类
private static void populateList(final List<DataObjectModification<? extends DataObject>> result,
        final BindingCodecTreeNode<?> parentCodec, final Collection<DataTreeCandidateNode> domChildNodes) {
    for (final DataTreeCandidateNode domChildNode : domChildNodes) {
        final BindingStructuralType type = BindingStructuralType.from(domChildNode);
        if (type != BindingStructuralType.NOT_ADDRESSABLE) {
            /*
             *  Even if type is UNKNOWN, from perspective of BindingStructuralType
             *  we try to load codec for it. We will use that type to further specify
             *  debug log.
             */
            try {
                final BindingCodecTreeNode<?> childCodec =
                        parentCodec.yangPathArgumentChild(domChildNode.getIdentifier());
                populateList(result,type, childCodec, domChildNode);
            } catch (final IllegalArgumentException e) {
                if (type == BindingStructuralType.UNKNOWN) {
                    LOG.debug("Unable to deserialize unknown DOM node {}",domChildNode,e);
                } else {
                    LOG.debug("Binding representation for DOM node {} was not found",domChildNode,e);
                }
            }
        }
    }
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:25,代码来源:LazyDataObjectModification.java

示例5: getModificationType

import org.opendaylight.controller.md.sal.binding.api.DataObjectModification; //导入依赖的package包/类
@Override
public DataObjectModification.ModificationType getModificationType() {
    switch(domData.getModificationType()) {
        case WRITE:
            return DataObjectModification.ModificationType.WRITE;
        case APPEARED:
        case SUBTREE_MODIFIED:
            return DataObjectModification.ModificationType.SUBTREE_MODIFIED;
        case DISAPPEARED:
        case DELETE:
            return DataObjectModification.ModificationType.DELETE;
        default:
            // TODO: Should we lie about modification type instead of exception?
            throw new IllegalStateException("Unsupported DOM Modification type " + domData.getModificationType());
    }
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:17,代码来源:LazyDataObjectModification.java

示例6: testTopLevelListener

import org.opendaylight.controller.md.sal.binding.api.DataObjectModification; //导入依赖的package包/类
@Test
public void testTopLevelListener() throws Exception {
    final EventCapturingListener<Top> listener = new EventCapturingListener<>();
    dataBrokerImpl.registerDataTreeChangeListener(TOP_IDENTIFIER, listener);

    createAndVerifyTop(listener);

    putTx(BAR_PATH, BAR_DATA).submit().checkedGet();
    final DataObjectModification<Top> afterBarPutEvent = Iterables.getOnlyElement(listener.nextEvent()).getRootNode();
    verifyModification(afterBarPutEvent, TOP_ARGUMENT, ModificationType.SUBTREE_MODIFIED);
    final DataObjectModification<TopLevelList> barPutMod = afterBarPutEvent.getModifiedChildListItem(TopLevelList.class, TOP_BAR_KEY);
    assertNotNull(barPutMod);
    verifyModification(barPutMod, BAR_ARGUMENT, ModificationType.WRITE);

    deleteTx(BAR_PATH).submit().checkedGet();
    final DataObjectModification<Top> afterBarDeleteEvent = Iterables.getOnlyElement(listener.nextEvent()).getRootNode();
    verifyModification(afterBarDeleteEvent, TOP_ARGUMENT, ModificationType.SUBTREE_MODIFIED);
    final DataObjectModification<TopLevelList> barDeleteMod = afterBarDeleteEvent.getModifiedChildListItem(TopLevelList.class, TOP_BAR_KEY);
    verifyModification(barDeleteMod, BAR_ARGUMENT, ModificationType.DELETE);
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:21,代码来源:DataTreeChangeListenerTest.java

示例7: ouputChanges

import org.opendaylight.controller.md.sal.binding.api.DataObjectModification; //导入依赖的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

示例8: onDataTreeChanged

import org.opendaylight.controller.md.sal.binding.api.DataObjectModification; //导入依赖的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

示例9: processChanges

import org.opendaylight.controller.md.sal.binding.api.DataObjectModification; //导入依赖的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

示例10: onPodInterfacesChanged

import org.opendaylight.controller.md.sal.binding.api.DataObjectModification; //导入依赖的package包/类
public void onPodInterfacesChanged(final DataObjectModification<Interface> dataObjectModification,
                                   final InstanceIdentifier<Pods> rootIdentifier,
                                   DataObjectModification<Pods> rootNode) {
    Pods pods = rootNode.getDataAfter();
    Pods podsBefore = rootNode.getDataBefore();
    Interface podInterfaceBefore = dataObjectModification.getDataBefore();
    Interface podInterfaceAfter = dataObjectModification.getDataAfter();
    switch (dataObjectModification.getModificationType()) {
        case DELETE:
            remove(podsBefore, podInterfaceBefore);
            break;
        case SUBTREE_MODIFIED:
            update(pods, podsBefore, podInterfaceBefore, podInterfaceAfter);
            break;
        case WRITE:
            if (podInterfaceBefore == null) {
                add(pods, podInterfaceAfter);
            } else {
                update(pods, podsBefore, podInterfaceBefore, podInterfaceAfter);
            }
            break;
        default:
            LOG.error("Unhandled Modificiation Type{} for {}", dataObjectModification.getModificationType(),
                    rootIdentifier);
    }
}
 
开发者ID:opendaylight,项目名称:netvirt,代码行数:27,代码来源:PodListener.java

示例11: onDataTreeChanged

import org.opendaylight.controller.md.sal.binding.api.DataObjectModification; //导入依赖的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

示例12: onDataTreeChanged

import org.opendaylight.controller.md.sal.binding.api.DataObjectModification; //导入依赖的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

示例13: extractDataObjectModifications

import org.opendaylight.controller.md.sal.binding.api.DataObjectModification; //导入依赖的package包/类
/**
 * Extract all the modifications affecting instances of {@code clazz} which are present in the given set of
 * modifications and satisfy the given filter.
 *
 * @param changes The changes to process.
 * @param paths The paths of the changes.
 * @param clazz The class we're interested in.
 * @param filter The filter the changes must satisfy.
 * @param <T> The type of changes we're interested in.
 * @return The modifications, mapped by instance identifier.
 */
private static <T extends DataObject> Map<InstanceIdentifier<T>, DataObjectModification<T>>
        extractDataObjectModifications(
        Collection<DataObjectModification<? extends DataObject>> changes,
        Collection<InstanceIdentifier<? extends DataObject>> paths, Class<T> clazz,
        Predicate<DataObjectModification<T>> filter) {
    Map<InstanceIdentifier<T>, DataObjectModification<T>> result = new HashMap<>();
    Queue<DataObjectModification<? extends DataObject>> remainingChanges = new LinkedList<>(changes);
    Queue<InstanceIdentifier<? extends DataObject>> remainingPaths = new LinkedList<>(paths);
    while (!remainingChanges.isEmpty()) {
        DataObjectModification<? extends DataObject> change = remainingChanges.remove();
        InstanceIdentifier<? extends DataObject> path = remainingPaths.remove();
        // Is the change relevant?
        if (clazz.isAssignableFrom(change.getDataType()) && filter.test((DataObjectModification<T>) change)) {
            result.put((InstanceIdentifier<T>) path, (DataObjectModification<T>) change);
        }
        // Add any children to the queue
        for (DataObjectModification<? extends DataObject> child : change.getModifiedChildren()) {
            remainingChanges.add(child);
            remainingPaths.add(extendPath(path, child));
        }
    }
    return result;
}
 
开发者ID:opendaylight,项目名称:netvirt,代码行数:35,代码来源:ChangeUtils.java

示例14: getOriginal

import org.opendaylight.controller.md.sal.binding.api.DataObjectModification; //导入依赖的package包/类
public static Node getOriginal(DataObjectModification<Node> mod) {
    Node node = null;
    switch (mod.getModificationType()) {
        case SUBTREE_MODIFIED:
        case DELETE:
            node = mod.getDataBefore();
            break;
        case WRITE:
            if (mod.getDataBefore() !=  null) {
                node = mod.getDataBefore();
            }
            break;
        default:
            break;
    }
    return node;
}
 
开发者ID:opendaylight,项目名称:netvirt,代码行数:18,代码来源:HwvtepHAUtil.java

示例15: getUpdated

import org.opendaylight.controller.md.sal.binding.api.DataObjectModification; //导入依赖的package包/类
public static Node getUpdated(DataObjectModification<Node> mod) {
    Node node = null;
    switch (mod.getModificationType()) {
        case SUBTREE_MODIFIED:
            node = mod.getDataAfter();
            break;
        case WRITE:
            if (mod.getDataAfter() !=  null) {
                node = mod.getDataAfter();
            }
            break;
        default:
            break;
    }
    return node;
}
 
开发者ID:opendaylight,项目名称:netvirt,代码行数:17,代码来源:HwvtepHAUtil.java


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