package org.opendaylight.controller.arphandler.internal;\r
\r
\r
-import junit.framework.TestCase;\r
-\r
import org.junit.Assert;\r
import org.junit.Test;\r
\r
-public class ArphandlerTest extends TestCase {\r
+public class ArphandlerTest {\r
\r
@Test\r
public void testArphandlerCreation() {\r
import org.junit.Assert;\r
import org.junit.Test;\r
\r
-import junit.framework.TestCase;\r
-\r
-public class TestClusteringTest extends TestCase {\r
+public class TestClusteringTest {\r
\r
@Test\r
public void testComplexClass() {\r
\r
import org.junit.Assert;\r
import org.junit.Test;\r
-\r
import org.opendaylight.controller.sal.core.ConstructionException;\r
import org.opendaylight.controller.sal.core.Node;\r
-\r
-import junit.framework.TestCase;\r
-\r
+import org.opendaylight.controller.sal.core.NodeConnector;\r
import org.opendaylight.controller.sal.packet.address.EthernetAddress;\r
-\r
import org.opendaylight.controller.sal.utils.NodeConnectorCreator;\r
-import org.opendaylight.controller.sal.core.NodeConnector;\r
import org.opendaylight.controller.sal.utils.NodeCreator;\r
\r
-public class HostNodeConnectorTest extends TestCase {\r
+public class HostNodeConnectorTest {\r
\r
@Test\r
public void testHostNodeConnector() throws UnknownHostException {\r
import java.net.InetAddress;\r
import java.net.UnknownHostException;\r
\r
-import junit.framework.TestCase;\r
-\r
import org.junit.Assert;\r
import org.junit.Test;\r
import org.opendaylight.controller.hosttracker.IHostId;\r
import org.opendaylight.controller.hosttracker.IPHostId;\r
\r
-public class HostTrackerTest extends TestCase {\r
+public class HostTrackerTest {\r
\r
@Test\r
public void testHostTrackerCallable() throws UnknownHostException {\r
\r
import org.junit.Assert;\r
import org.junit.Test;\r
-\r
import org.opendaylight.controller.sal.core.ConstructionException;\r
import org.opendaylight.controller.sal.core.Node;\r
-\r
-import junit.framework.TestCase;\r
-\r
+import org.opendaylight.controller.sal.core.NodeConnector;\r
import org.opendaylight.controller.sal.packet.address.EthernetAddress;\r
-\r
import org.opendaylight.controller.sal.utils.NodeConnectorCreator;\r
-import org.opendaylight.controller.sal.core.NodeConnector;\r
import org.opendaylight.controller.sal.utils.NodeCreator;\r
\r
-public class HostNodeConnectorTest extends TestCase {\r
+public class HostNodeConnectorTest {\r
\r
@Test\r
public void testHostNodeConnector() throws UnknownHostException {\r
if (reader == null) {
this.log.error("Cannot register the LogListener because "
+ "cannot retrieve LogReaderService");
- }
- reader.addLogListener(this.listener);
- // Now lets walk all the exiting messages
- Enumeration<LogEntry> entries = reader.getLog();
- if (entries != null) {
- while (entries.hasMoreElements()) {
- LogEntry entry = (LogEntry) entries.nextElement();
- this.listener.logged(entry);
+ } else {
+ reader.addLogListener(this.listener);
+ // Now lets walk all the exiting messages
+ Enumeration<LogEntry> entries = reader.getLog();
+ if (entries != null) {
+ while (entries.hasMoreElements()) {
+ LogEntry entry = entries.nextElement();
+ this.listener.logged(entry);
+ }
}
}
@Override
public void stop(BundleContext context) {
- ServiceReference service = null;
- service = context.getServiceReference(LogReaderService.class.getName());
- if (service != null) {
- LogReaderService reader = (LogReaderService) service;
+ ServiceReference serviceRef = context.getServiceReference(
+ LogReaderService.class.getName());
+ if (serviceRef != null) {
+ LogReaderService reader = (LogReaderService) context.getService(serviceRef);
reader.removeLogListener(this.listener);
}
if (this.shutdownHandler != null) {
}
def registerMountPoint(MountPointImpl impl) {
- dataBroker?.registerConfigurationReader(impl.mountPath,impl.readWrapper);
- dataBroker?.registerOperationalReader(impl.mountPath,impl.readWrapper);
+ //dataBroker?.registerConfigurationReader(impl.mountPath,impl.readWrapper);
+ //dataBroker?.registerOperationalReader(impl.mountPath,impl.readWrapper);
}
org.xml.sax,
javax.xml.namespace,
javax.xml.xpath,
- org.opendaylight.controller.config.api
+ org.opendaylight.controller.config.api,
+ org.opendaylight.controller.netconf.util
</Import-Package>
<Export-Package>
</Export-Package>
package org.opendaylight.controller.netconf.persist.impl;
+import com.google.common.base.Optional;
+import com.google.common.base.Preconditions;
import io.netty.channel.EventLoopGroup;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.InetSocketAddress;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import javax.annotation.concurrent.Immutable;
-
import org.opendaylight.controller.config.api.ConflictingVersionException;
import org.opendaylight.controller.config.persist.api.ConfigSnapshotHolder;
import org.opendaylight.controller.netconf.api.NetconfMessage;
import org.opendaylight.controller.netconf.client.NetconfClient;
import org.opendaylight.controller.netconf.client.NetconfClientDispatcher;
+import org.opendaylight.controller.netconf.util.NetconfUtil;
import org.opendaylight.controller.netconf.util.messages.NetconfMessageAdditionalHeader;
import org.opendaylight.controller.netconf.util.xml.XmlElement;
import org.opendaylight.controller.netconf.util.xml.XmlNetconfConstants;
import org.w3c.dom.Element;
import org.xml.sax.SAXException;
-import com.google.common.base.Optional;
-import com.google.common.base.Preconditions;
+import javax.annotation.concurrent.Immutable;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.InetSocketAddress;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
@Immutable
public class ConfigPusher {
int maxAttempts = 30;
for(int i = 0 ; i < maxAttempts; i++) {
NetconfClient netconfClient = makeNetconfConnection(configSnapshotHolder.getCapabilities(), oldClientForPossibleReuse);
- final String configSnapshot = configSnapshotHolder.getConfigSnapshot();
- logger.trace("Pushing following xml to netconf {}", configSnapshot);
+ logger.trace("Pushing following xml to netconf {}", configSnapshotHolder);
try {
pushLastConfig(configSnapshotHolder, netconfClient);
return netconfClient;
logger.info("Pushing last configuration to netconf: {}", configSnapshotHolder);
StringBuilder response = new StringBuilder("editConfig response = {");
-
NetconfMessage message = createEditConfigMessage(xmlToBePersisted, "/netconfOp/editConfig.xml");
// sending message to netconf
NetconfMessage responseMessage = getResponse(message, netconfClient);
- XmlElement element = XmlElement.fromDomDocument(responseMessage.getDocument());
- Preconditions.checkState(element.getName().equals(XmlNetconfConstants.RPC_REPLY_KEY));
- element = element.getOnlyChildElement();
-
- Util.checkIsOk(element, responseMessage);
+ NetconfUtil.checkIsMessageOk(responseMessage);
response.append(XmlUtil.toString(responseMessage.getDocument()));
response.append("}");
responseMessage = getResponse(getNetconfMessageFromResource("/netconfOp/commit.xml"), netconfClient);
- element = XmlElement.fromDomDocument(responseMessage.getDocument());
- Preconditions.checkState(element.getName().equals(XmlNetconfConstants.RPC_REPLY_KEY));
- element = element.getOnlyChildElement();
- Util.checkIsOk(element, responseMessage);
+
+ NetconfUtil.checkIsMessageOk(responseMessage);
response.append("commit response = {");
response.append(XmlUtil.toString(responseMessage.getDocument()));
response.append("}");
package org.opendaylight.controller.netconf.persist.impl;
-import org.opendaylight.controller.config.api.ConflictingVersionException;
-import org.opendaylight.controller.netconf.api.NetconfMessage;
import org.opendaylight.controller.netconf.client.NetconfClient;
import org.opendaylight.controller.netconf.client.NetconfClientDispatcher;
-import org.opendaylight.controller.netconf.util.xml.XMLNetconfUtil;
-import org.opendaylight.controller.netconf.util.xml.XmlElement;
-import org.opendaylight.controller.netconf.util.xml.XmlNetconfConstants;
-import org.opendaylight.controller.netconf.util.xml.XmlUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import javax.xml.xpath.XPathConstants;
-import javax.xml.xpath.XPathExpression;
import java.util.Set;
public final class Util {
}
}
}
-
-
- public static void checkIsOk(XmlElement element, NetconfMessage responseMessage) throws ConflictingVersionException {
- if (element.getName().equals(XmlNetconfConstants.OK)) {
- return;
- }
-
- if (element.getName().equals(XmlNetconfConstants.RPC_ERROR)) {
- logger.warn("Can not load last configuration, operation failed");
- // is it ConflictingVersionException ?
- XPathExpression xPathExpression = XMLNetconfUtil.compileXPath("/netconf:rpc-reply/netconf:rpc-error/netconf:error-info/netconf:error");
- String error = (String) XmlUtil.evaluateXPath(xPathExpression, element.getDomElement(), XPathConstants.STRING);
- if (error!=null && error.contains(ConflictingVersionException.class.getCanonicalName())) {
- throw new ConflictingVersionException(error);
- }
- throw new IllegalStateException("Can not load last configuration, operation failed: "
- + XmlUtil.toString(responseMessage.getDocument()));
- }
-
- logger.warn("Can not load last configuration. Operation failed.");
- throw new IllegalStateException("Can not load last configuration. Operation failed: "
- + XmlUtil.toString(responseMessage.getDocument()));
- }
}
--- /dev/null
+/*
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.controller.netconf.client;
+
+import io.netty.channel.nio.NioEventLoopGroup;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.opendaylight.controller.netconf.api.NetconfMessage;
+import org.opendaylight.controller.netconf.util.NetconfUtil;
+import org.opendaylight.controller.netconf.util.handler.ssh.authentication.LoginPassword;
+
+import java.net.InetSocketAddress;
+
+@Ignore
+public class SSHNetconfClientLiveTest {
+
+ NioEventLoopGroup nettyThreadgroup;
+ NetconfSshClientDispatcher netconfClientDispatcher;
+
+ @Before
+ public void setUp() {
+ nettyThreadgroup = new NioEventLoopGroup();
+ netconfClientDispatcher = new NetconfSshClientDispatcher(new LoginPassword(
+ System.getProperty("username"), System.getProperty("password")),
+ nettyThreadgroup, nettyThreadgroup);
+ }
+
+ @Test
+ public void test() throws Exception {
+ InetSocketAddress address = new InetSocketAddress(System.getProperty("host"), 830);
+ int connectionAttempts = 10, attemptMsTimeout = 1000;
+
+ NetconfClient netconfClient = new NetconfClient("client", address, connectionAttempts,
+ attemptMsTimeout, netconfClientDispatcher);
+
+ netconfClient.getCapabilities();
+
+ NetconfMessage netconfMessage = NetconfUtil.createMessage(getClass().getResourceAsStream("/get_schema.xml"));
+ NetconfMessage response = netconfClient.sendMessage(netconfMessage);
+ NetconfUtil.checkIsMessageOk(response);
+ }
+}
--- /dev/null
+<rpc message-id="2"
+ xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
+ <get-schema xmlns="urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring">
+ <identifier>ietf-netconf-monitoring</identifier>
+ <format
+ xmlns:ncm="urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring">ncm:yang
+ </format>
+ </get-schema>
+</rpc>
\ No newline at end of file
import org.opendaylight.controller.netconf.api.NetconfServerSessionPreferences;
import org.opendaylight.controller.netconf.impl.mapping.CapabilityProvider;
import org.opendaylight.controller.netconf.impl.osgi.NetconfOperationServiceFactoryListener;
-import org.opendaylight.controller.netconf.impl.util.NetconfUtil;
+import org.opendaylight.controller.netconf.util.NetconfUtil;
import org.opendaylight.controller.netconf.util.xml.XMLNetconfUtil;
import org.opendaylight.controller.netconf.util.xml.XmlNetconfConstants;
import org.opendaylight.controller.netconf.util.xml.XmlUtil;
+++ /dev/null
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.controller.netconf.impl.util;
-
-import com.google.common.base.Preconditions;
-import org.opendaylight.controller.netconf.api.NetconfMessage;
-import org.opendaylight.controller.netconf.util.xml.XmlUtil;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.w3c.dom.Document;
-import org.xml.sax.SAXException;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-
-public class NetconfUtil {
-
- private static final Logger logger = LoggerFactory.getLogger(NetconfUtil.class);
-
- public static NetconfMessage createMessage(final File f) {
- Preconditions.checkNotNull(f, "File parameter was null");
- try {
- return createMessage(new FileInputStream(f));
- } catch (final FileNotFoundException e) {
- logger.warn("File {} not found.", f, e);
- }
- return null;
- }
-
- public static NetconfMessage createMessage(final InputStream is) {
- Preconditions.checkNotNull(is, "InputStream parameter was null");
- Document doc = null;
- try {
- doc = XmlUtil.readXmlToDocument(is);
- } catch (final IOException e) {
- logger.warn("Error ocurred while parsing stream.", e);
- } catch (final SAXException e) {
- logger.warn("Error ocurred while final parsing stream.", e);
- }
- return (doc == null) ? null : new NetconfMessage(doc);
- }
-}
com.siemens.ct.exi.exceptions,
com.siemens.ct.exi.api.dom,
org.xml.sax.helpers,
+ org.opendaylight.controller.config.api,
</Import-Package>
</instructions>
</configuration>
--- /dev/null
+/*
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.netconf.util;
+
+import com.google.common.base.Preconditions;
+import org.opendaylight.controller.config.api.ConflictingVersionException;
+import org.opendaylight.controller.netconf.api.NetconfMessage;
+import org.opendaylight.controller.netconf.util.xml.XMLNetconfUtil;
+import org.opendaylight.controller.netconf.util.xml.XmlElement;
+import org.opendaylight.controller.netconf.util.xml.XmlNetconfConstants;
+import org.opendaylight.controller.netconf.util.xml.XmlUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.w3c.dom.Document;
+import org.xml.sax.SAXException;
+
+import javax.xml.xpath.XPathConstants;
+import javax.xml.xpath.XPathExpression;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+
+public class NetconfUtil {
+
+ private static final Logger logger = LoggerFactory.getLogger(NetconfUtil.class);
+
+ public static NetconfMessage createMessage(final File f) {
+ Preconditions.checkNotNull(f, "File parameter was null");
+ try {
+ return createMessage(new FileInputStream(f));
+ } catch (final FileNotFoundException e) {
+ logger.warn("File {} not found.", f, e);
+ }
+ return null;
+ }
+
+ public static NetconfMessage createMessage(final InputStream is) {
+ Preconditions.checkNotNull(is, "InputStream parameter was null");
+ Document doc = null;
+ try {
+ doc = XmlUtil.readXmlToDocument(is);
+ } catch (final IOException e) {
+ logger.warn("Error ocurred while parsing stream.", e);
+ } catch (final SAXException e) {
+ logger.warn("Error ocurred while final parsing stream.", e);
+ }
+ return (doc == null) ? null : new NetconfMessage(doc);
+ }
+
+ public static void checkIsMessageOk(NetconfMessage responseMessage) throws ConflictingVersionException {
+ XmlElement element = XmlElement.fromDomDocument(responseMessage.getDocument());
+ Preconditions.checkState(element.getName().equals(XmlNetconfConstants.RPC_REPLY_KEY));
+ element = element.getOnlyChildElement();
+
+ if (element.getName().equals(XmlNetconfConstants.OK)) {
+ return;
+ }
+
+ if (element.getName().equals(XmlNetconfConstants.RPC_ERROR)) {
+ logger.warn("Can not load last configuration, operation failed");
+ // is it ConflictingVersionException ?
+ XPathExpression xPathExpression = XMLNetconfUtil.compileXPath("/netconf:rpc-reply/netconf:rpc-error/netconf:error-info/netconf:error");
+ String error = (String) XmlUtil.evaluateXPath(xPathExpression, element.getDomElement(), XPathConstants.STRING);
+ if (error!=null && error.contains(ConflictingVersionException.class.getCanonicalName())) {
+ throw new ConflictingVersionException(error);
+ }
+ throw new IllegalStateException("Can not load last configuration, operation failed: "
+ + XmlUtil.toString(responseMessage.getDocument()));
+ }
+
+ logger.warn("Can not load last configuration. Operation failed.");
+ throw new IllegalStateException("Can not load last configuration. Operation failed: "
+ + XmlUtil.toString(responseMessage.getDocument()));
+ }
+}
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-package org.opendaylight.controller.netconf.persist.impl;
+package org.opendaylight.controller.netconf.util;
import org.junit.Test;
import org.opendaylight.controller.config.api.ConflictingVersionException;
import org.opendaylight.controller.netconf.api.NetconfMessage;
-import org.opendaylight.controller.netconf.util.xml.XmlElement;
import org.opendaylight.controller.netconf.util.xml.XmlUtil;
import org.w3c.dom.Document;
import static org.junit.Assert.fail;
import static org.junit.matchers.JUnitMatchers.containsString;
-public class ConfigPersisterNotificationHandlerTest {
+public class NetconfUtilTest {
@Test
public void testConflictingVersionDetection() throws Exception {
- Document document = XmlUtil.readXmlToDocument(getClass().getResourceAsStream("/conflictingVersionResponse.xml"));
+ Document document = XmlUtil.readXmlToDocument(getClass().getResourceAsStream("/netconfMessages/conflictingversion/conflictingVersionResponse.xml"));
try{
- Util.checkIsOk(XmlElement.fromDomDocument(document).getOnlyChildElement(), new NetconfMessage(document));
+ NetconfUtil.checkIsMessageOk(new NetconfMessage(document));
fail();
}catch(ConflictingVersionException e){
assertThat(e.getMessage(), containsString("Optimistic lock failed. Expected parent version 21, was 18"));
}
}
-
}
import org.junit.Assert;
import org.junit.Test;
-import junit.framework.TestCase;
-
-public class CommonsNorthboundTest extends TestCase {
+public class CommonsNorthboundTest {
@Test
public void testRestMessages() {
import org.junit.Assert;
import org.junit.Test;
-import junit.framework.TestCase;
-
-public class CommonsNorthboundExceptionTest extends TestCase {
+public class CommonsNorthboundExceptionTest {
@Test
public void testMethodNotAllowed() {
import java.util.HashSet;
import java.util.Set;
-import junit.framework.TestCase;
-
import org.junit.Assert;
import org.junit.Test;
import org.opendaylight.controller.sal.core.Property;
-public class ControllerManagerNorthboundTest extends TestCase {
+public class ControllerManagerNorthboundTest {
@Test
public void testControllerProperties() {
import org.junit.Assert;
import org.junit.Test;
-import junit.framework.TestCase;
-
-public class StaticRoutingNorthboundTest extends TestCase {
+public class StaticRoutingNorthboundTest {
@Test
public void testStaticRoute() {
import java.util.ArrayList;
import java.util.List;
-import junit.framework.TestCase;
-
import org.junit.Assert;
import org.junit.Test;
import org.opendaylight.controller.sal.core.Node;
import org.opendaylight.controller.sal.reader.NodeTableStatistics;
import org.opendaylight.controller.sal.utils.NodeCreator;
-public class StatisticsNorthboundTest extends TestCase {
+public class StatisticsNorthboundTest {
@Test
public void testFlowStatistics() {
package org.opendaylight.controller.switchmanager.northbound;
+import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
-import java.util.ArrayList;
import org.junit.Assert;
import org.junit.Test;
-import junit.framework.TestCase;
-
import org.opendaylight.controller.sal.core.Node;
import org.opendaylight.controller.sal.core.NodeConnector;
import org.opendaylight.controller.sal.core.Property;
import org.opendaylight.controller.sal.utils.NodeConnectorCreator;
import org.opendaylight.controller.sal.utils.NodeCreator;
-public class SwitchManagerNorthboundTest extends TestCase {
+public class SwitchManagerNorthboundTest {
@Test
public void testNodes() {
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
+import java.util.TreeMap;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
if (this.fields == null) {
result = prime * result;
} else {
- int sum = 0;
- for (MatchType field : this.fields.keySet()) {
- MatchField f = this.fields.get(field);
- sum = sum + ((field==null ? 0 : field.calculateConsistentHashCode()) ^
- (f==null ? 0 : f.hashCode()));
+ // use a tree map as the order of hashMap is not guaranteed.
+ // 2 Match objects with fields in different order are still equal.
+ // Hence the hashCode should be the same too.
+ TreeMap<MatchType, MatchField> tm = new TreeMap<MatchType, MatchField>(this.fields);
+ for (MatchType field : tm.keySet()) {
+ MatchField f = tm.get(field);
+ int fieldHashCode = (field==null ? 0 : field.calculateConsistentHashCode()) ^
+ (f==null ? 0 : f.hashCode());
+ result = prime * result + fieldHashCode;
}
- result = prime * result + sum;
}
result = prime * result + matches;
return result;
Assert.assertTrue(match1.equals(match2));
}
+ @Test
+ public void testHashCodeWithReverseMatch() throws Exception {
+ InetAddress srcIP1 = InetAddress.getByName("1.1.1.1");
+ InetAddress ipMask1 = InetAddress.getByName("255.255.255.255");
+ InetAddress srcIP2 = InetAddress.getByName("2.2.2.2");
+ InetAddress ipMask2 = InetAddress.getByName("255.255.255.255");
+ MatchField field1 = new MatchField(MatchType.NW_SRC, srcIP1, ipMask1);
+ MatchField field2 = new MatchField(MatchType.NW_DST, srcIP2, ipMask2);
+ Match match1 = new Match();
+ match1.setField(field1);
+ match1.setField(field2);
+ Match match2 = match1.reverse();
+ Assert.assertFalse(match1.hashCode() == match2.hashCode());
+ }
+
@Test
public void testHashCode() throws Exception {
byte srcMac1[] = { (byte) 0x12, (byte) 0x34, (byte) 0x56, (byte) 0x78, (byte) 0x9a, (byte) 0xbc };
import org.opendaylight.controller.samples.loadbalancer.entities.VIP;\r
import org.opendaylight.controller.samples.loadbalancer.policies.RoundRobinLBPolicy;\r
\r
-import junit.framework.TestCase;\r
-\r
/**\r
*\r
* Class to unit test the load balancing policies.\r
*\r
*/\r
-public class LoadBalancerTest extends TestCase {\r
+public class LoadBalancerTest {\r
@Test\r
public void testRoundRobinPolicy() {\r
ConfigManager cm = null;\r
c1 = new Client("10.0.0.1","TCP",(short)5003);\r
Assert.assertTrue(rrp.getPoolMemberForClient(c1, vip).equals(host4.getIp()));\r
}\r
-}
\ No newline at end of file
+}
private TopoEdgeUpdate edgeUpdate(Edge e, UpdateType type, Set<Property> props) {
switch (type) {
case ADDED:
- // Avoid redundant update as notifications trigger expensive tasks
- if (edgesDB.containsKey(e)) {
- log.trace("Skipping redundant edge addition: {}", e);
- return null;
- }
-
- // Ensure that head node connector exists
- if (!headNodeConnectorExist(e)) {
- log.warn("Ignore edge that contains invalid node connector: {}", e);
- return null;
- }
-
- // Check if nodeConnectors of the edge were correctly categorized
- // by OF plugin
- crossCheckNodeConnectors(e);
- // Make sure the props are non-null
+ // Make sure the props are non-null or create a copy
if (props == null) {
props = new HashSet<Property>();
} else {
props = new HashSet<Property>(props);
}
- //in case of node switch-over to a different cluster controller,
- //let's retain edge props
Set<Property> currentProps = this.edgesDB.get(e);
- if (currentProps != null){
+ if (currentProps != null) {
+
+ if (currentProps.equals(props)) {
+ // Avoid redundant updates as notifications trigger expensive tasks
+ log.trace("Skipping redundant edge addition: {}", e);
+ return null;
+ }
+
+ // In case of node switch-over to a different cluster controller,
+ // let's retain edge props (e.g. creation time)
props.addAll(currentProps);
}
+ // Ensure that head node connector exists
+ if (!headNodeConnectorExist(e)) {
+ log.warn("Ignore edge that contains invalid node connector: {}", e);
+ return null;
+ }
+
+ // Check if nodeConnectors of the edge were correctly categorized
+ // by protocol plugin
+ crossCheckNodeConnectors(e);
+
// Now make sure there is the creation timestamp for the
// edge, if not there, stamp with the first update
boolean found_create = false;