mirror of
https://github.com/google/nomulus.git
synced 2025-08-03 00:12:11 +02:00
Add a cron schedule for the BSA upload unavailable domains task (#2280)
Also fixes the action taken in the case where zero unavailable domains are found, and temporarily changes over to using the primary DB (because the replica transaction was timing out at 30 seconds on large databases). I'll switch this over to use batching and move it back to replica afterwards, but this should unblock us temporarily.
This commit is contained in:
parent
d7edd27cdd
commit
9d4c38684a
2 changed files with 27 additions and 4 deletions
|
@ -18,7 +18,9 @@ import static com.google.common.collect.ImmutableSet.toImmutableSet;
|
|||
import static google.registry.model.tld.Tld.isEnrolledWithBsa;
|
||||
import static google.registry.model.tld.Tlds.getTldEntitiesOfType;
|
||||
import static google.registry.model.tld.label.ReservedList.loadReservedLists;
|
||||
import static google.registry.persistence.PersistenceModule.TransactionIsolationLevel.TRANSACTION_REPEATABLE_READ;
|
||||
import static google.registry.persistence.transaction.TransactionManagerFactory.replicaTm;
|
||||
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
||||
import static google.registry.request.Action.Method.POST;
|
||||
import static java.nio.charset.StandardCharsets.US_ASCII;
|
||||
|
||||
|
@ -104,11 +106,19 @@ public class UploadBsaUnavailableDomainsAction implements Runnable {
|
|||
|
||||
@Override
|
||||
public void run() {
|
||||
// TODO(mcilwain): Implement a date Cursor, have the cronjob run frequently, and short-circuit
|
||||
// the run if the daily upload is already completed.
|
||||
DateTime runTime = clock.nowUtc();
|
||||
// TODO(mcilwain): Batch this.
|
||||
String unavailableDomains =
|
||||
Joiner.on("\n").join(replicaTm().transact(() -> getUnavailableDomains(runTime)));
|
||||
uploadToGcs(unavailableDomains, runTime);
|
||||
uploadToBsa(unavailableDomains, runTime);
|
||||
Joiner.on("\n")
|
||||
.join(tm().transact(() -> getUnavailableDomains(runTime), TRANSACTION_REPEATABLE_READ));
|
||||
if (unavailableDomains.isEmpty()) {
|
||||
logger.atWarning().log("No unavailable domains found; terminating.");
|
||||
} else {
|
||||
uploadToGcs(unavailableDomains, runTime);
|
||||
uploadToBsa(unavailableDomains, runTime);
|
||||
}
|
||||
}
|
||||
|
||||
/** Uploads the unavailable domains list to GCS in the unavailable domains bucket. */
|
||||
|
@ -187,7 +197,9 @@ public class UploadBsaUnavailableDomainsAction implements Runnable {
|
|||
.filter(tld -> isEnrolledWithBsa(tld, runTime))
|
||||
.collect(toImmutableSet());
|
||||
|
||||
logger.atInfo().log("Getting unavailable domains in TLDs: %s ...", bsaEnabledTlds);
|
||||
logger.atInfo().log(
|
||||
"Getting unavailable domains in TLDs: %s ...",
|
||||
bsaEnabledTlds.stream().map(Tld::getTldStr).collect(toImmutableSet()));
|
||||
|
||||
ImmutableSortedSet.Builder<String> unavailableDomains =
|
||||
new ImmutableSortedSet.Builder<>(Ordering.natural());
|
||||
|
|
|
@ -138,4 +138,15 @@
|
|||
</description>
|
||||
<schedule>*/1 * * * *</schedule>
|
||||
</task>
|
||||
|
||||
<task>
|
||||
<url><![CDATA[/_dr/task/uploadBsaUnavailableNames]]></url>
|
||||
<name>uploadBsaUnavailableNames</name>
|
||||
<description>
|
||||
This job uploads all unavailable domain names (those registered and
|
||||
reserved) to the BSA.
|
||||
</description>
|
||||
<service>bsa</service>
|
||||
<schedule>23 8,20 * * *</schedule>
|
||||
</task>
|
||||
</entries>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue