connector.
BREAKS BACKWARDS COMPATIBILITY FOR CONNECTOR CONFIGURATION.
SEND EMAIL TO MAILING LIST ABOUT BREAKING COMPATIBILITY FOR NETCONF CONNECTOR BEFORE MERGE!
ALL DISTRIBUTIONS THAT USE NETCONF-CONNECTOR NEED TO UPDATE CONFIGURATION OF CONNECTORS ACCORDING TO 99-netconf-connector INITIAL CONFIG FILE
Deprecated config attributes and code removed.
Extracted common connector modules(threadfactory, threadpool and client dispatcher) from config file 99-netconf-connector into 01-netconf
Change-Id: I77a93a1dc6845414474632f85c93d8a940449ac6
Signed-off-by: Maros Marsalek <mmarsale@cisco.com>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- vi: set et smarttab sw=4 tabstop=4: -->
+<!--
+ 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
+-->
+<snapshot>
+ <configuration>
+ <data xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
+ <modules xmlns="urn:opendaylight:params:xml:ns:yang:controller:config">
+
+ <!-- Netconf dispatcher to be used by all netconf-connectors -->
+ <module>
+ <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:config:netconf:client:dispatcher">prefix:netconf-client-dispatcher</type>
+ <name>global-netconf-dispatcher</name>
+ <boss-thread-group xmlns="urn:opendaylight:params:xml:ns:yang:controller:config:netconf:client:dispatcher">
+ <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:netty">prefix:netty-threadgroup</type>
+ <name>global-boss-group</name>
+ </boss-thread-group>
+ <worker-thread-group xmlns="urn:opendaylight:params:xml:ns:yang:controller:config:netconf:client:dispatcher">
+ <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:netty">prefix:netty-threadgroup</type>
+ <name>global-worker-group</name>
+ </worker-thread-group>
+ <timer xmlns="urn:opendaylight:params:xml:ns:yang:controller:config:netconf:client:dispatcher">
+ <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:netty">prefix:netty-timer</type>
+ <name>global-timer</name>
+ </timer>
+ </module>
+
+ <!-- Thread factory to be used by all threadpools in netconf-connectors -->
+ <module>
+ <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:threadpool:impl">prefix:threadfactory-naming</type>
+ <name>global-netconf-processing-executor-threadfactory</name>
+ <name-prefix xmlns="urn:opendaylight:params:xml:ns:yang:controller:threadpool:impl">remote-connector-processing-executor</name-prefix>
+ </module>
+ <!-- Flexible threadpool for all netconf connectors, Max thread count is set to 4 -->
+ <module>
+ <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:threadpool:impl:flexible">prefix:threadpool-flexible</type>
+ <name>global-netconf-processing-executor</name>
+ <minThreadCount xmlns="urn:opendaylight:params:xml:ns:yang:controller:threadpool:impl:flexible">1</minThreadCount>
+ <max-thread-count xmlns="urn:opendaylight:params:xml:ns:yang:controller:threadpool:impl:flexible">4</max-thread-count>
+ <keepAliveMillis xmlns="urn:opendaylight:params:xml:ns:yang:controller:threadpool:impl:flexible">600000</keepAliveMillis>
+ <threadFactory xmlns="urn:opendaylight:params:xml:ns:yang:controller:threadpool:impl:flexible">
+ <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:threadpool">prefix:threadfactory</type>
+ <name>global-netconf-processing-executor-threadfactory</name>
+ </threadFactory>
+ </module>
+ </modules>
+
+ <services xmlns="urn:opendaylight:params:xml:ns:yang:controller:config">
+ <service>
+ <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:config:netconf">prefix:netconf-client-dispatcher</type>
+ <instance>
+ <name>global-netconf-dispatcher</name>
+ <provider>/modules/module[type='netconf-client-dispatcher'][name='global-netconf-dispatcher']</provider>
+ </instance>
+ </service>
+ <service>
+ <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:threadpool">prefix:threadfactory</type>
+ <instance>
+ <name>global-netconf-processing-executor-threadfactory</name>
+ <provider>/modules/module[type='threadfactory-naming'][name='global-netconf-processing-executor-threadfactory']</provider>
+ </instance>
+ </service>
+ <service>
+ <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:threadpool">prefix:threadpool</type>
+ <instance>
+ <name>global-netconf-processing-executor</name>
+ <provider>/modules/module[type='threadpool-flexible'][name='global-netconf-processing-executor']</provider>
+ </instance>
+ </service>
+ </services>
+
+ </data>
+ </configuration>
+ <required-capabilities>
+ <capability>urn:opendaylight:params:xml:ns:yang:controller:config:netconf:client:dispatcher?module=odl-netconfig-client-cfg&revision=2014-04-08</capability>
+ <capability>urn:opendaylight:params:xml:ns:yang:controller:threadpool:impl?module=threadpool-impl&revision=2013-04-05</capability>
+ <capability>urn:opendaylight:params:xml:ns:yang:controller:threadpool:impl:flexible?module=threadpool-impl-flexible&revision=2013-12-01</capability>
+ </required-capabilities>
+</snapshot>
<configuration>
<data xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
<modules xmlns="urn:opendaylight:params:xml:ns:yang:controller:config">
-
- <!-- Netconf dispatcher to be used by all netconf-connectors -->
- <module>
- <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:config:netconf:client:dispatcher">prefix:netconf-client-dispatcher</type>
- <name>global-netconf-dispatcher</name>
- <boss-thread-group xmlns="urn:opendaylight:params:xml:ns:yang:controller:config:netconf:client:dispatcher">
- <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:netty">prefix:netty-threadgroup</type>
- <name>global-boss-group</name>
- </boss-thread-group>
- <worker-thread-group xmlns="urn:opendaylight:params:xml:ns:yang:controller:config:netconf:client:dispatcher">
- <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:netty">prefix:netty-threadgroup</type>
- <name>global-worker-group</name>
- </worker-thread-group>
- <timer xmlns="urn:opendaylight:params:xml:ns:yang:controller:config:netconf:client:dispatcher">
- <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:netty">prefix:netty-timer</type>
- <name>global-timer</name>
- </timer>
- </module>
-
- <!-- Netconf dispatcher to be used by all netconf-connectors -->
- <module>
- <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:threadpool:impl">prefix:threadfactory-naming</type>
- <name>global-netconf-processing-executor-threadfactory</name>
- <name-prefix xmlns="urn:opendaylight:params:xml:ns:yang:controller:threadpool:impl">remote-connector-processing-executor</name-prefix>
- </module>
- <module>
- <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:threadpool:impl:flexible">prefix:threadpool-flexible</type>
- <name>global-netconf-processing-executor</name>
- <minThreadCount xmlns="urn:opendaylight:params:xml:ns:yang:controller:threadpool:impl:flexible">1</minThreadCount>
- <max-thread-count xmlns="urn:opendaylight:params:xml:ns:yang:controller:threadpool:impl:flexible">4</max-thread-count>
- <keepAliveMillis xmlns="urn:opendaylight:params:xml:ns:yang:controller:threadpool:impl:flexible">600000</keepAliveMillis>
- <threadFactory xmlns="urn:opendaylight:params:xml:ns:yang:controller:threadpool:impl:flexible">
- <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:threadpool">prefix:threadfactory</type>
- <name>global-netconf-processing-executor-threadfactory</name>
- </threadFactory>
- </module>
-
<!-- Loopback connection to netconf server in controller using netconf-connector -->
<module>
<type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:connector:netconf">prefix:sal-netconf-connector</type>
</processing-executor>
</module>
</modules>
-
- <services xmlns="urn:opendaylight:params:xml:ns:yang:controller:config">
- <service>
- <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:config:netconf">prefix:netconf-client-dispatcher</type>
- <instance>
- <name>global-netconf-dispatcher</name>
- <provider>/modules/module[type='netconf-client-dispatcher'][name='global-netconf-dispatcher']</provider>
- </instance>
- </service>
- <service>
- <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:threadpool">prefix:threadfactory</type>
- <instance>
- <name>global-netconf-processing-executor-threadfactory</name>
- <provider>/modules/module[type='threadfactory-naming'][name='global-netconf-processing-executor-threadfactory']</provider>
- </instance>
- </service>
- <service>
- <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:threadpool">prefix:threadpool</type>
- <instance>
- <name>global-netconf-processing-executor</name>
- <provider>/modules/module[type='threadpool-flexible'][name='global-netconf-processing-executor']</provider>
- </instance>
- </service>
- </services>
-
</data>
</configuration>
<required-capabilities>
<capability>urn:opendaylight:params:xml:ns:yang:controller:md:sal:connector:netconf?module=odl-sal-netconf-connector-cfg&revision=2013-10-28</capability>
- <capability>urn:opendaylight:params:xml:ns:yang:controller:config:netconf:client:dispatcher?module=odl-netconfig-client-cfg&revision=2014-04-08</capability>
- <capability>urn:opendaylight:params:xml:ns:yang:controller:threadpool:impl?module=threadpool-impl&revision=2013-04-05</capability>
- <capability>urn:opendaylight:params:xml:ns:yang:controller:threadpool:impl:flexible?module=threadpool-impl-flexible&revision=2013-12-01</capability>
</required-capabilities>
</snapshot>
import java.io.File;
import java.io.InputStream;
-import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
import org.opendaylight.controller.netconf.client.NetconfClientDispatcher;
-import org.opendaylight.controller.netconf.client.NetconfClientDispatcherImpl;
import org.opendaylight.controller.netconf.client.conf.NetconfClientConfiguration;
import org.opendaylight.controller.netconf.client.conf.NetconfReconnectingClientConfiguration;
import org.opendaylight.controller.netconf.client.conf.NetconfReconnectingClientConfigurationBuilder;
import org.opendaylight.protocol.framework.ReconnectStrategy;
import org.opendaylight.protocol.framework.ReconnectStrategyFactory;
import org.opendaylight.protocol.framework.TimedReconnectStrategy;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Host;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
import org.opendaylight.yangtools.yang.model.util.repo.AbstractCachingSchemaSourceProvider;
import org.opendaylight.yangtools.yang.model.util.repo.FilesystemSchemaCachingProvider;
import org.opendaylight.yangtools.yang.model.util.repo.SchemaSourceProvider;
import org.opendaylight.yangtools.yang.model.util.repo.SchemaSourceProviders;
import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceReference;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import com.google.common.base.Preconditions;
-import com.google.common.net.InetAddresses;
-import io.netty.util.HashedWheelTimer;
-
/**
*
*/
@Override
protected void customValidation() {
checkNotNull(getAddress(), addressJmxAttribute);
+ checkCondition(isHostAddressPresent(getAddress()), "Host address not present in " + getAddress(), addressJmxAttribute);
checkNotNull(getPort(), portJmxAttribute);
checkNotNull(getDomRegistry(), portJmxAttribute);
checkNotNull(getDomRegistry(), domRegistryJmxAttribute);
checkNotNull(getBetweenAttemptsTimeoutMillis(), betweenAttemptsTimeoutMillisJmxAttribute);
checkCondition(getBetweenAttemptsTimeoutMillis() > 0, "must be > 0", betweenAttemptsTimeoutMillisJmxAttribute);
- // FIXME BUG-944 remove backwards compatibility
- if(getClientDispatcher() == null) {
- checkCondition(getBossThreadGroup() != null, "Client dispatcher was not set, thread groups have to be set instead", bossThreadGroupJmxAttribute);
- checkCondition(getWorkerThreadGroup() != null, "Client dispatcher was not set, thread groups have to be set instead", workerThreadGroupJmxAttribute);
- }
+ checkNotNull(getClientDispatcher(), clientDispatcherJmxAttribute);
+ checkNotNull(getBindingRegistry(), bindingRegistryJmxAttribute);
+ checkNotNull(getProcessingExecutor(), processingExecutorJmxAttribute);
// Check username + password in case of ssh
if(getTcpOnly() == false) {
checkNotNull(getPassword(), passwordJmxAttribute);
}
- // FIXME BUG 944 remove this warning
- if(getBindingRegistry() == null) {
- logger.warn("Configuration property: \"binding-registry\" not set for sal-netconf-connector (" + getIdentifier() + "). " +
- "Netconf-connector now requires a dependency on \"binding-broker-osgi-registry\". " +
- "The dependency is optional for now to preserve backwards compatibility, but will be mandatory in the future. " +
- "Please set the property as in \"01-netconf-connector\" initial config file. " +
- "The service will be retrieved from OSGi service registry now.");
- }
+ }
- // FIXME BUG 944 remove this warning
- if(getProcessingExecutor() == null) {
- logger.warn("Configuration property: \"processing-executor\" not set for sal-netconf-connector (" + getIdentifier() + "). " +
- "Netconf-connector now requires a dependency on \"threadpool\". " +
- "The dependency is optional for now to preserve backwards compatibility, but will be mandatory in the future. " +
- "Please set the property as in \"01-netconf-connector\" initial config file. " +
- "New instance will be created for the executor.");
- }
+ private boolean isHostAddressPresent(Host address) {
+ return address.getDomainName() != null ||
+ address.getIpAddress() != null && (address.getIpAddress().getIpv4Address() != null || address.getIpAddress().getIpv6Address() != null);
}
@Override
public java.lang.AutoCloseable createInstance() {
final RemoteDeviceId id = new RemoteDeviceId(getIdentifier());
- final ExecutorService globalProcessingExecutor = getGlobalProcessingExecutor();
+ final ExecutorService globalProcessingExecutor = getProcessingExecutorDependency().getExecutor();
final Broker domBroker = getDomRegistryDependency();
- final BindingAwareBroker bindingBroker = getBindingRegistryBackwards();
+ final BindingAwareBroker bindingBroker = getBindingRegistryDependency();
final RemoteDeviceHandler salFacade = new NetconfDeviceSalFacade(id, domBroker, bindingBroker, bundleContext, globalProcessingExecutor);
final NetconfDevice device =
final NetconfDeviceCommunicator listener = new NetconfDeviceCommunicator(id, device);
final NetconfReconnectingClientConfiguration clientConfig = getClientConfig(listener);
- // FIXME BUG-944 remove backwards compatibility
- final NetconfClientDispatcher dispatcher = getClientDispatcher() == null ? createDispatcher() : getClientDispatcherDependency();
+ final NetconfClientDispatcher dispatcher = getClientDispatcherDependency();
listener.initializeRemoteConnection(dispatcher, clientConfig);
return new AutoCloseable() {
};
}
- private BindingAwareBroker getBindingRegistryBackwards() {
- if(getBindingRegistry() != null) {
- return getBindingRegistryDependency();
- } else {
- // FIXME BUG 944 remove backwards compatibility
- final ServiceReference<BindingAwareBroker> serviceReference = bundleContext.getServiceReference(BindingAwareBroker.class);
- Preconditions
- .checkNotNull(
- serviceReference,
- "Unable to retrieve %s from OSGi service registry, use binding-registry config property to inject %s with config subsystem",
- BindingAwareBroker.class, BindingAwareBroker.class);
- return bundleContext.getService(serviceReference);
- }
- }
-
- private ExecutorService getGlobalProcessingExecutor() {
- if(getProcessingExecutor() != null) {
- return getProcessingExecutorDependency().getExecutor();
- } else {
- // FIXME BUG 944 remove backwards compatibility
- return Executors.newCachedThreadPool();
- }
- }
-
private synchronized AbstractCachingSchemaSourceProvider<String, InputStream> getGlobalNetconfSchemaProvider() {
if(GLOBAL_NETCONF_SOURCE_PROVIDER == null) {
final String storageFile = "cache/schema";
return GLOBAL_NETCONF_SOURCE_PROVIDER;
}
- // FIXME BUG-944 remove backwards compatibility
- /**
- * @deprecated Use getClientDispatcherDependency method instead to retrieve injected dispatcher.
- * This one creates new instance of NetconfClientDispatcher and will be removed in near future.
- */
- @Deprecated
- private NetconfClientDispatcher createDispatcher() {
- return new NetconfClientDispatcherImpl(getBossThreadGroupDependency(), getWorkerThreadGroupDependency(), new HashedWheelTimer());
- }
-
public void setBundleContext(final BundleContext bundleContext) {
this.bundleContext = bundleContext;
}
}
private InetSocketAddress getSocketAddress() {
- /*
- * Uncomment after Switch to IP Address
- if(getAddress().getIpv4Address() != null) {
- addressValue = getAddress().getIpv4Address().getValue();
+ if(getAddress().getDomainName() != null) {
+ return new InetSocketAddress(getAddress().getDomainName().getValue(), getPort().getValue());
} else {
- addressValue = getAddress().getIpv6Address().getValue();
+ IpAddress ipAddress = getAddress().getIpAddress();
+ String ip = ipAddress.getIpv4Address() != null ? ipAddress.getIpv4Address().getValue() : ipAddress.getIpv6Address().getValue();
+ return new InetSocketAddress(ip, getPort().getValue());
}
- */
- final InetAddress inetAddress = InetAddresses.forString(getAddress());
- return new InetSocketAddress(inetAddress, getPort().intValue());
}
}
import opendaylight-md-sal-dom {prefix dom;}
import opendaylight-md-sal-binding {prefix md-sal-binding; revision-date 2013-10-28;}
import odl-netconf-cfg { prefix cfg-net; revision-date 2014-04-08; }
+ import ietf-inet-types {prefix inet; revision-date "2010-09-24";}
description
"Service definition for Binding Aware MD-SAL.";
when "/config:modules/config:module/config:type = 'sal-netconf-connector'";
leaf address {
- type string;
+ type inet:host;
}
leaf port {
- type uint32;
+ type inet:port-number;
}
leaf tcp-only {
container binding-registry {
uses config:service-ref {
refine type {
- // FIXME BUG-944 make mandatory (remove backwards compatibility)
- mandatory false;
+ mandatory true;
config:required-identity md-sal-binding:binding-broker-osgi-registry;
}
}
}
- // FIXME BUG-944 remove backwards compatibility
- // Deprecated, replaced by client dispatcher.
- // This dependency will be removed in near future and all configurations of netconf-connector need to be changed to use dispatcher dependency.
- container boss-thread-group {
- uses config:service-ref {
- refine type {
- mandatory false;
- config:required-identity netty:netty-threadgroup;
- }
- }
- }
-
- // FIXME BUG-944 remove backwards compatibility
- // Deprecated, replaced by client dispatcher.
- // This dependency will be removed in near future and all configurations of netconf-connector need to be changed to use dispatcher dependency.
- container worker-thread-group {
- uses config:service-ref {
- refine type {
- mandatory false;
- config:required-identity netty:netty-threadgroup;
- }
- }
- }
-
container event-executor {
uses config:service-ref {
refine type {
+ mandatory true;
config:required-identity netty:netty-event-executor;
}
}
container processing-executor {
uses config:service-ref {
refine type {
- // FIXME BUG-944 make mandatory (remove backwards compatibility)
- mandatory false;
+ mandatory true;
config:required-identity th:threadpool;
}
}
description "Makes up for flaws in netty threading design";
}
- // Replaces thread group dependencies
container client-dispatcher {
uses config:service-ref {
refine type {