2 * Copyright (c) 2016 Cisco and/or its affiliates.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at:
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package io.fd.honeycomb.northbound.netconf;
19 import com.google.inject.Inject;
20 import com.google.inject.name.Named;
21 import io.fd.honeycomb.binding.init.ProviderTrait;
22 import io.netty.channel.nio.NioEventLoopGroup;
23 import io.netty.util.Timer;
24 import java.util.concurrent.TimeUnit;
25 import org.opendaylight.netconf.api.NetconfServerDispatcher;
26 import org.opendaylight.netconf.api.monitoring.NetconfMonitoringService;
27 import org.opendaylight.netconf.impl.NetconfServerDispatcherImpl;
28 import org.opendaylight.netconf.impl.ServerChannelInitializer;
29 import org.opendaylight.netconf.impl.SessionIdProvider;
30 import org.opendaylight.netconf.impl.osgi.AggregatedNetconfOperationServiceFactory;
31 import org.opendaylight.netconf.mapping.api.NetconfOperationServiceFactory;
33 public final class NetconfServerDispatcherProvider extends ProviderTrait<NetconfServerDispatcher> {
34 private static final long CONNECTION_TIMEOUT_MILLIS = TimeUnit.SECONDS.toMillis(20);
37 @Named(NetconfModule.HONEYCOMB_NETCONF_MAPPER_AGGR)
38 private NetconfOperationServiceFactory aggregator;
40 private NetconfMonitoringService monitoringService;
44 private NioEventLoopGroup nettyThreadgroup;
47 protected NetconfServerDispatcherImpl create() {
48 AggregatedNetconfOperationServiceFactory netconfOperationProvider =
49 new AggregatedNetconfOperationServiceFactory();
50 netconfOperationProvider.onAddNetconfOperationServiceFactory(aggregator);
52 NetconfServerSessionNegotiatorFactory serverNegotiatorFactory =
53 new NetconfServerSessionNegotiatorFactory(timer, netconfOperationProvider, new SessionIdProvider(),
54 CONNECTION_TIMEOUT_MILLIS, monitoringService);
55 ServerChannelInitializer serverChannelInitializer = new ServerChannelInitializer(serverNegotiatorFactory);
57 return new NetconfServerDispatcherImpl(serverChannelInitializer, nettyThreadgroup, nettyThreadgroup);
60 private static final class NetconfServerSessionNegotiatorFactory extends
61 org.opendaylight.netconf.impl.NetconfServerSessionNegotiatorFactory {
63 NetconfServerSessionNegotiatorFactory(final Timer timer,
64 final AggregatedNetconfOperationServiceFactory netconfOperationProvider,
65 final SessionIdProvider sessionIdProvider,
66 final long connectionTimeoutMillis,
67 final NetconfMonitoringService monitoringService) {
68 super(timer, netconfOperationProvider, sessionIdProvider, connectionTimeoutMillis, monitoringService,
69 org.opendaylight.netconf.impl.NetconfServerSessionNegotiatorFactory.DEFAULT_BASE_CAPABILITIES);