mirror of
https://github.com/opennetworkinglab/onos.git
synced 2025-10-17 02:11:38 +02:00
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:
parent
69bf4ddc27
commit
0c47d5386e
@ -3,7 +3,6 @@ COMPILE_DEPS = [
|
||||
'//lib:JACKSON',
|
||||
'//lib:METRICS',
|
||||
'//lib:KRYO',
|
||||
'//lib:joda-time',
|
||||
'//lib:org.apache.karaf.shell.console',
|
||||
'//lib:javax.ws.rs-api',
|
||||
'//lib:rrd4j',
|
||||
|
@ -23,7 +23,6 @@ import com.google.common.collect.Maps;
|
||||
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.UiMessageHandler;
|
||||
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 @@ public class CpmanViewMessageHandler extends UiMessageHandler {
|
||||
|
||||
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 @@ public class CpmanViewMessageHandler extends UiMessageHandler {
|
||||
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 @@ public class CpmanViewMessageHandler extends UiMessageHandler {
|
||||
}
|
||||
}
|
||||
|
||||
// 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 @@ public class CpmanViewMessageHandler extends UiMessageHandler {
|
||||
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);
|
||||
|
@ -3,7 +3,6 @@ COMPILE_DEPS = [
|
||||
'//lib:JACKSON',
|
||||
'//lib:org.apache.karaf.shell.console',
|
||||
'//cli:onos-cli',
|
||||
'//lib:joda-time',
|
||||
]
|
||||
|
||||
osgi_jar_with_tests (
|
||||
|
@ -24,7 +24,7 @@ import java.util.stream.Stream;
|
||||
|
||||
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 @@ public class EventsCommand
|
||||
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 @@ public class EventsCommand
|
||||
} 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 @@ public class EventsCommand
|
||||
|
||||
} 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 @@ public class EventsCommand
|
||||
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 @@ public class EventsCommand
|
||||
} 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 @@ public class EventsCommand
|
||||
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 @@ public class EventsCommand
|
||||
} else {
|
||||
// Unknown Event?
|
||||
print("%s %s\t%s [%s]",
|
||||
new LocalDateTime(event.time()),
|
||||
Tools.defaultOffsetDataTime(event.time()),
|
||||
event.type(),
|
||||
event.subject(),
|
||||
event);
|
||||
|
@ -1,6 +1,5 @@
|
||||
COMPILE_DEPS = [
|
||||
'//lib:CORE_DEPS',
|
||||
'//lib:joda-time',
|
||||
]
|
||||
|
||||
TEST_DEPS = [
|
||||
|
@ -20,7 +20,7 @@ import java.util.Collection;
|
||||
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 @@ public class EvpnRouteEvent extends AbstractEvent<EvpnRouteEvent.Type,
|
||||
@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)
|
||||
|
@ -4,7 +4,6 @@ COMPILE_DEPS = [
|
||||
'//lib:org.apache.karaf.shell.console',
|
||||
'//incubator/api:onos-incubator-api',
|
||||
'//cli:onos-cli',
|
||||
'//lib:joda-time',
|
||||
]
|
||||
|
||||
osgi_jar_with_tests (
|
||||
|
@ -18,7 +18,6 @@ package org.onosproject.faultmanagement.alarms.gui;
|
||||
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.onosproject.ui.table.cell.TimeFormatter;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.Collection;
|
||||
import java.util.Set;
|
||||
|
||||
@ -126,7 +126,7 @@ public class AlarmTableMessageHandler extends UiMessageHandler {
|
||||
.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 @@ public class AlarmTableMessageHandler extends UiMessageHandler {
|
||||
if (msSinceStartOfEpoch == null) {
|
||||
return "-";
|
||||
}
|
||||
return new TimeFormatter().format(new DateTime(msSinceStartOfEpoch));
|
||||
return new TimeFormatter().format(Instant.ofEpochMilli(msSinceStartOfEpoch));
|
||||
}
|
||||
}
|
||||
|
@ -10,7 +10,6 @@ COMPILE_DEPS = [
|
||||
'//lib:okio',
|
||||
'//lib:gson',
|
||||
'//cli:onos-cli',
|
||||
'//lib:joda-time',
|
||||
]
|
||||
|
||||
EXCLUDED_BUNDLES = [
|
||||
|
@ -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 @@ public final class DefaultInfluxMetric implements InfluxMetric {
|
||||
}
|
||||
|
||||
@Override
|
||||
public DateTime time() {
|
||||
public Instant time() {
|
||||
return time;
|
||||
}
|
||||
|
||||
@ -75,10 +73,8 @@ public final class DefaultInfluxMetric implements InfluxMetric {
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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 @@ public interface InfluxMetric {
|
||||
*
|
||||
* @return collected timestamp of the given metric
|
||||
*/
|
||||
DateTime time();
|
||||
Instant time();
|
||||
|
||||
/**
|
||||
* A builder of InfluxMetric.
|
||||
|
@ -1,6 +1,5 @@
|
||||
COMPILE_DEPS = [
|
||||
'//lib:CORE_DEPS',
|
||||
'//lib:joda-time',
|
||||
]
|
||||
|
||||
osgi_jar_with_tests (
|
||||
|
@ -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 @@ public class IpDeviceEvent extends AbstractEvent<IpDeviceEvent.Type, IpDevice> {
|
||||
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)
|
||||
|
@ -9,7 +9,6 @@ COMPILE_DEPS = [
|
||||
'//cli:onos-cli',
|
||||
'//apps/openstacknode/api:onos-apps-openstacknode-api',
|
||||
'//lib:openstack4j-core',
|
||||
'//lib:joda-time',
|
||||
]
|
||||
|
||||
TEST_DEPS = [
|
||||
|
@ -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 @@ public class OpenstackNetworkEvent extends AbstractEvent<OpenstackNetworkEvent.T
|
||||
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)
|
||||
|
@ -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 @@ public class OpenstackRouterEvent extends AbstractEvent<OpenstackRouterEvent.Typ
|
||||
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)
|
||||
|
@ -1,7 +1,6 @@
|
||||
COMPILE_DEPS = [
|
||||
'//lib:CORE_DEPS',
|
||||
'//lib:JACKSON',
|
||||
'//lib:joda-time',
|
||||
]
|
||||
|
||||
TEST_DEPS = [
|
||||
|
@ -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 @@ public class RouteEvent extends AbstractEvent<RouteEvent.Type, ResolvedRoute> {
|
||||
@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)
|
||||
|
@ -9,7 +9,6 @@ COMPILE_DEPS = [
|
||||
'//incubator/api:onos-incubator-api',
|
||||
'//utils/rest:onlab-rest',
|
||||
'//apps/route-service/api:onos-apps-route-service-api',
|
||||
'//lib:joda-time',
|
||||
]
|
||||
|
||||
BUNDLES = [
|
||||
|
@ -23,7 +23,6 @@ import com.google.common.collect.Lists;
|
||||
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.onosproject.segmentrouting.grouphandler.DefaultGroupHandler;
|
||||
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 @@ public class DefaultRoutingHandler {
|
||||
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 @@ public class DefaultRoutingHandler {
|
||||
* @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 @@ public class DefaultRoutingHandler {
|
||||
* 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 @@ public class DefaultRoutingHandler {
|
||||
return;
|
||||
}
|
||||
|
||||
lastRoutingChange = DateTime.now();
|
||||
lastRoutingChange = Instant.now();
|
||||
statusLock.lock();
|
||||
try {
|
||||
if (populationStatus == Status.STARTED) {
|
||||
@ -374,7 +374,7 @@ public class DefaultRoutingHandler {
|
||||
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();
|
||||
|
1
cli/BUCK
1
cli/BUCK
@ -7,7 +7,6 @@ COMPILE_DEPS = [
|
||||
'//incubator/net:onos-incubator-net',
|
||||
'//utils/rest:onlab-rest',
|
||||
'//core/common:onos-core-common',
|
||||
'//lib:joda-time',
|
||||
]
|
||||
|
||||
osgi_jar (
|
||||
|
@ -31,8 +31,8 @@ import com.google.common.collect.Ordering;
|
||||
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 @@ public class MetricsListCommand extends AbstractShellCommand {
|
||||
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 @@ public class MetricsListCommand extends AbstractShellCommand {
|
||||
private double nanoToMs(double nano) {
|
||||
return nano / 1_000_000D;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -20,13 +20,13 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
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 @@ public class NodesListCommand extends AbstractShellCommand {
|
||||
} 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(),
|
||||
|
@ -34,6 +34,7 @@
|
||||
<dependency>
|
||||
<groupId>joda-time</groupId>
|
||||
<artifactId>joda-time</artifactId>
|
||||
<version>2.9.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-configuration</groupId>
|
||||
|
@ -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 @@ public interface ClusterService extends ListenerService<ClusterEvent, ClusterEve
|
||||
* @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);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -20,6 +20,8 @@ import org.onlab.packet.IpAddress;
|
||||
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 @@ public interface ClusterStore extends Store<ClusterEvent, ClusterStoreDelegate>
|
||||
* @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.
|
||||
|
@ -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 @@ public class AbstractEvent<T extends Enum, S> implements Event<T, S> {
|
||||
@Override
|
||||
public String toString() {
|
||||
return toStringHelper(this)
|
||||
.add("time", new LocalDateTime(time))
|
||||
.add("time", Tools.defaultOffsetDataTime(time))
|
||||
.add("type", type())
|
||||
.add("subject", subject())
|
||||
.toString();
|
||||
|
@ -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 @@ public class MastershipEvent extends AbstractEvent<MastershipEvent.Type, DeviceI
|
||||
@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)
|
||||
|
@ -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 @@ public class NetworkConfigEvent extends AbstractEvent<NetworkConfigEvent.Type, O
|
||||
@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())
|
||||
|
@ -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 @@ public class DeviceEvent extends AbstractEvent<DeviceEvent.Type, Device> {
|
||||
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)
|
||||
|
@ -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 @@ public class HostEvent extends AbstractEvent<HostEvent.Type, Host> {
|
||||
@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())
|
||||
|
@ -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 @@ public class InterfaceEvent extends AbstractEvent<InterfaceEvent.Type, Interface
|
||||
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)
|
||||
|
@ -18,8 +18,8 @@ package org.onosproject.store.service;
|
||||
|
||||
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 @@ public class Versioned<V> {
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ import static com.google.common.base.Preconditions.checkArgument;
|
||||
|
||||
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 @@ public class WallClockTimestamp implements Timestamp {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new DateTime(unixTimestamp).toString();
|
||||
return Tools.defaultOffsetDataTime(unixTimestamp).toString();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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 @@ public final class TimeFormatter extends AbstractCellFormatter {
|
||||
* 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 @@ public final class TimeFormatter extends AbstractCellFormatter {
|
||||
* @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);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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 @@ public class ClusterServiceAdapter implements ClusterService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public DateTime getLastUpdated(NodeId nodeId) {
|
||||
public Instant getLastUpdatedInstant(NodeId nodeId) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -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 @@ import static org.junit.Assert.assertTrue;
|
||||
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 @@ public class TimeFormatterTest {
|
||||
|
||||
@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));
|
||||
}
|
||||
}
|
||||
|
@ -4,7 +4,6 @@ SRC_DEPS = [
|
||||
'//lib:METRICS',
|
||||
'//incubator/api:onos-incubator-api',
|
||||
'//core/api:onos-api',
|
||||
'//lib:joda-time',
|
||||
]
|
||||
|
||||
TEST_DEPS = [
|
||||
|
@ -23,7 +23,6 @@ import org.apache.felix.scr.annotations.Deactivate;
|
||||
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.net.intent.WorkPartitionService;
|
||||
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 @@ public class SimpleClusterStore
|
||||
|
||||
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 @@ public class SimpleClusterStore
|
||||
}
|
||||
|
||||
@Override
|
||||
public DateTime getLastUpdated(NodeId nodeId) {
|
||||
public Instant getLastUpdatedInstant(NodeId nodeId) {
|
||||
return creationTime;
|
||||
}
|
||||
|
||||
|
@ -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.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.Deactivate;
|
||||
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 @@ public class SimpleMastershipStore
|
||||
|
||||
clusterService = new ClusterService() {
|
||||
|
||||
private final DateTime creationTime = DateTime.now();
|
||||
private final Instant creationTime = Instant.now();
|
||||
|
||||
@Override
|
||||
public ControllerNode getLocalNode() {
|
||||
@ -135,7 +135,7 @@ public class SimpleMastershipStore
|
||||
}
|
||||
|
||||
@Override
|
||||
public DateTime getLastUpdated(NodeId nodeId) {
|
||||
public Instant getLastUpdatedInstant(NodeId nodeId) {
|
||||
return creationTime;
|
||||
}
|
||||
|
||||
|
@ -9,7 +9,6 @@ COMPILE_DEPS = [
|
||||
'//incubator/net:onos-incubator-net',
|
||||
'//incubator/store:onos-incubator-store',
|
||||
'//core/store/serializers:onos-core-serializers',
|
||||
'//lib:joda-time',
|
||||
]
|
||||
|
||||
TEST_DEPS = [
|
||||
|
@ -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.Reference;
|
||||
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 @@ public class ClusterManager
|
||||
}
|
||||
|
||||
@Override
|
||||
public DateTime getLastUpdated(NodeId nodeId) {
|
||||
public Instant getLastUpdatedInstant(NodeId nodeId) {
|
||||
checkPermission(CLUSTER_READ);
|
||||
return store.getLastUpdated(nodeId);
|
||||
return store.getLastUpdatedInstant(nodeId);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -25,7 +25,6 @@ import org.apache.felix.scr.annotations.Deactivate;
|
||||
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.serializers.KryoNamespaces;
|
||||
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 @@ public class DeviceManager
|
||||
*/
|
||||
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 @@ public class DeviceManager
|
||||
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 @@ public class DeviceManager
|
||||
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 class DeviceManager
|
||||
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)
|
||||
|
1
core/store/dist/BUCK
vendored
1
core/store/dist/BUCK
vendored
@ -14,7 +14,6 @@ COMPILE_DEPS = [
|
||||
'//lib:netty-resolver',
|
||||
'//lib:commons-math3',
|
||||
'//incubator/api:onos-incubator-api',
|
||||
'//lib:joda-time',
|
||||
]
|
||||
|
||||
TEST_DEPS = [
|
||||
|
@ -27,7 +27,6 @@ import org.apache.felix.scr.annotations.Reference;
|
||||
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.onosproject.store.service.Serializer;
|
||||
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 @@ public class DistributedClusterStore
|
||||
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 @@ public class DistributedClusterStore
|
||||
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 @@ public class DistributedClusterStore
|
||||
}
|
||||
|
||||
@Override
|
||||
public DateTime getLastUpdated(NodeId nodeId) {
|
||||
public Instant getLastUpdatedInstant(NodeId nodeId) {
|
||||
return nodeLastUpdatedTimes.get(nodeId);
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,6 @@ COMPILE_DEPS = [
|
||||
'//incubator/api:onos-incubator-api',
|
||||
'//core/store/dist:onos-core-dist',
|
||||
'//core/store/serializers:onos-core-serializers',
|
||||
'//lib:joda-time',
|
||||
]
|
||||
|
||||
TEST_DEPS = [
|
||||
|
@ -24,7 +24,6 @@ import org.apache.felix.scr.annotations.Deactivate;
|
||||
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.DeviceId;
|
||||
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 @@ public class SimpleVirtualMastershipStore
|
||||
|
||||
ClusterService faceClusterService = new ClusterService() {
|
||||
|
||||
private final DateTime creationTime = DateTime.now();
|
||||
private final Instant creationTime = Instant.now();
|
||||
|
||||
@Override
|
||||
public ControllerNode getLocalNode() {
|
||||
@ -492,7 +492,7 @@ public class SimpleVirtualMastershipStore
|
||||
}
|
||||
|
||||
@Override
|
||||
public DateTime getLastUpdated(NodeId nodeId) {
|
||||
public Instant getLastUpdatedInstant(NodeId nodeId) {
|
||||
return creationTime;
|
||||
}
|
||||
|
||||
|
11
lib/pom.xml
11
lib/pom.xml
@ -420,12 +420,6 @@
|
||||
<version>${netty4.version}</version>
|
||||
</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>
|
||||
@ -472,11 +466,6 @@
|
||||
<dependencies>
|
||||
|
||||
<!-- COMPILE -->
|
||||
<dependency>
|
||||
<groupId>joda-time</groupId>
|
||||
<artifactId>joda-time</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>commons-configuration</groupId>
|
||||
<artifactId>commons-configuration</artifactId>
|
||||
|
@ -3,7 +3,6 @@ COMPILE_DEPS = [
|
||||
'//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 (
|
||||
|
@ -38,10 +38,11 @@ import javax.xml.transform.stream.StreamResult;
|
||||
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 @@ public class NetconfAlarmTranslator implements AlarmTranslator {
|
||||
|
||||
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 {
|
||||
|
@ -32,6 +32,9 @@ import java.nio.file.Paths;
|
||||
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 @@ public abstract class Tools {
|
||||
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 @@ 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());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -17,7 +17,6 @@ COMPILE_DEPS = [
|
||||
'//utils/rest:onlab-rest',
|
||||
'//core/store/serializers:onos-core-serializers',
|
||||
':onos-tools-gui',
|
||||
'//lib:joda-time',
|
||||
]
|
||||
|
||||
TEST_DEPS = [
|
||||
|
@ -19,7 +19,6 @@ package org.onosproject.ui.impl;
|
||||
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.TableModel;
|
||||
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 @@ public class ClusterViewMessageHandler extends UiMessageHandler {
|
||||
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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user