Committed by
Gerrit Code Review
Avoid repeated re-creation of AlarmTranslator
Change-Id: I1cb7239442cbb9cec193b32fb09e49f2d873ebd9
Showing
1 changed file
with
2 additions
and
1 deletions
... | @@ -26,6 +26,7 @@ import org.onosproject.incubator.net.faultmanagement.alarm.Alarm; | ... | @@ -26,6 +26,7 @@ import org.onosproject.incubator.net.faultmanagement.alarm.Alarm; |
26 | import org.onosproject.incubator.net.faultmanagement.alarm.AlarmProvider; | 26 | import org.onosproject.incubator.net.faultmanagement.alarm.AlarmProvider; |
27 | import org.onosproject.incubator.net.faultmanagement.alarm.AlarmProviderService; | 27 | import org.onosproject.incubator.net.faultmanagement.alarm.AlarmProviderService; |
28 | import org.onosproject.incubator.net.faultmanagement.alarm.AlarmProviderRegistry; | 28 | import org.onosproject.incubator.net.faultmanagement.alarm.AlarmProviderRegistry; |
29 | +import org.onosproject.incubator.net.faultmanagement.alarm.AlarmTranslator; | ||
29 | import org.onosproject.net.DeviceId; | 30 | import org.onosproject.net.DeviceId; |
30 | import org.onosproject.net.provider.AbstractProvider; | 31 | import org.onosproject.net.provider.AbstractProvider; |
31 | import org.onosproject.net.provider.ProviderId; | 32 | import org.onosproject.net.provider.ProviderId; |
... | @@ -55,6 +56,7 @@ public class NetconfAlarmProvider extends AbstractProvider implements AlarmProvi | ... | @@ -55,6 +56,7 @@ public class NetconfAlarmProvider extends AbstractProvider implements AlarmProvi |
55 | 56 | ||
56 | public static final String ACTIVE = "active"; | 57 | public static final String ACTIVE = "active"; |
57 | private final Logger log = getLogger(getClass()); | 58 | private final Logger log = getLogger(getClass()); |
59 | + private final AlarmTranslator translator = new NetconfAlarmTranslator(); | ||
58 | 60 | ||
59 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | 61 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
60 | protected AlarmProviderRegistry providerRegistry; | 62 | protected AlarmProviderRegistry providerRegistry; |
... | @@ -120,7 +122,6 @@ public class NetconfAlarmProvider extends AbstractProvider implements AlarmProvi | ... | @@ -120,7 +122,6 @@ public class NetconfAlarmProvider extends AbstractProvider implements AlarmProvi |
120 | public void event(NetconfDeviceOutputEvent event) { | 122 | public void event(NetconfDeviceOutputEvent event) { |
121 | if (event.type() == NetconfDeviceOutputEvent.Type.DEVICE_NOTIFICATION) { | 123 | if (event.type() == NetconfDeviceOutputEvent.Type.DEVICE_NOTIFICATION) { |
122 | DeviceId deviceId = event.getDeviceInfo().getDeviceId(); | 124 | DeviceId deviceId = event.getDeviceInfo().getDeviceId(); |
123 | - NetconfAlarmTranslator translator = new NetconfAlarmTranslator(); | ||
124 | String message = event.getMessagePayload(); | 125 | String message = event.getMessagePayload(); |
125 | InputStream in = new ByteArrayInputStream(message.getBytes(StandardCharsets.UTF_8)); | 126 | InputStream in = new ByteArrayInputStream(message.getBytes(StandardCharsets.UTF_8)); |
126 | Collection<Alarm> newAlarms = translator.translateToAlarm(deviceId, in); | 127 | Collection<Alarm> newAlarms = translator.translateToAlarm(deviceId, in); | ... | ... |
-
Please register or login to post a comment