2 * Copyright (c) 2023 PANTHEON.tech, s.r.o. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.netconf.northbound;
10 import static java.util.Objects.requireNonNull;
12 import com.google.common.util.concurrent.ThreadFactoryBuilder;
14 import java.util.concurrent.ThreadFactory;
15 import java.util.concurrent.TimeUnit;
16 import org.opendaylight.netconf.server.api.monitoring.NetconfMonitoringService;
17 import org.opendaylight.netconf.server.api.operations.NetconfOperationServiceFactory;
18 import org.opendaylight.netconf.server.osgi.NetconfMonitoringServiceImpl;
19 import org.osgi.service.component.annotations.Activate;
20 import org.osgi.service.component.annotations.Component;
21 import org.osgi.service.component.annotations.Deactivate;
23 @Component(factory = DefaultNetconfMonitoringService.FACTORY_NAME, service = NetconfMonitoringService.class)
24 public final class DefaultNetconfMonitoringService extends NetconfMonitoringServiceImpl {
25 static final String FACTORY_NAME = "org.opendaylight.netconf.impl.mdsal.DefaultNetconfMonitoringService";
27 private static final ThreadFactory THREAD_FACTORY = new ThreadFactoryBuilder()
28 .setNameFormat("netconf-server-monitoring-%d")
31 private static final String OP_PROVIDER_PROP = ".opProvider";
32 private static final String UPDATE_INTERVAL_PROP = ".updateInterval";
34 private DefaultNetconfMonitoringService(final NetconfOperationServiceFactory opProvider, final long periodSeconds) {
35 super(opProvider, THREAD_FACTORY, periodSeconds, TimeUnit.SECONDS);
39 public DefaultNetconfMonitoringService(final Map<String, ?> properties) {
40 this(OSGiNetconfServer.extractProp(properties, OP_PROVIDER_PROP, NetconfOperationServiceFactory.class),
41 OSGiNetconfServer.extractProp(properties, UPDATE_INTERVAL_PROP, Long.class));
50 static Map<String, ?> props(final NetconfOperationServiceFactory opProvider, final long updateInterval) {
52 "type", "netconf-server-monitoring",
53 OP_PROVIDER_PROP, requireNonNull(opProvider),
54 UPDATE_INTERVAL_PROP, updateInterval);