use of org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventaggregator.rev141202.Pattern in project controller by opendaylight.
the class EventSourceTopic method notifyExistingNodes.
private void notifyExistingNodes(final EventSourceTopology eventSourceTopology) {
LOG.debug("Notify existing nodes");
final Pattern nodeRegex = this.nodeIdPattern;
final ReadOnlyTransaction tx = eventSourceTopology.getDataBroker().newReadOnlyTransaction();
final ListenableFuture<Optional<Topology>> future = tx.read(LogicalDatastoreType.OPERATIONAL, EventSourceTopology.EVENT_SOURCE_TOPOLOGY_PATH);
Futures.addCallback(future, new FutureCallback<Optional<Topology>>() {
@Override
public void onSuccess(@Nonnull final Optional<Topology> data) {
if (data.isPresent()) {
final List<Node> nodes = data.get().getNode();
if (nodes != null) {
for (final Node node : nodes) {
if (nodeRegex.matcher(node.getNodeId().getValue()).matches()) {
notifyNode(EventSourceTopology.EVENT_SOURCE_TOPOLOGY_PATH.child(Node.class, node.getKey()));
}
}
}
}
tx.close();
}
@Override
public void onFailure(final Throwable ex) {
LOG.error("Can not notify existing nodes", ex);
tx.close();
}
}, MoreExecutors.directExecutor());
}
use of org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventaggregator.rev141202.Pattern in project controller by opendaylight.
the class EventSourceTopologyTest method closeTest.
@Test
public void closeTest() throws Exception {
constructorTestHelper();
topicTestHelper();
Map<TopicId, EventSourceTopic> localMap = getEventSourceTopicMap();
TopicId topicIdMock = mock(TopicId.class);
EventSourceTopic eventSourceTopic = EventSourceTopic.create(new NotificationPattern("foo"), "pattern", eventSourceTopology);
localMap.put(topicIdMock, eventSourceTopic);
eventSourceTopology.close();
verify(aggregatorRpcReg, times(1)).close();
verify(listenerRegistrationMock, times(1)).close();
}
use of org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventaggregator.rev141202.Pattern in project controller by opendaylight.
the class EventSourceTopologyTest method destroyTopicTest.
@Test
public void destroyTopicTest() throws Exception {
topicTestHelper();
TopicId topicId = new TopicId("topic-id-007");
Map<TopicId, EventSourceTopic> localMap = getEventSourceTopicMap();
EventSourceTopic eventSourceTopic = EventSourceTopic.create(new NotificationPattern("foo"), "pattern", eventSourceTopology);
localMap.put(topicId, eventSourceTopic);
DestroyTopicInput input = new DestroyTopicInputBuilder().setTopicId(topicId).build();
eventSourceTopology.destroyTopic(input);
verify(listenerRegistrationMock, times(1)).close();
}
use of org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventaggregator.rev141202.Pattern in project controller by opendaylight.
the class EventSourceTopologyTest method topicTestHelper.
private void topicTestHelper() throws Exception {
constructorTestHelper();
createTopicInputMock = mock(CreateTopicInput.class);
eventSourceTopology = new EventSourceTopology(dataBrokerMock, rpcProviderRegistryMock);
NotificationPattern notificationPattern = new NotificationPattern("value1");
doReturn(notificationPattern).when(createTopicInputMock).getNotificationPattern();
Pattern pattern = new Pattern("valuePattern1");
doReturn(pattern).when(createTopicInputMock).getNodeIdPattern();
listenerRegistrationMock = mock(ListenerRegistration.class);
doReturn(listenerRegistrationMock).when(dataBrokerMock).registerDataTreeChangeListener(any(DataTreeIdentifier.class), any(EventSourceTopic.class));
ReadOnlyTransaction readOnlyTransactionMock = mock(ReadOnlyTransaction.class);
doReturn(readOnlyTransactionMock).when(dataBrokerMock).newReadOnlyTransaction();
CheckedFuture checkedFutureMock = mock(CheckedFuture.class);
doReturn(checkedFutureMock).when(readOnlyTransactionMock).read(eq(LogicalDatastoreType.OPERATIONAL), any(InstanceIdentifier.class));
Optional optionalMock = mock(Optional.class);
doReturn(optionalMock).when(checkedFutureMock).checkedGet();
doReturn(true).when(optionalMock).isPresent();
Topology topologyMock = mock(Topology.class);
doReturn(topologyMock).when(optionalMock).get();
Node nodeMock = mock(Node.class);
List<Node> nodeList = new ArrayList<>();
nodeList.add(nodeMock);
doReturn(nodeList).when(topologyMock).getNode();
NodeId nodeId = new NodeId("nodeIdValue1");
doReturn(nodeId).when(nodeMock).getNodeId();
}
use of org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventaggregator.rev141202.Pattern in project netvirt by opendaylight.
the class SubnetRouteInterfaceStateChangeListener method getSubnetId.
@Nonnull
protected List<Uuid> getSubnetId(Interface intrf) {
List<Uuid> listSubnetIds = new ArrayList<>();
if (!NeutronUtils.isUuid(intrf.getName())) {
LOG.debug("SubnetRouteInterfaceListener: Interface {} doesn't have valid uuid pattern", intrf.getName());
return listSubnetIds;
}
PortOpDataEntry portOpEntry = subOpDpnManager.getPortOpDataEntry(intrf.getName());
if (portOpEntry != null) {
List<Uuid> subnet = portOpEntry.getSubnetIds();
if (subnet != null) {
return subnet;
}
return listSubnetIds;
}
LOG.trace("SubnetRouteInterfaceListener : Received Port {} event for {} that is not part of subnetRoute", intrf.getOperStatus(), intrf.getName());
Port port = neutronVpnManager.getNeutronPort(intrf.getName());
if (port == null) {
return listSubnetIds;
}
List<FixedIps> portIps = port.getFixedIps();
if (port.getFixedIps() != null) {
for (FixedIps portIp : portIps) {
listSubnetIds.add(portIp.getSubnetId());
}
}
return listSubnetIds;
}
Aggregations