X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fprotocol_plugins%2Fopenflow%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fprotocol_plugin%2Fopenflow%2Finternal%2FDiscoveryService.java;h=d8fe7a4cae22176bd14229c07dc6ea3172dc7768;hb=752d1c2dd164f5789a9197b3718dc790c02fec73;hp=26ed4f237098ba3be7818678be684bc1af33d068;hpb=889a586b7db63f36ea608caa54bba8d7a222ef45;p=controller.git diff --git a/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/DiscoveryService.java b/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/DiscoveryService.java index 26ed4f2370..d8fe7a4cae 100644 --- a/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/DiscoveryService.java +++ b/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/DiscoveryService.java @@ -85,11 +85,11 @@ public class DiscoveryService implements IInventoryShimExternalListener, private long discoveryTimerTick = 1L * 1000; // per tick in msec private int discoveryTimerTickCount = 0; // main tick counter private int discoveryBatchMaxPorts = 500; // max # of ports handled in one batch - private int discoveryBatchRestartTicks = 30; // periodically restart batching process - private int discoveryBatchPausePeriod = 2; // pause for few secs + private int discoveryBatchRestartTicks = getDiscoveryInterval(); // periodically restart batching process + private int discoveryBatchPausePeriod = 5; // pause for few secs private int discoveryBatchPauseTicks = discoveryBatchRestartTicks - discoveryBatchPausePeriod; // pause after this point - private int discoveryRetry = 1; // number of retry after initial timeout - private int discoveryTimeoutTicks = 2; // timeout 2 sec + private int discoveryRetry = 2; // number of retry after initial timeout + private int discoveryTimeoutTicks = getDiscoveryTimeout(); // timeout in sec private int discoveryAgeoutTicks = 120; // age out 2 min private int discoveryConsistencyCheckMultiple = 2; // multiple of discoveryBatchRestartTicks private int discoveryConsistencyCheckTickCount = discoveryBatchPauseTicks; // CC tick counter @@ -127,7 +127,7 @@ public class DiscoveryService implements IInventoryShimExternalListener, if (shuttingDown) return; } catch (Exception e2) { - e2.printStackTrace(); + logger.error("",e2); } } } @@ -256,8 +256,8 @@ public class DiscoveryService implements IInventoryShimExternalListener, try { ethPkt.deserialize(data, 0, data.length * NetUtils.NumBitsInAByte); } catch (Exception e) { - logger.warn("Failed to decode LLDP packet from " - + inPkt.getIncomingNodeConnector() + ": " + e); + logger.warn("Failed to decode LLDP packet from {}: {}", + inPkt.getIncomingNodeConnector(), e); return PacketResult.IGNORED; } if (ethPkt.getPayload() instanceof LLDP) { @@ -1349,7 +1349,7 @@ public class DiscoveryService implements IInventoryShimExternalListener, portIdTlv.setType((byte) LLDPTLV.TLVType.PortID.getValue()); // Create LLDP TTL TLV - byte[] ttl = new byte[] { (byte) 120 }; + byte[] ttl = new byte[] {(byte) 0, (byte) 120 }; ttlTlv = new LLDPTLV(); ttlTlv.setType((byte) LLDPTLV.TLVType.TTL.getValue()).setLength( (short) ttl.length).setValue(ttl); @@ -1475,4 +1475,44 @@ public class DiscoveryService implements IInventoryShimExternalListener, return sourceMac; } + + /** + * This method returns the interval which determines how often the discovery + * packets will be sent. Default is 300 seconds. + * + * @return The discovery interval in second + */ + private static int getDiscoveryInterval() { + String elapsedTime = System.getProperty("of.discoveryInterval"); + int rv = 300; + + try { + if (elapsedTime != null) { + rv = Integer.parseInt(elapsedTime); + } + } catch (Exception e) { + } + + return rv; + } + + /** + * This method returns the timeout value in waiting for response of a + * discovery query. Default is 60 seconds. + * + * @return The discovery timeout in second + */ + private static int getDiscoveryTimeout() { + String elapsedTime = System.getProperty("of.discoveryTimeout"); + int rv = 60; + + try { + if (elapsedTime != null) { + rv = Integer.parseInt(elapsedTime); + } + } catch (Exception e) { + } + + return rv; + } }