1
0
mirror of https://github.com/google/nomulus synced 2026-02-08 22:10:28 +00:00

Export entity integrity alerts to BigQuery

This is part 2 of a longer series.  Part 3 will add lots more tests, will add a cron entry, and will include an analysis script to run on BigQuery to detect the presence of two consecutive errors.
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=120040267
This commit is contained in:
mcilwain
2016-04-16 12:45:10 -07:00
committed by Justine Tunney
parent f20b1d89a9
commit 4fbf613955
11 changed files with 784 additions and 161 deletions

View File

@@ -41,6 +41,8 @@ import com.google.domain.registry.util.NonFinalForTesting;
import java.io.IOException;
import java.util.Set;
import javax.inject.Inject;
/** Factory for creating {@link Bigquery} connections. */
public class BigqueryFactory {
@@ -57,6 +59,8 @@ public class BigqueryFactory {
@VisibleForTesting
Subfactory subfactory = new Subfactory();
@Inject public BigqueryFactory() {}
/** This class is broken out solely so that it can be mocked inside of tests. */
static class Subfactory {

View File

@@ -25,6 +25,13 @@ import java.util.Map;
/** Schemas for BigQuery tables. */
public final class BigquerySchemas {
public static final String EPPMETRICS_TABLE_ID = "eppMetrics";
public static final String ENTITY_INTEGRITY_ALERTS_TABLE_ID = "alerts";
public static final String ENTITY_INTEGRITY_ALERTS_FIELD_SCANTIME = "scanTime";
public static final String ENTITY_INTEGRITY_ALERTS_FIELD_SOURCE = "source";
public static final String ENTITY_INTEGRITY_ALERTS_FIELD_TARGET = "target";
public static final String ENTITY_INTEGRITY_ALERTS_FIELD_MESSAGE = "message";
static final ImmutableList<TableFieldSchema> EPPMETRICS_SCHEMA_FIELDS =
ImmutableList.<TableFieldSchema>of(
new TableFieldSchema().setName("requestId").setType(FieldType.STRING.name()),
@@ -37,11 +44,27 @@ public final class BigquerySchemas {
new TableFieldSchema().setName("eppStatus").setType(FieldType.INTEGER.name()),
new TableFieldSchema().setName("attempts").setType(FieldType.INTEGER.name()));
public static final String EPPMETRICS_TABLE_ID = "eppMetrics";
static final ImmutableList<TableFieldSchema> ENTITY_INTEGRITY_ALERTS_SCHEMA_FIELDS =
ImmutableList.<TableFieldSchema>of(
new TableFieldSchema()
.setName(ENTITY_INTEGRITY_ALERTS_FIELD_SCANTIME)
.setType(FieldType.TIMESTAMP.name()),
new TableFieldSchema()
.setName(ENTITY_INTEGRITY_ALERTS_FIELD_SOURCE)
.setType(FieldType.STRING.name()),
new TableFieldSchema()
.setName(ENTITY_INTEGRITY_ALERTS_FIELD_TARGET)
.setType(FieldType.STRING.name()),
new TableFieldSchema()
.setName(ENTITY_INTEGRITY_ALERTS_FIELD_MESSAGE)
.setType(FieldType.STRING.name()));
@NonFinalForTesting
static Map<String, ImmutableList<TableFieldSchema>> knownTableSchemas =
ImmutableMap.of(EPPMETRICS_TABLE_ID, EPPMETRICS_SCHEMA_FIELDS);
new ImmutableMap.Builder<String, ImmutableList<TableFieldSchema>>()
.put(EPPMETRICS_TABLE_ID, EPPMETRICS_SCHEMA_FIELDS)
.put(ENTITY_INTEGRITY_ALERTS_TABLE_ID, ENTITY_INTEGRITY_ALERTS_SCHEMA_FIELDS)
.build();
private BigquerySchemas() {}
}