Committed by
Gerrit Code Review
[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
Showing
3 changed files
with
9 additions
and
43 deletions
... | @@ -53,14 +53,12 @@ | ... | @@ -53,14 +53,12 @@ |
53 | <dependency> | 53 | <dependency> |
54 | <groupId>org.osgi</groupId> | 54 | <groupId>org.osgi</groupId> |
55 | <artifactId>org.osgi.compendium</artifactId> | 55 | <artifactId>org.osgi.compendium</artifactId> |
56 | - <version>5.0.0</version> | ||
57 | <type>jar</type> | 56 | <type>jar</type> |
58 | </dependency> | 57 | </dependency> |
59 | 58 | ||
60 | <dependency> | 59 | <dependency> |
61 | <groupId>org.onosproject</groupId> | 60 | <groupId>org.onosproject</groupId> |
62 | <artifactId>onos-api</artifactId> | 61 | <artifactId>onos-api</artifactId> |
63 | - <version>${project.version}</version> | ||
64 | </dependency> | 62 | </dependency> |
65 | 63 | ||
66 | 64 | ||
... | @@ -74,7 +72,6 @@ | ... | @@ -74,7 +72,6 @@ |
74 | <dependency> | 72 | <dependency> |
75 | <groupId>org.onosproject</groupId> | 73 | <groupId>org.onosproject</groupId> |
76 | <artifactId>onlab-osgi</artifactId> | 74 | <artifactId>onlab-osgi</artifactId> |
77 | - <version>${project.version}</version> | ||
78 | <classifier>tests</classifier> | 75 | <classifier>tests</classifier> |
79 | <scope>test</scope> | 76 | <scope>test</scope> |
80 | </dependency> | 77 | </dependency> |
... | @@ -82,7 +79,6 @@ | ... | @@ -82,7 +79,6 @@ |
82 | <dependency> | 79 | <dependency> |
83 | <groupId>org.onosproject</groupId> | 80 | <groupId>org.onosproject</groupId> |
84 | <artifactId>onos-api</artifactId> | 81 | <artifactId>onos-api</artifactId> |
85 | - <version>${project.version}</version> | ||
86 | <classifier>tests</classifier> | 82 | <classifier>tests</classifier> |
87 | <scope>test</scope> | 83 | <scope>test</scope> |
88 | </dependency> | 84 | </dependency> |
... | @@ -90,19 +86,16 @@ | ... | @@ -90,19 +86,16 @@ |
90 | <dependency> | 86 | <dependency> |
91 | <groupId>junit</groupId> | 87 | <groupId>junit</groupId> |
92 | <artifactId>junit</artifactId> | 88 | <artifactId>junit</artifactId> |
93 | - <version>4.11</version> | ||
94 | <scope>test</scope> | 89 | <scope>test</scope> |
95 | </dependency> | 90 | </dependency> |
96 | <dependency> | 91 | <dependency> |
97 | <groupId>org.hamcrest</groupId> | 92 | <groupId>org.hamcrest</groupId> |
98 | <artifactId>hamcrest-core</artifactId> | 93 | <artifactId>hamcrest-core</artifactId> |
99 | - <version>1.3</version> | ||
100 | <scope>test</scope> | 94 | <scope>test</scope> |
101 | </dependency> | 95 | </dependency> |
102 | <dependency> | 96 | <dependency> |
103 | <groupId>org.hamcrest</groupId> | 97 | <groupId>org.hamcrest</groupId> |
104 | <artifactId>hamcrest-library</artifactId> | 98 | <artifactId>hamcrest-library</artifactId> |
105 | - <version>1.3</version> | ||
106 | <scope>test</scope> | 99 | <scope>test</scope> |
107 | </dependency> | 100 | </dependency> |
108 | <dependency> | 101 | <dependency> |
... | @@ -114,41 +107,7 @@ | ... | @@ -114,41 +107,7 @@ |
114 | 107 | ||
115 | <build> | 108 | <build> |
116 | <plugins> | 109 | <plugins> |
117 | - <plugin> | 110 | + |
118 | - <groupId>org.apache.maven.plugins</groupId> | ||
119 | - <artifactId>maven-shade-plugin</artifactId> | ||
120 | - <version>2.3</version> | ||
121 | - <configuration> | ||
122 | - <filters> | ||
123 | - <filter> | ||
124 | - <artifact>com.btisystems:snmp-core</artifact> | ||
125 | - <excludes> | ||
126 | - <exclude>**</exclude> | ||
127 | - </excludes> | ||
128 | - </filter> | ||
129 | - <filter> | ||
130 | - <artifact>com.btisystems.mibbler.mibs:bti7000</artifact> | ||
131 | - <excludes> | ||
132 | - <exclude>**</exclude> | ||
133 | - </excludes> | ||
134 | - </filter> | ||
135 | - <filter> | ||
136 | - <artifact>com.btisystems.mibbler.mibs:net-snmp</artifact> | ||
137 | - <excludes> | ||
138 | - <exclude>**</exclude> | ||
139 | - </excludes> | ||
140 | - </filter> | ||
141 | - </filters> | ||
142 | - </configuration> | ||
143 | - <executions> | ||
144 | - <execution> | ||
145 | - <phase>package</phase> | ||
146 | - <goals> | ||
147 | - <goal>shade</goal> | ||
148 | - </goals> | ||
149 | - </execution> | ||
150 | - </executions> | ||
151 | - </plugin> | ||
152 | <plugin> | 111 | <plugin> |
153 | <groupId>org.apache.felix</groupId> | 112 | <groupId>org.apache.felix</groupId> |
154 | <artifactId>maven-scr-plugin</artifactId> | 113 | <artifactId>maven-scr-plugin</artifactId> | ... | ... |
... | @@ -50,6 +50,7 @@ import org.osgi.service.component.ComponentContext; | ... | @@ -50,6 +50,7 @@ import org.osgi.service.component.ComponentContext; |
50 | import org.slf4j.Logger; | 50 | import org.slf4j.Logger; |
51 | import org.apache.felix.scr.annotations.Reference; | 51 | import org.apache.felix.scr.annotations.Reference; |
52 | import org.apache.felix.scr.annotations.ReferenceCardinality; | 52 | import org.apache.felix.scr.annotations.ReferenceCardinality; |
53 | +import org.apache.felix.scr.annotations.Service; | ||
53 | import static org.onlab.util.Tools.groupedThreads; | 54 | import static org.onlab.util.Tools.groupedThreads; |
54 | import org.onosproject.core.ApplicationId; | 55 | import org.onosproject.core.ApplicationId; |
55 | import org.onosproject.core.CoreService; | 56 | import org.onosproject.core.CoreService; |
... | @@ -64,10 +65,13 @@ import org.onosproject.net.device.DeviceService; | ... | @@ -64,10 +65,13 @@ import org.onosproject.net.device.DeviceService; |
64 | * SNMP alarms provider. | 65 | * SNMP alarms provider. |
65 | */ | 66 | */ |
66 | @Component(immediate = true) | 67 | @Component(immediate = true) |
68 | +@Service | ||
67 | public class SnmpAlarmProviderService extends AbstractProvider implements AlarmProvider { | 69 | public class SnmpAlarmProviderService extends AbstractProvider implements AlarmProvider { |
68 | 70 | ||
69 | private final Logger log = getLogger(getClass()); | 71 | private final Logger log = getLogger(getClass()); |
70 | 72 | ||
73 | + private final InternalDeviceListener internalDeviceListener = new InternalDeviceListener(); | ||
74 | + | ||
71 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | 75 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
72 | protected CoreService coreService; | 76 | protected CoreService coreService; |
73 | 77 | ||
... | @@ -88,6 +92,7 @@ public class SnmpAlarmProviderService extends AbstractProvider implements AlarmP | ... | @@ -88,6 +92,7 @@ public class SnmpAlarmProviderService extends AbstractProvider implements AlarmP |
88 | 92 | ||
89 | public SnmpAlarmProviderService() { | 93 | public SnmpAlarmProviderService() { |
90 | super(new ProviderId("snmp", "org.onosproject.provider.alarm")); | 94 | super(new ProviderId("snmp", "org.onosproject.provider.alarm")); |
95 | + log.info("SnmpAlarmProviderService ..."); | ||
91 | sessionFactory = new SnmpSessionFactory( | 96 | sessionFactory = new SnmpSessionFactory( |
92 | new DefaultSnmpConfigurationFactory(new V2cSnmpConfiguration())); | 97 | new DefaultSnmpConfigurationFactory(new V2cSnmpConfiguration())); |
93 | providers.put("1.3.6.1.4.1.18070.2.2", new Bti7000SnmpAlarmProvider()); | 98 | providers.put("1.3.6.1.4.1.18070.2.2", new Bti7000SnmpAlarmProvider()); |
... | @@ -99,7 +104,7 @@ public class SnmpAlarmProviderService extends AbstractProvider implements AlarmP | ... | @@ -99,7 +104,7 @@ public class SnmpAlarmProviderService extends AbstractProvider implements AlarmP |
99 | appId = coreService.registerApplication("org.onosproject.snmp"); | 104 | appId = coreService.registerApplication("org.onosproject.snmp"); |
100 | eventHandlingExecutor = Executors.newSingleThreadExecutor( | 105 | eventHandlingExecutor = Executors.newSingleThreadExecutor( |
101 | groupedThreads("onos/alarms", "event-handler")); | 106 | groupedThreads("onos/alarms", "event-handler")); |
102 | - deviceService.addListener(new InternalDeviceListener()); | 107 | + deviceService.addListener(internalDeviceListener); |
103 | log.info("activated SNMP provider with appId = {} and context props {}", appId, context.getProperties()); | 108 | log.info("activated SNMP provider with appId = {} and context props {}", appId, context.getProperties()); |
104 | modified(context); | 109 | modified(context); |
105 | 110 | ||
... | @@ -109,6 +114,7 @@ public class SnmpAlarmProviderService extends AbstractProvider implements AlarmP | ... | @@ -109,6 +114,7 @@ public class SnmpAlarmProviderService extends AbstractProvider implements AlarmP |
109 | @Deactivate | 114 | @Deactivate |
110 | public void deactivate() { | 115 | public void deactivate() { |
111 | log.info("deactivate SNMP provider {}", appId); | 116 | log.info("deactivate SNMP provider {}", appId); |
117 | + deviceService.removeListener(internalDeviceListener); | ||
112 | } | 118 | } |
113 | 119 | ||
114 | @Modified | 120 | @Modified | ... | ... |
... | @@ -21,6 +21,7 @@ | ... | @@ -21,6 +21,7 @@ |
21 | <bundle>mvn:io.netty/netty/3.9.2.Final</bundle> | 21 | <bundle>mvn:io.netty/netty/3.9.2.Final</bundle> |
22 | <bundle>mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.snmp4j/2.3.4_1</bundle> | 22 | <bundle>mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.snmp4j/2.3.4_1</bundle> |
23 | <bundle>mvn:${project.groupId}/onos-snmp-provider-device/${project.version}</bundle> | 23 | <bundle>mvn:${project.groupId}/onos-snmp-provider-device/${project.version}</bundle> |
24 | + <bundle>mvn:${project.groupId}/onos-snmp-provider-alarm/${project.version}</bundle> | ||
24 | <bundle>mvn:com.btisystems/snmp-core/1.3-SNAPSHOT</bundle> | 25 | <bundle>mvn:com.btisystems/snmp-core/1.3-SNAPSHOT</bundle> |
25 | <bundle>mvn:com.btisystems.mibbler.mibs/bti7000/1.0-SNAPSHOT</bundle> | 26 | <bundle>mvn:com.btisystems.mibbler.mibs/bti7000/1.0-SNAPSHOT</bundle> |
26 | <bundle>mvn:com.btisystems.mibbler.mibs/net-snmp/1.0-SNAPSHOT</bundle> | 27 | <bundle>mvn:com.btisystems.mibbler.mibs/net-snmp/1.0-SNAPSHOT</bundle> | ... | ... |
-
Please register or login to post a comment