Search in sources :

Example 36 with DataObject

use of org.opendaylight.yangtools.yang.binding.DataObject in project bgpcep by opendaylight.

the class SimpleNlriRegistry method registerNlriSerializer.

synchronized AutoCloseable registerNlriSerializer(final Class<? extends DataObject> nlriClass, final NlriSerializer serializer) {
    final NlriSerializer prev = this.serializers.get(nlriClass);
    Preconditions.checkState(prev == null, "Serializer already bound to class " + prev);
    this.serializers.put(nlriClass, serializer);
    final Object lock = this;
    return new AbstractRegistration() {

        @Override
        protected void removeRegistration() {
            synchronized (lock) {
                SimpleNlriRegistry.this.serializers.remove(nlriClass);
            }
        }
    };
}
Also used : AbstractRegistration(org.opendaylight.protocol.concepts.AbstractRegistration) NlriSerializer(org.opendaylight.protocol.bgp.parser.spi.NlriSerializer) DataObject(org.opendaylight.yangtools.yang.binding.DataObject)

Example 37 with DataObject

use of org.opendaylight.yangtools.yang.binding.DataObject in project netvirt by opendaylight.

the class L2GwValidateCli method fillNodesData.

private void fillNodesData(Map<InstanceIdentifier<Node>, Node> nodes, Map<InstanceIdentifier<Node>, Map<InstanceIdentifier, DataObject>> dataMap) {
    for (Map.Entry<InstanceIdentifier<Node>, Node> entry : nodes.entrySet()) {
        InstanceIdentifier<Node> nodeId = entry.getKey();
        Node node = entry.getValue();
        Map<InstanceIdentifier, DataObject> map = new HashMap<>();
        dataMap.put(nodeId, map);
        if (node.getAugmentation(HwvtepGlobalAugmentation.class) != null) {
            for (MergeCommand command : globalCommands) {
                List<DataObject> data = command.getData(node.getAugmentation(HwvtepGlobalAugmentation.class));
                if (data != null) {
                    for (DataObject dataObject : data) {
                        map.put(command.generateId(nodeId, dataObject), dataObject);
                    }
                }
            }
        } else {
            for (MergeCommand command : physicalSwitchCommands) {
                List<DataObject> data = command.getData(node);
                if (data != null) {
                    for (DataObject dataObject : data) {
                        map.put(command.generateId(nodeId, dataObject), dataObject);
                    }
                }
            }
        }
    }
}
Also used : DataObject(org.opendaylight.yangtools.yang.binding.DataObject) HashMap(java.util.HashMap) Node(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node) HwvtepGlobalAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepGlobalAugmentation) MergeCommand(org.opendaylight.netvirt.elan.l2gw.ha.commands.MergeCommand) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) Map(java.util.Map) HashMap(java.util.HashMap)

Example 38 with DataObject

use of org.opendaylight.yangtools.yang.binding.DataObject in project openflowplugin by opendaylight.

the class OFDecoder method decode.

@Override
@SuppressWarnings("checkstyle:IllegalCatch")
protected void decode(ChannelHandlerContext ctx, VersionMessageWrapper msg, List<Object> out) throws Exception {
    statisticsCounter.incrementCounter(CounterEventTypes.US_RECEIVED_IN_OFJAVA);
    if (LOG.isDebugEnabled()) {
        LOG.debug("VersionMessageWrapper received");
        LOG.debug("<< {}", ByteBufUtils.byteBufToHexString(msg.getMessageBuffer()));
    }
    try {
        final DataObject dataObject = deserializationFactory.deserialize(msg.getMessageBuffer(), msg.getVersion());
        if (dataObject == null) {
            LOG.warn("Translated POJO is null");
            statisticsCounter.incrementCounter(CounterEventTypes.US_DECODE_FAIL);
        } else {
            out.add(dataObject);
            statisticsCounter.incrementCounter(CounterEventTypes.US_DECODE_SUCCESS);
        }
    } catch (RuntimeException e) {
        LOG.warn("Message deserialization failed", e);
        statisticsCounter.incrementCounter(CounterEventTypes.US_DECODE_FAIL);
    } finally {
        msg.getMessageBuffer().release();
    }
}
Also used : DataObject(org.opendaylight.yangtools.yang.binding.DataObject)

Example 39 with DataObject

use of org.opendaylight.yangtools.yang.binding.DataObject in project openflowplugin by opendaylight.

the class ConnectionAdapterImplStatisticsTest method testMessagePassCounter.

/**
 * Test counter for pass messages to consumer (counter US_MESSAGE_PASS has to be enabled).
 */
