mirror of
https://github.com/google/nomulus.git
synced 2025-05-14 00:17:20 +02:00
Begin migration away from ReferenceUnions
It is important to get at least this one commit in before the public Nomulus release so that none of our public users will have to go through this data migration (although we will have to). The migration strategy is as follows: 1. Dual-write to non-ReferenceUnion fields in addition to the current ReferenceUnion fields in use, and add new indexes (this commit). Deploy. 2. Run the ResaveAllEppResourcesAction backfill []. 3. Switch all code over to using the new fields. Dual-write is still in effect, except it is now copying over the values of the new fields to the old fields. Switch over all BigQuery reporting scripts to use the new fields. Deploy. 4. Remove all of the old code and indexes. Deploy. 5. (Optional, at our leisure) Re-run the ResaveAllEppResourcesAction backfill [] to delete the old obsolete fields. Note that this migration strategy is rollback-safe at every step -- new data is not read until it has already been written out in the previous step, and old data is not removed immediately following a step in which it was still being read, so the previous step is safe to roll back to. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=136196988
This commit is contained in:
parent
2d11f12115
commit
861fd60d2c
7 changed files with 78 additions and 6 deletions
|
@ -40,6 +40,7 @@ import com.googlecode.objectify.Key;
|
|||
import com.googlecode.objectify.annotation.Entity;
|
||||
import com.googlecode.objectify.annotation.IgnoreSave;
|
||||
import com.googlecode.objectify.annotation.Index;
|
||||
import com.googlecode.objectify.annotation.OnSave;
|
||||
import com.googlecode.objectify.condition.IfNull;
|
||||
import google.registry.model.EppResource;
|
||||
import google.registry.model.contact.ContactResource;
|
||||
|
@ -78,9 +79,13 @@ public abstract class DomainBase extends EppResource {
|
|||
|
||||
/** References to hosts that are the nameservers for the domain. */
|
||||
@XmlTransient
|
||||
//TODO(b/28713909): Make this a Set<Key<HostResource>>.
|
||||
//TODO(b/28713909): Delete this once migration away from ReferenceUnions is complete.
|
||||
Set<ReferenceUnion<HostResource>> nameservers;
|
||||
|
||||
@Index
|
||||
@XmlTransient
|
||||
Set<Key<HostResource>> nsHosts;
|
||||
|
||||
/**
|
||||
* The union of the contacts visible via {@link #getContacts} and {@link #getRegistrant}.
|
||||
*
|
||||
|
@ -234,6 +239,18 @@ public abstract class DomainBase extends EppResource {
|
|||
return tld;
|
||||
}
|
||||
|
||||
@OnSave
|
||||
void dualSaveReferenceUnions() {
|
||||
for (DesignatedContact contact : nullToEmptyImmutableCopy(allContacts)) {
|
||||
contact.contact = contact.contactId.getLinked();
|
||||
}
|
||||
ImmutableSet.Builder<Key<HostResource>> hostKeys = new ImmutableSet.Builder<>();
|
||||
for (ReferenceUnion<HostResource> refUnion : nullToEmptyImmutableCopy(nameservers)) {
|
||||
hostKeys.add(refUnion.getLinked());
|
||||
}
|
||||
nsHosts = hostKeys.build();
|
||||
}
|
||||
|
||||
/** Predicate to determine if a given {@link DesignatedContact} is the registrant. */
|
||||
private static final Predicate<DesignatedContact> IS_REGISTRANT =
|
||||
new Predicate<DesignatedContact>() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue