cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Announcements

Community Helping Community

321
Views
0
Helpful
3
Replies
Beginner

topology event duplicate

Using method Topology::addTopologyListener(...) I receive the same EDGES_ADD events every minute. Note that my network does not change but I receive add events which imply change.

Is this functionality just a thin veneer on top of NetworkElement::addCDPListener(..) ?

I recognise that the topology package, in future, could have implementations other than CDP, such as LLDP.

Thus topology provides independence from the underlying protocol, which might be useful to client code.

What additional value does it provide on top of CDP functionality?

I was hoping to receive just one EDGES_ADD event per edge and no further events regarding that edge until the network changes.

Can you please confirm the intended functionality?

Everyone's tags (6)
3 REPLIES 3
Hall of Fame Cisco Employee

Re: topology event duplicate

This reads like a bug to me.  The description indicates that the event should only fire when a new edge is added.  Can you provide a snippet of code that shows this issue?

Highlighted
Beginner

Re: topology event duplicate

Joseph, thank you for discussing the topology functionality.

I have written a Junit test case to reproduce the problem.

The test does not assert the required behaviour and thus fail.

It just prints the address at the tail of the edge.

I ran the test for 3 minutes on two networks and both show duplicates.

Here is the output:

3-node:

172.16.1.59

172.16.1.57

10.0.0.1

10.0.0.10

172.16.1.57

172.16.1.59

10.0.0.1

10.0.0.10

172.16.1.57

172.16.1.59

10.0.0.1

5-node:

10.0.0.1

172.16.1.59

10.0.128.2

172.16.1.55

172.16.1.58

172.16.1.57

10.0.0.1

172.16.1.59

172.16.1.55

10.0.128.2

172.16.1.58

172.16.1.57

10.0.0.1

172.16.1.55

10.0.128.2

172.16.1.59

172.16.1.58

You might like to modify the test case to insert the addresses into a set and assert that the add method returns true. This test could become part of the continuous test suite for ONEP SDK.

(PS: I’ve done this for you at the end)

Below is the test case source code.

If you add it to your own test class then just hack the credentials to establish a connection.

Or you can add this code ‘as is’ to class HelloNetworkTest in the HelloNetwork project.

The clone commands are:

git clone http://codehub-one-samples-review.cisco.com:8090/java-onepk-HelloNetwork

git clone http://codehub-one-samples-review.cisco.com:8090/onepk_build_tools

@Test

public void testTopology() throws IOException, OnepException, InterruptedException {

final SampleNetworkApplication app = new SampleNetworkApplication(

programOptions.applicationName);

try {

final NetworkElement networkElement = app

.getNetworkElement(programOptions.elementHostname);

networkElement.connect( //

programOptions.elementUsername, //

programOptions.elementPassword, //

sessionConfig);

final Topology topology = new Topology(networkElement,TopologyType.CDP);

List topologyFilterList=Arrays.asList(new TopologyEventType[]{TopologyEventType.EDGES_ADD});

final TopologyFilter topologyFilter = new TopologyFilter(topologyFilterList);

final TopologyListener listener=new TopologyListener() {

@Override

public void handleEvent(TopologyEvent event, Object clientData) {

System.out.println(event.getEdgeList().get(0).getTailNodeConnector().getAddressList().get(0).getHostAddress());

}

};

topology.addTopologyListener(listener, topologyFilter, null);

Thread.sleep(3 * 60 * 1000L);

} finally {

app.disconnectAll();

}

}

Below is a test case that asserts the expected condition.

I wrote it for you because it is non-trivial to communicate a problem from a background thread into the foreground (Junit) thread.

The test currently fails, as follows:

java.lang.AssertionError: Duplicated edges: [Edge[Node[iosv-2,,CDP_NODE],NodeConnector[GigabitEthernet0/1,ONEP_CDP_CONNECTOR],Node[iosv-1,,CDP_NODE],NodeConnector[GigabitEthernet0/1,ONEP_CDP_CONNECTOR]]]

at org.junit.Assert.fail(Assert.java:88)

at org.junit.Assert.assertTrue(Assert.java:41)

at com.cisco.onep.examples.hn.HelloNetworkTest.testTopologyEventNotDuplicated(HelloNetworkTest.java:180)

Please add this test to the continuous test suite of ONEP SDK (hack the connection as necessary):

/**

  • Assert that Topology events are not duplicated.

*

  • @author Ken Jarrad kjarrad@cisco.com

*/

@Test

public void testTopologyEventNotDuplicated() throws IOException, OnepException, InterruptedException {

final SampleNetworkApplication app = new SampleNetworkApplication(

programOptions.applicationName);

try {

final NetworkElement networkElement = app

.getNetworkElement(programOptions.elementHostname);

networkElement.connect( //

programOptions.elementUsername, //

programOptions.elementPassword, //

sessionConfig);

final Topology topology = new Topology(networkElement, TopologyType.CDP);

List();

final TopologyListener listener = new TopologyListener() {

@Override

public void handleEvent(TopologyEvent event, Object clientData) {

final Edge edge = event.getEdgeList().get(0);

final boolean accepted = all.add(edge);

if (!accepted)

synchronized (duplicates) {

duplicates.add(edge);

duplicates.notify();

}

}

};

final int handle = topology.addTopologyListener(listener, topologyFilter, null);

try {

synchronized (duplicates) {

duplicates.wait(3 * 60 * 1000L);

}

assertTrue("Duplicated edges: " + duplicates, duplicates.isEmpty());

} finally {

topology.removeTopologyListener(handle);

}

} finally {

// topology.

app.disconnectAll();

}

}

Beginner

Re: topology event duplicate

I have filed a bug for this: https://cdetsng.cisco.com/webui/;jsessionid=3AC896C2A67B97AE88B975FA7F240741.webui-mantis#view=CSCup80398

Content for Community-Ad
FusionCharts will render here