discovery: Add timestamp to discovery.Update.
The syncbase discovery service needs to be able to order updates from
global discovery and neighborhood discovery based on timestamps in the
case of a changed advertisement.
This change exposes timestamps from discovery.Update.
MultiPart: 4/5
Change-Id: Ie02e414623f0fd3f27d54cbea161b4387eb6aedf
diff --git a/lib/src/main/java/io/v/impl/google/lib/discovery/UpdateImpl.java b/lib/src/main/java/io/v/impl/google/lib/discovery/UpdateImpl.java
index 42d1ef3..6ac400d 100644
--- a/lib/src/main/java/io/v/impl/google/lib/discovery/UpdateImpl.java
+++ b/lib/src/main/java/io/v/impl/google/lib/discovery/UpdateImpl.java
@@ -31,6 +31,7 @@
private boolean lost;
private Advertisement ad;
+ private long timestampNs;
private native void nativeAttachment(
long nativeRef, VContext ctx, String name, ListenableFutureCallback<byte[]> callback)
@@ -38,10 +39,11 @@
private native void nativeFinalize(long nativeRef);
- private UpdateImpl(long nativeRef, boolean lost, Advertisement ad) {
+ private UpdateImpl(long nativeRef, boolean lost, Advertisement ad, long timestampNs) {
this.nativeRef = nativeRef;
this.lost = lost;
this.ad = ad;
+ this.timestampNs = timestampNs;
}
@Override
@@ -127,6 +129,11 @@
}
@Override
+ public long getTimestampNs() {
+ return timestampNs;
+ }
+
+ @Override
public String toString() {
return String.format(
"{%b %s %s %s %s}",
diff --git a/lib/src/main/java/io/v/v23/discovery/Update.java b/lib/src/main/java/io/v/v23/discovery/Update.java
index fa29e8a..5f84d9e 100644
--- a/lib/src/main/java/io/v/v23/discovery/Update.java
+++ b/lib/src/main/java/io/v/v23/discovery/Update.java
@@ -79,4 +79,9 @@
* The returned advertisement may not include all attachments.
*/
Advertisement getAdvertisement();
+
+ /**
+ * Timestamp returns the time when advertising began for the corresponding Advertisement.
+ */
+ long getTimestampNs();
}