Initial implementation of the ClusteredDataStore
[controller.git] / opendaylight / forwardingrulesmanager_mdsal / openflow / src / main / java / org / opendaylight / controller / forwardingrulesmanager_mdsal / consumer / impl / FRMConsumerImpl.java
1
2 /*
3  * Copyright (c) 2013 Ericsson , Inc. and others.  All rights reserved.
4  *
5  * This program and the accompanying materials are made available under the
6  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
7  * and is available at http://www.eclipse.org/legal/epl-v10.html
8  */
9
10 package org.opendaylight.controller.forwardingrulesmanager_mdsal.consumer.impl;
11
12
13 import org.opendaylight.controller.sal.binding.api.AbstractBindingAwareProvider;
14 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
15 import org.opendaylight.controller.sal.binding.api.NotificationService;
16 import org.opendaylight.controller.sal.binding.api.data.DataBrokerService;
17 import org.opendaylight.controller.sal.binding.api.data.DataProviderService;
18 import org.slf4j.Logger;
19 import org.slf4j.LoggerFactory;
20
21
22 public class FRMConsumerImpl extends AbstractBindingAwareProvider {
23         protected static final Logger logger = LoggerFactory.getLogger(FRMConsumerImpl.class);
24         private static ProviderContext p_session;
25     private static DataBrokerService dataBrokerService;          
26     private static NotificationService notificationService;     
27     private FlowConsumerImpl flowImplRef;
28         private GroupConsumerImpl groupImplRef;
29         private static DataProviderService dataProviderService;  
30
31         @Override
32     public void onSessionInitiated(ProviderContext session) {
33         
34         FRMConsumerImpl.p_session = session;
35         
36         if (null != session) {
37                 notificationService = session.getSALService(NotificationService.class);
38                 
39                 if (null != notificationService) {
40                         dataBrokerService = session.getSALService(DataBrokerService.class);
41                         
42                         if (null != dataBrokerService) {
43                                 dataProviderService = session.getSALService(DataProviderService.class);
44                                 
45                                 if (null != dataProviderService) {
46                                         flowImplRef = new FlowConsumerImpl();
47                                         groupImplRef = new GroupConsumerImpl();
48                                 }
49                                 else {
50                                         logger.error("Data Provider Service is down or NULL. " +
51                                                         "Accessing data from configuration data store will not be possible");
52                         System.out.println("Data Broker Service is down or NULL.");
53                                 }
54                                         
55                         }
56                         else {
57                                 logger.error("Data Broker Service is down or NULL.");
58                         System.out.println("Data Broker Service is down or NULL.");
59                         }
60                 }
61                 else {
62                         logger.error("Notification Service is down or NULL.");
63                 System.out.println("Notification Service is down or NULL.");
64                 }                       
65         }
66         else {
67                 logger.error("Consumer session is NULL. Please check if provider is registered");
68                 System.out.println("Consumer session is NULL. Please check if provider is registered");
69         }
70   
71     }
72
73         public static DataProviderService getDataProviderService() {
74                 return dataProviderService;
75         }
76
77         public FlowConsumerImpl getFlowImplRef() {
78                 return flowImplRef;
79         }
80
81         public GroupConsumerImpl getGroupImplRef() {
82                         return groupImplRef;
83         }
84          
85         public static ProviderContext getProviderSession() {
86                 return p_session;
87         }       
88
89         public static NotificationService getNotificationService() {
90                 return notificationService;
91         }
92
93         public static DataBrokerService getDataBrokerService() {
94                 return dataBrokerService;
95         }
96
97 }
98