Move VerifyEntityIntegrityAction to batch package

By moving []s into the batch package, which is not included in the frontend service, we pave the way to remove the dependency of frontend on the [] library.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=142265351
This commit is contained in:
mountford 2016-12-16 09:07:43 -08:00 committed by Ben McIlwain
parent 246098d8e8
commit 0afafeff03
11 changed files with 67 additions and 29 deletions

View file

@ -8,6 +8,8 @@ java_library(
name = "batch", name = "batch",
srcs = glob(["*.java"]), srcs = glob(["*.java"]),
deps = [ deps = [
"//apiserving/discoverydata/bigquery:bigqueryv2",
"//java/com/google/api/client/util",
"//java/com/google/common/annotations", "//java/com/google/common/annotations",
"//java/com/google/common/base", "//java/com/google/common/base",
"//java/com/google/common/collect", "//java/com/google/common/collect",
@ -15,17 +17,22 @@ java_library(
"//java/com/google/common/io", "//java/com/google/common/io",
"//java/com/google/common/math", "//java/com/google/common/math",
"//java/com/google/common/net", "//java/com/google/common/net",
"//java/google/registry/bigquery",
"//java/google/registry/config",
"//java/google/registry/dns", "//java/google/registry/dns",
"//java/google/registry/flows", "//java/google/registry/flows",
"//java/google/registry/mapreduce", "//java/google/registry/mapreduce",
"//java/google/registry/mapreduce/inputs", "//java/google/registry/mapreduce/inputs",
"//java/google/registry/model", "//java/google/registry/model",
"//java/google/registry/monitoring/whitebox",
"//java/google/registry/pricing", "//java/google/registry/pricing",
"//java/google/registry/request", "//java/google/registry/request",
"//java/google/registry/request:modules",
"//java/google/registry/util", "//java/google/registry/util",
"//third_party/java/appengine:appengine-api", "//third_party/java/appengine:appengine-api",
"//third_party/java/appengine_gcs_client", "//third_party/java/appengine_gcs_client",
"//third_party/java/appengine_mapreduce2:appengine_mapreduce", "//third_party/java/appengine_mapreduce2:appengine_mapreduce",
"//third_party/java/auto:auto_factory",
"//third_party/java/auto:auto_value", "//third_party/java/auto:auto_value",
"//third_party/java/dagger", "//third_party/java/dagger",
"//third_party/java/joda_money", "//third_party/java/joda_money",

View file

@ -12,25 +12,27 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
package google.registry.monitoring.whitebox; package google.registry.batch;
import dagger.Component; import dagger.Component;
import google.registry.bigquery.BigqueryModule; import google.registry.bigquery.BigqueryModule;
import google.registry.config.ConfigModule; import google.registry.config.ConfigModule;
import google.registry.monitoring.whitebox.WhiteboxModule;
import google.registry.request.Modules.DatastoreServiceModule; import google.registry.request.Modules.DatastoreServiceModule;
import google.registry.util.SystemSleeper.SystemSleeperModule; import google.registry.util.SystemSleeper.SystemSleeperModule;
import javax.inject.Singleton; import javax.inject.Singleton;
/** Dagger component with instance lifetime for Whitebox package. */ /** Dagger component with instance lifetime for batch package. */
@Singleton @Singleton
@Component( @Component(
modules = { modules = {
BatchModule.class,
BigqueryModule.class, BigqueryModule.class,
ConfigModule.class, ConfigModule.class,
DatastoreServiceModule.class, DatastoreServiceModule.class,
SystemSleeperModule.class, SystemSleeperModule.class,
WhiteboxModule.class WhiteboxModule.class
}) })
interface WhiteboxComponent { interface BatchComponent {
VerifyEntityIntegrityStreamerFactory verifyEntityIntegrityStreamerFactory(); VerifyEntityIntegrityStreamerFactory verifyEntityIntegrityStreamerFactory();
} }

View file

@ -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<TableFieldSchema> provideEntityIntegrityAlertsSchema() {
return EntityIntegrityAlertsSchema.SCHEMA_FIELDS;
}
}

View file

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // 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.STRING;
import static google.registry.bigquery.BigqueryUtils.FieldType.TIMESTAMP; import static google.registry.bigquery.BigqueryUtils.FieldType.TIMESTAMP;

View file

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // 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.base.Preconditions.checkState;
import static com.google.common.collect.Iterables.getOnlyElement; import static com.google.common.collect.Iterables.getOnlyElement;
@ -95,7 +95,7 @@ public class VerifyEntityIntegrityAction implements Runnable {
private static final int NUM_SHARDS = 200; private static final int NUM_SHARDS = 200;
@NonFinalForTesting @NonFinalForTesting
@VisibleForTesting @VisibleForTesting
static WhiteboxComponent component = DaggerWhiteboxComponent.create(); static BatchComponent component = DaggerBatchComponent.create();
private static final ImmutableSet<Class<?>> RESOURCE_CLASSES = private static final ImmutableSet<Class<?>> RESOURCE_CLASSES =
ImmutableSet.<Class<?>>of( ImmutableSet.<Class<?>>of(
ForeignKeyDomainIndex.class, ForeignKeyDomainIndex.class,

View file

@ -12,15 +12,15 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // 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 com.google.api.client.util.Data.NULL_STRING;
import static google.registry.monitoring.whitebox.EntityIntegrityAlertsSchema.DATASET; import static google.registry.batch.EntityIntegrityAlertsSchema.DATASET;
import static google.registry.monitoring.whitebox.EntityIntegrityAlertsSchema.FIELD_MESSAGE; import static google.registry.batch.EntityIntegrityAlertsSchema.FIELD_MESSAGE;
import static google.registry.monitoring.whitebox.EntityIntegrityAlertsSchema.FIELD_SCANTIME; import static google.registry.batch.EntityIntegrityAlertsSchema.FIELD_SCANTIME;
import static google.registry.monitoring.whitebox.EntityIntegrityAlertsSchema.FIELD_SOURCE; import static google.registry.batch.EntityIntegrityAlertsSchema.FIELD_SOURCE;
import static google.registry.monitoring.whitebox.EntityIntegrityAlertsSchema.FIELD_TARGET; import static google.registry.batch.EntityIntegrityAlertsSchema.FIELD_TARGET;
import static google.registry.monitoring.whitebox.EntityIntegrityAlertsSchema.TABLE_ID; import static google.registry.batch.EntityIntegrityAlertsSchema.TABLE_ID;
import com.google.api.services.bigquery.Bigquery; import com.google.api.services.bigquery.Bigquery;
import com.google.api.services.bigquery.Bigquery.Tabledata.InsertAll; import com.google.api.services.bigquery.Bigquery.Tabledata.InsertAll;

View file

@ -21,10 +21,12 @@ import google.registry.backup.CommitLogCheckpointAction;
import google.registry.backup.DeleteOldCommitLogsAction; import google.registry.backup.DeleteOldCommitLogsAction;
import google.registry.backup.ExportCommitLogDiffAction; import google.registry.backup.ExportCommitLogDiffAction;
import google.registry.backup.RestoreCommitLogsAction; import google.registry.backup.RestoreCommitLogsAction;
import google.registry.batch.BatchModule;
import google.registry.batch.DeleteContactsAndHostsAction; import google.registry.batch.DeleteContactsAndHostsAction;
import google.registry.batch.DeleteProberDataAction; import google.registry.batch.DeleteProberDataAction;
import google.registry.batch.ExpandRecurringBillingEventsAction; import google.registry.batch.ExpandRecurringBillingEventsAction;
import google.registry.batch.RefreshDnsOnHostRenameAction; import google.registry.batch.RefreshDnsOnHostRenameAction;
import google.registry.batch.VerifyEntityIntegrityAction;
import google.registry.cron.CommitLogFanoutAction; import google.registry.cron.CommitLogFanoutAction;
import google.registry.cron.CronModule; import google.registry.cron.CronModule;
import google.registry.cron.TldFanoutAction; import google.registry.cron.TldFanoutAction;
@ -47,7 +49,6 @@ import google.registry.export.sheet.SyncRegistrarsSheetAction;
import google.registry.flows.async.AsyncFlowsModule; import google.registry.flows.async.AsyncFlowsModule;
import google.registry.mapreduce.MapreduceModule; import google.registry.mapreduce.MapreduceModule;
import google.registry.monitoring.whitebox.MetricsExportAction; import google.registry.monitoring.whitebox.MetricsExportAction;
import google.registry.monitoring.whitebox.VerifyEntityIntegrityAction;
import google.registry.monitoring.whitebox.WhiteboxModule; import google.registry.monitoring.whitebox.WhiteboxModule;
import google.registry.rde.BrdaCopyAction; import google.registry.rde.BrdaCopyAction;
import google.registry.rde.RdeModule; import google.registry.rde.RdeModule;
@ -75,6 +76,7 @@ import google.registry.tmch.TmchSmdrlAction;
AsyncFlowsModule.class, AsyncFlowsModule.class,
BackendModule.class, BackendModule.class,
BackupModule.class, BackupModule.class,
BatchModule.class,
CloudDnsWriterModule.class, CloudDnsWriterModule.class,
CronModule.class, CronModule.class,
DnsModule.class, DnsModule.class,

View file

@ -12,7 +12,6 @@ java_library(
"//google/monitoring:monitoring_java_lib", "//google/monitoring:monitoring_java_lib",
"//java/com/google/api/client/http", "//java/com/google/api/client/http",
"//java/com/google/api/client/json", "//java/com/google/api/client/json",
"//java/com/google/api/client/util",
"//java/com/google/common/annotations", "//java/com/google/common/annotations",
"//java/com/google/common/base", "//java/com/google/common/base",
"//java/com/google/common/cache", "//java/com/google/common/cache",
@ -20,16 +19,11 @@ java_library(
"//java/com/google/common/net", "//java/com/google/common/net",
"//java/google/registry/bigquery", "//java/google/registry/bigquery",
"//java/google/registry/config", "//java/google/registry/config",
"//java/google/registry/mapreduce",
"//java/google/registry/mapreduce/inputs",
"//java/google/registry/model", "//java/google/registry/model",
"//java/google/registry/monitoring/metrics", "//java/google/registry/monitoring/metrics",
"//java/google/registry/request", "//java/google/registry/request",
"//java/google/registry/request:modules",
"//java/google/registry/util", "//java/google/registry/util",
"//third_party/java/appengine:appengine-api", "//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/auto:auto_value",
"//third_party/java/dagger", "//third_party/java/dagger",
"//third_party/java/joda_time", "//third_party/java/joda_time",

View file

@ -45,13 +45,6 @@ public class WhiteboxModule {
return EppMetric.SCHEMA_FIELDS; return EppMetric.SCHEMA_FIELDS;
} }
@Provides
@IntoMap
@StringKey(EntityIntegrityAlertsSchema.TABLE_ID)
static ImmutableList<TableFieldSchema> provideEntityIntegrityAlertsSchema() {
return EntityIntegrityAlertsSchema.SCHEMA_FIELDS;
}
@Provides @Provides
@Parameter("tableId") @Parameter("tableId")
static String provideTableId(HttpServletRequest req) { static String provideTableId(HttpServletRequest req) {

View file

@ -11,13 +11,17 @@ java_library(
name = "batch", name = "batch",
srcs = glob(["*.java"]), srcs = glob(["*.java"]),
deps = [ deps = [
"//apiserving/discoverydata/bigquery:bigqueryv2",
"//java/com/google/api/client/util",
"//java/com/google/common/annotations", "//java/com/google/common/annotations",
"//java/com/google/common/base", "//java/com/google/common/base",
"//java/com/google/common/collect", "//java/com/google/common/collect",
"//java/com/google/common/io", "//java/com/google/common/io",
"//java/com/google/common/net", "//java/com/google/common/net",
"//java/google/registry/batch", "//java/google/registry/batch",
"//java/google/registry/bigquery",
"//java/google/registry/flows", "//java/google/registry/flows",
"//java/google/registry/mapreduce",
"//java/google/registry/model", "//java/google/registry/model",
"//java/google/registry/util", "//java/google/registry/util",
"//javatests/google/registry/testing", "//javatests/google/registry/testing",

View file

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
package google.registry.monitoring.whitebox; package google.registry.batch;
import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertThat;
import static google.registry.testing.DatastoreHelper.createTld; import static google.registry.testing.DatastoreHelper.createTld;
@ -104,7 +104,7 @@ public class VerifyEntityIntegrityActionTest
action = new VerifyEntityIntegrityAction(); action = new VerifyEntityIntegrityAction();
action.mrRunner = new MapreduceRunner(Optional.of(2), Optional.of(2)); action.mrRunner = new MapreduceRunner(Optional.of(2), Optional.of(2));
action.response = new FakeResponse(); action.response = new FakeResponse();
WhiteboxComponent component = mock(WhiteboxComponent.class); BatchComponent component = mock(BatchComponent.class);
inject.setStaticField(VerifyEntityIntegrityAction.class, "component", component); inject.setStaticField(VerifyEntityIntegrityAction.class, "component", component);
integrity = integrity =
new VerifyEntityIntegrityStreamer( new VerifyEntityIntegrityStreamer(