mirror of
https://github.com/google/nomulus.git
synced 2025-06-27 14:54:51 +02:00
Cut RegistryCursor over to global cursors
------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=125797729
This commit is contained in:
parent
6fa1c2d91c
commit
14522eac0c
18 changed files with 195 additions and 152 deletions
|
@ -18,10 +18,10 @@ import static com.google.appengine.api.taskqueue.TaskOptions.Builder.withUrl;
|
|||
import static com.google.common.base.Verify.verify;
|
||||
import static com.google.common.net.MediaType.PLAIN_TEXT_UTF_8;
|
||||
import static com.jcraft.jsch.ChannelSftp.OVERWRITE;
|
||||
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 static java.nio.charset.StandardCharsets.UTF_8;
|
||||
import static java.util.Arrays.asList;
|
||||
|
||||
|
@ -35,11 +35,11 @@ import com.jcraft.jsch.JSch;
|
|||
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.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.EscrowTaskRunner.EscrowTask;
|
||||
import google.registry.rde.JSchSshSession.JSchSshSessionFactory;
|
||||
import google.registry.request.Action;
|
||||
|
@ -119,17 +119,17 @@ public final class RdeUploadAction implements Runnable, EscrowTask {
|
|||
|
||||
@Override
|
||||
public void runWithLock(DateTime watermark) throws Exception {
|
||||
DateTime stagingCursor =
|
||||
RegistryCursor.load(Registry.get(tld), CursorType.RDE_STAGING).or(START_OF_TIME);
|
||||
if (!stagingCursor.isAfter(watermark)) {
|
||||
logger.infofmt("tld=%s uploadCursor=%s stagingCursor=%s", tld, watermark, stagingCursor);
|
||||
DateTime stagingCursorTime = getCursorTimeOrStartOfTime(
|
||||
ofy().load().key(Cursor.createKey(CursorType.RDE_STAGING, Registry.get(tld))).now());
|
||||
if (!stagingCursorTime.isAfter(watermark)) {
|
||||
logger.infofmt("tld=%s uploadCursor=%s stagingCursor=%s", tld, watermark, stagingCursorTime);
|
||||
throw new ServiceUnavailableException("Waiting for RdeStagingAction to complete");
|
||||
}
|
||||
DateTime sftpCursor =
|
||||
RegistryCursor.load(Registry.get(tld), CursorType.RDE_UPLOAD_SFTP).or(START_OF_TIME);
|
||||
if (sftpCursor.plus(sftpCooldown).isAfter(clock.nowUtc())) {
|
||||
DateTime sftpCursorTime = getCursorTimeOrStartOfTime(
|
||||
ofy().load().key(Cursor.createKey(CursorType.RDE_UPLOAD_SFTP, Registry.get(tld))).now());
|
||||
if (sftpCursorTime.plus(sftpCooldown).isAfter(clock.nowUtc())) {
|
||||
// Fail the task good and hard so it retries until the cooldown passes.
|
||||
logger.infofmt("tld=%s cursor=%s sftpCursor=%s", tld, watermark, sftpCursor);
|
||||
logger.infofmt("tld=%s cursor=%s sftpCursor=%s", tld, watermark, sftpCursorTime);
|
||||
throw new ServiceUnavailableException("SFTP cooldown has not yet passed");
|
||||
}
|
||||
int revision = RdeRevision.getNextRevision(tld, watermark, FULL) - 1;
|
||||
|
@ -145,8 +145,10 @@ public final class RdeUploadAction implements Runnable, EscrowTask {
|
|||
ofy().transact(new VoidWork() {
|
||||
@Override
|
||||
public void vrun() {
|
||||
RegistryCursor.save(
|
||||
Registry.get(tld), CursorType.RDE_UPLOAD_SFTP, ofy().getTransactionTime());
|
||||
Cursor cursor =
|
||||
Cursor.create(
|
||||
CursorType.RDE_UPLOAD_SFTP, ofy().getTransactionTime(), Registry.get(tld));
|
||||
ofy().save().entity(cursor).now();
|
||||
}
|
||||
});
|
||||
response.setContentType(PLAIN_TEXT_UTF_8);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue