Deprecate joda-time

- ref:
  http://blog.joda.org/2014/11/converting-from-joda-time-to-javatime.html

Change-Id: I1115e8053f601e78cb933ccbfa664ff8787d2da1
This commit is contained in:
Yuta HIGUCHI 2017-08-18 23:16:35 -07:00 committed by Andrea Campanella
parent 69bf4ddc27
commit 0c47d5386e
53 changed files with 216 additions and 140 deletions

View File

@ -3,7 +3,6 @@ COMPILE_DEPS = [
'//lib:JACKSON', '//lib:JACKSON',
'//lib:METRICS', '//lib:METRICS',
'//lib:KRYO', '//lib:KRYO',
'//lib:joda-time',
'//lib:org.apache.karaf.shell.console', '//lib:org.apache.karaf.shell.console',
'//lib:javax.ws.rs-api', '//lib:javax.ws.rs-api',
'//lib:rrd4j', '//lib:rrd4j',

View File

@ -23,7 +23,6 @@ import com.google.common.collect.Maps;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
import org.apache.commons.lang.ArrayUtils; import org.apache.commons.lang.ArrayUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.joda.time.LocalDateTime;
import org.onosproject.cluster.ClusterService; import org.onosproject.cluster.ClusterService;
import org.onosproject.cluster.NodeId; import org.onosproject.cluster.NodeId;
import org.onosproject.cpman.ControlLoadSnapshot; import org.onosproject.cpman.ControlLoadSnapshot;
@ -36,6 +35,9 @@ import org.onosproject.ui.UiMessageHandler;
import org.onosproject.ui.chart.ChartModel; import org.onosproject.ui.chart.ChartModel;
import org.onosproject.ui.chart.ChartRequestHandler; 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.Collection;
import java.util.Map; import java.util.Map;
import java.util.Optional; import java.util.Optional;
@ -63,7 +65,7 @@ public class CpmanViewMessageHandler extends UiMessageHandler {
private static final int MILLI_CONV_UNIT = 1000; 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; private long timestamp = 0L;
@ -98,7 +100,7 @@ public class CpmanViewMessageHandler extends UiMessageHandler {
DeviceId deviceId = DeviceId.deviceId(uri); DeviceId deviceId = DeviceId.deviceId(uri);
if (cpms.availableResourcesSync(localNodeId, CONTROL_MESSAGE).contains(deviceId.toString())) { if (cpms.availableResourcesSync(localNodeId, CONTROL_MESSAGE).contains(deviceId.toString())) {
Map<ControlMetricType, Long[]> data = generateMatrix(cpms, cs, deviceId); 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); populateMetrics(cm, data, ldt, NUM_OF_DATA_POINTS);
@ -167,6 +169,7 @@ public class CpmanViewMessageHandler extends UiMessageHandler {
} }
} }
// FIXME using local time in timestamps likely to be sign of problem
private void populateMetrics(ChartModel cm, private void populateMetrics(ChartModel cm,
Map<ControlMetricType, Long[]> data, Map<ControlMetricType, Long[]> data,
LocalDateTime time, int numOfDp) { LocalDateTime time, int numOfDp) {
@ -176,7 +179,7 @@ public class CpmanViewMessageHandler extends UiMessageHandler {
local.put(StringUtils.lowerCase(cmt.name()), data.get(cmt)[i]); 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); local.put(LABEL, calculated);
populateMetric(cm.addDataPoint(calculated), local); populateMetric(cm.addDataPoint(calculated), local);

View File

@ -3,7 +3,6 @@ COMPILE_DEPS = [
'//lib:JACKSON', '//lib:JACKSON',
'//lib:org.apache.karaf.shell.console', '//lib:org.apache.karaf.shell.console',
'//cli:onos-cli', '//cli:onos-cli',
'//lib:joda-time',
] ]
osgi_jar_with_tests ( osgi_jar_with_tests (

View File

@ -24,7 +24,7 @@ import java.util.stream.Stream;
import org.apache.karaf.shell.commands.Command; import org.apache.karaf.shell.commands.Command;
import org.apache.karaf.shell.commands.Option; 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.cli.AbstractShellCommand;
import org.onosproject.cluster.ClusterEvent; import org.onosproject.cluster.ClusterEvent;
import org.onosproject.event.Event; import org.onosproject.event.Event;
@ -187,7 +187,7 @@ public class EventsCommand
if (event.type().toString().startsWith("PORT")) { if (event.type().toString().startsWith("PORT")) {
// Port event // Port event
print("%s %s\t%s/%s [%s]", print("%s %s\t%s/%s [%s]",
new LocalDateTime(event.time()), Tools.defaultOffsetDataTime(event.time()),
event.type(), event.type(),
deviceEvent.subject().id(), deviceEvent.port().number(), deviceEvent.subject().id(), deviceEvent.port().number(),
deviceEvent.port() deviceEvent.port()
@ -195,7 +195,7 @@ public class EventsCommand
} else { } else {
// Device event // Device event
print("%s %s\t%s [%s]", print("%s %s\t%s [%s]",
new LocalDateTime(event.time()), Tools.defaultOffsetDataTime(event.time()),
event.type(), event.type(),
deviceEvent.subject().id(), deviceEvent.subject().id(),
deviceEvent.subject() deviceEvent.subject()
@ -204,7 +204,7 @@ public class EventsCommand
} else if (event instanceof MastershipEvent) { } else if (event instanceof MastershipEvent) {
print("%s %s\t%s [%s]", print("%s %s\t%s [%s]",
new LocalDateTime(event.time()), Tools.defaultOffsetDataTime(event.time()),
event.type(), event.type(),
event.subject(), event.subject(),
((MastershipEvent) event).roleInfo()); ((MastershipEvent) event).roleInfo());
@ -213,7 +213,7 @@ public class EventsCommand
LinkEvent linkEvent = (LinkEvent) event; LinkEvent linkEvent = (LinkEvent) event;
Link link = linkEvent.subject(); Link link = linkEvent.subject();
print("%s %s\t%s/%s-%s/%s [%s]", print("%s %s\t%s/%s-%s/%s [%s]",
new LocalDateTime(event.time()), Tools.defaultOffsetDataTime(event.time()),
event.type(), event.type(),
link.src().deviceId(), link.src().port(), link.dst().deviceId(), link.dst().port(), link.src().deviceId(), link.src().port(), link.dst().deviceId(), link.dst().port(),
link); link);
@ -221,7 +221,7 @@ public class EventsCommand
} else if (event instanceof HostEvent) { } else if (event instanceof HostEvent) {
HostEvent hostEvent = (HostEvent) event; HostEvent hostEvent = (HostEvent) event;
print("%s %s\t%s [%s->%s]", print("%s %s\t%s [%s->%s]",
new LocalDateTime(event.time()), Tools.defaultOffsetDataTime(event.time()),
event.type(), event.type(),
hostEvent.subject().id(), hostEvent.subject().id(),
hostEvent.prevSubject(), hostEvent.subject()); hostEvent.prevSubject(), hostEvent.subject());
@ -236,14 +236,14 @@ public class EventsCommand
topo.linkCount(), topo.linkCount(),
topo.clusterCount()); topo.clusterCount());
print("%s %s%s [%s]", print("%s %s%s [%s]",
new LocalDateTime(event.time()), Tools.defaultOffsetDataTime(event.time()),
event.type(), event.type(),
summary, summary,
reasons.stream().map(e -> e.type()).collect(toList())); reasons.stream().map(e -> e.type()).collect(toList()));
} else if (event instanceof ClusterEvent) { } else if (event instanceof ClusterEvent) {
print("%s %s\t%s [%s]", print("%s %s\t%s [%s]",
new LocalDateTime(event.time()), Tools.defaultOffsetDataTime(event.time()),
event.type(), event.type(),
((ClusterEvent) event).subject().id(), ((ClusterEvent) event).subject().id(),
event.subject()); event.subject());
@ -251,7 +251,7 @@ public class EventsCommand
} else { } else {
// Unknown Event? // Unknown Event?
print("%s %s\t%s [%s]", print("%s %s\t%s [%s]",
new LocalDateTime(event.time()), Tools.defaultOffsetDataTime(event.time()),
event.type(), event.type(),
event.subject(), event.subject(),
event); event);

View File

@ -1,6 +1,5 @@
COMPILE_DEPS = [ COMPILE_DEPS = [
'//lib:CORE_DEPS', '//lib:CORE_DEPS',
'//lib:joda-time',
] ]
TEST_DEPS = [ TEST_DEPS = [

View File

@ -20,7 +20,7 @@ import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.Objects; import java.util.Objects;
import org.joda.time.LocalDateTime; import org.onlab.util.Tools;
import org.onosproject.event.AbstractEvent; import org.onosproject.event.AbstractEvent;
import static com.google.common.base.MoreObjects.toStringHelper; import static com.google.common.base.MoreObjects.toStringHelper;
@ -185,7 +185,7 @@ public class EvpnRouteEvent extends AbstractEvent<EvpnRouteEvent.Type,
@Override @Override
public String toString() { public String toString() {
return toStringHelper(this) return toStringHelper(this)
.add("time", new LocalDateTime(time())) .add("time", Tools.defaultOffsetDataTime(time()))
.add("type", type()) .add("type", type())
.add("subject", subject()) .add("subject", subject())
.add("prevSubject", prevSubject) .add("prevSubject", prevSubject)

View File

@ -4,7 +4,6 @@ COMPILE_DEPS = [
'//lib:org.apache.karaf.shell.console', '//lib:org.apache.karaf.shell.console',
'//incubator/api:onos-incubator-api', '//incubator/api:onos-incubator-api',
'//cli:onos-cli', '//cli:onos-cli',
'//lib:joda-time',
] ]
osgi_jar_with_tests ( osgi_jar_with_tests (

View File

@ -18,7 +18,6 @@ package org.onosproject.faultmanagement.alarms.gui;
import com.fasterxml.jackson.databind.node.ObjectNode; import com.fasterxml.jackson.databind.node.ObjectNode;
import com.google.common.base.Strings; import com.google.common.base.Strings;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import org.joda.time.DateTime;
import org.onosproject.incubator.net.faultmanagement.alarm.Alarm; import org.onosproject.incubator.net.faultmanagement.alarm.Alarm;
import org.onosproject.net.DeviceId; import org.onosproject.net.DeviceId;
import org.onosproject.ui.RequestHandler; import org.onosproject.ui.RequestHandler;
@ -29,6 +28,7 @@ import org.onosproject.ui.table.cell.TimeFormatter;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.time.Instant;
import java.util.Collection; import java.util.Collection;
import java.util.Set; import java.util.Set;
@ -126,7 +126,7 @@ public class AlarmTableMessageHandler extends UiMessageHandler {
.cell(DEVICE_ID_STR, alarm.deviceId()) .cell(DEVICE_ID_STR, alarm.deviceId())
.cell(DESCRIPTION, alarm.description()) .cell(DESCRIPTION, alarm.description())
.cell(SOURCE, alarm.source()) .cell(SOURCE, alarm.source())
.cell(TIME_RAISED, new DateTime(alarm.timeRaised())) .cell(TIME_RAISED, Instant.ofEpochMilli(alarm.timeRaised()))
.cell(SEVERITY, alarm.severity()); .cell(SEVERITY, alarm.severity());
} }
} }
@ -177,6 +177,6 @@ public class AlarmTableMessageHandler extends UiMessageHandler {
if (msSinceStartOfEpoch == null) { if (msSinceStartOfEpoch == null) {
return "-"; return "-";
} }
return new TimeFormatter().format(new DateTime(msSinceStartOfEpoch)); return new TimeFormatter().format(Instant.ofEpochMilli(msSinceStartOfEpoch));
} }
} }

View File

@ -10,7 +10,6 @@ COMPILE_DEPS = [
'//lib:okio', '//lib:okio',
'//lib:gson', '//lib:gson',
'//cli:onos-cli', '//cli:onos-cli',
'//lib:joda-time',
] ]
EXCLUDED_BUNDLES = [ EXCLUDED_BUNDLES = [

View File

@ -15,22 +15,20 @@
*/ */
package org.onosproject.influxdbmetrics; 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 static com.google.common.base.Preconditions.checkNotNull;
import java.time.Instant;
import java.time.format.DateTimeFormatter;
/** /**
* Default implementation of influx metric. * Default implementation of influx metric.
*/ */
public final class DefaultInfluxMetric implements InfluxMetric { public final class DefaultInfluxMetric implements InfluxMetric {
private double oneMinRate; 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.oneMinRate = oneMinRate;
this.time = time; this.time = time;
} }
@ -41,7 +39,7 @@ public final class DefaultInfluxMetric implements InfluxMetric {
} }
@Override @Override
public DateTime time() { public Instant time() {
return time; return time;
} }
@ -75,10 +73,8 @@ public final class DefaultInfluxMetric implements InfluxMetric {
return new DefaultInfluxMetric(oneMinRate, parseTime(timestamp)); return new DefaultInfluxMetric(oneMinRate, parseTime(timestamp));
} }
private DateTime parseTime(String time) { private Instant parseTime(String time) {
String reformatTime = StringUtils.replace(StringUtils.replace(time, "T", " "), "Z", ""); return DateTimeFormatter.ISO_DATE_TIME.parse(time, Instant::from);
DateTimeFormatter formatter = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss");
return formatter.parseDateTime(reformatTime);
} }
} }
} }

View File

@ -15,7 +15,7 @@
*/ */
package org.onosproject.influxdbmetrics; package org.onosproject.influxdbmetrics;
import org.joda.time.DateTime; import java.time.Instant;
/** /**
* Metric that represents all values queried from influx database. * Metric that represents all values queried from influx database.
@ -35,7 +35,7 @@ public interface InfluxMetric {
* *
* @return collected timestamp of the given metric * @return collected timestamp of the given metric
*/ */
DateTime time(); Instant time();
/** /**
* A builder of InfluxMetric. * A builder of InfluxMetric.

View File

@ -1,6 +1,5 @@
COMPILE_DEPS = [ COMPILE_DEPS = [
'//lib:CORE_DEPS', '//lib:CORE_DEPS',
'//lib:joda-time',
] ]
osgi_jar_with_tests ( osgi_jar_with_tests (

View File

@ -15,7 +15,7 @@
*/ */
package org.onosproject.iptopology.api.device; package org.onosproject.iptopology.api.device;
import org.joda.time.LocalDateTime; import org.onlab.util.Tools;
import org.onosproject.event.AbstractEvent; import org.onosproject.event.AbstractEvent;
import org.onosproject.iptopology.api.DeviceIntf; import org.onosproject.iptopology.api.DeviceIntf;
import org.onosproject.iptopology.api.DevicePrefix; import org.onosproject.iptopology.api.DevicePrefix;
@ -173,7 +173,7 @@ public class IpDeviceEvent extends AbstractEvent<IpDeviceEvent.Type, IpDevice> {
return super.toString(); return super.toString();
} }
return toStringHelper(this) return toStringHelper(this)
.add("time", new LocalDateTime(time())) .add("time", Tools.defaultOffsetDataTime(time()))
.add("type", type()) .add("type", type())
.add("subject", subject()) .add("subject", subject())
.add("interface", devInterface) .add("interface", devInterface)

View File

@ -9,7 +9,6 @@ COMPILE_DEPS = [
'//cli:onos-cli', '//cli:onos-cli',
'//apps/openstacknode/api:onos-apps-openstacknode-api', '//apps/openstacknode/api:onos-apps-openstacknode-api',
'//lib:openstack4j-core', '//lib:openstack4j-core',
'//lib:joda-time',
] ]
TEST_DEPS = [ TEST_DEPS = [

View File

@ -15,7 +15,7 @@
*/ */
package org.onosproject.openstacknetworking.api; package org.onosproject.openstacknetworking.api;
import org.joda.time.LocalDateTime; import org.onlab.util.Tools;
import org.onosproject.event.AbstractEvent; import org.onosproject.event.AbstractEvent;
import org.openstack4j.model.network.Network; import org.openstack4j.model.network.Network;
import org.openstack4j.model.network.Port; import org.openstack4j.model.network.Port;
@ -178,7 +178,7 @@ public class OpenstackNetworkEvent extends AbstractEvent<OpenstackNetworkEvent.T
return super.toString(); return super.toString();
} }
return toStringHelper(this) return toStringHelper(this)
.add("time", new LocalDateTime(time())) .add("time", Tools.defaultOffsetDataTime(time()))
.add("type", type()) .add("type", type())
.add("network", subject()) .add("network", subject())
.add("port", port) .add("port", port)

View File

@ -15,7 +15,7 @@
*/ */
package org.onosproject.openstacknetworking.api; package org.onosproject.openstacknetworking.api;
import org.joda.time.LocalDateTime; import org.onlab.util.Tools;
import org.onosproject.event.AbstractEvent; import org.onosproject.event.AbstractEvent;
import org.openstack4j.model.network.ExternalGateway; import org.openstack4j.model.network.ExternalGateway;
import org.openstack4j.model.network.NetFloatingIP; import org.openstack4j.model.network.NetFloatingIP;
@ -228,7 +228,7 @@ public class OpenstackRouterEvent extends AbstractEvent<OpenstackRouterEvent.Typ
return super.toString(); return super.toString();
} }
return toStringHelper(this) return toStringHelper(this)
.add("time", new LocalDateTime(time())) .add("time", Tools.defaultOffsetDataTime(time()))
.add("type", type()) .add("type", type())
.add("router", subject()) .add("router", subject())
.add("externalGateway", exGateway) .add("externalGateway", exGateway)

View File

@ -1,7 +1,6 @@
COMPILE_DEPS = [ COMPILE_DEPS = [
'//lib:CORE_DEPS', '//lib:CORE_DEPS',
'//lib:JACKSON', '//lib:JACKSON',
'//lib:joda-time',
] ]
TEST_DEPS = [ TEST_DEPS = [

View File

@ -16,7 +16,7 @@
package org.onosproject.routeservice; package org.onosproject.routeservice;
import org.joda.time.LocalDateTime; import org.onlab.util.Tools;
import org.onosproject.event.AbstractEvent; import org.onosproject.event.AbstractEvent;
import java.util.Collection; import java.util.Collection;
@ -210,7 +210,7 @@ public class RouteEvent extends AbstractEvent<RouteEvent.Type, ResolvedRoute> {
@Override @Override
public String toString() { public String toString() {
return toStringHelper(this) return toStringHelper(this)
.add("time", new LocalDateTime(time())) .add("time", Tools.defaultOffsetDataTime(time()))
.add("type", type()) .add("type", type())
.add("subject", subject()) .add("subject", subject())
.add("prevSubject", prevSubject) .add("prevSubject", prevSubject)

View File

@ -9,7 +9,6 @@ COMPILE_DEPS = [
'//incubator/api:onos-incubator-api', '//incubator/api:onos-incubator-api',
'//utils/rest:onlab-rest', '//utils/rest:onlab-rest',
'//apps/route-service/api:onos-apps-route-service-api', '//apps/route-service/api:onos-apps-route-service-api',
'//lib:joda-time',
] ]
BUNDLES = [ BUNDLES = [

View File

@ -23,7 +23,6 @@ import com.google.common.collect.Lists;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
import org.joda.time.DateTime;
import org.onlab.packet.Ip4Address; import org.onlab.packet.Ip4Address;
import org.onlab.packet.Ip6Address; import org.onlab.packet.Ip6Address;
import org.onlab.packet.IpPrefix; import org.onlab.packet.IpPrefix;
@ -41,6 +40,7 @@ import org.onosproject.segmentrouting.grouphandler.DefaultGroupHandler;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.time.Instant;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
@ -79,7 +79,7 @@ public class DefaultRoutingHandler {
private volatile Status populationStatus; private volatile Status populationStatus;
private ScheduledExecutorService executorService private ScheduledExecutorService executorService
= newScheduledThreadPool(1, groupedThreads("retryftr", "retry-%d", log)); = newScheduledThreadPool(1, groupedThreads("retryftr", "retry-%d", log));
private DateTime lastRoutingChange; private Instant lastRoutingChange;
/** /**
* Represents the default routing population status. * Represents the default routing population status.
@ -150,8 +150,8 @@ public class DefaultRoutingHandler {
* @return true if stable * @return true if stable
*/ */
public boolean isRoutingStable() { public boolean isRoutingStable() {
long last = (long) (lastRoutingChange.getMillis() / 1000.0); long last = (long) (lastRoutingChange.toEpochMilli() / 1000.0);
long now = (long) (DateTime.now().getMillis() / 1000.0); long now = (long) (Instant.now().toEpochMilli() / 1000.0);
log.trace("Routing stable since {}s", now - last); log.trace("Routing stable since {}s", now - last);
return (now - last) > STABLITY_THRESHOLD; return (now - last) > STABLITY_THRESHOLD;
} }
@ -173,7 +173,7 @@ public class DefaultRoutingHandler {
* startup or after a configuration event. * startup or after a configuration event.
*/ */
public void populateAllRoutingRules() { public void populateAllRoutingRules() {
lastRoutingChange = DateTime.now(); lastRoutingChange = Instant.now();
statusLock.lock(); statusLock.lock();
try { try {
if (populationStatus == Status.STARTED) { if (populationStatus == Status.STARTED) {
@ -249,7 +249,7 @@ public class DefaultRoutingHandler {
return; return;
} }
lastRoutingChange = DateTime.now(); lastRoutingChange = Instant.now();
statusLock.lock(); statusLock.lock();
try { try {
if (populationStatus == Status.STARTED) { if (populationStatus == Status.STARTED) {
@ -374,7 +374,7 @@ public class DefaultRoutingHandler {
log.warn("Only one event can be handled for link status change .. aborting"); log.warn("Only one event can be handled for link status change .. aborting");
return; return;
} }
lastRoutingChange = DateTime.now(); lastRoutingChange = Instant.now();
executorService.schedule(new UpdateMaps(), UPDATE_INTERVAL, executorService.schedule(new UpdateMaps(), UPDATE_INTERVAL,
TimeUnit.SECONDS); TimeUnit.SECONDS);
statusLock.lock(); statusLock.lock();

View File

@ -7,7 +7,6 @@ COMPILE_DEPS = [
'//incubator/net:onos-incubator-net', '//incubator/net:onos-incubator-net',
'//utils/rest:onlab-rest', '//utils/rest:onlab-rest',
'//core/common:onos-core-common', '//core/common:onos-core-common',
'//lib:joda-time',
] ]
osgi_jar ( osgi_jar (

View File

@ -31,8 +31,8 @@ import com.google.common.collect.Ordering;
import com.google.common.collect.TreeMultimap; import com.google.common.collect.TreeMultimap;
import org.apache.karaf.shell.commands.Argument; import org.apache.karaf.shell.commands.Argument;
import org.apache.karaf.shell.commands.Command; import org.apache.karaf.shell.commands.Command;
import org.joda.time.LocalDateTime;
import org.onlab.metrics.MetricsService; import org.onlab.metrics.MetricsService;
import org.onlab.util.Tools;
import java.util.Comparator; import java.util.Comparator;
import java.util.Map; import java.util.Map;
@ -108,7 +108,7 @@ public class MetricsListCommand extends AbstractShellCommand {
Gauge gauge = (Gauge) metric; Gauge gauge = (Gauge) metric;
final Object value = gauge.getValue(); final Object value = gauge.getValue();
if (name.endsWith("EpochMs") && value instanceof Long) { 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 { } else {
print(" value = %s", value); print(" value = %s", value);
} }
@ -233,4 +233,6 @@ public class MetricsListCommand extends AbstractShellCommand {
private double nanoToMs(double nano) { private double nanoToMs(double nano) {
return nano / 1_000_000D; return nano / 1_000_000D;
} }
} }

View File

@ -20,13 +20,13 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.ObjectNode; import com.fasterxml.jackson.databind.node.ObjectNode;
import org.apache.karaf.shell.commands.Command; import org.apache.karaf.shell.commands.Command;
import org.joda.time.DateTime;
import org.onlab.util.Tools; import org.onlab.util.Tools;
import org.onosproject.cluster.ClusterAdminService; import org.onosproject.cluster.ClusterAdminService;
import org.onosproject.cluster.ControllerNode; import org.onosproject.cluster.ControllerNode;
import org.onosproject.core.Version; import org.onosproject.core.Version;
import org.onosproject.utils.Comparators; import org.onosproject.utils.Comparators;
import java.time.Instant;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
@ -51,10 +51,10 @@ public class NodesListCommand extends AbstractShellCommand {
} else { } else {
ControllerNode self = service.getLocalNode(); ControllerNode self = service.getLocalNode();
for (ControllerNode node : nodes) { for (ControllerNode node : nodes) {
DateTime lastUpdated = service.getLastUpdated(node.id()); Instant lastUpdated = service.getLastUpdatedInstant(node.id());
String timeAgo = "Never"; String timeAgo = "Never";
if (lastUpdated != null) { if (lastUpdated != null) {
timeAgo = Tools.timeAgo(lastUpdated.getMillis()); timeAgo = Tools.timeAgo(lastUpdated.getEpochSecond());
} }
Version version = service.getVersion(node.id()); Version version = service.getVersion(node.id());
print(FMT, node.id(), node.ip(), node.tcpPort(), print(FMT, node.id(), node.ip(), node.tcpPort(),

View File

@ -34,6 +34,7 @@
<dependency> <dependency>
<groupId>joda-time</groupId> <groupId>joda-time</groupId>
<artifactId>joda-time</artifactId> <artifactId>joda-time</artifactId>
<version>2.9.3</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>commons-configuration</groupId> <groupId>commons-configuration</groupId>

View File

@ -15,6 +15,8 @@
*/ */
package org.onosproject.cluster; package org.onosproject.cluster;
import java.time.Instant;
import java.util.Optional;
import java.util.Set; import java.util.Set;
import org.joda.time.DateTime; import org.joda.time.DateTime;
@ -72,6 +74,27 @@ public interface ClusterService extends ListenerService<ClusterEvent, ClusterEve
* @param nodeId controller node identifier * @param nodeId controller node identifier
* @return system time when the availability state was last updated. * @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);
}
} }

View File

@ -20,6 +20,8 @@ import org.onlab.packet.IpAddress;
import org.onosproject.core.Version; import org.onosproject.core.Version;
import org.onosproject.store.Store; import org.onosproject.store.Store;
import java.time.Instant;
import java.util.Optional;
import java.util.Set; import java.util.Set;
/** /**
@ -78,7 +80,28 @@ public interface ClusterStore extends Store<ClusterEvent, ClusterStoreDelegate>
* @param nodeId controller node identifier * @param nodeId controller node identifier
* @return system time when the availability state was last updated. * @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. * Adds a new controller node to the cluster.

View File

@ -15,7 +15,7 @@
*/ */
package org.onosproject.event; package org.onosproject.event;
import org.joda.time.LocalDateTime; import org.onlab.util.Tools;
import static com.google.common.base.MoreObjects.toStringHelper; import static com.google.common.base.MoreObjects.toStringHelper;
@ -70,7 +70,7 @@ public class AbstractEvent<T extends Enum, S> implements Event<T, S> {
@Override @Override
public String toString() { public String toString() {
return toStringHelper(this) return toStringHelper(this)
.add("time", new LocalDateTime(time)) .add("time", Tools.defaultOffsetDataTime(time))
.add("type", type()) .add("type", type())
.add("subject", subject()) .add("subject", subject())
.toString(); .toString();

View File

@ -15,7 +15,7 @@
*/ */
package org.onosproject.mastership; package org.onosproject.mastership;
import org.joda.time.LocalDateTime; import org.onlab.util.Tools;
import org.onosproject.cluster.RoleInfo; import org.onosproject.cluster.RoleInfo;
import org.onosproject.event.AbstractEvent; import org.onosproject.event.AbstractEvent;
import org.onosproject.net.DeviceId; import org.onosproject.net.DeviceId;
@ -114,7 +114,7 @@ public class MastershipEvent extends AbstractEvent<MastershipEvent.Type, DeviceI
@Override @Override
public String toString() { public String toString() {
return MoreObjects.toStringHelper(getClass()) return MoreObjects.toStringHelper(getClass())
.add("time", new LocalDateTime(time())) .add("time", Tools.defaultOffsetDataTime(time()))
.add("type", type()) .add("type", type())
.add("subject", subject()) .add("subject", subject())
.add("roleInfo", roleInfo) .add("roleInfo", roleInfo)

View File

@ -15,7 +15,7 @@
*/ */
package org.onosproject.net.config; package org.onosproject.net.config;
import org.joda.time.LocalDateTime; import org.onlab.util.Tools;
import org.onosproject.event.AbstractEvent; import org.onosproject.event.AbstractEvent;
import java.util.Optional; import java.util.Optional;
@ -141,7 +141,7 @@ public class NetworkConfigEvent extends AbstractEvent<NetworkConfigEvent.Type, O
@Override @Override
public String toString() { public String toString() {
return toStringHelper(this) return toStringHelper(this)
.add("time", new LocalDateTime(time())) .add("time", Tools.defaultOffsetDataTime(time()))
.add("type", type()) .add("type", type())
.add("config", config()) .add("config", config())
.add("prevConfig", prevConfig()) .add("prevConfig", prevConfig())

View File

@ -15,7 +15,7 @@
*/ */
package org.onosproject.net.device; package org.onosproject.net.device;
import org.joda.time.LocalDateTime; import org.onlab.util.Tools;
import org.onosproject.event.AbstractEvent; import org.onosproject.event.AbstractEvent;
import org.onosproject.net.Device; import org.onosproject.net.Device;
import org.onosproject.net.Port; import org.onosproject.net.Port;
@ -132,7 +132,7 @@ public class DeviceEvent extends AbstractEvent<DeviceEvent.Type, Device> {
return super.toString(); return super.toString();
} }
return toStringHelper(this) return toStringHelper(this)
.add("time", new LocalDateTime(time())) .add("time", Tools.defaultOffsetDataTime(time()))
.add("type", type()) .add("type", type())
.add("subject", subject()) .add("subject", subject())
.add("port", port) .add("port", port)

View File

@ -15,7 +15,7 @@
*/ */
package org.onosproject.net.host; package org.onosproject.net.host;
import org.joda.time.LocalDateTime; import org.onlab.util.Tools;
import org.onosproject.event.AbstractEvent; import org.onosproject.event.AbstractEvent;
import org.onosproject.net.Host; import org.onosproject.net.Host;
@ -104,7 +104,7 @@ public class HostEvent extends AbstractEvent<HostEvent.Type, Host> {
@Override @Override
public String toString() { public String toString() {
return toStringHelper(this) return toStringHelper(this)
.add("time", new LocalDateTime(time())) .add("time", Tools.defaultOffsetDataTime(time()))
.add("type", type()) .add("type", type())
.add("subject", subject()) .add("subject", subject())
.add("prevSubject", prevSubject()) .add("prevSubject", prevSubject())

View File

@ -16,7 +16,7 @@
package org.onosproject.net.intf; package org.onosproject.net.intf;
import org.joda.time.LocalDateTime; import org.onlab.util.Tools;
import org.onosproject.event.AbstractEvent; import org.onosproject.event.AbstractEvent;
import static com.google.common.base.MoreObjects.toStringHelper; import static com.google.common.base.MoreObjects.toStringHelper;
@ -106,7 +106,7 @@ public class InterfaceEvent extends AbstractEvent<InterfaceEvent.Type, Interface
return super.toString(); return super.toString();
} }
return toStringHelper(this) return toStringHelper(this)
.add("time", new LocalDateTime(time())) .add("time", Tools.defaultOffsetDataTime(time()))
.add("type", type()) .add("type", type())
.add("subject", subject()) .add("subject", subject())
.add("prevSubject", prevSubject) .add("prevSubject", prevSubject)

View File

@ -18,8 +18,8 @@ package org.onosproject.store.service;
import java.util.function.Function; import java.util.function.Function;
import org.joda.time.DateTime;
import org.onlab.util.ByteArraySizeHashPrinter; import org.onlab.util.ByteArraySizeHashPrinter;
import org.onlab.util.Tools;
import com.google.common.base.MoreObjects; import com.google.common.base.MoreObjects;
import com.google.common.base.Objects; import com.google.common.base.Objects;
@ -143,7 +143,7 @@ public class Versioned<V> {
return MoreObjects.toStringHelper(this) return MoreObjects.toStringHelper(this)
.add("value", value instanceof byte[] ? new ByteArraySizeHashPrinter((byte[]) value) : value) .add("value", value instanceof byte[] ? new ByteArraySizeHashPrinter((byte[]) value) : value)
.add("version", version) .add("version", version)
.add("creationTime", new DateTime(creationTime)) .add("creationTime", Tools.defaultOffsetDataTime(creationTime))
.toString(); .toString();
} }
} }

View File

@ -19,7 +19,7 @@ import static com.google.common.base.Preconditions.checkArgument;
import java.util.Objects; import java.util.Objects;
import org.joda.time.DateTime; import org.onlab.util.Tools;
import org.onosproject.store.Timestamp; import org.onosproject.store.Timestamp;
import com.google.common.collect.ComparisonChain; import com.google.common.collect.ComparisonChain;
@ -69,7 +69,7 @@ public class WallClockTimestamp implements Timestamp {
@Override @Override
public String toString() { public String toString() {
return new DateTime(unixTimestamp).toString(); return Tools.defaultOffsetDataTime(unixTimestamp).toString();
} }
/** /**

View File

@ -16,13 +16,21 @@
package org.onosproject.ui.table.cell; 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 java.util.Locale;
import org.joda.time.DateTimeZone;
/** /**
* Formats time values using {@link DateTimeFormatter}. * Formats time values using {@link DateTimeFormatter}.
*/ */
@ -38,7 +46,19 @@ public final class TimeFormatter extends AbstractCellFormatter {
* Constructs a time formatter that uses the default locale and timezone. * Constructs a time formatter that uses the default locale and timezone.
*/ */
public TimeFormatter() { 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 @@ public final class TimeFormatter extends AbstractCellFormatter {
* @param zone time zone to use * @param zone time zone to use
* @return self, for chaining * @return self, for chaining
*/ */
public TimeFormatter withZone(DateTimeZone zone) { public TimeFormatter withZone(ZoneId zone) {
dtf = dtf.withZone(zone); dtf = dtf.withZone(zone);
return this; 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 @Override
protected String nonNullFormat(Object value) { 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);
} }
} }

View File

@ -15,9 +15,9 @@
*/ */
package org.onosproject.cluster; package org.onosproject.cluster;
import java.time.Instant;
import java.util.Set; import java.util.Set;
import org.joda.time.DateTime;
import org.onlab.packet.IpAddress; import org.onlab.packet.IpAddress;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
@ -56,7 +56,7 @@ public class ClusterServiceAdapter implements ClusterService {
} }
@Override @Override
public DateTime getLastUpdated(NodeId nodeId) { public Instant getLastUpdatedInstant(NodeId nodeId) {
return null; return null;
} }

View File

@ -16,14 +16,15 @@
package org.onosproject.ui.table.cell; package org.onosproject.ui.table.cell;
import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;
import org.junit.Test; import org.junit.Test;
import org.onosproject.ui.table.CellFormatter; import org.onosproject.ui.table.CellFormatter;
import java.time.OffsetDateTime;
import java.time.ZoneOffset;
import java.util.Locale; 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}. * Unit tests for {@link TimeFormatter}.
@ -31,9 +32,9 @@ import static org.junit.Assert.assertTrue;
public class TimeFormatterTest { public class TimeFormatterTest {
private static final Locale LOCALE = Locale.ENGLISH; 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_NAME = "3:30:00 PM UTC";
private static final String EXP_ZONE_OFFSET = "3:30:00 PM +00:00"; private static final String EXP_ZONE_OFFSET = "3:30:00 PM +00:00";
@ -45,7 +46,6 @@ public class TimeFormatterTest {
@Test @Test
public void basic() { public void basic() {
assertTrue("wrong format", (EXP_ZONE_NAME.equals(fmt.format(TIME)) || assertThat(fmt.format(TIME), isOneOf(EXP_ZONE_OFFSET, EXP_ZONE_NAME));
EXP_ZONE_OFFSET.equals(fmt.format(TIME))));
} }
} }

View File

@ -4,7 +4,6 @@ SRC_DEPS = [
'//lib:METRICS', '//lib:METRICS',
'//incubator/api:onos-incubator-api', '//incubator/api:onos-incubator-api',
'//core/api:onos-api', '//core/api:onos-api',
'//lib:joda-time',
] ]
TEST_DEPS = [ TEST_DEPS = [

View File

@ -23,7 +23,6 @@ import org.apache.felix.scr.annotations.Deactivate;
import org.apache.felix.scr.annotations.Reference; import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.ReferenceCardinality; import org.apache.felix.scr.annotations.ReferenceCardinality;
import org.apache.felix.scr.annotations.Service; import org.apache.felix.scr.annotations.Service;
import org.joda.time.DateTime;
import org.onlab.packet.IpAddress; import org.onlab.packet.IpAddress;
import org.onosproject.cluster.ClusterEvent; import org.onosproject.cluster.ClusterEvent;
import org.onosproject.cluster.ClusterStore; import org.onosproject.cluster.ClusterStore;
@ -41,6 +40,7 @@ import org.onosproject.net.intent.WorkPartitionService;
import org.onosproject.store.AbstractStore; import org.onosproject.store.AbstractStore;
import org.slf4j.Logger; import org.slf4j.Logger;
import java.time.Instant;
import java.util.Set; import java.util.Set;
import java.util.function.Function; import java.util.function.Function;
@ -64,7 +64,7 @@ public class SimpleClusterStore
private ControllerNode instance; private ControllerNode instance;
private final DateTime creationTime = DateTime.now(); private final Instant creationTime = Instant.now();
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected EventDeliveryService eventDispatcher; protected EventDeliveryService eventDispatcher;
@ -123,7 +123,7 @@ public class SimpleClusterStore
} }
@Override @Override
public DateTime getLastUpdated(NodeId nodeId) { public Instant getLastUpdatedInstant(NodeId nodeId) {
return creationTime; return creationTime;
} }

View File

@ -19,6 +19,7 @@ import static org.onosproject.mastership.MastershipEvent.Type.BACKUPS_CHANGED;
import static org.onosproject.mastership.MastershipEvent.Type.MASTER_CHANGED; import static org.onosproject.mastership.MastershipEvent.Type.MASTER_CHANGED;
import static org.slf4j.LoggerFactory.getLogger; import static org.slf4j.LoggerFactory.getLogger;
import java.time.Instant;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
@ -36,7 +37,6 @@ import org.apache.felix.scr.annotations.Deactivate;
import org.apache.felix.scr.annotations.Reference; import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.ReferenceCardinality; import org.apache.felix.scr.annotations.ReferenceCardinality;
import org.apache.felix.scr.annotations.Service; import org.apache.felix.scr.annotations.Service;
import org.joda.time.DateTime;
import org.onlab.packet.IpAddress; import org.onlab.packet.IpAddress;
import org.onosproject.cluster.ClusterEventListener; import org.onosproject.cluster.ClusterEventListener;
import org.onosproject.cluster.ClusterService; import org.onosproject.cluster.ClusterService;
@ -97,7 +97,7 @@ public class SimpleMastershipStore
clusterService = new ClusterService() { clusterService = new ClusterService() {
private final DateTime creationTime = DateTime.now(); private final Instant creationTime = Instant.now();
@Override @Override
public ControllerNode getLocalNode() { public ControllerNode getLocalNode() {
@ -135,7 +135,7 @@ public class SimpleMastershipStore
} }
@Override @Override
public DateTime getLastUpdated(NodeId nodeId) { public Instant getLastUpdatedInstant(NodeId nodeId) {
return creationTime; return creationTime;
} }

View File

@ -9,7 +9,6 @@ COMPILE_DEPS = [
'//incubator/net:onos-incubator-net', '//incubator/net:onos-incubator-net',
'//incubator/store:onos-incubator-store', '//incubator/store:onos-incubator-store',
'//core/store/serializers:onos-core-serializers', '//core/store/serializers:onos-core-serializers',
'//lib:joda-time',
] ]
TEST_DEPS = [ TEST_DEPS = [

View File

@ -15,6 +15,7 @@
*/ */
package org.onosproject.cluster.impl; package org.onosproject.cluster.impl;
import java.time.Instant;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
@ -31,7 +32,6 @@ import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.ReferenceCardinality; import org.apache.felix.scr.annotations.ReferenceCardinality;
import org.apache.felix.scr.annotations.Service; import org.apache.felix.scr.annotations.Service;
import org.apache.karaf.system.SystemService; import org.apache.karaf.system.SystemService;
import org.joda.time.DateTime;
import org.onlab.packet.IpAddress; import org.onlab.packet.IpAddress;
import org.onlab.util.Tools; import org.onlab.util.Tools;
import org.onosproject.cluster.ClusterAdminService; import org.onosproject.cluster.ClusterAdminService;
@ -147,9 +147,9 @@ public class ClusterManager
} }
@Override @Override
public DateTime getLastUpdated(NodeId nodeId) { public Instant getLastUpdatedInstant(NodeId nodeId) {
checkPermission(CLUSTER_READ); checkPermission(CLUSTER_READ);
return store.getLastUpdated(nodeId); return store.getLastUpdatedInstant(nodeId);
} }
@Override @Override

View File

@ -25,7 +25,6 @@ import org.apache.felix.scr.annotations.Deactivate;
import org.apache.felix.scr.annotations.Reference; import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.ReferenceCardinality; import org.apache.felix.scr.annotations.ReferenceCardinality;
import org.apache.felix.scr.annotations.Service; import org.apache.felix.scr.annotations.Service;
import org.joda.time.DateTime;
import org.onlab.util.KryoNamespace; import org.onlab.util.KryoNamespace;
import org.onlab.util.Tools; import org.onlab.util.Tools;
import org.onosproject.cluster.ClusterService; import org.onosproject.cluster.ClusterService;
@ -74,6 +73,7 @@ import org.onosproject.store.serializers.KryoNamespaces;
import org.onosproject.store.service.Serializer; import org.onosproject.store.service.Serializer;
import org.slf4j.Logger; import org.slf4j.Logger;
import java.time.Instant;
import java.util.Collection; import java.util.Collection;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
@ -180,9 +180,9 @@ public class DeviceManager
*/ */
private class LocalStatus { private class LocalStatus {
boolean connected; boolean connected;
DateTime dateTime; Instant dateTime;
public LocalStatus(boolean b, DateTime now) { public LocalStatus(boolean b, Instant now) {
connected = b; connected = b;
dateTime = now; dateTime = now;
} }
@ -333,7 +333,7 @@ public class DeviceManager
if (ls == null) { if (ls == null) {
return "No Record"; return "No Record";
} }
String timeAgo = Tools.timeAgo(ls.dateTime.getMillis()); String timeAgo = Tools.timeAgo(ls.dateTime.toEpochMilli());
return (ls.connected) ? "connected " + timeAgo : "disconnected " + timeAgo; return (ls.connected) ? "connected " + timeAgo : "disconnected " + timeAgo;
} }
@ -508,7 +508,7 @@ public class DeviceManager
checkNotNull(deviceDescription, DEVICE_DESCRIPTION_NULL); checkNotNull(deviceDescription, DEVICE_DESCRIPTION_NULL);
checkValidity(); checkValidity();
deviceLocalStatus.put(deviceId, new LocalStatus(true, DateTime.now())); deviceLocalStatus.put(deviceId, new LocalStatus(true, Instant.now()));
BasicDeviceConfig cfg = networkConfigService.getConfig(deviceId, BasicDeviceConfig.class); BasicDeviceConfig cfg = networkConfigService.getConfig(deviceId, BasicDeviceConfig.class);
if (!isAllowed(cfg)) { if (!isAllowed(cfg)) {
@ -564,7 +564,7 @@ public class DeviceManager
public void deviceDisconnected(DeviceId deviceId) { public void deviceDisconnected(DeviceId deviceId) {
checkNotNull(deviceId, DEVICE_ID_NULL); checkNotNull(deviceId, DEVICE_ID_NULL);
checkValidity(); 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); log.info("Device {} disconnected from this node", deviceId);
List<PortDescription> descs = store.getPortDescriptions(provider().id(), deviceId) List<PortDescription> descs = store.getPortDescriptions(provider().id(), deviceId)

View File

@ -14,7 +14,6 @@ COMPILE_DEPS = [
'//lib:netty-resolver', '//lib:netty-resolver',
'//lib:commons-math3', '//lib:commons-math3',
'//incubator/api:onos-incubator-api', '//incubator/api:onos-incubator-api',
'//lib:joda-time',
] ]
TEST_DEPS = [ TEST_DEPS = [

View File

@ -27,7 +27,6 @@ import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.ReferenceCardinality; import org.apache.felix.scr.annotations.ReferenceCardinality;
import org.apache.felix.scr.annotations.ReferencePolicy; import org.apache.felix.scr.annotations.ReferencePolicy;
import org.apache.felix.scr.annotations.Service; import org.apache.felix.scr.annotations.Service;
import org.joda.time.DateTime;
import org.onlab.packet.IpAddress; import org.onlab.packet.IpAddress;
import org.onlab.util.KryoNamespace; import org.onlab.util.KryoNamespace;
import org.onosproject.cfg.ConfigProperty; import org.onosproject.cfg.ConfigProperty;
@ -50,6 +49,7 @@ import org.onosproject.store.service.Serializer;
import org.osgi.service.component.ComponentContext; import org.osgi.service.component.ComponentContext;
import org.slf4j.Logger; import org.slf4j.Logger;
import java.time.Instant;
import java.util.Map; import java.util.Map;
import java.util.Objects; import java.util.Objects;
import java.util.Set; import java.util.Set;
@ -106,7 +106,7 @@ public class DistributedClusterStore
private final Map<NodeId, ControllerNode> allNodes = Maps.newConcurrentMap(); private final Map<NodeId, ControllerNode> allNodes = Maps.newConcurrentMap();
private final Map<NodeId, State> nodeStates = Maps.newConcurrentMap(); private final Map<NodeId, State> nodeStates = Maps.newConcurrentMap();
private final Map<NodeId, Version> nodeVersions = 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( private ScheduledExecutorService heartBeatSender = Executors.newSingleThreadScheduledExecutor(
groupedThreads("onos/cluster/membership", "heartbeat-sender", log)); groupedThreads("onos/cluster/membership", "heartbeat-sender", log));
@ -273,7 +273,7 @@ public class DistributedClusterStore
if (newVersion != null) { if (newVersion != null) {
nodeVersions.put(nodeId, newVersion); nodeVersions.put(nodeId, newVersion);
} }
nodeLastUpdatedTimes.put(nodeId, DateTime.now()); nodeLastUpdatedTimes.put(nodeId, Instant.now());
notifyChange(nodeId, currentState, newState, currentVersion, newVersion); notifyChange(nodeId, currentState, newState, currentVersion, newVersion);
} }
} }
@ -357,7 +357,7 @@ public class DistributedClusterStore
} }
@Override @Override
public DateTime getLastUpdated(NodeId nodeId) { public Instant getLastUpdatedInstant(NodeId nodeId) {
return nodeLastUpdatedTimes.get(nodeId); return nodeLastUpdatedTimes.get(nodeId);
} }

View File

@ -5,7 +5,6 @@ COMPILE_DEPS = [
'//incubator/api:onos-incubator-api', '//incubator/api:onos-incubator-api',
'//core/store/dist:onos-core-dist', '//core/store/dist:onos-core-dist',
'//core/store/serializers:onos-core-serializers', '//core/store/serializers:onos-core-serializers',
'//lib:joda-time',
] ]
TEST_DEPS = [ TEST_DEPS = [

View File

@ -24,7 +24,6 @@ import org.apache.felix.scr.annotations.Deactivate;
import org.apache.felix.scr.annotations.Reference; import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.ReferenceCardinality; import org.apache.felix.scr.annotations.ReferenceCardinality;
import org.apache.felix.scr.annotations.Service; import org.apache.felix.scr.annotations.Service;
import org.joda.time.DateTime;
import org.onlab.packet.IpAddress; import org.onlab.packet.IpAddress;
import org.onosproject.cluster.ClusterEventListener; import org.onosproject.cluster.ClusterEventListener;
import org.onosproject.cluster.ClusterService; import org.onosproject.cluster.ClusterService;
@ -43,6 +42,7 @@ import org.onosproject.net.DeviceId;
import org.onosproject.net.MastershipRole; import org.onosproject.net.MastershipRole;
import org.slf4j.Logger; import org.slf4j.Logger;
import java.time.Instant;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
@ -454,7 +454,7 @@ public class SimpleVirtualMastershipStore
ClusterService faceClusterService = new ClusterService() { ClusterService faceClusterService = new ClusterService() {
private final DateTime creationTime = DateTime.now(); private final Instant creationTime = Instant.now();
@Override @Override
public ControllerNode getLocalNode() { public ControllerNode getLocalNode() {
@ -492,7 +492,7 @@ public class SimpleVirtualMastershipStore
} }
@Override @Override
public DateTime getLastUpdated(NodeId nodeId) { public Instant getLastUpdatedInstant(NodeId nodeId) {
return creationTime; return creationTime;
} }

View File

@ -420,12 +420,6 @@
<version>${netty4.version}</version> <version>${netty4.version}</version>
</dependency> </dependency>
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.9.3</version>
</dependency>
<dependency> <dependency>
<groupId>com.google.code.findbugs</groupId> <groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId> <artifactId>jsr305</artifactId>
@ -472,11 +466,6 @@
<dependencies> <dependencies>
<!-- COMPILE --> <!-- COMPILE -->
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
</dependency>
<dependency> <dependency>
<groupId>commons-configuration</groupId> <groupId>commons-configuration</groupId>
<artifactId>commons-configuration</artifactId> <artifactId>commons-configuration</artifactId>

View File

@ -3,7 +3,6 @@ COMPILE_DEPS = [
'//incubator/api:onos-incubator-api', '//incubator/api:onos-incubator-api',
'//protocols/netconf/api:onos-protocols-netconf-api', '//protocols/netconf/api:onos-protocols-netconf-api',
'//protocols/netconf/ctl:onos-protocols-netconf-ctl', '//protocols/netconf/ctl:onos-protocols-netconf-ctl',
'//lib:joda-time',
] ]
osgi_jar_with_tests ( osgi_jar_with_tests (

View File

@ -38,10 +38,11 @@ import javax.xml.transform.stream.StreamResult;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.StringWriter; import java.io.StringWriter;
import java.time.Instant;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import org.joda.time.format.ISODateTimeFormat;
import org.xml.sax.SAXException; import org.xml.sax.SAXException;
import static org.slf4j.LoggerFactory.getLogger; import static org.slf4j.LoggerFactory.getLogger;
@ -96,7 +97,7 @@ public class NetconfAlarmTranslator implements AlarmTranslator {
private long parseDate(String timeStr) private long parseDate(String timeStr)
throws UnsupportedOperationException, IllegalArgumentException { 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 { private static String nodeToString(Node rootNode) throws TransformerException {

View File

@ -32,6 +32,9 @@ import java.nio.file.Paths;
import java.nio.file.SimpleFileVisitor; import java.nio.file.SimpleFileVisitor;
import java.nio.file.StandardCopyOption; import java.nio.file.StandardCopyOption;
import java.nio.file.attribute.BasicFileAttributes; 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.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.Dictionary; import java.util.Dictionary;
@ -676,7 +679,7 @@ public abstract class Tools {
return future; return future;
} }
BlockingAwareFuture<T> newFuture = new BlockingAwareFuture<T>(); BlockingAwareFuture<T> newFuture = new BlockingAwareFuture<>();
future.whenComplete((result, error) -> { future.whenComplete((result, error) -> {
Runnable completer = () -> { Runnable completer = () -> {
if (future.isCompletedExceptionally()) { if (future.isCompletedExceptionally()) {
@ -827,4 +830,16 @@ public abstract class Tools {
} }
} }
/**
* 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());
}
} }

View File

@ -17,7 +17,6 @@ COMPILE_DEPS = [
'//utils/rest:onlab-rest', '//utils/rest:onlab-rest',
'//core/store/serializers:onos-core-serializers', '//core/store/serializers:onos-core-serializers',
':onos-tools-gui', ':onos-tools-gui',
'//lib:joda-time',
] ]
TEST_DEPS = [ TEST_DEPS = [

View File

@ -19,7 +19,6 @@ package org.onosproject.ui.impl;
import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.ObjectNode; import com.fasterxml.jackson.databind.node.ObjectNode;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import org.joda.time.DateTime;
import org.onosproject.cluster.ClusterService; import org.onosproject.cluster.ClusterService;
import org.onosproject.cluster.ControllerNode; import org.onosproject.cluster.ControllerNode;
import org.onosproject.cluster.NodeId; import org.onosproject.cluster.NodeId;
@ -32,6 +31,7 @@ import org.onosproject.ui.table.TableModel;
import org.onosproject.ui.table.TableRequestHandler; import org.onosproject.ui.table.TableRequestHandler;
import org.onosproject.ui.table.cell.TimeFormatter; import org.onosproject.ui.table.cell.TimeFormatter;
import java.time.Instant;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -120,7 +120,7 @@ public class ClusterViewMessageHandler extends UiMessageHandler {
private void populateRow(TableModel.Row row, ControllerNode node, private void populateRow(TableModel.Row row, ControllerNode node,
ClusterService cs) { ClusterService cs) {
NodeId id = node.id(); NodeId id = node.id();
DateTime lastUpdated = cs.getLastUpdated(id); Instant lastUpdated = cs.getLastUpdatedInstant(id);
ControllerNode.State state = cs.getState(id); ControllerNode.State state = cs.getState(id);
String iconId = state.isActive() ? ICON_ID_ONLINE : ICON_ID_OFFLINE; String iconId = state.isActive() ? ICON_ID_ONLINE : ICON_ID_OFFLINE;
String startedId = state.isReady() ? ICON_ID_ONLINE : ICON_ID_OFFLINE; String startedId = state.isReady() ? ICON_ID_ONLINE : ICON_ID_OFFLINE;