[ONOS-3203] Fault Management fixes.
1) Fix "org.onlab.osgi.ServiceNotFoundException: Service org.onosproject.incubator.net.faultmanagement.alarm.AlarmService not found" runtime error by making SnmpAlarmProviderService a (annotated) Service. Possibly later can register it via the ProviderRegistry without the Service anotation.
2) When SnmpAlarmProviderService is deactivated de-register our InternalDeviceListener to avoid leak.
3) In providers/snmp/alarm/pom.xml : Remove unnecessary dependency versions info. Remove unnecessary shading.
Change-Id: I93c0c15215b6cf230bcb03d8ea9c08a88bd03e3b
diff --git a/providers/snmp/alarm/pom.xml b/providers/snmp/alarm/pom.xml
index 2b13e14..6b03c85 100644
--- a/providers/snmp/alarm/pom.xml
+++ b/providers/snmp/alarm/pom.xml
@@ -53,14 +53,12 @@
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.compendium</artifactId>
- <version>5.0.0</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.onosproject</groupId>
<artifactId>onos-api</artifactId>
- <version>${project.version}</version>
</dependency>
@@ -74,7 +72,6 @@
<dependency>
<groupId>org.onosproject</groupId>
<artifactId>onlab-osgi</artifactId>
- <version>${project.version}</version>
<classifier>tests</classifier>
<scope>test</scope>
</dependency>
@@ -82,7 +79,6 @@
<dependency>
<groupId>org.onosproject</groupId>
<artifactId>onos-api</artifactId>
- <version>${project.version}</version>
<classifier>tests</classifier>
<scope>test</scope>
</dependency>
@@ -90,19 +86,16 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
- <version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-core</artifactId>
- <version>1.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-library</artifactId>
- <version>1.3</version>
<scope>test</scope>
</dependency>
<dependency>
@@ -114,41 +107,7 @@
<build>
<plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-shade-plugin</artifactId>
- <version>2.3</version>
- <configuration>
- <filters>
- <filter>
- <artifact>com.btisystems:snmp-core</artifact>
- <excludes>
- <exclude>**</exclude>
- </excludes>
- </filter>
- <filter>
- <artifact>com.btisystems.mibbler.mibs:bti7000</artifact>
- <excludes>
- <exclude>**</exclude>
- </excludes>
- </filter>
- <filter>
- <artifact>com.btisystems.mibbler.mibs:net-snmp</artifact>
- <excludes>
- <exclude>**</exclude>
- </excludes>
- </filter>
- </filters>
- </configuration>
- <executions>
- <execution>
- <phase>package</phase>
- <goals>
- <goal>shade</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
+
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-scr-plugin</artifactId>
diff --git a/providers/snmp/alarm/src/main/java/org/onosproject/provider/snmp/alarm/impl/SnmpAlarmProviderService.java b/providers/snmp/alarm/src/main/java/org/onosproject/provider/snmp/alarm/impl/SnmpAlarmProviderService.java
index 4d2c658..65bd8c2 100644
--- a/providers/snmp/alarm/src/main/java/org/onosproject/provider/snmp/alarm/impl/SnmpAlarmProviderService.java
+++ b/providers/snmp/alarm/src/main/java/org/onosproject/provider/snmp/alarm/impl/SnmpAlarmProviderService.java
@@ -50,6 +50,7 @@
import org.slf4j.Logger;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.ReferenceCardinality;
+import org.apache.felix.scr.annotations.Service;
import static org.onlab.util.Tools.groupedThreads;
import org.onosproject.core.ApplicationId;
import org.onosproject.core.CoreService;
@@ -64,10 +65,13 @@
* SNMP alarms provider.
*/
@Component(immediate = true)
+@Service
public class SnmpAlarmProviderService extends AbstractProvider implements AlarmProvider {
private final Logger log = getLogger(getClass());
+ private final InternalDeviceListener internalDeviceListener = new InternalDeviceListener();
+
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected CoreService coreService;
@@ -88,6 +92,7 @@
public SnmpAlarmProviderService() {
super(new ProviderId("snmp", "org.onosproject.provider.alarm"));
+ log.info("SnmpAlarmProviderService ...");
sessionFactory = new SnmpSessionFactory(
new DefaultSnmpConfigurationFactory(new V2cSnmpConfiguration()));
providers.put("1.3.6.1.4.1.18070.2.2", new Bti7000SnmpAlarmProvider());
@@ -99,7 +104,7 @@
appId = coreService.registerApplication("org.onosproject.snmp");
eventHandlingExecutor = Executors.newSingleThreadExecutor(
groupedThreads("onos/alarms", "event-handler"));
- deviceService.addListener(new InternalDeviceListener());
+ deviceService.addListener(internalDeviceListener);
log.info("activated SNMP provider with appId = {} and context props {}", appId, context.getProperties());
modified(context);
@@ -109,6 +114,7 @@
@Deactivate
public void deactivate() {
log.info("deactivate SNMP provider {}", appId);
+ deviceService.removeListener(internalDeviceListener);
}
@Modified
diff --git a/providers/snmp/app/features.xml b/providers/snmp/app/features.xml
index 0874f54..b8ab857 100644
--- a/providers/snmp/app/features.xml
+++ b/providers/snmp/app/features.xml
@@ -21,6 +21,7 @@
<bundle>mvn:io.netty/netty/3.9.2.Final</bundle>
<bundle>mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.snmp4j/2.3.4_1</bundle>
<bundle>mvn:${project.groupId}/onos-snmp-provider-device/${project.version}</bundle>
+ <bundle>mvn:${project.groupId}/onos-snmp-provider-alarm/${project.version}</bundle>
<bundle>mvn:com.btisystems/snmp-core/1.3-SNAPSHOT</bundle>
<bundle>mvn:com.btisystems.mibbler.mibs/bti7000/1.0-SNAPSHOT</bundle>
<bundle>mvn:com.btisystems.mibbler.mibs/net-snmp/1.0-SNAPSHOT</bundle>