diff --git a/java/google/registry/model/common/Cursor.java b/java/google/registry/model/common/Cursor.java
index 92a104374..6c542d205 100644
--- a/java/google/registry/model/common/Cursor.java
+++ b/java/google/registry/model/common/Cursor.java
@@ -161,6 +161,13 @@ public class Cursor extends ImmutableObject {
return create(cursorType, cursorTime, Key.create(scope));
}
+ /**
+ * Returns the current time for a given cursor, or {@code START_OF_TIME} if the cursor is null.
+ */
+ public static DateTime getCursorTimeOrStartOfTime(Cursor cursor) {
+ return cursor != null ? cursor.getCursorTime() : START_OF_TIME;
+ }
+
public DateTime getCursorTime() {
return cursorTime;
}
diff --git a/java/google/registry/rde/EscrowTaskRunner.java b/java/google/registry/rde/EscrowTaskRunner.java
index 16f8bbc42..625852675 100644
--- a/java/google/registry/rde/EscrowTaskRunner.java
+++ b/java/google/registry/rde/EscrowTaskRunner.java
@@ -18,9 +18,9 @@ import static google.registry.model.ofy.ObjectifyService.ofy;
import com.googlecode.objectify.VoidWork;
+import google.registry.model.common.Cursor;
+import google.registry.model.common.Cursor.CursorType;
import google.registry.model.registry.Registry;
-import google.registry.model.registry.RegistryCursor;
-import google.registry.model.registry.RegistryCursor.CursorType;
import google.registry.model.server.Lock;
import google.registry.request.HttpException.NoContentException;
import google.registry.request.HttpException.ServiceUnavailableException;
@@ -50,13 +50,13 @@ import javax.inject.Inject;
* {@link NoContentException} is thrown to cancel the task.
*
*
The specific date for which the deposit is generated depends on the current position of the
- * {@link RegistryCursor}. If the cursor is set to tomorrow, we do nothing and return 204 No
- * Content. If the cursor is set to today, then we create a deposit for today and advance the
- * cursor. If the cursor is set to yesterday or earlier, then we create a deposit for that date,
- * advance the cursor, but we do not make any attempt to catch the cursor up to the current
- * time. Therefore you must set the cron interval to something less than the desired
- * interval, so the cursor can catch up. For example, if the task is supposed to run daily, you
- * should configure cron to execute it every twelve hours, or possibly less.
+ * {@link Cursor}. If the cursor is set to tomorrow, we do nothing and return 204 No Content. If the
+ * cursor is set to today, then we create a deposit for today and advance the cursor. If the cursor
+ * is set to yesterday or earlier, then we create a deposit for that date, advance the cursor, but
+ * we do not make any attempt to catch the cursor up to the current time. Therefore you
+ * must set the cron interval to something less than the desired interval, so the cursor can
+ * catch up. For example, if the task is supposed to run daily, you should configure cron to execute
+ * it every twelve hours, or possibly less.
*/
class EscrowTaskRunner {
@@ -97,7 +97,8 @@ class EscrowTaskRunner {
public Void call() throws Exception {
logger.info("tld=" + registry.getTld());
DateTime startOfToday = clock.nowUtc().withTimeAtStartOfDay();
- final DateTime nextRequiredRun = RegistryCursor.load(registry, cursorType).or(startOfToday);
+ Cursor cursor = ofy().load().key(Cursor.createKey(cursorType, registry)).now();
+ final DateTime nextRequiredRun = (cursor == null ? startOfToday : cursor.getCursorTime());
if (nextRequiredRun.isAfter(startOfToday)) {
throw new NoContentException("Already completed");
}
@@ -106,7 +107,8 @@ class EscrowTaskRunner {
ofy().transact(new VoidWork() {
@Override
public void vrun() {
- RegistryCursor.save(registry, cursorType, nextRequiredRun.plus(interval));
+ ofy().save().entity(
+ Cursor.create(cursorType, nextRequiredRun.plus(interval), registry));
}});
return null;
}};
diff --git a/java/google/registry/rde/PendingDeposit.java b/java/google/registry/rde/PendingDeposit.java
index 78204e885..a21a9cca1 100644
--- a/java/google/registry/rde/PendingDeposit.java
+++ b/java/google/registry/rde/PendingDeposit.java
@@ -16,8 +16,8 @@ package google.registry.rde;
import com.google.auto.value.AutoValue;
+import google.registry.model.common.Cursor.CursorType;
import google.registry.model.rde.RdeMode;
-import google.registry.model.registry.RegistryCursor.CursorType;
import org.joda.time.DateTime;
import org.joda.time.Duration;
diff --git a/java/google/registry/rde/PendingDepositChecker.java b/java/google/registry/rde/PendingDepositChecker.java
index 59e14fa27..8800afcf0 100644
--- a/java/google/registry/rde/PendingDepositChecker.java
+++ b/java/google/registry/rde/PendingDepositChecker.java
@@ -18,18 +18,17 @@ import static com.google.common.base.Preconditions.checkArgument;
import static google.registry.model.ofy.ObjectifyService.ofy;
import static google.registry.util.DateTimeUtils.isBeforeOrAt;
-import com.google.common.base.Optional;
import com.google.common.collect.ImmutableSetMultimap;
import com.googlecode.objectify.Work;
import google.registry.config.ConfigModule.Config;
+import google.registry.model.common.Cursor;
+import google.registry.model.common.Cursor.CursorType;
import google.registry.model.rde.RdeMode;
import google.registry.model.registry.Registries;
import google.registry.model.registry.Registry;
import google.registry.model.registry.Registry.TldType;
-import google.registry.model.registry.RegistryCursor;
-import google.registry.model.registry.RegistryCursor.CursorType;
import google.registry.util.Clock;
import org.joda.time.DateTime;
@@ -83,7 +82,7 @@ public final class PendingDepositChecker {
}
private ImmutableSetMultimap getTldsAndWatermarksPendingDeposit(
- RdeMode mode, CursorType cursor, Duration interval, DateTime startingPoint) {
+ RdeMode mode, CursorType cursorType, Duration interval, DateTime startingPoint) {
checkArgument(interval.isLongerThan(Duration.ZERO));
ImmutableSetMultimap.Builder builder =
new ImmutableSetMultimap.Builder<>();
@@ -94,16 +93,14 @@ public final class PendingDepositChecker {
continue;
}
// Avoid creating a transaction unless absolutely necessary.
- Optional cursorValue = RegistryCursor.load(registry, cursor);
- if (isBeforeOrAt(cursorValue.or(startingPoint), now)) {
- DateTime watermark;
- if (cursorValue.isPresent()) {
- watermark = cursorValue.get();
- } else {
- watermark = transactionallyInitializeCursor(registry, cursor, startingPoint);
- }
+ Cursor cursor = ofy().load().key(Cursor.createKey(cursorType, registry)).now();
+ DateTime cursorValue = (cursor != null ? cursor.getCursorTime() : startingPoint);
+ if (isBeforeOrAt(cursorValue, now)) {
+ DateTime watermark = (cursor != null
+ ? cursor.getCursorTime()
+ : transactionallyInitializeCursor(registry, cursorType, startingPoint));
if (isBeforeOrAt(watermark, now)) {
- builder.put(tld, PendingDeposit.create(tld, watermark, mode, cursor, interval));
+ builder.put(tld, PendingDeposit.create(tld, watermark, mode, cursorType, interval));
}
}
}
@@ -112,15 +109,16 @@ public final class PendingDepositChecker {
private DateTime transactionallyInitializeCursor(
final Registry registry,
- final CursorType cursor,
+ final CursorType cursorType,
final DateTime initialValue) {
return ofy().transact(new Work() {
@Override
public DateTime run() {
- for (DateTime value : RegistryCursor.load(registry, cursor).asSet()) {
- return value;
+ Cursor cursor = ofy().load().key(Cursor.createKey(cursorType, registry)).now();
+ if (cursor != null) {
+ return cursor.getCursorTime();
}
- RegistryCursor.save(registry, cursor, initialValue);
+ ofy().save().entity(Cursor.create(cursorType, initialValue, registry));
return initialValue;
}});
}
diff --git a/java/google/registry/rde/RdeReportAction.java b/java/google/registry/rde/RdeReportAction.java
index 92966464a..0e18711ce 100644
--- a/java/google/registry/rde/RdeReportAction.java
+++ b/java/google/registry/rde/RdeReportAction.java
@@ -16,9 +16,10 @@ package google.registry.rde;
import static com.google.common.base.Verify.verify;
import static com.google.common.net.MediaType.PLAIN_TEXT_UTF_8;
+import static google.registry.model.common.Cursor.getCursorTimeOrStartOfTime;
+import static google.registry.model.ofy.ObjectifyService.ofy;
import static google.registry.model.rde.RdeMode.FULL;
import static google.registry.request.Action.Method.POST;
-import static google.registry.util.DateTimeUtils.START_OF_TIME;
import com.google.appengine.tools.cloudstorage.GcsFilename;
import com.google.common.io.ByteStreams;
@@ -26,10 +27,10 @@ import com.google.common.io.ByteStreams;
import google.registry.config.ConfigModule.Config;
import google.registry.gcs.GcsUtils;
import google.registry.keyring.api.KeyModule.Key;
+import google.registry.model.common.Cursor;
+import google.registry.model.common.Cursor.CursorType;
import google.registry.model.rde.RdeNamingUtils;
import google.registry.model.registry.Registry;
-import google.registry.model.registry.RegistryCursor;
-import google.registry.model.registry.RegistryCursor.CursorType;
import google.registry.rde.EscrowTaskRunner.EscrowTask;
import google.registry.request.Action;
import google.registry.request.HttpException.NoContentException;
@@ -77,10 +78,11 @@ public final class RdeReportAction implements Runnable, EscrowTask {
@Override
public void runWithLock(DateTime watermark) throws Exception {
- DateTime stagingCursor =
- RegistryCursor.load(Registry.get(tld), CursorType.RDE_UPLOAD).or(START_OF_TIME);
- if (!stagingCursor.isAfter(watermark)) {
- logger.infofmt("tld=%s reportCursor=%s uploadCursor=%s", tld, watermark, stagingCursor);
+ DateTime cursorTime =
+ getCursorTimeOrStartOfTime(
+ ofy().load().key(Cursor.createKey(CursorType.RDE_UPLOAD, Registry.get(tld))).now());
+ if (!cursorTime.isAfter(watermark)) {
+ logger.infofmt("tld=%s reportCursor=%s uploadCursor=%s", tld, watermark, cursorTime);
throw new NoContentException("Waiting for RdeUploadAction to complete");
}
String prefix = RdeNamingUtils.makeRydeFilename(tld, watermark, FULL, 1, 0);
diff --git a/java/google/registry/rde/RdeStagingAction.java b/java/google/registry/rde/RdeStagingAction.java
index dd361d2d9..1a0bb4dac 100644
--- a/java/google/registry/rde/RdeStagingAction.java
+++ b/java/google/registry/rde/RdeStagingAction.java
@@ -27,13 +27,13 @@ import google.registry.mapreduce.MapreduceRunner;
import google.registry.mapreduce.inputs.EppResourceInputs;
import google.registry.mapreduce.inputs.NullInput;
import google.registry.model.EppResource;
+import google.registry.model.common.Cursor;
+import google.registry.model.common.Cursor.CursorType;
import google.registry.model.contact.ContactResource;
import google.registry.model.host.HostResource;
import google.registry.model.index.EppResourceIndex;
import google.registry.model.rde.RdeMode;
import google.registry.model.registrar.Registrar;
-import google.registry.model.registry.RegistryCursor;
-import google.registry.model.registry.RegistryCursor.CursorType;
import google.registry.request.Action;
import google.registry.request.Response;
import google.registry.util.Clock;
@@ -89,8 +89,8 @@ import javax.inject.Inject;
* key and shows you its representation in lenient XML.
*
* Failed deposits will be retried indefinitely. This is because RDE and BRDA each have a
- * {@link RegistryCursor} for each TLD. Even if the cursor lags for days, it'll catch up gradually
- * on its own, once the data becomes valid.
+ * {@link Cursor} for each TLD. Even if the cursor lags for days, it'll catch up gradually on its
+ * own, once the data becomes valid.
*
*
The third-party escrow provider will validate each deposit we send them. They do both schema
* validation and reference checking.
diff --git a/java/google/registry/rde/RdeStagingReducer.java b/java/google/registry/rde/RdeStagingReducer.java
index 550cef689..924740a49 100644
--- a/java/google/registry/rde/RdeStagingReducer.java
+++ b/java/google/registry/rde/RdeStagingReducer.java
@@ -18,6 +18,7 @@ import static com.google.appengine.api.taskqueue.QueueFactory.getQueue;
import static com.google.appengine.api.taskqueue.TaskOptions.Builder.withUrl;
import static com.google.appengine.tools.cloudstorage.GcsServiceFactory.createGcsService;
import static com.google.common.base.Verify.verify;
+import static google.registry.model.common.Cursor.getCursorTimeOrStartOfTime;
import static google.registry.model.ofy.ObjectifyService.ofy;
import static java.nio.charset.StandardCharsets.US_ASCII;
import static java.nio.charset.StandardCharsets.UTF_8;
@@ -33,11 +34,11 @@ import google.registry.config.ConfigModule.Config;
import google.registry.gcs.GcsUtils;
import google.registry.keyring.api.KeyModule;
import google.registry.keyring.api.PgpHelper;
+import google.registry.model.common.Cursor;
import google.registry.model.rde.RdeMode;
import google.registry.model.rde.RdeNamingUtils;
import google.registry.model.rde.RdeRevision;
import google.registry.model.registry.Registry;
-import google.registry.model.registry.RegistryCursor;
import google.registry.model.server.Lock;
import google.registry.request.RequestParameters;
import google.registry.tldconfig.idn.IdnTableEnum;
@@ -201,7 +202,8 @@ public final class RdeStagingReducer extends Reducer cursor = RegistryCursor.load(registry, cursorType);
- lines.add(String.format("%-25s%s", cursor.isPresent() ? cursor.get() : "absent", tld));
+ Cursor cursor = ofy().load().key(Cursor.createKey(cursorType, registry)).now();
+ lines.add(String.format("%-25s%s", cursor != null ? cursor.getCursorTime() : "absent", tld));
}
for (String line : Ordering.natural().sortedCopy(lines)) {
System.out.println(line);
diff --git a/java/google/registry/tools/UpdateCursorsCommand.java b/java/google/registry/tools/UpdateCursorsCommand.java
index 434475a5c..7e0f1531f 100644
--- a/java/google/registry/tools/UpdateCursorsCommand.java
+++ b/java/google/registry/tools/UpdateCursorsCommand.java
@@ -14,27 +14,24 @@
package google.registry.tools;
-import com.google.common.base.Optional;
+import static google.registry.model.ofy.ObjectifyService.ofy;
import com.beust.jcommander.Parameter;
import com.beust.jcommander.Parameters;
import google.registry.model.common.Cursor;
+import google.registry.model.common.Cursor.CursorType;
import google.registry.model.registry.Registry;
-import google.registry.model.registry.RegistryCursor;
-import google.registry.model.registry.RegistryCursor.CursorType;
import google.registry.tools.params.DateTimeParameter;
import org.joda.time.DateTime;
import java.util.List;
-/** Modifies {code RegistryCursor} timestamps used by locking rolling cursor tasks, like in RDE. */
+/** Modifies {@link Cursor} timestamps used by locking rolling cursor tasks, like in RDE. */
@Parameters(separators = " =", commandDescription = "Modifies cursor timestamps used by LRC tasks")
final class UpdateCursorsCommand extends MutatingCommand {
- // TODO(b/28386088): Cut command over to new Cursor format
-
@Parameter(
description = "TLDs on which to operate.",
required = true)
@@ -57,16 +54,10 @@ final class UpdateCursorsCommand extends MutatingCommand {
protected void init() throws Exception {
for (String tld : tlds) {
Registry registry = Registry.get(tld);
- Optional expectedTimestamp = RegistryCursor.load(registry, cursorType);
+ Cursor cursor = ofy().load().key(Cursor.createKey(cursorType, registry)).now();
stageEntityChange(
- expectedTimestamp.isPresent()
- ? RegistryCursor.create(registry, cursorType, expectedTimestamp.get())
- : null,
- RegistryCursor.create(registry, cursorType, newTimestamp));
- Cursor.CursorType newCursorType = Cursor.CursorType.valueOf(cursorType.name());
- stageEntityChange(
- null,
- Cursor.create(newCursorType, newTimestamp, registry));
- }
+ cursor,
+ Cursor.create(cursorType, newTimestamp, registry));
+ }
}
}
diff --git a/javatests/google/registry/backup/CommitLogCheckpointStrategyTest.java b/javatests/google/registry/backup/CommitLogCheckpointStrategyTest.java
index 59745d055..7bb85620f 100644
--- a/javatests/google/registry/backup/CommitLogCheckpointStrategyTest.java
+++ b/javatests/google/registry/backup/CommitLogCheckpointStrategyTest.java
@@ -16,6 +16,7 @@ package google.registry.backup;
import static com.google.common.truth.Truth.assertThat;
import static google.registry.model.ofy.CommitLogBucket.getBucketKey;
+import static google.registry.model.ofy.ObjectifyService.ofy;
import static google.registry.testing.DatastoreHelper.createTld;
import static google.registry.util.DateTimeUtils.END_OF_TIME;
import static google.registry.util.DateTimeUtils.START_OF_TIME;
@@ -26,12 +27,12 @@ import com.google.common.collect.ImmutableMap;
import com.googlecode.objectify.VoidWork;
import google.registry.config.TestRegistryConfig;
+import google.registry.model.common.Cursor;
+import google.registry.model.common.Cursor.CursorType;
import google.registry.model.ofy.CommitLogBucket;
import google.registry.model.ofy.CommitLogCheckpoint;
import google.registry.model.ofy.Ofy;
import google.registry.model.registry.Registry;
-import google.registry.model.registry.RegistryCursor;
-import google.registry.model.registry.RegistryCursor.CursorType;
import google.registry.testing.AppEngineRule;
import google.registry.testing.FakeClock;
import google.registry.testing.InjectRule;
@@ -309,7 +310,8 @@ public class CommitLogCheckpointStrategyTest {
@Override
public void vrun() {
String tld = "tld" + bucketId;
- RegistryCursor.save(Registry.get(tld), CursorType.RDE_REPORT, ofy.getTransactionTime());
+ ofy().save().entity(
+ Cursor.create(CursorType.RDE_REPORT, ofy.getTransactionTime(), Registry.get(tld)));
}
});
fakeBucketIdSupplier.value = null;
diff --git a/javatests/google/registry/rde/EscrowTaskRunnerTest.java b/javatests/google/registry/rde/EscrowTaskRunnerTest.java
index f9eb02f7a..88487e726 100644
--- a/javatests/google/registry/rde/EscrowTaskRunnerTest.java
+++ b/javatests/google/registry/rde/EscrowTaskRunnerTest.java
@@ -23,9 +23,9 @@ import static org.joda.time.Duration.standardSeconds;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
+import google.registry.model.common.Cursor;
+import google.registry.model.common.Cursor.CursorType;
import google.registry.model.registry.Registry;
-import google.registry.model.registry.RegistryCursor;
-import google.registry.model.registry.RegistryCursor.CursorType;
import google.registry.model.server.Lock;
import google.registry.rde.EscrowTaskRunner.EscrowTask;
import google.registry.request.HttpException.NoContentException;
@@ -77,13 +77,13 @@ public class EscrowTaskRunnerTest {
public void testRun_cursorIsToday_advancesCursorToTomorrow() throws Exception {
clock.setTo(DateTime.parse("2006-06-06T00:30:00Z"));
persistResource(
- RegistryCursor.create(registry, CursorType.RDE_STAGING, DateTime.parse("2006-06-06TZ")));
+ Cursor.create(CursorType.RDE_STAGING, DateTime.parse("2006-06-06TZ"), registry));
runner.lockRunAndRollForward(
task, registry, standardSeconds(30), CursorType.RDE_STAGING, standardDays(1));
verify(task).runWithLock(DateTime.parse("2006-06-06TZ"));
ofy().clearSessionCache();
- assertThat(RegistryCursor.load(registry, CursorType.RDE_STAGING))
- .hasValue(DateTime.parse("2006-06-07TZ"));
+ Cursor cursor = ofy().load().key(Cursor.createKey(CursorType.RDE_STAGING, registry)).now();
+ assertThat(cursor.getCursorTime()).isEqualTo(DateTime.parse("2006-06-07TZ"));
}
@Test
@@ -92,15 +92,16 @@ public class EscrowTaskRunnerTest {
runner.lockRunAndRollForward(
task, registry, standardSeconds(30), CursorType.RDE_STAGING, standardDays(1));
verify(task).runWithLock(DateTime.parse("2006-06-06TZ"));
- assertThat(RegistryCursor.load(Registry.get("lol"), CursorType.RDE_STAGING))
- .hasValue(DateTime.parse("2006-06-07TZ"));
+ Cursor cursor =
+ ofy().load().key(Cursor.createKey(CursorType.RDE_STAGING, Registry.get("lol"))).now();
+ assertThat(cursor.getCursorTime()).isEqualTo(DateTime.parse("2006-06-07TZ"));
}
@Test
public void testRun_cursorInTheFuture_doesNothing() throws Exception {
clock.setTo(DateTime.parse("2006-06-06T00:30:00Z"));
persistResource(
- RegistryCursor.create(registry, CursorType.RDE_STAGING, DateTime.parse("2006-06-07TZ")));
+ Cursor.create(CursorType.RDE_STAGING, DateTime.parse("2006-06-07TZ"), registry));
thrown.expect(NoContentException.class, "Already completed");
runner.lockRunAndRollForward(
task, registry, standardSeconds(30), CursorType.RDE_STAGING, standardDays(1));
@@ -112,7 +113,7 @@ public class EscrowTaskRunnerTest {
thrown.expect(ServiceUnavailableException.class, "Lock in use: " + lockName);
clock.setTo(DateTime.parse("2006-06-06T00:30:00Z"));
persistResource(
- RegistryCursor.create(registry, CursorType.RDE_STAGING, DateTime.parse("2006-06-06TZ")));
+ Cursor.create(CursorType.RDE_STAGING, DateTime.parse("2006-06-06TZ"), registry));
Lock.executeWithLocks(
new Callable() {
@Override
diff --git a/javatests/google/registry/rde/PendingDepositCheckerTest.java b/javatests/google/registry/rde/PendingDepositCheckerTest.java
index dc7bbb13c..d1190946d 100644
--- a/javatests/google/registry/rde/PendingDepositCheckerTest.java
+++ b/javatests/google/registry/rde/PendingDepositCheckerTest.java
@@ -15,11 +15,11 @@
package google.registry.rde;
import static com.google.common.truth.Truth.assertThat;
+import static google.registry.model.common.Cursor.CursorType.BRDA;
+import static google.registry.model.common.Cursor.CursorType.RDE_STAGING;
import static google.registry.model.ofy.ObjectifyService.ofy;
import static google.registry.model.rde.RdeMode.FULL;
import static google.registry.model.rde.RdeMode.THIN;
-import static google.registry.model.registry.RegistryCursor.CursorType.BRDA;
-import static google.registry.model.registry.RegistryCursor.CursorType.RDE_STAGING;
import static google.registry.testing.DatastoreHelper.createTld;
import static google.registry.testing.DatastoreHelper.persistResource;
import static org.joda.time.DateTimeConstants.TUESDAY;
@@ -29,10 +29,10 @@ import com.google.common.collect.ImmutableSetMultimap;
import com.googlecode.objectify.VoidWork;
+import google.registry.model.common.Cursor;
+import google.registry.model.common.Cursor.CursorType;
import google.registry.model.ofy.Ofy;
import google.registry.model.registry.Registry;
-import google.registry.model.registry.RegistryCursor;
-import google.registry.model.registry.RegistryCursor.CursorType;
import google.registry.testing.AppEngineRule;
import google.registry.testing.FakeClock;
import google.registry.testing.InjectRule;
@@ -107,10 +107,10 @@ public class PendingDepositCheckerTest {
createTldWithEscrowEnabled("lol");
clock.advanceOneMilli();
Registry registry = Registry.get("lol");
- assertThat(RegistryCursor.load(registry, RDE_STAGING)).isAbsent();
+ assertThat(ofy().load().key(Cursor.createKey(RDE_STAGING, registry)).now()).isNull();
checker.getTldsAndWatermarksPendingDepositForRdeAndBrda();
- assertThat(RegistryCursor.load(registry, RDE_STAGING))
- .hasValue(DateTime.parse("2000-01-01TZ"));
+ assertThat(ofy().load().key(Cursor.createKey(RDE_STAGING, registry)).now().getCursorTime())
+ .isEqualTo(DateTime.parse("2000-01-01TZ"));
}
@Test
@@ -122,7 +122,8 @@ public class PendingDepositCheckerTest {
setCursor(Registry.get("lol"), RDE_STAGING, yesterday);
clock.advanceOneMilli();
checker.getTldsAndWatermarksPendingDepositForRdeAndBrda();
- assertThat(RegistryCursor.load(Registry.get("lol"), RDE_STAGING)).hasValue(yesterday);
+ Cursor cursor = ofy().load().key(Cursor.createKey(RDE_STAGING, Registry.get("lol"))).now();
+ assertThat(cursor.getCursorTime()).isEqualTo(yesterday);
}
@Test
@@ -134,9 +135,9 @@ public class PendingDepositCheckerTest {
clock.advanceOneMilli();
setCursor(registry, RDE_STAGING, DateTime.parse("2000-01-02TZ")); // assume rde is already done
clock.advanceOneMilli();
- assertThat(RegistryCursor.load(registry, BRDA)).isAbsent();
+ assertThat(ofy().load().key(Cursor.createKey(BRDA, registry)).now()).isNull();
assertThat(checker.getTldsAndWatermarksPendingDepositForRdeAndBrda()).isEmpty();
- assertThat(RegistryCursor.load(registry, BRDA)).isAbsent();
+ assertThat(ofy().load().key(Cursor.createKey(BRDA, registry)).now()).isNull();
}
@Test
@@ -173,7 +174,7 @@ public class PendingDepositCheckerTest {
ofy().transact(new VoidWork() {
@Override
public void vrun() {
- RegistryCursor.save(registry, cursorType, value);
+ ofy().save().entity(Cursor.create(cursorType, value, registry));
}});
}
diff --git a/javatests/google/registry/rde/RdeReportActionTest.java b/javatests/google/registry/rde/RdeReportActionTest.java
index 3d867cbd9..0a74b8d0e 100644
--- a/javatests/google/registry/rde/RdeReportActionTest.java
+++ b/javatests/google/registry/rde/RdeReportActionTest.java
@@ -17,6 +17,7 @@ package google.registry.rde;
import static com.google.appengine.api.urlfetch.HTTPMethod.PUT;
import static com.google.common.net.MediaType.PLAIN_TEXT_UTF_8;
import static com.google.common.truth.Truth.assertThat;
+import static google.registry.model.ofy.ObjectifyService.ofy;
import static google.registry.testing.DatastoreHelper.createTld;
import static google.registry.testing.DatastoreHelper.persistResource;
import static google.registry.testing.GcsTestingUtils.writeGcsFile;
@@ -43,9 +44,9 @@ import com.google.common.io.ByteSource;
import google.registry.config.RegistryConfig;
import google.registry.config.RegistryEnvironment;
import google.registry.gcs.GcsUtils;
+import google.registry.model.common.Cursor;
+import google.registry.model.common.Cursor.CursorType;
import google.registry.model.registry.Registry;
-import google.registry.model.registry.RegistryCursor;
-import google.registry.model.registry.RegistryCursor.CursorType;
import google.registry.request.HttpException.InternalServerErrorException;
import google.registry.testing.AppEngineRule;
import google.registry.testing.BouncyCastleProviderRule;
@@ -121,11 +122,13 @@ public class RdeReportActionTest {
public void before() throws Exception {
PGPPublicKey encryptKey = new RdeKeyringModule().get().getRdeStagingEncryptionKey();
createTld("test");
- persistResource(RegistryCursor.create(
- Registry.get("test"), CursorType.RDE_REPORT, DateTime.parse("2006-06-06TZ")));
- persistResource(RegistryCursor.create(
- Registry.get("test"), CursorType.RDE_UPLOAD, DateTime.parse("2006-06-07TZ")));
- writeGcsFile(gcsService, reportFile,
+ persistResource(
+ Cursor.create(CursorType.RDE_REPORT, DateTime.parse("2006-06-06TZ"), Registry.get("test")));
+ persistResource(
+ Cursor.create(CursorType.RDE_UPLOAD, DateTime.parse("2006-06-07TZ"), Registry.get("test")));
+ writeGcsFile(
+ gcsService,
+ reportFile,
Ghostryde.encode(REPORT_XML.read(), encryptKey, "darkside.xml", DateTime.now()));
}
@@ -184,7 +187,11 @@ public class RdeReportActionTest {
}
private DateTime loadRdeReportCursor() {
- return RegistryCursor.load(Registry.get("test"), CursorType.RDE_REPORT).get();
+ return ofy()
+ .load()
+ .key(Cursor.createKey(CursorType.RDE_REPORT, Registry.get("test")))
+ .now()
+ .getCursorTime();
}
private static ImmutableMap mapifyHeaders(Iterable headers) {
diff --git a/javatests/google/registry/rde/RdeStagingActionTest.java b/javatests/google/registry/rde/RdeStagingActionTest.java
index c840d3a3b..a2b03f3c0 100644
--- a/javatests/google/registry/rde/RdeStagingActionTest.java
+++ b/javatests/google/registry/rde/RdeStagingActionTest.java
@@ -15,9 +15,9 @@
package google.registry.rde;
import static com.google.common.truth.Truth.assertThat;
+import static google.registry.model.common.Cursor.CursorType.BRDA;
+import static google.registry.model.common.Cursor.CursorType.RDE_STAGING;
import static google.registry.model.ofy.ObjectifyService.ofy;
-import static google.registry.model.registry.RegistryCursor.CursorType.BRDA;
-import static google.registry.model.registry.RegistryCursor.CursorType.RDE_STAGING;
import static google.registry.rde.RdeFixtures.makeContactResource;
import static google.registry.rde.RdeFixtures.makeDomainResource;
import static google.registry.rde.RdeFixtures.makeHostResource;
@@ -46,11 +46,11 @@ import com.googlecode.objectify.VoidWork;
import google.registry.keyring.api.Keyring;
import google.registry.keyring.api.PgpHelper;
import google.registry.mapreduce.MapreduceRunner;
+import google.registry.model.common.Cursor;
+import google.registry.model.common.Cursor.CursorType;
import google.registry.model.host.HostResource;
import google.registry.model.ofy.Ofy;
import google.registry.model.registry.Registry;
-import google.registry.model.registry.RegistryCursor;
-import google.registry.model.registry.RegistryCursor.CursorType;
import google.registry.request.RequestParameters;
import google.registry.testing.FakeClock;
import google.registry.testing.FakeResponse;
@@ -295,10 +295,15 @@ public class RdeStagingActionTest extends MapreduceTestCase {
clock.setTo(DateTime.parse("2000-01-01TZ")); // Saturday
action.run();
executeTasksUntilEmpty("mapreduce", clock);
- assertThat(RegistryCursor.load(Registry.get("lol"), RDE_STAGING))
- .hasValue(DateTime.parse("2000-01-02TZ"));
- assertThat(RegistryCursor.load(Registry.get("lol"), BRDA))
- .hasValue(DateTime.parse("2000-01-04TZ"));
+ assertThat(
+ ofy()
+ .load()
+ .key(Cursor.createKey(RDE_STAGING, Registry.get("lol")))
+ .now()
+ .getCursorTime())
+ .isEqualTo(DateTime.parse("2000-01-02TZ"));
+ assertThat(ofy().load().key(Cursor.createKey(BRDA, Registry.get("lol"))).now().getCursorTime())
+ .isEqualTo(DateTime.parse("2000-01-04TZ"));
}
@Test
@@ -311,10 +316,15 @@ public class RdeStagingActionTest extends MapreduceTestCase {
clock.setTo(DateTime.parse("2000-01-04TZ")); // Tuesday
action.run();
executeTasksUntilEmpty("mapreduce", clock);
- assertThat(RegistryCursor.load(Registry.get("lol"), RDE_STAGING))
- .hasValue(DateTime.parse("2000-01-05TZ"));
- assertThat(RegistryCursor.load(Registry.get("lol"), BRDA))
- .hasValue(DateTime.parse("2000-01-11TZ"));
+ assertThat(
+ ofy()
+ .load()
+ .key(Cursor.createKey(RDE_STAGING, Registry.get("lol")))
+ .now()
+ .getCursorTime())
+ .isEqualTo(DateTime.parse("2000-01-05TZ"));
+ assertThat(ofy().load().key(Cursor.createKey(BRDA, Registry.get("lol"))).now().getCursorTime())
+ .isEqualTo(DateTime.parse("2000-01-11TZ"));
}
@Test
@@ -363,11 +373,14 @@ public class RdeStagingActionTest extends MapreduceTestCase {
.containsExactly("New Registrar", "The Registrar");
assertThat(mapifyCounts(header)).containsEntry(RdeResourceType.REGISTRAR.getUri(), 2L);
}
+
+ assertThat(
+ ofy().load().key(Cursor.createKey(RDE_STAGING, Registry.get("fop"))).now()
+ .getCursorTime())
+ .isEqualTo(DateTime.parse("1971-01-02TZ"));
- assertThat(RegistryCursor.load(Registry.get("fop"), RDE_STAGING))
- .hasValue(DateTime.parse("1971-01-02TZ"));
- assertThat(RegistryCursor.load(Registry.get("fop"), BRDA))
- .hasValue(DateTime.parse("1971-01-12TZ"));
+ assertThat(ofy().load().key(Cursor.createKey(BRDA, Registry.get("fop"))).now().getCursorTime())
+ .isEqualTo(DateTime.parse("1971-01-12TZ"));
}
@Test
@@ -561,8 +574,13 @@ public class RdeStagingActionTest extends MapreduceTestCase {
executeTasksUntilEmpty("mapreduce", clock);
String firstDeposit = readXml("lol_1984-12-18_full_S1_R0.xml.ghostryde");
assertThat(firstDeposit).doesNotContain("ns1.justine.lol");
- assertThat(RegistryCursor.load(Registry.get("lol"), RDE_STAGING))
- .hasValue(DateTime.parse("1984-12-19TZ"));
+ assertThat(
+ ofy()
+ .load()
+ .key(Cursor.createKey(RDE_STAGING, Registry.get("lol")))
+ .now()
+ .getCursorTime())
+ .isEqualTo(DateTime.parse("1984-12-19TZ"));
// Second mapreduce should emit the old version of host.
action.response = new FakeResponse();
@@ -572,8 +590,14 @@ public class RdeStagingActionTest extends MapreduceTestCase {
assertThat(secondDeposit).contains("ns1.justine.lol");
assertThat(secondDeposit).contains("feed::a:bee");
assertThat(secondDeposit).doesNotContain("dead:beef::cafe");
- assertThat(RegistryCursor.load(Registry.get("lol"), RDE_STAGING))
- .hasValue(DateTime.parse("1984-12-20TZ"));
+
+ assertThat(
+ ofy()
+ .load()
+ .key(Cursor.createKey(RDE_STAGING, Registry.get("lol")))
+ .now()
+ .getCursorTime())
+ .isEqualTo(DateTime.parse("1984-12-20TZ"));
// Third mapreduce emits current version of host.
action.response = new FakeResponse();
@@ -583,8 +607,13 @@ public class RdeStagingActionTest extends MapreduceTestCase {
assertThat(thirdDeposit).contains("ns1.justine.lol");
assertThat(thirdDeposit).doesNotContain("feed::a:bee");
assertThat(thirdDeposit).contains("dead:beef::cafe");
- assertThat(RegistryCursor.load(Registry.get("lol"), RDE_STAGING))
- .hasValue(DateTime.parse("1984-12-21TZ"));
+ assertThat(
+ ofy()
+ .load()
+ .key(Cursor.createKey(RDE_STAGING, Registry.get("lol")))
+ .now()
+ .getCursorTime())
+ .isEqualTo(DateTime.parse("1984-12-21TZ"));
}
private String readXml(String objectName) throws IOException, PGPException {
@@ -623,7 +652,7 @@ public class RdeStagingActionTest extends MapreduceTestCase {
ofy().transact(new VoidWork() {
@Override
public void vrun() {
- RegistryCursor.save(registry, cursorType, value);
+ ofy().save().entity(Cursor.create(cursorType, value, registry)).now();
}});
}
diff --git a/javatests/google/registry/rde/RdeUploadActionTest.java b/javatests/google/registry/rde/RdeUploadActionTest.java
index bd1d2b086..d29838934 100644
--- a/javatests/google/registry/rde/RdeUploadActionTest.java
+++ b/javatests/google/registry/rde/RdeUploadActionTest.java
@@ -47,10 +47,10 @@ import com.googlecode.objectify.VoidWork;
import google.registry.gcs.GcsUtils;
import google.registry.keyring.api.Keyring;
+import google.registry.model.common.Cursor;
+import google.registry.model.common.Cursor.CursorType;
import google.registry.model.rde.RdeRevision;
import google.registry.model.registry.Registry;
-import google.registry.model.registry.RegistryCursor;
-import google.registry.model.registry.RegistryCursor.CursorType;
import google.registry.rde.JSchSshSession.JSchSshSessionFactory;
import google.registry.request.HttpException.ServiceUnavailableException;
import google.registry.request.RequestParameters;
@@ -264,7 +264,7 @@ public class RdeUploadActionTest {
DateTime stagingCursor = DateTime.parse("2010-10-18TZ");
DateTime uploadCursor = DateTime.parse("2010-10-17TZ");
persistResource(
- RegistryCursor.create(Registry.get("tld"), CursorType.RDE_STAGING, stagingCursor));
+ Cursor.create(CursorType.RDE_STAGING, stagingCursor, Registry.get("tld")));
createAction(uploadUrl).runWithLock(uploadCursor);
assertThat(response.getStatus()).isEqualTo(200);
assertThat(response.getContentType()).isEqualTo(PLAIN_TEXT_UTF_8);
@@ -283,7 +283,7 @@ public class RdeUploadActionTest {
DateTime stagingCursor = DateTime.parse("2010-10-18TZ");
DateTime uploadCursor = DateTime.parse("2010-10-17TZ");
persistResource(
- RegistryCursor.create(Registry.get("tld"), CursorType.RDE_STAGING, stagingCursor));
+ Cursor.create(CursorType.RDE_STAGING, stagingCursor, Registry.get("tld")));
createAction(uploadUrl).runWithLock(uploadCursor);
assertThat(response.getStatus()).isEqualTo(200);
assertThat(response.getContentType()).isEqualTo(PLAIN_TEXT_UTF_8);
@@ -311,7 +311,7 @@ public class RdeUploadActionTest {
DateTime stagingCursor = DateTime.parse("2010-10-18TZ");
DateTime uploadCursor = DateTime.parse("2010-10-17TZ");
persistSimpleResource(
- RegistryCursor.create(Registry.get("tld"), CursorType.RDE_STAGING, stagingCursor));
+ Cursor.create(CursorType.RDE_STAGING, stagingCursor, Registry.get("tld")));
createAction(uploadUrl).runWithLock(uploadCursor);
assertThat(response.getStatus()).isEqualTo(200);
assertThat(response.getContentType()).isEqualTo(PLAIN_TEXT_UTF_8);
@@ -331,7 +331,7 @@ public class RdeUploadActionTest {
DateTime stagingCursor = DateTime.parse("2010-10-18TZ");
DateTime uploadCursor = DateTime.parse("2010-10-17TZ");
persistResource(
- RegistryCursor.create(Registry.get("tld"), CursorType.RDE_STAGING, stagingCursor));
+ Cursor.create(CursorType.RDE_STAGING, stagingCursor, Registry.get("tld")));
createAction(uploadUrl).runWithLock(uploadCursor);
// Only verify signature for SFTP versions, since we check elsewhere that the GCS files are
// identical to the ones sent over SFTP.
@@ -349,7 +349,7 @@ public class RdeUploadActionTest {
DateTime stagingCursor = DateTime.parse("2010-10-17TZ");
DateTime uploadCursor = DateTime.parse("2010-10-17TZ");
persistResource(
- RegistryCursor.create(Registry.get("tld"), CursorType.RDE_STAGING, stagingCursor));
+ Cursor.create(CursorType.RDE_STAGING, stagingCursor, Registry.get("tld")));
thrown.expect(ServiceUnavailableException.class, "Waiting for RdeStagingAction to complete");
createAction(null).runWithLock(uploadCursor);
}
diff --git a/javatests/google/registry/tools/ListCursorsCommandTest.java b/javatests/google/registry/tools/ListCursorsCommandTest.java
index d28616d4e..79fbe7a10 100644
--- a/javatests/google/registry/tools/ListCursorsCommandTest.java
+++ b/javatests/google/registry/tools/ListCursorsCommandTest.java
@@ -20,9 +20,9 @@ import static google.registry.testing.DatastoreHelper.persistResource;
import com.beust.jcommander.ParameterException;
+import google.registry.model.common.Cursor;
+import google.registry.model.common.Cursor.CursorType;
import google.registry.model.registry.Registry;
-import google.registry.model.registry.RegistryCursor;
-import google.registry.model.registry.RegistryCursor.CursorType;
import org.joda.time.DateTime;
import org.junit.Test;
@@ -39,8 +39,8 @@ public class ListCursorsCommandTest extends CommandTestCase
@Test
public void testListCursors_twoTldsOneAbsent_printsAbsentAndTimestampSorted() throws Exception {
createTlds("foo", "bar");
- persistResource(RegistryCursor.create(
- Registry.get("bar"), CursorType.BRDA, DateTime.parse("1984-12-18TZ")));
+ persistResource(
+ Cursor.create(CursorType.BRDA, DateTime.parse("1984-12-18TZ"), Registry.get("bar")));
runCommand("--type=BRDA");
assertThat(getStdoutAsLines())
.containsExactly(
diff --git a/javatests/google/registry/tools/UpdateCursorsCommandTest.java b/javatests/google/registry/tools/UpdateCursorsCommandTest.java
index 3e6946cde..9fa6e8210 100644
--- a/javatests/google/registry/tools/UpdateCursorsCommandTest.java
+++ b/javatests/google/registry/tools/UpdateCursorsCommandTest.java
@@ -15,12 +15,13 @@
package google.registry.tools;
import static com.google.common.truth.Truth.assertThat;
+import static google.registry.model.ofy.ObjectifyService.ofy;
import static google.registry.testing.DatastoreHelper.createTld;
import static google.registry.testing.DatastoreHelper.persistResource;
+import google.registry.model.common.Cursor;
+import google.registry.model.common.Cursor.CursorType;
import google.registry.model.registry.Registry;
-import google.registry.model.registry.RegistryCursor;
-import google.registry.model.registry.RegistryCursor.CursorType;
import org.joda.time.DateTime;
import org.junit.Before;
@@ -39,20 +40,19 @@ public class UpdateCursorsCommandTest extends CommandTestCase