@Test
public void testMessagePassCounter() {
    if (!statCounters.isCounterEnabled(CounterEventTypes.US_MESSAGE_PASS)) {
        Assert.fail("Counter " + CounterEventTypes.US_MESSAGE_PASS + " is not enabled");
    }
    when(channel.pipeline()).thenReturn(pipeline);
    adapter = new ConnectionAdapterImpl(channel, InetSocketAddress.createUnresolved("10.0.0.1", 6653), true, CHANNEL_OUTBOUND_QUEUE_SIZE);
    adapter.setMessageListener(messageListener);
    adapter.setSystemListener(systemListener);
    adapter.setConnectionReadyListener(readyListener);
    cache = CacheBuilder.newBuilder().concurrencyLevel(1).expireAfterWrite(RPC_RESPONSE_EXPIRATION, TimeUnit.MINUTES).removalListener(REMOVAL_LISTENER).build();
    adapter.setResponseCache(cache);
    when(channel.disconnect()).thenReturn(channelFuture);
    DataObject message = new EchoRequestMessageBuilder().build();
    adapter.consume(message);
    message = new ErrorMessageBuilder().build();
    adapter.consume(message);
    message = new ExperimenterMessageBuilder().build();
    adapter.consume(message);
    message = new FlowRemovedMessageBuilder().build();
    adapter.consume(message);
    message = new HelloMessageBuilder().build();
    adapter.consume(message);
    message = new MultipartReplyMessageBuilder().build();
    adapter.consume(message);
    message = new PacketInMessageBuilder().build();
    adapter.consume(message);
    message = new PortStatusMessageBuilder().build();
    adapter.consume(message);
    message = new EchoRequestMessageBuilder().build();
    adapter.consume(message);
    Assert.assertEquals("Wrong - bad counter value for ConnectionAdapterImpl consume method", 9, statCounters.getCounter(CounterEventTypes.US_MESSAGE_PASS).getCounterValue());
    adapter.disconnect();
}
Also used : ErrorMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessageBuilder) ExperimenterMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessageBuilder) PacketInMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketInMessageBuilder) DataObject(org.opendaylight.yangtools.yang.binding.DataObject) PortStatusMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortStatusMessageBuilder) HelloMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloMessageBuilder) MultipartReplyMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessageBuilder) FlowRemovedMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemovedMessageBuilder) EchoRequestMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoRequestMessageBuilder) Test(org.junit.Test)

Example 40 with DataObject

use of org.opendaylight.yangtools.yang.binding.DataObject in project lispflowmapping by opendaylight.

the class VppEndpointListener method handleChange.

private ListenableFuture<Void> handleChange(DataObjectModification modification) {
    Collection<DataObjectModification<? extends DataObject>> modifiedChildren = modification.getModifiedChildren();
    List<ListenableFuture<KeyedInstanceIdentifier<Node, NodeKey>>> processingTasks = new ArrayList<>();
    for (DataObjectModification modifiedNode : modifiedChildren) {
        final Node newOrModifiedNode = (Node) modifiedNode.getDataAfter();
        ListenableFuture<KeyedInstanceIdentifier<Node, NodeKey>> processingTask = processNode(newOrModifiedNode);
        Futures.addCallback(processingTask, new FutureCallback<KeyedInstanceIdentifier<Node, NodeKey>>() {

            @Override
            public void onSuccess(@Nullable KeyedInstanceIdentifier<Node, NodeKey> kiiToNode) {
                hostInformationManager.addHostRelatedInfo(newOrModifiedNode.getNodeId().getValue(), LispAddressUtil.toRloc(vppNodeReader.rlocIpOfNode(kiiToNode)));
            }

            @Override
            public void onFailure(Throwable throwable) {
                LOG.debug("Couldn't process {}", newOrModifiedNode.getNodeId().getValue());
            }
        }, MoreExecutors.directExecutor());
        processingTasks.add(processNode(newOrModifiedNode));
    }
    return Futures.immediateFuture(null);
}
Also used : DataObjectModification(org.opendaylight.controller.md.sal.binding.api.DataObjectModification) SupportingNode(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.node.attributes.SupportingNode) Node(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node) ArrayList(java.util.ArrayList) DataObject(org.opendaylight.yangtools.yang.binding.DataObject) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) KeyedInstanceIdentifier(org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier) NodeKey(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeKey)

Aggregations

DataObject (org.opendaylight.yangtools.yang.binding.DataObject)44 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)24 Test (org.junit.Test)14 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)11 DataBroker (org.opendaylight.controller.md.sal.binding.api.DataBroker)10 Optional (com.google.common.base.Optional)8 HashMap (java.util.HashMap)7 Map (java.util.Map)7 LogicalDatastoreType (org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType)7 YangInstanceIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier)7 Logger (org.slf4j.Logger)7 LoggerFactory (org.slf4j.LoggerFactory)7 ReadOnlyTransaction (org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction)6 AbstractDataChangeListenerTest (org.opendaylight.controller.md.sal.binding.test.AbstractDataChangeListenerTest)6 Node (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node)6 Collection (java.util.Collection)5 Nonnull (javax.annotation.Nonnull)5 ReadFailedException (org.opendaylight.controller.md.sal.common.api.data.ReadFailedException)5 TopLevelListKey (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelListKey)5 DataObjectModification (org.opendaylight.controller.md.sal.binding.api.DataObjectModification)4