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.SessionIdProvider;
29 import org.opendaylight.netconf.impl.osgi.AggregatedNetconfOperationServiceFactory;
30 import org.opendaylight.netconf.mapping.api.NetconfOperationServiceFactory;
32 public final class NetconfServerDispatcherProvider extends ProviderTrait<NetconfServerDispatcher> {
33 private static final long CONNECTION_TIMEOUT_MILLIS = TimeUnit.SECONDS.toMillis(20);
36 @Named(NetconfModule.HONEYCOMB_NETCONF_MAPPER_AGGR)
37 private NetconfOperationServiceFactory aggregator;
39 private NetconfMonitoringService monitoringService;
43 private NioEventLoopGroup nettyThreadgroup;
46 protected NetconfServerDispatcherImpl create() {
47 AggregatedNetconfOperationServiceFactory netconfOperationProvider =
48 new AggregatedNetconfOperationServiceFactory();
49 netconfOperationProvider.onAddNetconfOperationServiceFactory(aggregator);
51 NetconfServerSessionNegotiatorFactory serverNegotiatorFactory =
52 new NetconfServerSessionNegotiatorFactory(timer, netconfOperationProvider, new SessionIdProvider(),
53 CONNECTION_TIMEOUT_MILLIS, monitoringService);
54 NetconfServerDispatcherImpl.ServerChannelInitializer serverChannelInitializer =
55 new NetconfServerDispatcherImpl.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);