mirror of
https://github.com/google/nomulus.git
synced 2025-06-05 12:07:25 +02:00
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:
parent
445faab977
commit
ae039aa0d8
37 changed files with 29 additions and 341 deletions
|
@ -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());
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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()) {
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue