mirror of
https://github.com/google/nomulus.git
synced 2025-06-27 14:54:51 +02:00
Deprecate more fields in RegistryConfig
This primarily addresses issues with TMCH testing mode and email sending utils. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=143710550
This commit is contained in:
parent
c05424b947
commit
25a8bbe890
23 changed files with 203 additions and 265 deletions
|
@ -18,6 +18,7 @@ import static com.google.common.base.Preconditions.checkArgument;
|
|||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static com.google.common.base.Predicates.equalTo;
|
||||
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;
|
||||
|
@ -49,7 +50,6 @@ import com.googlecode.objectify.annotation.Id;
|
|||
import com.googlecode.objectify.annotation.Mapify;
|
||||
import com.googlecode.objectify.annotation.OnSave;
|
||||
import com.googlecode.objectify.annotation.Parent;
|
||||
import google.registry.config.RegistryEnvironment;
|
||||
import google.registry.model.Buildable;
|
||||
import google.registry.model.CreateAutoTimestamp;
|
||||
import google.registry.model.ImmutableObject;
|
||||
|
@ -211,24 +211,23 @@ public class Registry extends ImmutableObject implements Buildable {
|
|||
}
|
||||
|
||||
/** A cache that loads the {@link Registry} for a given tld. */
|
||||
private static final LoadingCache<String, Optional<Registry>> CACHE = CacheBuilder.newBuilder()
|
||||
.expireAfterWrite(
|
||||
RegistryEnvironment.get().config().getSingletonCacheRefreshDuration().getMillis(),
|
||||
MILLISECONDS)
|
||||
.build(new CacheLoader<String, Optional<Registry>>() {
|
||||
@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.
|
||||
return Optional.fromNullable(ofy().doTransactionless(new Work<Registry>() {
|
||||
@Override
|
||||
public Registry run() {
|
||||
return ofy()
|
||||
.load()
|
||||
.key(Key.create(getCrossTldKey(), Registry.class, tld))
|
||||
.now();
|
||||
}}));
|
||||
}});
|
||||
private static final LoadingCache<String, Optional<Registry>> CACHE =
|
||||
CacheBuilder.newBuilder()
|
||||
.expireAfterWrite(getSingletonCacheRefreshDuration().getMillis(), MILLISECONDS)
|
||||
.build(new CacheLoader<String, Optional<Registry>>() {
|
||||
@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
|
||||
return Optional.fromNullable(ofy().doTransactionless(new Work<Registry>() {
|
||||
@Override
|
||||
public Registry run() {
|
||||
return ofy()
|
||||
.load()
|
||||
.key(Key.create(getCrossTldKey(), Registry.class, tld))
|
||||
.now();
|
||||
}}));
|
||||
}});
|
||||
|
||||
/** Returns the registry for a given TLD, throwing if none exists. */
|
||||
public static Registry get(String tld) {
|
||||
|
|
|
@ -19,6 +19,7 @@ import static com.google.common.base.Preconditions.checkArgument;
|
|||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static com.google.common.base.Preconditions.checkState;
|
||||
import static com.google.common.collect.Iterables.partition;
|
||||
import static google.registry.config.RegistryConfig.getDomainLabelListCacheDuration;
|
||||
import static google.registry.model.common.EntityGroupRoot.getCrossTldKey;
|
||||
import static google.registry.model.ofy.ObjectifyService.allocateId;
|
||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
||||
|
@ -48,7 +49,6 @@ import com.googlecode.objectify.annotation.Ignore;
|
|||
import com.googlecode.objectify.annotation.OnLoad;
|
||||
import com.googlecode.objectify.annotation.Parent;
|
||||
import com.googlecode.objectify.cmd.Query;
|
||||
import google.registry.config.RegistryEnvironment;
|
||||
import google.registry.model.Buildable;
|
||||
import google.registry.model.ImmutableObject;
|
||||
import google.registry.model.annotations.ReportedOn;
|
||||
|
@ -97,24 +97,22 @@ public final class PremiumList extends BaseDomainLabelList<Money, PremiumList.Pr
|
|||
}
|
||||
}
|
||||
|
||||
private static LoadingCache<String, PremiumList> cache = CacheBuilder
|
||||
.newBuilder()
|
||||
.expireAfterWrite(
|
||||
RegistryEnvironment.get().config().getDomainLabelListCacheDuration().getMillis(),
|
||||
MILLISECONDS)
|
||||
.build(new CacheLoader<String, PremiumList>() {
|
||||
@Override
|
||||
public PremiumList load(final String listName) {
|
||||
return ofy().doTransactionless(new Work<PremiumList>() {
|
||||
private static LoadingCache<String, PremiumList> cache =
|
||||
CacheBuilder.newBuilder()
|
||||
.expireAfterWrite(getDomainLabelListCacheDuration().getMillis(), MILLISECONDS)
|
||||
.build(new CacheLoader<String, PremiumList>() {
|
||||
@Override
|
||||
public PremiumList run() {
|
||||
return ofy().load()
|
||||
.type(PremiumList.class)
|
||||
.parent(getCrossTldKey())
|
||||
.id(listName)
|
||||
.now();
|
||||
public PremiumList load(final String listName) {
|
||||
return ofy().doTransactionless(new Work<PremiumList>() {
|
||||
@Override
|
||||
public PremiumList run() {
|
||||
return ofy().load()
|
||||
.type(PremiumList.class)
|
||||
.parent(getCrossTldKey())
|
||||
.id(listName)
|
||||
.now();
|
||||
}});
|
||||
}});
|
||||
}});
|
||||
|
||||
/**
|
||||
* Gets the premium price for the specified label on the specified tld, or returns Optional.absent
|
||||
|
|
|
@ -16,6 +16,7 @@ package google.registry.model.registry.label;
|
|||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
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;
|
||||
|
@ -40,7 +41,6 @@ import com.googlecode.objectify.annotation.Embed;
|
|||
import com.googlecode.objectify.annotation.Entity;
|
||||
import com.googlecode.objectify.annotation.Mapify;
|
||||
import com.googlecode.objectify.mapper.Mapper;
|
||||
import google.registry.config.RegistryEnvironment;
|
||||
import google.registry.model.registry.Registry;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
@ -221,16 +221,20 @@ public final class ReservedList
|
|||
return builder.build();
|
||||
}
|
||||
|
||||
private static LoadingCache<String, ReservedList> cache = CacheBuilder
|
||||
.newBuilder()
|
||||
.expireAfterWrite(
|
||||
RegistryEnvironment.get().config().getDomainLabelListCacheDuration().getMillis(),
|
||||
MILLISECONDS)
|
||||
.build(new CacheLoader<String, ReservedList>() {
|
||||
@Override
|
||||
public ReservedList load(String listName) {
|
||||
return ofy().load().type(ReservedList.class).parent(getCrossTldKey()).id(listName).now();
|
||||
}});
|
||||
private static LoadingCache<String, ReservedList> cache =
|
||||
CacheBuilder.newBuilder()
|
||||
.expireAfterWrite(getDomainLabelListCacheDuration().getMillis(), MILLISECONDS)
|
||||
.build(
|
||||
new CacheLoader<String, ReservedList>() {
|
||||
@Override
|
||||
public ReservedList load(String listName) {
|
||||
return ofy()
|
||||
.load()
|
||||
.type(ReservedList.class)
|
||||
.parent(getCrossTldKey())
|
||||
.id(listName)
|
||||
.now();
|
||||
}});
|
||||
|
||||
/**
|
||||
* Gets the {@link ReservationType} of a label in a single ReservedList, or returns an absent
|
||||
|
|
|
@ -15,13 +15,13 @@
|
|||
package google.registry.model.translators;
|
||||
|
||||
import static com.google.common.base.MoreObjects.firstNonNull;
|
||||
import static google.registry.config.RegistryConfig.getCommitLogDatastoreRetention;
|
||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
||||
import static google.registry.util.DateTimeUtils.START_OF_TIME;
|
||||
|
||||
import com.google.common.collect.ImmutableSortedMap;
|
||||
import com.google.common.collect.Ordering;
|
||||
import com.googlecode.objectify.Key;
|
||||
import google.registry.config.RegistryEnvironment;
|
||||
import google.registry.model.ofy.CommitLogManifest;
|
||||
import org.joda.time.DateTime;
|
||||
|
||||
|
@ -47,8 +47,6 @@ import org.joda.time.DateTime;
|
|||
public final class CommitLogRevisionsTranslatorFactory
|
||||
extends ImmutableSortedMapTranslatorFactory<DateTime, Key<CommitLogManifest>> {
|
||||
|
||||
private static final RegistryEnvironment ENVIRONMENT = RegistryEnvironment.get();
|
||||
|
||||
/**
|
||||
* Add a reference to the current commit log to the resource's revisions map.
|
||||
*
|
||||
|
@ -65,7 +63,7 @@ public final class CommitLogRevisionsTranslatorFactory
|
|||
ImmutableSortedMap<DateTime, Key<CommitLogManifest>> transformBeforeSave(
|
||||
ImmutableSortedMap<DateTime, Key<CommitLogManifest>> revisions) {
|
||||
DateTime now = ofy().getTransactionTime();
|
||||
DateTime threshold = now.minus(ENVIRONMENT.config().getCommitLogDatastoreRetention());
|
||||
DateTime threshold = now.minus(getCommitLogDatastoreRetention());
|
||||
DateTime preThresholdTime = firstNonNull(revisions.floorKey(threshold), START_OF_TIME);
|
||||
return new ImmutableSortedMap.Builder<DateTime, Key<CommitLogManifest>>(Ordering.natural())
|
||||
.putAll(revisions.subMap(preThresholdTime, true, now.withTimeAtStartOfDay(), false))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue