mirror of
https://github.com/google/nomulus.git
synced 2025-05-22 04:09:46 +02:00
Allow multiple DNS writers on TLDs
This completes the data/functionality migration for multiple DNS writers. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=163835077
This commit is contained in:
parent
05d22a2556
commit
2a29ada032
8 changed files with 38 additions and 37 deletions
|
@ -22,13 +22,11 @@ import static google.registry.dns.PublishDnsUpdatesAction.PARAM_HOSTS;
|
|||
import static google.registry.dns.ReadDnsQueueAction.PARAM_KEEP_TASKS;
|
||||
import static google.registry.request.RequestParameters.extractBooleanParameter;
|
||||
import static google.registry.request.RequestParameters.extractEnumParameter;
|
||||
import static google.registry.request.RequestParameters.extractOptionalParameter;
|
||||
import static google.registry.request.RequestParameters.extractRequiredParameter;
|
||||
import static google.registry.request.RequestParameters.extractSetOfParameters;
|
||||
|
||||
import com.google.appengine.api.taskqueue.Queue;
|
||||
import com.google.appengine.api.taskqueue.QueueFactory;
|
||||
import com.google.common.base.Optional;
|
||||
import dagger.Binds;
|
||||
import dagger.Module;
|
||||
import dagger.Provides;
|
||||
|
@ -62,9 +60,8 @@ public abstract class DnsModule {
|
|||
|
||||
@Provides
|
||||
@Parameter(PARAM_DNS_WRITER)
|
||||
static Optional<String> provideDnsWriter(HttpServletRequest req) {
|
||||
// TODO(b/63385597): Make this required after DNS writers migration is complete.
|
||||
return extractOptionalParameter(req, PARAM_DNS_WRITER);
|
||||
static String provideDnsWriter(HttpServletRequest req) {
|
||||
return extractRequiredParameter(req, PARAM_DNS_WRITER);
|
||||
}
|
||||
|
||||
@Provides
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
package google.registry.dns;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkState;
|
||||
import static com.google.common.collect.Iterables.getOnlyElement;
|
||||
import static google.registry.util.FormattingLogger.getLoggerForCallerClass;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
@ -37,13 +36,6 @@ public final class DnsWriterProxy {
|
|||
this.dnsWriters = ImmutableMap.copyOf(dnsWriters);
|
||||
}
|
||||
|
||||
/** Returns the {@link DnsWriter} for the given tld. */
|
||||
// TODO(b/63385597): Delete this method after DNS writers migration is complete.
|
||||
@Deprecated
|
||||
public DnsWriter getForTld(String tld) {
|
||||
return getByClassNameForTld(getOnlyElement(Registry.get(tld).getDnsWriters()), tld);
|
||||
}
|
||||
|
||||
/** Returns the instance of {@link DnsWriter} by class name. */
|
||||
public DnsWriter getByClassNameForTld(String className, String tld) {
|
||||
if (!Registry.get(tld).getDnsWriters().contains(className)) {
|
||||
|
|
|
@ -19,7 +19,6 @@ import static google.registry.request.Action.Method.POST;
|
|||
import static google.registry.request.RequestParameters.PARAM_TLD;
|
||||
import static google.registry.util.CollectionUtils.nullToEmpty;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
import com.google.common.net.InternetDomainName;
|
||||
import google.registry.config.RegistryConfig.Config;
|
||||
import google.registry.dns.DnsMetrics.Status;
|
||||
|
@ -65,8 +64,7 @@ public final class PublishDnsUpdatesAction implements Runnable, Callable<Void> {
|
|||
* writers configured in {@link Registry#getDnsWriters()}, as of the time the batch was written
|
||||
* out (and not necessarily currently).
|
||||
*/
|
||||
// TODO(b/63385597): Make this non-optional DNS once writers migration is complete.
|
||||
@Inject @Parameter(PARAM_DNS_WRITER) Optional<String> dnsWriter;
|
||||
@Inject @Parameter(PARAM_DNS_WRITER) String dnsWriter;
|
||||
|
||||
@Inject @Parameter(PARAM_DOMAINS) Set<String> domains;
|
||||
@Inject @Parameter(PARAM_HOSTS) Set<String> hosts;
|
||||
|
@ -95,12 +93,7 @@ public final class PublishDnsUpdatesAction implements Runnable, Callable<Void> {
|
|||
|
||||
/** Steps through the domain and host refreshes contained in the parameters and processes them. */
|
||||
private void processBatch() {
|
||||
// TODO(b/63385597): After all old DNS task queue items that did not have a DNS writer on them
|
||||
// are finished being processed, then remove handling for when dnsWriter is absent.
|
||||
try (DnsWriter writer =
|
||||
(dnsWriter.isPresent())
|
||||
? dnsWriterProxy.getByClassNameForTld(dnsWriter.get(), tld)
|
||||
: dnsWriterProxy.getForTld(tld)) {
|
||||
try (DnsWriter writer = dnsWriterProxy.getByClassNameForTld(dnsWriter, tld)) {
|
||||
for (String domain : nullToEmpty(domains)) {
|
||||
if (!DomainNameUtils.isUnder(
|
||||
InternetDomainName.from(domain), InternetDomainName.from(tld))) {
|
||||
|
|
|
@ -676,8 +676,6 @@ public class Registry extends ImmutableObject implements Buildable {
|
|||
}
|
||||
|
||||
public Builder setDnsWriters(ImmutableSet<String> dnsWriters) {
|
||||
// TODO(b/63385597): Remove this restriction once DNS task queue migration is complete.
|
||||
checkArgument(dnsWriters.size() == 1, "Multiple DNS writers are not yet supported");
|
||||
getInstance().dnsWriters = dnsWriters;
|
||||
return this;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue