Integration of Fcaps framework 31/38331/5
authorViji J <viji.j@ericsson.com>
Tue, 3 May 2016 12:59:19 +0000 (18:29 +0530)
committerViji J <viji.j@ericsson.com>
Tue, 3 May 2016 14:48:03 +0000 (20:18 +0530)
Change-Id: I68429a51ba6cd8a7d49a426b78fad866efdf126e
Signed-off-by: Viji J <viji.j@ericsson.com>
15 files changed:
fcapsmanager/alarmmanager/pom.xml [new file with mode: 0644]
fcapsmanager/alarmmanager/src/main/java/org/opendaylight/vpnservice/fcapsmanager/alarmmanager/Activator.java [new file with mode: 0644]
fcapsmanager/alarmmanager/src/main/java/org/opendaylight/vpnservice/fcapsmanager/alarmmanager/AlarmNotificationListeners.java [new file with mode: 0644]
fcapsmanager/countermanager/pom.xml [new file with mode: 0644]
fcapsmanager/countermanager/src/main/java/org/opendaylight/vpnservice/fcapsmanager/countermanager/Activator.java [new file with mode: 0644]
fcapsmanager/countermanager/src/main/java/org/opendaylight/vpnservice/fcapsmanager/countermanager/PMRegistrationListener.java [new file with mode: 0644]
fcapsmanager/countermanager/src/main/java/org/opendaylight/vpnservice/fcapsmanager/countermanager/Poller.java [new file with mode: 0644]
fcapsmanager/fcaps-api/pom.xml [new file with mode: 0644]
fcapsmanager/fcaps-api/src/main/java/org/opendaylight/vpnservice/fcapsmanager/Activator.java [new file with mode: 0644]
fcapsmanager/fcaps-api/src/main/java/org/opendaylight/vpnservice/fcapsmanager/AlarmServiceFacade.java [new file with mode: 0644]
fcapsmanager/fcaps-api/src/main/java/org/opendaylight/vpnservice/fcapsmanager/PMServiceFacade.java [new file with mode: 0644]
fcapsmanager/pom.xml [new file with mode: 0644]
features/pom.xml
features/src/main/features/features.xml
pom.xml

