Cut RegistryCursor over to global cursors

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=125797729
This commit is contained in:
ctingue 2016-06-24 11:12:46 -07:00 committed by Ben McIlwain
parent 6fa1c2d91c
commit 14522eac0c
18 changed files with 195 additions and 152 deletions

View file

@ -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<DateTime> 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));
}
}
}