Improve Datastore efficiency of duplicate contact messages

I should have caught this in the review, but [] is loading *ALL*
contacts individually from Datastore on every domain update. This will add a
large number of Datastore round trips and thus significantly reduce update
performance.

This CL changes the behavior to *ONLY* load contacts when there is a duplicate
(which is needed to determine the contact's display name to generate the error
message), and loads all of them in a single batch rather than individually.

This also makes some minor changes around domain getters returning empty sets
instead of null.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=233128140
This commit is contained in:
mcilwain 2019-02-08 14:34:26 -08:00 committed by jianglai
parent 920d5d0190
commit 49ac4e3e69
3 changed files with 57 additions and 52 deletions

View file

@ -43,6 +43,7 @@ import google.registry.model.host.HostResource;
import google.registry.model.index.ForeignKeyIndex;
import java.util.Map;
import java.util.Set;
import javax.annotation.Nullable;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
@ -90,6 +91,7 @@ public class DomainCommand {
return registrantContactId;
}
@Nullable
public Key<ContactResource> getRegistrant() {
return registrant;
}
@ -153,15 +155,15 @@ public class DomainCommand {
}
public ImmutableSet<String> getNameserverFullyQualifiedHostNames() {
return nullSafeImmutableCopy(nameserverFullyQualifiedHostNames);
return nullToEmptyImmutableCopy(nameserverFullyQualifiedHostNames);
}
public ImmutableSet<Key<HostResource>> getNameservers() {
return nullSafeImmutableCopy(nameservers);
return nullToEmptyImmutableCopy(nameservers);
}
public ImmutableSet<DesignatedContact> getContacts() {
return nullSafeImmutableCopy(contacts);
return nullToEmptyImmutableCopy(contacts);
}
@Override