Remove all vestiges of memcache

Memcache is already off but now it's not in the code anymore.

This includes removing domain creation failfast, since that is actually
slower now than just running the flow - all you gain is a non-transactional
read over a transactional read, but the cost is that you always pay that
read, which is going to drive up latency.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=158183506
This commit is contained in:
cgoldfeder 2017-06-06 13:43:42 -07:00 committed by Ben McIlwain
parent 445faab977
commit ae039aa0d8
37 changed files with 29 additions and 341 deletions

View file

@ -20,7 +20,6 @@ import static google.registry.flows.FlowUtils.validateClientIsLoggedIn;
import static google.registry.flows.ResourceFlowUtils.verifyResourceDoesNotExist;
import static google.registry.flows.domain.DomainFlowUtils.cloneAndLinkReferences;
import static google.registry.flows.domain.DomainFlowUtils.createFeeCreateResponse;
import static google.registry.flows.domain.DomainFlowUtils.failfastForCreate;
import static google.registry.flows.domain.DomainFlowUtils.getReservationTypes;
import static google.registry.flows.domain.DomainFlowUtils.prepareMarkedLrpTokenEntity;
import static google.registry.flows.domain.DomainFlowUtils.validateCreateCommandContactsAndNameservers;
@ -139,7 +138,6 @@ public class DomainAllocateFlow implements TransactionalFlow {
validateClientIsLoggedIn(clientId);
verifyIsSuperuser();
DateTime now = ofy().getTransactionTime();
failfastForCreate(targetId, now);
Create command = cloneAndLinkReferences((Create) resourceCommand, now);
verifyResourceDoesNotExist(DomainResource.class, targetId, now);
InternetDomainName domainName = validateDomainName(command.getFullyQualifiedDomainName());

View file

@ -21,7 +21,6 @@ import static google.registry.flows.ResourceFlowUtils.verifyResourceDoesNotExist
import static google.registry.flows.domain.DomainFlowUtils.checkAllowedAccessToTld;
import static google.registry.flows.domain.DomainFlowUtils.cloneAndLinkReferences;
import static google.registry.flows.domain.DomainFlowUtils.createFeeCreateResponse;
import static google.registry.flows.domain.DomainFlowUtils.failfastForCreate;
import static google.registry.flows.domain.DomainFlowUtils.prepareMarkedLrpTokenEntity;
import static google.registry.flows.domain.DomainFlowUtils.validateCreateCommandContactsAndNameservers;
import static google.registry.flows.domain.DomainFlowUtils.validateDomainName;
@ -195,7 +194,6 @@ public final class DomainApplicationCreateFlow implements TransactionalFlow {
extensionManager.validate();
validateClientIsLoggedIn(clientId);
DateTime now = ofy().getTransactionTime();
failfastForCreate(targetId, now);
Create command = cloneAndLinkReferences((Create) resourceCommand, now);
// Fail if the domain is already registered (e.g. this is a landrush application but the domain
// was awarded at the end of sunrise). However, multiple domain applications can be created for

View file

@ -89,7 +89,7 @@ public final class DomainApplicationInfoFlow implements Flow {
throw new MissingApplicationIdException();
}
DomainApplication application =
ofy().loadWithMemcache().key(Key.create(DomainApplication.class, applicationId)).now();
ofy().load().key(Key.create(DomainApplication.class, applicationId)).now();
verifyExistence(
DomainApplication.class,
applicationId,
@ -106,7 +106,7 @@ public final class DomainApplicationInfoFlow implements Flow {
verifyResourceOwnership(clientId, application);
boolean showDelegatedHosts = ((Info) resourceCommand).getHostsRequest().requestDelegated();
// Prefetch all referenced resources. Calling values() blocks until loading is done.
ofy().loadWithMemcache()
ofy().load()
.values(union(application.getNameservers(), application.getReferencedContacts())).values();
return responseBuilder
.setResData(DomainInfoData.newBuilder()
@ -114,7 +114,7 @@ public final class DomainApplicationInfoFlow implements Flow {
.setRepoId(application.getRepoId())
.setStatusValues(application.getStatusValues())
.setRegistrant(
ofy().loadWithMemcache().key(application.getRegistrant()).now().getContactId())
ofy().load().key(application.getRegistrant()).now().getContactId())
.setContacts(loadForeignKeyedDesignatedContacts(application.getContacts()))
.setNameservers(showDelegatedHosts
? application.loadNameserverFullyQualifiedHostNames()

View file

@ -20,7 +20,6 @@ import static google.registry.flows.ResourceFlowUtils.verifyResourceDoesNotExist
import static google.registry.flows.domain.DomainFlowUtils.checkAllowedAccessToTld;
import static google.registry.flows.domain.DomainFlowUtils.cloneAndLinkReferences;
import static google.registry.flows.domain.DomainFlowUtils.createFeeCreateResponse;
import static google.registry.flows.domain.DomainFlowUtils.failfastForCreate;
import static google.registry.flows.domain.DomainFlowUtils.prepareMarkedLrpTokenEntity;
import static google.registry.flows.domain.DomainFlowUtils.validateCreateCommandContactsAndNameservers;
import static google.registry.flows.domain.DomainFlowUtils.validateDomainAllowedOnCreateRestrictedTld;
@ -193,7 +192,6 @@ public class DomainCreateFlow implements TransactionalFlow {
extensionManager.validate();
validateClientIsLoggedIn(clientId);
DateTime now = ofy().getTransactionTime();
failfastForCreate(targetId, now);
Create command = cloneAndLinkReferences((Create) resourceCommand, now);
Period period = command.getPeriod();
verifyUnitIsYears(period);

View file

@ -22,7 +22,6 @@ import static com.google.common.collect.Sets.difference;
import static com.google.common.collect.Sets.intersection;
import static com.google.common.collect.Sets.union;
import static google.registry.flows.domain.DomainPricingLogic.getMatchingLrpToken;
import static google.registry.model.EppResourceUtils.loadByForeignKeyWithMemcache;
import static google.registry.model.domain.DomainResource.MAX_REGISTRATION_YEARS;
import static google.registry.model.ofy.ObjectifyService.ofy;
import static google.registry.model.registry.Registries.findTldForName;
@ -48,7 +47,6 @@ import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Sets;
import com.google.common.net.InternetDomainName;
import com.googlecode.objectify.Key;
import com.googlecode.objectify.Work;
import google.registry.flows.EppException;
import google.registry.flows.EppException.AuthorizationErrorException;
import google.registry.flows.EppException.CommandUseErrorException;
@ -60,7 +58,6 @@ import google.registry.flows.EppException.ParameterValueSyntaxErrorException;
import google.registry.flows.EppException.RequiredParameterMissingException;
import google.registry.flows.EppException.StatusProhibitsOperationException;
import google.registry.flows.EppException.UnimplementedOptionException;
import google.registry.flows.exceptions.ResourceAlreadyExistsException;
import google.registry.flows.exceptions.ResourceHasClientUpdateProhibitedException;
import google.registry.model.EppResource;
import google.registry.model.billing.BillingEvent;
@ -90,7 +87,6 @@ import google.registry.model.domain.launch.LaunchExtension;
import google.registry.model.domain.launch.LaunchNotice;
import google.registry.model.domain.launch.LaunchNotice.InvalidChecksumException;
import google.registry.model.domain.launch.LaunchPhase;
import google.registry.model.domain.rgp.GracePeriodStatus;
import google.registry.model.domain.secdns.DelegationSignerData;
import google.registry.model.domain.secdns.SecDnsCreateExtension;
import google.registry.model.domain.secdns.SecDnsInfoExtension;
@ -432,8 +428,6 @@ public class DomainFlowUtils {
static void verifyPremiumNameIsNotBlocked(
String domainName, DateTime priceTime, String clientId) throws EppException {
if (isDomainPremium(domainName, priceTime)) {
// NB: The load of the Registar object is transactionless, which means that it should hit
// memcache most of the time.
if (Registrar.loadByClientIdCached(clientId).getBlockPremiumNames()) {
throw new PremiumNameBlockedException();
}
@ -783,36 +777,6 @@ public class DomainFlowUtils {
validateNameserversAllowedOnDomain(domainName, fullyQualifiedHostNames);
}
/**
* Fail a domain or application create very fast if the domain is already registered.
*
* <p>Try to load the domain non-transactionally, since this can hit memcache. If we succeed, and
* the domain is not in the add grace period (the only state that allows instantaneous transition
* to being deleted), we can assume that the domain will not be deleted (and therefore won't be
* creatable) until its deletion time. For repeated failed creates this means we can avoid the
* Datastore lookup, which is very expensive (and first-seen failed creates are no worse than they
* otherwise would be). This comes at the cost of the extra lookup for successful creates (or
* rather, those that don't fail due to the domain existing) and also for failed creates within
* the existing domain's add grace period.
*/
static void failfastForCreate(final String targetId, final DateTime now) throws EppException {
// Enter a transactionless context briefly.
DomainResource domain = ofy().doTransactionless(new Work<DomainResource>() {
@Override
public DomainResource run() {
// We want to load the ForeignKeyIndex and DomainResource from memcache if possible so that
// repeated create attempts of the same domain will not put load on datastore. This is safe
// because this is only a failfast method, and if memcache is stale the worst case scenario
// is that we will fall through to the regular transactional flow and fail there.
return loadByForeignKeyWithMemcache(DomainResource.class, targetId, now);
}});
// If the domain exists already and isn't in the add grace period then there is no way it will
// be suddenly deleted and therefore the create must fail.
if (domain != null && !domain.getGracePeriodStatuses().contains(GracePeriodStatus.ADD)) {
throw new ResourceAlreadyExistsException(targetId, true);
}
}
/** Validate the secDNS extension, if present. */
static SecDnsCreateExtension validateSecDnsExtension(SecDnsCreateExtension secDnsCreate)
throws EppException {

View file

@ -21,7 +21,7 @@ import static google.registry.flows.ResourceFlowUtils.verifyOptionalAuthInfo;
import static google.registry.flows.domain.DomainFlowUtils.addSecDnsExtensionIfPresent;
import static google.registry.flows.domain.DomainFlowUtils.handleFeeRequest;
import static google.registry.flows.domain.DomainFlowUtils.loadForeignKeyedDesignatedContacts;
import static google.registry.model.EppResourceUtils.loadByForeignKeyWithMemcache;
import static google.registry.model.EppResourceUtils.loadByForeignKey;
import static google.registry.model.ofy.ObjectifyService.ofy;
import com.google.common.base.Optional;
@ -96,13 +96,11 @@ public final class DomainInfoFlow implements Flow {
validateClientIsLoggedIn(clientId);
DateTime now = clock.nowUtc();
DomainResource domain = verifyExistence(
DomainResource.class,
targetId,
loadByForeignKeyWithMemcache(DomainResource.class, targetId, now));
DomainResource.class, targetId, loadByForeignKey(DomainResource.class, targetId, now));
verifyOptionalAuthInfo(authInfo, domain);
customLogic.afterValidation(AfterValidationParameters.newBuilder().setDomain(domain).build());
// Prefetch all referenced resources. Calling values() blocks until loading is done.
ofy().loadWithMemcache()
ofy().load()
.values(union(domain.getNameservers(), domain.getReferencedContacts())).values();
// Registrars can only see a few fields on unauthorized domains.
// This is a policy decision that is left up to us by the rfcs.
@ -110,7 +108,7 @@ public final class DomainInfoFlow implements Flow {
.setFullyQualifiedDomainName(domain.getFullyQualifiedDomainName())
.setRepoId(domain.getRepoId())
.setCurrentSponsorClientId(domain.getCurrentSponsorClientId())
.setRegistrant(ofy().loadWithMemcache().key(domain.getRegistrant()).now().getContactId());
.setRegistrant(ofy().load().key(domain.getRegistrant()).now().getContactId());
// If authInfo is non-null, then the caller is authorized to see the full information since we
// will have already verified the authInfo is valid.
if (clientId.equals(domain.getCurrentSponsorClientId()) || authInfo.isPresent()) {

View file

@ -14,26 +14,11 @@
package google.registry.flows.exceptions;
import com.google.common.annotations.VisibleForTesting;
import google.registry.flows.EppException.ObjectAlreadyExistsException;
/** Resource with this id already exists. */
public class ResourceAlreadyExistsException extends ObjectAlreadyExistsException {
/** Whether this was thrown from a "failfast" context. Useful for testing. */
final boolean failfast;
public ResourceAlreadyExistsException(String resourceId, boolean failfast) {
super(String.format("Object with given ID (%s) already exists", resourceId));
this.failfast = failfast;
}
public ResourceAlreadyExistsException(String resourceId) {
this(resourceId, false);
}
@VisibleForTesting
public boolean isFailfast() {
return failfast;
super(String.format("Object with given ID (%s) already exists", resourceId));
}
}

View file

@ -24,7 +24,6 @@ import static google.registry.util.DateTimeUtils.latestOf;
import com.google.common.base.Function;
import com.googlecode.objectify.Key;
import com.googlecode.objectify.Result;
import com.googlecode.objectify.cmd.Loader;
import com.googlecode.objectify.cmd.Query;
import com.googlecode.objectify.util.ResultNow;
import google.registry.model.EppResource.Builder;
@ -93,41 +92,16 @@ public final class EppResourceUtils {
@Nullable
public static <T extends EppResource> T loadByForeignKey(
Class<T> clazz, String foreignKey, DateTime now) {
return loadByForeignKeyInternal(clazz, foreignKey, now, false);
}
/**
* Loads the last created version of an {@link EppResource} from Datastore or memcache.
*
* <p>In general, prefer {@link #loadByForeignKey} over this method. Loading from memcache can, in
* rare instances, produce a stale result (when a memcache write fails and the previous result is
* not cleared out) and so using memcache should be avoided unless the caller can tolerate
* staleness until the memcache expiration time and there is a specific need for very low latency
* that is worth the extra complexity of reasoning about caching.
*
* @param clazz the resource type to load
* @param foreignKey id to match
* @param now the current logical time to project resources at
*/
@Nullable
public static <T extends EppResource> T loadByForeignKeyWithMemcache(
Class<T> clazz, String foreignKey, DateTime now) {
return loadByForeignKeyInternal(clazz, foreignKey, now, true);
}
@Nullable
private static <T extends EppResource> T loadByForeignKeyInternal(
Class<T> clazz, String foreignKey, DateTime now, boolean useMemcache) {
checkArgument(
ForeignKeyedEppResource.class.isAssignableFrom(clazz),
"loadByForeignKey may only be called for foreign keyed EPP resources");
Loader loader = useMemcache ? ofy().loadWithMemcache() : ofy().load();
ForeignKeyIndex<T> fki = loader.type(ForeignKeyIndex.mapToFkiClass(clazz)).id(foreignKey).now();
ForeignKeyIndex<T> fki =
ofy().load().type(ForeignKeyIndex.mapToFkiClass(clazz)).id(foreignKey).now();
// The value of fki.getResourceKey() might be null for hard-deleted prober data.
if (fki == null || isAtOrAfter(now, fki.getDeletionTime()) || fki.getResourceKey() == null) {
return null;
}
T resource = loader.key(fki.getResourceKey()).now();
T resource = ofy().load().key(fki.getResourceKey()).now();
if (resource == null || isAtOrAfter(now, resource.getDeletionTime())) {
return null;
}

View file

@ -16,14 +16,12 @@ package google.registry.model.contact;
import static com.google.common.base.Preconditions.checkArgument;
import static google.registry.model.EppResourceUtils.projectResourceOntoBuilderAtTime;
import static google.registry.model.ofy.Ofy.RECOMMENDED_MEMCACHE_EXPIRATION;
import com.google.common.base.Optional;
import com.google.common.base.Predicates;
import com.google.common.collect.FluentIterable;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
import com.googlecode.objectify.annotation.Cache;
import com.googlecode.objectify.annotation.Entity;
import com.googlecode.objectify.annotation.IgnoreSave;
import com.googlecode.objectify.annotation.Index;
@ -43,7 +41,6 @@ import org.joda.time.DateTime;
*
* @see <a href="https://tools.ietf.org/html/rfc5733">RFC 5733</a>
*/
@Cache(expirationSeconds = RECOMMENDED_MEMCACHE_EXPIRATION)
@ReportedOn
@Entity
@ExternalMessagingName("contact")

View file

@ -15,11 +15,9 @@
package google.registry.model.domain;
import static google.registry.model.ofy.ObjectifyService.ofy;
import static google.registry.model.ofy.Ofy.RECOMMENDED_MEMCACHE_EXPIRATION;
import static google.registry.util.CollectionUtils.nullToEmptyImmutableCopy;
import com.google.common.collect.ImmutableList;
import com.googlecode.objectify.annotation.Cache;
import com.googlecode.objectify.annotation.EntitySubclass;
import com.googlecode.objectify.annotation.OnLoad;
import google.registry.model.annotations.ExternalMessagingName;
@ -37,7 +35,6 @@ import org.joda.money.Money;
import org.joda.time.DateTime;
/** An application to create a domain. */
@Cache(expirationSeconds = RECOMMENDED_MEMCACHE_EXPIRATION)
@EntitySubclass(index = true)
@ExternalMessagingName("application")
public class DomainApplication extends DomainBase {

View file

@ -17,7 +17,6 @@
import static com.google.common.collect.Sets.intersection;
import static google.registry.model.EppResourceUtils.projectResourceOntoBuilderAtTime;
import static google.registry.model.EppResourceUtils.setAutomaticTransferSuccessProperties;
import static google.registry.model.ofy.Ofy.RECOMMENDED_MEMCACHE_EXPIRATION;
import static google.registry.util.CollectionUtils.difference;
import static google.registry.util.CollectionUtils.nullToEmptyImmutableCopy;
import static google.registry.util.CollectionUtils.union;
@ -28,7 +27,6 @@ import static google.registry.util.DateTimeUtils.leapSafeAddYears;
import com.google.common.base.Optional;
import com.google.common.collect.ImmutableSet;
import com.googlecode.objectify.Key;
import com.googlecode.objectify.annotation.Cache;
import com.googlecode.objectify.annotation.EntitySubclass;
import com.googlecode.objectify.annotation.IgnoreSave;
import com.googlecode.objectify.condition.IfNull;
@ -53,7 +51,6 @@ import org.joda.time.Interval;
*
* @see <a href="https://tools.ietf.org/html/rfc5731">RFC 5731</a>
*/
@Cache(expirationSeconds = RECOMMENDED_MEMCACHE_EXPIRATION)
@EntitySubclass(index = true)
@ExternalMessagingName("domain")
public class DomainResource extends DomainBase

View file

@ -17,7 +17,6 @@ package google.registry.model.host;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.collect.Sets.difference;
import static com.google.common.collect.Sets.union;
import static google.registry.model.ofy.Ofy.RECOMMENDED_MEMCACHE_EXPIRATION;
import static google.registry.util.CollectionUtils.nullToEmptyImmutableCopy;
import static google.registry.util.DateTimeUtils.START_OF_TIME;
import static google.registry.util.DomainNameUtils.canonicalizeDomainName;
@ -25,7 +24,6 @@ import static google.registry.util.DomainNameUtils.canonicalizeDomainName;
import com.google.common.base.Optional;
import com.google.common.collect.ImmutableSet;
import com.googlecode.objectify.Key;
import com.googlecode.objectify.annotation.Cache;
import com.googlecode.objectify.annotation.Entity;
import com.googlecode.objectify.annotation.IgnoreSave;
import com.googlecode.objectify.annotation.Index;
@ -49,7 +47,6 @@ import org.joda.time.DateTime;
*
* @see <a href="https://tools.ietf.org/html/rfc5732">RFC 5732</a>
*/
@Cache(expirationSeconds = RECOMMENDED_MEMCACHE_EXPIRATION)
@ReportedOn
@Entity
@ExternalMessagingName("host")

View file

@ -17,12 +17,10 @@ package google.registry.model.index;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Strings.isNullOrEmpty;
import static google.registry.model.ofy.ObjectifyService.ofy;
import static google.registry.model.ofy.Ofy.RECOMMENDED_MEMCACHE_EXPIRATION;
import static google.registry.util.CollectionUtils.isNullOrEmpty;
import com.google.common.collect.ImmutableSet;
import com.googlecode.objectify.Key;
import com.googlecode.objectify.annotation.Cache;
import com.googlecode.objectify.annotation.Entity;
import com.googlecode.objectify.annotation.Id;
import google.registry.model.BackupGroupRoot;
@ -40,7 +38,6 @@ import org.joda.time.DateTime;
*/
@ReportedOn
@Entity
@Cache(expirationSeconds = RECOMMENDED_MEMCACHE_EXPIRATION)
public class DomainApplicationIndex extends BackupGroupRoot {
@Id

View file

@ -16,14 +16,12 @@ package google.registry.model.index;
import static com.google.common.collect.Maps.filterValues;
import static google.registry.model.ofy.ObjectifyService.ofy;
import static google.registry.model.ofy.Ofy.RECOMMENDED_MEMCACHE_EXPIRATION;
import static google.registry.util.TypeUtils.instantiate;
import com.google.common.base.Predicate;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.googlecode.objectify.Key;
import com.googlecode.objectify.annotation.Cache;
import com.googlecode.objectify.annotation.Entity;
import com.googlecode.objectify.annotation.Id;
import com.googlecode.objectify.annotation.Index;
@ -45,19 +43,16 @@ import org.joda.time.DateTime;
public abstract class ForeignKeyIndex<E extends EppResource> extends BackupGroupRoot {
/** The {@link ForeignKeyIndex} type for {@link ContactResource} entities. */
@Cache(expirationSeconds = RECOMMENDED_MEMCACHE_EXPIRATION)
@ReportedOn
@Entity
public static class ForeignKeyContactIndex extends ForeignKeyIndex<ContactResource> {}
/** The {@link ForeignKeyIndex} type for {@link DomainResource} entities. */
@Cache(expirationSeconds = RECOMMENDED_MEMCACHE_EXPIRATION)
@ReportedOn
@Entity
public static class ForeignKeyDomainIndex extends ForeignKeyIndex<DomainResource> {}
/** The {@link ForeignKeyIndex} type for {@link HostResource} entities. */
@Cache(expirationSeconds = RECOMMENDED_MEMCACHE_EXPIRATION)
@ReportedOn
@Entity
public static class ForeignKeyHostIndex extends ForeignKeyIndex<HostResource> {}

View file

@ -14,7 +14,6 @@
package google.registry.model.ofy;
import static com.google.appengine.api.memcache.ErrorHandlers.getConsistentLogAndContinue;
import static com.google.common.base.Preconditions.checkState;
import static com.google.common.base.Predicates.not;
import static com.googlecode.objectify.ObjectifyService.factory;
@ -46,7 +45,6 @@ import google.registry.model.translators.InetAddressTranslatorFactory;
import google.registry.model.translators.ReadableInstantUtcTranslatorFactory;
import google.registry.model.translators.UpdateAutoTimestampTranslatorFactory;
import java.util.concurrent.atomic.AtomicLong;
import java.util.logging.Level;
/**
* An instance of Ofy, obtained via {@code #ofy()}, should be used to access all persistable
@ -114,9 +112,6 @@ public class ObjectifyService {
// Translators must be registered before any entities can be registered.
registerTranslators();
registerEntityClasses(EntityClasses.ALL_CLASSES);
// Set the memcache error handler so that we don't see internally logged errors.
factory().setMemcacheErrorHandler(getConsistentLogAndContinue(Level.INFO));
}
/** Register translators that allow less common types to be stored directly in Datastore. */

View file

@ -63,15 +63,6 @@ public class Ofy {
private static final FormattingLogger logger = FormattingLogger.getLoggerForCallerClass();
/**
* Recommended memcache expiration time, which is one hour, specified in seconds.
*
* <p>This value should used as a cache expiration time for any entities annotated with an
* Objectify {@code @Cache} annotation, to put an upper bound on unlikely-but-possible divergence
* between memcache and Datastore when a memcache write fails.
*/
public static final int RECOMMENDED_MEMCACHE_EXPIRATION = 3600;
/** Default clock for transactions that don't provide one. */
@NonFinalForTesting
static Clock clock = new SystemClock();
@ -130,31 +121,9 @@ public class Ofy {
checkState(inTransaction(), "Must be called in a transaction");
}
/**
* Load from Datastore, bypassing memcache even when the results might be there.
*
* <p>In general, this is the correct method to use for loads. Loading from memcache can, in rare
* instances, produce a stale result (when a memcache write fails and the previous result is not
* cleared out) and so using memcache should be avoided unless the caller can tolerate staleness
* until the memcache expiration time and there is a specific need for very low latency that is
* worth the extra complexity of reasoning about caching.
*/
/** Load from Datastore. */
public Loader load() {
return ofy().cache(false).load();
}
/**
* Load from Datastore, bypassing memcache even when the results might be there.
*
* <p>In general, prefer {@link #load} over this method. Loading from memcache can, in rare
* instances, produce a stale result (when a memcache write fails and the previous result is not
* cleared out) and so using memcache should be avoided unless the caller can tolerate staleness
* until the memcache expiration time and there is a specific need for very low latency that is
* worth the extra complexity of reasoning about caching.
*/
public Loader loadWithMemcache() {
// TODO(b/27424173): Remove this method if we determine we are ok with no memcache.
return ofy().cache(false).load();
return ofy().load();
}
/**

View file

@ -28,7 +28,6 @@ import static google.registry.config.RegistryConfig.getDefaultRegistrarWhoisServ
import static google.registry.model.CacheUtils.memoizeWithShortExpiration;
import static google.registry.model.common.EntityGroupRoot.getCrossTldKey;
import static google.registry.model.ofy.ObjectifyService.ofy;
import static google.registry.model.ofy.Ofy.RECOMMENDED_MEMCACHE_EXPIRATION;
import static google.registry.model.registry.Registries.assertTldsExist;
import static google.registry.util.CollectionUtils.nullToEmptyImmutableCopy;
import static google.registry.util.CollectionUtils.nullToEmptyImmutableSortedCopy;
@ -50,7 +49,6 @@ import com.google.common.collect.Sets;
import com.google.re2j.Pattern;
import com.googlecode.objectify.Key;
import com.googlecode.objectify.Work;
import com.googlecode.objectify.annotation.Cache;
import com.googlecode.objectify.annotation.Embed;
import com.googlecode.objectify.annotation.Entity;
import com.googlecode.objectify.annotation.Id;
@ -85,7 +83,6 @@ import org.joda.money.CurrencyUnit;
import org.joda.time.DateTime;
/** Information about a registrar. */
@Cache(expirationSeconds = RECOMMENDED_MEMCACHE_EXPIRATION)
@ReportedOn
@Entity
public class Registrar extends ImmutableObject implements Buildable, Jsonifiable {

View file

@ -19,7 +19,6 @@ import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.collect.Iterables.transform;
import static com.google.common.collect.Sets.difference;
import static google.registry.model.ofy.ObjectifyService.ofy;
import static google.registry.model.ofy.Ofy.RECOMMENDED_MEMCACHE_EXPIRATION;
import static google.registry.util.CollectionUtils.nullToEmptyImmutableSortedCopy;
import static google.registry.util.ObjectifyUtils.OBJECTS_TO_KEYS;
@ -30,7 +29,6 @@ import com.google.common.collect.ImmutableSet;
import com.google.common.collect.ImmutableSortedSet;
import com.googlecode.objectify.Key;
import com.googlecode.objectify.VoidWork;
import com.googlecode.objectify.annotation.Cache;
import com.googlecode.objectify.annotation.Entity;
import com.googlecode.objectify.annotation.Id;
import com.googlecode.objectify.annotation.Index;
@ -52,7 +50,6 @@ import java.util.Set;
* *MUST* also modify the persisted Registrar entity with {@link Registrar#contactsRequireSyncing}
* set to true.
*/
@Cache(expirationSeconds = RECOMMENDED_MEMCACHE_EXPIRATION)
@ReportedOn
@Entity
public class RegistrarContact extends ImmutableObject implements Jsonifiable {

View file

@ -21,7 +21,6 @@ import static com.google.common.base.Predicates.not;
import static google.registry.config.RegistryConfig.getSingletonCacheRefreshDuration;
import static google.registry.model.common.EntityGroupRoot.getCrossTldKey;
import static google.registry.model.ofy.ObjectifyService.ofy;
import static google.registry.model.ofy.Ofy.RECOMMENDED_MEMCACHE_EXPIRATION;
import static google.registry.util.CollectionUtils.nullToEmptyImmutableCopy;
import static google.registry.util.DateTimeUtils.END_OF_TIME;
import static google.registry.util.DateTimeUtils.START_OF_TIME;
@ -46,7 +45,6 @@ import com.google.common.collect.Range;
import com.google.common.net.InternetDomainName;
import com.googlecode.objectify.Key;
import com.googlecode.objectify.Work;
import com.googlecode.objectify.annotation.Cache;
import com.googlecode.objectify.annotation.Embed;
import com.googlecode.objectify.annotation.Entity;
import com.googlecode.objectify.annotation.Id;
@ -78,7 +76,6 @@ import org.joda.time.Duration;
import org.joda.time.Interval;
/** Persisted per-TLD configuration data. */
@Cache(expirationSeconds = RECOMMENDED_MEMCACHE_EXPIRATION)
@ReportedOn
@Entity
public class Registry extends ImmutableObject implements Buildable {
@ -245,12 +242,12 @@ public class Registry extends ImmutableObject implements Buildable {
@Override
public Optional<Registry> load(final String tld) {
// Enter a transactionless context briefly; we don't want to enroll every TLD in a
// transaction that might be wrapping this call, and memcached results are fine here
// transaction that might be wrapping this call.
return Optional.fromNullable(ofy().doTransactionless(new Work<Registry>() {
@Override
public Registry run() {
return ofy()
.loadWithMemcache()
.load()
.key(Key.create(getCrossTldKey(), Registry.class, tld))
.now();
}}));

View file

@ -21,7 +21,6 @@ import static google.registry.config.RegistryConfig.getStaticPremiumListMaxCache
import static google.registry.model.common.EntityGroupRoot.getCrossTldKey;
import static google.registry.model.ofy.ObjectifyService.allocateId;
import static google.registry.model.ofy.ObjectifyService.ofy;
import static google.registry.model.ofy.Ofy.RECOMMENDED_MEMCACHE_EXPIRATION;
import static java.util.concurrent.TimeUnit.MILLISECONDS;
import com.google.common.annotations.VisibleForTesting;
@ -35,7 +34,6 @@ import com.google.common.hash.BloomFilter;
import com.google.common.util.concurrent.UncheckedExecutionException;
import com.googlecode.objectify.Key;
import com.googlecode.objectify.Work;
import com.googlecode.objectify.annotation.Cache;
import com.googlecode.objectify.annotation.Entity;
import com.googlecode.objectify.annotation.Id;
import com.googlecode.objectify.annotation.Parent;
@ -59,7 +57,6 @@ import org.joda.time.Duration;
*/
@ReportedOn
@Entity
@Cache(expirationSeconds = RECOMMENDED_MEMCACHE_EXPIRATION)
public final class PremiumList extends BaseDomainLabelList<Money, PremiumList.PremiumListEntry> {
/** Stores the revision key for the set of currently used premium list entry entities. */
@ -68,7 +65,6 @@ public final class PremiumList extends BaseDomainLabelList<Money, PremiumList.Pr
/** Virtual parent entity for premium list entry entities associated with a single revision. */
@ReportedOn
@Entity
@Cache(expirationSeconds = RECOMMENDED_MEMCACHE_EXPIRATION)
public static class PremiumListRevision extends ImmutableObject {
@Parent
@ -242,7 +238,6 @@ public final class PremiumList extends BaseDomainLabelList<Money, PremiumList.Pr
*/
@ReportedOn
@Entity
@Cache(expirationSeconds = RECOMMENDED_MEMCACHE_EXPIRATION)
public static class PremiumListEntry extends DomainLabelEntry<Money, PremiumListEntry>
implements Buildable {

View file

@ -21,7 +21,6 @@ import static com.google.common.collect.Iterables.getOnlyElement;
import static google.registry.config.RegistryConfig.getDomainLabelListCacheDuration;
import static google.registry.model.common.EntityGroupRoot.getCrossTldKey;
import static google.registry.model.ofy.ObjectifyService.ofy;
import static google.registry.model.ofy.Ofy.RECOMMENDED_MEMCACHE_EXPIRATION;
import static google.registry.model.registry.label.ReservationType.FULLY_BLOCKED;
import static google.registry.model.registry.label.ReservationType.NAMESERVER_RESTRICTED;
import static google.registry.model.registry.label.ReservationType.RESERVED_FOR_ANCHOR_TENANT;
@ -42,7 +41,6 @@ import com.google.common.collect.ImmutableSet;
import com.google.common.net.InternetDomainName;
import com.google.common.util.concurrent.UncheckedExecutionException;
import com.googlecode.objectify.Key;
import com.googlecode.objectify.annotation.Cache;
import com.googlecode.objectify.annotation.Embed;
import com.googlecode.objectify.annotation.Entity;
import com.googlecode.objectify.annotation.Mapify;
@ -61,7 +59,6 @@ import org.joda.time.DateTime;
* A reserved list entity, persisted to Datastore, that is used to check domain label reservations.
*/
@Entity
@Cache(expirationSeconds = RECOMMENDED_MEMCACHE_EXPIRATION)
public final class ReservedList
extends BaseDomainLabelList<ReservationType, ReservedList.ReservedListEntry> {

View file

@ -15,10 +15,8 @@
package google.registry.model.server;
import static google.registry.model.common.EntityGroupRoot.getCrossTldKey;
import static google.registry.model.ofy.Ofy.RECOMMENDED_MEMCACHE_EXPIRATION;
import com.googlecode.objectify.Key;
import com.googlecode.objectify.annotation.Cache;
import com.googlecode.objectify.annotation.Entity;
import com.googlecode.objectify.annotation.Id;
import com.googlecode.objectify.annotation.Parent;
@ -29,7 +27,6 @@ import google.registry.model.common.EntityGroupRoot;
/** Pointer to the latest {@link KmsSecretRevision}. */
@Entity
@ReportedOn
@Cache(expirationSeconds = RECOMMENDED_MEMCACHE_EXPIRATION)
public class KmsSecret extends ImmutableObject {
/** The unique name of this {@link KmsSecret}. */

View file

@ -16,10 +16,8 @@ package google.registry.model.server;
import static com.google.common.base.Preconditions.checkArgument;
import static google.registry.model.common.EntityGroupRoot.getCrossTldKey;
import static google.registry.model.ofy.Ofy.RECOMMENDED_MEMCACHE_EXPIRATION;
import com.googlecode.objectify.Key;
import com.googlecode.objectify.annotation.Cache;
import com.googlecode.objectify.annotation.Entity;
import com.googlecode.objectify.annotation.Id;
import com.googlecode.objectify.annotation.Parent;
@ -43,7 +41,6 @@ import google.registry.model.annotations.ReportedOn;
*/
@Entity
@ReportedOn
@Cache(expirationSeconds = RECOMMENDED_MEMCACHE_EXPIRATION)
public class KmsSecretRevision extends ImmutableObject {
/**

View file

@ -15,7 +15,6 @@
package google.registry.model.server;
import static google.registry.model.ofy.ObjectifyService.ofy;
import static google.registry.model.ofy.Ofy.RECOMMENDED_MEMCACHE_EXPIRATION;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.cache.CacheBuilder;
@ -23,7 +22,6 @@ import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
import com.google.common.primitives.Longs;
import com.googlecode.objectify.Work;
import com.googlecode.objectify.annotation.Cache;
import com.googlecode.objectify.annotation.Entity;
import com.googlecode.objectify.annotation.Unindex;
import google.registry.model.annotations.NotBackedUp;
@ -35,7 +33,6 @@ import java.util.concurrent.ExecutionException;
/** A secret number used for generating tokens (such as XSRF tokens). */
@Entity
@Cache(expirationSeconds = RECOMMENDED_MEMCACHE_EXPIRATION)
@Unindex
@NotBackedUp(reason = Reason.AUTO_GENERATED)
public class ServerSecret extends CrossTldSingleton {

View file

@ -20,7 +20,6 @@ import static com.google.common.base.Verify.verify;
import static google.registry.model.CacheUtils.memoizeWithShortExpiration;
import static google.registry.model.ofy.ObjectifyService.allocateId;
import static google.registry.model.ofy.ObjectifyService.ofy;
import static google.registry.model.ofy.Ofy.RECOMMENDED_MEMCACHE_EXPIRATION;
import static google.registry.util.DateTimeUtils.START_OF_TIME;
import com.google.common.annotations.VisibleForTesting;
@ -30,7 +29,6 @@ import com.google.common.collect.ImmutableMap;
import com.googlecode.objectify.Key;
import com.googlecode.objectify.VoidWork;
import com.googlecode.objectify.Work;
import com.googlecode.objectify.annotation.Cache;
import com.googlecode.objectify.annotation.EmbedMap;
import com.googlecode.objectify.annotation.Entity;
import com.googlecode.objectify.annotation.Id;
@ -246,7 +244,6 @@ public class ClaimsListShard extends ImmutableObject {
* that is live.
*/
@Entity
@Cache(expirationSeconds = RECOMMENDED_MEMCACHE_EXPIRATION)
@NotBackedUp(reason = Reason.EXTERNALLY_SOURCED)
public static class ClaimsListSingleton extends CrossTldSingleton {
Key<ClaimsListRevision> activeRevision;

View file

@ -16,10 +16,8 @@ package google.registry.model.tmch;
import static com.google.common.base.Preconditions.checkNotNull;
import static google.registry.model.ofy.ObjectifyService.ofy;
import static google.registry.model.ofy.Ofy.RECOMMENDED_MEMCACHE_EXPIRATION;
import com.googlecode.objectify.VoidWork;
import com.googlecode.objectify.annotation.Cache;
import com.googlecode.objectify.annotation.Entity;
import google.registry.model.annotations.NotBackedUp;
import google.registry.model.annotations.NotBackedUp.Reason;
@ -30,7 +28,6 @@ import org.joda.time.DateTime;
/** Datastore singleton for ICANN's TMCH CA certificate revocation list (CRL). */
@Entity
@Cache(expirationSeconds = RECOMMENDED_MEMCACHE_EXPIRATION)
@Immutable
@NotBackedUp(reason = Reason.EXTERNALLY_SOURCED)
public final class TmchCrl extends CrossTldSingleton {

View file

@ -22,7 +22,6 @@ import static google.registry.util.PipelineUtils.createJobPath;
import com.google.appengine.tools.mapreduce.Mapper;
import com.google.common.collect.ImmutableList;
import com.googlecode.objectify.Key;
import com.googlecode.objectify.Work;
import google.registry.config.RegistryEnvironment;
import google.registry.mapreduce.MapreduceRunner;
import google.registry.mapreduce.inputs.EppResourceInputs;
@ -92,14 +91,7 @@ public class KillAllEppResourcesAction implements Runnable {
for (Key<Object> key : ofy().load().ancestor(resourceKey).keys()) {
emitAndIncrementCounter(resourceKey, key);
}
// Load in a transaction to make sure we don't get stale data (in case of host renames).
// TODO(b/27424173): A transaction is overkill. When we have memcache-skipping, use that.
EppResource resource = ofy().transactNewReadOnly(
new Work<EppResource>() {
@Override
public EppResource run() {
return ofy().load().key(eri.getKey()).now();
}});
EppResource resource = ofy().load().key(eri.getKey()).now();
// TODO(b/28247733): What about FKI's for renamed hosts?
Key<?> indexKey = resource instanceof DomainApplication
? DomainApplicationIndex.createKey((DomainApplication) resource)

View file

@ -61,7 +61,7 @@ public class SessionUtils {
* user's GAIA ID is associated. The {@code clientId} of the first matching {@code Registrar} will
* then be stored to the HTTP session.
* <li>If it does exist, then we'll fetch the Registrar from Datastore to make sure access
* wasn't revoked. This should only cost one memcache read.
* wasn't revoked.
* </ul>
*
* <p><b>Note:</b> You must ensure the user has logged in before calling this method, for example

View file

@ -85,7 +85,6 @@ public abstract class FlowTestCase<F extends Flow> extends ShardableTestCase {
@Rule
public final AppEngineRule appEngine = AppEngineRule.builder()
.withDatastore()
.withMemcache()
.withTaskQueue()
.build();

View file

@ -69,8 +69,8 @@ public abstract class ResourceFlowTestCase<F extends Flow, R extends EppResource
}
protected R reloadResourceByForeignKey(DateTime now) throws Exception {
// Force the session to be cleared so that when we read it back, we read from Datastore and
// not from the transaction cache or memcache.
// Force the session to be cleared so that when we read it back, we read from Datastore and not
// from the transaction's session cache.
ofy().clearSessionCache();
return loadByForeignKey(getResourceClass(), getUniqueIdFromCommand(), now);
}

View file

@ -17,7 +17,6 @@ package google.registry.flows.domain;
import static com.google.common.collect.Iterables.getLast;
import static com.google.common.io.BaseEncoding.base16;
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assertWithMessage;
import static com.google.common.truth.Truth.assert_;
import static google.registry.model.index.DomainApplicationIndex.loadActiveApplicationsByDomainName;
import static google.registry.model.ofy.ObjectifyService.ofy;
@ -25,7 +24,6 @@ import static google.registry.testing.DatastoreHelper.assertNoBillingEvents;
import static google.registry.testing.DatastoreHelper.createTld;
import static google.registry.testing.DatastoreHelper.deleteTld;
import static google.registry.testing.DatastoreHelper.newDomainApplication;
import static google.registry.testing.DatastoreHelper.newDomainResource;
import static google.registry.testing.DatastoreHelper.persistActiveContact;
import static google.registry.testing.DatastoreHelper.persistActiveDomain;
import static google.registry.testing.DatastoreHelper.persistActiveHost;
@ -33,7 +31,6 @@ import static google.registry.testing.DatastoreHelper.persistReservedList;
import static google.registry.testing.DatastoreHelper.persistResource;
import static google.registry.testing.DomainApplicationSubject.assertAboutApplications;
import static google.registry.testing.EppExceptionSubject.assertAboutEppExceptions;
import static google.registry.util.DateTimeUtils.END_OF_TIME;
import static google.registry.util.DateTimeUtils.START_OF_TIME;
import static org.joda.money.CurrencyUnit.EUR;
import static org.joda.money.CurrencyUnit.USD;
@ -107,12 +104,10 @@ import google.registry.flows.domain.DomainFlowUtils.UnsupportedFeeAttributeExcep
import google.registry.flows.domain.DomainFlowUtils.UnsupportedMarkTypeException;
import google.registry.flows.exceptions.ResourceAlreadyExistsException;
import google.registry.model.domain.DomainApplication;
import google.registry.model.domain.GracePeriod;
import google.registry.model.domain.LrpTokenEntity;
import google.registry.model.domain.launch.ApplicationStatus;
import google.registry.model.domain.launch.LaunchNotice;
import google.registry.model.domain.launch.LaunchPhase;
import google.registry.model.domain.rgp.GracePeriodStatus;
import google.registry.model.domain.secdns.DelegationSignerData;
import google.registry.model.registrar.Registrar;
import google.registry.model.registry.Registry;
@ -1526,7 +1521,7 @@ public class DomainApplicationCreateFlowTest
@Test
public void testFailure_alreadyExists_triggersFailfast() throws Exception {
public void testFailure_alreadyExists() throws Exception {
persistContactsAndHosts();
clock.advanceOneMilli();
persistActiveDomain(getUniqueIdFromCommand());
@ -1537,7 +1532,6 @@ public class DomainApplicationCreateFlowTest
+ "Object with given ID (%s) already exists",
getUniqueIdFromCommand());
} catch (ResourceAlreadyExistsException e) {
assertThat(e.isFailfast()).isTrue();
assertAboutEppExceptions().that(e).marshalsToXml().and().hasMessage(
String.format("Object with given ID (%s) already exists", getUniqueIdFromCommand()));
}
@ -1712,37 +1706,6 @@ public class DomainApplicationCreateFlowTest
runFlow();
}
/**
* There is special logic that disallows a failfast for domains in add grace period and sunrush
* add grace period, so make sure that they fail anyways in the actual flow.
*/
private void doNonFailFastAlreadyExistsTest(GracePeriodStatus gracePeriodStatus)
throws Exception {
persistContactsAndHosts();
clock.advanceOneMilli();
persistResource(newDomainResource(getUniqueIdFromCommand()).asBuilder()
.addGracePeriod(GracePeriod.create(gracePeriodStatus, END_OF_TIME, "", null))
.build());
try {
runFlow();
assertWithMessage("Expected ResourceAlreadyExistsException to be thrown").fail();
} catch (ResourceAlreadyExistsException e) {
assertThat(e.isFailfast()).isFalse();
assertAboutEppExceptions().that(e).marshalsToXml().and().hasMessage(
String.format("Object with given ID (%s) already exists", getUniqueIdFromCommand()));
}
}
@Test
public void testFailure_alreadyExists_addGracePeriod() throws Exception {
doNonFailFastAlreadyExistsTest(GracePeriodStatus.ADD);
}
@Test
public void testFailure_alreadyExists_sunrushAddGracePeriod() throws Exception {
doNonFailFastAlreadyExistsTest(GracePeriodStatus.SUNRUSH_ADD);
}
private void doFailingDomainNameTest(String domainName, Class<? extends Throwable> exception)
throws Exception {
setEppInput("domain_create_sunrise_signed_mark_uppercase.xml");

View file

@ -23,7 +23,6 @@ import static google.registry.testing.DatastoreHelper.createTld;
import static google.registry.testing.DatastoreHelper.persistActiveContact;
import static google.registry.testing.DatastoreHelper.persistActiveHost;
import static google.registry.testing.DatastoreHelper.persistResource;
import static google.registry.testing.MemcacheHelper.clearMemcache;
import static google.registry.testing.TestDataHelper.loadFileWithSubstitutions;
import static google.registry.util.DatastoreServiceUtils.KEY_TO_KIND_FUNCTION;
@ -332,9 +331,8 @@ public class DomainApplicationInfoFlowTest
@Test
public void testBatchLoadingOfReferences() throws Exception {
persistTestEntities(HostsState.HOSTS_EXIST, MarksState.NO_MARKS_EXIST);
// Clear out memcache and session cache so that we count actual Datastore calls.
// Clear out the session cache so that we count actual Datastore calls.
ofy().clearSessionCache();
clearMemcache();
int numPreviousReads = RequestCapturingAsyncDatastoreService.getReads().size();
doSuccessfulTest("domain_info_sunrise_response.xml", HostsState.HOSTS_EXIST);
// Get all of the keys loaded in the flow, with each distinct load() call as a list of keys.

View file

@ -30,7 +30,6 @@ import static google.registry.testing.DatastoreHelper.deleteTld;
import static google.registry.testing.DatastoreHelper.getHistoryEntries;
import static google.registry.testing.DatastoreHelper.newContactResource;
import static google.registry.testing.DatastoreHelper.newDomainApplication;
import static google.registry.testing.DatastoreHelper.newDomainResource;
import static google.registry.testing.DatastoreHelper.newHostResource;
import static google.registry.testing.DatastoreHelper.persistActiveContact;
import static google.registry.testing.DatastoreHelper.persistActiveDomain;
@ -892,7 +891,7 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
}
@Test
public void testFailure_alreadyExists_triggersFailfast() throws Exception {
public void testFailure_alreadyExists() throws Exception {
persistContactsAndHosts();
persistActiveDomain(getUniqueIdFromCommand());
try {
@ -902,43 +901,11 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
+ "Object with given ID (%s) already exists",
getUniqueIdFromCommand());
} catch (ResourceAlreadyExistsException e) {
assertThat(e.isFailfast()).isTrue();
assertAboutEppExceptions().that(e).marshalsToXml().and().hasMessage(
String.format("Object with given ID (%s) already exists", getUniqueIdFromCommand()));
}
}
/**
* There is special logic that disallows a failfast for domains in add grace period and sunrush
* add grace period, so make sure that they fail anyways in the actual flow.
*/
private void doNonFailFastAlreadyExistsTest(GracePeriodStatus gracePeriodStatus)
throws Exception {
// This doesn't fail fast, so it throws the regular ResourceAlreadyExistsException from run().
persistContactsAndHosts();
persistResource(newDomainResource(getUniqueIdFromCommand()).asBuilder()
.addGracePeriod(GracePeriod.create(gracePeriodStatus, END_OF_TIME, "", null))
.build());
thrown.expect(
ResourceAlreadyExistsException.class,
String.format("Object with given ID (%s) already exists", getUniqueIdFromCommand()));
try {
runFlow();
} catch (ResourceAlreadyExistsException e) {
assertThat(e.isFailfast()).isFalse();
throw e;
}
}
@Test
public void testFailure_alreadyExists_addGracePeriod() throws Exception {
doNonFailFastAlreadyExistsTest(GracePeriodStatus.ADD);
}
@Test
public void testFailure_alreadyExists_sunrushAddGracePeriod() throws Exception {
doNonFailFastAlreadyExistsTest(GracePeriodStatus.SUNRUSH_ADD);
}
@Test
public void testFailure_reserved() throws Exception {

View file

@ -24,7 +24,6 @@ import static google.registry.testing.DatastoreHelper.newDomainResource;
import static google.registry.testing.DatastoreHelper.persistActiveContact;
import static google.registry.testing.DatastoreHelper.persistActiveHost;
import static google.registry.testing.DatastoreHelper.persistResource;
import static google.registry.testing.MemcacheHelper.clearMemcache;
import static google.registry.testing.TestDataHelper.loadFileWithSubstitutions;
import static google.registry.util.DatastoreServiceUtils.KEY_TO_KIND_FUNCTION;
@ -637,9 +636,8 @@ public class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, Dom
@Test
public void testBatchLoadingOfReferences() throws Exception {
persistTestEntities(false);
// Clear out memcache and session cache so that we count actual Datastore calls.
// Clear out the session cache so that we count actual Datastore calls.
ofy().clearSessionCache();
clearMemcache();
int numPreviousReads = RequestCapturingAsyncDatastoreService.getReads().size();
doSuccessfulTest("domain_info_response.xml", false);
// Get all of the keys loaded in the flow, with each distinct load() call as a list of keys.

View file

@ -21,7 +21,6 @@ import static java.nio.charset.StandardCharsets.UTF_8;
import static org.json.XML.toJSONObject;
import com.google.appengine.tools.development.testing.LocalDatastoreServiceTestConfig;
import com.google.appengine.tools.development.testing.LocalMemcacheServiceTestConfig;
import com.google.appengine.tools.development.testing.LocalModulesServiceTestConfig;
import com.google.appengine.tools.development.testing.LocalServiceTestConfig;
import com.google.appengine.tools.development.testing.LocalServiceTestHelper;
@ -96,7 +95,6 @@ public final class AppEngineRule extends ExternalResource {
private boolean withDatastore;
private boolean withLocalModules;
private boolean withMemcache;
private boolean withTaskQueue;
private boolean withUserService;
private boolean withUrlFetch;
@ -122,12 +120,6 @@ public final class AppEngineRule extends ExternalResource {
return this;
}
/** Turn on the use of local modules. */
public Builder withMemcache() {
rule.withMemcache = true;
return this;
}
/** Turn on the task queue service. */
public Builder withTaskQueue() {
@ -281,9 +273,6 @@ public final class AppEngineRule extends ExternalResource {
.addBasicScalingModuleVersion("tools", "1", 1)
.addBasicScalingModuleVersion("backend", "1", 1));
}
if (withMemcache) {
configs.add(new LocalMemcacheServiceTestConfig());
}
if (withTaskQueue) {
File queueFile = temporaryFolder.newFile("queue.xml");
Files.asCharSink(queueFile, UTF_8).write(taskQueueXml);

View file

@ -829,9 +829,9 @@ public class DatastoreHelper {
saveResource(resource, wantBackup);
}});
// Force the session cache to be cleared so that when we read the resource back, we read from
// Datastore (or memcache) and not from the session cache. This is needed to trigger Objectify's
// load process (unmarshalling entity protos to POJOs, nulling out empty collections, calling
// @OnLoad methods, etc.) which is bypassed for entities loaded from the session cache.
// Datastore and not from the session cache. This is needed to trigger Objectify's load process
// (unmarshalling entity protos to POJOs, nulling out empty collections, calling @OnLoad
// methods, etc.) which is bypassed for entities loaded from the session cache.
ofy().clearSessionCache();
return ofy().load().entity(resource).now();
}
@ -872,7 +872,7 @@ public class DatastoreHelper {
}});
}
// Force the session to be cleared so that when we read it back, we read from Datastore
// and not from the transaction cache or memcache.
// and not from the transaction's session cache.
ofy().clearSessionCache();
for (R resource : resources) {
ofy().load().entity(resource).now();
@ -984,7 +984,7 @@ public class DatastoreHelper {
ofy().saveWithoutBackup().entities(resources);
}});
// Force the session to be cleared so that when we read it back, we read from Datastore
// and not from the transaction cache or memcache.
// and not from the transaction's session cache.
ofy().clearSessionCache();
return ImmutableList.copyOf(ofy().load().entities(resources).values());
}
@ -992,7 +992,7 @@ public class DatastoreHelper {
public static void deleteResource(final Object resource) {
ofy().deleteWithoutBackup().entity(resource).now();
// Force the session to be cleared so that when we read it back, we read from Datastore and
// not from the transaction cache or memcache.
// not from the transaction's session cache.
ofy().clearSessionCache();
}

View file

@ -1,45 +0,0 @@
// Copyright 2017 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.testing;
import static com.google.appengine.tools.development.testing.LocalMemcacheServiceTestConfig.getLocalMemcacheService;
import static google.registry.model.ofy.ObjectifyService.ofy;
import com.google.appengine.api.memcache.MemcacheServicePb.MemcacheFlushRequest;
import com.google.appengine.tools.development.LocalRpcService;
import com.googlecode.objectify.Key;
/** Utilities for manipulating memcache in tests. */
public class MemcacheHelper {
/** Clear out memcache */
public static void clearMemcache() {
getLocalMemcacheService().flushAll(
new LocalRpcService.Status(), MemcacheFlushRequest.newBuilder().build());
}
/** Clears memcache, inserts the specific keys requested, and clears the session cache. */
public static void setMemcacheContents(Key<?>... keys) {
// Clear out the session cache. This is needed so that the calls to loadWithMemcache() below
// actually go to datastore and write to memcache instead of bottoming out at the session cache.
ofy().clearSessionCache();
clearMemcache();
// Load the entities we want to be in memcache. If an entity's type is not marked with @Cache it
// will be ignored.
ofy().loadWithMemcache().keys(keys).values();
// Clear out the session cache again, since it now contains the newly loaded types.
ofy().clearSessionCache();
}
}