Bug-2208: Added ability to configure keepalive and deadtimer 49/13449/3
authorMilos Fabian <milfabia@cisco.com>
Mon, 8 Dec 2014 13:51:47 +0000 (14:51 +0100)
committerMilos Fabian <milfabia@cisco.com>
Tue, 9 Dec 2014 07:45:49 +0000 (07:45 +0000)
-d, --deadtimer <0..255> (optional, default 120) - DeadTimer value in seconds
-ka, --keepalive <0.255> (optional, deafult 30) - KeepAlive timer value in seconds

Change-Id: I1fcc983f96793853d719ed8c5aaa241e848801b4
Signed-off-by: Milos Fabian <milfabia@cisco.com>
pcep/pcc-mock/src/main/java/org/opendaylight/protocol/pcep/pcc/mock/Main.java
pcep/pcc-mock/src/test/java/org/opendaylight/protocol/pcep/pcc/mock/PCCMockTest.java

index 04b9cad12e57107125ec7d71390ef7cdb4c82b78..74e591f679a42820dd5ad37a476f4b32bd7a1e59 100644 (file)
@@ -53,6 +53,8 @@ public final class Main {
         int lsps = 1;
         boolean pcError = false;
         final LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
+        short ka = DEFAULT_KEEP_ALIVE;
+        short dt = DEFAULT_DEAD_TIMER;
 
         getRootLogger(lc).setLevel(ch.qos.logback.classic.Level.INFO);
         int argIdx = 0;
@@ -69,18 +71,22 @@ public final class Main {
                 pcError = true;
             } else if (args[argIdx].equals("--log-level")) {
                 getRootLogger(lc).setLevel(Level.toLevel(args[++argIdx], ch.qos.logback.classic.Level.INFO));
+            } else if (args[argIdx].equals("--keepalive") || args[argIdx].equals("-ka")) {
+                ka = Short.valueOf(args[++argIdx]);
+            } else if (args[argIdx].equals("--deadtimer") || args[argIdx].equals("-d")) {
+                dt = Short.valueOf(args[++argIdx]);
             } else {
                 LOG.warn("WARNING: Unrecognized argument: {}", args[argIdx]);
             }
             argIdx++;
         }
-        createPCCs(lsps, pcError, pccCount, localAddress, remoteAddress);
+        createPCCs(lsps, pcError, pccCount, localAddress, remoteAddress, ka, dt);
     }
 
     public static void createPCCs(final int lspsPerPcc, final boolean pcerr, final int pccCount,
-            final InetAddress localAddress, final List<InetAddress> remoteAddress) throws InterruptedException, ExecutionException {
+            final InetAddress localAddress, final List<InetAddress> remoteAddress, final short keepalive, final short deadtimer) throws InterruptedException, ExecutionException {
         final SessionNegotiatorFactory<Message, PCEPSessionImpl, PCEPSessionListener> snf = new DefaultPCEPSessionNegotiatorFactory(
-                new OpenBuilder().setKeepalive(DEFAULT_KEEP_ALIVE).setDeadTimer(DEFAULT_DEAD_TIMER).setSessionId((short) 0).build(), 0);
+                new OpenBuilder().setKeepalive(keepalive).setDeadTimer(deadtimer).setSessionId((short) 0).build(), 0);
 
         final StatefulActivator activator07 = new StatefulActivator();
         activator07.start(ServiceLoaderPCEPExtensionProviderContext.getSingletonInstance());
index 173a9dd89470e956baffb818ee986cb5eab22952..225b673e036195ca6269c62aef5aac8096636f95 100644 (file)
@@ -30,7 +30,7 @@ public class PCCMockTest {
     public void testSessionEstablishment() {
         try {
             org.opendaylight.protocol.pcep.testtool.Main.main(new String[]{"-a", "127.0.1.0:4189", "-ka", "10", "-d", "0", "--stateful", "--active"});
-            Main.main(new String[] {"--local-address", "127.0.0.1", "--remote-address", "127.0.1.0", "--pcc", "2", "--lsp", "1", "--log-level", "DEBUG"});
+            Main.main(new String[] {"--local-address", "127.0.0.1", "--remote-address", "127.0.1.0", "--pcc", "2", "--lsp", "1", "--log-level", "DEBUG", "-ka", "10", "-d", "0",});
         } catch (Exception e) {
             Assert.fail(e.getMessage());
         }