X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fnetconf%2Fnetconf-util%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fnetconf%2Futil%2Fosgi%2FNetconfConfigUtil.java;h=6855aa73c3685c2e1b1b40e7a42b37c6f653063d;hb=edcc020c8fda4b13f22a31d79c13feef0b53b0ee;hp=333fea3493172286fdba2c807eff105760741411;hpb=b1ad47e987f7e73ebcd44f2076f57550715f75d6;p=controller.git diff --git a/opendaylight/netconf/netconf-util/src/main/java/org/opendaylight/controller/netconf/util/osgi/NetconfConfigUtil.java b/opendaylight/netconf/netconf-util/src/main/java/org/opendaylight/controller/netconf/util/osgi/NetconfConfigUtil.java index 333fea3493..6855aa73c3 100644 --- a/opendaylight/netconf/netconf-util/src/main/java/org/opendaylight/controller/netconf/util/osgi/NetconfConfigUtil.java +++ b/opendaylight/netconf/netconf-util/src/main/java/org/opendaylight/controller/netconf/util/osgi/NetconfConfigUtil.java @@ -11,12 +11,13 @@ package org.opendaylight.controller.netconf.util.osgi; import com.google.common.base.Optional; import io.netty.channel.local.LocalAddress; import java.net.InetSocketAddress; +import java.util.concurrent.TimeUnit; import org.osgi.framework.BundleContext; import org.slf4j.Logger; import org.slf4j.LoggerFactory; public final class NetconfConfigUtil { - private static final Logger logger = LoggerFactory.getLogger(NetconfConfigUtil.class); + private static final Logger LOG = LoggerFactory.getLogger(NetconfConfigUtil.class); private static final String PREFIX_PROP = "netconf."; @@ -32,7 +33,7 @@ public final class NetconfConfigUtil { private static final String PRIVATE_KEY_PATH_PROP = ".pk.path"; private static final String CONNECTION_TIMEOUT_MILLIS_PROP = "connectionTimeoutMillis"; - private static final long DEFAULT_TIMEOUT_MILLIS = 5000; + public static final long DEFAULT_TIMEOUT_MILLIS = TimeUnit.SECONDS.toMillis(30); private static final LocalAddress netconfLocalAddress = new LocalAddress("netconf"); public static LocalAddress getNetconfLocalAddress() { @@ -48,34 +49,11 @@ public final class NetconfConfigUtil { try { return Long.parseLong(timeoutString); } catch (final NumberFormatException e) { - logger.warn("Cannot parse {} property: {}, using defaults", key, timeoutString, e); + LOG.warn("Cannot parse {} property: {}, using defaults", key, timeoutString, e); return DEFAULT_TIMEOUT_MILLIS; } } - /** - * Get extracted address or default. - * - * @throws java.lang.IllegalStateException if neither address is present. - */ - private static InetSocketAddress getNetconfAddress(final InetSocketAddress defaultAddress, Optional extractedAddress, InfixProp infix) { - InetSocketAddress inetSocketAddress; - - if (extractedAddress.isPresent() == false) { - logger.debug("Netconf {} address not found, falling back to default {}", infix, defaultAddress); - - if (defaultAddress == null) { - logger.warn("Netconf {} address not found, default address not provided", infix); - throw new IllegalStateException("Netconf " + infix + " address not found, default address not provided"); - } - inetSocketAddress = defaultAddress; - } else { - inetSocketAddress = extractedAddress.get(); - } - - return inetSocketAddress; - } - public static String getPrivateKeyPath(final BundleContext context) { return getPropertyValue(context, getPrivateKeyKey()); } @@ -112,7 +90,7 @@ public final class NetconfConfigUtil { try { return Optional.of(parseAddress(address, port)); } catch (final RuntimeException e) { - logger.warn("Unable to parse {} netconf address from {}:{}, fallback to default", + LOG.warn("Unable to parse {} netconf address from {}:{}, fallback to default", infixProp, address, port, e); } }