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);
}
}
};
}
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);
}
}
}
}
}
}
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();
}
}
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();
}
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);
}
Aggregations