mirror of
https://github.com/google/nomulus.git
synced 2025-07-25 12:08:36 +02:00
Add fields needed to implement pull queue alternative (#1915)
This commit is contained in:
parent
5a3aa9fa52
commit
ab146c4bf8
7 changed files with 116 additions and 41 deletions
|
@ -32,6 +32,7 @@ import com.google.common.annotations.VisibleForTesting;
|
|||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import google.registry.config.RegistryConfig;
|
||||
import google.registry.dns.RefreshDnsAction;
|
||||
import google.registry.model.annotations.IdAllocation;
|
||||
import google.registry.model.eppcommon.StatusValue;
|
||||
import google.registry.model.transfer.TransferData;
|
||||
|
@ -41,6 +42,7 @@ import java.time.Duration;
|
|||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import javax.annotation.Nullable;
|
||||
import javax.persistence.Access;
|
||||
import javax.persistence.AccessType;
|
||||
import javax.persistence.AttributeOverride;
|
||||
|
@ -134,6 +136,23 @@ public abstract class EppResource extends UpdateAutoTimestampEntity implements B
|
|||
/** Status values associated with this resource. */
|
||||
Set<StatusValue> statuses;
|
||||
|
||||
/**
|
||||
* When this domain/host's DNS was requested to be refreshed, or null if its DNS is up-to-date.
|
||||
*
|
||||
* <p>This will almost always be null except in the couple of minutes' interval between when a
|
||||
* DNS-affecting create or update operation takes place and when the {@link RefreshDnsAction}
|
||||
* runs, which resets this back to null upon completion of the DNS refresh task. This is a {@link
|
||||
* DateTime} rather than a simple dirty boolean so that the DNS refresh action can order by the
|
||||
* DNS refresh request time and take action on the oldest ones first.
|
||||
*
|
||||
* <p>Note that in the {@code DomainHistory}/{@code HostHistory} table this value means something
|
||||
* slightly different: It means that the given domain/host action requested a DNS update. Unlike
|
||||
* on the {@code Domain}/{code Host} table, this value is not then subsequently nulled out once
|
||||
* the DNS refresh is complete; rather, it remains as a permanent record of which actions were
|
||||
* DNS-affecting and which were not.
|
||||
*/
|
||||
@Transient @Nullable protected DateTime dnsRefreshRequestTime;
|
||||
|
||||
public String getRepoId() {
|
||||
return repoId;
|
||||
}
|
||||
|
@ -185,6 +204,19 @@ public abstract class EppResource extends UpdateAutoTimestampEntity implements B
|
|||
return deletionTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the DNS refresh request time iff this domain/host's DNS needs refreshing, otherwise
|
||||
* absent.
|
||||
*/
|
||||
public Optional<DateTime> getDnsRefreshRequestTime() {
|
||||
return Optional.ofNullable(dnsRefreshRequestTime);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private void setInternalDnsRefreshRequestTime(DateTime time) {
|
||||
dnsRefreshRequestTime = time;
|
||||
}
|
||||
|
||||
/** Return a clone of the resource with timed status values modified using the given time. */
|
||||
public abstract EppResource cloneProjectedAtTime(DateTime now);
|
||||
|
||||
|
@ -338,6 +370,11 @@ public abstract class EppResource extends UpdateAutoTimestampEntity implements B
|
|||
return thisCastToDerived();
|
||||
}
|
||||
|
||||
public B setDnsRefreshRequestTime(Optional<DateTime> dnsRefreshRequestTime) {
|
||||
getInstance().dnsRefreshRequestTime = dnsRefreshRequestTime.orElse(null);
|
||||
return thisCastToDerived();
|
||||
}
|
||||
|
||||
/** Build the resource, nullifying empty strings and sets and setting defaults. */
|
||||
@Override
|
||||
public T build() {
|
||||
|
|
|
@ -59,6 +59,7 @@ import org.joda.time.DateTime;
|
|||
@Index(columnList = "tld"),
|
||||
@Index(columnList = "registrantContact"),
|
||||
@Index(columnList = "dnsRefreshRequestTime"),
|
||||
@Index(columnList = "lordnPhase"),
|
||||
@Index(columnList = "billing_recurrence_id"),
|
||||
@Index(columnList = "transfer_billing_event_id"),
|
||||
@Index(columnList = "transfer_billing_recurrence_id")
|
||||
|
@ -200,6 +201,7 @@ public class Domain extends DomainBase implements ForeignKeyedEppResource {
|
|||
.setStatusValues(domainBase.getStatusValues())
|
||||
.setTransferData(domainBase.getTransferData())
|
||||
.setDnsRefreshRequestTime(domainBase.getDnsRefreshRequestTime())
|
||||
.setLordnPhase(domainBase.getLordnPhase())
|
||||
.setCurrentPackageToken(domainBase.getCurrentPackageToken().orElse(null));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,7 +40,6 @@ import com.google.common.collect.ImmutableSet;
|
|||
import com.google.common.collect.ImmutableSortedSet;
|
||||
import com.google.common.collect.Ordering;
|
||||
import com.google.common.collect.Sets;
|
||||
import google.registry.dns.RefreshDnsAction;
|
||||
import google.registry.flows.ResourceFlowUtils;
|
||||
import google.registry.model.EppResource;
|
||||
import google.registry.model.EppResource.ResourceWithTransferData;
|
||||
|
@ -61,6 +60,8 @@ import google.registry.model.transfer.DomainTransferData;
|
|||
import google.registry.model.transfer.TransferStatus;
|
||||
import google.registry.persistence.VKey;
|
||||
import google.registry.tldconfig.idn.IdnLabelValidator;
|
||||
import google.registry.tmch.LordnTaskUtils.LordnPhase;
|
||||
import google.registry.tmch.NordnUploadAction;
|
||||
import google.registry.util.CollectionUtils;
|
||||
import google.registry.util.DateTimeUtils;
|
||||
import java.util.HashSet;
|
||||
|
@ -76,6 +77,8 @@ import javax.persistence.AttributeOverrides;
|
|||
import javax.persistence.Column;
|
||||
import javax.persistence.Embeddable;
|
||||
import javax.persistence.Embedded;
|
||||
import javax.persistence.EnumType;
|
||||
import javax.persistence.Enumerated;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.MappedSuperclass;
|
||||
import javax.persistence.Transient;
|
||||
|
@ -247,34 +250,34 @@ public class DomainBase extends EppResource
|
|||
DateTime autorenewEndTime;
|
||||
|
||||
/**
|
||||
* When this domain's DNS was requested to be refreshed, or null if its DNS is up-to-date.
|
||||
* Which Lordn phase the domain is in after it is created but before the Nordn upload has
|
||||
* processed the domain.
|
||||
*
|
||||
* <p>This will almost always be null except in the couple of minutes' interval between when a
|
||||
* DNS-affecting create or update operation takes place and when the {@link RefreshDnsAction}
|
||||
* runs, which resets this back to null upon completion of the DNS refresh task. This is a {@link
|
||||
* DateTime} rather than a simple dirty boolean so that the DNS refresh action can order by the
|
||||
* DNS refresh request time and take action on the oldest ones first.
|
||||
* <p>This will almost always be {@code NONE} except in the interval between when a domain that
|
||||
* contains a signed mark or claims notice has been created, and when {@link NordnUploadAction}
|
||||
* runs, which includes the domain in the CSV uploaded to TMCH and sets this back to {@code NONE}.
|
||||
*
|
||||
* <p>Note that this is a Cloud SQL-based replacement for the {@code dns-pull} task queue. The
|
||||
* domains that have a non-null value for this field should be exactly the same as the tasks that
|
||||
* would be in the {@code dns-pull} queue.
|
||||
*
|
||||
* <p>Note that in the {@link DomainHistory} table this value means something slightly different:
|
||||
* It means that the given domain action requested a DNS update. Unlike on the {@code Domain}
|
||||
* table, this value is not then subsequently nulled out once the DNS refresh is complete; rather,
|
||||
* it remains as a permanent record of which actions were DNS-affecting and which were not.
|
||||
* <p>Note that in the {@code DomainHistory} table this value means something slightly different:
|
||||
* It means that the given domain was created with a signed mark ({@code SUNRISE} or a claims
|
||||
* notice ({@code CLAIMS}. Unlike on the {@code Domain} table, this value is not then subsequently
|
||||
* set back to {@code NONE} once the Nordn upload is complete; rather, it remains as a permanent
|
||||
* record of when which phase the domain is in when created.
|
||||
*/
|
||||
// TODO(mcilwain): Start using this field once we are further along in the DB migration.
|
||||
DateTime dnsRefreshRequestTime;
|
||||
@Enumerated(EnumType.STRING)
|
||||
LordnPhase lordnPhase = LordnPhase.NONE;
|
||||
|
||||
/** The {@link AllocationToken} for the package this domain is currently a part of. */
|
||||
@Nullable VKey<AllocationToken> currentPackageToken;
|
||||
|
||||
/**
|
||||
* Returns the DNS refresh request time iff this domain's DNS needs refreshing, otherwise absent.
|
||||
*/
|
||||
public Optional<DateTime> getDnsRefreshRequestTime() {
|
||||
return Optional.ofNullable(dnsRefreshRequestTime);
|
||||
public LordnPhase getLordnPhase() {
|
||||
return lordnPhase;
|
||||
}
|
||||
|
||||
@Access(AccessType.PROPERTY)
|
||||
@SuppressWarnings("unused")
|
||||
@Column(name = "dnsRefreshRequestTime")
|
||||
private DateTime getInternalDnsRefreshRequestTime() {
|
||||
return getDnsRefreshRequestTime().orElse(null);
|
||||
}
|
||||
|
||||
public ImmutableSet<String> getSubordinateHosts() {
|
||||
|
@ -861,8 +864,8 @@ public class DomainBase extends EppResource
|
|||
return thisCastToDerived();
|
||||
}
|
||||
|
||||
public B setDnsRefreshRequestTime(Optional<DateTime> dnsRefreshRequestTime) {
|
||||
getInstance().dnsRefreshRequestTime = dnsRefreshRequestTime.orElse(null);
|
||||
public B setLordnPhase(LordnPhase lordnPhase) {
|
||||
getInstance().lordnPhase = lordnPhase;
|
||||
return thisCastToDerived();
|
||||
}
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ import javax.persistence.Table;
|
|||
/**
|
||||
* A persistable Host resource including mutable and non-mutable fields.
|
||||
*
|
||||
* <p>The {@link javax.persistence.Id} of the Host is the repoId.
|
||||
* <p>The {@link Id} of the Host is the repoId.
|
||||
*/
|
||||
@Entity(name = "Host")
|
||||
@Table(
|
||||
|
@ -48,7 +48,8 @@ import javax.persistence.Table;
|
|||
@Index(columnList = "hostName"),
|
||||
@Index(columnList = "creationTime"),
|
||||
@Index(columnList = "deletionTime"),
|
||||
@Index(columnList = "currentSponsorRegistrarId")
|
||||
@Index(columnList = "currentSponsorRegistrarId"),
|
||||
@Index(columnList = "dnsRefreshRequestTime")
|
||||
})
|
||||
@ExternalMessagingName("host")
|
||||
@WithVKey(String.class)
|
||||
|
@ -81,7 +82,7 @@ public class Host extends HostBase implements ForeignKeyedEppResource {
|
|||
}
|
||||
|
||||
public Builder copyFrom(HostBase hostBase) {
|
||||
return this.setCreationRegistrarId(hostBase.getCreationRegistrarId())
|
||||
return setCreationRegistrarId(hostBase.getCreationRegistrarId())
|
||||
.setCreationTime(hostBase.getCreationTime())
|
||||
.setDeletionTime(hostBase.getDeletionTime())
|
||||
.setHostName(hostBase.getHostName())
|
||||
|
@ -93,6 +94,7 @@ public class Host extends HostBase implements ForeignKeyedEppResource {
|
|||
.setPersistedCurrentSponsorRegistrarId(hostBase.getPersistedCurrentSponsorRegistrarId())
|
||||
.setRepoId(hostBase.getRepoId())
|
||||
.setSuperordinateDomain(hostBase.getSuperordinateDomain())
|
||||
.setDnsRefreshRequestTime(hostBase.getDnsRefreshRequestTime())
|
||||
.setStatusValues(hostBase.getStatusValues());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,6 +32,7 @@ import java.util.Set;
|
|||
import javax.annotation.Nullable;
|
||||
import javax.persistence.Access;
|
||||
import javax.persistence.AccessType;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Embeddable;
|
||||
import javax.persistence.MappedSuperclass;
|
||||
import org.joda.time.DateTime;
|
||||
|
@ -85,6 +86,13 @@ public class HostBase extends EppResource {
|
|||
*/
|
||||
DateTime lastSuperordinateChange;
|
||||
|
||||
@Access(AccessType.PROPERTY)
|
||||
@SuppressWarnings("unused")
|
||||
@Column(name = "dnsRefreshRequestTime")
|
||||
private DateTime getInternalDnsRefreshRequestTime() {
|
||||
return getDnsRefreshRequestTime().orElse(null);
|
||||
}
|
||||
|
||||
public String getHostName() {
|
||||
return hostName;
|
||||
}
|
||||
|
|
|
@ -38,10 +38,11 @@ public final class LordnTaskUtils {
|
|||
|
||||
public static final String QUEUE_SUNRISE = "lordn-sunrise";
|
||||
public static final String QUEUE_CLAIMS = "lordn-claims";
|
||||
public static final String COLUMNS_CLAIMS = "roid,domain-name,notice-id,registrar-id,"
|
||||
+ "registration-datetime,ack-datetime,application-datetime";
|
||||
public static final String COLUMNS_SUNRISE = "roid,domain-name,SMD-id,registrar-id,"
|
||||
+ "registration-datetime,application-datetime";
|
||||
public static final String COLUMNS_CLAIMS =
|
||||
"roid,domain-name,notice-id,registrar-id,"
|
||||
+ "registration-datetime,ack-datetime,application-datetime";
|
||||
public static final String COLUMNS_SUNRISE =
|
||||
"roid,domain-name,SMD-id,registrar-id," + "registration-datetime,application-datetime";
|
||||
|
||||
/** Enqueues a task in the LORDN queue representing a line of CSV for LORDN export. */
|
||||
public static void enqueueDomainTask(Domain domain) {
|
||||
|
@ -50,15 +51,17 @@ public final class LordnTaskUtils {
|
|||
// isn't yet populated when this method is called during the resource flow.
|
||||
String tld = domain.getTld();
|
||||
if (domain.getLaunchNotice() == null) {
|
||||
getQueue(QUEUE_SUNRISE).add(TaskOptions.Builder
|
||||
.withTag(tld)
|
||||
.method(Method.PULL)
|
||||
.payload(getCsvLineForSunriseDomain(domain, tm().getTransactionTime())));
|
||||
getQueue(QUEUE_SUNRISE)
|
||||
.add(
|
||||
TaskOptions.Builder.withTag(tld)
|
||||
.method(Method.PULL)
|
||||
.payload(getCsvLineForSunriseDomain(domain, tm().getTransactionTime())));
|
||||
} else {
|
||||
getQueue(QUEUE_CLAIMS).add(TaskOptions.Builder
|
||||
.withTag(tld)
|
||||
.method(Method.PULL)
|
||||
.payload(getCsvLineForClaimsDomain(domain, tm().getTransactionTime())));
|
||||
getQueue(QUEUE_CLAIMS)
|
||||
.add(
|
||||
TaskOptions.Builder.withTag(tld)
|
||||
.method(Method.PULL)
|
||||
.payload(getCsvLineForClaimsDomain(domain, tm().getTransactionTime())));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -95,4 +98,18 @@ public final class LordnTaskUtils {
|
|||
}
|
||||
|
||||
private LordnTaskUtils() {}
|
||||
|
||||
public enum LordnPhase {
|
||||
SUNRISE(QUEUE_SUNRISE),
|
||||
|
||||
CLAIMS(QUEUE_CLAIMS),
|
||||
|
||||
NONE(null);
|
||||
|
||||
final String queue;
|
||||
|
||||
LordnPhase(String queue) {
|
||||
this.queue = queue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue