From 7a14f23c79b31fee5337a2bf4ad01a5b18d74d56 Mon Sep 17 00:00:00 2001 From: gbrodman Date: Thu, 20 Jan 2022 20:50:10 +0000 Subject: [PATCH] Use the read-only replica for JPA invoicing (#1494) * Use the read-only replica for JPA invoicing --- .../billing/GenerateInvoicesAction.java | 22 +++++++++---------- .../beam/invoicing_pipeline_metadata.json | 6 +++++ 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/core/src/main/java/google/registry/reporting/billing/GenerateInvoicesAction.java b/core/src/main/java/google/registry/reporting/billing/GenerateInvoicesAction.java index a180e9d32..1219b2e1a 100644 --- a/core/src/main/java/google/registry/reporting/billing/GenerateInvoicesAction.java +++ b/core/src/main/java/google/registry/reporting/billing/GenerateInvoicesAction.java @@ -32,6 +32,7 @@ import com.google.common.net.MediaType; import google.registry.config.RegistryConfig.Config; import google.registry.config.RegistryEnvironment; import google.registry.model.common.DatabaseMigrationStateSchedule.PrimaryDatabase; +import google.registry.persistence.PersistenceModule; import google.registry.reporting.ReportingModule; import google.registry.request.Action; import google.registry.request.Parameter; @@ -120,17 +121,16 @@ public class GenerateInvoicesAction implements Runnable { .setContainerSpecGcsPath( String.format("%s/%s_metadata.json", stagingBucketUrl, PIPELINE_NAME)) .setParameters( - ImmutableMap.of( - "yearMonth", - yearMonth.toString("yyyy-MM"), - "invoiceFilePrefix", - invoiceFilePrefix, - "database", - database.name(), - "billingBucketUrl", - billingBucketUrl, - "registryEnvironment", - RegistryEnvironment.get().name())); + new ImmutableMap.Builder() + .put("yearMonth", yearMonth.toString("yyyy-MM")) + .put("invoiceFilePrefix", invoiceFilePrefix) + .put("database", database.name()) + .put("billingBucketUrl", billingBucketUrl) + .put("registryEnvironment", RegistryEnvironment.get().name()) + .put( + "jpaTransactionManagerType", + PersistenceModule.JpaTransactionManagerType.READ_ONLY_REPLICA.toString()) + .build()); LaunchFlexTemplateResponse launchResponse = dataflow .projects() diff --git a/core/src/main/resources/google/registry/beam/invoicing_pipeline_metadata.json b/core/src/main/resources/google/registry/beam/invoicing_pipeline_metadata.json index ecab86358..28d1ce822 100644 --- a/core/src/main/resources/google/registry/beam/invoicing_pipeline_metadata.json +++ b/core/src/main/resources/google/registry/beam/invoicing_pipeline_metadata.json @@ -69,6 +69,12 @@ "regexes": [ "^DATASTORE|CLOUD_SQL$" ] + }, + { + "name": "jpaTransactionManagerType", + "label": "The type of JPA transaction manager to use if using SQL", + "helpText": "The standard SQL instance or a read-only replica may be used", + "regexes": ["^REGULAR|READ_ONLY_REPLICA$"] } ] }