Deprecate joda-time
- ref:
http://blog.joda.org/2014/11/converting-from-joda-time-to-javatime.html
Change-Id: I1115e8053f601e78cb933ccbfa664ff8787d2da1
diff --git a/apps/cpman/app/BUCK b/apps/cpman/app/BUCK
index 936c9ff..ea4dda7 100644
--- a/apps/cpman/app/BUCK
+++ b/apps/cpman/app/BUCK
@@ -3,7 +3,6 @@
'//lib:JACKSON',
'//lib:METRICS',
'//lib:KRYO',
- '//lib:joda-time',
'//lib:org.apache.karaf.shell.console',
'//lib:javax.ws.rs-api',
'//lib:rrd4j',
diff --git a/apps/cpman/app/src/main/java/org/onosproject/cpman/gui/CpmanViewMessageHandler.java b/apps/cpman/app/src/main/java/org/onosproject/cpman/gui/CpmanViewMessageHandler.java
index 9263aa8..8f64844 100644
--- a/apps/cpman/app/src/main/java/org/onosproject/cpman/gui/CpmanViewMessageHandler.java
+++ b/apps/cpman/app/src/main/java/org/onosproject/cpman/gui/CpmanViewMessageHandler.java
@@ -23,7 +23,6 @@
import com.google.common.collect.Sets;
import org.apache.commons.lang.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
-import org.joda.time.LocalDateTime;
import org.onosproject.cluster.ClusterService;
import org.onosproject.cluster.NodeId;
import org.onosproject.cpman.ControlLoadSnapshot;
@@ -36,6 +35,9 @@
import org.onosproject.ui.chart.ChartModel;
import org.onosproject.ui.chart.ChartRequestHandler;
+import java.time.Instant;
+import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
import java.util.Collection;
import java.util.Map;
import java.util.Optional;
@@ -63,7 +65,7 @@
private static final int MILLI_CONV_UNIT = 1000;
- private static final String TIME_FORMAT = "HH:mm";
+ private static final DateTimeFormatter TIME_FORMAT = DateTimeFormatter.ISO_LOCAL_TIME;
private long timestamp = 0L;
@@ -98,7 +100,7 @@
DeviceId deviceId = DeviceId.deviceId(uri);
if (cpms.availableResourcesSync(localNodeId, CONTROL_MESSAGE).contains(deviceId.toString())) {
Map<ControlMetricType, Long[]> data = generateMatrix(cpms, cs, deviceId);
- LocalDateTime ldt = new LocalDateTime(timestamp * MILLI_CONV_UNIT);
+ LocalDateTime ldt = LocalDateTime.from(Instant.ofEpochMilli(timestamp * MILLI_CONV_UNIT));
populateMetrics(cm, data, ldt, NUM_OF_DATA_POINTS);
@@ -167,6 +169,7 @@
}
}
+ // FIXME using local time in timestamps likely to be sign of problem
private void populateMetrics(ChartModel cm,
Map<ControlMetricType, Long[]> data,
LocalDateTime time, int numOfDp) {
@@ -176,7 +179,7 @@
local.put(StringUtils.lowerCase(cmt.name()), data.get(cmt)[i]);
}
- String calculated = time.minusMinutes(numOfDp - i).toString(TIME_FORMAT);
+ String calculated = time.minusMinutes(numOfDp - i).format(TIME_FORMAT);
local.put(LABEL, calculated);
populateMetric(cm.addDataPoint(calculated), local);
diff --git a/apps/events/BUCK b/apps/events/BUCK
index 52fd3a9..12e888b 100644
--- a/apps/events/BUCK
+++ b/apps/events/BUCK
@@ -3,7 +3,6 @@
'//lib:JACKSON',
'//lib:org.apache.karaf.shell.console',
'//cli:onos-cli',
- '//lib:joda-time',
]
osgi_jar_with_tests (
diff --git a/apps/events/src/main/java/org/onosproject/events/EventsCommand.java b/apps/events/src/main/java/org/onosproject/events/EventsCommand.java
index db8df10..2664344 100644
--- a/apps/events/src/main/java/org/onosproject/events/EventsCommand.java
+++ b/apps/events/src/main/java/org/onosproject/events/EventsCommand.java
@@ -24,7 +24,7 @@
import org.apache.karaf.shell.commands.Command;
import org.apache.karaf.shell.commands.Option;
-import org.joda.time.LocalDateTime;
+import org.onlab.util.Tools;
import org.onosproject.cli.AbstractShellCommand;
import org.onosproject.cluster.ClusterEvent;
import org.onosproject.event.Event;
@@ -187,7 +187,7 @@
if (event.type().toString().startsWith("PORT")) {
// Port event
print("%s %s\t%s/%s [%s]",
- new LocalDateTime(event.time()),
+ Tools.defaultOffsetDataTime(event.time()),
event.type(),
deviceEvent.subject().id(), deviceEvent.port().number(),
deviceEvent.port()
@@ -195,7 +195,7 @@
} else {
// Device event
print("%s %s\t%s [%s]",
- new LocalDateTime(event.time()),
+ Tools.defaultOffsetDataTime(event.time()),
event.type(),
deviceEvent.subject().id(),
deviceEvent.subject()
@@ -204,7 +204,7 @@
} else if (event instanceof MastershipEvent) {
print("%s %s\t%s [%s]",
- new LocalDateTime(event.time()),
+ Tools.defaultOffsetDataTime(event.time()),
event.type(),
event.subject(),
((MastershipEvent) event).roleInfo());
@@ -213,7 +213,7 @@
LinkEvent linkEvent = (LinkEvent) event;
Link link = linkEvent.subject();
print("%s %s\t%s/%s-%s/%s [%s]",
- new LocalDateTime(event.time()),
+ Tools.defaultOffsetDataTime(event.time()),
event.type(),
link.src().deviceId(), link.src().port(), link.dst().deviceId(), link.dst().port(),
link);
@@ -221,7 +221,7 @@
} else if (event instanceof HostEvent) {
HostEvent hostEvent = (HostEvent) event;
print("%s %s\t%s [%s->%s]",
- new LocalDateTime(event.time()),
+ Tools.defaultOffsetDataTime(event.time()),
event.type(),
hostEvent.subject().id(),
hostEvent.prevSubject(), hostEvent.subject());
@@ -236,14 +236,14 @@
topo.linkCount(),
topo.clusterCount());
print("%s %s%s [%s]",
- new LocalDateTime(event.time()),
+ Tools.defaultOffsetDataTime(event.time()),
event.type(),
summary,
reasons.stream().map(e -> e.type()).collect(toList()));
} else if (event instanceof ClusterEvent) {
print("%s %s\t%s [%s]",
- new LocalDateTime(event.time()),
+ Tools.defaultOffsetDataTime(event.time()),
event.type(),
((ClusterEvent) event).subject().id(),
event.subject());
@@ -251,7 +251,7 @@
} else {
// Unknown Event?
print("%s %s\t%s [%s]",
- new LocalDateTime(event.time()),
+ Tools.defaultOffsetDataTime(event.time()),
event.type(),
event.subject(),
event);
diff --git a/apps/evpn-route-service/api/BUCK b/apps/evpn-route-service/api/BUCK
index d4825d3..68eeacf 100644
--- a/apps/evpn-route-service/api/BUCK
+++ b/apps/evpn-route-service/api/BUCK
@@ -1,6 +1,5 @@
COMPILE_DEPS = [
'//lib:CORE_DEPS',
- '//lib:joda-time',
]
TEST_DEPS = [
diff --git a/apps/evpn-route-service/api/src/main/java/org/onosproject/evpnrouteservice/EvpnRouteEvent.java b/apps/evpn-route-service/api/src/main/java/org/onosproject/evpnrouteservice/EvpnRouteEvent.java
index ae3d93a..5e7f83a 100644
--- a/apps/evpn-route-service/api/src/main/java/org/onosproject/evpnrouteservice/EvpnRouteEvent.java
+++ b/apps/evpn-route-service/api/src/main/java/org/onosproject/evpnrouteservice/EvpnRouteEvent.java
@@ -20,7 +20,7 @@
import java.util.Collections;
import java.util.Objects;
-import org.joda.time.LocalDateTime;
+import org.onlab.util.Tools;
import org.onosproject.event.AbstractEvent;
import static com.google.common.base.MoreObjects.toStringHelper;
@@ -185,7 +185,7 @@
@Override
public String toString() {
return toStringHelper(this)
- .add("time", new LocalDateTime(time()))
+ .add("time", Tools.defaultOffsetDataTime(time()))
.add("type", type())
.add("subject", subject())
.add("prevSubject", prevSubject)
diff --git a/apps/faultmanagement/fmgui/BUCK b/apps/faultmanagement/fmgui/BUCK
index 3d8cfc7..96c7835 100644
--- a/apps/faultmanagement/fmgui/BUCK
+++ b/apps/faultmanagement/fmgui/BUCK
@@ -4,7 +4,6 @@
'//lib:org.apache.karaf.shell.console',
'//incubator/api:onos-incubator-api',
'//cli:onos-cli',
- '//lib:joda-time',
]
osgi_jar_with_tests (
diff --git a/apps/faultmanagement/fmgui/src/main/java/org/onosproject/faultmanagement/alarms/gui/AlarmTableMessageHandler.java b/apps/faultmanagement/fmgui/src/main/java/org/onosproject/faultmanagement/alarms/gui/AlarmTableMessageHandler.java
index 1a21907..3bb49ad 100644
--- a/apps/faultmanagement/fmgui/src/main/java/org/onosproject/faultmanagement/alarms/gui/AlarmTableMessageHandler.java
+++ b/apps/faultmanagement/fmgui/src/main/java/org/onosproject/faultmanagement/alarms/gui/AlarmTableMessageHandler.java
@@ -18,7 +18,6 @@
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.google.common.base.Strings;
import com.google.common.collect.ImmutableSet;
-import org.joda.time.DateTime;
import org.onosproject.incubator.net.faultmanagement.alarm.Alarm;
import org.onosproject.net.DeviceId;
import org.onosproject.ui.RequestHandler;
@@ -29,6 +28,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import java.time.Instant;
import java.util.Collection;
import java.util.Set;
@@ -126,7 +126,7 @@
.cell(DEVICE_ID_STR, alarm.deviceId())
.cell(DESCRIPTION, alarm.description())
.cell(SOURCE, alarm.source())
- .cell(TIME_RAISED, new DateTime(alarm.timeRaised()))
+ .cell(TIME_RAISED, Instant.ofEpochMilli(alarm.timeRaised()))
.cell(SEVERITY, alarm.severity());
}
}
@@ -177,6 +177,6 @@
if (msSinceStartOfEpoch == null) {
return "-";
}
- return new TimeFormatter().format(new DateTime(msSinceStartOfEpoch));
+ return new TimeFormatter().format(Instant.ofEpochMilli(msSinceStartOfEpoch));
}
}
diff --git a/apps/influxdbmetrics/BUCK b/apps/influxdbmetrics/BUCK
index 6c0bbc8..14e6a4b 100644
--- a/apps/influxdbmetrics/BUCK
+++ b/apps/influxdbmetrics/BUCK
@@ -10,7 +10,6 @@
'//lib:okio',
'//lib:gson',
'//cli:onos-cli',
- '//lib:joda-time',
]
EXCLUDED_BUNDLES = [
diff --git a/apps/influxdbmetrics/src/main/java/org/onosproject/influxdbmetrics/DefaultInfluxMetric.java b/apps/influxdbmetrics/src/main/java/org/onosproject/influxdbmetrics/DefaultInfluxMetric.java
index ab8f31c..f3ce81a 100644
--- a/apps/influxdbmetrics/src/main/java/org/onosproject/influxdbmetrics/DefaultInfluxMetric.java
+++ b/apps/influxdbmetrics/src/main/java/org/onosproject/influxdbmetrics/DefaultInfluxMetric.java
@@ -15,22 +15,20 @@
*/
package org.onosproject.influxdbmetrics;
-import org.apache.commons.lang.StringUtils;
-import org.joda.time.DateTime;
-import org.joda.time.format.DateTimeFormat;
-import org.joda.time.format.DateTimeFormatter;
-
import static com.google.common.base.Preconditions.checkNotNull;
+import java.time.Instant;
+import java.time.format.DateTimeFormatter;
+
/**
* Default implementation of influx metric.
*/
public final class DefaultInfluxMetric implements InfluxMetric {
private double oneMinRate;
- private DateTime time;
+ private Instant time;
- private DefaultInfluxMetric(double oneMinRate, DateTime time) {
+ private DefaultInfluxMetric(double oneMinRate, Instant time) {
this.oneMinRate = oneMinRate;
this.time = time;
}
@@ -41,7 +39,7 @@
}
@Override
- public DateTime time() {
+ public Instant time() {
return time;
}
@@ -75,10 +73,8 @@
return new DefaultInfluxMetric(oneMinRate, parseTime(timestamp));
}
- private DateTime parseTime(String time) {
- String reformatTime = StringUtils.replace(StringUtils.replace(time, "T", " "), "Z", "");
- DateTimeFormatter formatter = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss");
- return formatter.parseDateTime(reformatTime);
+ private Instant parseTime(String time) {
+ return DateTimeFormatter.ISO_DATE_TIME.parse(time, Instant::from);
}
}
}
diff --git a/apps/influxdbmetrics/src/main/java/org/onosproject/influxdbmetrics/InfluxMetric.java b/apps/influxdbmetrics/src/main/java/org/onosproject/influxdbmetrics/InfluxMetric.java
index e0d16ef..35756f3 100644
--- a/apps/influxdbmetrics/src/main/java/org/onosproject/influxdbmetrics/InfluxMetric.java
+++ b/apps/influxdbmetrics/src/main/java/org/onosproject/influxdbmetrics/InfluxMetric.java
@@ -15,7 +15,7 @@
*/
package org.onosproject.influxdbmetrics;
-import org.joda.time.DateTime;
+import java.time.Instant;
/**
* Metric that represents all values queried from influx database.
@@ -35,7 +35,7 @@
*
* @return collected timestamp of the given metric
*/
- DateTime time();
+ Instant time();
/**
* A builder of InfluxMetric.
diff --git a/apps/iptopology-api/BUCK b/apps/iptopology-api/BUCK
index 9661e11..3cc9301 100644
--- a/apps/iptopology-api/BUCK
+++ b/apps/iptopology-api/BUCK
@@ -1,6 +1,5 @@
COMPILE_DEPS = [
'//lib:CORE_DEPS',
- '//lib:joda-time',
]
osgi_jar_with_tests (
diff --git a/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/device/IpDeviceEvent.java b/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/device/IpDeviceEvent.java
index 602d72e..26aaf31 100644
--- a/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/device/IpDeviceEvent.java
+++ b/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/device/IpDeviceEvent.java
@@ -15,7 +15,7 @@
*/
package org.onosproject.iptopology.api.device;
-import org.joda.time.LocalDateTime;
+import org.onlab.util.Tools;
import org.onosproject.event.AbstractEvent;
import org.onosproject.iptopology.api.DeviceIntf;
import org.onosproject.iptopology.api.DevicePrefix;
@@ -173,7 +173,7 @@
return super.toString();
}
return toStringHelper(this)
- .add("time", new LocalDateTime(time()))
+ .add("time", Tools.defaultOffsetDataTime(time()))
.add("type", type())
.add("subject", subject())
.add("interface", devInterface)
diff --git a/apps/openstacknetworking/BUCK b/apps/openstacknetworking/BUCK
index 60ebc1f..4a5d19c 100644
--- a/apps/openstacknetworking/BUCK
+++ b/apps/openstacknetworking/BUCK
@@ -9,7 +9,6 @@
'//cli:onos-cli',
'//apps/openstacknode/api:onos-apps-openstacknode-api',
'//lib:openstack4j-core',
- '//lib:joda-time',
]
TEST_DEPS = [
diff --git a/apps/openstacknetworking/src/main/java/org/onosproject/openstacknetworking/api/OpenstackNetworkEvent.java b/apps/openstacknetworking/src/main/java/org/onosproject/openstacknetworking/api/OpenstackNetworkEvent.java
index c4aad23..4f4892f 100644
--- a/apps/openstacknetworking/src/main/java/org/onosproject/openstacknetworking/api/OpenstackNetworkEvent.java
+++ b/apps/openstacknetworking/src/main/java/org/onosproject/openstacknetworking/api/OpenstackNetworkEvent.java
@@ -15,7 +15,7 @@
*/
package org.onosproject.openstacknetworking.api;
-import org.joda.time.LocalDateTime;
+import org.onlab.util.Tools;
import org.onosproject.event.AbstractEvent;
import org.openstack4j.model.network.Network;
import org.openstack4j.model.network.Port;
@@ -178,7 +178,7 @@
return super.toString();
}
return toStringHelper(this)
- .add("time", new LocalDateTime(time()))
+ .add("time", Tools.defaultOffsetDataTime(time()))
.add("type", type())
.add("network", subject())
.add("port", port)
diff --git a/apps/openstacknetworking/src/main/java/org/onosproject/openstacknetworking/api/OpenstackRouterEvent.java b/apps/openstacknetworking/src/main/java/org/onosproject/openstacknetworking/api/OpenstackRouterEvent.java
index d3a9d77..ba15cd0 100644
--- a/apps/openstacknetworking/src/main/java/org/onosproject/openstacknetworking/api/OpenstackRouterEvent.java
+++ b/apps/openstacknetworking/src/main/java/org/onosproject/openstacknetworking/api/OpenstackRouterEvent.java
@@ -15,7 +15,7 @@
*/
package org.onosproject.openstacknetworking.api;
-import org.joda.time.LocalDateTime;
+import org.onlab.util.Tools;
import org.onosproject.event.AbstractEvent;
import org.openstack4j.model.network.ExternalGateway;
import org.openstack4j.model.network.NetFloatingIP;
@@ -228,7 +228,7 @@
return super.toString();
}
return toStringHelper(this)
- .add("time", new LocalDateTime(time()))
+ .add("time", Tools.defaultOffsetDataTime(time()))
.add("type", type())
.add("router", subject())
.add("externalGateway", exGateway)
diff --git a/apps/route-service/api/BUCK b/apps/route-service/api/BUCK
index 05b3eee..3b7812b 100644
--- a/apps/route-service/api/BUCK
+++ b/apps/route-service/api/BUCK
@@ -1,7 +1,6 @@
COMPILE_DEPS = [
'//lib:CORE_DEPS',
'//lib:JACKSON',
- '//lib:joda-time',
]
TEST_DEPS = [
diff --git a/apps/route-service/api/src/main/java/org/onosproject/routeservice/RouteEvent.java b/apps/route-service/api/src/main/java/org/onosproject/routeservice/RouteEvent.java
index a7f5d88..b661b40 100644
--- a/apps/route-service/api/src/main/java/org/onosproject/routeservice/RouteEvent.java
+++ b/apps/route-service/api/src/main/java/org/onosproject/routeservice/RouteEvent.java
@@ -16,7 +16,7 @@
package org.onosproject.routeservice;
-import org.joda.time.LocalDateTime;
+import org.onlab.util.Tools;
import org.onosproject.event.AbstractEvent;
import java.util.Collection;
@@ -210,7 +210,7 @@
@Override
public String toString() {
return toStringHelper(this)
- .add("time", new LocalDateTime(time()))
+ .add("time", Tools.defaultOffsetDataTime(time()))
.add("type", type())
.add("subject", subject())
.add("prevSubject", prevSubject)
diff --git a/apps/segmentrouting/BUCK b/apps/segmentrouting/BUCK
index ae72b22..5942871 100644
--- a/apps/segmentrouting/BUCK
+++ b/apps/segmentrouting/BUCK
@@ -9,7 +9,6 @@
'//incubator/api:onos-incubator-api',
'//utils/rest:onlab-rest',
'//apps/route-service/api:onos-apps-route-service-api',
- '//lib:joda-time',
]
BUNDLES = [
diff --git a/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/DefaultRoutingHandler.java b/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/DefaultRoutingHandler.java
index 709d05e..5014811 100644
--- a/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/DefaultRoutingHandler.java
+++ b/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/DefaultRoutingHandler.java
@@ -23,7 +23,6 @@
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
-import org.joda.time.DateTime;
import org.onlab.packet.Ip4Address;
import org.onlab.packet.Ip6Address;
import org.onlab.packet.IpPrefix;
@@ -41,6 +40,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import java.time.Instant;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
@@ -79,7 +79,7 @@
private volatile Status populationStatus;
private ScheduledExecutorService executorService
= newScheduledThreadPool(1, groupedThreads("retryftr", "retry-%d", log));
- private DateTime lastRoutingChange;
+ private Instant lastRoutingChange;
/**
* Represents the default routing population status.
@@ -150,8 +150,8 @@
* @return true if stable
*/
public boolean isRoutingStable() {
- long last = (long) (lastRoutingChange.getMillis() / 1000.0);
- long now = (long) (DateTime.now().getMillis() / 1000.0);
+ long last = (long) (lastRoutingChange.toEpochMilli() / 1000.0);
+ long now = (long) (Instant.now().toEpochMilli() / 1000.0);
log.trace("Routing stable since {}s", now - last);
return (now - last) > STABLITY_THRESHOLD;
}
@@ -173,7 +173,7 @@
* startup or after a configuration event.
*/
public void populateAllRoutingRules() {
- lastRoutingChange = DateTime.now();
+ lastRoutingChange = Instant.now();
statusLock.lock();
try {
if (populationStatus == Status.STARTED) {
@@ -249,7 +249,7 @@
return;
}
- lastRoutingChange = DateTime.now();
+ lastRoutingChange = Instant.now();
statusLock.lock();
try {
if (populationStatus == Status.STARTED) {
@@ -374,7 +374,7 @@
log.warn("Only one event can be handled for link status change .. aborting");
return;
}
- lastRoutingChange = DateTime.now();
+ lastRoutingChange = Instant.now();
executorService.schedule(new UpdateMaps(), UPDATE_INTERVAL,
TimeUnit.SECONDS);
statusLock.lock();
diff --git a/cli/BUCK b/cli/BUCK
index 5e2d397..3fedcf4 100644
--- a/cli/BUCK
+++ b/cli/BUCK
@@ -7,7 +7,6 @@
'//incubator/net:onos-incubator-net',
'//utils/rest:onlab-rest',
'//core/common:onos-core-common',
- '//lib:joda-time',
]
osgi_jar (
diff --git a/cli/src/main/java/org/onosproject/cli/MetricsListCommand.java b/cli/src/main/java/org/onosproject/cli/MetricsListCommand.java
index 32a4ba0..d1ecafa 100644
--- a/cli/src/main/java/org/onosproject/cli/MetricsListCommand.java
+++ b/cli/src/main/java/org/onosproject/cli/MetricsListCommand.java
@@ -31,8 +31,8 @@
import com.google.common.collect.TreeMultimap;
import org.apache.karaf.shell.commands.Argument;
import org.apache.karaf.shell.commands.Command;
-import org.joda.time.LocalDateTime;
import org.onlab.metrics.MetricsService;
+import org.onlab.util.Tools;
import java.util.Comparator;
import java.util.Map;
@@ -108,7 +108,7 @@
Gauge gauge = (Gauge) metric;
final Object value = gauge.getValue();
if (name.endsWith("EpochMs") && value instanceof Long) {
- print(" value = %s (%s)", value, new LocalDateTime(value));
+ print(" value = %s (%s)", value, Tools.defaultOffsetDataTime((Long) value));
} else {
print(" value = %s", value);
}
@@ -233,4 +233,6 @@
private double nanoToMs(double nano) {
return nano / 1_000_000D;
}
+
+
}
diff --git a/cli/src/main/java/org/onosproject/cli/NodesListCommand.java b/cli/src/main/java/org/onosproject/cli/NodesListCommand.java
index a0967b3..8246b1d 100644
--- a/cli/src/main/java/org/onosproject/cli/NodesListCommand.java
+++ b/cli/src/main/java/org/onosproject/cli/NodesListCommand.java
@@ -20,13 +20,13 @@
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
import org.apache.karaf.shell.commands.Command;
-import org.joda.time.DateTime;
import org.onlab.util.Tools;
import org.onosproject.cluster.ClusterAdminService;
import org.onosproject.cluster.ControllerNode;
import org.onosproject.core.Version;
import org.onosproject.utils.Comparators;
+import java.time.Instant;
import java.util.Collections;
import java.util.List;
@@ -51,10 +51,10 @@
} else {
ControllerNode self = service.getLocalNode();
for (ControllerNode node : nodes) {
- DateTime lastUpdated = service.getLastUpdated(node.id());
+ Instant lastUpdated = service.getLastUpdatedInstant(node.id());
String timeAgo = "Never";
if (lastUpdated != null) {
- timeAgo = Tools.timeAgo(lastUpdated.getMillis());
+ timeAgo = Tools.timeAgo(lastUpdated.getEpochSecond());
}
Version version = service.getVersion(node.id());
print(FMT, node.id(), node.ip(), node.tcpPort(),
diff --git a/core/api/pom.xml b/core/api/pom.xml
index f4d65ca..290c345 100644
--- a/core/api/pom.xml
+++ b/core/api/pom.xml
@@ -34,6 +34,7 @@
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
+ <version>2.9.3</version>
</dependency>
<dependency>
<groupId>commons-configuration</groupId>
diff --git a/core/api/src/main/java/org/onosproject/cluster/ClusterService.java b/core/api/src/main/java/org/onosproject/cluster/ClusterService.java
index e4cf7ec..1a75e5f 100644
--- a/core/api/src/main/java/org/onosproject/cluster/ClusterService.java
+++ b/core/api/src/main/java/org/onosproject/cluster/ClusterService.java
@@ -15,6 +15,8 @@
*/
package org.onosproject.cluster;
+import java.time.Instant;
+import java.util.Optional;
import java.util.Set;
import org.joda.time.DateTime;
@@ -72,6 +74,27 @@
* @param nodeId controller node identifier
* @return system time when the availability state was last updated.
*/
- DateTime getLastUpdated(NodeId nodeId);
+ default Instant getLastUpdatedInstant(NodeId nodeId) {
+ return Optional.ofNullable(getLastUpdated(nodeId))
+ .map(DateTime::getMillis)
+ .map(Instant::ofEpochMilli)
+ .orElse(null);
+ }
+
+ /**
+ * Returns the system time when the availability state was last updated.
+ *
+ * @param nodeId controller node identifier
+ * @return system time when the availability state was last updated.
+ *
+ * @deprecated in 1.12.0
+ */
+ @Deprecated
+ default DateTime getLastUpdated(NodeId nodeId) {
+ return Optional.ofNullable(getLastUpdatedInstant(nodeId))
+ .map(Instant::toEpochMilli)
+ .map(DateTime::new)
+ .orElse(null);
+ }
}
diff --git a/core/api/src/main/java/org/onosproject/cluster/ClusterStore.java b/core/api/src/main/java/org/onosproject/cluster/ClusterStore.java
index 7154c78..dfe0b23 100644
--- a/core/api/src/main/java/org/onosproject/cluster/ClusterStore.java
+++ b/core/api/src/main/java/org/onosproject/cluster/ClusterStore.java
@@ -20,6 +20,8 @@
import org.onosproject.core.Version;
import org.onosproject.store.Store;
+import java.time.Instant;
+import java.util.Optional;
import java.util.Set;
/**
@@ -78,7 +80,28 @@
* @param nodeId controller node identifier
* @return system time when the availability state was last updated.
*/
- DateTime getLastUpdated(NodeId nodeId);
+ default Instant getLastUpdatedInstant(NodeId nodeId) {
+ return Optional.ofNullable(getLastUpdated(nodeId))
+ .map(DateTime::getMillis)
+ .map(Instant::ofEpochMilli)
+ .orElse(null);
+ }
+
+ /**
+ * Returns the system when the availability state was last updated.
+ *
+ * @param nodeId controller node identifier
+ * @return system time when the availability state was last updated.
+ *
+ * @deprecated in 1.12.0
+ */
+ @Deprecated
+ default DateTime getLastUpdated(NodeId nodeId) {
+ return Optional.ofNullable(getLastUpdatedInstant(nodeId))
+ .map(Instant::toEpochMilli)
+ .map(DateTime::new)
+ .orElse(null);
+ }
/**
* Adds a new controller node to the cluster.
diff --git a/core/api/src/main/java/org/onosproject/event/AbstractEvent.java b/core/api/src/main/java/org/onosproject/event/AbstractEvent.java
index 2d810a3..754ecbb 100644
--- a/core/api/src/main/java/org/onosproject/event/AbstractEvent.java
+++ b/core/api/src/main/java/org/onosproject/event/AbstractEvent.java
@@ -15,7 +15,7 @@
*/
package org.onosproject.event;
-import org.joda.time.LocalDateTime;
+import org.onlab.util.Tools;
import static com.google.common.base.MoreObjects.toStringHelper;
@@ -70,7 +70,7 @@
@Override
public String toString() {
return toStringHelper(this)
- .add("time", new LocalDateTime(time))
+ .add("time", Tools.defaultOffsetDataTime(time))
.add("type", type())
.add("subject", subject())
.toString();
diff --git a/core/api/src/main/java/org/onosproject/mastership/MastershipEvent.java b/core/api/src/main/java/org/onosproject/mastership/MastershipEvent.java
index 4242e61..db5ba74 100644
--- a/core/api/src/main/java/org/onosproject/mastership/MastershipEvent.java
+++ b/core/api/src/main/java/org/onosproject/mastership/MastershipEvent.java
@@ -15,7 +15,7 @@
*/
package org.onosproject.mastership;
-import org.joda.time.LocalDateTime;
+import org.onlab.util.Tools;
import org.onosproject.cluster.RoleInfo;
import org.onosproject.event.AbstractEvent;
import org.onosproject.net.DeviceId;
@@ -114,7 +114,7 @@
@Override
public String toString() {
return MoreObjects.toStringHelper(getClass())
- .add("time", new LocalDateTime(time()))
+ .add("time", Tools.defaultOffsetDataTime(time()))
.add("type", type())
.add("subject", subject())
.add("roleInfo", roleInfo)
diff --git a/core/api/src/main/java/org/onosproject/net/config/NetworkConfigEvent.java b/core/api/src/main/java/org/onosproject/net/config/NetworkConfigEvent.java
index e94e0d9..ee1f03c 100644
--- a/core/api/src/main/java/org/onosproject/net/config/NetworkConfigEvent.java
+++ b/core/api/src/main/java/org/onosproject/net/config/NetworkConfigEvent.java
@@ -15,7 +15,7 @@
*/
package org.onosproject.net.config;
-import org.joda.time.LocalDateTime;
+import org.onlab.util.Tools;
import org.onosproject.event.AbstractEvent;
import java.util.Optional;
@@ -141,7 +141,7 @@
@Override
public String toString() {
return toStringHelper(this)
- .add("time", new LocalDateTime(time()))
+ .add("time", Tools.defaultOffsetDataTime(time()))
.add("type", type())
.add("config", config())
.add("prevConfig", prevConfig())
diff --git a/core/api/src/main/java/org/onosproject/net/device/DeviceEvent.java b/core/api/src/main/java/org/onosproject/net/device/DeviceEvent.java
index 7ebb041..16e9d25 100644
--- a/core/api/src/main/java/org/onosproject/net/device/DeviceEvent.java
+++ b/core/api/src/main/java/org/onosproject/net/device/DeviceEvent.java
@@ -15,7 +15,7 @@
*/
package org.onosproject.net.device;
-import org.joda.time.LocalDateTime;
+import org.onlab.util.Tools;
import org.onosproject.event.AbstractEvent;
import org.onosproject.net.Device;
import org.onosproject.net.Port;
@@ -132,7 +132,7 @@
return super.toString();
}
return toStringHelper(this)
- .add("time", new LocalDateTime(time()))
+ .add("time", Tools.defaultOffsetDataTime(time()))
.add("type", type())
.add("subject", subject())
.add("port", port)
diff --git a/core/api/src/main/java/org/onosproject/net/host/HostEvent.java b/core/api/src/main/java/org/onosproject/net/host/HostEvent.java
index 318c3ff..0ed491f 100644
--- a/core/api/src/main/java/org/onosproject/net/host/HostEvent.java
+++ b/core/api/src/main/java/org/onosproject/net/host/HostEvent.java
@@ -15,7 +15,7 @@
*/
package org.onosproject.net.host;
-import org.joda.time.LocalDateTime;
+import org.onlab.util.Tools;
import org.onosproject.event.AbstractEvent;
import org.onosproject.net.Host;
@@ -104,7 +104,7 @@
@Override
public String toString() {
return toStringHelper(this)
- .add("time", new LocalDateTime(time()))
+ .add("time", Tools.defaultOffsetDataTime(time()))
.add("type", type())
.add("subject", subject())
.add("prevSubject", prevSubject())
diff --git a/core/api/src/main/java/org/onosproject/net/intf/InterfaceEvent.java b/core/api/src/main/java/org/onosproject/net/intf/InterfaceEvent.java
index 1e7d9ba..9d26208 100644
--- a/core/api/src/main/java/org/onosproject/net/intf/InterfaceEvent.java
+++ b/core/api/src/main/java/org/onosproject/net/intf/InterfaceEvent.java
@@ -16,7 +16,7 @@
package org.onosproject.net.intf;
-import org.joda.time.LocalDateTime;
+import org.onlab.util.Tools;
import org.onosproject.event.AbstractEvent;
import static com.google.common.base.MoreObjects.toStringHelper;
@@ -106,7 +106,7 @@
return super.toString();
}
return toStringHelper(this)
- .add("time", new LocalDateTime(time()))
+ .add("time", Tools.defaultOffsetDataTime(time()))
.add("type", type())
.add("subject", subject())
.add("prevSubject", prevSubject)
diff --git a/core/api/src/main/java/org/onosproject/store/service/Versioned.java b/core/api/src/main/java/org/onosproject/store/service/Versioned.java
index a3f555e..5033240 100644
--- a/core/api/src/main/java/org/onosproject/store/service/Versioned.java
+++ b/core/api/src/main/java/org/onosproject/store/service/Versioned.java
@@ -18,8 +18,8 @@
import java.util.function.Function;
-import org.joda.time.DateTime;
import org.onlab.util.ByteArraySizeHashPrinter;
+import org.onlab.util.Tools;
import com.google.common.base.MoreObjects;
import com.google.common.base.Objects;
@@ -143,7 +143,7 @@
return MoreObjects.toStringHelper(this)
.add("value", value instanceof byte[] ? new ByteArraySizeHashPrinter((byte[]) value) : value)
.add("version", version)
- .add("creationTime", new DateTime(creationTime))
+ .add("creationTime", Tools.defaultOffsetDataTime(creationTime))
.toString();
}
}
diff --git a/core/api/src/main/java/org/onosproject/store/service/WallClockTimestamp.java b/core/api/src/main/java/org/onosproject/store/service/WallClockTimestamp.java
index 307de2e..78f6b19 100644
--- a/core/api/src/main/java/org/onosproject/store/service/WallClockTimestamp.java
+++ b/core/api/src/main/java/org/onosproject/store/service/WallClockTimestamp.java
@@ -19,7 +19,7 @@
import java.util.Objects;
-import org.joda.time.DateTime;
+import org.onlab.util.Tools;
import org.onosproject.store.Timestamp;
import com.google.common.collect.ComparisonChain;
@@ -69,7 +69,7 @@
@Override
public String toString() {
- return new DateTime(unixTimestamp).toString();
+ return Tools.defaultOffsetDataTime(unixTimestamp).toString();
}
/**
diff --git a/core/api/src/main/java/org/onosproject/ui/table/cell/TimeFormatter.java b/core/api/src/main/java/org/onosproject/ui/table/cell/TimeFormatter.java
index f2dba03..adf8ead 100644
--- a/core/api/src/main/java/org/onosproject/ui/table/cell/TimeFormatter.java
+++ b/core/api/src/main/java/org/onosproject/ui/table/cell/TimeFormatter.java
@@ -16,13 +16,21 @@
package org.onosproject.ui.table.cell;
-import org.joda.time.DateTime;
-import org.joda.time.DateTimeZone;
-import org.joda.time.format.DateTimeFormat;
-import org.joda.time.format.DateTimeFormatter;
+import static java.time.temporal.ChronoField.CLOCK_HOUR_OF_AMPM;
+import static java.time.temporal.ChronoField.MINUTE_OF_HOUR;
+import static java.time.temporal.ChronoField.SECOND_OF_MINUTE;
+
+import java.time.Instant;
+import java.time.ZoneId;
+import java.time.format.DateTimeFormatter;
+import java.time.format.DateTimeFormatterBuilder;
+import java.time.temporal.ChronoField;
+import java.time.temporal.TemporalAccessor;
import java.util.Locale;
+import org.joda.time.DateTimeZone;
+
/**
* Formats time values using {@link DateTimeFormatter}.
*/
@@ -38,7 +46,19 @@
* Constructs a time formatter that uses the default locale and timezone.
*/
public TimeFormatter() {
- dtf = DateTimeFormat.longTime();
+ dtf = new DateTimeFormatterBuilder()
+ .appendValue(CLOCK_HOUR_OF_AMPM)
+ .appendLiteral(':')
+ .appendValue(MINUTE_OF_HOUR, 2)
+ .optionalStart()
+ .appendLiteral(':')
+ .appendValue(SECOND_OF_MINUTE, 2)
+ .appendLiteral(' ')
+ .appendText(ChronoField.AMPM_OF_DAY)
+ .optionalStart()
+ .appendLiteral(' ')
+ .appendOffset("+HH:MM", "+00:00")
+ .toFormatter();
}
/**
@@ -58,14 +78,33 @@
* @param zone time zone to use
* @return self, for chaining
*/
- public TimeFormatter withZone(DateTimeZone zone) {
+ public TimeFormatter withZone(ZoneId zone) {
dtf = dtf.withZone(zone);
return this;
}
+ /**
+ * Sets the time zone to use for formatting the time.
+ *
+ * @param zone time zone to use
+ * @return self, for chaining
+ *
+ * @deprecated in 1.12.0
+ */
+ @Deprecated
+ public TimeFormatter withZone(DateTimeZone zone) {
+ return withZone(zone.toTimeZone().toZoneId());
+ }
+
@Override
protected String nonNullFormat(Object value) {
- return dtf.print((DateTime) value);
+ if (value instanceof TemporalAccessor) {
+ return dtf.format((TemporalAccessor) value);
+ } else if (value instanceof org.joda.time.DateTime) {
+ return dtf.format(Instant.ofEpochMilli(((org.joda.time.DateTime) value).getMillis()));
+ }
+ // should never reach here
+ return String.valueOf(value);
}
}
diff --git a/core/api/src/test/java/org/onosproject/cluster/ClusterServiceAdapter.java b/core/api/src/test/java/org/onosproject/cluster/ClusterServiceAdapter.java
index cc6916f..bc40f67 100644
--- a/core/api/src/test/java/org/onosproject/cluster/ClusterServiceAdapter.java
+++ b/core/api/src/test/java/org/onosproject/cluster/ClusterServiceAdapter.java
@@ -15,9 +15,9 @@
*/
package org.onosproject.cluster;
+import java.time.Instant;
import java.util.Set;
-import org.joda.time.DateTime;
import org.onlab.packet.IpAddress;
import com.google.common.collect.ImmutableSet;
@@ -56,7 +56,7 @@
}
@Override
- public DateTime getLastUpdated(NodeId nodeId) {
+ public Instant getLastUpdatedInstant(NodeId nodeId) {
return null;
}
diff --git a/core/api/src/test/java/org/onosproject/ui/table/cell/TimeFormatterTest.java b/core/api/src/test/java/org/onosproject/ui/table/cell/TimeFormatterTest.java
index 4f73490..7517aac 100644
--- a/core/api/src/test/java/org/onosproject/ui/table/cell/TimeFormatterTest.java
+++ b/core/api/src/test/java/org/onosproject/ui/table/cell/TimeFormatterTest.java
@@ -16,14 +16,15 @@
package org.onosproject.ui.table.cell;
-import org.joda.time.DateTime;
-import org.joda.time.DateTimeZone;
import org.junit.Test;
import org.onosproject.ui.table.CellFormatter;
+import java.time.OffsetDateTime;
+import java.time.ZoneOffset;
import java.util.Locale;
-import static org.junit.Assert.assertTrue;
+import static org.hamcrest.Matchers.isOneOf;
+import static org.junit.Assert.assertThat;
/**
* Unit tests for {@link TimeFormatter}.
@@ -31,9 +32,9 @@
public class TimeFormatterTest {
private static final Locale LOCALE = Locale.ENGLISH;
- private static final DateTimeZone ZONE = DateTimeZone.UTC;
+ private static final ZoneOffset ZONE = ZoneOffset.UTC;
- private static final DateTime TIME = new DateTime(2015, 5, 4, 15, 30, ZONE);
+ private static final OffsetDateTime TIME = OffsetDateTime.of(2015, 5, 4, 15, 30, 0, 0, ZONE);
private static final String EXP_ZONE_NAME = "3:30:00 PM UTC";
private static final String EXP_ZONE_OFFSET = "3:30:00 PM +00:00";
@@ -45,7 +46,6 @@
@Test
public void basic() {
- assertTrue("wrong format", (EXP_ZONE_NAME.equals(fmt.format(TIME)) ||
- EXP_ZONE_OFFSET.equals(fmt.format(TIME))));
+ assertThat(fmt.format(TIME), isOneOf(EXP_ZONE_OFFSET, EXP_ZONE_NAME));
}
}
diff --git a/core/common/BUCK b/core/common/BUCK
index 46d519d..56c6970 100644
--- a/core/common/BUCK
+++ b/core/common/BUCK
@@ -4,7 +4,6 @@
'//lib:METRICS',
'//incubator/api:onos-incubator-api',
'//core/api:onos-api',
- '//lib:joda-time',
]
TEST_DEPS = [
diff --git a/core/common/src/test/java/org/onosproject/store/trivial/SimpleClusterStore.java b/core/common/src/test/java/org/onosproject/store/trivial/SimpleClusterStore.java
index fb50123..4a4fdaf 100644
--- a/core/common/src/test/java/org/onosproject/store/trivial/SimpleClusterStore.java
+++ b/core/common/src/test/java/org/onosproject/store/trivial/SimpleClusterStore.java
@@ -23,7 +23,6 @@
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.ReferenceCardinality;
import org.apache.felix.scr.annotations.Service;
-import org.joda.time.DateTime;
import org.onlab.packet.IpAddress;
import org.onosproject.cluster.ClusterEvent;
import org.onosproject.cluster.ClusterStore;
@@ -41,6 +40,7 @@
import org.onosproject.store.AbstractStore;
import org.slf4j.Logger;
+import java.time.Instant;
import java.util.Set;
import java.util.function.Function;
@@ -64,7 +64,7 @@
private ControllerNode instance;
- private final DateTime creationTime = DateTime.now();
+ private final Instant creationTime = Instant.now();
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected EventDeliveryService eventDispatcher;
@@ -123,7 +123,7 @@
}
@Override
- public DateTime getLastUpdated(NodeId nodeId) {
+ public Instant getLastUpdatedInstant(NodeId nodeId) {
return creationTime;
}
diff --git a/core/common/src/test/java/org/onosproject/store/trivial/SimpleMastershipStore.java b/core/common/src/test/java/org/onosproject/store/trivial/SimpleMastershipStore.java
index e533f23..31480e8 100644
--- a/core/common/src/test/java/org/onosproject/store/trivial/SimpleMastershipStore.java
+++ b/core/common/src/test/java/org/onosproject/store/trivial/SimpleMastershipStore.java
@@ -19,6 +19,7 @@
import static org.onosproject.mastership.MastershipEvent.Type.MASTER_CHANGED;
import static org.slf4j.LoggerFactory.getLogger;
+import java.time.Instant;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
@@ -36,7 +37,6 @@
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.ReferenceCardinality;
import org.apache.felix.scr.annotations.Service;
-import org.joda.time.DateTime;
import org.onlab.packet.IpAddress;
import org.onosproject.cluster.ClusterEventListener;
import org.onosproject.cluster.ClusterService;
@@ -97,7 +97,7 @@
clusterService = new ClusterService() {
- private final DateTime creationTime = DateTime.now();
+ private final Instant creationTime = Instant.now();
@Override
public ControllerNode getLocalNode() {
@@ -135,7 +135,7 @@
}
@Override
- public DateTime getLastUpdated(NodeId nodeId) {
+ public Instant getLastUpdatedInstant(NodeId nodeId) {
return creationTime;
}
diff --git a/core/net/BUCK b/core/net/BUCK
index 26b898d..267c70a 100644
--- a/core/net/BUCK
+++ b/core/net/BUCK
@@ -9,7 +9,6 @@
'//incubator/net:onos-incubator-net',
'//incubator/store:onos-incubator-store',
'//core/store/serializers:onos-core-serializers',
- '//lib:joda-time',
]
TEST_DEPS = [
diff --git a/core/net/src/main/java/org/onosproject/cluster/impl/ClusterManager.java b/core/net/src/main/java/org/onosproject/cluster/impl/ClusterManager.java
index fc3d802..92a3894 100644
--- a/core/net/src/main/java/org/onosproject/cluster/impl/ClusterManager.java
+++ b/core/net/src/main/java/org/onosproject/cluster/impl/ClusterManager.java
@@ -15,6 +15,7 @@
*/
package org.onosproject.cluster.impl;
+import java.time.Instant;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
@@ -31,7 +32,6 @@
import org.apache.felix.scr.annotations.ReferenceCardinality;
import org.apache.felix.scr.annotations.Service;
import org.apache.karaf.system.SystemService;
-import org.joda.time.DateTime;
import org.onlab.packet.IpAddress;
import org.onlab.util.Tools;
import org.onosproject.cluster.ClusterAdminService;
@@ -147,9 +147,9 @@
}
@Override
- public DateTime getLastUpdated(NodeId nodeId) {
+ public Instant getLastUpdatedInstant(NodeId nodeId) {
checkPermission(CLUSTER_READ);
- return store.getLastUpdated(nodeId);
+ return store.getLastUpdatedInstant(nodeId);
}
@Override
diff --git a/core/net/src/main/java/org/onosproject/net/device/impl/DeviceManager.java b/core/net/src/main/java/org/onosproject/net/device/impl/DeviceManager.java
index bbf6d39..eb477be 100644
--- a/core/net/src/main/java/org/onosproject/net/device/impl/DeviceManager.java
+++ b/core/net/src/main/java/org/onosproject/net/device/impl/DeviceManager.java
@@ -25,7 +25,6 @@
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.ReferenceCardinality;
import org.apache.felix.scr.annotations.Service;
-import org.joda.time.DateTime;
import org.onlab.util.KryoNamespace;
import org.onlab.util.Tools;
import org.onosproject.cluster.ClusterService;
@@ -74,6 +73,7 @@
import org.onosproject.store.service.Serializer;
import org.slf4j.Logger;
+import java.time.Instant;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
@@ -180,9 +180,9 @@
*/
private class LocalStatus {
boolean connected;
- DateTime dateTime;
+ Instant dateTime;
- public LocalStatus(boolean b, DateTime now) {
+ public LocalStatus(boolean b, Instant now) {
connected = b;
dateTime = now;
}
@@ -333,7 +333,7 @@
if (ls == null) {
return "No Record";
}
- String timeAgo = Tools.timeAgo(ls.dateTime.getMillis());
+ String timeAgo = Tools.timeAgo(ls.dateTime.toEpochMilli());
return (ls.connected) ? "connected " + timeAgo : "disconnected " + timeAgo;
}
@@ -508,7 +508,7 @@
checkNotNull(deviceDescription, DEVICE_DESCRIPTION_NULL);
checkValidity();
- deviceLocalStatus.put(deviceId, new LocalStatus(true, DateTime.now()));
+ deviceLocalStatus.put(deviceId, new LocalStatus(true, Instant.now()));
BasicDeviceConfig cfg = networkConfigService.getConfig(deviceId, BasicDeviceConfig.class);
if (!isAllowed(cfg)) {
@@ -564,7 +564,7 @@
public void deviceDisconnected(DeviceId deviceId) {
checkNotNull(deviceId, DEVICE_ID_NULL);
checkValidity();
- deviceLocalStatus.put(deviceId, new LocalStatus(false, DateTime.now()));
+ deviceLocalStatus.put(deviceId, new LocalStatus(false, Instant.now()));
log.info("Device {} disconnected from this node", deviceId);
List<PortDescription> descs = store.getPortDescriptions(provider().id(), deviceId)
diff --git a/core/store/dist/BUCK b/core/store/dist/BUCK
index 3483f64..b6be5ec 100644
--- a/core/store/dist/BUCK
+++ b/core/store/dist/BUCK
@@ -14,7 +14,6 @@
'//lib:netty-resolver',
'//lib:commons-math3',
'//incubator/api:onos-incubator-api',
- '//lib:joda-time',
]
TEST_DEPS = [
diff --git a/core/store/dist/src/main/java/org/onosproject/store/cluster/impl/DistributedClusterStore.java b/core/store/dist/src/main/java/org/onosproject/store/cluster/impl/DistributedClusterStore.java
index 34b2f0b..b106763 100644
--- a/core/store/dist/src/main/java/org/onosproject/store/cluster/impl/DistributedClusterStore.java
+++ b/core/store/dist/src/main/java/org/onosproject/store/cluster/impl/DistributedClusterStore.java
@@ -27,7 +27,6 @@
import org.apache.felix.scr.annotations.ReferenceCardinality;
import org.apache.felix.scr.annotations.ReferencePolicy;
import org.apache.felix.scr.annotations.Service;
-import org.joda.time.DateTime;
import org.onlab.packet.IpAddress;
import org.onlab.util.KryoNamespace;
import org.onosproject.cfg.ConfigProperty;
@@ -50,6 +49,7 @@
import org.osgi.service.component.ComponentContext;
import org.slf4j.Logger;
+import java.time.Instant;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
@@ -106,7 +106,7 @@
private final Map<NodeId, ControllerNode> allNodes = Maps.newConcurrentMap();
private final Map<NodeId, State> nodeStates = Maps.newConcurrentMap();
private final Map<NodeId, Version> nodeVersions = Maps.newConcurrentMap();
- private final Map<NodeId, DateTime> nodeLastUpdatedTimes = Maps.newConcurrentMap();
+ private final Map<NodeId, Instant> nodeLastUpdatedTimes = Maps.newConcurrentMap();
private ScheduledExecutorService heartBeatSender = Executors.newSingleThreadScheduledExecutor(
groupedThreads("onos/cluster/membership", "heartbeat-sender", log));
@@ -273,7 +273,7 @@
if (newVersion != null) {
nodeVersions.put(nodeId, newVersion);
}
- nodeLastUpdatedTimes.put(nodeId, DateTime.now());
+ nodeLastUpdatedTimes.put(nodeId, Instant.now());
notifyChange(nodeId, currentState, newState, currentVersion, newVersion);
}
}
@@ -357,7 +357,7 @@
}
@Override
- public DateTime getLastUpdated(NodeId nodeId) {
+ public Instant getLastUpdatedInstant(NodeId nodeId) {
return nodeLastUpdatedTimes.get(nodeId);
}
diff --git a/incubator/store/BUCK b/incubator/store/BUCK
index 84c5d47..e3fa120 100644
--- a/incubator/store/BUCK
+++ b/incubator/store/BUCK
@@ -5,7 +5,6 @@
'//incubator/api:onos-incubator-api',
'//core/store/dist:onos-core-dist',
'//core/store/serializers:onos-core-serializers',
- '//lib:joda-time',
]
TEST_DEPS = [
diff --git a/incubator/store/src/main/java/org/onosproject/incubator/store/virtual/impl/SimpleVirtualMastershipStore.java b/incubator/store/src/main/java/org/onosproject/incubator/store/virtual/impl/SimpleVirtualMastershipStore.java
index df52547..730ebee 100644
--- a/incubator/store/src/main/java/org/onosproject/incubator/store/virtual/impl/SimpleVirtualMastershipStore.java
+++ b/incubator/store/src/main/java/org/onosproject/incubator/store/virtual/impl/SimpleVirtualMastershipStore.java
@@ -24,7 +24,6 @@
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.ReferenceCardinality;
import org.apache.felix.scr.annotations.Service;
-import org.joda.time.DateTime;
import org.onlab.packet.IpAddress;
import org.onosproject.cluster.ClusterEventListener;
import org.onosproject.cluster.ClusterService;
@@ -43,6 +42,7 @@
import org.onosproject.net.MastershipRole;
import org.slf4j.Logger;
+import java.time.Instant;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
@@ -454,7 +454,7 @@
ClusterService faceClusterService = new ClusterService() {
- private final DateTime creationTime = DateTime.now();
+ private final Instant creationTime = Instant.now();
@Override
public ControllerNode getLocalNode() {
@@ -492,7 +492,7 @@
}
@Override
- public DateTime getLastUpdated(NodeId nodeId) {
+ public Instant getLastUpdatedInstant(NodeId nodeId) {
return creationTime;
}
diff --git a/lib/pom.xml b/lib/pom.xml
index 5e5f11e..4a9d96e 100644
--- a/lib/pom.xml
+++ b/lib/pom.xml
@@ -421,12 +421,6 @@
</dependency>
<dependency>
- <groupId>joda-time</groupId>
- <artifactId>joda-time</artifactId>
- <version>2.9.3</version>
- </dependency>
-
- <dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
<version>3.0.1</version>
@@ -473,11 +467,6 @@
<!-- COMPILE -->
<dependency>
- <groupId>joda-time</groupId>
- <artifactId>joda-time</artifactId>
- </dependency>
-
- <dependency>
<groupId>commons-configuration</groupId>
<artifactId>commons-configuration</artifactId>
</dependency>
diff --git a/providers/netconf/alarm/BUCK b/providers/netconf/alarm/BUCK
index 292fe14..761f2ed 100644
--- a/providers/netconf/alarm/BUCK
+++ b/providers/netconf/alarm/BUCK
@@ -3,7 +3,6 @@
'//incubator/api:onos-incubator-api',
'//protocols/netconf/api:onos-protocols-netconf-api',
'//protocols/netconf/ctl:onos-protocols-netconf-ctl',
- '//lib:joda-time',
]
osgi_jar_with_tests (
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 b39a772..4636704 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
@@ -38,10 +38,11 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.StringWriter;
+import java.time.Instant;
+import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Collection;
-import org.joda.time.format.ISODateTimeFormat;
import org.xml.sax.SAXException;
import static org.slf4j.LoggerFactory.getLogger;
@@ -96,7 +97,7 @@
private long parseDate(String timeStr)
throws UnsupportedOperationException, IllegalArgumentException {
- return ISODateTimeFormat.dateTime().parseMillis(timeStr);
+ return DateTimeFormatter.ISO_DATE_TIME.parse(timeStr, Instant::from).getEpochSecond();
}
private static String nodeToString(Node rootNode) throws TransformerException {
diff --git a/utils/misc/src/main/java/org/onlab/util/Tools.java b/utils/misc/src/main/java/org/onlab/util/Tools.java
index a678f6a..057441e 100644
--- a/utils/misc/src/main/java/org/onlab/util/Tools.java
+++ b/utils/misc/src/main/java/org/onlab/util/Tools.java
@@ -32,6 +32,9 @@
import java.nio.file.SimpleFileVisitor;
import java.nio.file.StandardCopyOption;
import java.nio.file.attribute.BasicFileAttributes;
+import java.time.Instant;
+import java.time.OffsetDateTime;
+import java.time.ZoneId;
import java.util.Arrays;
import java.util.Collection;
import java.util.Dictionary;
@@ -676,7 +679,7 @@
return future;
}
- BlockingAwareFuture<T> newFuture = new BlockingAwareFuture<T>();
+ BlockingAwareFuture<T> newFuture = new BlockingAwareFuture<>();
future.whenComplete((result, error) -> {
Runnable completer = () -> {
if (future.isCompletedExceptionally()) {
@@ -827,4 +830,16 @@
}
}
+ /**
+ * Creates OffsetDateTime instance from epoch milliseconds,
+ * using system default time zone.
+ *
+ * @param epochMillis to convert
+ * @return OffsetDateTime
+ */
+ public static OffsetDateTime defaultOffsetDataTime(long epochMillis) {
+ return OffsetDateTime.ofInstant(Instant.ofEpochMilli(epochMillis),
+ ZoneId.systemDefault());
+ }
+
}
diff --git a/web/gui/BUCK b/web/gui/BUCK
index 2354dfe..b295c7f 100644
--- a/web/gui/BUCK
+++ b/web/gui/BUCK
@@ -17,7 +17,6 @@
'//utils/rest:onlab-rest',
'//core/store/serializers:onos-core-serializers',
':onos-tools-gui',
- '//lib:joda-time',
]
TEST_DEPS = [
diff --git a/web/gui/src/main/java/org/onosproject/ui/impl/ClusterViewMessageHandler.java b/web/gui/src/main/java/org/onosproject/ui/impl/ClusterViewMessageHandler.java
index c9ec72c..980d7f6 100644
--- a/web/gui/src/main/java/org/onosproject/ui/impl/ClusterViewMessageHandler.java
+++ b/web/gui/src/main/java/org/onosproject/ui/impl/ClusterViewMessageHandler.java
@@ -19,7 +19,6 @@
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.google.common.collect.ImmutableSet;
-import org.joda.time.DateTime;
import org.onosproject.cluster.ClusterService;
import org.onosproject.cluster.ControllerNode;
import org.onosproject.cluster.NodeId;
@@ -32,6 +31,7 @@
import org.onosproject.ui.table.TableRequestHandler;
import org.onosproject.ui.table.cell.TimeFormatter;
+import java.time.Instant;
import java.util.Collection;
import java.util.List;
import java.util.stream.Collectors;
@@ -120,7 +120,7 @@
private void populateRow(TableModel.Row row, ControllerNode node,
ClusterService cs) {
NodeId id = node.id();
- DateTime lastUpdated = cs.getLastUpdated(id);
+ Instant lastUpdated = cs.getLastUpdatedInstant(id);
ControllerNode.State state = cs.getState(id);
String iconId = state.isActive() ? ICON_ID_ONLINE : ICON_ID_OFFLINE;
String startedId = state.isReady() ? ICON_ID_ONLINE : ICON_ID_OFFLINE;