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.infra.distro.netconf
19 import com.google.inject.Inject
20 import com.google.inject.name.Named
21 import groovy.transform.ToString
22 import groovy.util.logging.Slf4j
23 import io.fd.honeycomb.infra.distro.ProviderTrait
24 import io.netty.channel.nio.NioEventLoopGroup
25 import io.netty.util.Timer
26 import org.opendaylight.netconf.api.NetconfServerDispatcher
27 import org.opendaylight.netconf.api.monitoring.NetconfMonitoringService
28 import org.opendaylight.netconf.impl.NetconfServerDispatcherImpl
29 import org.opendaylight.netconf.impl.NetconfServerSessionNegotiatorFactory
30 import org.opendaylight.netconf.impl.SessionIdProvider
31 import org.opendaylight.netconf.impl.osgi.AggregatedNetconfOperationServiceFactory
32 import org.opendaylight.netconf.mapping.api.NetconfOperationServiceFactory
34 import java.util.concurrent.TimeUnit
36 * Mirror of org.opendaylight.controller.config.yang.config.netconf.northbound.impl.NetconfServerDispatcherModule
40 class NetconfServerDispatcherProvider extends ProviderTrait<NetconfServerDispatcher> {
42 // TODO make configurable
43 private static final long CONNECTION_TIMEOUT_MILLIS = TimeUnit.SECONDS.toMillis(20)
46 @Named("netconf-mapper-aggregator")
47 NetconfOperationServiceFactory aggregator
49 NetconfMonitoringService monitoringService
53 NioEventLoopGroup nettyThreadgroup
57 def netconfOperationProvider = new AggregatedNetconfOperationServiceFactory()
58 netconfOperationProvider.onAddNetconfOperationServiceFactory(aggregator)
60 def serverNegotiatorFactory = new NetconfServerSessionNegotiatorFactory(
61 timer, netconfOperationProvider, new SessionIdProvider(), CONNECTION_TIMEOUT_MILLIS, monitoringService);
62 def serverChannelInitializer = new NetconfServerDispatcherImpl.ServerChannelInitializer(
63 serverNegotiatorFactory);
65 new NetconfServerDispatcherImpl(serverChannelInitializer, nettyThreadgroup, nettyThreadgroup)