diff --git a/java/google/registry/batch/BUILD b/java/google/registry/batch/BUILD index 7351acccc..f7cb46eef 100644 --- a/java/google/registry/batch/BUILD +++ b/java/google/registry/batch/BUILD @@ -8,6 +8,8 @@ java_library( name = "batch", srcs = glob(["*.java"]), deps = [ + "//apiserving/discoverydata/bigquery:bigqueryv2", + "//java/com/google/api/client/util", "//java/com/google/common/annotations", "//java/com/google/common/base", "//java/com/google/common/collect", @@ -15,17 +17,22 @@ java_library( "//java/com/google/common/io", "//java/com/google/common/math", "//java/com/google/common/net", + "//java/google/registry/bigquery", + "//java/google/registry/config", "//java/google/registry/dns", "//java/google/registry/flows", "//java/google/registry/mapreduce", "//java/google/registry/mapreduce/inputs", "//java/google/registry/model", + "//java/google/registry/monitoring/whitebox", "//java/google/registry/pricing", "//java/google/registry/request", + "//java/google/registry/request:modules", "//java/google/registry/util", "//third_party/java/appengine:appengine-api", "//third_party/java/appengine_gcs_client", "//third_party/java/appengine_mapreduce2:appengine_mapreduce", + "//third_party/java/auto:auto_factory", "//third_party/java/auto:auto_value", "//third_party/java/dagger", "//third_party/java/joda_money", diff --git a/java/google/registry/monitoring/whitebox/WhiteboxComponent.java b/java/google/registry/batch/BatchComponent.java similarity index 84% rename from java/google/registry/monitoring/whitebox/WhiteboxComponent.java rename to java/google/registry/batch/BatchComponent.java index b24515d64..c5c512bbc 100644 --- a/java/google/registry/monitoring/whitebox/WhiteboxComponent.java +++ b/java/google/registry/batch/BatchComponent.java @@ -12,25 +12,27 @@ // See the License for the specific language governing permissions and // limitations under the License. -package google.registry.monitoring.whitebox; +package google.registry.batch; import dagger.Component; import google.registry.bigquery.BigqueryModule; import google.registry.config.ConfigModule; +import google.registry.monitoring.whitebox.WhiteboxModule; import google.registry.request.Modules.DatastoreServiceModule; import google.registry.util.SystemSleeper.SystemSleeperModule; import javax.inject.Singleton; -/** Dagger component with instance lifetime for Whitebox package. */ +/** Dagger component with instance lifetime for batch package. */ @Singleton @Component( modules = { + BatchModule.class, BigqueryModule.class, ConfigModule.class, DatastoreServiceModule.class, SystemSleeperModule.class, WhiteboxModule.class }) -interface WhiteboxComponent { +interface BatchComponent { VerifyEntityIntegrityStreamerFactory verifyEntityIntegrityStreamerFactory(); } diff --git a/java/google/registry/batch/BatchModule.java b/java/google/registry/batch/BatchModule.java new file mode 100644 index 000000000..70e215214 --- /dev/null +++ b/java/google/registry/batch/BatchModule.java @@ -0,0 +1,36 @@ +// Copyright 2016 The Nomulus Authors. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package google.registry.batch; + +import com.google.api.services.bigquery.model.TableFieldSchema; +import com.google.common.collect.ImmutableList; +import dagger.Module; +import dagger.Provides; +import dagger.multibindings.IntoMap; +import dagger.multibindings.StringKey; + +/** + * Dagger module for injecting common settings for batch actions. + */ +@Module +public class BatchModule { + + @Provides + @IntoMap + @StringKey(EntityIntegrityAlertsSchema.TABLE_ID) + static ImmutableList provideEntityIntegrityAlertsSchema() { + return EntityIntegrityAlertsSchema.SCHEMA_FIELDS; + } +} diff --git a/java/google/registry/monitoring/whitebox/EntityIntegrityAlertsSchema.java b/java/google/registry/batch/EntityIntegrityAlertsSchema.java similarity index 97% rename from java/google/registry/monitoring/whitebox/EntityIntegrityAlertsSchema.java rename to java/google/registry/batch/EntityIntegrityAlertsSchema.java index efeeab622..044848ee6 100644 --- a/java/google/registry/monitoring/whitebox/EntityIntegrityAlertsSchema.java +++ b/java/google/registry/batch/EntityIntegrityAlertsSchema.java @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package google.registry.monitoring.whitebox; +package google.registry.batch; import static google.registry.bigquery.BigqueryUtils.FieldType.STRING; import static google.registry.bigquery.BigqueryUtils.FieldType.TIMESTAMP; diff --git a/java/google/registry/monitoring/whitebox/VerifyEntityIntegrityAction.java b/java/google/registry/batch/VerifyEntityIntegrityAction.java similarity index 99% rename from java/google/registry/monitoring/whitebox/VerifyEntityIntegrityAction.java rename to java/google/registry/batch/VerifyEntityIntegrityAction.java index d815c152f..6eda0782c 100644 --- a/java/google/registry/monitoring/whitebox/VerifyEntityIntegrityAction.java +++ b/java/google/registry/batch/VerifyEntityIntegrityAction.java @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package google.registry.monitoring.whitebox; +package google.registry.batch; import static com.google.common.base.Preconditions.checkState; import static com.google.common.collect.Iterables.getOnlyElement; @@ -95,7 +95,7 @@ public class VerifyEntityIntegrityAction implements Runnable { private static final int NUM_SHARDS = 200; @NonFinalForTesting @VisibleForTesting - static WhiteboxComponent component = DaggerWhiteboxComponent.create(); + static BatchComponent component = DaggerBatchComponent.create(); private static final ImmutableSet> RESOURCE_CLASSES = ImmutableSet.>of( ForeignKeyDomainIndex.class, diff --git a/java/google/registry/monitoring/whitebox/VerifyEntityIntegrityStreamer.java b/java/google/registry/batch/VerifyEntityIntegrityStreamer.java similarity index 92% rename from java/google/registry/monitoring/whitebox/VerifyEntityIntegrityStreamer.java rename to java/google/registry/batch/VerifyEntityIntegrityStreamer.java index 8061a341d..fe65ac61a 100644 --- a/java/google/registry/monitoring/whitebox/VerifyEntityIntegrityStreamer.java +++ b/java/google/registry/batch/VerifyEntityIntegrityStreamer.java @@ -12,15 +12,15 @@ // See the License for the specific language governing permissions and // limitations under the License. -package google.registry.monitoring.whitebox; +package google.registry.batch; import static com.google.api.client.util.Data.NULL_STRING; -import static google.registry.monitoring.whitebox.EntityIntegrityAlertsSchema.DATASET; -import static google.registry.monitoring.whitebox.EntityIntegrityAlertsSchema.FIELD_MESSAGE; -import static google.registry.monitoring.whitebox.EntityIntegrityAlertsSchema.FIELD_SCANTIME; -import static google.registry.monitoring.whitebox.EntityIntegrityAlertsSchema.FIELD_SOURCE; -import static google.registry.monitoring.whitebox.EntityIntegrityAlertsSchema.FIELD_TARGET; -import static google.registry.monitoring.whitebox.EntityIntegrityAlertsSchema.TABLE_ID; +import static google.registry.batch.EntityIntegrityAlertsSchema.DATASET; +import static google.registry.batch.EntityIntegrityAlertsSchema.FIELD_MESSAGE; +import static google.registry.batch.EntityIntegrityAlertsSchema.FIELD_SCANTIME; +import static google.registry.batch.EntityIntegrityAlertsSchema.FIELD_SOURCE; +import static google.registry.batch.EntityIntegrityAlertsSchema.FIELD_TARGET; +import static google.registry.batch.EntityIntegrityAlertsSchema.TABLE_ID; import com.google.api.services.bigquery.Bigquery; import com.google.api.services.bigquery.Bigquery.Tabledata.InsertAll; diff --git a/java/google/registry/module/backend/BackendRequestComponent.java b/java/google/registry/module/backend/BackendRequestComponent.java index 9bab1e074..4331d54c5 100644 --- a/java/google/registry/module/backend/BackendRequestComponent.java +++ b/java/google/registry/module/backend/BackendRequestComponent.java @@ -21,10 +21,12 @@ import google.registry.backup.CommitLogCheckpointAction; import google.registry.backup.DeleteOldCommitLogsAction; import google.registry.backup.ExportCommitLogDiffAction; import google.registry.backup.RestoreCommitLogsAction; +import google.registry.batch.BatchModule; import google.registry.batch.DeleteContactsAndHostsAction; import google.registry.batch.DeleteProberDataAction; import google.registry.batch.ExpandRecurringBillingEventsAction; import google.registry.batch.RefreshDnsOnHostRenameAction; +import google.registry.batch.VerifyEntityIntegrityAction; import google.registry.cron.CommitLogFanoutAction; import google.registry.cron.CronModule; import google.registry.cron.TldFanoutAction; @@ -47,7 +49,6 @@ import google.registry.export.sheet.SyncRegistrarsSheetAction; import google.registry.flows.async.AsyncFlowsModule; import google.registry.mapreduce.MapreduceModule; import google.registry.monitoring.whitebox.MetricsExportAction; -import google.registry.monitoring.whitebox.VerifyEntityIntegrityAction; import google.registry.monitoring.whitebox.WhiteboxModule; import google.registry.rde.BrdaCopyAction; import google.registry.rde.RdeModule; @@ -75,6 +76,7 @@ import google.registry.tmch.TmchSmdrlAction; AsyncFlowsModule.class, BackendModule.class, BackupModule.class, + BatchModule.class, CloudDnsWriterModule.class, CronModule.class, DnsModule.class, diff --git a/java/google/registry/monitoring/whitebox/BUILD b/java/google/registry/monitoring/whitebox/BUILD index e8ba2352f..253735c15 100644 --- a/java/google/registry/monitoring/whitebox/BUILD +++ b/java/google/registry/monitoring/whitebox/BUILD @@ -12,7 +12,6 @@ java_library( "//google/monitoring:monitoring_java_lib", "//java/com/google/api/client/http", "//java/com/google/api/client/json", - "//java/com/google/api/client/util", "//java/com/google/common/annotations", "//java/com/google/common/base", "//java/com/google/common/cache", @@ -20,16 +19,11 @@ java_library( "//java/com/google/common/net", "//java/google/registry/bigquery", "//java/google/registry/config", - "//java/google/registry/mapreduce", - "//java/google/registry/mapreduce/inputs", "//java/google/registry/model", "//java/google/registry/monitoring/metrics", "//java/google/registry/request", - "//java/google/registry/request:modules", "//java/google/registry/util", "//third_party/java/appengine:appengine-api", - "//third_party/java/appengine_mapreduce2:appengine_mapreduce", - "//third_party/java/auto:auto_factory", "//third_party/java/auto:auto_value", "//third_party/java/dagger", "//third_party/java/joda_time", diff --git a/java/google/registry/monitoring/whitebox/WhiteboxModule.java b/java/google/registry/monitoring/whitebox/WhiteboxModule.java index 52ff50b6c..81625f196 100644 --- a/java/google/registry/monitoring/whitebox/WhiteboxModule.java +++ b/java/google/registry/monitoring/whitebox/WhiteboxModule.java @@ -45,13 +45,6 @@ public class WhiteboxModule { return EppMetric.SCHEMA_FIELDS; } - @Provides - @IntoMap - @StringKey(EntityIntegrityAlertsSchema.TABLE_ID) - static ImmutableList provideEntityIntegrityAlertsSchema() { - return EntityIntegrityAlertsSchema.SCHEMA_FIELDS; - } - @Provides @Parameter("tableId") static String provideTableId(HttpServletRequest req) { diff --git a/javatests/google/registry/batch/BUILD b/javatests/google/registry/batch/BUILD index 25a2a5a59..cf6962b18 100644 --- a/javatests/google/registry/batch/BUILD +++ b/javatests/google/registry/batch/BUILD @@ -11,13 +11,17 @@ java_library( name = "batch", srcs = glob(["*.java"]), deps = [ + "//apiserving/discoverydata/bigquery:bigqueryv2", + "//java/com/google/api/client/util", "//java/com/google/common/annotations", "//java/com/google/common/base", "//java/com/google/common/collect", "//java/com/google/common/io", "//java/com/google/common/net", "//java/google/registry/batch", + "//java/google/registry/bigquery", "//java/google/registry/flows", + "//java/google/registry/mapreduce", "//java/google/registry/model", "//java/google/registry/util", "//javatests/google/registry/testing", diff --git a/javatests/google/registry/monitoring/whitebox/VerifyEntityIntegrityActionTest.java b/javatests/google/registry/batch/VerifyEntityIntegrityActionTest.java similarity index 99% rename from javatests/google/registry/monitoring/whitebox/VerifyEntityIntegrityActionTest.java rename to javatests/google/registry/batch/VerifyEntityIntegrityActionTest.java index 1abac6ae3..41c9be3e2 100644 --- a/javatests/google/registry/monitoring/whitebox/VerifyEntityIntegrityActionTest.java +++ b/javatests/google/registry/batch/VerifyEntityIntegrityActionTest.java @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package google.registry.monitoring.whitebox; +package google.registry.batch; import static com.google.common.truth.Truth.assertThat; import static google.registry.testing.DatastoreHelper.createTld; @@ -104,7 +104,7 @@ public class VerifyEntityIntegrityActionTest action = new VerifyEntityIntegrityAction(); action.mrRunner = new MapreduceRunner(Optional.of(2), Optional.of(2)); action.response = new FakeResponse(); - WhiteboxComponent component = mock(WhiteboxComponent.class); + BatchComponent component = mock(BatchComponent.class); inject.setStaticField(VerifyEntityIntegrityAction.class, "component", component); integrity = new VerifyEntityIntegrityStreamer(