Remove deprecated singular DNS writer field and update tooling

Note that even though the nomulus command line tool now supports multiple
DNS writers for all subcommands, this still won't work quite yet because
the DNS task queue format migration from [] is still in progress.
After next week's push that migration will be complete and we can remove
the final restriction against only having one DNS writer per TLD.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=162490399
This commit is contained in:
mcilwain 2017-07-19 08:47:48 -07:00 committed by Ben McIlwain
parent 8ff1102223
commit d3e9ebad16
8 changed files with 101 additions and 123 deletions

View file

@ -15,6 +15,7 @@
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;
@ -40,7 +41,7 @@ public final class DnsWriterProxy {
// TODO(b/63385597): Delete this method after DNS writers migration is complete.
@Deprecated
public DnsWriter getForTld(String tld) {
return getByClassNameForTld(Registry.get(tld).getDnsWriter(), tld);
return getByClassNameForTld(getOnlyElement(Registry.get(tld).getDnsWriters()), tld);
}
/** Returns the instance of {@link DnsWriter} by class name. */

View file

@ -18,7 +18,6 @@ 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 com.google.common.collect.Iterables.getOnlyElement;
import static google.registry.config.RegistryConfig.getSingletonCacheRefreshDuration;
import static google.registry.model.common.EntityGroupRoot.getCrossTldKey;
import static google.registry.model.ofy.ObjectifyService.ofy;
@ -50,7 +49,6 @@ import com.googlecode.objectify.annotation.Embed;
import com.googlecode.objectify.annotation.Entity;
import com.googlecode.objectify.annotation.Id;
import com.googlecode.objectify.annotation.Mapify;
import com.googlecode.objectify.annotation.OnLoad;
import com.googlecode.objectify.annotation.OnSave;
import com.googlecode.objectify.annotation.Parent;
import google.registry.model.Buildable;
@ -266,18 +264,6 @@ public class Registry extends ImmutableObject implements Buildable {
*/
String pricingEngineClassName;
/**
* The name of the DnsWriter that this TLD uses.
*
* <p>This must be a valid key for the map of DnsWriters injected by <code>
* @Inject Map<String, DnsWriter></code>
*
* @deprecated by dnsWriters
*/
// TODO(b/63385623): Delete this field when the data migration is complete.
@Deprecated
String dnsWriter;
/**
* The set of name(s) of the {@code DnsWriter} implementations that this TLD uses.
*
@ -288,13 +274,6 @@ public class Registry extends ImmutableObject implements Buildable {
*/
Set<String> dnsWriters;
@OnLoad
public void migrateDnsWriters() {
if (dnsWriter == null) {
dnsWriter = getOnlyElement(dnsWriters);
}
}
/**
* The unicode-aware representation of the TLD associated with this {@link Registry}.
*
@ -611,11 +590,6 @@ public class Registry extends ImmutableObject implements Buildable {
return pricingEngineClassName;
}
@Deprecated
public String getDnsWriter() {
return getOnlyElement(dnsWriters);
}
public ImmutableSet<String> getDnsWriters() {
return ImmutableSet.copyOf(dnsWriters);
}
@ -703,9 +677,9 @@ 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;
getInstance().dnsWriter = getOnlyElement(dnsWriters);
return this;
}
@ -972,9 +946,6 @@ public class Registry extends ImmutableObject implements Buildable {
"All EAP fees must be in the registry's currency");
checkArgumentNotNull(
instance.pricingEngineClassName, "All registries must have a configured pricing engine");
checkArgumentNotNull(
instance.dnsWriter,
"A DNS writer must be specified. VoidDnsWriter can be used if DNS writing isn't wanted");
checkArgument(
instance.dnsWriters != null && !instance.dnsWriters.isEmpty(),
"At least one DNS writer must be specified."

View file

@ -25,6 +25,8 @@ import com.google.common.base.Optional;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.ImmutableSortedMap;
import com.google.common.collect.ImmutableSortedSet;
import com.google.common.collect.Sets;
import google.registry.model.pricing.StaticPremiumListPricingEngine;
import google.registry.model.registry.Registries;
import google.registry.model.registry.Registry;
@ -51,7 +53,7 @@ abstract class CreateOrUpdateTldCommand extends MutatingCommand {
@Inject
@Named("dnsWriterNames")
Set<String> dnsWriterNames;
Set<String> validDnsWriterNames;
@Parameter(description = "Names of the TLDs", required = true)
List<String> mainParameters;
@ -220,11 +222,9 @@ abstract class CreateOrUpdateTldCommand extends MutatingCommand {
@Nullable
@Parameter(
names = "--dns_writer",
description = "The name of the DnsWriter implementation to use",
converter = OptionalStringParameter.class,
validateWith = OptionalStringParameter.class)
Optional<String> dnsWriter;
names = "--dns_writers",
description = "A comma-separated list of DnsWriter implementations to use")
List<String> dnsWriters;
@Nullable
@Parameter(
@ -388,12 +388,15 @@ abstract class CreateOrUpdateTldCommand extends MutatingCommand {
}
}
if (dnsWriter != null && dnsWriter.isPresent()) {
checkArgument(
dnsWriterNames.contains(dnsWriter.get()),
"The DNS writer '%s' doesn't exist",
dnsWriter.get());
builder.setDnsWriters(ImmutableSet.of(dnsWriter.get()));
if (dnsWriters != null) {
ImmutableSet<String> dnsWritersSet = ImmutableSet.copyOf(dnsWriters);
ImmutableSortedSet<String> invalidDnsWriters =
ImmutableSortedSet.copyOf(Sets.difference(dnsWritersSet, validDnsWriterNames));
checkArgument(
invalidDnsWriters.isEmpty(),
"Invalid DNS writer name(s) specified: %s",
invalidDnsWriters);
builder.setDnsWriters(dnsWritersSet);
}
if (lrpPeriod != null) {

View file

@ -56,7 +56,7 @@ final class SetupOteCommand extends ConfirmingCommand implements RemoteApiComman
@Inject
@Named("dnsWriterNames")
Set<String> dnsWriterNames;
Set<String> validDnsWriterNames;
@Parameter(
names = {"-r", "--registrar"},
@ -82,10 +82,10 @@ final class SetupOteCommand extends ConfirmingCommand implements RemoteApiComman
private Path certFile;
@Parameter(
names = {"--dns_writer"},
description = "DNS writer to use on all TLDs",
names = {"--dns_writers"},
description = "comma separated list of DNS writers to use on all TLDs",
required = true)
private String dnsWriter;
private List<String> dnsWriters;
@Parameter(
names = {"--premium_list"},
@ -110,8 +110,8 @@ final class SetupOteCommand extends ConfirmingCommand implements RemoteApiComman
Duration pendingDeleteLength) throws Exception {
CreateTldCommand command = new CreateTldCommand();
command.addGracePeriod = addGracePeriod;
command.dnsWriter = Optional.of(dnsWriter);
command.dnsWriterNames = dnsWriterNames;
command.dnsWriters = dnsWriters;
command.validDnsWriterNames = validDnsWriterNames;
command.force = force;
command.initialTldState = initialTldState;
command.mainParameters = ImmutableList.of(tldName);