// Copyright 2016 The Nomulus Authors. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package google.registry.model.common; import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkNotNull; import static google.registry.model.common.EntityGroupRoot.getCrossTldKey; import static google.registry.model.ofy.ObjectifyService.ofy; import static google.registry.util.DateTimeUtils.START_OF_TIME; import com.googlecode.objectify.Key; import com.googlecode.objectify.annotation.Entity; import com.googlecode.objectify.annotation.Id; import com.googlecode.objectify.annotation.Parent; import google.registry.model.ImmutableObject; import google.registry.model.registry.Registry; import org.joda.time.DateTime; /** * Shared entity for date cursors. This type supports both "scoped" cursors (i.e. per resource * of a given type, such as a TLD) and global (i.e. one per environment) cursors, defined internally * as scoped on {@link EntityGroupRoot}. */ @Entity public class Cursor extends ImmutableObject { /** The types of cursors, used as the string id field for each cursor in datastore. */ public enum CursorType { /** Cursor for ensuring rolling transactional isolation of BRDA staging operation. */ BRDA(Registry.class), /** Cursor for ensuring rolling transactional isolation of RDE report operation. */ RDE_REPORT(Registry.class), /** Cursor for ensuring rolling transactional isolation of RDE staging operation. */ RDE_STAGING(Registry.class), /** Cursor for ensuring rolling transactional isolation of RDE upload operation. */ RDE_UPLOAD(Registry.class), /** * Cursor that tracks the last time we talked to the escrow provider's SFTP server for a given * TLD. * *
Our escrow provider has an odd feature where separate deposits uploaded within two hours * of each other will be merged into a single deposit. This is problematic in situations where * the cursor might be a few days behind and is trying to catch up. * *
The way we solve this problem is by having {@code RdeUploadAction} check this cursor
* before performing an upload for a given TLD. If the cursor is less than two hours old, the
* action will fail with a status code above 300 and App Engine will keep retrying the action
* until it's ready.
*/
RDE_UPLOAD_SFTP(Registry.class),
/**
* Cursor for ensuring rolling transactional isolation of recurring billing expansion. The
* value of this cursor represents the exclusive upper bound on the range of billing times
* for which Recurring billing events have been expanded (i.e. the inclusive first billing time
* for the next expansion job).
*/
RECURRING_BILLING(EntityGroupRoot.class);
/** See the definition of scope on {@link #getScopeClass}. */
private final Class extends ImmutableObject> scope;
private CursorType(Class extends ImmutableObject> scope) {
this.scope = scope;
}
/**
* If there are multiple cursors for a given cursor type, a cursor must also have a scope
* defined (distinct from a parent, which is always the EntityGroupRoot key). For instance,
* for a cursor that is defined at the registry level, the scope type will be Registry.class.
* For a cursor (theoretically) defined for each EPP resource, the scope type will be
* EppResource.class. For a global cursor, i.e. one that applies per environment, this will be
* {@link EntityGroupRoot}.
*/
public Class> getScopeClass() {
return scope;
}
}
@Parent
Key