Avoid repeated re-creation of AlarmTranslator
Change-Id: I1cb7239442cbb9cec193b32fb09e49f2d873ebd9
diff --git a/providers/netconf/alarm/src/main/java/org/onosproject/provider/netconf/alarm/NetconfAlarmProvider.java b/providers/netconf/alarm/src/main/java/org/onosproject/provider/netconf/alarm/NetconfAlarmProvider.java
index ec74eb6..eb0ccb6 100644
--- a/providers/netconf/alarm/src/main/java/org/onosproject/provider/netconf/alarm/NetconfAlarmProvider.java
+++ b/providers/netconf/alarm/src/main/java/org/onosproject/provider/netconf/alarm/NetconfAlarmProvider.java
@@ -26,6 +26,7 @@
import org.onosproject.incubator.net.faultmanagement.alarm.AlarmProvider;
import org.onosproject.incubator.net.faultmanagement.alarm.AlarmProviderService;
import org.onosproject.incubator.net.faultmanagement.alarm.AlarmProviderRegistry;
+import org.onosproject.incubator.net.faultmanagement.alarm.AlarmTranslator;
import org.onosproject.net.DeviceId;
import org.onosproject.net.provider.AbstractProvider;
import org.onosproject.net.provider.ProviderId;
@@ -55,6 +56,7 @@
public static final String ACTIVE = "active";
private final Logger log = getLogger(getClass());
+ private final AlarmTranslator translator = new NetconfAlarmTranslator();
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected AlarmProviderRegistry providerRegistry;
@@ -120,7 +122,6 @@
public void event(NetconfDeviceOutputEvent event) {
if (event.type() == NetconfDeviceOutputEvent.Type.DEVICE_NOTIFICATION) {
DeviceId deviceId = event.getDeviceInfo().getDeviceId();
- NetconfAlarmTranslator translator = new NetconfAlarmTranslator();
String message = event.getMessagePayload();
InputStream in = new ByteArrayInputStream(message.getBytes(StandardCharsets.UTF_8));
Collection<Alarm> newAlarms = translator.translateToAlarm(deviceId, in);