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.data;
19 import com.google.common.collect.Lists;
20 import com.google.inject.Inject;
21 import io.fd.honeycomb.binding.init.ProviderTrait;
22 import io.fd.honeycomb.notification.ManagedNotificationProducer;
23 import io.fd.honeycomb.notification.NotificationCollector;
24 import io.fd.honeycomb.notification.impl.HoneycombNotificationCollector;
25 import io.fd.honeycomb.notification.impl.NotificationProducerRegistry;
26 import io.fd.honeycomb.notification.impl.NotificationProducerTracker;
27 import java.util.HashSet;
29 import org.opendaylight.controller.md.sal.binding.impl.BindingDOMNotificationPublishServiceAdapter;
30 import org.opendaylight.controller.md.sal.binding.impl.BindingToNormalizedNodeCodec;
31 import org.opendaylight.controller.md.sal.dom.broker.impl.DOMNotificationRouter;
33 public final class HoneycombNotificationManagerProvider extends ProviderTrait<NotificationCollector> {
36 private DOMNotificationRouter notificationRouter;
37 @Inject(optional = true)
38 private Set<ManagedNotificationProducer> notificationProducers = new HashSet<>();
40 private BindingToNormalizedNodeCodec codec;
43 protected HoneycombNotificationCollector create() {
44 // Create the registry to keep track of what'OPERATIONAL registered
45 NotificationProducerRegistry notificationProducerRegistry =
46 new NotificationProducerRegistry(Lists.newArrayList(notificationProducers));
48 // Create BA version of notification service (implementation is free from ODL)
49 BindingDOMNotificationPublishServiceAdapter bindingDOMNotificationPublishServiceAdapter =
50 new BindingDOMNotificationPublishServiceAdapter(codec, notificationRouter);
52 // Create Collector on top of BA notification service and registry
53 HoneycombNotificationCollector honeycombNotificationCollector =
54 new HoneycombNotificationCollector(bindingDOMNotificationPublishServiceAdapter,
55 notificationProducerRegistry);
57 // Create tracker, responsible for starting and stopping registered notification producers whenever necessary
58 NotificationProducerTracker notificationProducerTracker =
59 new NotificationProducerTracker(notificationProducerRegistry, honeycombNotificationCollector,
62 // DOMNotificationService is already provided by DOMBroker injected into RESTCONF, however RESTCONF
63 // only supports data-change notification, nothing else. So currently (Beryllium-SR2) honeycomb notifications
64 // won't be available over RESTCONF.
66 return honeycombNotificationCollector;