diff --git a/fcapsmanager/alarmmanager/pom.xml b/fcapsmanager/alarmmanager/pom.xml
new file mode 100644 (file)
index 0000000..88db687
--- /dev/null
@@ -0,0 +1,64 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- vi: set et smarttab sw=4 tabstop=4: --><!--
+Copyright (c) 2015 Ericsson India Global Services Pvt Ltd. and others.  All rights reserved.
+
+This program and the accompanying materials are made available under the
+terms of the Eclipse Public License v1.0 which accompanies this distribution,
+and is available at http://www.eclipse.org/legal/epl-v10.html
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+    <parent>
+        <groupId>org.opendaylight.vpnservice</groupId>
+        <artifactId>config-parent</artifactId>
+        <version>0.3.0-SNAPSHOT</version>
+        <relativePath>../../commons/config-parent</relativePath>
+    </parent>
+
+    <modelVersion>4.0.0</modelVersion>
+    <groupId>org.opendaylight.vpnservice</groupId>
+    <artifactId>alarmmanager</artifactId>
+    <version>${vpnservices.version}</version>
+    <packaging>bundle</packaging>
+
+    <properties>
+        <maven-bundle-plugin.version>2.5.3</maven-bundle-plugin.version>
+        <osgi.version>5.0.0</osgi.version>
+    </properties>
+    <dependencies>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.core</artifactId>
+            <version>${osgi.version}</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.vpnservice</groupId>
+            <artifactId>fcaps-api</artifactId>
+            <version>${vpnservices.version}</version>
+        </dependency>
+    </dependencies>
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                <version>${maven-bundle-plugin.version}</version>
+                <extensions>true</extensions>
+                <configuration>
+                    <instructions>
+                        <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
+                        <Bundle-Version>${project.version}</Bundle-Version>
+                        <Bundle-Activator>org.opendaylight.vpnservice.fcapsmanager.alarmmanager.Activator</Bundle-Activator>
+                        <Export-Package>org.opendaylight.vpnservice.fcapsmanager.alarmmanager*;version=${project.version}</Export-Package>
+                        <Import-Package>*</Import-Package>
+                    </instructions>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+</project>
\ No newline at end of file
diff --git a/fcapsmanager/alarmmanager/src/main/java/org/opendaylight/vpnservice/fcapsmanager/alarmmanager/Activator.java b/fcapsmanager/alarmmanager/src/main/java/org/opendaylight/vpnservice/fcapsmanager/alarmmanager/Activator.java
new file mode 100644 (file)
index 0000000..a133c8d
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2016 Ericsson India Global Services Pvt Ltd. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.vpnservice.fcapsmanager.alarmmanager;
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class Activator implements BundleActivator {
+    static Logger s_logger = LoggerFactory.getLogger(Activator.class);
+    private Runnable listener;
+    private Thread listenerThread;
+
+    public void start(BundleContext context) {
+        s_logger.info("Starting alarmmanager bundle");
+        AlarmNotificationListeners notificationListeners = new AlarmNotificationListeners(context);
+        try {
+            listener = notificationListeners;
+            listenerThread = new Thread(listener);
+            listenerThread.start();
+        } catch (Exception e) {
+            s_logger.error("Exception in alarm thread {}", e);
+        }
+    }
+
+    public void stop(BundleContext context) {
+        s_logger.info("Stopping alarmmanager bundle");
+    }
+}
\ No newline at end of file
diff --git a/fcapsmanager/alarmmanager/src/main/java/org/opendaylight/vpnservice/fcapsmanager/alarmmanager/AlarmNotificationListeners.java b/fcapsmanager/alarmmanager/src/main/java/org/opendaylight/vpnservice/fcapsmanager/alarmmanager/AlarmNotificationListeners.java
new file mode 100644 (file)
index 0000000..7cb8785
--- /dev/null
@@ -0,0 +1,179 @@
+/*
+ * Copyright (c) 2016 Ericsson India Global Services Pvt Ltd. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.vpnservice.fcapsmanager.alarmmanager;
+
+import javax.management.*;
+import java.lang.management.ManagementFactory;
+import java.util.*;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.opendaylight.vpnservice.fcapsmanager.AlarmServiceFacade;
+
+public class AlarmNotificationListeners implements Runnable {
+    static Logger s_logger = LoggerFactory.getLogger(AlarmNotificationListeners.class);
+    private MBeanServer mbs = null;
+    private static String DOMAIN = "SDNC.FM";
+
+    private final DelegateListener delegateListener = new DelegateListener();
+    private BundleContext context = null;
+
+    public AlarmNotificationListeners(BundleContext context) {
+        this.context=context;
+    }
+
+    /**
+     * Platform dependent bundle injects its handle and it is retrieved in the method
+     */
+    private AlarmServiceFacade getAlarmServiceSPI (){
+        AlarmServiceFacade service =null;
+        if(context != null) {
+            try {
+                ServiceReference<?> serviceReference = context.
+                        getServiceReference(AlarmServiceFacade.class.getName());
+                service = (AlarmServiceFacade) context.
+                        getService(serviceReference);
+            }catch (NullPointerException ex){
+                service = null;
+            }catch (Exception e){
+                s_logger.error("Exception {} occurred in getting AlarmServiceSPI",e);
+            }
+        }
+        return service;
+    }
+
+    /**
+     * Gets register notification when a mbean is registered in platform Mbeanserver and checks if it is alarm mbean and add attribute notification listener to it.
+     * Gets attribute notification when alarm mbean is updated by the application.
+     */
+    public class DelegateListener implements NotificationListener {
+        public void handleNotification(Notification notification, Object obj) {
+            if (notification instanceof MBeanServerNotification) {
+                MBeanServerNotification msnotification =
+                        (MBeanServerNotification) notification;
+                String nType = msnotification.getType();
+                ObjectName mbn = msnotification.getMBeanName();
+
+                if (nType.equals("JMX.mbean.registered")) {
+                    if (mbn.toString().contains(DOMAIN)) {
+                        s_logger.debug("Received registeration of Mbean "+mbn);
+                        try {
+                            mbs.addNotificationListener(mbn,delegateListener, null, null);
+                            s_logger.debug("Added attribute notification listener for Mbean "+ mbn);
+                        } catch (InstanceNotFoundException e) {
+                            s_logger.error("Exception while adding attribute notification of mbean {}", e);
+                        }
+                    }
+                }
+
+                if (nType.equals("JMX.mbean.unregistered")) {
+                    if (mbn.toString().contains(DOMAIN)) {
+                        s_logger.debug("Time: " + msnotification.getTimeStamp() + "MBean " + msnotification.getMBeanName()+" unregistered successfully");
+                    }
+                }
+            }
+            else if (notification instanceof AttributeChangeNotification) {
+                AttributeChangeNotification acn =
+                        (AttributeChangeNotification) notification;
+
+                s_logger.debug("Received attribute notification of Mbean: "
+                        + notification.getSource()
+                        + " for attribute:" + acn.getAttributeName() );
+
+                if(acn.getAttributeName().toString().equals("raiseAlarmObject")){
+
+                    String value=acn.getNewValue().toString();
+                    value = value.replace(value.charAt(0), ' ');
+                    value = value.replace(value.charAt(value.lastIndexOf("]")), ' ');
+
+                    String[] args =value.split(",");
+                    s_logger.debug("Receive attribute value :"+args[0].trim()+args[1].trim()+args[2].trim());
+                    if(getAlarmServiceSPI() != null ) {
+                        getAlarmServiceSPI().raiseAlarm(args[0].trim(),args[1].trim(),args[2].trim());
+                    } else {
+                        s_logger.debug("Alarm service not available");
+                    }
+
+                } else if(acn.getAttributeName().toString().equals("clearAlarmObject")){
+
+                    String value=acn.getNewValue().toString();
+                    value = value.replace(value.charAt(0), ' ');
+                    value = value.replace(value.charAt(value.lastIndexOf("]")), ' ');
+
+                    String[] args =value.split(",");
+                    s_logger.debug("Receive attribute value :"+args[0].trim()+args[1].trim()+args[2].trim());
+                    if(getAlarmServiceSPI() != null )
+                        getAlarmServiceSPI().clearAlarm(args[0].trim(), args[1].trim(), args[2].trim());
+                    else
+                        s_logger.debug("Alarm service not available");
+                }
+            }
+        }
+    }
+
+    /**
+     * Gets the platform MBeanServer instance and registers to get notification whenever alarm mbean is registered in the mbeanserver
+     */
+    @Override
+    public void run() {
+        mbs = ManagementFactory.getPlatformMBeanServer();
+
+        queryMbeans();
+
+        ObjectName delegate = null;
+        try {
+            delegate = new ObjectName("JMImplementation:type=MBeanServerDelegate");
+        } catch (MalformedObjectNameException e) {
+            e.printStackTrace();
+        }
+        NotificationFilterSupport filter = new NotificationFilterSupport();
+        filter.enableType("JMX.mbean.registered");
+        filter.enableType("JMX.mbean.unregistered");
+
+        try {
+            mbs.addNotificationListener(delegate, delegateListener, filter, null);
+            s_logger.debug("Added registeration listener for Mbean {}",delegate);
+        } catch (InstanceNotFoundException e) {
+            s_logger.error("Failed to add registeration listener {}", e);
+        }
+
+        waitForNotification();
+    }
+
+    /**
+     *  Pre-provisioning case to handle all alarm mbeans which are registered before installation of framework bundle
+     *  Queries the platform Mbeanserver to retrieve registered alarm mbean and add attribute notification listener to it
+     */
+    public void queryMbeans() {
+
+        Set<ObjectName> names =
+                new TreeSet<ObjectName>(mbs.queryNames(null, null));
+        s_logger.debug("Queried MBeanServer for MBeans:");
+        for (ObjectName beanName : names) {
+            if(beanName.toString().contains(DOMAIN)){
+                try {
+                    mbs.addNotificationListener(beanName,delegateListener, null, null);
+                    s_logger.debug("Added attribute notification listener for Mbean "+ beanName);
+                } catch (InstanceNotFoundException e) {
+                    s_logger.error("Failed to add attribute notification for Mbean {}", e);
+                }
+            }
+        }
+    }
+    public void waitForNotification() {
+        while(true){
+            try {
+                Thread.sleep(50);
+            }
+            catch(Exception ex){
+                ex.printStackTrace();
+            }
+        }
+    }
+}
\ No newline at end of file
diff --git a/fcapsmanager/countermanager/pom.xml b/fcapsmanager/countermanager/pom.xml
new file mode 100644 (file)
index 0000000..63cb649
--- /dev/null
@@ -0,0 +1,64 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- vi: set et smarttab sw=4 tabstop=4: --><!--
+Copyright (c) 2015 Ericsson India Global Services Pvt Ltd. and others.  All rights reserved.
+
+This program and the accompanying materials are made available under the
+terms of the Eclipse Public License v1.0 which accompanies this distribution,
+and is available at http://www.eclipse.org/legal/epl-v10.html
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+    <parent>
+        <groupId>org.opendaylight.vpnservice</groupId>
+        <artifactId>config-parent</artifactId>
+        <version>0.3.0-SNAPSHOT</version>
+        <relativePath>../../commons/config-parent</relativePath>
+    </parent>
+
+    <modelVersion>4.0.0</modelVersion>
+    <groupId>org.opendaylight.vpnservice</groupId>
+    <artifactId>countermanager</artifactId>
+    <version>${vpnservices.version}</version>
+    <packaging>bundle</packaging>
+
+    <properties>
+        <maven-bundle-plugin.version>2.5.3</maven-bundle-plugin.version>
+        <osgi.version>5.0.0</osgi.version>
+    </properties>
+    <dependencies>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.core</artifactId>
+            <version>${osgi.version}</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.vpnservice</groupId>
+            <artifactId>fcaps-api</artifactId>
+            <version>${vpnservices.version}</version>
+        </dependency>
+    </dependencies>
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                <version>${maven-bundle-plugin.version}</version>
+                <extensions>true</extensions>
+                <configuration>
+                    <instructions>
+                        <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
+                        <Bundle-Version>${project.version}</Bundle-Version>
+                        <Bundle-Activator>org.opendaylight.vpnservice.fcapsmanager.countermanager.Activator</Bundle-Activator>
+                        <Export-Package>org.opendaylight.vpnservice.fcapsmanager.countermanager*;version=${project.version}</Export-Package>
+                        <Import-Package>*</Import-Package>
+                    </instructions>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+</project>
\ No newline at end of file
diff --git a/fcapsmanager/countermanager/src/main/java/org/opendaylight/vpnservice/fcapsmanager/countermanager/Activator.java b/fcapsmanager/countermanager/src/main/java/org/opendaylight/vpnservice/fcapsmanager/countermanager/Activator.java
new file mode 100644 (file)
index 0000000..6f6928c
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2016 Ericsson India Global Services Pvt Ltd. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.vpnservice.fcapsmanager.countermanager;
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.management.InstanceNotFoundException;
+import javax.management.MBeanException;
+import javax.management.MalformedObjectNameException;
+import javax.management.ReflectionException;
+import java.io.IOException;
+
+public class Activator implements BundleActivator {
+    private final static org.slf4j.Logger LOG = LoggerFactory.getLogger(Activator.class);
+    private Runnable listener;
+    private Thread listenerThread;
+
+    public void start(BundleContext context) throws InstanceNotFoundException, MalformedObjectNameException, MBeanException, ReflectionException, IOException {
+        LOG.info("Starting countermanager bundle ");
+        PMRegistrationListener notificationListeners = new PMRegistrationListener(context);
+        try {
+            listener = notificationListeners;
+            listenerThread = new Thread(listener);
+            listenerThread.start();
+        } catch (Exception e) {
+            LOG.error("Exception in counter thread {}", e);
+        }
+    }
+
+    public void stop(BundleContext context) {
+        LOG.info("Stopping countermanager bundle ");
+    }
+}
\ No newline at end of file
diff --git a/fcapsmanager/countermanager/src/main/java/org/opendaylight/vpnservice/fcapsmanager/countermanager/PMRegistrationListener.java b/fcapsmanager/countermanager/src/main/java/org/opendaylight/vpnservice/fcapsmanager/countermanager/PMRegistrationListener.java
new file mode 100644 (file)
index 0000000..cfdbdb4
--- /dev/null
@@ -0,0 +1,117 @@
+/*
+ * Copyright (c) 2016 Ericsson India Global Services Pvt Ltd. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.vpnservice.fcapsmanager.countermanager;
+
+import java.lang.management.ManagementFactory;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.TreeSet;
+
+import javax.management.InstanceNotFoundException;
+import javax.management.MBeanServer;
+import javax.management.MBeanServerNotification;
+import javax.management.MalformedObjectNameException;
+import javax.management.Notification;
+import javax.management.NotificationFilterSupport;
+import javax.management.NotificationListener;
+import javax.management.ObjectName;
+
+import org.osgi.framework.BundleContext;
+import org.slf4j.LoggerFactory;
+
+public class PMRegistrationListener implements Runnable {
+    private final static org.slf4j.Logger LOG = LoggerFactory.getLogger(PMRegistrationListener.class);
+    static MBeanServer mbs = null;
+
+    private static String DOMAIN = "SDNC.PM";
+    public static HashSet<ObjectName> beanNames = new HashSet<ObjectName>();
+    private BundleContext context = null;
+
+    public PMRegistrationListener(BundleContext context){
+        this.context=context;
+    }
+
+    /**
+     * Gets register notification when a mbean is registered in platform Mbeanserver and checks if it is counter mbean and add it to the map.
+     */
+    public static class DelegateListener implements NotificationListener {
+        public void handleNotification(Notification notification, Object obj) {
+            if (notification instanceof MBeanServerNotification) {
+                MBeanServerNotification msnotification =
+                        (MBeanServerNotification) notification;
+                String nType = msnotification.getType();
+                ObjectName mbn = msnotification.getMBeanName();
+                if (nType.equals("JMX.mbean.registered")) {
+                    String mbean = mbn.toString();
+                    if(mbean.contains(DOMAIN)) {
+                        beanNames.add(mbn);
+                        LOG.debug("Beans are " +beanNames);
+                    }
+                }
+                if (nType.equals("JMX.mbean.unregistered")) {
+                    if(mbn.toString().contains(DOMAIN)) {
+                        beanNames.remove(mbn);
+                        LOG.debug(mbn +" MBean has been unregistered");
+                    }
+                }
+            }
+        }
+    }
+
+    @Override
+    public void run(){
+        mbs = ManagementFactory.getPlatformMBeanServer();
+        queryMbeans();
+        DelegateListener delegateListener = new DelegateListener();
+        ObjectName delegate = null;
+        try {
+            delegate = new ObjectName("JMImplementation:type=MBeanServerDelegate");
+        } catch (MalformedObjectNameException e) {
+            e.printStackTrace();
+        }
+        NotificationFilterSupport filter = new NotificationFilterSupport();
+
+        filter.enableType("JMX.mbean.registered");
+        filter.enableType("JMX.mbean.unregistered");
+
+        LOG.debug("Add PM Registeration Notification Listener");
+        try {
+            mbs.addNotificationListener(delegate, delegateListener, filter,null);
+        }catch (InstanceNotFoundException e) {
+            e.printStackTrace();
+        }
+        Poller poller = new Poller(this.context);
+        poller.polling();
+        waitforNotification();
+    }
+
+    /**
+     * Prepovising case to handle all counter mbeans which are registered before the installation of framework bundle
+     * Queries the platform Mbeanserver to retrieve registered counter mbean and add it to the map
+     */
+    public void queryMbeans() {
+        Set<ObjectName> names =
+                new TreeSet<ObjectName>(mbs.queryNames(null, null));
+        LOG.debug("\nQueried MBeanServer for MBeans:");
+        for (ObjectName name : names) {
+            if(name.toString().contains(DOMAIN)){
+                beanNames.add(name);
+            }
+        }
+    }
+
+    private void waitforNotification() {
+        while(true){
+            try {
+                Thread.sleep(50);
+            } catch (InterruptedException e) {
+                e.printStackTrace();
+            }
+        }
+    }
+}
\ No newline at end of file
diff --git a/fcapsmanager/countermanager/src/main/java/org/opendaylight/vpnservice/fcapsmanager/countermanager/Poller.java b/fcapsmanager/countermanager/src/main/java/org/opendaylight/vpnservice/fcapsmanager/countermanager/Poller.java
new file mode 100644 (file)
index 0000000..ad6f850
--- /dev/null
@@ -0,0 +1,85 @@
+/*
+ * Copyright (c) 2016 Ericsson India Global Services Pvt Ltd. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.vpnservice.fcapsmanager.countermanager;
+
+import java.lang.management.ManagementFactory;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.slf4j.LoggerFactory;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+import org.opendaylight.vpnservice.fcapsmanager.PMServiceFacade;
+
+public class Poller {
+    private final static org.slf4j.Logger LOG = LoggerFactory.getLogger(Poller.class);
+    private static BundleContext context = null;
+    public Poller(){
+    }
+    public Poller(BundleContext bundleContext) {
+        context = bundleContext;
+    }
+    //This method do the Polling every 5 second and retrieves the the counter details
+    //@Override
+    public void polling() {
+        LOG.debug("Poller Polling Mbean List and the content is " + PMRegistrationListener.beanNames);
+        ScheduledExecutorService service = Executors.newSingleThreadScheduledExecutor();
+        service.scheduleAtFixedRate(new Pollerthread(), 0, 5, TimeUnit.SECONDS);
+    }
+
+    /**
+     * Platform dependent bundle injects its handle and it is retrieved in the method
+     */
+    protected PMServiceFacade getPMServiceSPI (){
+        PMServiceFacade service =null;
+        if(context != null) {
+            try {
+                ServiceReference<?> serviceReference = context.
+                        getServiceReference(PMServiceFacade.class.getName());
+                service = (PMServiceFacade) context.
+                        getService(serviceReference);
+            }catch(NullPointerException ex){
+                service = null;
+            }catch (Exception e){
+                LOG.error("Exception {} occurred in getting PMServiceSPI",e);
+            }
+        }
+        return service;
+    }
+}
+
+class Pollerthread implements Runnable {
+    private final static org.slf4j.Logger LOG = LoggerFactory.getLogger(Pollerthread.class);
+    MBeanServer mbs = null;
+    Map<String,String> getCounter = new HashMap<String,String>();
+    Poller poller = new Poller();
+
+    /**
+     * Retrieve countermap from each counter mbean and send to platform
+     */
+    @SuppressWarnings("unchecked")
+    @Override
+    public void run() {
+        try {
+            mbs = ManagementFactory.getPlatformMBeanServer();
+            for (ObjectName objectName : PMRegistrationListener.beanNames) {
+                getCounter=(Map<String, String>) mbs.invoke(objectName, "retrieveCounterMap",null,null);
+                if(poller.getPMServiceSPI() != null)
+                    poller.getPMServiceSPI().connectToPMFactory(getCounter);
+                else
+                    LOG.debug("PM service not available");
+            }
+        } catch (Exception e) {
+            LOG.error("Exception caught {} ", e);
+        }
+    }
+}
\ No newline at end of file
diff --git a/fcapsmanager/fcaps-api/pom.xml b/fcapsmanager/fcaps-api/pom.xml
new file mode 100644 (file)
index 0000000..1277591
--- /dev/null
@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- vi: set et smarttab sw=4 tabstop=4: --><!--
+Copyright (c) 2015 Ericsson India Global Services Pvt Ltd. and others.  All rights reserved.
+
+This program and the accompanying materials are made available under the
+terms of the Eclipse Public License v1.0 which accompanies this distribution,
+and is available at http://www.eclipse.org/legal/epl-v10.html
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+    <parent>
+        <groupId>org.opendaylight.vpnservice</groupId>
+        <artifactId>config-parent</artifactId>
+        <version>0.3.0-SNAPSHOT</version>
+        <relativePath>../../commons/config-parent</relativePath>
+    </parent>
+
+    <modelVersion>4.0.0</modelVersion>
+    <groupId>org.opendaylight.vpnservice</groupId>
+    <artifactId>fcaps-api</artifactId>
+    <version>${vpnservices.version}</version>
+    <packaging>bundle</packaging>
+
+    <properties>
+        <maven-bundle-plugin.version>2.5.3</maven-bundle-plugin.version>
+        <osgi.version>5.0.0</osgi.version>
+    </properties>
+    <dependencies>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.core</artifactId>
+            <version>${osgi.version}</version>
+            <scope>provided</scope>
+        </dependency>
+    </dependencies>
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                <version>${maven-bundle-plugin.version}</version>
+                <extensions>true</extensions>
+                <configuration>
+                    <instructions>
+                        <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
+                        <Bundle-Version>${project.version}</Bundle-Version>
+                        <Bundle-Activator>org.opendaylight.vpnservice.fcapsmanager.Activator</Bundle-Activator>
+                        <Export-Package>org.opendaylight.vpnservice.fcapsmanager*;version=${project.version}</Export-Package>
+                        <Import-Package>*</Import-Package>
+                    </instructions>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+</project>
\ No newline at end of file
diff --git a/fcapsmanager/fcaps-api/src/main/java/org/opendaylight/vpnservice/fcapsmanager/Activator.java b/fcapsmanager/fcaps-api/src/main/java/org/opendaylight/vpnservice/fcapsmanager/Activator.java
new file mode 100644 (file)
index 0000000..2188390
--- /dev/null
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2016 Ericsson India Global Services Pvt Ltd. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.vpnservice.fcapsmanager;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+
+public class Activator implements BundleActivator {
+    static Logger s_logger = LoggerFactory.getLogger(Activator.class);
+    public void start(BundleContext context) {
+        s_logger.info("Starting fcapsSPI bundle");
+    }
+
+    public void stop(BundleContext context) {
+        s_logger.info("Stopping fcapsSPI bundle");
+    }
+
+}
\ No newline at end of file
diff --git a/fcapsmanager/fcaps-api/src/main/java/org/opendaylight/vpnservice/fcapsmanager/AlarmServiceFacade.java b/fcapsmanager/fcaps-api/src/main/java/org/opendaylight/vpnservice/fcapsmanager/AlarmServiceFacade.java
new file mode 100644 (file)
index 0000000..85ec789
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2016 Ericsson India Global Services Pvt Ltd. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.vpnservice.fcapsmanager;
+
+public interface AlarmServiceFacade {
+    /**
+     * Raises the given alarm in platform environment
+     *
+     * @param alarmName
+     *            Alarm to be raised
+     * @param additionalText
+     *            Additional details describing about the alarm
+     * @param source
+     *            Source of the alarm ex: dpnId=openflow:1
+     *            the source node that caused this alarm
+     */
+    public void raiseAlarm(String alarmName, String additionalText, String source);
+
+    /**
+     * Clears the given alarm in platform environment
+     *
+     * @param alarmName
+     *            Alarm to be cleared
+     * @param additionalText
+     *            Additional details describing about the alarm
+     * @param source
+     *            Source of the alarm ex:  dpnId=openflow:1
+     *            the source node that caused this alarm
+     */
+    public void clearAlarm(String alarmName, String additionalText, String source);
+}
\ No newline at end of file
diff --git a/fcapsmanager/fcaps-api/src/main/java/org/opendaylight/vpnservice/fcapsmanager/PMServiceFacade.java b/fcapsmanager/fcaps-api/src/main/java/org/opendaylight/vpnservice/fcapsmanager/PMServiceFacade.java
new file mode 100644 (file)
index 0000000..6bad020
--- /dev/null
@@ -0,0 +1,14 @@
+/*
+ * Copyright (c) 2016 Ericsson India Global Services Pvt Ltd. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.vpnservice.fcapsmanager;
+
+import java.util.Map;
+
+public interface PMServiceFacade {
+    public void connectToPMFactory(Map map);
+}
diff --git a/fcapsmanager/pom.xml b/fcapsmanager/pom.xml
new file mode 100644 (file)
index 0000000..6034382
--- /dev/null
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Copyright (c) 2015 - 2016 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
+This program and the accompanying materials are made available under the
+terms of the Eclipse Public License v1.0 which accompanies this distribution,
+and is available at http://www.eclipse.org/legal/epl-v10.html INTERNAL
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+    <parent>
+        <groupId>org.opendaylight.odlparent</groupId>
+        <artifactId>odlparent</artifactId>
+        <version>1.7.0-SNAPSHOT</version>
+        <relativePath/>
+    </parent>
+
+    <groupId>org.opendaylight.vpnservice</groupId>
+    <artifactId>fcapsmanager</artifactId>
+    <version>0.3.0-SNAPSHOT</version>
+    <name>fcapsmanager</name>
+    <packaging>pom</packaging>
+    <modelVersion>4.0.0</modelVersion>
+    <prerequisites>
+        <maven>3.1.1</maven>
+    </prerequisites>
+    <modules>
+        <module>fcaps-api</module>
+        <module>alarmmanager</module>
+        <module>countermanager</module>
+    </modules>
+    <!-- DO NOT install or deploy the repo root pom as it's only needed to initiate a build -->
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-deploy-plugin</artifactId>
+                <configuration>
+                    <skip>true</skip>
+                </configuration>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-install-plugin</artifactId>
+                <configuration>
+                    <skip>true</skip>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+</project>
\ No newline at end of file
index 0cd96d4a4946349e361a2d518290741c22f55258..e2e05a02a0e7141e210efd8228345dabce9bd3cd 100644 (file)
@@ -42,6 +42,8 @@ and is available at http://www.eclipse.org/legal/epl-v10.html INTERNAL
     <idmanager.version>${vpnservices.version}</idmanager.version>
     <itm.version>${vpnservices.version}</itm.version>
     <neutronvpn.version>${vpnservices.version}</neutronvpn.version>
+    <fcaps.manager.version>${vpnservices.version}</fcaps.manager.version>
+
   </properties>
   <dependencyManagement>
     <dependencies>
@@ -437,5 +439,21 @@ and is available at http://www.eclipse.org/legal/epl-v10.html INTERNAL
       <classifier>config</classifier>
       <type>xml</type>
     </dependency>
+
+    <dependency>
+      <groupId>${project.groupId}</groupId>
+      <artifactId>alarmmanager</artifactId>
+      <version>${fcaps.manager.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>${project.groupId}</groupId>
+      <artifactId>countermanager</artifactId>
+      <version>${fcaps.manager.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>${project.groupId}</groupId>
+      <artifactId>fcaps-api</artifactId>
+      <version>${fcaps.manager.version}</version>
+    </dependency>
   </dependencies>
 </project>
index d92ccda954c749d5cf3bd2a18a5d1fb32862c019..1daa7ed362a96969e08b14f43738dac48db3681a 100644 (file)
@@ -119,4 +119,10 @@ and is available at http://www.eclipse.org/legal/epl-v10.html
     <bundle>mvn:org.opendaylight.vpnservice/vpnintent-impl/{{VERSION}}</bundle>
     <configfile finalname="vpnintent-impl-default-config.xml">mvn:org.opendaylight.vpnservice/vpnintent-impl/{{VERSION}}/xml/config</configfile>
   </feature>
-  </features>
+
+  <feature name='odl-fcaps-framework' version='${project.version}' description='OpenDaylight :: fcapsframework'>
+    <bundle>mvn:org.opendaylight.vpnservice/fcaps-api/${fcaps.manager.version}</bundle>
+    <bundle>mvn:org.opendaylight.vpnservice/alarmmanager/${fcaps.manager.version}</bundle>
+    <bundle>mvn:org.opendaylight.vpnservice/countermanager/${fcaps.manager.version}</bundle>
+  </feature>
+</features>
diff --git a/pom.xml b/pom.xml
index baa7a3198d053dd16a212415bad2361abe43f01f..b35783b224d78fa40f5205f4f9b31ee39df8b386 100644 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -36,6 +36,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html INTERNAL
     <module>features</module>
     <module>vpnservice-artifacts</module>
     <module>vpnintent</module>
+    <module>fcapsmanager</module>
   </modules>
 
   <!-- DO NOT install or deploy the repo root pom as it's only needed to initiate a build -->