Remove deprecated Alarm builder API
Change-Id: I2a51096836b918179b1e2b9e7a3358447e7170cb
diff --git a/drivers/fujitsu/src/main/java/org/onosproject/drivers/fujitsu/FujitsuVoltAlarmConsumer.java b/drivers/fujitsu/src/main/java/org/onosproject/drivers/fujitsu/FujitsuVoltAlarmConsumer.java
index 01df800..991b7f7 100644
--- a/drivers/fujitsu/src/main/java/org/onosproject/drivers/fujitsu/FujitsuVoltAlarmConsumer.java
+++ b/drivers/fujitsu/src/main/java/org/onosproject/drivers/fujitsu/FujitsuVoltAlarmConsumer.java
@@ -22,6 +22,7 @@
import org.onosproject.incubator.net.faultmanagement.alarm.Alarm;
import org.onosproject.incubator.net.faultmanagement.alarm.AlarmConsumer;
import org.onosproject.incubator.net.faultmanagement.alarm.AlarmEntityId;
+import org.onosproject.incubator.net.faultmanagement.alarm.AlarmId;
import org.onosproject.incubator.net.faultmanagement.alarm.DefaultAlarm;
import org.onosproject.net.DeviceId;
import org.onosproject.net.driver.AbstractHandlerBehaviour;
@@ -190,6 +191,7 @@
log.warn("Unknown severity: {}", severity);
}
DefaultAlarm.Builder alarmBuilder = new DefaultAlarm.Builder(
+ AlarmId.alarmId(ncDeviceId, Long.toString(timeRaised)),
ncDeviceId, alertType.toUpperCase(), alarmLevel, timeRaised)
.forSource(AlarmEntityId.alarmEntityId(alarmSrc));
alarms.add(alarmBuilder.build());
diff --git a/drivers/lumentum/src/main/java/org/onosproject/drivers/lumentum/LumentumAlarmConsumer.java b/drivers/lumentum/src/main/java/org/onosproject/drivers/lumentum/LumentumAlarmConsumer.java
index bdd0c94..91289e3 100644
--- a/drivers/lumentum/src/main/java/org/onosproject/drivers/lumentum/LumentumAlarmConsumer.java
+++ b/drivers/lumentum/src/main/java/org/onosproject/drivers/lumentum/LumentumAlarmConsumer.java
@@ -68,11 +68,11 @@
snmp.get(ALARMS_TABLE_OID)
.forEach(alarm -> snmp.get(ALARMS_ID_OID).forEach(alarmIdEvent -> {
int alarmId = getAlarmId(alarmIdEvent);
- alarms.add(new DefaultAlarm.Builder(deviceId, getMessage(alarmId),
+ alarms.add(new DefaultAlarm.Builder(AlarmId.alarmId(deviceId, String.valueOf(alarmId)),
+ deviceId, getMessage(alarmId),
getSeverity(alarmId),
System.currentTimeMillis())
- .withId(AlarmId.alarmId(deviceId, String.valueOf(alarmId)))
- .build());
+ .build());
}));
return ImmutableList.copyOf(alarms);
}
diff --git a/incubator/api/src/main/java/org/onosproject/incubator/net/faultmanagement/alarm/DefaultAlarm.java b/incubator/api/src/main/java/org/onosproject/incubator/net/faultmanagement/alarm/DefaultAlarm.java
index fd4bad0..53784b0 100644
--- a/incubator/api/src/main/java/org/onosproject/incubator/net/faultmanagement/alarm/DefaultAlarm.java
+++ b/incubator/api/src/main/java/org/onosproject/incubator/net/faultmanagement/alarm/DefaultAlarm.java
@@ -277,28 +277,6 @@
/**
* Constructs a Builder to create a Default Alarm.
*
- * @param deviceId the device ID
- * @param description the Alarm description
- * @param severity the severity
- * @param timeRaised when the alarm was raised
- * @deprecated 1.10.0 - Kingfisher
- */
- @Deprecated
- public Builder(final DeviceId deviceId,
- final String description, final SeverityLevel severity, final long timeRaised) {
- super();
- this.deviceId = deviceId;
- this.description = description;
- this.severity = severity;
- this.timeRaised = timeRaised;
- // Unless specified time-updated is same as raised.
- this.timeUpdated = timeRaised;
- this.id = AlarmId.alarmId(deviceId, Long.toString(timeRaised));
- }
-
- /**
- * Constructs a Builder to create a Default Alarm.
- *
* @param id the AlarmId
* @param deviceId the device ID
* @param description the Alarm description
@@ -351,19 +329,6 @@
}
/**
- * Sets the new alarm Id.
- *
- * @param id the id
- * @return self for chaining
- * @deprecated 1.10.0- Kingfisher
- */
- @Deprecated
- public Builder withId(final AlarmId id) {
- this.id = id;
- return this;
- }
-
- /**
* Clears the alarm that is being created.
*
* @return self for chaining
diff --git a/protocols/snmp/ctl/src/main/java/org/onosproject/snmp/ctl/DefaultSnmpController.java b/protocols/snmp/ctl/src/main/java/org/onosproject/snmp/ctl/DefaultSnmpController.java
index 5703e82..8ddbb6b 100644
--- a/protocols/snmp/ctl/src/main/java/org/onosproject/snmp/ctl/DefaultSnmpController.java
+++ b/protocols/snmp/ctl/src/main/java/org/onosproject/snmp/ctl/DefaultSnmpController.java
@@ -27,6 +27,7 @@
import org.apache.felix.scr.annotations.Deactivate;
import org.apache.felix.scr.annotations.Service;
import org.onosproject.incubator.net.faultmanagement.alarm.Alarm;
+import org.onosproject.incubator.net.faultmanagement.alarm.AlarmId;
import org.onosproject.incubator.net.faultmanagement.alarm.DefaultAlarm;
import org.onosproject.net.DeviceId;
import org.onosproject.snmp.SnmpController;
@@ -122,9 +123,10 @@
@Override
public DefaultAlarm buildWalkFailedAlarm(DeviceId deviceId) {
+ long timeRaised = System.currentTimeMillis();
return new DefaultAlarm.Builder(
+ AlarmId.alarmId(deviceId, Long.toString(timeRaised)),
deviceId, "SNMP alarm retrieval failed",
- Alarm.SeverityLevel.CRITICAL,
- System.currentTimeMillis()).build();
+ Alarm.SeverityLevel.CRITICAL, timeRaised).build();
}
}
diff --git a/protocols/snmp/ctl/src/test/java/org/onosproject/snmp/ctl/DefaultSnmpControllerTest.java b/protocols/snmp/ctl/src/test/java/org/onosproject/snmp/ctl/DefaultSnmpControllerTest.java
index ff1aa03..a649633 100644
--- a/protocols/snmp/ctl/src/test/java/org/onosproject/snmp/ctl/DefaultSnmpControllerTest.java
+++ b/protocols/snmp/ctl/src/test/java/org/onosproject/snmp/ctl/DefaultSnmpControllerTest.java
@@ -23,6 +23,7 @@
import org.junit.Before;
import org.junit.Test;
import org.onosproject.incubator.net.faultmanagement.alarm.Alarm;
+import org.onosproject.incubator.net.faultmanagement.alarm.AlarmId;
import org.onosproject.incubator.net.faultmanagement.alarm.DefaultAlarm;
import java.io.IOException;
@@ -42,10 +43,12 @@
ISnmpSession snmpSession = new ISnmpSessionAdapter();
+ long time = System.currentTimeMillis();
DefaultAlarm alarm = new DefaultAlarm.Builder(
+ AlarmId.alarmId(device.deviceId(), Long.toString(time)),
device.deviceId(), "SNMP alarm retrieval failed",
Alarm.SeverityLevel.CRITICAL,
- System.currentTimeMillis()).build();
+ time).build();
@Before
public void setUp() {
diff --git a/providers/netconf/alarm/src/main/java/org/onosproject/provider/netconf/alarm/NetconfAlarmTranslator.java b/providers/netconf/alarm/src/main/java/org/onosproject/provider/netconf/alarm/NetconfAlarmTranslator.java
index 4636704..10c653c 100644
--- a/providers/netconf/alarm/src/main/java/org/onosproject/provider/netconf/alarm/NetconfAlarmTranslator.java
+++ b/providers/netconf/alarm/src/main/java/org/onosproject/provider/netconf/alarm/NetconfAlarmTranslator.java
@@ -18,6 +18,7 @@
import com.google.common.collect.ImmutableSet;
import org.onosproject.incubator.net.faultmanagement.alarm.Alarm;
+import org.onosproject.incubator.net.faultmanagement.alarm.AlarmId;
import org.onosproject.incubator.net.faultmanagement.alarm.AlarmTranslator;
import org.onosproject.incubator.net.faultmanagement.alarm.DefaultAlarm;
import org.onosproject.net.DeviceId;
@@ -71,7 +72,8 @@
while (descriptionNode != null) {
if (descriptionNode.getNodeType() == Node.ELEMENT_NODE) {
String description = nodeToString(descriptionNode);
- alarms.add(new DefaultAlarm.Builder(deviceId, description,
+ alarms.add(new DefaultAlarm.Builder(AlarmId.alarmId(deviceId, Long.toString(timeStamp)),
+ deviceId, description,
Alarm.SeverityLevel.WARNING,
timeStamp).build());
descriptionNode = null;