Migrate to Flogger (green)

This is a 'green' Flogger migration CL. Green CLs are intended to be as
safe as possible and should be easy to review and submit.

No changes should be necessary to the code itself prior to submission,
but small changes to BUILD files may be required.

Changes within files are completely independent of each other, so this CL
can be safely split up for review using tools such as Rosie.

For more information, see []
Base CL: 197826149

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=198560170
This commit is contained in:
jianglai 2018-05-30 07:58:51 -07:00
parent 0d2fb3a8f0
commit 70b13596e4
178 changed files with 984 additions and 988 deletions

View file

@ -8,7 +8,6 @@ java_library(
name = "backup", name = "backup",
srcs = glob(["*.java"]), srcs = glob(["*.java"]),
deps = [ deps = [
"//java/com/google/common/logging:formatting_logger",
"//java/google/registry/config", "//java/google/registry/config",
"//java/google/registry/cron", "//java/google/registry/cron",
"//java/google/registry/mapreduce", "//java/google/registry/mapreduce",
@ -24,6 +23,8 @@ java_library(
"@com_google_auto_value", "@com_google_auto_value",
"@com_google_code_findbugs_jsr305", "@com_google_code_findbugs_jsr305",
"@com_google_dagger", "@com_google_dagger",
"@com_google_flogger",
"@com_google_flogger_system_backend",
"@com_google_guava", "@com_google_guava",
"@com_googlecode_json_simple", "@com_googlecode_json_simple",
"@javax_servlet_api", "@javax_servlet_api",

View file

@ -16,13 +16,12 @@ package google.registry.backup;
import static com.google.appengine.api.taskqueue.QueueFactory.getQueue; import static com.google.appengine.api.taskqueue.QueueFactory.getQueue;
import static com.google.appengine.api.taskqueue.TaskOptions.Builder.withUrl; import static com.google.appengine.api.taskqueue.TaskOptions.Builder.withUrl;
import static com.google.common.logging.FormattingLogger.getLoggerForCallerClass;
import static google.registry.backup.ExportCommitLogDiffAction.LOWER_CHECKPOINT_TIME_PARAM; import static google.registry.backup.ExportCommitLogDiffAction.LOWER_CHECKPOINT_TIME_PARAM;
import static google.registry.backup.ExportCommitLogDiffAction.UPPER_CHECKPOINT_TIME_PARAM; import static google.registry.backup.ExportCommitLogDiffAction.UPPER_CHECKPOINT_TIME_PARAM;
import static google.registry.model.ofy.ObjectifyService.ofy; import static google.registry.model.ofy.ObjectifyService.ofy;
import static google.registry.util.DateTimeUtils.isBeforeOrAt; import static google.registry.util.DateTimeUtils.isBeforeOrAt;
import com.google.common.logging.FormattingLogger; import com.google.common.flogger.FluentLogger;
import google.registry.model.ofy.CommitLogCheckpoint; import google.registry.model.ofy.CommitLogCheckpoint;
import google.registry.model.ofy.CommitLogCheckpointRoot; import google.registry.model.ofy.CommitLogCheckpointRoot;
import google.registry.request.Action; import google.registry.request.Action;
@ -50,7 +49,7 @@ import org.joda.time.DateTime;
) )
public final class CommitLogCheckpointAction implements Runnable { public final class CommitLogCheckpointAction implements Runnable {
private static final FormattingLogger logger = getLoggerForCallerClass(); private static final FluentLogger logger = FluentLogger.forEnclosingClass();
private static final String QUEUE_NAME = "export-commits"; private static final String QUEUE_NAME = "export-commits";
@ -62,13 +61,15 @@ public final class CommitLogCheckpointAction implements Runnable {
@Override @Override
public void run() { public void run() {
final CommitLogCheckpoint checkpoint = strategy.computeCheckpoint(); final CommitLogCheckpoint checkpoint = strategy.computeCheckpoint();
logger.infofmt("Generated candidate checkpoint for time: %s", checkpoint.getCheckpointTime()); logger.atInfo().log(
"Generated candidate checkpoint for time: %s", checkpoint.getCheckpointTime());
ofy() ofy()
.transact( .transact(
() -> { () -> {
DateTime lastWrittenTime = CommitLogCheckpointRoot.loadRoot().getLastWrittenTime(); DateTime lastWrittenTime = CommitLogCheckpointRoot.loadRoot().getLastWrittenTime();
if (isBeforeOrAt(checkpoint.getCheckpointTime(), lastWrittenTime)) { if (isBeforeOrAt(checkpoint.getCheckpointTime(), lastWrittenTime)) {
logger.infofmt("Newer checkpoint already written at time: %s", lastWrittenTime); logger.atInfo().log(
"Newer checkpoint already written at time: %s", lastWrittenTime);
return; return;
} }
ofy() ofy()

View file

@ -16,7 +16,6 @@ package google.registry.backup;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Preconditions.checkState; import static com.google.common.base.Preconditions.checkState;
import static com.google.common.logging.FormattingLogger.getLoggerForCallerClass;
import static google.registry.mapreduce.MapreduceRunner.PARAM_DRY_RUN; import static google.registry.mapreduce.MapreduceRunner.PARAM_DRY_RUN;
import static google.registry.model.ofy.ObjectifyService.ofy; import static google.registry.model.ofy.ObjectifyService.ofy;
import static google.registry.util.PipelineUtils.createJobPath; import static google.registry.util.PipelineUtils.createJobPath;
@ -29,7 +28,7 @@ import com.google.appengine.tools.mapreduce.ReducerInput;
import com.google.auto.value.AutoValue; import com.google.auto.value.AutoValue;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMultiset; import com.google.common.collect.ImmutableMultiset;
import com.google.common.logging.FormattingLogger; import com.google.common.flogger.FluentLogger;
import com.googlecode.objectify.Key; import com.googlecode.objectify.Key;
import google.registry.config.RegistryConfig.Config; import google.registry.config.RegistryConfig.Config;
import google.registry.mapreduce.MapreduceRunner; import google.registry.mapreduce.MapreduceRunner;
@ -73,7 +72,7 @@ public final class DeleteOldCommitLogsAction implements Runnable {
private static final int NUM_MAP_SHARDS = 20; private static final int NUM_MAP_SHARDS = 20;
private static final int NUM_REDUCE_SHARDS = 10; private static final int NUM_REDUCE_SHARDS = 10;
private static final FormattingLogger logger = getLoggerForCallerClass(); private static final FluentLogger logger = FluentLogger.forEnclosingClass();
@Inject MapreduceRunner mrRunner; @Inject MapreduceRunner mrRunner;
@Inject Response response; @Inject Response response;
@ -85,7 +84,7 @@ public final class DeleteOldCommitLogsAction implements Runnable {
@Override @Override
public void run() { public void run() {
DateTime deletionThreshold = clock.nowUtc().minus(maxAge); DateTime deletionThreshold = clock.nowUtc().minus(maxAge);
logger.infofmt( logger.atInfo().log(
"Processing asynchronous deletion of unreferenced CommitLogManifests older than %s", "Processing asynchronous deletion of unreferenced CommitLogManifests older than %s",
deletionThreshold); deletionThreshold);
@ -182,7 +181,7 @@ public final class DeleteOldCommitLogsAction implements Runnable {
// First - check if there even are revisions // First - check if there even are revisions
if (eppResource.getRevisions().isEmpty()) { if (eppResource.getRevisions().isEmpty()) {
getContext().incrementCounter("EPP resources missing all revisions (SEE LOGS)"); getContext().incrementCounter("EPP resources missing all revisions (SEE LOGS)");
logger.severefmt("EPP resource missing all revisions: %s", Key.create(eppResource)); logger.atSevere().log("EPP resource missing all revisions: %s", Key.create(eppResource));
return; return;
} }
// Next, check if there's a revision that's older than "CommitLogDatastoreRetention". There // Next, check if there's a revision that's older than "CommitLogDatastoreRetention". There
@ -198,9 +197,9 @@ public final class DeleteOldCommitLogsAction implements Runnable {
} }
// The oldest revision date is newer than the threshold! This shouldn't happen. // The oldest revision date is newer than the threshold! This shouldn't happen.
getContext().incrementCounter("EPP resources missing pre-threshold revision (SEE LOGS)"); getContext().incrementCounter("EPP resources missing pre-threshold revision (SEE LOGS)");
logger.severefmt( logger.atSevere().log(
"EPP resource missing old enough revision: " "EPP resource missing old enough revision: "
+ "%s (created on %s) has %s revisions between %s and %s, while threshold is %s", + "%s (created on %s) has %d revisions between %s and %s, while threshold is %s",
Key.create(eppResource), Key.create(eppResource),
eppResource.getCreationTime(), eppResource.getCreationTime(),
eppResource.getRevisions().size(), eppResource.getRevisions().size(),
@ -320,7 +319,8 @@ public final class DeleteOldCommitLogsAction implements Runnable {
getContext().incrementCounter("attempts to delete an already deleted manifest"); getContext().incrementCounter("attempts to delete an already deleted manifest");
break; break;
case AFTER_THRESHOLD: case AFTER_THRESHOLD:
logger.severefmt("Won't delete CommitLogManifest %s that is too recent.", manifestKey); logger.atSevere().log(
"Won't delete CommitLogManifest %s that is too recent.", manifestKey);
getContext().incrementCounter("manifests incorrectly assigned for deletion (SEE LOGS)"); getContext().incrementCounter("manifests incorrectly assigned for deletion (SEE LOGS)");
break; break;
} }

View file

@ -20,7 +20,6 @@ import static com.google.common.base.Verify.verifyNotNull;
import static com.google.common.collect.ImmutableList.toImmutableList; import static com.google.common.collect.ImmutableList.toImmutableList;
import static com.google.common.collect.Iterables.concat; import static com.google.common.collect.Iterables.concat;
import static com.google.common.collect.Lists.partition; import static com.google.common.collect.Lists.partition;
import static com.google.common.logging.FormattingLogger.getLoggerForCallerClass;
import static google.registry.backup.BackupUtils.GcsMetadataKeys.LOWER_BOUND_CHECKPOINT; import static google.registry.backup.BackupUtils.GcsMetadataKeys.LOWER_BOUND_CHECKPOINT;
import static google.registry.backup.BackupUtils.GcsMetadataKeys.NUM_TRANSACTIONS; import static google.registry.backup.BackupUtils.GcsMetadataKeys.NUM_TRANSACTIONS;
import static google.registry.backup.BackupUtils.GcsMetadataKeys.UPPER_BOUND_CHECKPOINT; import static google.registry.backup.BackupUtils.GcsMetadataKeys.UPPER_BOUND_CHECKPOINT;
@ -39,7 +38,7 @@ import com.google.appengine.tools.cloudstorage.GcsService;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Streams; import com.google.common.collect.Streams;
import com.google.common.logging.FormattingLogger; import com.google.common.flogger.FluentLogger;
import com.googlecode.objectify.Key; import com.googlecode.objectify.Key;
import google.registry.config.RegistryConfig.Config; import google.registry.config.RegistryConfig.Config;
import google.registry.model.ImmutableObject; import google.registry.model.ImmutableObject;
@ -68,7 +67,7 @@ import org.joda.time.DateTime;
) )
public final class ExportCommitLogDiffAction implements Runnable { public final class ExportCommitLogDiffAction implements Runnable {
private static final FormattingLogger logger = getLoggerForCallerClass(); private static final FluentLogger logger = FluentLogger.forEnclosingClass();
static final String PATH = "/_dr/task/exportCommitLogDiff"; static final String PATH = "/_dr/task/exportCommitLogDiff";
static final String UPPER_CHECKPOINT_TIME_PARAM = "upperCheckpointTime"; static final String UPPER_CHECKPOINT_TIME_PARAM = "upperCheckpointTime";
@ -85,7 +84,7 @@ public final class ExportCommitLogDiffAction implements Runnable {
@Override @Override
public void run() { public void run() {
logger.infofmt( logger.atInfo().log(
"Exporting commit log diffs between %s and %s.", lowerCheckpointTime, upperCheckpointTime); "Exporting commit log diffs between %s and %s.", lowerCheckpointTime, upperCheckpointTime);
checkArgument(isAtOrAfter(lowerCheckpointTime, START_OF_TIME)); checkArgument(isAtOrAfter(lowerCheckpointTime, START_OF_TIME));
checkArgument(lowerCheckpointTime.isBefore(upperCheckpointTime)); checkArgument(lowerCheckpointTime.isBefore(upperCheckpointTime));
@ -99,7 +98,7 @@ public final class ExportCommitLogDiffAction implements Runnable {
// Load the keys of all the manifests to include in this diff. // Load the keys of all the manifests to include in this diff.
List<Key<CommitLogManifest>> sortedKeys = loadAllDiffKeys(lowerCheckpoint, upperCheckpoint); List<Key<CommitLogManifest>> sortedKeys = loadAllDiffKeys(lowerCheckpoint, upperCheckpoint);
logger.infofmt("Found %d manifests to export", sortedKeys.size()); logger.atInfo().log("Found %d manifests to export", sortedKeys.size());
// Open an output channel to GCS, wrapped in a stream for convenience. // Open an output channel to GCS, wrapped in a stream for convenience.
try (OutputStream gcsStream = newOutputStream(gcsService.createOrReplace( try (OutputStream gcsStream = newOutputStream(gcsService.createOrReplace(
new GcsFilename(gcsBucket, DIFF_FILE_PREFIX + upperCheckpointTime), new GcsFilename(gcsBucket, DIFF_FILE_PREFIX + upperCheckpointTime),
@ -123,7 +122,7 @@ public final class ExportCommitLogDiffAction implements Runnable {
for (int i = 0; i < keyChunks.size(); i++) { for (int i = 0; i < keyChunks.size(); i++) {
// Force the async load to finish. // Force the async load to finish.
Collection<CommitLogManifest> chunkValues = nextChunkToExport.values(); Collection<CommitLogManifest> chunkValues = nextChunkToExport.values();
logger.infofmt("Loaded %d manifests", chunkValues.size()); logger.atInfo().log("Loaded %d manifests", chunkValues.size());
// Since there is no hard bound on how much data this might be, take care not to let the // Since there is no hard bound on how much data this might be, take care not to let the
// Objectify session cache fill up and potentially run out of memory. This is the only safe // Objectify session cache fill up and potentially run out of memory. This is the only safe
// point to do this since at this point there is no async load in progress. // point to do this since at this point there is no async load in progress.
@ -133,12 +132,12 @@ public final class ExportCommitLogDiffAction implements Runnable {
nextChunkToExport = ofy().load().keys(keyChunks.get(i + 1)); nextChunkToExport = ofy().load().keys(keyChunks.get(i + 1));
} }
exportChunk(gcsStream, chunkValues); exportChunk(gcsStream, chunkValues);
logger.infofmt("Exported %d manifests", chunkValues.size()); logger.atInfo().log("Exported %d manifests", chunkValues.size());
} }
} catch (IOException e) { } catch (IOException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
logger.infofmt("Exported %d manifests in total", sortedKeys.size()); logger.atInfo().log("Exported %d manifests in total", sortedKeys.size());
} }
/** /**

View file

@ -27,7 +27,7 @@ import com.google.appengine.tools.cloudstorage.GcsService;
import com.google.appengine.tools.cloudstorage.ListItem; import com.google.appengine.tools.cloudstorage.ListItem;
import com.google.appengine.tools.cloudstorage.ListOptions; import com.google.appengine.tools.cloudstorage.ListOptions;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.logging.FormattingLogger; import com.google.common.flogger.FluentLogger;
import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.ListeningExecutorService; import com.google.common.util.concurrent.ListeningExecutorService;
@ -44,7 +44,7 @@ import org.joda.time.DateTime;
/** Utility class to list commit logs diff files stored on GCS. */ /** Utility class to list commit logs diff files stored on GCS. */
class GcsDiffFileLister { class GcsDiffFileLister {
private static final FormattingLogger logger = FormattingLogger.getLoggerForCallerClass(); private static final FluentLogger logger = FluentLogger.forEnclosingClass();
@Inject GcsService gcsService; @Inject GcsService gcsService;
@Inject @Config("commitLogGcsBucket") String gcsBucket; @Inject @Config("commitLogGcsBucket") String gcsBucket;
@ -68,30 +68,29 @@ class GcsDiffFileLister {
metadata = Futures.getUnchecked(upperBoundTimesToMetadata.get(checkpointTime)); metadata = Futures.getUnchecked(upperBoundTimesToMetadata.get(checkpointTime));
} else { } else {
String filename = DIFF_FILE_PREFIX + checkpointTime; String filename = DIFF_FILE_PREFIX + checkpointTime;
logger.infofmt("Patching GCS list; discovered file: %s", filename); logger.atInfo().log("Patching GCS list; discovered file: %s", filename);
metadata = getMetadata(filename); metadata = getMetadata(filename);
// If we hit a gap, quit. // If we hit a gap, quit.
if (metadata == null) { if (metadata == null) {
logger.infofmt( logger.atInfo().log(
"Gap discovered in sequence terminating at %s, missing file: %s", "Gap discovered in sequence terminating at %s, missing file: %s",
sequence.lastKey(), sequence.lastKey(), filename);
filename); logger.atInfo().log("Found sequence from %s to %s", checkpointTime, lastTime);
logger.infofmt("Found sequence from %s to %s", checkpointTime, lastTime);
return false; return false;
} }
} }
sequence.put(checkpointTime, metadata); sequence.put(checkpointTime, metadata);
checkpointTime = getLowerBoundTime(metadata); checkpointTime = getLowerBoundTime(metadata);
} }
logger.infofmt("Found sequence from %s to %s", checkpointTime, lastTime); logger.atInfo().log("Found sequence from %s to %s", checkpointTime, lastTime);
return true; return true;
} }
ImmutableList<GcsFileMetadata> listDiffFiles(DateTime fromTime, @Nullable DateTime toTime) { ImmutableList<GcsFileMetadata> listDiffFiles(DateTime fromTime, @Nullable DateTime toTime) {
logger.infofmt("Requested restore from time: %s", fromTime); logger.atInfo().log("Requested restore from time: %s", fromTime);
if (toTime != null) { if (toTime != null) {
logger.infofmt(" Until time: %s", toTime); logger.atInfo().log(" Until time: %s", toTime);
} }
// List all of the diff files on GCS and build a map from each file's upper checkpoint time // List all of the diff files on GCS and build a map from each file's upper checkpoint time
// (extracted from the filename) to its asynchronously-loaded metadata, keeping only files with // (extracted from the filename) to its asynchronously-loaded metadata, keeping only files with
@ -117,7 +116,7 @@ class GcsDiffFileLister {
} }
} }
if (upperBoundTimesToMetadata.isEmpty()) { if (upperBoundTimesToMetadata.isEmpty()) {
logger.info("No files found"); logger.atInfo().log("No files found");
return ImmutableList.of(); return ImmutableList.of();
} }
@ -130,7 +129,7 @@ class GcsDiffFileLister {
// last file and work backwards we can verify that we have no holes in our chain (although we // last file and work backwards we can verify that we have no holes in our chain (although we
// may be missing files at the end). // may be missing files at the end).
TreeMap<DateTime, GcsFileMetadata> sequence = new TreeMap<>(); TreeMap<DateTime, GcsFileMetadata> sequence = new TreeMap<>();
logger.infofmt("Restoring until: %s", lastUpperBoundTime); logger.atInfo().log("Restoring until: %s", lastUpperBoundTime);
boolean inconsistentFileSet = !constructDiffSequence( boolean inconsistentFileSet = !constructDiffSequence(
upperBoundTimesToMetadata, fromTime, lastUpperBoundTime, sequence); upperBoundTimesToMetadata, fromTime, lastUpperBoundTime, sequence);
@ -157,9 +156,9 @@ class GcsDiffFileLister {
"Unable to compute commit diff history, there are either gaps or forks in the history " "Unable to compute commit diff history, there are either gaps or forks in the history "
+ "file set. Check log for details."); + "file set. Check log for details.");
logger.infofmt( logger.atInfo().log(
"Actual restore from time: %s", getLowerBoundTime(sequence.firstEntry().getValue())); "Actual restore from time: %s", getLowerBoundTime(sequence.firstEntry().getValue()));
logger.infofmt("Found %d files to restore", sequence.size()); logger.atInfo().log("Found %d files to restore", sequence.size());
return ImmutableList.copyOf(sequence.values()); return ImmutableList.copyOf(sequence.values());
} }

View file

@ -29,7 +29,7 @@ import com.google.appengine.tools.cloudstorage.GcsService;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.google.common.collect.PeekingIterator; import com.google.common.collect.PeekingIterator;
import com.google.common.collect.Streams; import com.google.common.collect.Streams;
import com.google.common.logging.FormattingLogger; import com.google.common.flogger.FluentLogger;
import com.googlecode.objectify.Key; import com.googlecode.objectify.Key;
import com.googlecode.objectify.Result; import com.googlecode.objectify.Result;
import com.googlecode.objectify.util.ResultNow; import com.googlecode.objectify.util.ResultNow;
@ -64,7 +64,7 @@ import org.joda.time.DateTime;
) )
public class RestoreCommitLogsAction implements Runnable { public class RestoreCommitLogsAction implements Runnable {
private static final FormattingLogger logger = FormattingLogger.getLoggerForCallerClass(); private static final FluentLogger logger = FluentLogger.forEnclosingClass();
static final int BLOCK_SIZE = 1024 * 1024; // Buffer 1mb at a time, for no particular reason. static final int BLOCK_SIZE = 1024 * 1024; // Buffer 1mb at a time, for no particular reason.
@ -90,17 +90,17 @@ public class RestoreCommitLogsAction implements Runnable {
|| RegistryEnvironment.get() == RegistryEnvironment.UNITTEST, || RegistryEnvironment.get() == RegistryEnvironment.UNITTEST,
"DO NOT RUN ANYWHERE ELSE EXCEPT ALPHA, CRASH OR TESTS."); "DO NOT RUN ANYWHERE ELSE EXCEPT ALPHA, CRASH OR TESTS.");
if (dryRun) { if (dryRun) {
logger.info("Running in dryRun mode"); logger.atInfo().log("Running in dryRun mode");
} }
List<GcsFileMetadata> diffFiles = diffLister.listDiffFiles(fromTime, toTime); List<GcsFileMetadata> diffFiles = diffLister.listDiffFiles(fromTime, toTime);
if (diffFiles.isEmpty()) { if (diffFiles.isEmpty()) {
logger.info("Nothing to restore"); logger.atInfo().log("Nothing to restore");
return; return;
} }
Map<Integer, DateTime> bucketTimestamps = new HashMap<>(); Map<Integer, DateTime> bucketTimestamps = new HashMap<>();
CommitLogCheckpoint lastCheckpoint = null; CommitLogCheckpoint lastCheckpoint = null;
for (GcsFileMetadata metadata : diffFiles) { for (GcsFileMetadata metadata : diffFiles) {
logger.infofmt("Restoring: %s", metadata.getFilename().getObjectName()); logger.atInfo().log("Restoring: %s", metadata.getFilename().getObjectName());
try (InputStream input = Channels.newInputStream( try (InputStream input = Channels.newInputStream(
gcsService.openPrefetchingReadChannel(metadata.getFilename(), 0, BLOCK_SIZE))) { gcsService.openPrefetchingReadChannel(metadata.getFilename(), 0, BLOCK_SIZE))) {
PeekingIterator<ImmutableObject> commitLogs = PeekingIterator<ImmutableObject> commitLogs =
@ -129,7 +129,7 @@ public class RestoreCommitLogsAction implements Runnable {
.build()), .build()),
Stream.of(CommitLogCheckpointRoot.create(lastCheckpoint.getCheckpointTime()))) Stream.of(CommitLogCheckpointRoot.create(lastCheckpoint.getCheckpointTime())))
.collect(toImmutableList())); .collect(toImmutableList()));
logger.info("Restore complete"); logger.atInfo().log("Restore complete");
} }
/** /**
@ -164,7 +164,7 @@ public class RestoreCommitLogsAction implements Runnable {
private void saveRaw(List<Entity> entitiesToSave) { private void saveRaw(List<Entity> entitiesToSave) {
if (dryRun) { if (dryRun) {
logger.infofmt("Would have saved entities: %s", entitiesToSave); logger.atInfo().log("Would have saved entities: %s", entitiesToSave);
return; return;
} }
retrier.callWithRetry(() -> datastoreService.put(entitiesToSave), RuntimeException.class); retrier.callWithRetry(() -> datastoreService.put(entitiesToSave), RuntimeException.class);
@ -172,7 +172,7 @@ public class RestoreCommitLogsAction implements Runnable {
private void saveOfy(Iterable<? extends ImmutableObject> objectsToSave) { private void saveOfy(Iterable<? extends ImmutableObject> objectsToSave) {
if (dryRun) { if (dryRun) {
logger.infofmt("Would have saved entities: %s", objectsToSave); logger.atInfo().log("Would have saved entities: %s", objectsToSave);
return; return;
} }
retrier.callWithRetry( retrier.callWithRetry(
@ -181,7 +181,7 @@ public class RestoreCommitLogsAction implements Runnable {
private Result<?> deleteAsync(Set<Key<?>> keysToDelete) { private Result<?> deleteAsync(Set<Key<?>> keysToDelete) {
if (dryRun) { if (dryRun) {
logger.infofmt("Would have deleted entities: %s", keysToDelete); logger.atInfo().log("Would have deleted entities: %s", keysToDelete);
} }
return dryRun || keysToDelete.isEmpty() return dryRun || keysToDelete.isEmpty()
? new ResultNow<Void>(null) ? new ResultNow<Void>(null)

View file

@ -8,7 +8,6 @@ java_library(
name = "batch", name = "batch",
srcs = glob(["*.java"]), srcs = glob(["*.java"]),
deps = [ deps = [
"//java/com/google/common/logging:formatting_logger",
"//java/google/registry/bigquery", "//java/google/registry/bigquery",
"//java/google/registry/config", "//java/google/registry/config",
"//java/google/registry/dns", "//java/google/registry/dns",
@ -32,6 +31,8 @@ java_library(
"@com_google_auto_value", "@com_google_auto_value",
"@com_google_code_findbugs_jsr305", "@com_google_code_findbugs_jsr305",
"@com_google_dagger", "@com_google_dagger",
"@com_google_flogger",
"@com_google_flogger_system_backend",
"@com_google_guava", "@com_google_guava",
"@com_google_http_client", "@com_google_http_client",
"@com_googlecode_json_simple", "@com_googlecode_json_simple",

View file

@ -19,7 +19,6 @@ import static com.google.appengine.api.taskqueue.QueueFactory.getQueue;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Preconditions.checkState; import static com.google.common.base.Preconditions.checkState;
import static com.google.common.collect.ImmutableList.toImmutableList; import static com.google.common.collect.ImmutableList.toImmutableList;
import static com.google.common.logging.FormattingLogger.getLoggerForCallerClass;
import static com.google.common.math.IntMath.divide; import static com.google.common.math.IntMath.divide;
import static com.googlecode.objectify.Key.getKind; import static com.googlecode.objectify.Key.getKind;
import static google.registry.flows.ResourceFlowUtils.denyPendingTransfer; import static google.registry.flows.ResourceFlowUtils.denyPendingTransfer;
@ -58,7 +57,7 @@ import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Iterators; import com.google.common.collect.Iterators;
import com.google.common.collect.Multiset; import com.google.common.collect.Multiset;
import com.google.common.logging.FormattingLogger; import com.google.common.flogger.FluentLogger;
import com.googlecode.objectify.Key; import com.googlecode.objectify.Key;
import google.registry.batch.DeleteContactsAndHostsAction.DeletionResult.Type; import google.registry.batch.DeleteContactsAndHostsAction.DeletionResult.Type;
import google.registry.dns.DnsQueue; import google.registry.dns.DnsQueue;
@ -112,7 +111,7 @@ public class DeleteContactsAndHostsAction implements Runnable {
static final String KIND_HOST = getKind(HostResource.class); static final String KIND_HOST = getKind(HostResource.class);
private static final long LEASE_MINUTES = 20; private static final long LEASE_MINUTES = 20;
private static final FormattingLogger logger = getLoggerForCallerClass(); private static final FluentLogger logger = FluentLogger.forEnclosingClass();
private static final int MAX_REDUCE_SHARDS = 50; private static final int MAX_REDUCE_SHARDS = 50;
private static final int DELETES_PER_SHARD = 5; private static final int DELETES_PER_SHARD = 5;
@ -149,8 +148,8 @@ public class DeleteContactsAndHostsAction implements Runnable {
requestsToDelete.add(deletionRequest); requestsToDelete.add(deletionRequest);
} }
} catch (Exception e) { } catch (Exception e) {
logger.severefmt( logger.atSevere().withCause(e).log(
e, "Could not parse async deletion request, delaying task for a day: %s", task); "Could not parse async deletion request, delaying task for a day: %s", task);
// Grab the lease for a whole day, so that it won't continue throwing errors every five // Grab the lease for a whole day, so that it won't continue throwing errors every five
// minutes. // minutes.
queue.modifyTaskLease(task, 1L, DAYS); queue.modifyTaskLease(task, 1L, DAYS);
@ -159,10 +158,10 @@ public class DeleteContactsAndHostsAction implements Runnable {
deleteStaleTasksWithRetry(requestsToDelete); deleteStaleTasksWithRetry(requestsToDelete);
ImmutableList<DeletionRequest> deletionRequests = builder.build(); ImmutableList<DeletionRequest> deletionRequests = builder.build();
if (deletionRequests.isEmpty()) { if (deletionRequests.isEmpty()) {
logger.info("No asynchronous deletions to process because all were already handled."); logger.atInfo().log("No asynchronous deletions to process because all were already handled.");
response.setPayload("All requested deletions of contacts/hosts have already occurred."); response.setPayload("All requested deletions of contacts/hosts have already occurred.");
} else { } else {
logger.infofmt( logger.atInfo().log(
"Processing asynchronous deletion of %d contacts and %d hosts: %s", "Processing asynchronous deletion of %d contacts and %d hosts: %s",
kindCounts.count(KIND_CONTACT), kindCounts.count(KIND_HOST), resourceKeys.build()); kindCounts.count(KIND_CONTACT), kindCounts.count(KIND_HOST), resourceKeys.build());
runMapreduce(deletionRequests); runMapreduce(deletionRequests);
@ -204,7 +203,8 @@ public class DeleteContactsAndHostsAction implements Runnable {
new NullInput<>(), new NullInput<>(),
EppResourceInputs.createEntityInput(DomainBase.class))))); EppResourceInputs.createEntityInput(DomainBase.class)))));
} catch (Throwable t) { } catch (Throwable t) {
logger.severefmt(t, "Error while kicking off mapreduce to delete contacts/hosts"); logger.atSevere().withCause(t).log(
"Error while kicking off mapreduce to delete contacts/hosts");
} }
} }
@ -274,7 +274,7 @@ public class DeleteContactsAndHostsAction implements Runnable {
@Override @Override
public void reduce(final DeletionRequest deletionRequest, ReducerInput<Boolean> values) { public void reduce(final DeletionRequest deletionRequest, ReducerInput<Boolean> values) {
final boolean hasNoActiveReferences = !Iterators.contains(values, true); final boolean hasNoActiveReferences = !Iterators.contains(values, true);
logger.infofmt("Processing async deletion request for %s", deletionRequest.key()); logger.atInfo().log("Processing async deletion request for %s", deletionRequest.key());
DeletionResult result = DeletionResult result =
ofy() ofy()
.transactNew( .transactNew(
@ -290,7 +290,7 @@ public class DeleteContactsAndHostsAction implements Runnable {
deletionRequest.requestedTime()); deletionRequest.requestedTime());
String resourceNamePlural = deletionRequest.key().getKind() + "s"; String resourceNamePlural = deletionRequest.key().getKind() + "s";
getContext().incrementCounter(result.type().renderCounterText(resourceNamePlural)); getContext().incrementCounter(result.type().renderCounterText(resourceNamePlural));
logger.infofmt( logger.atInfo().log(
"Result of async deletion for resource %s: %s", "Result of async deletion for resource %s: %s",
deletionRequest.key(), result.pollMessageText()); deletionRequest.key(), result.pollMessageText());
} }
@ -563,11 +563,12 @@ public class DeleteContactsAndHostsAction implements Runnable {
static boolean doesResourceStateAllowDeletion(EppResource resource, DateTime now) { static boolean doesResourceStateAllowDeletion(EppResource resource, DateTime now) {
Key<EppResource> key = Key.create(resource); Key<EppResource> key = Key.create(resource);
if (isDeleted(resource, now)) { if (isDeleted(resource, now)) {
logger.warningfmt("Cannot asynchronously delete %s because it is already deleted", key); logger.atWarning().log("Cannot asynchronously delete %s because it is already deleted", key);
return false; return false;
} }
if (!resource.getStatusValues().contains(PENDING_DELETE)) { if (!resource.getStatusValues().contains(PENDING_DELETE)) {
logger.warningfmt("Cannot asynchronously delete %s because it is not in PENDING_DELETE", key); logger.atWarning().log(
"Cannot asynchronously delete %s because it is not in PENDING_DELETE", key);
return false; return false;
} }
return true; return true;

View file

@ -24,7 +24,7 @@ import static google.registry.request.Action.Method.POST;
import com.google.appengine.tools.mapreduce.Mapper; import com.google.appengine.tools.mapreduce.Mapper;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.google.common.logging.FormattingLogger; import com.google.common.flogger.FluentLogger;
import com.googlecode.objectify.Key; import com.googlecode.objectify.Key;
import google.registry.config.RegistryEnvironment; import google.registry.config.RegistryEnvironment;
import google.registry.mapreduce.MapreduceRunner; import google.registry.mapreduce.MapreduceRunner;
@ -54,7 +54,7 @@ import javax.inject.Inject;
@Action(path = "/_dr/task/deleteLoadTestData", method = POST, auth = Auth.AUTH_INTERNAL_ONLY) @Action(path = "/_dr/task/deleteLoadTestData", method = POST, auth = Auth.AUTH_INTERNAL_ONLY)
public class DeleteLoadTestDataAction implements Runnable { public class DeleteLoadTestDataAction implements Runnable {
private static final FormattingLogger logger = FormattingLogger.getLoggerForCallerClass(); private static final FluentLogger logger = FluentLogger.forEnclosingClass();
/** /**
* The registrars for which to wipe out all contacts/hosts. * The registrars for which to wipe out all contacts/hosts.
@ -136,7 +136,7 @@ public class DeleteLoadTestDataAction implements Runnable {
.addAll(resourceAndDependentKeys) .addAll(resourceAndDependentKeys)
.build(); .build();
if (isDryRun) { if (isDryRun) {
logger.infofmt("Would hard-delete the following entities: %s", allKeys); logger.atInfo().log("Would hard-delete the following entities: %s", allKeys);
} else { } else {
ofy().deleteWithoutBackup().keys(allKeys); ofy().deleteWithoutBackup().keys(allKeys);
} }

View file

@ -33,7 +33,7 @@ import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables; import com.google.common.collect.Iterables;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
import com.google.common.logging.FormattingLogger; import com.google.common.flogger.FluentLogger;
import com.googlecode.objectify.Key; import com.googlecode.objectify.Key;
import google.registry.config.RegistryConfig.Config; import google.registry.config.RegistryConfig.Config;
import google.registry.config.RegistryEnvironment; import google.registry.config.RegistryEnvironment;
@ -72,7 +72,7 @@ import org.joda.time.Duration;
) )
public class DeleteProberDataAction implements Runnable { public class DeleteProberDataAction implements Runnable {
private static final FormattingLogger logger = FormattingLogger.getLoggerForCallerClass(); private static final FluentLogger logger = FluentLogger.forEnclosingClass();
@Inject @Parameter(PARAM_DRY_RUN) boolean isDryRun; @Inject @Parameter(PARAM_DRY_RUN) boolean isDryRun;
/** List of TLDs to work on. If empty - will work on all TLDs that end with .test. */ /** List of TLDs to work on. If empty - will work on all TLDs that end with .test. */
@ -161,7 +161,7 @@ public class DeleteProberDataAction implements Runnable {
getContext().incrementCounter("skipped, non-prober data"); getContext().incrementCounter("skipped, non-prober data");
} }
} catch (Throwable t) { } catch (Throwable t) {
logger.severefmt(t, "Error while deleting prober data for key %s", key); logger.atSevere().withCause(t).log("Error while deleting prober data for key %s", key);
getContext().incrementCounter(String.format("error, kind %s", key.getKind())); getContext().incrementCounter(String.format("error, kind %s", key.getKind()));
} }
} }
@ -194,7 +194,7 @@ public class DeleteProberDataAction implements Runnable {
return; return;
} }
if (!domain.getSubordinateHosts().isEmpty()) { if (!domain.getSubordinateHosts().isEmpty()) {
logger.warningfmt( logger.atWarning().log(
"Cannot delete domain %s (%s) because it has subordinate hosts.", "Cannot delete domain %s (%s) because it has subordinate hosts.",
domainName, domainKey); domainName, domainKey);
getContext().incrementCounter("skipped, had subordinate host(s)"); getContext().incrementCounter("skipped, had subordinate host(s)");
@ -207,7 +207,8 @@ public class DeleteProberDataAction implements Runnable {
// time the mapreduce is run. // time the mapreduce is run.
if (EppResourceUtils.isActive(domain, now)) { if (EppResourceUtils.isActive(domain, now)) {
if (isDryRun) { if (isDryRun) {
logger.infofmt("Would soft-delete the active domain: %s (%s)", domainName, domainKey); logger.atInfo().log(
"Would soft-delete the active domain: %s (%s)", domainName, domainKey);
} else { } else {
softDeleteDomain(domain); softDeleteDomain(domain);
} }
@ -225,22 +226,28 @@ public class DeleteProberDataAction implements Runnable {
final Key<EppResourceIndex> eppIndex = Key.create(EppResourceIndex.create(domainKey)); final Key<EppResourceIndex> eppIndex = Key.create(EppResourceIndex.create(domainKey));
final Key<? extends ForeignKeyIndex<?>> fki = ForeignKeyIndex.createKey(domain); final Key<? extends ForeignKeyIndex<?>> fki = ForeignKeyIndex.createKey(domain);
int entitiesDeleted = ofy().transact(() -> { int entitiesDeleted =
// This ancestor query selects all descendant HistoryEntries, BillingEvents, PollMessages, ofy()
// and TLD-specific entities, as well as the domain itself. .transact(
List<Key<Object>> domainAndDependentKeys = ofy().load().ancestor(domainKey).keys().list(); () -> {
ImmutableSet<Key<?>> allKeys = new ImmutableSet.Builder<Key<?>>() // This ancestor query selects all descendant HistoryEntries, BillingEvents,
.add(fki) // PollMessages,
.add(eppIndex) // and TLD-specific entities, as well as the domain itself.
.addAll(domainAndDependentKeys) List<Key<Object>> domainAndDependentKeys =
.build(); ofy().load().ancestor(domainKey).keys().list();
if (isDryRun) { ImmutableSet<Key<?>> allKeys =
logger.infofmt("Would hard-delete the following entities: %s", allKeys); new ImmutableSet.Builder<Key<?>>()
} else { .add(fki)
ofy().deleteWithoutBackup().keys(allKeys); .add(eppIndex)
} .addAll(domainAndDependentKeys)
return allKeys.size(); .build();
}); if (isDryRun) {
logger.atInfo().log("Would hard-delete the following entities: %s", allKeys);
} else {
ofy().deleteWithoutBackup().keys(allKeys);
}
return allKeys.size();
});
getContext().incrementCounter("domains hard-deleted"); getContext().incrementCounter("domains hard-deleted");
getContext().incrementCounter("total entities hard-deleted", entitiesDeleted); getContext().incrementCounter("total entities hard-deleted", entitiesDeleted);
} }

View file

@ -37,7 +37,7 @@ import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Range; import com.google.common.collect.Range;
import com.google.common.collect.Streams; import com.google.common.collect.Streams;
import com.google.common.logging.FormattingLogger; import com.google.common.flogger.FluentLogger;
import com.googlecode.objectify.Key; import com.googlecode.objectify.Key;
import google.registry.mapreduce.MapreduceRunner; import google.registry.mapreduce.MapreduceRunner;
import google.registry.mapreduce.inputs.NullInput; import google.registry.mapreduce.inputs.NullInput;
@ -81,7 +81,7 @@ public class ExpandRecurringBillingEventsAction implements Runnable {
public static final String PARAM_CURSOR_TIME = "cursorTime"; public static final String PARAM_CURSOR_TIME = "cursorTime";
private static final String ERROR_COUNTER = "errors"; private static final String ERROR_COUNTER = "errors";
private static final FormattingLogger logger = FormattingLogger.getLoggerForCallerClass(); private static final FluentLogger logger = FluentLogger.forEnclosingClass();
@Inject Clock clock; @Inject Clock clock;
@Inject MapreduceRunner mrRunner; @Inject MapreduceRunner mrRunner;
@ -99,10 +99,9 @@ public class ExpandRecurringBillingEventsAction implements Runnable {
checkArgument( checkArgument(
cursorTime.isBefore(executeTime), cursorTime.isBefore(executeTime),
"Cursor time must be earlier than execution time."); "Cursor time must be earlier than execution time.");
logger.infofmt( logger.atInfo().log(
"Running Recurring billing event expansion for billing time range [%s, %s).", "Running Recurring billing event expansion for billing time range [%s, %s).",
cursorTime, cursorTime, executeTime);
executeTime);
response.sendJavaScriptRedirect(createJobPath(mrRunner response.sendJavaScriptRedirect(createJobPath(mrRunner
.setJobName("Expand Recurring billing events into synthetic OneTime events.") .setJobName("Expand Recurring billing events into synthetic OneTime events.")
.setModuleName("backend") .setModuleName("backend")
@ -232,11 +231,12 @@ public class ExpandRecurringBillingEventsAction implements Runnable {
return syntheticOneTimes.size(); return syntheticOneTimes.size();
}); });
} catch (Throwable t) { } catch (Throwable t) {
logger.severefmt(
t, "Error while expanding Recurring billing events for %s", recurring.getId());
getContext().incrementCounter("error: " + t.getClass().getSimpleName()); getContext().incrementCounter("error: " + t.getClass().getSimpleName());
getContext().incrementCounter(ERROR_COUNTER); getContext().incrementCounter(ERROR_COUNTER);
throw t; throw new RuntimeException(
String.format(
"Error while expanding Recurring billing events for %d", recurring.getId()),
t);
} }
if (!isDryRun) { if (!isDryRun) {
getContext().incrementCounter("Saved OneTime billing events", numBillingEventsSaved); getContext().incrementCounter("Saved OneTime billing events", numBillingEventsSaved);
@ -300,16 +300,15 @@ public class ExpandRecurringBillingEventsAction implements Runnable {
@Override @Override
public void reduce(final DateTime cursorTime, final ReducerInput<DateTime> executionTimeInput) { public void reduce(final DateTime cursorTime, final ReducerInput<DateTime> executionTimeInput) {
if (getContext().getCounter(ERROR_COUNTER).getValue() > 0) { if (getContext().getCounter(ERROR_COUNTER).getValue() > 0) {
logger.severefmt("One or more errors logged during recurring event expansion. Cursor will" logger.atSevere().log(
+ " not be advanced."); "One or more errors logged during recurring event expansion. Cursor will"
+ " not be advanced.");
return; return;
} }
final DateTime executionTime = executionTimeInput.next(); final DateTime executionTime = executionTimeInput.next();
logger.infofmt( logger.atInfo().log(
"Recurring event expansion %s complete for billing event range [%s, %s).", "Recurring event expansion %s complete for billing event range [%s, %s).",
isDryRun ? "(dry run) " : "", isDryRun ? "(dry run) " : "", cursorTime, executionTime);
cursorTime,
executionTime);
ofy() ofy()
.transact( .transact(
() -> { () -> {
@ -317,7 +316,7 @@ public class ExpandRecurringBillingEventsAction implements Runnable {
DateTime currentCursorTime = DateTime currentCursorTime =
(cursor == null ? START_OF_TIME : cursor.getCursorTime()); (cursor == null ? START_OF_TIME : cursor.getCursorTime());
if (!currentCursorTime.equals(expectedPersistedCursorTime)) { if (!currentCursorTime.equals(expectedPersistedCursorTime)) {
logger.severefmt( logger.atSevere().log(
"Current cursor position %s does not match expected cursor position %s.", "Current cursor position %s does not match expected cursor position %s.",
currentCursorTime, expectedPersistedCursorTime); currentCursorTime, expectedPersistedCursorTime);
return; return;

View file

@ -19,7 +19,7 @@ import static javax.servlet.http.HttpServletResponse.SC_BAD_REQUEST;
import com.google.appengine.api.datastore.DatastoreService; import com.google.appengine.api.datastore.DatastoreService;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.google.common.logging.FormattingLogger; import com.google.common.flogger.FluentLogger;
import google.registry.batch.MapreduceEntityCleanupUtil.EligibleJobResults; import google.registry.batch.MapreduceEntityCleanupUtil.EligibleJobResults;
import google.registry.mapreduce.MapreduceRunner; import google.registry.mapreduce.MapreduceRunner;
import google.registry.request.Action; import google.registry.request.Action;
@ -88,7 +88,7 @@ public class MapreduceEntityCleanupAction implements Runnable {
private static final String ERROR_NON_POSITIVE_JOBS_TO_DELETE = private static final String ERROR_NON_POSITIVE_JOBS_TO_DELETE =
"Do not specify a non-positive integer for the number of jobs to delete"; "Do not specify a non-positive integer for the number of jobs to delete";
private static final FormattingLogger logger = FormattingLogger.getLoggerForCallerClass(); private static final FluentLogger logger = FluentLogger.forEnclosingClass();
private final Optional<String> jobId; private final Optional<String> jobId;
private final Optional<String> jobName; private final Optional<String> jobName;
@ -133,7 +133,7 @@ public class MapreduceEntityCleanupAction implements Runnable {
} }
private void handleBadRequest(String message) { private void handleBadRequest(String message) {
logger.severe(message); logger.atSevere().log(message);
response.setPayload(message); response.setPayload(message);
response.setStatus(SC_BAD_REQUEST); response.setStatus(SC_BAD_REQUEST);
} }
@ -198,12 +198,12 @@ public class MapreduceEntityCleanupAction implements Runnable {
&& (!numJobsToDelete.isPresent() || (numJobsProcessed < numJobsToDelete.get()))); && (!numJobsToDelete.isPresent() || (numJobsProcessed < numJobsToDelete.get())));
if (numJobsProcessed == 0) { if (numJobsProcessed == 0) {
logger.infofmt( logger.atInfo().log(
"No eligible jobs found with name '%s' older than %s days old.", "No eligible jobs found with name '%s' older than %d days old.",
jobName.orElse("(any)"), defaultedDaysOld); jobName.orElse("(any)"), defaultedDaysOld);
payload.append("No eligible jobs found"); payload.append("No eligible jobs found");
} else { } else {
logger.infofmt("A total of %s job(s) processed.", numJobsProcessed); logger.atInfo().log("A total of %d job(s) processed.", numJobsProcessed);
payload.append(String.format("A total of %d job(s) processed", numJobsProcessed)); payload.append(String.format("A total of %d job(s) processed", numJobsProcessed));
} }
response.setPayload(payload.toString()); response.setPayload(payload.toString());
@ -219,16 +219,15 @@ public class MapreduceEntityCleanupAction implements Runnable {
if (error.isPresent()) { if (error.isPresent()) {
errorCount++; errorCount++;
} }
logger.infofmt("%s: %s", actualJobId, error.orElse("deletion requested")); logger.atInfo().log("%s: %s", actualJobId, error.orElse("deletion requested"));
payloadChunkBuilder.ifPresent( payloadChunkBuilder.ifPresent(
stringBuilder -> stringBuilder ->
stringBuilder.append( stringBuilder.append(
String.format("%s: %s\n", actualJobId, error.orElse("deletion requested")))); String.format("%s: %s\n", actualJobId, error.orElse("deletion requested"))));
} }
logger.infofmt( logger.atInfo().log(
"successfully requested async deletion of %s job(s); errors received on %s", "successfully requested async deletion of %d job(s); errors received on %d",
actualJobIds.size() - errorCount, actualJobIds.size() - errorCount, errorCount);
errorCount);
if (payloadChunkBuilder.isPresent()) { if (payloadChunkBuilder.isPresent()) {
payloadChunkBuilder.get().append(String.format( payloadChunkBuilder.get().append(String.format(
"successfully requested async deletion of %d job(s); errors received on %d\n", "successfully requested async deletion of %d job(s); errors received on %d\n",

View file

@ -41,7 +41,7 @@ import com.google.appengine.tools.mapreduce.ReducerInput;
import com.google.auto.value.AutoValue; import com.google.auto.value.AutoValue;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import com.google.common.logging.FormattingLogger; import com.google.common.flogger.FluentLogger;
import com.googlecode.objectify.Key; import com.googlecode.objectify.Key;
import google.registry.dns.DnsQueue; import google.registry.dns.DnsQueue;
import google.registry.flows.async.AsyncFlowMetrics; import google.registry.flows.async.AsyncFlowMetrics;
@ -72,7 +72,7 @@ import org.joda.time.DateTime;
) )
public class RefreshDnsOnHostRenameAction implements Runnable { public class RefreshDnsOnHostRenameAction implements Runnable {
private static final FormattingLogger logger = FormattingLogger.getLoggerForCallerClass(); private static final FluentLogger logger = FluentLogger.forEnclosingClass();
private static final long LEASE_MINUTES = 20; private static final long LEASE_MINUTES = 20;
@Inject AsyncFlowMetrics asyncFlowMetrics; @Inject AsyncFlowMetrics asyncFlowMetrics;
@ -108,8 +108,8 @@ public class RefreshDnsOnHostRenameAction implements Runnable {
requestsToDelete.add(request); requestsToDelete.add(request);
} }
} catch (Exception e) { } catch (Exception e) {
logger.severefmt( logger.atSevere().withCause(e).log(
e, "Could not parse DNS refresh for host request, delaying task for a day: %s", task); "Could not parse DNS refresh for host request, delaying task for a day: %s", task);
// Grab the lease for a whole day, so it won't continue throwing errors every five minutes. // Grab the lease for a whole day, so it won't continue throwing errors every five minutes.
pullQueue.modifyTaskLease(task, 1L, DAYS); pullQueue.modifyTaskLease(task, 1L, DAYS);
} }
@ -119,11 +119,12 @@ public class RefreshDnsOnHostRenameAction implements Runnable {
requestsToDelete, pullQueue, asyncFlowMetrics, retrier, OperationResult.STALE); requestsToDelete, pullQueue, asyncFlowMetrics, retrier, OperationResult.STALE);
ImmutableList<DnsRefreshRequest> refreshRequests = requestsBuilder.build(); ImmutableList<DnsRefreshRequest> refreshRequests = requestsBuilder.build();
if (refreshRequests.isEmpty()) { if (refreshRequests.isEmpty()) {
logger.info( logger.atInfo().log(
"No asynchronous DNS refreshes to process because all renamed hosts are deleted."); "No asynchronous DNS refreshes to process because all renamed hosts are deleted.");
response.setPayload("All requested DNS refreshes are on hosts that were since deleted."); response.setPayload("All requested DNS refreshes are on hosts that were since deleted.");
} else { } else {
logger.infofmt("Processing asynchronous DNS refresh for renamed hosts: %s", hostKeys.build()); logger.atInfo().log(
"Processing asynchronous DNS refresh for renamed hosts: %s", hostKeys.build());
runMapreduce(refreshRequests); runMapreduce(refreshRequests);
} }
} }
@ -141,7 +142,8 @@ public class RefreshDnsOnHostRenameAction implements Runnable {
ImmutableList.of( ImmutableList.of(
new NullInput<>(), createEntityInput(DomainResource.class))))); new NullInput<>(), createEntityInput(DomainResource.class)))));
} catch (Throwable t) { } catch (Throwable t) {
logger.severefmt(t, "Error while kicking off mapreduce to refresh DNS for renamed hosts."); logger.atSevere().withCause(t).log(
"Error while kicking off mapreduce to refresh DNS for renamed hosts.");
} }
} }
@ -180,7 +182,7 @@ public class RefreshDnsOnHostRenameAction implements Runnable {
retrier.callWithRetry( retrier.callWithRetry(
() -> dnsQueue.addDomainRefreshTask(domain.getFullyQualifiedDomainName()), () -> dnsQueue.addDomainRefreshTask(domain.getFullyQualifiedDomainName()),
TransientFailureException.class); TransientFailureException.class);
logger.infofmt( logger.atInfo().log(
"Enqueued DNS refresh for domain %s referenced by host %s.", "Enqueued DNS refresh for domain %s referenced by host %s.",
domain.getFullyQualifiedDomainName(), referencingHostKey); domain.getFullyQualifiedDomainName(), referencingHostKey);
getContext().incrementCounter("domains refreshed"); getContext().incrementCounter("domains refreshed");
@ -278,7 +280,7 @@ public class RefreshDnsOnHostRenameAction implements Runnable {
boolean isHostDeleted = boolean isHostDeleted =
isDeleted(host, latestOf(now, host.getUpdateAutoTimestamp().getTimestamp())); isDeleted(host, latestOf(now, host.getUpdateAutoTimestamp().getTimestamp()));
if (isHostDeleted) { if (isHostDeleted) {
logger.infofmt("Host %s is already deleted, not refreshing DNS.", hostKey); logger.atInfo().log("Host %s is already deleted, not refreshing DNS.", hostKey);
} }
return new AutoValue_RefreshDnsOnHostRenameAction_DnsRefreshRequest.Builder() return new AutoValue_RefreshDnsOnHostRenameAction_DnsRefreshRequest.Builder()
.setHostKey(hostKey) .setHostKey(hostKey)

View file

@ -17,7 +17,6 @@ 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.ImmutableSet.toImmutableSet; import static com.google.common.collect.ImmutableSet.toImmutableSet;
import static com.google.common.collect.Iterables.getOnlyElement; import static com.google.common.collect.Iterables.getOnlyElement;
import static com.google.common.logging.FormattingLogger.getLoggerForCallerClass;
import static com.googlecode.objectify.Key.getKind; import static com.googlecode.objectify.Key.getKind;
import static google.registry.model.EppResourceUtils.isActive; import static google.registry.model.EppResourceUtils.isActive;
import static google.registry.model.ofy.ObjectifyService.ofy; import static google.registry.model.ofy.ObjectifyService.ofy;
@ -38,7 +37,7 @@ import com.google.appengine.tools.mapreduce.inputs.DatastoreKeyInput;
import com.google.common.annotations.VisibleForTesting; import com.google.common.annotations.VisibleForTesting;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
import com.google.common.logging.FormattingLogger; import com.google.common.flogger.FluentLogger;
import com.googlecode.objectify.Key; import com.googlecode.objectify.Key;
import google.registry.mapreduce.MapreduceRunner; import google.registry.mapreduce.MapreduceRunner;
import google.registry.mapreduce.inputs.EppResourceInputs; import google.registry.mapreduce.inputs.EppResourceInputs;
@ -95,7 +94,7 @@ import org.joda.time.DateTime;
) )
public class VerifyEntityIntegrityAction implements Runnable { public class VerifyEntityIntegrityAction implements Runnable {
private static final FormattingLogger logger = getLoggerForCallerClass(); private static final FluentLogger logger = FluentLogger.forEnclosingClass();
private static final int NUM_SHARDS = 200; private static final int NUM_SHARDS = 200;
@NonFinalForTesting @NonFinalForTesting
@VisibleForTesting @VisibleForTesting
@ -220,7 +219,8 @@ public class VerifyEntityIntegrityAction implements Runnable {
mapEntity(keyOrEntity); mapEntity(keyOrEntity);
} catch (Throwable e) { } catch (Throwable e) {
// Log and swallow so that the mapreduce doesn't abort on first error. // Log and swallow so that the mapreduce doesn't abort on first error.
logger.severefmt(e, "Exception while checking integrity of entity: %s", keyOrEntity); logger.atSevere().withCause(e).log(
"Exception while checking integrity of entity: %s", keyOrEntity);
} }
} }
@ -413,8 +413,8 @@ public class VerifyEntityIntegrityAction implements Runnable {
reduceKeys(mapperKey, keys); reduceKeys(mapperKey, keys);
} catch (Throwable e) { } catch (Throwable e) {
// Log and swallow so that the mapreduce doesn't abort on first error. // Log and swallow so that the mapreduce doesn't abort on first error.
logger.severefmt( logger.atSevere().withCause(e).log(
e, "Exception while checking foreign key integrity constraints for: %s", mapperKey); "Exception while checking foreign key integrity constraints for: %s", mapperKey);
} }
} }

View file

@ -9,13 +9,14 @@ java_library(
srcs = glob(["*.java"]), srcs = glob(["*.java"]),
resources = glob(["sql/*"]), resources = glob(["sql/*"]),
deps = [ deps = [
"//java/com/google/common/logging:formatting_logger",
"//java/google/registry/config", "//java/google/registry/config",
"//java/google/registry/reporting/billing", "//java/google/registry/reporting/billing",
"//java/google/registry/util", "//java/google/registry/util",
"@com_google_apis_google_api_services_bigquery", "@com_google_apis_google_api_services_bigquery",
"@com_google_auto_value", "@com_google_auto_value",
"@com_google_dagger", "@com_google_dagger",
"@com_google_flogger",
"@com_google_flogger_system_backend",
"@com_google_guava", "@com_google_guava",
"@org_apache_avro", "@org_apache_avro",
"@org_apache_beam_runners_direct_java", "@org_apache_beam_runners_direct_java",

View file

@ -18,7 +18,7 @@ import com.google.auto.value.AutoValue;
import com.google.common.annotations.VisibleForTesting; import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Joiner; import com.google.common.base.Joiner;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.logging.FormattingLogger; import com.google.common.flogger.FluentLogger;
import google.registry.reporting.billing.BillingModule; import google.registry.reporting.billing.BillingModule;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
@ -46,7 +46,7 @@ import org.apache.beam.sdk.io.gcp.bigquery.SchemaAndRecord;
@AutoValue @AutoValue
public abstract class BillingEvent implements Serializable { public abstract class BillingEvent implements Serializable {
private static final FormattingLogger logger = FormattingLogger.getLoggerForCallerClass(); private static final FluentLogger logger = FluentLogger.forEnclosingClass();
private static final DateTimeFormatter DATE_TIME_FORMATTER = private static final DateTimeFormatter DATE_TIME_FORMATTER =
DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss zzz"); DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss zzz");
@ -328,9 +328,9 @@ public abstract class BillingEvent implements Serializable {
.filter(fieldName -> record.get(fieldName) == null) .filter(fieldName -> record.get(fieldName) == null)
.collect(ImmutableList.toImmutableList()); .collect(ImmutableList.toImmutableList());
if (!nullFields.isEmpty()) { if (!nullFields.isEmpty()) {
logger.severefmt( logger.atSevere().log(
"Found unexpected null value(s) in field(s) %s for record %s", "Found unexpected null value(s) in field(s) %s for record %s",
Joiner.on(", ").join(nullFields), record.toString()); Joiner.on(", ").join(nullFields), record);
throw new IllegalStateException("Read null value from Bigquery query"); throw new IllegalStateException("Read null value from Bigquery query");
} }
} }

View file

@ -8,7 +8,6 @@ java_library(
name = "bigquery", name = "bigquery",
srcs = glob(["*.java"]), srcs = glob(["*.java"]),
deps = [ deps = [
"//java/com/google/common/logging:formatting_logger",
"//java/google/registry/config", "//java/google/registry/config",
"//java/google/registry/util", "//java/google/registry/util",
"@com_google_api_client", "@com_google_api_client",
@ -16,6 +15,8 @@ java_library(
"@com_google_apis_google_api_services_bigquery", "@com_google_apis_google_api_services_bigquery",
"@com_google_code_findbugs_jsr305", "@com_google_code_findbugs_jsr305",
"@com_google_dagger", "@com_google_dagger",
"@com_google_flogger",
"@com_google_flogger_system_backend",
"@com_google_guava", "@com_google_guava",
"@com_google_http_client", "@com_google_http_client",
"@com_google_http_client_appengine", "@com_google_http_client_appengine",

View file

@ -53,8 +53,8 @@ import com.google.api.services.bigquery.model.TableRow;
import com.google.api.services.bigquery.model.ViewDefinition; import com.google.api.services.bigquery.model.ViewDefinition;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableTable; import com.google.common.collect.ImmutableTable;
import com.google.common.flogger.FluentLogger;
import com.google.common.io.BaseEncoding; import com.google.common.io.BaseEncoding;
import com.google.common.logging.FormattingLogger;
import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.ListeningExecutorService; import com.google.common.util.concurrent.ListeningExecutorService;
@ -79,7 +79,7 @@ import org.joda.time.Duration;
/** Class encapsulating parameters and state for accessing the Bigquery API. */ /** Class encapsulating parameters and state for accessing the Bigquery API. */
public class BigqueryConnection implements AutoCloseable { public class BigqueryConnection implements AutoCloseable {
private static final FormattingLogger logger = FormattingLogger.getLoggerForCallerClass(); private static final FluentLogger logger = FluentLogger.forEnclosingClass();
private static final Duration MIN_POLL_INTERVAL = Duration.millis(500); private static final Duration MIN_POLL_INTERVAL = Duration.millis(500);
@ -642,10 +642,10 @@ public class BigqueryConnection implements AutoCloseable {
if (jobStatus.getErrorResult() != null) { if (jobStatus.getErrorResult() != null) {
throw BigqueryJobFailureException.create(jobStatus); throw BigqueryJobFailureException.create(jobStatus);
} else { } else {
logger.info(summarizeCompletedJob(job)); logger.atInfo().log(summarizeCompletedJob(job));
if (jobStatus.getErrors() != null) { if (jobStatus.getErrors() != null) {
for (ErrorProto error : jobStatus.getErrors()) { for (ErrorProto error : jobStatus.getErrors()) {
logger.warningfmt("%s: %s", error.getReason(), error.getMessage()); logger.atWarning().log("%s: %s", error.getReason(), error.getMessage());
} }
} }
return job; return job;

View file

@ -16,7 +16,6 @@ package google.registry.bigquery;
import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.collect.Sets.newConcurrentHashSet; import static com.google.common.collect.Sets.newConcurrentHashSet;
import static com.google.common.logging.FormattingLogger.getLoggerForCallerClass;
import com.google.api.client.extensions.appengine.http.UrlFetchTransport; import com.google.api.client.extensions.appengine.http.UrlFetchTransport;
import com.google.api.client.googleapis.extensions.appengine.auth.oauth2.AppIdentityCredential; import com.google.api.client.googleapis.extensions.appengine.auth.oauth2.AppIdentityCredential;
@ -33,7 +32,7 @@ import com.google.api.services.bigquery.model.TableFieldSchema;
import com.google.api.services.bigquery.model.TableReference; import com.google.api.services.bigquery.model.TableReference;
import com.google.api.services.bigquery.model.TableSchema; import com.google.api.services.bigquery.model.TableSchema;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.logging.FormattingLogger; import com.google.common.flogger.FluentLogger;
import java.io.IOException; import java.io.IOException;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -43,7 +42,7 @@ import javax.inject.Inject;
/** Factory for creating {@link Bigquery} connections. */ /** Factory for creating {@link Bigquery} connections. */
public class BigqueryFactory { public class BigqueryFactory {
private static final FormattingLogger logger = getLoggerForCallerClass(); private static final FluentLogger logger = FluentLogger.forEnclosingClass();
// Cross-request caches to avoid unnecessary RPCs. // Cross-request caches to avoid unnecessary RPCs.
private static Set<String> knownExistingDatasets = newConcurrentHashSet(); private static Set<String> knownExistingDatasets = newConcurrentHashSet();
@ -152,8 +151,9 @@ public class BigqueryFactory {
.setSchema(new TableSchema().setFields(schema)) .setSchema(new TableSchema().setFields(schema))
.setTableReference(table)) .setTableReference(table))
.execute(); .execute();
logger.infofmt("Created BigQuery table %s:%s.%s", table.getProjectId(), table.getDatasetId(), logger.atInfo().log(
table.getTableId()); "Created BigQuery table %s:%s.%s",
table.getProjectId(), table.getDatasetId(), table.getTableId());
} catch (IOException e) { } catch (IOException e) {
// Swallow errors about a table that exists, and throw any other ones. // Swallow errors about a table that exists, and throw any other ones.
if (!BigqueryJobFailureException.create(e).getReason().equals("duplicate")) { if (!BigqueryJobFailureException.create(e).getReason().equals("duplicate")) {

View file

@ -9,12 +9,13 @@ java_library(
srcs = glob(["*.java"]), srcs = glob(["*.java"]),
resources = glob(["files/*.yaml"]), resources = glob(["files/*.yaml"]),
deps = [ deps = [
"//java/com/google/common/logging:formatting_logger",
"//java/google/registry/util", "//java/google/registry/util",
"@com_google_appengine_api_1_0_sdk", "@com_google_appengine_api_1_0_sdk",
"@com_google_auto_value", "@com_google_auto_value",
"@com_google_code_findbugs_jsr305", "@com_google_code_findbugs_jsr305",
"@com_google_dagger", "@com_google_dagger",
"@com_google_flogger",
"@com_google_flogger_system_backend",
"@com_google_guava", "@com_google_guava",
"@joda_time", "@joda_time",
"@org_joda_money", "@org_joda_money",

View file

@ -15,10 +15,9 @@
package google.registry.config; package google.registry.config;
import static com.google.common.base.Ascii.toLowerCase; import static com.google.common.base.Ascii.toLowerCase;
import static com.google.common.logging.FormattingLogger.getLoggerForCallerClass;
import static google.registry.util.ResourceUtils.readResourceUtf8; import static google.registry.util.ResourceUtils.readResourceUtf8;
import com.google.common.logging.FormattingLogger; import com.google.common.flogger.FluentLogger;
import java.util.Map; import java.util.Map;
import java.util.Optional; import java.util.Optional;
import org.yaml.snakeyaml.Yaml; import org.yaml.snakeyaml.Yaml;
@ -34,7 +33,7 @@ import org.yaml.snakeyaml.Yaml;
*/ */
public final class YamlUtils { public final class YamlUtils {
private static final FormattingLogger logger = getLoggerForCallerClass(); private static final FluentLogger logger = FluentLogger.forEnclosingClass();
private static final String ENVIRONMENT_CONFIG_FORMAT = "files/nomulus-config-%s.yaml"; private static final String ENVIRONMENT_CONFIG_FORMAT = "files/nomulus-config-%s.yaml";
private static final String YAML_CONFIG_PROD = private static final String YAML_CONFIG_PROD =
@ -92,9 +91,9 @@ public final class YamlUtils {
Optional<Map<String, Object>> customMap = loadAsMap(yaml, customYaml); Optional<Map<String, Object>> customMap = loadAsMap(yaml, customYaml);
if (customMap.isPresent()) { if (customMap.isPresent()) {
yamlMap = mergeMaps(yamlMap, customMap.get()); yamlMap = mergeMaps(yamlMap, customMap.get());
logger.fine("Successfully loaded environment configuration YAML file."); logger.atFine().log("Successfully loaded environment configuration YAML file.");
} else { } else {
logger.warning("Ignoring empty environment configuration YAML file."); logger.atWarning().log("Ignoring empty environment configuration YAML file.");
} }
return yaml.dump(yamlMap); return yaml.dump(yamlMap);
} }

View file

@ -8,7 +8,6 @@ java_library(
name = "cron", name = "cron",
srcs = glob(["*.java"]), srcs = glob(["*.java"]),
deps = [ deps = [
"//java/com/google/common/logging:formatting_logger",
"//java/google/registry/model", "//java/google/registry/model",
"//java/google/registry/request", "//java/google/registry/request",
"//java/google/registry/request/auth", "//java/google/registry/request/auth",
@ -17,6 +16,8 @@ java_library(
"@com_google_appengine_api_1_0_sdk", "@com_google_appengine_api_1_0_sdk",
"@com_google_code_findbugs_jsr305", "@com_google_code_findbugs_jsr305",
"@com_google_dagger", "@com_google_dagger",
"@com_google_flogger",
"@com_google_flogger_system_backend",
"@com_google_guava", "@com_google_guava",
"@javax_servlet_api", "@javax_servlet_api",
"@joda_time", "@joda_time",

View file

@ -36,7 +36,7 @@ import com.google.common.collect.ImmutableListMultimap;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Multimap; import com.google.common.collect.Multimap;
import com.google.common.collect.Streams; import com.google.common.collect.Streams;
import com.google.common.logging.FormattingLogger; import com.google.common.flogger.FluentLogger;
import google.registry.request.Action; import google.registry.request.Action;
import google.registry.request.Parameter; import google.registry.request.Parameter;
import google.registry.request.ParameterMap; import google.registry.request.ParameterMap;
@ -101,7 +101,7 @@ public final class TldFanoutAction implements Runnable {
private static final Random random = new Random(); private static final Random random = new Random();
private static final FormattingLogger logger = FormattingLogger.getLoggerForCallerClass(); private static final FluentLogger logger = FluentLogger.forEnclosingClass();
@Inject TaskQueueUtils taskQueueUtils; @Inject TaskQueueUtils taskQueueUtils;
@Inject Response response; @Inject Response response;
@ -138,9 +138,9 @@ public final class TldFanoutAction implements Runnable {
StringBuilder outputPayload = StringBuilder outputPayload =
new StringBuilder( new StringBuilder(
String.format("OK: Launched the following %d tasks in queue %s\n", tlds.size(), queue)); String.format("OK: Launched the following %d tasks in queue %s\n", tlds.size(), queue));
logger.infofmt("Launching %d tasks in queue %s", tlds.size(), queue); logger.atInfo().log("Launching %d tasks in queue %s", tlds.size(), queue);
if (tlds.isEmpty()) { if (tlds.isEmpty()) {
logger.warning("No TLDs to fan-out!"); logger.atWarning().log("No TLDs to fan-out!");
} }
for (String tld : tlds) { for (String tld : tlds) {
TaskOptions taskOptions = createTaskOptions(tld, flowThruParams); TaskOptions taskOptions = createTaskOptions(tld, flowThruParams);
@ -149,8 +149,8 @@ public final class TldFanoutAction implements Runnable {
String.format( String.format(
"- Task: '%s', tld: '%s', endpoint: '%s'\n", "- Task: '%s', tld: '%s', endpoint: '%s'\n",
taskHandle.getName(), tld, taskOptions.getUrl())); taskHandle.getName(), tld, taskOptions.getUrl()));
logger.infofmt("Task: '%s', tld: '%s', endpoint: '%s'", logger.atInfo().log(
taskHandle.getName(), tld, taskOptions.getUrl()); "Task: '%s', tld: '%s', endpoint: '%s'", taskHandle.getName(), tld, taskOptions.getUrl());
} }
response.setContentType(PLAIN_TEXT_UTF_8); response.setContentType(PLAIN_TEXT_UTF_8);
response.setPayload(outputPayload.toString()); response.setPayload(outputPayload.toString());

View file

@ -20,7 +20,6 @@ java_library(
), ),
deps = [ deps = [
":constants", ":constants",
"//java/com/google/common/logging:formatting_logger",
"//java/google/registry/config", "//java/google/registry/config",
"//java/google/registry/dns/writer", "//java/google/registry/dns/writer",
"//java/google/registry/model", "//java/google/registry/model",
@ -33,6 +32,8 @@ java_library(
"@com_google_auto_value", "@com_google_auto_value",
"@com_google_code_findbugs_jsr305", "@com_google_code_findbugs_jsr305",
"@com_google_dagger", "@com_google_dagger",
"@com_google_flogger",
"@com_google_flogger_system_backend",
"@com_google_guava", "@com_google_guava",
"@com_google_monitoring_client_metrics", "@com_google_monitoring_client_metrics",
"@javax_servlet_api", "@javax_servlet_api",

View file

@ -34,7 +34,7 @@ import com.google.appengine.api.taskqueue.TransientFailureException;
import com.google.apphosting.api.DeadlineExceededException; import com.google.apphosting.api.DeadlineExceededException;
import com.google.common.annotations.VisibleForTesting; import com.google.common.annotations.VisibleForTesting;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.logging.FormattingLogger; import com.google.common.flogger.FluentLogger;
import com.google.common.net.InternetDomainName; import com.google.common.net.InternetDomainName;
import com.google.common.util.concurrent.RateLimiter; import com.google.common.util.concurrent.RateLimiter;
import google.registry.dns.DnsConstants.TargetType; import google.registry.dns.DnsConstants.TargetType;
@ -65,7 +65,7 @@ import org.joda.time.Duration;
*/ */
public class DnsQueue { public class DnsQueue {
private static final FormattingLogger logger = FormattingLogger.getLoggerForCallerClass(); private static final FluentLogger logger = FluentLogger.forEnclosingClass();
private final Queue queue; private final Queue queue;
@ -107,7 +107,7 @@ public class DnsQueue {
* Enqueues the given task type with the given target name to the DNS queue. * Enqueues the given task type with the given target name to the DNS queue.
*/ */
private TaskHandle addToQueue(TargetType targetType, String targetName, String tld) { private TaskHandle addToQueue(TargetType targetType, String targetName, String tld) {
logger.infofmt( logger.atInfo().log(
"Adding task type=%s, target=%s, tld=%s to pull queue %s (%d tasks currently on queue)", "Adding task type=%s, target=%s, tld=%s to pull queue %s (%d tasks currently on queue)",
targetType, targetName, tld, DNS_PULL_QUEUE_NAME, queue.fetchStatistics().getNumTasks()); targetType, targetName, tld, DNS_PULL_QUEUE_NAME, queue.fetchStatistics().getNumTasks());
return queue.add( return queue.add(
@ -159,14 +159,11 @@ public class DnsQueue {
try { try {
rateLimiter.acquire(); rateLimiter.acquire();
int numTasks = queue.fetchStatistics().getNumTasks(); int numTasks = queue.fetchStatistics().getNumTasks();
logger.logfmt( logger.at((numTasks >= leaseTasksBatchSize) ? Level.WARNING : Level.INFO).log(
(numTasks >= leaseTasksBatchSize) ? Level.WARNING : Level.INFO, "There are %d tasks in the DNS queue '%s'.", numTasks, DNS_PULL_QUEUE_NAME);
"There are %d tasks in the DNS queue '%s'.",
numTasks,
DNS_PULL_QUEUE_NAME);
return queue.leaseTasks(leaseDuration.getMillis(), MILLISECONDS, leaseTasksBatchSize); return queue.leaseTasks(leaseDuration.getMillis(), MILLISECONDS, leaseTasksBatchSize);
} catch (TransientFailureException | DeadlineExceededException e) { } catch (TransientFailureException | DeadlineExceededException e) {
logger.severe(e, "Failed leasing tasks too fast"); logger.atSevere().withCause(e).log("Failed leasing tasks too fast");
return ImmutableList.of(); return ImmutableList.of();
} }
} }
@ -176,7 +173,7 @@ public class DnsQueue {
try { try {
queue.deleteTask(tasks); queue.deleteTask(tasks);
} catch (TransientFailureException | DeadlineExceededException e) { } catch (TransientFailureException | DeadlineExceededException e) {
logger.severe(e, "Failed deleting tasks too fast"); logger.atSevere().withCause(e).log("Failed deleting tasks too fast");
} }
} }
} }

View file

@ -15,10 +15,9 @@
package google.registry.dns; package google.registry.dns;
import static com.google.common.base.Preconditions.checkState; import static com.google.common.base.Preconditions.checkState;
import static com.google.common.logging.FormattingLogger.getLoggerForCallerClass;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import com.google.common.logging.FormattingLogger; import com.google.common.flogger.FluentLogger;
import google.registry.dns.writer.DnsWriter; import google.registry.dns.writer.DnsWriter;
import google.registry.model.registry.Registry; import google.registry.model.registry.Registry;
import java.util.Map; import java.util.Map;
@ -27,7 +26,7 @@ import javax.inject.Inject;
/** Proxy for retrieving {@link DnsWriter} implementations. */ /** Proxy for retrieving {@link DnsWriter} implementations. */
public final class DnsWriterProxy { public final class DnsWriterProxy {
private static final FormattingLogger logger = getLoggerForCallerClass(); private static final FluentLogger logger = FluentLogger.forEnclosingClass();
private final ImmutableMap<String, DnsWriter> dnsWriters; private final ImmutableMap<String, DnsWriter> dnsWriters;
@ -43,9 +42,8 @@ public final class DnsWriterProxy {
*/ */
public DnsWriter getByClassNameForTld(String className, String tld) { public DnsWriter getByClassNameForTld(String className, String tld) {
if (!Registry.get(tld).getDnsWriters().contains(className)) { if (!Registry.get(tld).getDnsWriters().contains(className)) {
logger.warningfmt( logger.atWarning().log(
"Loaded potentially stale DNS writer %s which is not active on TLD %s.", "Loaded potentially stale DNS writer %s which is not active on TLD %s.", className, tld);
className, tld);
return null; return null;
} }
DnsWriter dnsWriter = dnsWriters.get(className); DnsWriter dnsWriter = dnsWriters.get(className);

View file

@ -18,7 +18,7 @@ import static google.registry.request.Action.Method.POST;
import static google.registry.request.RequestParameters.PARAM_TLD; import static google.registry.request.RequestParameters.PARAM_TLD;
import static google.registry.util.CollectionUtils.nullToEmpty; import static google.registry.util.CollectionUtils.nullToEmpty;
import com.google.common.logging.FormattingLogger; import com.google.common.flogger.FluentLogger;
import com.google.common.net.InternetDomainName; import com.google.common.net.InternetDomainName;
import google.registry.config.RegistryConfig.Config; import google.registry.config.RegistryConfig.Config;
import google.registry.dns.DnsMetrics.ActionStatus; import google.registry.dns.DnsMetrics.ActionStatus;
@ -58,7 +58,7 @@ public final class PublishDnsUpdatesAction implements Runnable, Callable<Void> {
public static final String PARAM_REFRESH_REQUEST_CREATED = "itemsCreated"; public static final String PARAM_REFRESH_REQUEST_CREATED = "itemsCreated";
public static final String LOCK_NAME = "DNS updates"; public static final String LOCK_NAME = "DNS updates";
private static final FormattingLogger logger = FormattingLogger.getLoggerForCallerClass(); private static final FluentLogger logger = FluentLogger.forEnclosingClass();
@Inject DnsQueue dnsQueue; @Inject DnsQueue dnsQueue;
@Inject DnsWriterProxy dnsWriterProxy; @Inject DnsWriterProxy dnsWriterProxy;
@ -101,9 +101,9 @@ public final class PublishDnsUpdatesAction implements Runnable, Callable<Void> {
nullToEmpty(domains).size() + nullToEmpty(hosts).size(), nullToEmpty(domains).size() + nullToEmpty(hosts).size(),
new Duration(itemsCreateTime, now), new Duration(itemsCreateTime, now),
new Duration(enqueuedTime, now)); new Duration(enqueuedTime, now));
logger.infofmt( logger.atInfo().log(
"publishDnsWriter latency statistics: TLD: %s, dnsWriter: %s, actionStatus: %s, " "publishDnsWriter latency statistics: TLD: %s, dnsWriter: %s, actionStatus: %s, "
+ "numItems: %s, timeSinceCreation: %s, timeInQueue: %s", + "numItems: %d, timeSinceCreation: %s, timeInQueue: %s",
tld, tld,
dnsWriter, dnsWriter,
status, status,
@ -143,7 +143,7 @@ public final class PublishDnsUpdatesAction implements Runnable, Callable<Void> {
/** Adds all the domains and hosts in the batch back to the queue to be processed later. */ /** Adds all the domains and hosts in the batch back to the queue to be processed later. */
private void requeueBatch() { private void requeueBatch() {
logger.infofmt("Requeueing batch for retry"); logger.atInfo().log("Requeueing batch for retry");
for (String domain : nullToEmpty(domains)) { for (String domain : nullToEmpty(domains)) {
dnsQueue.addDomainRefreshTask(domain); dnsQueue.addDomainRefreshTask(domain);
} }
@ -156,14 +156,14 @@ public final class PublishDnsUpdatesAction implements Runnable, Callable<Void> {
private boolean validLockParams() { private boolean validLockParams() {
// LockIndex should always be within [1, numPublishLocks] // LockIndex should always be within [1, numPublishLocks]
if (lockIndex > numPublishLocks || lockIndex <= 0) { if (lockIndex > numPublishLocks || lockIndex <= 0) {
logger.severefmt( logger.atSevere().log(
"Lock index should be within [1,%d], got %d instead", numPublishLocks, lockIndex); "Lock index should be within [1,%d], got %d instead", numPublishLocks, lockIndex);
return false; return false;
} }
// Check if the Registry object's num locks has changed since this task was batched // Check if the Registry object's num locks has changed since this task was batched
int registryNumPublishLocks = Registry.get(tld).getNumDnsPublishLocks(); int registryNumPublishLocks = Registry.get(tld).getNumDnsPublishLocks();
if (registryNumPublishLocks != numPublishLocks) { if (registryNumPublishLocks != numPublishLocks) {
logger.warningfmt( logger.atWarning().log(
"Registry numDnsPublishLocks %d out of sync with parameter %d", "Registry numDnsPublishLocks %d out of sync with parameter %d",
registryNumPublishLocks, numPublishLocks); registryNumPublishLocks, numPublishLocks);
return false; return false;
@ -178,7 +178,7 @@ public final class PublishDnsUpdatesAction implements Runnable, Callable<Void> {
DnsWriter writer = dnsWriterProxy.getByClassNameForTld(dnsWriter, tld); DnsWriter writer = dnsWriterProxy.getByClassNameForTld(dnsWriter, tld);
if (writer == null) { if (writer == null) {
logger.warningfmt("Couldn't get writer %s for TLD %s", dnsWriter, tld); logger.atWarning().log("Couldn't get writer %s for TLD %s", dnsWriter, tld);
recordActionResult(ActionStatus.BAD_WRITER); recordActionResult(ActionStatus.BAD_WRITER);
requeueBatch(); requeueBatch();
return; return;
@ -189,11 +189,11 @@ public final class PublishDnsUpdatesAction implements Runnable, Callable<Void> {
for (String domain : nullToEmpty(domains)) { for (String domain : nullToEmpty(domains)) {
if (!DomainNameUtils.isUnder( if (!DomainNameUtils.isUnder(
InternetDomainName.from(domain), InternetDomainName.from(tld))) { InternetDomainName.from(domain), InternetDomainName.from(tld))) {
logger.severefmt("%s: skipping domain %s not under tld", tld, domain); logger.atSevere().log("%s: skipping domain %s not under tld", tld, domain);
domainsRejected += 1; domainsRejected += 1;
} else { } else {
writer.publishDomain(domain); writer.publishDomain(domain);
logger.infofmt("%s: published domain %s", tld, domain); logger.atInfo().log("%s: published domain %s", tld, domain);
domainsPublished += 1; domainsPublished += 1;
} }
} }
@ -205,11 +205,11 @@ public final class PublishDnsUpdatesAction implements Runnable, Callable<Void> {
for (String host : nullToEmpty(hosts)) { for (String host : nullToEmpty(hosts)) {
if (!DomainNameUtils.isUnder( if (!DomainNameUtils.isUnder(
InternetDomainName.from(host), InternetDomainName.from(tld))) { InternetDomainName.from(host), InternetDomainName.from(tld))) {
logger.severefmt("%s: skipping host %s not under tld", tld, host); logger.atSevere().log("%s: skipping host %s not under tld", tld, host);
hostsRejected += 1; hostsRejected += 1;
} else { } else {
writer.publishHost(host); writer.publishHost(host);
logger.infofmt("%s: published host %s", tld, host); logger.atInfo().log("%s: published host %s", tld, host);
hostsPublished += 1; hostsPublished += 1;
} }
} }
@ -234,7 +234,7 @@ public final class PublishDnsUpdatesAction implements Runnable, Callable<Void> {
duration, duration,
domainsPublished, domainsPublished,
hostsPublished); hostsPublished);
logger.infofmt( logger.atInfo().log(
"writer.commit() statistics: TLD: %s, dnsWriter: %s, commitStatus: %s, duration: %s, " "writer.commit() statistics: TLD: %s, dnsWriter: %s, commitStatus: %s, duration: %s, "
+ "domainsPublished: %d, domainsRejected: %d, hostsPublished: %d, hostsRejected: %d", + "domainsPublished: %d, domainsRejected: %d, hostsPublished: %d, hostsRejected: %d",
tld, tld,

View file

@ -35,9 +35,9 @@ import com.google.common.collect.ImmutableSet;
import com.google.common.collect.ImmutableSetMultimap; import com.google.common.collect.ImmutableSetMultimap;
import com.google.common.collect.Iterables; import com.google.common.collect.Iterables;
import com.google.common.collect.Ordering; import com.google.common.collect.Ordering;
import com.google.common.flogger.FluentLogger;
import com.google.common.hash.HashFunction; import com.google.common.hash.HashFunction;
import com.google.common.hash.Hashing; import com.google.common.hash.Hashing;
import com.google.common.logging.FormattingLogger;
import google.registry.config.RegistryConfig.Config; import google.registry.config.RegistryConfig.Config;
import google.registry.dns.DnsConstants.TargetType; import google.registry.dns.DnsConstants.TargetType;
import google.registry.model.registry.Registries; import google.registry.model.registry.Registries;
@ -78,7 +78,7 @@ public final class ReadDnsQueueAction implements Runnable {
private static final String PARAM_JITTER_SECONDS = "jitterSeconds"; private static final String PARAM_JITTER_SECONDS = "jitterSeconds";
private static final Random random = new Random(); private static final Random random = new Random();
private static final FormattingLogger logger = FormattingLogger.getLoggerForCallerClass(); private static final FluentLogger logger = FluentLogger.forEnclosingClass();
/** /**
* Buffer time since the end of this action until retriable tasks are available again. * Buffer time since the end of this action until retriable tasks are available again.
@ -134,7 +134,7 @@ public final class ReadDnsQueueAction implements Runnable {
ImmutableSet<String> tlds = Registries.getTlds(); ImmutableSet<String> tlds = Registries.getTlds();
while (requestedEndTime.isAfterNow()) { while (requestedEndTime.isAfterNow()) {
List<TaskHandle> tasks = dnsQueue.leaseTasks(requestedMaximumDuration.plus(LEASE_PADDING)); List<TaskHandle> tasks = dnsQueue.leaseTasks(requestedMaximumDuration.plus(LEASE_PADDING));
logger.infofmt("Leased %d DNS update tasks.", tasks.size()); logger.atInfo().log("Leased %d DNS update tasks.", tasks.size());
if (!tasks.isEmpty()) { if (!tasks.isEmpty()) {
dispatchTasks(ImmutableSet.copyOf(tasks), tlds); dispatchTasks(ImmutableSet.copyOf(tasks), tlds);
} }
@ -220,15 +220,16 @@ public final class ReadDnsQueueAction implements Runnable {
private void dispatchTasks(ImmutableSet<TaskHandle> tasks, ImmutableSet<String> tlds) { private void dispatchTasks(ImmutableSet<TaskHandle> tasks, ImmutableSet<String> tlds) {
ClassifiedTasks classifiedTasks = classifyTasks(tasks, tlds); ClassifiedTasks classifiedTasks = classifyTasks(tasks, tlds);
if (!classifiedTasks.pausedTlds().isEmpty()) { if (!classifiedTasks.pausedTlds().isEmpty()) {
logger.infofmt("The dns-pull queue is paused for TLDs: %s.", classifiedTasks.pausedTlds()); logger.atInfo().log(
"The dns-pull queue is paused for TLDs: %s.", classifiedTasks.pausedTlds());
} }
if (!classifiedTasks.unknownTlds().isEmpty()) { if (!classifiedTasks.unknownTlds().isEmpty()) {
logger.warningfmt( logger.atWarning().log(
"The dns-pull queue has unknown TLDs: %s.", classifiedTasks.unknownTlds()); "The dns-pull queue has unknown TLDs: %s.", classifiedTasks.unknownTlds());
} }
bucketRefreshItems(classifiedTasks.refreshItemsByTld()); bucketRefreshItems(classifiedTasks.refreshItemsByTld());
if (!classifiedTasks.tasksToKeep().isEmpty()) { if (!classifiedTasks.tasksToKeep().isEmpty()) {
logger.warningfmt( logger.atWarning().log(
"Keeping %d DNS update tasks in the queue.", classifiedTasks.tasksToKeep().size()); "Keeping %d DNS update tasks in the queue.", classifiedTasks.tasksToKeep().size());
} }
// Delete the tasks we don't want to see again from the queue. // Delete the tasks we don't want to see again from the queue.
@ -243,9 +244,9 @@ public final class ReadDnsQueueAction implements Runnable {
// tasks again. // tasks again.
ImmutableSet<TaskHandle> tasksToDelete = ImmutableSet<TaskHandle> tasksToDelete =
difference(tasks, classifiedTasks.tasksToKeep()).immutableCopy(); difference(tasks, classifiedTasks.tasksToKeep()).immutableCopy();
logger.infofmt("Removing %d DNS update tasks from the queue.", tasksToDelete.size()); logger.atInfo().log("Removing %d DNS update tasks from the queue.", tasksToDelete.size());
dnsQueue.deleteTasks(tasksToDelete.asList()); dnsQueue.deleteTasks(tasksToDelete.asList());
logger.infofmt("Done processing DNS tasks."); logger.atInfo().log("Done processing DNS tasks.");
} }
/** /**
@ -266,7 +267,8 @@ public final class ReadDnsQueueAction implements Runnable {
DateTime creationTime = DateTime.parse(params.get(DNS_TARGET_CREATE_TIME_PARAM)); DateTime creationTime = DateTime.parse(params.get(DNS_TARGET_CREATE_TIME_PARAM));
String tld = params.get(RequestParameters.PARAM_TLD); String tld = params.get(RequestParameters.PARAM_TLD);
if (tld == null) { if (tld == null) {
logger.severefmt("Discarding invalid DNS refresh request %s; no TLD specified.", task); logger.atSevere().log(
"Discarding invalid DNS refresh request %s; no TLD specified.", task);
} else if (!tlds.contains(tld)) { } else if (!tlds.contains(tld)) {
classifiedTasksBuilder.tasksToKeepBuilder().add(task); classifiedTasksBuilder.tasksToKeepBuilder().add(task);
classifiedTasksBuilder.unknownTldsBuilder().add(tld); classifiedTasksBuilder.unknownTldsBuilder().add(tld);
@ -285,12 +287,13 @@ public final class ReadDnsQueueAction implements Runnable {
.put(tld, RefreshItem.create(type, name, creationTime)); .put(tld, RefreshItem.create(type, name, creationTime));
break; break;
default: default:
logger.severefmt("Discarding DNS refresh request %s of type %s.", task, typeString); logger.atSevere().log(
"Discarding DNS refresh request %s of type %s.", task, typeString);
break; break;
} }
} }
} catch (RuntimeException | UnsupportedEncodingException e) { } catch (RuntimeException | UnsupportedEncodingException e) {
logger.severefmt(e, "Discarding invalid DNS refresh request %s.", task); logger.atSevere().withCause(e).log("Discarding invalid DNS refresh request %s.", task);
} }
} }
return classifiedTasksBuilder.build(); return classifiedTasksBuilder.build();

View file

@ -8,8 +8,9 @@ java_library(
name = "writer", name = "writer",
srcs = glob(["*.java"]), srcs = glob(["*.java"]),
deps = [ deps = [
"//java/com/google/common/logging:formatting_logger",
"@com_google_dagger", "@com_google_dagger",
"@com_google_flogger",
"@com_google_flogger_system_backend",
"@com_google_guava", "@com_google_guava",
], ],
) )

View file

@ -14,7 +14,7 @@
package google.registry.dns.writer; package google.registry.dns.writer;
import com.google.common.logging.FormattingLogger; import com.google.common.flogger.FluentLogger;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
import javax.inject.Inject; import javax.inject.Inject;
@ -32,7 +32,7 @@ public final class VoidDnsWriter extends BaseDnsWriter {
*/ */
public static final String NAME = "VoidDnsWriter"; public static final String NAME = "VoidDnsWriter";
private static final FormattingLogger logger = FormattingLogger.getLoggerForCallerClass(); private static final FluentLogger logger = FluentLogger.forEnclosingClass();
private final Set<String> names = new HashSet<>(); private final Set<String> names = new HashSet<>();
@ -51,7 +51,7 @@ public final class VoidDnsWriter extends BaseDnsWriter {
@Override @Override
protected void commitUnchecked() { protected void commitUnchecked() {
logger.warningfmt( logger.atWarning().log(
"No DnsWriterFactory implementation specified; ignoring names to commit: %s", names); "No DnsWriterFactory implementation specified; ignoring names to commit: %s", names);
} }
} }

View file

@ -8,7 +8,6 @@ java_library(
name = "clouddns", name = "clouddns",
srcs = glob(["*.java"]), srcs = glob(["*.java"]),
deps = [ deps = [
"//java/com/google/common/logging:formatting_logger",
"//java/google/registry/config", "//java/google/registry/config",
"//java/google/registry/dns/writer", "//java/google/registry/dns/writer",
"//java/google/registry/model", "//java/google/registry/model",
@ -16,6 +15,8 @@ java_library(
"@com_google_api_client", "@com_google_api_client",
"@com_google_apis_google_api_services_dns", "@com_google_apis_google_api_services_dns",
"@com_google_dagger", "@com_google_dagger",
"@com_google_flogger",
"@com_google_flogger_system_backend",
"@com_google_guava", "@com_google_guava",
"@com_google_http_client", "@com_google_http_client",
"@joda_time", "@joda_time",

View file

@ -29,7 +29,7 @@ import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
import com.google.common.logging.FormattingLogger; import com.google.common.flogger.FluentLogger;
import com.google.common.net.InternetDomainName; import com.google.common.net.InternetDomainName;
import com.google.common.util.concurrent.RateLimiter; import com.google.common.util.concurrent.RateLimiter;
import google.registry.config.RegistryConfig.Config; import google.registry.config.RegistryConfig.Config;
@ -72,7 +72,7 @@ public class CloudDnsWriter extends BaseDnsWriter {
*/ */
public static final String NAME = "CloudDnsWriter"; public static final String NAME = "CloudDnsWriter";
private static final FormattingLogger logger = FormattingLogger.getLoggerForCallerClass(); private static final FluentLogger logger = FluentLogger.forEnclosingClass();
private static final ImmutableSet<String> RETRYABLE_EXCEPTION_REASONS = private static final ImmutableSet<String> RETRYABLE_EXCEPTION_REASONS =
ImmutableSet.of("preconditionFailed", "notFound", "alreadyExists"); ImmutableSet.of("preconditionFailed", "notFound", "alreadyExists");
@ -179,12 +179,12 @@ public class CloudDnsWriter extends BaseDnsWriter {
} }
desiredRecords.put(absoluteDomainName, domainRecords.build()); desiredRecords.put(absoluteDomainName, domainRecords.build());
logger.finefmt( logger.atFine().log(
"Will write %s records for domain %s", domainRecords.build().size(), absoluteDomainName); "Will write %d records for domain %s", domainRecords.build().size(), absoluteDomainName);
} }
private void publishSubordinateHost(String hostName) { private void publishSubordinateHost(String hostName) {
logger.infofmt("Publishing glue records for %s", hostName); logger.atInfo().log("Publishing glue records for %s", hostName);
// Canonicalize name // Canonicalize name
String absoluteHostName = getAbsoluteHostName(hostName); String absoluteHostName = getAbsoluteHostName(hostName);
@ -251,7 +251,7 @@ public class CloudDnsWriter extends BaseDnsWriter {
// Host not managed by our registry, no need to update DNS. // Host not managed by our registry, no need to update DNS.
if (!tld.isPresent()) { if (!tld.isPresent()) {
logger.severefmt("publishHost called for invalid host %s", hostName); logger.atSevere().log("publishHost called for invalid host %s", hostName);
return; return;
} }
@ -274,7 +274,7 @@ public class CloudDnsWriter extends BaseDnsWriter {
ImmutableMap<String, ImmutableSet<ResourceRecordSet>> desiredRecordsCopy = ImmutableMap<String, ImmutableSet<ResourceRecordSet>> desiredRecordsCopy =
ImmutableMap.copyOf(desiredRecords); ImmutableMap.copyOf(desiredRecords);
retrier.callWithRetry(() -> mutateZone(desiredRecordsCopy), ZoneStateException.class); retrier.callWithRetry(() -> mutateZone(desiredRecordsCopy), ZoneStateException.class);
logger.info("Wrote to Cloud DNS"); logger.atInfo().log("Wrote to Cloud DNS");
} }
/** Returns the glue records for in-bailiwick nameservers for the given domain+records. */ /** Returns the glue records for in-bailiwick nameservers for the given domain+records. */
@ -324,7 +324,7 @@ public class CloudDnsWriter extends BaseDnsWriter {
*/ */
private Map<String, List<ResourceRecordSet>> getResourceRecordsForDomains( private Map<String, List<ResourceRecordSet>> getResourceRecordsForDomains(
Set<String> domainNames) { Set<String> domainNames) {
logger.finefmt("Fetching records for %s", domainNames); logger.atFine().log("Fetching records for %s", domainNames);
// As per Concurrent.transform() - if numThreads or domainNames.size() < 2, it will not use // As per Concurrent.transform() - if numThreads or domainNames.size() < 2, it will not use
// threading. // threading.
return ImmutableMap.copyOf( return ImmutableMap.copyOf(
@ -373,12 +373,12 @@ public class CloudDnsWriter extends BaseDnsWriter {
// the result. // the result.
ImmutableSet<ResourceRecordSet> intersection = ImmutableSet<ResourceRecordSet> intersection =
Sets.intersection(additions, deletions).immutableCopy(); Sets.intersection(additions, deletions).immutableCopy();
logger.infofmt( logger.atInfo().log(
"There are %s common items out of the %s items in 'additions' and %s items in 'deletions'", "There are %d common items out of the %d items in 'additions' and %d items in 'deletions'",
intersection.size(), additions.size(), deletions.size()); intersection.size(), additions.size(), deletions.size());
// Exit early if we have nothing to update - dnsConnection doesn't work on empty changes // Exit early if we have nothing to update - dnsConnection doesn't work on empty changes
if (additions.equals(deletions)) { if (additions.equals(deletions)) {
logger.infofmt("Returning early because additions is the same as deletions"); logger.atInfo().log("Returning early because additions is the same as deletions");
return; return;
} }
Change change = Change change =

View file

@ -29,7 +29,7 @@ import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
import com.google.common.logging.FormattingLogger; import com.google.common.flogger.FluentLogger;
import com.google.common.net.InternetDomainName; import com.google.common.net.InternetDomainName;
import com.google.common.util.concurrent.RateLimiter; import com.google.common.util.concurrent.RateLimiter;
import google.registry.config.RegistryConfig.Config; import google.registry.config.RegistryConfig.Config;
@ -91,7 +91,7 @@ public class MultiplyingCloudDnsWriter extends BaseDnsWriter {
*/ */
public static final String NAME = "MultiplyingCloudDnsWriter"; public static final String NAME = "MultiplyingCloudDnsWriter";
private static final FormattingLogger logger = FormattingLogger.getLoggerForCallerClass(); private static final FluentLogger logger = FluentLogger.forEnclosingClass();
private static final ImmutableSet<String> RETRYABLE_EXCEPTION_REASONS = private static final ImmutableSet<String> RETRYABLE_EXCEPTION_REASONS =
ImmutableSet.of("preconditionFailed", "notFound", "alreadyExists"); ImmutableSet.of("preconditionFailed", "notFound", "alreadyExists");
@ -199,13 +199,13 @@ public class MultiplyingCloudDnsWriter extends BaseDnsWriter {
} }
desiredRecords.put(absoluteDomainName, domainRecords.build()); desiredRecords.put(absoluteDomainName, domainRecords.build());
logger.finefmt( logger.atFine().log(
"Will write %s records for domain %s", domainRecords.build().size(), absoluteDomainName); "Will write %d records for domain %s", domainRecords.build().size(), absoluteDomainName);
} }
} }
private void publishSubordinateHost(String hostName) { private void publishSubordinateHost(String hostName) {
logger.infofmt("Publishing glue records for %s", hostName); logger.atInfo().log("Publishing glue records for %s", hostName);
// Canonicalize name // Canonicalize name
String absoluteHostName = getAbsoluteHostName(hostName); String absoluteHostName = getAbsoluteHostName(hostName);
@ -272,7 +272,7 @@ public class MultiplyingCloudDnsWriter extends BaseDnsWriter {
// Host not managed by our registry, no need to update DNS. // Host not managed by our registry, no need to update DNS.
if (!tld.isPresent()) { if (!tld.isPresent()) {
logger.severefmt("publishHost called for invalid host %s", hostName); logger.atSevere().log("publishHost called for invalid host %s", hostName);
return; return;
} }
@ -303,7 +303,7 @@ public class MultiplyingCloudDnsWriter extends BaseDnsWriter {
ImmutableMap<String, ImmutableSet<ResourceRecordSet>> desiredRecordsCopy = ImmutableMap<String, ImmutableSet<ResourceRecordSet>> desiredRecordsCopy =
ImmutableMap.copyOf(desiredRecords); ImmutableMap.copyOf(desiredRecords);
retrier.callWithRetry(() -> mutateZone(desiredRecordsCopy), ZoneStateException.class); retrier.callWithRetry(() -> mutateZone(desiredRecordsCopy), ZoneStateException.class);
logger.info("Wrote to Cloud DNS"); logger.atInfo().log("Wrote to Cloud DNS");
} }
/** /**
@ -357,7 +357,7 @@ public class MultiplyingCloudDnsWriter extends BaseDnsWriter {
*/ */
private Map<String, List<ResourceRecordSet>> getResourceRecordsForDomains( private Map<String, List<ResourceRecordSet>> getResourceRecordsForDomains(
Set<String> domainNames) { Set<String> domainNames) {
logger.finefmt("Fetching records for %s", domainNames); logger.atFine().log("Fetching records for %s", domainNames);
// As per Concurrent.transform() - if numThreads or domainNames.size() < 2, it will not use // As per Concurrent.transform() - if numThreads or domainNames.size() < 2, it will not use
// threading. // threading.
return ImmutableMap.copyOf( return ImmutableMap.copyOf(
@ -406,12 +406,12 @@ public class MultiplyingCloudDnsWriter extends BaseDnsWriter {
// the result. // the result.
ImmutableSet<ResourceRecordSet> intersection = ImmutableSet<ResourceRecordSet> intersection =
Sets.intersection(additions, deletions).immutableCopy(); Sets.intersection(additions, deletions).immutableCopy();
logger.infofmt( logger.atInfo().log(
"There are %s common items out of the %s items in 'additions' and %s items in 'deletions'", "There are %d common items out of the %d items in 'additions' and %d items in 'deletions'",
intersection.size(), additions.size(), deletions.size()); intersection.size(), additions.size(), deletions.size());
// Exit early if we have nothing to update - dnsConnection doesn't work on empty changes // Exit early if we have nothing to update - dnsConnection doesn't work on empty changes
if (additions.equals(deletions)) { if (additions.equals(deletions)) {
logger.infofmt("Returning early because additions is the same as deletions"); logger.atInfo().log("Returning early because additions is the same as deletions");
return; return;
} }
Change change = Change change =

View file

@ -8,7 +8,6 @@ java_library(
name = "export", name = "export",
srcs = glob(["*.java"]), srcs = glob(["*.java"]),
deps = [ deps = [
"//java/com/google/common/logging:formatting_logger",
"//java/google/registry/bigquery", "//java/google/registry/bigquery",
"//java/google/registry/config", "//java/google/registry/config",
"//java/google/registry/gcs", "//java/google/registry/gcs",
@ -30,6 +29,8 @@ java_library(
"@com_google_appengine_tools_appengine_mapreduce", "@com_google_appengine_tools_appengine_mapreduce",
"@com_google_code_findbugs_jsr305", "@com_google_code_findbugs_jsr305",
"@com_google_dagger", "@com_google_dagger",
"@com_google_flogger",
"@com_google_flogger_system_backend",
"@com_google_guava", "@com_google_guava",
"@com_google_http_client", "@com_google_http_client",
"@com_googlecode_json_simple", "@com_googlecode_json_simple",

View file

@ -25,7 +25,7 @@ import com.google.appengine.api.taskqueue.Queue;
import com.google.appengine.api.taskqueue.TaskHandle; import com.google.appengine.api.taskqueue.TaskHandle;
import com.google.appengine.api.taskqueue.TaskOptions; import com.google.appengine.api.taskqueue.TaskOptions;
import com.google.appengine.api.taskqueue.TaskOptions.Method; import com.google.appengine.api.taskqueue.TaskOptions.Method;
import com.google.common.logging.FormattingLogger; import com.google.common.flogger.FluentLogger;
import dagger.Lazy; import dagger.Lazy;
import google.registry.request.Action; import google.registry.request.Action;
import google.registry.request.Header; import google.registry.request.Header;
@ -54,7 +54,7 @@ import org.joda.time.Duration;
) )
public class BigqueryPollJobAction implements Runnable { public class BigqueryPollJobAction implements Runnable {
private static final FormattingLogger logger = FormattingLogger.getLoggerForCallerClass(); private static final FluentLogger logger = FluentLogger.forEnclosingClass();
static final String QUEUE = "export-bigquery-poll"; // See queue.xml static final String QUEUE = "export-bigquery-poll"; // See queue.xml
static final String PATH = "/_dr/task/pollBigqueryJob"; // See web.xml static final String PATH = "/_dr/task/pollBigqueryJob"; // See web.xml
@ -85,12 +85,9 @@ public class BigqueryPollJobAction implements Runnable {
throw new BadRequestException("Cannot deserialize task from payload", e); throw new BadRequestException("Cannot deserialize task from payload", e);
} }
String taskName = taskQueueUtils.enqueue(getQueue(chainedQueueName.get()), task).getName(); String taskName = taskQueueUtils.enqueue(getQueue(chainedQueueName.get()), task).getName();
logger.infofmt( logger.atInfo().log(
"Added chained task %s for %s to queue %s: %s", "Added chained task %s for %s to queue %s: %s",
taskName, taskName, task.getUrl(), chainedQueueName.get(), task);
task.getUrl(),
chainedQueueName.get(),
task.toString());
} }
/** /**
@ -106,7 +103,7 @@ public class BigqueryPollJobAction implements Runnable {
job = bigquery.jobs().get(projectId, jobId).execute(); job = bigquery.jobs().get(projectId, jobId).execute();
} catch (IOException e) { } catch (IOException e) {
// We will throw a new exception because done==false, but first log this exception. // We will throw a new exception because done==false, but first log this exception.
logger.warningfmt(e, "Error checking outcome of BigQuery job %s.", jobId); logger.atWarning().withCause(e).log("Error checking outcome of BigQuery job %s.", jobId);
} }
// If job is not yet done, then throw an exception so that we'll return a failing HTTP status // If job is not yet done, then throw an exception so that we'll return a failing HTTP status
// code and the task will be retried. // code and the task will be retried.
@ -116,10 +113,10 @@ public class BigqueryPollJobAction implements Runnable {
// Check if the job ended with an error. // Check if the job ended with an error.
if (job.getStatus().getErrorResult() != null) { if (job.getStatus().getErrorResult() != null) {
logger.severefmt("Bigquery job failed - %s - %s", jobRefString, job); logger.atSevere().log("Bigquery job failed - %s - %s", jobRefString, job);
return false; return false;
} }
logger.infofmt("Bigquery job succeeded - %s", jobRefString); logger.atInfo().log("Bigquery job succeeded - %s", jobRefString);
return true; return true;
} }

View file

@ -15,7 +15,6 @@
package google.registry.export; package google.registry.export;
import static com.google.common.collect.Sets.intersection; import static com.google.common.collect.Sets.intersection;
import static com.google.common.logging.FormattingLogger.getLoggerForCallerClass;
import static google.registry.export.LoadSnapshotAction.enqueueLoadSnapshotTask; import static google.registry.export.LoadSnapshotAction.enqueueLoadSnapshotTask;
import static google.registry.request.Action.Method.GET; import static google.registry.request.Action.Method.GET;
import static google.registry.request.Action.Method.POST; import static google.registry.request.Action.Method.POST;
@ -28,7 +27,7 @@ import com.google.common.base.Joiner;
import com.google.common.base.Splitter; import com.google.common.base.Splitter;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
import com.google.common.logging.FormattingLogger; import com.google.common.flogger.FluentLogger;
import google.registry.export.DatastoreBackupInfo.BackupStatus; import google.registry.export.DatastoreBackupInfo.BackupStatus;
import google.registry.request.Action; import google.registry.request.Action;
import google.registry.request.HttpException.BadRequestException; import google.registry.request.HttpException.BadRequestException;
@ -69,7 +68,7 @@ public class CheckSnapshotAction implements Runnable {
/** The maximum amount of time we allow a backup to run before abandoning it. */ /** The maximum amount of time we allow a backup to run before abandoning it. */
static final Duration MAXIMUM_BACKUP_RUNNING_TIME = Duration.standardHours(20); static final Duration MAXIMUM_BACKUP_RUNNING_TIME = Duration.standardHours(20);
private static final FormattingLogger logger = getLoggerForCallerClass(); private static final FluentLogger logger = FluentLogger.forEnclosingClass();
@Inject Response response; @Inject Response response;
@Inject @RequestMethod Action.Method requestMethod; @Inject @RequestMethod Action.Method requestMethod;
@ -133,7 +132,7 @@ public class CheckSnapshotAction implements Runnable {
: backup.getStartTime().toString("YYYYMMdd_HHmmss"); : backup.getStartTime().toString("YYYYMMdd_HHmmss");
// Log a warning if kindsToLoad is not a subset of the exported snapshot kinds. // Log a warning if kindsToLoad is not a subset of the exported snapshot kinds.
if (!backup.getKinds().containsAll(kindsToLoad)) { if (!backup.getKinds().containsAll(kindsToLoad)) {
logger.warningfmt( logger.atWarning().log(
"Kinds to load included non-exported kinds: %s", "Kinds to load included non-exported kinds: %s",
Sets.difference(kindsToLoad, backup.getKinds())); Sets.difference(kindsToLoad, backup.getKinds()));
} }
@ -147,7 +146,7 @@ public class CheckSnapshotAction implements Runnable {
enqueueLoadSnapshotTask(snapshotId, backup.getGcsFilename().get(), exportedKindsToLoad); enqueueLoadSnapshotTask(snapshotId, backup.getGcsFilename().get(), exportedKindsToLoad);
message += "BigQuery load task enqueued"; message += "BigQuery load task enqueued";
} }
logger.info(message); logger.atInfo().log(message);
response.setPayload(message); response.setPayload(message);
} }

View file

@ -31,7 +31,7 @@ import com.google.appengine.tools.mapreduce.ReducerInput;
import com.google.common.base.Joiner; import com.google.common.base.Joiner;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.google.common.logging.FormattingLogger; import com.google.common.flogger.FluentLogger;
import com.google.common.net.MediaType; import com.google.common.net.MediaType;
import google.registry.config.RegistryConfig.Config; import google.registry.config.RegistryConfig.Config;
import google.registry.gcs.GcsUtils; import google.registry.gcs.GcsUtils;
@ -60,7 +60,7 @@ import org.joda.time.DateTime;
@Action(path = "/_dr/task/exportDomainLists", method = POST, auth = Auth.AUTH_INTERNAL_ONLY) @Action(path = "/_dr/task/exportDomainLists", method = POST, auth = Auth.AUTH_INTERNAL_ONLY)
public class ExportDomainListsAction implements Runnable { public class ExportDomainListsAction implements Runnable {
private static final FormattingLogger logger = FormattingLogger.getLoggerForCallerClass(); private static final FluentLogger logger = FluentLogger.forEnclosingClass();
private static final int MAX_NUM_REDUCE_SHARDS = 100; private static final int MAX_NUM_REDUCE_SHARDS = 100;
@Inject MapreduceRunner mrRunner; @Inject MapreduceRunner mrRunner;
@ -72,7 +72,7 @@ public class ExportDomainListsAction implements Runnable {
@Override @Override
public void run() { public void run() {
ImmutableSet<String> realTlds = getTldsOfType(TldType.REAL); ImmutableSet<String> realTlds = getTldsOfType(TldType.REAL);
logger.infofmt("Exporting domain lists for tlds %s", realTlds); logger.atInfo().log("Exporting domain lists for tlds %s", realTlds);
response.sendJavaScriptRedirect(createJobPath(mrRunner response.sendJavaScriptRedirect(createJobPath(mrRunner
.setJobName("Export domain lists") .setJobName("Export domain lists")
.setModuleName("backend") .setModuleName("backend")
@ -131,7 +131,7 @@ public class ExportDomainListsAction implements Runnable {
try { try {
Registry registry = Registry.get(tld); Registry registry = Registry.get(tld);
if (registry.getDriveFolderId() == null) { if (registry.getDriveFolderId() == null) {
logger.infofmt( logger.atInfo().log(
"Skipping registered domains export for TLD %s because Drive folder isn't specified", "Skipping registered domains export for TLD %s because Drive folder isn't specified",
tld); tld);
} else { } else {
@ -141,12 +141,13 @@ public class ExportDomainListsAction implements Runnable {
EXPORT_MIME_TYPE, EXPORT_MIME_TYPE,
registry.getDriveFolderId(), registry.getDriveFolderId(),
domains.getBytes(UTF_8)); domains.getBytes(UTF_8));
logger.infofmt( logger.atInfo().log(
"Exporting registered domains succeeded for TLD %s, response was: %s", "Exporting registered domains succeeded for TLD %s, response was: %s",
tld, resultMsg); tld, resultMsg);
} }
} catch (Throwable e) { } catch (Throwable e) {
logger.severefmt(e, "Error exporting registered domains for TLD %s to Drive", tld); logger.atSevere().withCause(e).log(
"Error exporting registered domains for TLD %s to Drive", tld);
} }
getContext().incrementCounter("domain lists written out to Drive"); getContext().incrementCounter("domain lists written out to Drive");
} }
@ -159,7 +160,8 @@ public class ExportDomainListsAction implements Runnable {
Writer osWriter = new OutputStreamWriter(gcsOutput, UTF_8)) { Writer osWriter = new OutputStreamWriter(gcsOutput, UTF_8)) {
osWriter.write(domains); osWriter.write(domains);
} catch (IOException e) { } catch (IOException e) {
logger.severefmt(e, "Error exporting registered domains for TLD %s to GCS.", tld); logger.atSevere().withCause(e).log(
"Error exporting registered domains for TLD %s to GCS.", tld);
} }
getContext().incrementCounter("domain lists written out to GCS"); getContext().incrementCounter("domain lists written out to GCS");
} }
@ -168,7 +170,7 @@ public class ExportDomainListsAction implements Runnable {
public void reduce(String tld, ReducerInput<String> fqdns) { public void reduce(String tld, ReducerInput<String> fqdns) {
ImmutableList<String> domains = ImmutableList.sortedCopyOf(() -> fqdns); ImmutableList<String> domains = ImmutableList.sortedCopyOf(() -> fqdns);
String domainsList = Joiner.on('\n').join(domains); String domainsList = Joiner.on('\n').join(domains);
logger.infofmt("Exporting %d domains for TLD %s to GCS and Drive.", domains.size(), tld); logger.atInfo().log("Exporting %d domains for TLD %s to GCS and Drive.", domains.size(), tld);
exportToGcs(tld, domainsList); exportToGcs(tld, domainsList);
exportToDrive(tld, domainsList); exportToDrive(tld, domainsList);
} }

View file

@ -21,7 +21,7 @@ import static java.nio.charset.StandardCharsets.UTF_8;
import static javax.servlet.http.HttpServletResponse.SC_INTERNAL_SERVER_ERROR; import static javax.servlet.http.HttpServletResponse.SC_INTERNAL_SERVER_ERROR;
import static javax.servlet.http.HttpServletResponse.SC_OK; import static javax.servlet.http.HttpServletResponse.SC_OK;
import com.google.common.logging.FormattingLogger; import com.google.common.flogger.FluentLogger;
import com.google.common.net.MediaType; import com.google.common.net.MediaType;
import google.registry.model.registry.Registry; import google.registry.model.registry.Registry;
import google.registry.request.Action; import google.registry.request.Action;
@ -40,7 +40,7 @@ import javax.inject.Inject;
) )
public class ExportReservedTermsAction implements Runnable { public class ExportReservedTermsAction implements Runnable {
private static final FormattingLogger logger = FormattingLogger.getLoggerForCallerClass(); private static final FluentLogger logger = FluentLogger.forEnclosingClass();
static final MediaType EXPORT_MIME_TYPE = MediaType.PLAIN_TEXT_UTF_8; static final MediaType EXPORT_MIME_TYPE = MediaType.PLAIN_TEXT_UTF_8;
static final String RESERVED_TERMS_FILENAME = "reserved_terms.txt"; static final String RESERVED_TERMS_FILENAME = "reserved_terms.txt";
@ -65,10 +65,10 @@ public class ExportReservedTermsAction implements Runnable {
String resultMsg; String resultMsg;
if (registry.getReservedLists().isEmpty() && isNullOrEmpty(registry.getDriveFolderId())) { if (registry.getReservedLists().isEmpty() && isNullOrEmpty(registry.getDriveFolderId())) {
resultMsg = "No reserved lists configured"; resultMsg = "No reserved lists configured";
logger.infofmt("No reserved terms to export for TLD %s", tld); logger.atInfo().log("No reserved terms to export for TLD %s", tld);
} else if (registry.getDriveFolderId() == null) { } else if (registry.getDriveFolderId() == null) {
resultMsg = "Skipping export because no Drive folder is associated with this TLD"; resultMsg = "Skipping export because no Drive folder is associated with this TLD";
logger.infofmt( logger.atInfo().log(
"Skipping reserved terms export for TLD %s because Drive folder isn't specified", tld); "Skipping reserved terms export for TLD %s because Drive folder isn't specified", tld);
} else { } else {
resultMsg = driveConnection.createOrUpdateFile( resultMsg = driveConnection.createOrUpdateFile(
@ -76,8 +76,8 @@ public class ExportReservedTermsAction implements Runnable {
EXPORT_MIME_TYPE, EXPORT_MIME_TYPE,
registry.getDriveFolderId(), registry.getDriveFolderId(),
exportUtils.exportReservedTerms(registry).getBytes(UTF_8)); exportUtils.exportReservedTerms(registry).getBytes(UTF_8));
logger.infofmt("Exporting reserved terms succeeded for TLD %s, response was: %s", logger.atInfo().log(
tld, resultMsg); "Exporting reserved terms succeeded for TLD %s, response was: %s", tld, resultMsg);
} }
response.setStatus(SC_OK); response.setStatus(SC_OK);
response.setPayload(resultMsg); response.setPayload(resultMsg);

View file

@ -17,7 +17,7 @@ package google.registry.export;
import static google.registry.export.CheckSnapshotAction.enqueuePollTask; import static google.registry.export.CheckSnapshotAction.enqueuePollTask;
import static google.registry.request.Action.Method.POST; import static google.registry.request.Action.Method.POST;
import com.google.common.logging.FormattingLogger; import com.google.common.flogger.FluentLogger;
import google.registry.config.RegistryConfig; import google.registry.config.RegistryConfig;
import google.registry.request.Action; import google.registry.request.Action;
import google.registry.request.Response; import google.registry.request.Response;
@ -54,7 +54,7 @@ public class ExportSnapshotAction implements Runnable {
/** Prefix to use for naming all snapshots that are started by this servlet. */ /** Prefix to use for naming all snapshots that are started by this servlet. */
static final String SNAPSHOT_PREFIX = "auto_snapshot_"; static final String SNAPSHOT_PREFIX = "auto_snapshot_";
private static final FormattingLogger logger = FormattingLogger.getLoggerForCallerClass(); private static final FluentLogger logger = FluentLogger.forEnclosingClass();
@Inject Clock clock; @Inject Clock clock;
@Inject DatastoreBackupService backupService; @Inject DatastoreBackupService backupService;
@ -72,7 +72,7 @@ public class ExportSnapshotAction implements Runnable {
// Enqueue a poll task to monitor the backup and load reporting-related kinds into bigquery. // Enqueue a poll task to monitor the backup and load reporting-related kinds into bigquery.
enqueuePollTask(snapshotName, ExportConstants.getReportingKinds()); enqueuePollTask(snapshotName, ExportConstants.getReportingKinds());
String message = "Datastore backup started with name: " + snapshotName; String message = "Datastore backup started with name: " + snapshotName;
logger.info(message); logger.atInfo().log(message);
response.setPayload(message); response.setPayload(message);
} }
} }

View file

@ -17,7 +17,6 @@ package google.registry.export;
import static com.google.appengine.api.taskqueue.QueueFactory.getQueue; import static com.google.appengine.api.taskqueue.QueueFactory.getQueue;
import static com.google.common.base.MoreObjects.firstNonNull; import static com.google.common.base.MoreObjects.firstNonNull;
import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.logging.FormattingLogger.getLoggerForCallerClass;
import static google.registry.export.UpdateSnapshotViewAction.createViewUpdateTask; import static google.registry.export.UpdateSnapshotViewAction.createViewUpdateTask;
import static google.registry.request.Action.Method.POST; import static google.registry.request.Action.Method.POST;
@ -34,7 +33,7 @@ import com.google.common.base.Joiner;
import com.google.common.base.Splitter; import com.google.common.base.Splitter;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.google.common.logging.FormattingLogger; import com.google.common.flogger.FluentLogger;
import google.registry.bigquery.BigqueryFactory; import google.registry.bigquery.BigqueryFactory;
import google.registry.bigquery.BigqueryUtils.SourceFormat; import google.registry.bigquery.BigqueryUtils.SourceFormat;
import google.registry.bigquery.BigqueryUtils.WriteDisposition; import google.registry.bigquery.BigqueryUtils.WriteDisposition;
@ -69,7 +68,7 @@ public class LoadSnapshotAction implements Runnable {
static final String QUEUE = "export-snapshot"; // See queue.xml. static final String QUEUE = "export-snapshot"; // See queue.xml.
static final String PATH = "/_dr/task/loadSnapshot"; // See web.xml. static final String PATH = "/_dr/task/loadSnapshot"; // See web.xml.
private static final FormattingLogger logger = getLoggerForCallerClass(); private static final FluentLogger logger = FluentLogger.forEnclosingClass();
@Inject BigqueryFactory bigqueryFactory; @Inject BigqueryFactory bigqueryFactory;
@Inject BigqueryPollJobEnqueuer bigqueryPollEnqueuer; @Inject BigqueryPollJobEnqueuer bigqueryPollEnqueuer;
@ -96,9 +95,9 @@ public class LoadSnapshotAction implements Runnable {
try { try {
String message = String message =
loadSnapshot(snapshotId, snapshotFile, Splitter.on(',').split(snapshotKinds)); loadSnapshot(snapshotId, snapshotFile, Splitter.on(',').split(snapshotKinds));
logger.infofmt("Loaded snapshot successfully: %s", message); logger.atInfo().log("Loaded snapshot successfully: %s", message);
} catch (Throwable e) { } catch (Throwable e) {
logger.severe(e, "Error loading snapshot"); logger.atSevere().withCause(e).log("Error loading snapshot");
if (e instanceof IllegalArgumentException) { if (e instanceof IllegalArgumentException) {
throw new BadRequestException("Error calling load snapshot: " + e.getMessage(), e); throw new BadRequestException("Error calling load snapshot: " + e.getMessage(), e);
} else { } else {
@ -114,7 +113,7 @@ public class LoadSnapshotAction implements Runnable {
DateTime now = clock.nowUtc(); DateTime now = clock.nowUtc();
String loadMessage = String loadMessage =
String.format("Loading Datastore snapshot %s from %s...", snapshotId, gcsFilename); String.format("Loading Datastore snapshot %s from %s...", snapshotId, gcsFilename);
logger.info(loadMessage); logger.atInfo().log(loadMessage);
StringBuilder builder = new StringBuilder(loadMessage + "\n"); StringBuilder builder = new StringBuilder(loadMessage + "\n");
builder.append("Load jobs:\n"); builder.append("Load jobs:\n");
@ -136,7 +135,7 @@ public class LoadSnapshotAction implements Runnable {
getQueue(UpdateSnapshotViewAction.QUEUE)); getQueue(UpdateSnapshotViewAction.QUEUE));
builder.append(String.format(" - %s:%s\n", projectId, jobId)); builder.append(String.format(" - %s:%s\n", projectId, jobId));
logger.infofmt("Submitted load job %s:%s", projectId, jobId); logger.atInfo().log("Submitted load job %s:%s", projectId, jobId);
} }
return builder.toString(); return builder.toString();
} }

View file

@ -20,8 +20,8 @@ import static google.registry.util.PreconditionsUtils.checkArgumentPresent;
import com.google.appengine.tools.cloudstorage.GcsFilename; import com.google.appengine.tools.cloudstorage.GcsFilename;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import com.google.common.flogger.FluentLogger;
import com.google.common.io.ByteStreams; import com.google.common.io.ByteStreams;
import com.google.common.logging.FormattingLogger;
import com.google.common.net.MediaType; import com.google.common.net.MediaType;
import google.registry.gcs.GcsUtils; import google.registry.gcs.GcsUtils;
import google.registry.model.registrar.Registrar; import google.registry.model.registrar.Registrar;
@ -52,7 +52,7 @@ import javax.inject.Inject;
@Deprecated @Deprecated
public final class PublishDetailReportAction implements Runnable, JsonAction { public final class PublishDetailReportAction implements Runnable, JsonAction {
private static final FormattingLogger logger = FormattingLogger.getLoggerForCallerClass(); private static final FluentLogger logger = FluentLogger.forEnclosingClass();
/** MIME type to use for deposited report files in Drive. */ /** MIME type to use for deposited report files in Drive. */
private static final MediaType REPORT_MIME_TYPE = MediaType.CSV_UTF_8; private static final MediaType REPORT_MIME_TYPE = MediaType.CSV_UTF_8;
@ -91,7 +91,7 @@ public final class PublishDetailReportAction implements Runnable, JsonAction {
@Override @Override
public Map<String, Object> handleJsonRequest(Map<String, ?> json) { public Map<String, Object> handleJsonRequest(Map<String, ?> json) {
try { try {
logger.infofmt("Publishing detail report for parameters: %s", json); logger.atInfo().log("Publishing detail report for parameters: %s", json);
String registrarId = getParam(json, REGISTRAR_ID_PARAM); String registrarId = getParam(json, REGISTRAR_ID_PARAM);
Registrar registrar = Registrar registrar =
checkArgumentPresent( checkArgumentPresent(
@ -111,11 +111,9 @@ public final class PublishDetailReportAction implements Runnable, JsonAction {
REPORT_MIME_TYPE, REPORT_MIME_TYPE,
driveFolderId, driveFolderId,
ByteStreams.toByteArray(input)); ByteStreams.toByteArray(input));
logger.infofmt("Published detail report for %s to folder %s using GCS file gs://%s/%s.", logger.atInfo().log(
registrarId, "Published detail report for %s to folder %s using GCS file gs://%s/%s.",
driveFolderId, registrarId, driveFolderId, gcsBucketName, gcsObjectName);
gcsBucketName,
gcsObjectName);
return ImmutableMap.of("driveId", driveId); return ImmutableMap.of("driveId", driveId);
} catch (FileNotFoundException e) { } catch (FileNotFoundException e) {
throw new IllegalArgumentException(e.getMessage(), e); throw new IllegalArgumentException(e.getMessage(), e);

View file

@ -27,7 +27,7 @@ import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
import com.google.common.collect.Streams; import com.google.common.collect.Streams;
import com.google.common.logging.FormattingLogger; import com.google.common.flogger.FluentLogger;
import google.registry.config.RegistryConfig.Config; import google.registry.config.RegistryConfig.Config;
import google.registry.groups.GroupsConnection; import google.registry.groups.GroupsConnection;
import google.registry.groups.GroupsConnection.Role; import google.registry.groups.GroupsConnection.Role;
@ -58,7 +58,7 @@ import javax.inject.Inject;
) )
public final class SyncGroupMembersAction implements Runnable { public final class SyncGroupMembersAction implements Runnable {
private static final FormattingLogger logger = FormattingLogger.getLoggerForCallerClass(); private static final FluentLogger logger = FluentLogger.forEnclosingClass();
private enum Result { private enum Result {
OK(SC_OK, "Group memberships successfully updated."), OK(SC_OK, "Group memberships successfully updated."),
@ -66,7 +66,7 @@ public final class SyncGroupMembersAction implements Runnable {
FAILED(SC_INTERNAL_SERVER_ERROR, "Error occurred while updating registrar contacts.") { FAILED(SC_INTERNAL_SERVER_ERROR, "Error occurred while updating registrar contacts.") {
@Override @Override
protected void log(Throwable cause) { protected void log(Throwable cause) {
logger.severe(cause, message); logger.atSevere().withCause(cause).log(message);
}}; }};
final int statusCode; final int statusCode;
@ -79,7 +79,7 @@ public final class SyncGroupMembersAction implements Runnable {
/** Log an error message. Results that use log levels other than info should override this. */ /** Log an error message. Results that use log levels other than info should override this. */
void log(@Nullable Throwable cause) { void log(@Nullable Throwable cause) {
logger.info(cause, message); logger.atInfo().withCause(cause).log(message);
} }
} }
@ -134,7 +134,7 @@ public final class SyncGroupMembersAction implements Runnable {
retrier.callWithRetry(() -> syncRegistrarContacts(registrar), RuntimeException.class); retrier.callWithRetry(() -> syncRegistrarContacts(registrar), RuntimeException.class);
resultsBuilder.put(registrar, Optional.empty()); resultsBuilder.put(registrar, Optional.empty());
} catch (Throwable e) { } catch (Throwable e) {
logger.severe(e, e.getMessage()); logger.atSevere().withCause(e).log(e.getMessage());
resultsBuilder.put(registrar, Optional.of(e)); resultsBuilder.put(registrar, Optional.of(e));
} }
} }
@ -193,10 +193,9 @@ public final class SyncGroupMembersAction implements Runnable {
totalRemoved++; totalRemoved++;
} }
} }
logger.infofmt("Successfully synced contacts for registrar %s: added %d and removed %d", logger.atInfo().log(
registrar.getClientId(), "Successfully synced contacts for registrar %s: added %d and removed %d",
totalAdded, registrar.getClientId(), totalAdded, totalRemoved);
totalRemoved);
} catch (IOException e) { } catch (IOException e) {
// Package up exception and re-throw with attached additional relevant info. // Package up exception and re-throw with attached additional relevant info.
String msg = String.format("Couldn't sync contacts for registrar %s to group %s", String msg = String.format("Couldn't sync contacts for registrar %s to group %s",

View file

@ -23,7 +23,7 @@ import com.google.api.services.bigquery.model.TableReference;
import com.google.api.services.bigquery.model.ViewDefinition; import com.google.api.services.bigquery.model.ViewDefinition;
import com.google.appengine.api.taskqueue.TaskOptions; import com.google.appengine.api.taskqueue.TaskOptions;
import com.google.appengine.api.taskqueue.TaskOptions.Method; import com.google.appengine.api.taskqueue.TaskOptions.Method;
import com.google.common.logging.FormattingLogger; import com.google.common.flogger.FluentLogger;
import google.registry.bigquery.BigqueryFactory; import google.registry.bigquery.BigqueryFactory;
import google.registry.config.RegistryConfig.Config; import google.registry.config.RegistryConfig.Config;
import google.registry.request.Action; import google.registry.request.Action;
@ -52,7 +52,7 @@ public class UpdateSnapshotViewAction implements Runnable {
static final String PATH = "/_dr/task/updateSnapshotView"; // See web.xml. static final String PATH = "/_dr/task/updateSnapshotView"; // See web.xml.
private static final FormattingLogger logger = FormattingLogger.getLoggerForCallerClass(); private static final FluentLogger logger = FluentLogger.forEnclosingClass();
@Inject @Inject
@Parameter(UPDATE_SNAPSHOT_DATASET_ID_PARAM) @Parameter(UPDATE_SNAPSHOT_DATASET_ID_PARAM)
@ -101,8 +101,8 @@ public class UpdateSnapshotViewAction implements Runnable {
datasetId, tableId, kindName, STANDARD_LATEST_SNAPSHOT_DATASET, standardTemplate, false); datasetId, tableId, kindName, STANDARD_LATEST_SNAPSHOT_DATASET, standardTemplate, false);
} catch (Throwable e) { } catch (Throwable e) {
logger.severefmt(e, "Could not update snapshot view for table %s", tableId); throw new InternalServerErrorException(
throw new InternalServerErrorException("Error in update snapshot view action"); String.format("Could not update snapshot view for table %s", tableId), e);
} }
} }
@ -134,7 +134,7 @@ public class UpdateSnapshotViewAction implements Runnable {
.put("SOURCE_TABLE", sourceTableId) .put("SOURCE_TABLE", sourceTableId)
.build()))); .build())));
logger.infofmt( logger.atInfo().log(
"Updated view [%s:%s.%s] to point at snapshot table [%s:%s.%s].", "Updated view [%s:%s.%s] to point at snapshot table [%s:%s.%s].",
projectId, viewDataset, kindName, projectId, sourceDatasetId, sourceTableId); projectId, viewDataset, kindName, projectId, sourceDatasetId, sourceTableId);
} }
@ -150,8 +150,8 @@ public class UpdateSnapshotViewAction implements Runnable {
if (e.getDetails().getCode() == 404) { if (e.getDetails().getCode() == 404) {
bigquery.tables().insert(ref.getProjectId(), ref.getDatasetId(), table).execute(); bigquery.tables().insert(ref.getProjectId(), ref.getDatasetId(), table).execute();
} else { } else {
logger.warningfmt( logger.atWarning().withCause(e).log(
e, "UpdateSnapshotViewAction failed, caught exception %s", e.getDetails()); "UpdateSnapshotViewAction failed, caught exception %s", e.getDetails());
} }
} }
} }

View file

@ -8,7 +8,6 @@ java_library(
name = "sheet", name = "sheet",
srcs = glob(["*.java"]), srcs = glob(["*.java"]),
deps = [ deps = [
"//java/com/google/common/logging:formatting_logger",
"//java/google/registry/config", "//java/google/registry/config",
"//java/google/registry/model", "//java/google/registry/model",
"//java/google/registry/request", "//java/google/registry/request",
@ -21,6 +20,8 @@ java_library(
"@com_google_appengine_api_1_0_sdk", "@com_google_appengine_api_1_0_sdk",
"@com_google_code_findbugs_jsr305", "@com_google_code_findbugs_jsr305",
"@com_google_dagger", "@com_google_dagger",
"@com_google_flogger",
"@com_google_flogger_system_backend",
"@com_google_guava", "@com_google_guava",
"@com_google_http_client", "@com_google_http_client",
"@javax_servlet_api", "@javax_servlet_api",

View file

@ -25,7 +25,7 @@ import com.google.api.services.sheets.v4.model.ClearValuesResponse;
import com.google.api.services.sheets.v4.model.ValueRange; import com.google.api.services.sheets.v4.model.ValueRange;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import com.google.common.logging.FormattingLogger; import com.google.common.flogger.FluentLogger;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -34,7 +34,7 @@ import javax.inject.Inject;
/** Generic data synchronization utility for Google Spreadsheets. */ /** Generic data synchronization utility for Google Spreadsheets. */
class SheetSynchronizer { class SheetSynchronizer {
private static final FormattingLogger logger = FormattingLogger.getLoggerForCallerClass(); private static final FluentLogger logger = FluentLogger.forEnclosingClass();
private static final String SHEET_NAME = "Registrars"; private static final String SHEET_NAME = "Registrars";
@ -117,7 +117,7 @@ class SheetSynchronizer {
BatchUpdateValuesResponse response = BatchUpdateValuesResponse response =
sheetsService.spreadsheets().values().batchUpdate(spreadsheetId, updateRequest).execute(); sheetsService.spreadsheets().values().batchUpdate(spreadsheetId, updateRequest).execute();
Integer cellsUpdated = response.getTotalUpdatedCells(); Integer cellsUpdated = response.getTotalUpdatedCells();
logger.infofmt("Updated %d originalVals", cellsUpdated != null ? cellsUpdated : 0); logger.atInfo().log("Updated %d originalVals", cellsUpdated != null ? cellsUpdated : 0);
} }
// Append extra rows if necessary // Append extra rows if necessary
@ -139,7 +139,7 @@ class SheetSynchronizer {
.setValueInputOption("RAW") .setValueInputOption("RAW")
.setInsertDataOption("INSERT_ROWS") .setInsertDataOption("INSERT_ROWS")
.execute(); .execute();
logger.infofmt( logger.atInfo().log(
"Appended %d rows to range %s", "Appended %d rows to range %s",
data.size() - originalVals.size(), appendResponse.getTableRange()); data.size() - originalVals.size(), appendResponse.getTableRange());
// Clear the extra rows if necessary // Clear the extra rows if necessary
@ -154,7 +154,7 @@ class SheetSynchronizer {
getRowRange(data.size(), originalVals.size()), getRowRange(data.size(), originalVals.size()),
new ClearValuesRequest()) new ClearValuesRequest())
.execute(); .execute();
logger.infofmt( logger.atInfo().log(
"Cleared %d rows from range %s", "Cleared %d rows from range %s",
originalVals.size() - data.size(), clearResponse.getClearedRange()); originalVals.size() - data.size(), clearResponse.getClearedRange());
} }

View file

@ -27,7 +27,7 @@ import com.google.appengine.api.modules.ModulesService;
import com.google.appengine.api.modules.ModulesServiceFactory; import com.google.appengine.api.modules.ModulesServiceFactory;
import com.google.appengine.api.taskqueue.TaskHandle; import com.google.appengine.api.taskqueue.TaskHandle;
import com.google.appengine.api.taskqueue.TaskOptions.Method; import com.google.appengine.api.taskqueue.TaskOptions.Method;
import com.google.common.logging.FormattingLogger; import com.google.common.flogger.FluentLogger;
import google.registry.config.RegistryConfig.Config; import google.registry.config.RegistryConfig.Config;
import google.registry.request.Action; import google.registry.request.Action;
import google.registry.request.Parameter; import google.registry.request.Parameter;
@ -74,12 +74,12 @@ public class SyncRegistrarsSheetAction implements Runnable {
MISSINGNO(SC_BAD_REQUEST, "No sheet ID specified or configured; dropping task.") { MISSINGNO(SC_BAD_REQUEST, "No sheet ID specified or configured; dropping task.") {
@Override @Override
protected void log(Exception cause) { protected void log(Exception cause) {
logger.warning(cause, message); logger.atWarning().withCause(cause).log(message);
}}, }},
FAILED(SC_INTERNAL_SERVER_ERROR, "Spreadsheet synchronization failed") { FAILED(SC_INTERNAL_SERVER_ERROR, "Spreadsheet synchronization failed") {
@Override @Override
protected void log(Exception cause) { protected void log(Exception cause) {
logger.severe(cause, message); logger.atSevere().withCause(cause).log(message);
}}; }};
private final int statusCode; private final int statusCode;
@ -92,7 +92,7 @@ public class SyncRegistrarsSheetAction implements Runnable {
/** Log an error message. Results that use log levels other than info should override this. */ /** Log an error message. Results that use log levels other than info should override this. */
protected void log(@Nullable Exception cause) { protected void log(@Nullable Exception cause) {
logger.info(cause, message); logger.atInfo().withCause(cause).log(message);
} }
private void send(Response response, @Nullable Exception cause) { private void send(Response response, @Nullable Exception cause) {
@ -106,7 +106,7 @@ public class SyncRegistrarsSheetAction implements Runnable {
public static final String PATH = "/_dr/task/syncRegistrarsSheet"; public static final String PATH = "/_dr/task/syncRegistrarsSheet";
private static final String QUEUE = "sheet"; private static final String QUEUE = "sheet";
private static final String LOCK_NAME = "Synchronize registrars sheet"; private static final String LOCK_NAME = "Synchronize registrars sheet";
private static final FormattingLogger logger = FormattingLogger.getLoggerForCallerClass(); private static final FluentLogger logger = FluentLogger.forEnclosingClass();
@NonFinalForTesting @NonFinalForTesting
private static ModulesService modulesService = ModulesServiceFactory.getModulesService(); private static ModulesService modulesService = ModulesServiceFactory.getModulesService();

View file

@ -23,7 +23,6 @@ java_library(
visibility = ["//visibility:public"], visibility = ["//visibility:public"],
deps = [ deps = [
":soy_java_wrappers", ":soy_java_wrappers",
"//java/com/google/common/logging:formatting_logger",
"//java/google/registry/config", "//java/google/registry/config",
"//java/google/registry/dns", "//java/google/registry/dns",
"//java/google/registry/model", "//java/google/registry/model",
@ -40,6 +39,8 @@ java_library(
"@com_google_auto_value", "@com_google_auto_value",
"@com_google_code_findbugs_jsr305", "@com_google_code_findbugs_jsr305",
"@com_google_dagger", "@com_google_dagger",
"@com_google_flogger",
"@com_google_flogger_system_backend",
"@com_google_guava", "@com_google_guava",
"@com_google_monitoring_client_metrics", "@com_google_monitoring_client_metrics",
"@com_googlecode_json_simple", "@com_googlecode_json_simple",

View file

@ -29,7 +29,7 @@ import static org.json.simple.JSONValue.toJSONString;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Iterables; import com.google.common.collect.Iterables;
import com.google.common.logging.FormattingLogger; import com.google.common.flogger.FluentLogger;
import com.google.common.net.InternetDomainName; import com.google.common.net.InternetDomainName;
import com.google.common.net.MediaType; import com.google.common.net.MediaType;
import com.google.template.soy.SoyFileSet; import com.google.template.soy.SoyFileSet;
@ -64,7 +64,7 @@ import javax.servlet.http.HttpServletRequest;
) )
public class CheckApiAction implements Runnable { public class CheckApiAction implements Runnable {
private static final FormattingLogger logger = FormattingLogger.getLoggerForCallerClass(); private static final FluentLogger logger = FluentLogger.forEnclosingClass();
private static final SoyTofu TOFU = private static final SoyTofu TOFU =
SoyFileSet.builder().add(getResource(DomainCheckFeeEppSoyInfo.class, SoyFileSet.builder().add(getResource(DomainCheckFeeEppSoyInfo.class,
@ -138,7 +138,7 @@ public class CheckApiAction implements Runnable {
} }
return builder.build(); return builder.build();
} catch (Exception e) { } catch (Exception e) {
logger.warning(e, "Unknown error"); logger.atWarning().withCause(e).log("Unknown error");
return fail("Invalid request"); return fail("Invalid request");
} }
} }

View file

@ -15,6 +15,7 @@
package google.registry.flows; package google.registry.flows;
import static com.google.common.base.Strings.nullToEmpty; import static com.google.common.base.Strings.nullToEmpty;
import static com.google.common.flogger.LazyArgs.lazy;
import static com.google.common.io.BaseEncoding.base64; import static com.google.common.io.BaseEncoding.base64;
import static google.registry.flows.EppXmlTransformer.unmarshal; import static google.registry.flows.EppXmlTransformer.unmarshal;
import static google.registry.flows.FlowReporter.extractTlds; import static google.registry.flows.FlowReporter.extractTlds;
@ -24,7 +25,7 @@ import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Joiner; import com.google.common.base.Joiner;
import com.google.common.base.Strings; import com.google.common.base.Strings;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import com.google.common.logging.FormattingLogger; import com.google.common.flogger.FluentLogger;
import google.registry.flows.FlowModule.EppExceptionInProviderException; import google.registry.flows.FlowModule.EppExceptionInProviderException;
import google.registry.model.eppcommon.Trid; import google.registry.model.eppcommon.Trid;
import google.registry.model.eppinput.EppInput; import google.registry.model.eppinput.EppInput;
@ -35,7 +36,6 @@ import google.registry.model.eppoutput.Result.Code;
import google.registry.monitoring.whitebox.BigQueryMetricsEnqueuer; import google.registry.monitoring.whitebox.BigQueryMetricsEnqueuer;
import google.registry.monitoring.whitebox.EppMetric; import google.registry.monitoring.whitebox.EppMetric;
import java.util.Optional; import java.util.Optional;
import java.util.logging.Level;
import javax.inject.Inject; import javax.inject.Inject;
import org.json.simple.JSONValue; import org.json.simple.JSONValue;
@ -46,7 +46,8 @@ import org.json.simple.JSONValue;
*/ */
public final class EppController { public final class EppController {
private static final FormattingLogger logger = FormattingLogger.getLoggerForCallerClass(); private static final FluentLogger logger = FluentLogger.forEnclosingClass();
private static final String LOG_SEPARATOR = Strings.repeat("=", 40);
@Inject FlowComponent.Builder flowComponentBuilder; @Inject FlowComponent.Builder flowComponentBuilder;
@Inject EppMetric.Builder eppMetricBuilder; @Inject EppMetric.Builder eppMetricBuilder;
@ -71,25 +72,27 @@ public final class EppController {
eppInput = unmarshal(EppInput.class, inputXmlBytes); eppInput = unmarshal(EppInput.class, inputXmlBytes);
} catch (EppException e) { } catch (EppException e) {
// Log the unmarshalling error, with the raw bytes (in base64) to help with debugging. // Log the unmarshalling error, with the raw bytes (in base64) to help with debugging.
if (logger.isLoggable(Level.INFO)) { logger.atInfo().withCause(e).log(
logger.infofmt( "EPP request XML unmarshalling failed - \"%s\":\n%s\n%s\n%s\n%s",
e, e.getMessage(),
"EPP request XML unmarshalling failed - \"%s\":\n%s\n%s\n%s\n%s", lazy(
e.getMessage(), () ->
JSONValue.toJSONString( JSONValue.toJSONString(
ImmutableMap.<String, Object>of( ImmutableMap.<String, Object>of(
"clientId", "clientId",
nullToEmpty(sessionMetadata.getClientId()), nullToEmpty(sessionMetadata.getClientId()),
"resultCode", "resultCode",
e.getResult().getCode().code, e.getResult().getCode().code,
"resultMessage", "resultMessage",
e.getResult().getCode().msg, e.getResult().getCode().msg,
"xmlBytes", "xmlBytes",
base64().encode(inputXmlBytes))), base64().encode(inputXmlBytes)))),
Strings.repeat("=", 40), LOG_SEPARATOR,
new String(inputXmlBytes, UTF_8).trim(), // Charset decoding failures are swallowed. lazy(
Strings.repeat("=", 40)); () ->
} new String(inputXmlBytes, UTF_8)
.trim()), // Charset decoding failures are swallowed.
LOG_SEPARATOR);
// Return early by sending an error message, with no clTRID since we couldn't unmarshal it. // Return early by sending an error message, with no clTRID since we couldn't unmarshal it.
eppMetricBuilder.setStatus(e.getResult().getCode()); eppMetricBuilder.setStatus(e.getResult().getCode());
return getErrorResponse( return getErrorResponse(
@ -133,12 +136,12 @@ public final class EppController {
} catch (EppException | EppExceptionInProviderException e) { } catch (EppException | EppExceptionInProviderException e) {
// The command failed. Send the client an error message, but only log at INFO since many of // The command failed. Send the client an error message, but only log at INFO since many of
// these failures are innocuous or due to client error, so there's nothing we have to change. // these failures are innocuous or due to client error, so there's nothing we have to change.
logger.info(e, "Flow returned failure response"); logger.atInfo().withCause(e).log("Flow returned failure response");
EppException eppEx = (EppException) (e instanceof EppException ? e : e.getCause()); EppException eppEx = (EppException) (e instanceof EppException ? e : e.getCause());
return getErrorResponse(eppEx.getResult(), flowComponent.trid()); return getErrorResponse(eppEx.getResult(), flowComponent.trid());
} catch (Throwable e) { } catch (Throwable e) {
// Something bad and unexpected happened. Send the client a generic error, and log at SEVERE. // Something bad and unexpected happened. Send the client a generic error, and log at SEVERE.
logger.severe(e, "Unexpected failure in flow execution"); logger.atSevere().withCause(e).log("Unexpected failure in flow execution");
return getErrorResponse(Result.create(Code.COMMAND_FAILED), flowComponent.trid()); return getErrorResponse(Result.create(Code.COMMAND_FAILED), flowComponent.trid());
} }
} }

View file

@ -20,7 +20,7 @@ import static java.nio.charset.StandardCharsets.UTF_8;
import static javax.servlet.http.HttpServletResponse.SC_BAD_REQUEST; import static javax.servlet.http.HttpServletResponse.SC_BAD_REQUEST;
import static javax.servlet.http.HttpServletResponse.SC_OK; import static javax.servlet.http.HttpServletResponse.SC_OK;
import com.google.common.logging.FormattingLogger; import com.google.common.flogger.FluentLogger;
import com.google.common.net.MediaType; import com.google.common.net.MediaType;
import google.registry.model.eppoutput.EppOutput; import google.registry.model.eppoutput.EppOutput;
import google.registry.request.Response; import google.registry.request.Response;
@ -32,7 +32,7 @@ public class EppRequestHandler {
private static final MediaType APPLICATION_EPP_XML = private static final MediaType APPLICATION_EPP_XML =
MediaType.create("application", "epp+xml").withCharset(UTF_8); MediaType.create("application", "epp+xml").withCharset(UTF_8);
private static final FormattingLogger logger = FormattingLogger.getLoggerForCallerClass(); private static final FluentLogger logger = FluentLogger.forEnclosingClass();
@Inject EppController eppController; @Inject EppController eppController;
@Inject Response response; @Inject Response response;
@ -71,7 +71,7 @@ public class EppRequestHandler {
response.setHeader("Epp-Session", "close"); response.setHeader("Epp-Session", "close");
} }
} catch (Exception e) { } catch (Exception e) {
logger.warning(e, "handleEppCommand general exception"); logger.atWarning().withCause(e).log("handleEppCommand general exception");
response.setStatus(SC_BAD_REQUEST); response.setStatus(SC_BAD_REQUEST);
} }
} }

View file

@ -14,7 +14,7 @@
package google.registry.flows; package google.registry.flows;
import com.google.common.logging.FormattingLogger; import com.google.common.flogger.FluentLogger;
import google.registry.request.Action; import google.registry.request.Action;
import google.registry.request.Action.Method; import google.registry.request.Action.Method;
import google.registry.request.Payload; import google.registry.request.Payload;
@ -33,7 +33,7 @@ import javax.servlet.http.HttpSession;
) )
public class EppTlsAction implements Runnable { public class EppTlsAction implements Runnable {
private static final FormattingLogger logger = FormattingLogger.getLoggerForCallerClass(); private static final FluentLogger logger = FluentLogger.forEnclosingClass();
@Inject @Payload byte[] inputXmlBytes; @Inject @Payload byte[] inputXmlBytes;
@Inject TlsCredentials tlsCredentials; @Inject TlsCredentials tlsCredentials;
@ -46,7 +46,7 @@ public class EppTlsAction implements Runnable {
// Check that SNI header is present. This is a signal that we're receiving traffic proxied by a // Check that SNI header is present. This is a signal that we're receiving traffic proxied by a
// GFE, which is the expectation of this servlet. The value is unused. // GFE, which is the expectation of this servlet. The value is unused.
if (!tlsCredentials.hasSni()) { if (!tlsCredentials.hasSni()) {
logger.warning("Request did not include required SNI header."); logger.atWarning().log("Request did not include required SNI header.");
} }
eppRequestHandler.executeEpp( eppRequestHandler.executeEpp(
new HttpSessionMetadata(session), new HttpSessionMetadata(session),

View file

@ -22,7 +22,7 @@ import static java.nio.charset.StandardCharsets.UTF_8;
import com.google.common.annotations.VisibleForTesting; import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Throwables; import com.google.common.base.Throwables;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.logging.FormattingLogger; import com.google.common.flogger.FluentLogger;
import google.registry.flows.EppException.ParameterValueRangeErrorException; import google.registry.flows.EppException.ParameterValueRangeErrorException;
import google.registry.flows.EppException.ParameterValueSyntaxErrorException; import google.registry.flows.EppException.ParameterValueSyntaxErrorException;
import google.registry.flows.EppException.SyntaxErrorException; import google.registry.flows.EppException.SyntaxErrorException;
@ -44,7 +44,7 @@ import java.util.List;
/** {@link XmlTransformer} for marshalling to and from the Epp model classes. */ /** {@link XmlTransformer} for marshalling to and from the Epp model classes. */
public class EppXmlTransformer { public class EppXmlTransformer {
private static final FormattingLogger logger = FormattingLogger.getLoggerForCallerClass(); private static final FluentLogger logger = FluentLogger.forEnclosingClass();
// Hardcoded XML schemas, ordered with respect to dependency. // Hardcoded XML schemas, ordered with respect to dependency.
private static final ImmutableList<String> SCHEMAS = ImmutableList.of( private static final ImmutableList<String> SCHEMAS = ImmutableList.of(
@ -130,8 +130,8 @@ public class EppXmlTransformer {
try { try {
byte[] lenient = EppXmlTransformer.marshal(eppOutput, LENIENT); byte[] lenient = EppXmlTransformer.marshal(eppOutput, LENIENT);
// Marshaling worked even though the results didn't validate against the schema. // Marshaling worked even though the results didn't validate against the schema.
logger.severefmt( logger.atSevere().withCause(e).log(
e, "Result marshaled but did not validate: %s", new String(lenient, UTF_8)); "Result marshaled but did not validate: %s", new String(lenient, UTF_8));
return lenient; return lenient;
} catch (XmlException e2) { } catch (XmlException e2) {
throw new RuntimeException(e2); // Failing to marshal at all is not recoverable. throw new RuntimeException(e2); // Failing to marshal at all is not recoverable.

View file

@ -22,7 +22,7 @@ import static google.registry.model.eppcommon.ProtocolDefinition.ServiceExtensio
import com.google.common.base.Joiner; import com.google.common.base.Joiner;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.google.common.logging.FormattingLogger; import com.google.common.flogger.FluentLogger;
import google.registry.flows.EppException.CommandUseErrorException; import google.registry.flows.EppException.CommandUseErrorException;
import google.registry.flows.EppException.SyntaxErrorException; import google.registry.flows.EppException.SyntaxErrorException;
import google.registry.flows.EppException.UnimplementedExtensionException; import google.registry.flows.EppException.UnimplementedExtensionException;
@ -45,7 +45,7 @@ import javax.inject.Inject;
*/ */
public final class ExtensionManager { public final class ExtensionManager {
private static final FormattingLogger logger = FormattingLogger.getLoggerForCallerClass(); private static final FluentLogger logger = FluentLogger.forEnclosingClass();
/** Blacklist of extension URIs that cause an error if they are used without being declared. */ /** Blacklist of extension URIs that cause an error if they are used without being declared. */
private static final ImmutableSet<String> UNDECLARED_URIS_BLACKLIST = FEE_EXTENSION_URIS; private static final ImmutableSet<String> UNDECLARED_URIS_BLACKLIST = FEE_EXTENSION_URIS;
@ -99,11 +99,9 @@ public final class ExtensionManager {
if (!undeclaredUrisThatError.isEmpty()) { if (!undeclaredUrisThatError.isEmpty()) {
throw new UndeclaredServiceExtensionException(undeclaredUrisThatError); throw new UndeclaredServiceExtensionException(undeclaredUrisThatError);
} }
logger.infofmt( logger.atInfo().log(
"Client %s is attempting to run %s without declaring URIs %s on login", "Client %s is attempting to run %s without declaring URIs %s on login",
clientId, clientId, flowClass.getSimpleName(), undeclaredUris);
flowClass.getSimpleName(),
undeclaredUris);
} }
private void checkForRestrictedExtensions( private void checkForRestrictedExtensions(
@ -155,7 +153,7 @@ public final class ExtensionManager {
ImmutableSet<Class<? extends CommandExtension>> unimplementedExtensions = ImmutableSet<Class<? extends CommandExtension>> unimplementedExtensions =
unimplementedExtensionsBuilder.build(); unimplementedExtensionsBuilder.build();
if (!unimplementedExtensions.isEmpty()) { if (!unimplementedExtensions.isEmpty()) {
logger.infofmt("Unimplemented extensions: %s", unimplementedExtensions); logger.atInfo().log("Unimplemented extensions: %s", unimplementedExtensions);
throw new UnimplementedExtensionException(); throw new UnimplementedExtensionException();
} }
} }

View file

@ -24,14 +24,13 @@ import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Streams; import com.google.common.collect.Streams;
import com.google.common.logging.FormattingLogger; import com.google.common.flogger.FluentLogger;
import google.registry.flows.FlowModule.ClientId; import google.registry.flows.FlowModule.ClientId;
import google.registry.flows.FlowModule.InputXml; import google.registry.flows.FlowModule.InputXml;
import google.registry.flows.annotations.ReportingSpec; import google.registry.flows.annotations.ReportingSpec;
import google.registry.model.eppcommon.Trid; import google.registry.model.eppcommon.Trid;
import google.registry.model.eppinput.EppInput; import google.registry.model.eppinput.EppInput;
import java.util.Optional; import java.util.Optional;
import java.util.logging.Level;
import javax.inject.Inject; import javax.inject.Inject;
import org.json.simple.JSONValue; import org.json.simple.JSONValue;
@ -52,7 +51,7 @@ public class FlowReporter {
*/ */
private static final String METADATA_LOG_SIGNATURE = "FLOW-LOG-SIGNATURE-METADATA"; private static final String METADATA_LOG_SIGNATURE = "FLOW-LOG-SIGNATURE-METADATA";
private static final FormattingLogger logger = FormattingLogger.getLoggerForCallerClass(); private static final FluentLogger logger = FluentLogger.forEnclosingClass();
@Inject Trid trid; @Inject Trid trid;
@Inject @ClientId String clientId; @Inject @ClientId String clientId;
@ -65,44 +64,38 @@ public class FlowReporter {
public void recordToLogs() { public void recordToLogs() {
// WARNING: These log statements are parsed by reporting pipelines - be careful when changing. // WARNING: These log statements are parsed by reporting pipelines - be careful when changing.
// It should be safe to add new keys, but be very cautious in changing existing keys. // It should be safe to add new keys, but be very cautious in changing existing keys.
if (logger.isLoggable(Level.INFO)) { logger.atInfo().log(
logger.infofmt( "%s: %s",
"%s: %s", EPPINPUT_LOG_SIGNATURE,
EPPINPUT_LOG_SIGNATURE, JSONValue.toJSONString(
JSONValue.toJSONString( ImmutableMap.<String, Object>of(
ImmutableMap.<String, Object>of( "xml", prettyPrint(inputXmlBytes),
"xml", prettyPrint(inputXmlBytes), "xmlBytes", base64().encode(inputXmlBytes))));
"xmlBytes", base64().encode(inputXmlBytes))));
}
// Explicitly log flow metadata separately from the EPP XML itself so that it stays compact // Explicitly log flow metadata separately from the EPP XML itself so that it stays compact
// enough to be sure to fit in a single log entry (the XML part in rare cases could be long // enough to be sure to fit in a single log entry (the XML part in rare cases could be long
// enough to overflow into multiple log entries, breaking routine parsing of the JSON format). // enough to overflow into multiple log entries, breaking routine parsing of the JSON format).
String singleTargetId = eppInput.getSingleTargetId().orElse(""); String singleTargetId = eppInput.getSingleTargetId().orElse("");
ImmutableList<String> targetIds = eppInput.getTargetIds(); ImmutableList<String> targetIds = eppInput.getTargetIds();
if (logger.isLoggable(Level.INFO)) { logger.atInfo().log(
logger.infofmt( "%s: %s",
"%s: %s", METADATA_LOG_SIGNATURE,
METADATA_LOG_SIGNATURE, JSONValue.toJSONString(
JSONValue.toJSONString( new ImmutableMap.Builder<String, Object>()
new ImmutableMap.Builder<String, Object>() .put("serverTrid", trid.getServerTransactionId())
.put("serverTrid", trid.getServerTransactionId()) .put("clientId", clientId)
.put("clientId", clientId) .put("commandType", eppInput.getCommandType())
.put("commandType", eppInput.getCommandType()) .put("resourceType", eppInput.getResourceType().orElse(""))
.put("resourceType", eppInput.getResourceType().orElse("")) .put("flowClassName", flowClass.getSimpleName())
.put("flowClassName", flowClass.getSimpleName()) .put("targetId", singleTargetId)
.put("targetId", singleTargetId) .put("targetIds", targetIds)
.put("targetIds", targetIds) .put(
.put( "tld",
"tld", eppInput.isDomainResourceType() ? extractTld(singleTargetId).orElse("") : "")
eppInput.isDomainResourceType() ? extractTld(singleTargetId).orElse("") : "") .put(
.put( "tlds",
"tlds", eppInput.isDomainResourceType() ? extractTlds(targetIds).asList() : EMPTY_LIST)
eppInput.isDomainResourceType() .put("icannActivityReportField", extractActivityReportField(flowClass))
? extractTlds(targetIds).asList() .build()));
: EMPTY_LIST)
.put("icannActivityReportField", extractActivityReportField(flowClass))
.build()));
}
} }
/** /**

View file

@ -18,7 +18,7 @@ import static google.registry.model.ofy.ObjectifyService.ofy;
import static google.registry.xml.XmlTransformer.prettyPrint; import static google.registry.xml.XmlTransformer.prettyPrint;
import com.google.common.base.Strings; import com.google.common.base.Strings;
import com.google.common.logging.FormattingLogger; import com.google.common.flogger.FluentLogger;
import google.registry.flows.FlowModule.ClientId; import google.registry.flows.FlowModule.ClientId;
import google.registry.flows.FlowModule.DryRun; import google.registry.flows.FlowModule.DryRun;
import google.registry.flows.FlowModule.InputXml; import google.registry.flows.FlowModule.InputXml;
@ -28,7 +28,6 @@ import google.registry.flows.session.LoginFlow;
import google.registry.model.eppcommon.Trid; import google.registry.model.eppcommon.Trid;
import google.registry.model.eppoutput.EppOutput; import google.registry.model.eppoutput.EppOutput;
import google.registry.monitoring.whitebox.EppMetric; import google.registry.monitoring.whitebox.EppMetric;
import java.util.logging.Level;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Provider; import javax.inject.Provider;
@ -37,7 +36,7 @@ public class FlowRunner {
private static final String COMMAND_LOG_FORMAT = "EPP Command" + Strings.repeat("\n\t%s", 8); private static final String COMMAND_LOG_FORMAT = "EPP Command" + Strings.repeat("\n\t%s", 8);
private static final FormattingLogger logger = FormattingLogger.getLoggerForCallerClass(); private static final FluentLogger logger = FluentLogger.forEnclosingClass();
@Inject @ClientId String clientId; @Inject @ClientId String clientId;
@Inject TransportCredentials credentials; @Inject TransportCredentials credentials;
@ -57,18 +56,16 @@ public class FlowRunner {
public EppOutput run(final EppMetric.Builder eppMetricBuilder) throws EppException { public EppOutput run(final EppMetric.Builder eppMetricBuilder) throws EppException {
String prettyXml = prettyPrint(inputXmlBytes); String prettyXml = prettyPrint(inputXmlBytes);
if (logger.isLoggable(Level.INFO)) { logger.atInfo().log(
logger.infofmt( COMMAND_LOG_FORMAT,
COMMAND_LOG_FORMAT, trid.getServerTransactionId(),
trid.getServerTransactionId(), clientId,
clientId, sessionMetadata,
sessionMetadata, prettyXml.replace("\n", "\n\t"),
prettyXml.replace("\n", "\n\t"), credentials,
credentials, eppRequestSource,
eppRequestSource, isDryRun ? "DRY_RUN" : "LIVE",
isDryRun ? "DRY_RUN" : "LIVE", isSuperuser ? "SUPERUSER" : "NORMAL");
isSuperuser ? "SUPERUSER" : "NORMAL");
}
// Record flow info to the GAE request logs for reporting purposes if it's not a dry run. // Record flow info to the GAE request logs for reporting purposes if it's not a dry run.
if (!isDryRun) { if (!isDryRun) {
flowReporter.recordToLogs(); flowReporter.recordToLogs();

View file

@ -21,7 +21,7 @@ import static google.registry.request.RequestParameters.extractRequiredHeader;
import com.google.common.annotations.VisibleForTesting; import com.google.common.annotations.VisibleForTesting;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.logging.FormattingLogger; import com.google.common.flogger.FluentLogger;
import com.google.common.net.HostAndPort; import com.google.common.net.HostAndPort;
import com.google.common.net.InetAddresses; import com.google.common.net.InetAddresses;
import dagger.Module; import dagger.Module;
@ -55,7 +55,7 @@ import javax.servlet.http.HttpServletRequest;
*/ */
public class TlsCredentials implements TransportCredentials { public class TlsCredentials implements TransportCredentials {
private static final FormattingLogger logger = FormattingLogger.getLoggerForCallerClass(); private static final FluentLogger logger = FluentLogger.forEnclosingClass();
private final String clientCertificateHash; private final String clientCertificateHash;
private final String sni; private final String sni;
@ -100,7 +100,7 @@ public class TlsCredentials implements TransportCredentials {
private void validateIp(Registrar registrar) throws AuthenticationErrorException { private void validateIp(Registrar registrar) throws AuthenticationErrorException {
ImmutableList<CidrAddressBlock> ipWhitelist = registrar.getIpAddressWhitelist(); ImmutableList<CidrAddressBlock> ipWhitelist = registrar.getIpAddressWhitelist();
if (ipWhitelist.isEmpty()) { if (ipWhitelist.isEmpty()) {
logger.infofmt( logger.atInfo().log(
"Skipping IP whitelist check because %s doesn't have an IP whitelist", "Skipping IP whitelist check because %s doesn't have an IP whitelist",
registrar.getClientId()); registrar.getClientId());
return; return;
@ -111,7 +111,7 @@ public class TlsCredentials implements TransportCredentials {
return; return;
} }
} }
logger.infofmt( logger.atInfo().log(
"Authentication error: IP address %s is not whitelisted for registrar %s; whitelist is: %s", "Authentication error: IP address %s is not whitelisted for registrar %s; whitelist is: %s",
clientInetAddr, registrar.getClientId(), ipWhitelist); clientInetAddr, registrar.getClientId(), ipWhitelist);
throw new BadRegistrarIpAddressException(); throw new BadRegistrarIpAddressException();
@ -127,7 +127,7 @@ public class TlsCredentials implements TransportCredentials {
private void validateCertificate(Registrar registrar) throws AuthenticationErrorException { private void validateCertificate(Registrar registrar) throws AuthenticationErrorException {
if (isNullOrEmpty(registrar.getClientCertificateHash()) if (isNullOrEmpty(registrar.getClientCertificateHash())
&& isNullOrEmpty(registrar.getFailoverClientCertificateHash())) { && isNullOrEmpty(registrar.getFailoverClientCertificateHash())) {
logger.infofmt( logger.atInfo().log(
"Skipping SSL certificate check because %s doesn't have any certificate hashes on file", "Skipping SSL certificate check because %s doesn't have any certificate hashes on file",
registrar.getClientId()); registrar.getClientId());
return; return;
@ -138,12 +138,12 @@ public class TlsCredentials implements TransportCredentials {
if (!hasSni()) { if (!hasSni()) {
throw new NoSniException(); throw new NoSniException();
} }
logger.info("Request did not include X-SSL-Certificate"); logger.atInfo().log("Request did not include X-SSL-Certificate");
throw new MissingRegistrarCertificateException(); throw new MissingRegistrarCertificateException();
} }
if (!clientCertificateHash.equals(registrar.getClientCertificateHash()) if (!clientCertificateHash.equals(registrar.getClientCertificateHash())
&& !clientCertificateHash.equals(registrar.getFailoverClientCertificateHash())) { && !clientCertificateHash.equals(registrar.getFailoverClientCertificateHash())) {
logger.warningfmt( logger.atWarning().log(
"bad certificate hash (%s) for %s, wanted either %s or %s", "bad certificate hash (%s) for %s, wanted either %s or %s",
clientCertificateHash, clientCertificateHash,
registrar.getClientId(), registrar.getClientId(),

View file

@ -19,7 +19,7 @@ import com.google.appengine.api.taskqueue.TaskOptions;
import com.google.appengine.api.taskqueue.TaskOptions.Method; import com.google.appengine.api.taskqueue.TaskOptions.Method;
import com.google.appengine.api.taskqueue.TransientFailureException; import com.google.appengine.api.taskqueue.TransientFailureException;
import com.google.common.annotations.VisibleForTesting; import com.google.common.annotations.VisibleForTesting;
import com.google.common.logging.FormattingLogger; import com.google.common.flogger.FluentLogger;
import com.googlecode.objectify.Key; import com.googlecode.objectify.Key;
import google.registry.config.RegistryConfig.Config; import google.registry.config.RegistryConfig.Config;
import google.registry.model.EppResource; import google.registry.model.EppResource;
@ -47,7 +47,7 @@ public final class AsyncFlowEnqueuer {
public static final String QUEUE_ASYNC_DELETE = "async-delete-pull"; public static final String QUEUE_ASYNC_DELETE = "async-delete-pull";
public static final String QUEUE_ASYNC_HOST_RENAME = "async-host-rename-pull"; public static final String QUEUE_ASYNC_HOST_RENAME = "async-host-rename-pull";
private static final FormattingLogger logger = FormattingLogger.getLoggerForCallerClass(); private static final FluentLogger logger = FluentLogger.forEnclosingClass();
private final Duration asyncDeleteDelay; private final Duration asyncDeleteDelay;
private final Queue asyncDeletePullQueue; private final Queue asyncDeletePullQueue;
@ -75,7 +75,7 @@ public final class AsyncFlowEnqueuer {
Trid trid, Trid trid,
boolean isSuperuser) { boolean isSuperuser) {
Key<EppResource> resourceKey = Key.create(resourceToDelete); Key<EppResource> resourceKey = Key.create(resourceToDelete);
logger.infofmt( logger.atInfo().log(
"Enqueuing async deletion of %s on behalf of registrar %s.", "Enqueuing async deletion of %s on behalf of registrar %s.",
resourceKey, requestingClientId); resourceKey, requestingClientId);
TaskOptions task = TaskOptions task =
@ -95,7 +95,7 @@ public final class AsyncFlowEnqueuer {
/** Enqueues a task to asynchronously refresh DNS for a renamed host. */ /** Enqueues a task to asynchronously refresh DNS for a renamed host. */
public void enqueueAsyncDnsRefresh(HostResource host, DateTime now) { public void enqueueAsyncDnsRefresh(HostResource host, DateTime now) {
Key<HostResource> hostKey = Key.create(host); Key<HostResource> hostKey = Key.create(host);
logger.infofmt("Enqueuing async DNS refresh for renamed host %s.", hostKey); logger.atInfo().log("Enqueuing async DNS refresh for renamed host %s.", hostKey);
addTaskToQueueWithRetry( addTaskToQueueWithRetry(
asyncDnsRefreshPullQueue, asyncDnsRefreshPullQueue,
TaskOptions.Builder.withMethod(Method.PULL) TaskOptions.Builder.withMethod(Method.PULL)

View file

@ -15,14 +15,13 @@
package google.registry.flows.async; package google.registry.flows.async;
import static com.google.appengine.api.taskqueue.QueueConstants.maxLeaseCount; import static com.google.appengine.api.taskqueue.QueueConstants.maxLeaseCount;
import static com.google.common.logging.FormattingLogger.getLoggerForCallerClass;
import static com.google.monitoring.metrics.EventMetric.DEFAULT_FITTER; import static com.google.monitoring.metrics.EventMetric.DEFAULT_FITTER;
import static google.registry.flows.async.AsyncFlowMetrics.OperationType.CONTACT_AND_HOST_DELETE; import static google.registry.flows.async.AsyncFlowMetrics.OperationType.CONTACT_AND_HOST_DELETE;
import static google.registry.flows.async.AsyncFlowMetrics.OperationType.DNS_REFRESH; import static google.registry.flows.async.AsyncFlowMetrics.OperationType.DNS_REFRESH;
import com.google.common.annotations.VisibleForTesting; import com.google.common.annotations.VisibleForTesting;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.google.common.logging.FormattingLogger; import com.google.common.flogger.FluentLogger;
import com.google.monitoring.metrics.DistributionFitter; import com.google.monitoring.metrics.DistributionFitter;
import com.google.monitoring.metrics.EventMetric; import com.google.monitoring.metrics.EventMetric;
import com.google.monitoring.metrics.FibonacciFitter; import com.google.monitoring.metrics.FibonacciFitter;
@ -42,7 +41,7 @@ import org.joda.time.Duration;
*/ */
public class AsyncFlowMetrics { public class AsyncFlowMetrics {
private static final FormattingLogger logger = getLoggerForCallerClass(); private static final FluentLogger logger = FluentLogger.forEnclosingClass();
private final Clock clock; private final Clock clock;
@ -153,7 +152,7 @@ public class AsyncFlowMetrics {
processingMillis, processingMillis,
operationType.getMetricLabelValue(), operationType.getMetricLabelValue(),
operationResult.getMetricLabelValue()); operationResult.getMetricLabelValue());
logger.infofmt( logger.atInfo().log(
"Asynchronous %s operation took %d ms to process, yielding result: %s.", "Asynchronous %s operation took %d ms to process, yielding result: %s.",
operationType.getMetricLabelValue(), operationType.getMetricLabelValue(),
processingMillis, processingMillis,

View file

@ -18,7 +18,7 @@ import static com.google.common.collect.Sets.difference;
import static google.registry.util.CollectionUtils.nullToEmpty; import static google.registry.util.CollectionUtils.nullToEmpty;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.google.common.logging.FormattingLogger; import com.google.common.flogger.FluentLogger;
import google.registry.flows.EppException; import google.registry.flows.EppException;
import google.registry.flows.EppException.AuthenticationErrorClosingConnectionException; import google.registry.flows.EppException.AuthenticationErrorClosingConnectionException;
import google.registry.flows.EppException.AuthenticationErrorException; import google.registry.flows.EppException.AuthenticationErrorException;
@ -67,7 +67,7 @@ import javax.inject.Inject;
*/ */
public class LoginFlow implements Flow { public class LoginFlow implements Flow {
private static final FormattingLogger logger = FormattingLogger.getLoggerForCallerClass(); private static final FluentLogger logger = FluentLogger.forEnclosingClass();
/** Maximum number of failed login attempts allowed per connection. */ /** Maximum number of failed login attempts allowed per connection. */
private static final int MAX_FAILED_LOGIN_ATTEMPTS_PER_CONNECTION = 3; private static final int MAX_FAILED_LOGIN_ATTEMPTS_PER_CONNECTION = 3;
@ -86,7 +86,7 @@ public class LoginFlow implements Flow {
try { try {
return runWithoutLogging(); return runWithoutLogging();
} catch (EppException e) { } catch (EppException e) {
logger.warning("Login failed: " + e.getMessage()); logger.atWarning().log("Login failed: %s", e.getMessage());
throw e; throw e;
} }
} }

View file

@ -8,7 +8,6 @@ java_library(
name = "gcs", name = "gcs",
srcs = glob(["*.java"]), srcs = glob(["*.java"]),
deps = [ deps = [
"//java/com/google/common/logging:formatting_logger",
"//java/google/registry/config", "//java/google/registry/config",
"@com_google_appengine_tools_appengine_gcs_client", "@com_google_appengine_tools_appengine_gcs_client",
"@com_google_code_findbugs_jsr305", "@com_google_code_findbugs_jsr305",

View file

@ -26,7 +26,7 @@ import com.google.appengine.tools.cloudstorage.ListResult;
import com.google.common.base.Splitter; import com.google.common.base.Splitter;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import com.google.common.logging.FormattingLogger; import com.google.common.flogger.FluentLogger;
import com.google.common.net.MediaType; import com.google.common.net.MediaType;
import google.registry.config.RegistryConfig.Config; import google.registry.config.RegistryConfig.Config;
import java.io.IOException; import java.io.IOException;
@ -40,7 +40,7 @@ import javax.inject.Inject;
/** Utilities for working with Google Cloud Storage. */ /** Utilities for working with Google Cloud Storage. */
public class GcsUtils { public class GcsUtils {
private static final FormattingLogger logger = FormattingLogger.getLoggerForCallerClass(); private static final FluentLogger logger = FluentLogger.forEnclosingClass();
private static final ImmutableMap<String, MediaType> EXTENSIONS = private static final ImmutableMap<String, MediaType> EXTENSIONS =
new ImmutableMap.Builder<String, MediaType>() new ImmutableMap.Builder<String, MediaType>()
@ -105,7 +105,7 @@ public class GcsUtils {
try { try {
metadata = gcsService.getMetadata(file); metadata = gcsService.getMetadata(file);
} catch (IOException e) { } catch (IOException e) {
logger.warning(e, "Failed to check if GCS file exists"); logger.atWarning().withCause(e).log("Failed to check if GCS file exists");
return false; return false;
} }
return metadata != null && metadata.getLength() > 0; return metadata != null && metadata.getLength() > 0;

View file

@ -8,7 +8,6 @@ java_library(
name = "groups", name = "groups",
srcs = glob(["*.java"]), srcs = glob(["*.java"]),
deps = [ deps = [
"//java/com/google/common/logging:formatting_logger",
"//java/google/registry/config", "//java/google/registry/config",
"//java/google/registry/util", "//java/google/registry/util",
"@com_google_api_client", "@com_google_api_client",
@ -16,6 +15,8 @@ java_library(
"@com_google_apis_google_api_services_groupssettings", "@com_google_apis_google_api_services_groupssettings",
"@com_google_code_findbugs_jsr305", "@com_google_code_findbugs_jsr305",
"@com_google_dagger", "@com_google_dagger",
"@com_google_flogger",
"@com_google_flogger_system_backend",
"@com_google_guava", "@com_google_guava",
"@javax_servlet_api", "@javax_servlet_api",
"@joda_time", "@joda_time",

View file

@ -29,7 +29,7 @@ import com.google.api.services.groupssettings.model.Groups;
import com.google.common.annotations.VisibleForTesting; import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Strings; import com.google.common.base.Strings;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.google.common.logging.FormattingLogger; import com.google.common.flogger.FluentLogger;
import google.registry.config.RegistryConfig.Config; import google.registry.config.RegistryConfig.Config;
import java.io.IOException; import java.io.IOException;
import java.util.Set; import java.util.Set;
@ -46,7 +46,7 @@ public class DirectoryGroupsConnection implements GroupsConnection {
private static final String MEMBER_NOT_FOUND_MSG = "Resource Not Found: memberKey"; private static final String MEMBER_NOT_FOUND_MSG = "Resource Not Found: memberKey";
private static final String MEMBER_ALREADY_EXISTS_MSG = "Member already exists."; private static final String MEMBER_ALREADY_EXISTS_MSG = "Member already exists.";
private static final FormattingLogger logger = FormattingLogger.getLoggerForCallerClass(); private static final FluentLogger logger = FluentLogger.forEnclosingClass();
private static final Groups defaultGroupPermissions = getDefaultGroupPermissions(); private static final Groups defaultGroupPermissions = getDefaultGroupPermissions();
@VisibleForTesting @VisibleForTesting
@ -80,11 +80,9 @@ public class DirectoryGroupsConnection implements GroupsConnection {
// return it. // return it.
GoogleJsonError err = e.getDetails(); GoogleJsonError err = e.getDetails();
if (err.getCode() == SC_NOT_FOUND && err.getMessage().equals(GROUP_NOT_FOUND_MSG)) { if (err.getCode() == SC_NOT_FOUND && err.getMessage().equals(GROUP_NOT_FOUND_MSG)) {
logger.infofmt( logger.atInfo().withCause(e).log(
e,
"Creating group %s during addition of member %s because the group doesn't exist.", "Creating group %s during addition of member %s because the group doesn't exist.",
groupKey, groupKey, email);
email);
createGroup(groupKey); createGroup(groupKey);
addMemberToGroup(groupKey, email, role); addMemberToGroup(groupKey, email, role);
} else if (err.getCode() == SC_NOT_FOUND && err.getMessage().equals(MEMBER_NOT_FOUND_MSG)) { } else if (err.getCode() == SC_NOT_FOUND && err.getMessage().equals(MEMBER_NOT_FOUND_MSG)) {
@ -98,12 +96,10 @@ public class DirectoryGroupsConnection implements GroupsConnection {
// but it is bouncing incoming emails. It won't show up in the members list API call, but // but it is bouncing incoming emails. It won't show up in the members list API call, but
// will throw a "Member already exists" error message if you attempt to add it again. The // will throw a "Member already exists" error message if you attempt to add it again. The
// correct thing to do is log an info message when this happens and then ignore it. // correct thing to do is log an info message when this happens and then ignore it.
logger.infofmt( logger.atInfo().withCause(e).log(
e,
"Could not add email %s to group %s because it is already a member " "Could not add email %s to group %s because it is already a member "
+ "(likely because the email address is bouncing incoming messages).", + "(likely because the email address is bouncing incoming messages).",
email, email, groupKey);
groupKey);
} else { } else {
throw e; throw e;
} }
@ -159,7 +155,8 @@ public class DirectoryGroupsConnection implements GroupsConnection {
// Ignore the error thrown if the group already exists. // Ignore the error thrown if the group already exists.
if (e.getDetails().getCode() == SC_CONFLICT if (e.getDetails().getCode() == SC_CONFLICT
&& e.getDetails().getMessage().equals("Entity already exists.")) { && e.getDetails().getMessage().equals("Entity already exists.")) {
logger.infofmt(e, "Could not create group %s because it already exists.", groupKey); logger.atInfo().withCause(e).log(
"Could not create group %s because it already exists.", groupKey);
return directory.groups().get(groupKey).execute(); return directory.groups().get(groupKey).execute();
} else { } else {
throw e; throw e;

View file

@ -9,7 +9,6 @@ java_library(
srcs = glob(["*.java"]), srcs = glob(["*.java"]),
resources = glob(["*.asc"]), resources = glob(["*.asc"]),
deps = [ deps = [
"//java/com/google/common/logging:formatting_logger",
"//java/google/registry/util", "//java/google/registry/util",
"@com_google_code_findbugs_jsr305", "@com_google_code_findbugs_jsr305",
"@com_google_dagger", "@com_google_dagger",

View file

@ -9,7 +9,6 @@ java_library(
srcs = glob(["*.java"]), srcs = glob(["*.java"]),
resources = glob(["templates/*.xml"]), resources = glob(["templates/*.xml"]),
deps = [ deps = [
"//java/com/google/common/logging:formatting_logger",
"//java/google/registry/config", "//java/google/registry/config",
"//java/google/registry/request", "//java/google/registry/request",
"//java/google/registry/request/auth", "//java/google/registry/request/auth",
@ -18,6 +17,8 @@ java_library(
"//third_party/objectify:objectify-v4_1", "//third_party/objectify:objectify-v4_1",
"@com_google_appengine_api_1_0_sdk", "@com_google_appengine_api_1_0_sdk",
"@com_google_dagger", "@com_google_dagger",
"@com_google_flogger",
"@com_google_flogger_system_backend",
"@com_google_guava", "@com_google_guava",
"@javax_servlet_api", "@javax_servlet_api",
"@joda_time", "@joda_time",

View file

@ -19,7 +19,6 @@ import static com.google.appengine.api.taskqueue.QueueFactory.getQueue;
import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.collect.ImmutableList.toImmutableList; import static com.google.common.collect.ImmutableList.toImmutableList;
import static com.google.common.collect.Lists.partition; import static com.google.common.collect.Lists.partition;
import static com.google.common.logging.FormattingLogger.getLoggerForCallerClass;
import static google.registry.security.XsrfTokenManager.X_CSRF_TOKEN; import static google.registry.security.XsrfTokenManager.X_CSRF_TOKEN;
import static google.registry.util.ResourceUtils.readResourceUtf8; import static google.registry.util.ResourceUtils.readResourceUtf8;
import static java.util.Arrays.asList; import static java.util.Arrays.asList;
@ -28,7 +27,7 @@ import static org.joda.time.DateTimeZone.UTC;
import com.google.appengine.api.taskqueue.TaskOptions; import com.google.appengine.api.taskqueue.TaskOptions;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.collect.Iterators; import com.google.common.collect.Iterators;
import com.google.common.logging.FormattingLogger; import com.google.common.flogger.FluentLogger;
import google.registry.config.RegistryEnvironment; import google.registry.config.RegistryEnvironment;
import google.registry.request.Action; import google.registry.request.Action;
import google.registry.request.Parameter; import google.registry.request.Parameter;
@ -60,7 +59,7 @@ import org.joda.time.DateTime;
) )
public class LoadTestAction implements Runnable { public class LoadTestAction implements Runnable {
private static final FormattingLogger logger = getLoggerForCallerClass(); private static final FluentLogger logger = FluentLogger.forEnclosingClass();
private static final int NUM_QUEUES = 10; private static final int NUM_QUEUES = 10;
private static final int ARBITRARY_VALID_HOST_LENGTH = 40; private static final int ARBITRARY_VALID_HOST_LENGTH = 40;
@ -257,7 +256,7 @@ public class LoadTestAction implements Runnable {
} }
ImmutableList<TaskOptions> taskOptions = tasks.build(); ImmutableList<TaskOptions> taskOptions = tasks.build();
enqueue(taskOptions); enqueue(taskOptions);
logger.infofmt("Added %d total load test tasks", taskOptions.size()); logger.atInfo().log("Added %d total load test tasks", taskOptions.size());
} }
private void validateAndLogRequest() { private void validateAndLogRequest() {
@ -276,7 +275,7 @@ public class LoadTestAction implements Runnable {
|| failedHostCreatesPerSecond > 0 || failedHostCreatesPerSecond > 0
|| hostInfosPerSecond > 0, || hostInfosPerSecond > 0,
"You must specify at least one of the 'operations per second' parameters."); "You must specify at least one of the 'operations per second' parameters.");
logger.infofmt( logger.atInfo().log(
"Running load test with the following params. clientId: %s, delaySeconds: %d, " "Running load test with the following params. clientId: %s, delaySeconds: %d, "
+ "runSeconds: %d, successful|failed domain creates/s: %d|%d, domain infos/s: %d, " + "runSeconds: %d, successful|failed domain creates/s: %d|%d, domain infos/s: %d, "
+ "domain checks/s: %d, successful|failed contact creates/s: %d|%d, " + "domain checks/s: %d, successful|failed contact creates/s: %d|%d, "

View file

@ -8,7 +8,6 @@ java_library(
name = "mapreduce", name = "mapreduce",
srcs = glob(["*.java"]), srcs = glob(["*.java"]),
deps = [ deps = [
"//java/com/google/common/logging:formatting_logger",
"//java/google/registry/mapreduce/inputs", "//java/google/registry/mapreduce/inputs",
"//java/google/registry/request", "//java/google/registry/request",
"//java/google/registry/util", "//java/google/registry/util",
@ -17,6 +16,8 @@ java_library(
"@com_google_appengine_tools_appengine_mapreduce", "@com_google_appengine_tools_appengine_mapreduce",
"@com_google_appengine_tools_appengine_pipeline", "@com_google_appengine_tools_appengine_pipeline",
"@com_google_dagger", "@com_google_dagger",
"@com_google_flogger",
"@com_google_flogger_system_backend",
"@com_google_guava", "@com_google_guava",
"@javax_servlet_api", "@javax_servlet_api",
"@joda_time", "@joda_time",

View file

@ -33,7 +33,7 @@ import com.google.appengine.tools.mapreduce.outputs.NoOutput;
import com.google.appengine.tools.pipeline.Job0; import com.google.appengine.tools.pipeline.Job0;
import com.google.appengine.tools.pipeline.JobSetting; import com.google.appengine.tools.pipeline.JobSetting;
import com.google.common.annotations.VisibleForTesting; import com.google.common.annotations.VisibleForTesting;
import com.google.common.logging.FormattingLogger; import com.google.common.flogger.FluentLogger;
import google.registry.mapreduce.inputs.ConcatenatingInput; import google.registry.mapreduce.inputs.ConcatenatingInput;
import google.registry.request.Parameter; import google.registry.request.Parameter;
import google.registry.util.PipelineUtils; import google.registry.util.PipelineUtils;
@ -50,7 +50,7 @@ import org.joda.time.Duration;
*/ */
public class MapreduceRunner { public class MapreduceRunner {
private static final FormattingLogger logger = FormattingLogger.getLoggerForCallerClass(); private static final FluentLogger logger = FluentLogger.forEnclosingClass();
public static final String PARAM_DRY_RUN = "dryRun"; public static final String PARAM_DRY_RUN = "dryRun";
public static final String PARAM_MAP_SHARDS = "mapShards"; public static final String PARAM_MAP_SHARDS = "mapShards";
@ -273,11 +273,9 @@ public class MapreduceRunner {
job, job,
new JobSetting.OnModule(moduleName), new JobSetting.OnModule(moduleName),
new JobSetting.OnQueue(QUEUE_NAME)); new JobSetting.OnQueue(QUEUE_NAME));
logger.infofmt( logger.atInfo().log(
"Started '%s' %s job: %s", "Started '%s' %s job: %s",
jobName, jobName, job instanceof MapJob ? "map" : "mapreduce", PipelineUtils.createJobPath(jobId));
job instanceof MapJob ? "map" : "mapreduce",
PipelineUtils.createJobPath(jobId));
return jobId; return jobId;
} }
} }

View file

@ -8,7 +8,6 @@ java_library(
name = "inputs", name = "inputs",
srcs = glob(["*.java"]), srcs = glob(["*.java"]),
deps = [ deps = [
"//java/com/google/common/logging:formatting_logger",
"//java/google/registry/model", "//java/google/registry/model",
"//java/google/registry/util", "//java/google/registry/util",
"//third_party/objectify:objectify-v4_1", "//third_party/objectify:objectify-v4_1",

View file

@ -21,7 +21,7 @@ import com.google.appengine.api.datastore.Cursor;
import com.google.appengine.api.datastore.DatastoreTimeoutException; import com.google.appengine.api.datastore.DatastoreTimeoutException;
import com.google.appengine.api.datastore.QueryResultIterator; import com.google.appengine.api.datastore.QueryResultIterator;
import com.google.appengine.tools.mapreduce.InputReader; import com.google.appengine.tools.mapreduce.InputReader;
import com.google.common.logging.FormattingLogger; import com.google.common.flogger.FluentLogger;
import com.googlecode.objectify.cmd.Query; import com.googlecode.objectify.cmd.Query;
import google.registry.util.Retrier; import google.registry.util.Retrier;
import google.registry.util.SystemSleeper; import google.registry.util.SystemSleeper;
@ -44,7 +44,7 @@ abstract class RetryingInputReader<I, T> extends InputReader<T> {
private static final long serialVersionUID = -4897677478541818899L; private static final long serialVersionUID = -4897677478541818899L;
private static final Retrier retrier = new Retrier(new SystemSleeper(), 5); private static final Retrier retrier = new Retrier(new SystemSleeper(), 5);
private static final FormattingLogger logger = FormattingLogger.getLoggerForCallerClass(); private static final FluentLogger logger = FluentLogger.forEnclosingClass();
@Nullable private Cursor cursor; @Nullable private Cursor cursor;
private int total; private int total;
@ -136,9 +136,9 @@ abstract class RetryingInputReader<I, T> extends InputReader<T> {
() -> queryIterator.next(), () -> queryIterator.next(),
(thrown, failures, maxAttempts) -> { (thrown, failures, maxAttempts) -> {
checkNotNull(cursor, "Can't retry because cursor is null. Giving up."); checkNotNull(cursor, "Can't retry because cursor is null. Giving up.");
logger.infofmt( logger.atInfo().withCause(thrown).log(
"Retriable failure while reading item %d/%d - attempt %d/%d: %s", "Retriable failure while reading item %d/%d - attempt %d/%d.",
loaded, total, failures, maxAttempts, thrown); loaded, total, failures, maxAttempts);
queryIterator = getQueryIterator(cursor); queryIterator = getQueryIterator(cursor);
}, },
DatastoreTimeoutException.class); DatastoreTimeoutException.class);
@ -146,8 +146,9 @@ abstract class RetryingInputReader<I, T> extends InputReader<T> {
// We expect NoSuchElementException to be thrown, and it isn't an error. Just rethrow. // We expect NoSuchElementException to be thrown, and it isn't an error. Just rethrow.
throw e; throw e;
} catch (Throwable e) { } catch (Throwable e) {
logger.warningfmt(e, "Got an unrecoverable failure while reading item %d/%d.", loaded, total); throw new RuntimeException(
throw e; String.format("Got an unrecoverable failure while reading item %d/%d.", loaded, total),
e);
} finally { } finally {
ofy().clearSessionCache(); ofy().clearSessionCache();
} }

View file

@ -13,7 +13,6 @@ java_library(
]), ]),
visibility = ["//visibility:public"], visibility = ["//visibility:public"],
deps = [ deps = [
"//java/com/google/common/logging:formatting_logger",
"//java/google/registry/config", "//java/google/registry/config",
"//java/google/registry/util", "//java/google/registry/util",
"//java/google/registry/xml", "//java/google/registry/xml",
@ -23,6 +22,8 @@ java_library(
"@com_google_auto_value", "@com_google_auto_value",
"@com_google_code_findbugs_jsr305", "@com_google_code_findbugs_jsr305",
"@com_google_dagger", "@com_google_dagger",
"@com_google_flogger",
"@com_google_flogger_system_backend",
"@com_google_guava", "@com_google_guava",
"@com_google_monitoring_client_metrics", "@com_google_monitoring_client_metrics",
"@com_google_re2j", "@com_google_re2j",

View file

@ -22,7 +22,7 @@ import static google.registry.util.DateTimeUtils.isBeforeOrAt;
import static google.registry.util.DateTimeUtils.latestOf; import static google.registry.util.DateTimeUtils.latestOf;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.logging.FormattingLogger; import com.google.common.flogger.FluentLogger;
import com.googlecode.objectify.Key; import com.googlecode.objectify.Key;
import com.googlecode.objectify.Result; import com.googlecode.objectify.Result;
import com.googlecode.objectify.cmd.Query; import com.googlecode.objectify.cmd.Query;
@ -53,7 +53,7 @@ import org.joda.time.Interval;
/** Utilities for working with {@link EppResource}. */ /** Utilities for working with {@link EppResource}. */
public final class EppResourceUtils { public final class EppResourceUtils {
private static final FormattingLogger logger = FormattingLogger.getLoggerForCallerClass(); private static final FluentLogger logger = FluentLogger.forEnclosingClass();
/** Returns the full domain repoId in the format HEX-TLD for the specified long id and tld. */ /** Returns the full domain repoId in the format HEX-TLD for the specified long id and tld. */
public static String createDomainRepoId(long repoId, String tld) { public static String createDomainRepoId(long repoId, String tld) {
@ -331,7 +331,7 @@ public final class EppResourceUtils {
final Key<T> resourceKey = Key.create(resource); final Key<T> resourceKey = Key.create(resource);
final Key<CommitLogManifest> revision = findMostRecentRevisionAtTime(resource, timestamp); final Key<CommitLogManifest> revision = findMostRecentRevisionAtTime(resource, timestamp);
if (revision == null) { if (revision == null) {
logger.severefmt("No revision found for %s, falling back to resource.", resourceKey); logger.atSevere().log("No revision found for %s, falling back to resource.", resourceKey);
return new ResultNow<>(resource); return new ResultNow<>(resource);
} }
final Result<CommitLogMutation> mutationResult = final Result<CommitLogMutation> mutationResult =
@ -341,7 +341,7 @@ public final class EppResourceUtils {
if (mutation != null) { if (mutation != null) {
return ofy().load().fromEntity(mutation.getEntity()); return ofy().load().fromEntity(mutation.getEntity());
} }
logger.severefmt( logger.atSevere().log(
"Couldn't load mutation for revision at %s for %s, falling back to resource." "Couldn't load mutation for revision at %s for %s, falling back to resource."
+ " Revision: %s", + " Revision: %s",
timestamp, resourceKey, revision); timestamp, resourceKey, revision);
@ -355,18 +355,20 @@ public final class EppResourceUtils {
final Key<T> resourceKey = Key.create(resource); final Key<T> resourceKey = Key.create(resource);
Entry<?, Key<CommitLogManifest>> revision = resource.getRevisions().floorEntry(timestamp); Entry<?, Key<CommitLogManifest>> revision = resource.getRevisions().floorEntry(timestamp);
if (revision != null) { if (revision != null) {
logger.infofmt("Found revision history at %s for %s: %s", timestamp, resourceKey, revision); logger.atInfo().log(
"Found revision history at %s for %s: %s", timestamp, resourceKey, revision);
return revision.getValue(); return revision.getValue();
} }
// Fall back to the earliest revision if we don't have one before the requested timestamp. // Fall back to the earliest revision if we don't have one before the requested timestamp.
revision = resource.getRevisions().firstEntry(); revision = resource.getRevisions().firstEntry();
if (revision != null) { if (revision != null) {
logger.severefmt("Found no revision history at %s for %s, using earliest revision: %s", logger.atSevere().log(
"Found no revision history at %s for %s, using earliest revision: %s",
timestamp, resourceKey, revision); timestamp, resourceKey, revision);
return revision.getValue(); return revision.getValue();
} }
// Ultimate fallback: There are no revisions whatsoever, so return null. // Ultimate fallback: There are no revisions whatsoever, so return null.
logger.severefmt("Found no revision history at all for %s", resourceKey); logger.atSevere().log("Found no revision history at all for %s", resourceKey);
return null; return null;
} }

View file

@ -28,7 +28,7 @@ import com.google.common.annotations.VisibleForTesting;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Streams; import com.google.common.collect.Streams;
import com.google.common.logging.FormattingLogger; import com.google.common.flogger.FluentLogger;
import com.googlecode.objectify.Key; import com.googlecode.objectify.Key;
import com.googlecode.objectify.Objectify; import com.googlecode.objectify.Objectify;
import com.googlecode.objectify.ObjectifyFactory; import com.googlecode.objectify.ObjectifyFactory;
@ -59,7 +59,7 @@ import org.joda.time.Duration;
*/ */
public class Ofy { public class Ofy {
private static final FormattingLogger logger = FormattingLogger.getLoggerForCallerClass(); private static final FluentLogger logger = FluentLogger.forEnclosingClass();
/** Default clock for transactions that don't provide one. */ /** Default clock for transactions that don't provide one. */
@NonFinalForTesting @NonFinalForTesting
@ -263,7 +263,8 @@ public class Ofy {
throw e; // Give up. throw e; // Give up.
} }
sleeper.sleepUninterruptibly(Duration.millis(sleepMillis)); sleeper.sleepUninterruptibly(Duration.millis(sleepMillis));
logger.infofmt(e, "Retrying %s, attempt %s", e.getClass().getSimpleName(), attempt); logger.atInfo().withCause(e).log(
"Retrying %s, attempt %d", e.getClass().getSimpleName(), attempt);
} }
} }
} }

View file

@ -21,7 +21,7 @@ import static google.registry.util.DateTimeUtils.isAtOrAfter;
import com.google.auto.value.AutoValue; import com.google.auto.value.AutoValue;
import com.google.common.annotations.VisibleForTesting; import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Strings; import com.google.common.base.Strings;
import com.google.common.logging.FormattingLogger; import com.google.common.flogger.FluentLogger;
import com.googlecode.objectify.VoidWork; import com.googlecode.objectify.VoidWork;
import com.googlecode.objectify.annotation.Entity; import com.googlecode.objectify.annotation.Entity;
import com.googlecode.objectify.annotation.Id; import com.googlecode.objectify.annotation.Id;
@ -48,7 +48,7 @@ import org.joda.time.Duration;
@NotBackedUp(reason = Reason.TRANSIENT) @NotBackedUp(reason = Reason.TRANSIENT)
public class Lock extends ImmutableObject { public class Lock extends ImmutableObject {
private static final FormattingLogger logger = FormattingLogger.getLoggerForCallerClass(); private static final FluentLogger logger = FluentLogger.forEnclosingClass();
/** Disposition of locking, for monitoring. */ /** Disposition of locking, for monitoring. */
enum LockState { IN_USE, FREE, TIMED_OUT, OWNER_DIED } enum LockState { IN_USE, FREE, TIMED_OUT, OWNER_DIED }
@ -133,28 +133,19 @@ public class Lock extends ImmutableObject {
DateTime now = acquireResult.transactionTime(); DateTime now = acquireResult.transactionTime();
switch (acquireResult.lockState()) { switch (acquireResult.lockState()) {
case IN_USE: case IN_USE:
logger.infofmt( logger.atInfo().log(
"Existing lock by request %s is still valid now %s (until %s) lock: %s", "Existing lock by request %s is still valid now %s (until %s) lock: %s",
lock.requestLogId, lock.requestLogId, now, lock.expirationTime, lock.lockId);
now,
lock.expirationTime,
lock.lockId);
break; break;
case TIMED_OUT: case TIMED_OUT:
logger.infofmt( logger.atInfo().log(
"Existing lock by request %s is timed out now %s (was valid until %s) lock: %s", "Existing lock by request %s is timed out now %s (was valid until %s) lock: %s",
lock.requestLogId, lock.requestLogId, now, lock.expirationTime, lock.lockId);
now,
lock.expirationTime,
lock.lockId);
break; break;
case OWNER_DIED: case OWNER_DIED:
logger.infofmt( logger.atInfo().log(
"Existing lock is valid now %s (until %s), but owner (%s) isn't running lock: %s", "Existing lock is valid now %s (until %s), but owner (%s) isn't running lock: %s",
now, now, lock.expirationTime, lock.requestLogId, lock.lockId);
lock.expirationTime,
lock.requestLogId,
lock.lockId);
break; break;
case FREE: case FREE:
// There was no existing lock // There was no existing lock
@ -162,15 +153,13 @@ public class Lock extends ImmutableObject {
} }
Lock newLock = acquireResult.newLock(); Lock newLock = acquireResult.newLock();
if (acquireResult.newLock() != null) { if (acquireResult.newLock() != null) {
logger.infofmt( logger.atInfo().log("acquire succeeded %s lock: %s", newLock, newLock.lockId);
"acquire succeeded %s lock: %s",
newLock,
newLock.lockId);
} }
} catch (Throwable e) { } catch (Throwable e) {
// We might get here if there is a NullPointerException for example, if AcquireResult wasn't // We might get here if there is a NullPointerException for example, if AcquireResult wasn't
// constructed correctly. Simply log it for debugging but continue as if nothing happened // constructed correctly. Simply log it for debugging but continue as if nothing happened
logger.warningfmt(e, "Error while logging AcquireResult %s. Continuing.", acquireResult); logger.atWarning().withCause(e).log(
"Error while logging AcquireResult %s. Continuing.", acquireResult);
} }
} }
@ -184,38 +173,38 @@ public class Lock extends ImmutableObject {
// It's important to use transactNew rather than transact, because a Lock can be used to control // It's important to use transactNew rather than transact, because a Lock can be used to control
// access to resources like GCS that can't be transactionally rolled back. Therefore, the lock // access to resources like GCS that can't be transactionally rolled back. Therefore, the lock
// must be definitively acquired before it is used, even when called inside another transaction. // must be definitively acquired before it is used, even when called inside another transaction.
AcquireResult acquireResult = ofy().transactNew(() -> { AcquireResult acquireResult =
DateTime now = ofy().getTransactionTime(); ofy()
.transactNew(
() -> {
DateTime now = ofy().getTransactionTime();
// Checking if an unexpired lock still exists - if so, the lock can't be acquired. // Checking if an unexpired lock still exists - if so, the lock can't be acquired.
Lock lock = ofy().load().type(Lock.class).id(lockId).now(); Lock lock = ofy().load().type(Lock.class).id(lockId).now();
if (lock != null) { if (lock != null) {
logger.infofmt( logger.atInfo().log(
"Loaded existing lock: %s for request: %s", lock.lockId, lock.requestLogId); "Loaded existing lock: %s for request: %s", lock.lockId, lock.requestLogId);
} }
LockState lockState; LockState lockState;
if (lock == null) { if (lock == null) {
lockState = LockState.FREE; lockState = LockState.FREE;
} else if (isAtOrAfter(now, lock.expirationTime)) { } else if (isAtOrAfter(now, lock.expirationTime)) {
lockState = LockState.TIMED_OUT; lockState = LockState.TIMED_OUT;
} else if (!requestStatusChecker.isRunning(lock.requestLogId)) { } else if (!requestStatusChecker.isRunning(lock.requestLogId)) {
lockState = LockState.OWNER_DIED; lockState = LockState.OWNER_DIED;
} else { } else {
lockState = LockState.IN_USE; lockState = LockState.IN_USE;
return AcquireResult.create(now, lock, null, lockState); return AcquireResult.create(now, lock, null, lockState);
} }
Lock newLock = create( Lock newLock =
resourceName, create(resourceName, tld, requestStatusChecker.getLogId(), now, leaseLength);
tld, // Locks are not parented under an EntityGroupRoot (so as to avoid write
requestStatusChecker.getLogId(), // contention) and
now, // don't need to be backed up.
leaseLength); ofy().saveWithoutBackup().entity(newLock);
// Locks are not parented under an EntityGroupRoot (so as to avoid write contention) and return AcquireResult.create(now, lock, newLock, lockState);
// don't need to be backed up. });
ofy().saveWithoutBackup().entity(newLock);
return AcquireResult.create(now, lock, newLock, lockState);
});
logAcquireResult(acquireResult); logAcquireResult(acquireResult);
lockMetrics.recordAcquire(resourceName, tld, acquireResult.lockState()); lockMetrics.recordAcquire(resourceName, tld, acquireResult.lockState());
@ -225,28 +214,33 @@ public class Lock extends ImmutableObject {
/** Release the lock. */ /** Release the lock. */
public void release() { public void release() {
// Just use the default clock because we aren't actually doing anything that will use the clock. // Just use the default clock because we aren't actually doing anything that will use the clock.
ofy().transact(new VoidWork() { ofy()
@Override .transact(
public void vrun() { new VoidWork() {
// To release a lock, check that no one else has already obtained it and if not delete it. @Override
// If the lock in Datastore was different then this lock is gone already; this can happen public void vrun() {
// if release() is called around the expiration time and the lock expires underneath us. // To release a lock, check that no one else has already obtained it and if not
Lock loadedLock = ofy().load().type(Lock.class).id(lockId).now(); // delete it. If the lock in Datastore was different then this lock is gone already;
if (Lock.this.equals(loadedLock)) { // this can happen if release() is called around the expiration time and the lock
// Use noBackupOfy() so that we don't create a commit log entry for deleting the lock. // expires underneath us.
logger.infofmt("Deleting lock: %s", lockId); Lock loadedLock = ofy().load().type(Lock.class).id(lockId).now();
ofy().deleteWithoutBackup().entity(Lock.this); if (Lock.this.equals(loadedLock)) {
lockMetrics.recordRelease( // Use noBackupOfy() so that we don't create a commit log entry for deleting the
resourceName, tld, new Duration(acquiredTime, ofy().getTransactionTime())); // lock.
} else { logger.atInfo().log("Deleting lock: %s", lockId);
logger.severefmt( ofy().deleteWithoutBackup().entity(Lock.this);
"The lock we acquired was transferred to someone else before we" lockMetrics.recordRelease(
+ " released it! Did action take longer than lease length?" resourceName, tld, new Duration(acquiredTime, ofy().getTransactionTime()));
+ " Our lock: %s, current lock: %s", } else {
Lock.this, logger.atSevere().log(
loadedLock); "The lock we acquired was transferred to someone else before we"
logger.infofmt("Not deleting lock: %s - someone else has it: %s", lockId, loadedLock); + " released it! Did action take longer than lease length?"
} + " Our lock: %s, current lock: %s",
}}); Lock.this, loadedLock);
logger.atInfo().log(
"Not deleting lock: %s - someone else has it: %s", lockId, loadedLock);
}
}
});
} }
} }

View file

@ -8,7 +8,6 @@ java_library(
name = "backend", name = "backend",
srcs = glob(["*.java"]), srcs = glob(["*.java"]),
deps = [ deps = [
"//java/com/google/common/logging:formatting_logger",
"//java/google/registry/backup", "//java/google/registry/backup",
"//java/google/registry/batch", "//java/google/registry/batch",
"//java/google/registry/bigquery", "//java/google/registry/bigquery",
@ -41,6 +40,8 @@ java_library(
"@com_google_appengine_api_1_0_sdk", "@com_google_appengine_api_1_0_sdk",
"@com_google_code_findbugs_jsr305", "@com_google_code_findbugs_jsr305",
"@com_google_dagger", "@com_google_dagger",
"@com_google_flogger",
"@com_google_flogger_system_backend",
"@com_google_guava", "@com_google_guava",
"@com_google_monitoring_client_metrics", "@com_google_monitoring_client_metrics",
"@javax_servlet_api", "@javax_servlet_api",

View file

@ -15,7 +15,7 @@
package google.registry.module.backend; package google.registry.module.backend;
import com.google.appengine.api.LifecycleManager; import com.google.appengine.api.LifecycleManager;
import com.google.common.logging.FormattingLogger; import com.google.common.flogger.FluentLogger;
import com.google.monitoring.metrics.MetricReporter; import com.google.monitoring.metrics.MetricReporter;
import dagger.Lazy; import dagger.Lazy;
import java.io.IOException; import java.io.IOException;
@ -33,7 +33,7 @@ public final class BackendServlet extends HttpServlet {
private static final BackendComponent component = DaggerBackendComponent.create(); private static final BackendComponent component = DaggerBackendComponent.create();
private static final BackendRequestHandler requestHandler = component.requestHandler(); private static final BackendRequestHandler requestHandler = component.requestHandler();
private static final Lazy<MetricReporter> metricReporter = component.metricReporter(); private static final Lazy<MetricReporter> metricReporter = component.metricReporter();
private static final FormattingLogger logger = FormattingLogger.getLoggerForCallerClass(); private static final FluentLogger logger = FluentLogger.forEnclosingClass();
@Override @Override
public void init() { public void init() {
@ -44,25 +44,26 @@ public final class BackendServlet extends HttpServlet {
// registered if metric reporter starts up correctly. // registered if metric reporter starts up correctly.
try { try {
metricReporter.get().startAsync().awaitRunning(10, TimeUnit.SECONDS); metricReporter.get().startAsync().awaitRunning(10, TimeUnit.SECONDS);
logger.info("Started up MetricReporter"); logger.atInfo().log("Started up MetricReporter");
LifecycleManager.getInstance() LifecycleManager.getInstance()
.setShutdownHook( .setShutdownHook(
() -> { () -> {
try { try {
metricReporter.get().stopAsync().awaitTerminated(10, TimeUnit.SECONDS); metricReporter.get().stopAsync().awaitTerminated(10, TimeUnit.SECONDS);
logger.info("Shut down MetricReporter"); logger.atInfo().log("Shut down MetricReporter");
} catch (TimeoutException timeoutException) { } catch (TimeoutException timeoutException) {
logger.severefmt("Failed to stop MetricReporter: %s", timeoutException); logger.atSevere().withCause(timeoutException).log(
"Failed to stop MetricReporter: %s", timeoutException);
} }
}); });
} catch (Exception e) { } catch (Exception e) {
logger.severefmt(e, "Failed to initialize MetricReporter."); logger.atSevere().withCause(e).log("Failed to initialize MetricReporter.");
} }
} }
@Override @Override
public void service(HttpServletRequest req, HttpServletResponse rsp) throws IOException { public void service(HttpServletRequest req, HttpServletResponse rsp) throws IOException {
logger.info("Received backend request"); logger.atInfo().log("Received backend request");
requestHandler.handleRequest(req, rsp); requestHandler.handleRequest(req, rsp);
} }
} }

View file

@ -8,7 +8,6 @@ java_library(
name = "frontend", name = "frontend",
srcs = glob(["*.java"]), srcs = glob(["*.java"]),
deps = [ deps = [
"//java/com/google/common/logging:formatting_logger",
"//java/google/registry/braintree", "//java/google/registry/braintree",
"//java/google/registry/config", "//java/google/registry/config",
"//java/google/registry/dns", "//java/google/registry/dns",

View file

@ -16,7 +16,6 @@ package google.registry.module.frontend;
import com.google.appengine.api.LifecycleManager; import com.google.appengine.api.LifecycleManager;
import com.google.common.flogger.FluentLogger; import com.google.common.flogger.FluentLogger;
import com.google.common.logging.FormattingLogger;
import com.google.monitoring.metrics.MetricReporter; import com.google.monitoring.metrics.MetricReporter;
import dagger.Lazy; import dagger.Lazy;
import java.io.IOException; import java.io.IOException;
@ -34,9 +33,7 @@ public final class FrontendServlet extends HttpServlet {
private static final FrontendComponent component = DaggerFrontendComponent.create(); private static final FrontendComponent component = DaggerFrontendComponent.create();
private static final FrontendRequestHandler requestHandler = component.requestHandler(); private static final FrontendRequestHandler requestHandler = component.requestHandler();
private static final Lazy<MetricReporter> metricReporter = component.metricReporter(); private static final Lazy<MetricReporter> metricReporter = component.metricReporter();
private static final FormattingLogger logger = FormattingLogger.getLoggerForCallerClass(); private static final FluentLogger logger = FluentLogger.forEnclosingClass();
// TODO(b/): Remove this static field.
private static final FluentLogger flogger = FluentLogger.forEnclosingClass();
@Override @Override
public void init() { public void init() {
@ -47,25 +44,25 @@ public final class FrontendServlet extends HttpServlet {
// registered if metric reporter starts up correctly. // registered if metric reporter starts up correctly.
try { try {
metricReporter.get().startAsync().awaitRunning(10, TimeUnit.SECONDS); metricReporter.get().startAsync().awaitRunning(10, TimeUnit.SECONDS);
logger.info("Started up MetricReporter"); logger.atInfo().log("Started up MetricReporter");
LifecycleManager.getInstance() LifecycleManager.getInstance()
.setShutdownHook( .setShutdownHook(
() -> { () -> {
try { try {
metricReporter.get().stopAsync().awaitTerminated(10, TimeUnit.SECONDS); metricReporter.get().stopAsync().awaitTerminated(10, TimeUnit.SECONDS);
logger.info("Shut down MetricReporter"); logger.atInfo().log("Shut down MetricReporter");
} catch (TimeoutException e) { } catch (TimeoutException e) {
logger.severe(e, "Failed to stop MetricReporter."); logger.atSevere().withCause(e).log("Failed to stop MetricReporter.");
} }
}); });
} catch (Exception e) { } catch (Exception e) {
logger.severe(e, "Failed to initialize MetricReporter."); logger.atSevere().withCause(e).log("Failed to initialize MetricReporter.");
} }
} }
@Override @Override
public void service(HttpServletRequest req, HttpServletResponse rsp) throws IOException { public void service(HttpServletRequest req, HttpServletResponse rsp) throws IOException {
flogger.atInfo().log("Received frontend request"); logger.atInfo().log("Received frontend request");
requestHandler.handleRequest(req, rsp); requestHandler.handleRequest(req, rsp);
} }
} }

View file

@ -8,7 +8,6 @@ java_library(
name = "pubapi", name = "pubapi",
srcs = glob(["*.java"]), srcs = glob(["*.java"]),
deps = [ deps = [
"//java/com/google/common/logging:formatting_logger",
"//java/google/registry/config", "//java/google/registry/config",
"//java/google/registry/dns", "//java/google/registry/dns",
"//java/google/registry/flows", "//java/google/registry/flows",
@ -24,6 +23,8 @@ java_library(
"@com_google_appengine_api_1_0_sdk", "@com_google_appengine_api_1_0_sdk",
"@com_google_code_findbugs_jsr305", "@com_google_code_findbugs_jsr305",
"@com_google_dagger", "@com_google_dagger",
"@com_google_flogger",
"@com_google_flogger_system_backend",
"@com_google_guava", "@com_google_guava",
"@com_google_monitoring_client_metrics", "@com_google_monitoring_client_metrics",
"@javax_servlet_api", "@javax_servlet_api",

View file

@ -15,7 +15,7 @@
package google.registry.module.pubapi; package google.registry.module.pubapi;
import com.google.appengine.api.LifecycleManager; import com.google.appengine.api.LifecycleManager;
import com.google.common.logging.FormattingLogger; import com.google.common.flogger.FluentLogger;
import com.google.monitoring.metrics.MetricReporter; import com.google.monitoring.metrics.MetricReporter;
import dagger.Lazy; import dagger.Lazy;
import java.io.IOException; import java.io.IOException;
@ -33,7 +33,7 @@ public final class PubApiServlet extends HttpServlet {
private static final PubApiComponent component = DaggerPubApiComponent.create(); private static final PubApiComponent component = DaggerPubApiComponent.create();
private static final PubApiRequestHandler requestHandler = component.requestHandler(); private static final PubApiRequestHandler requestHandler = component.requestHandler();
private static final Lazy<MetricReporter> metricReporter = component.metricReporter(); private static final Lazy<MetricReporter> metricReporter = component.metricReporter();
private static final FormattingLogger logger = FormattingLogger.getLoggerForCallerClass(); private static final FluentLogger logger = FluentLogger.forEnclosingClass();
@Override @Override
public void init() { public void init() {
@ -44,25 +44,25 @@ public final class PubApiServlet extends HttpServlet {
// registered if metric reporter starts up correctly. // registered if metric reporter starts up correctly.
try { try {
metricReporter.get().startAsync().awaitRunning(10, TimeUnit.SECONDS); metricReporter.get().startAsync().awaitRunning(10, TimeUnit.SECONDS);
logger.info("Started up MetricReporter"); logger.atInfo().log("Started up MetricReporter");
LifecycleManager.getInstance() LifecycleManager.getInstance()
.setShutdownHook( .setShutdownHook(
() -> { () -> {
try { try {
metricReporter.get().stopAsync().awaitTerminated(10, TimeUnit.SECONDS); metricReporter.get().stopAsync().awaitTerminated(10, TimeUnit.SECONDS);
logger.info("Shut down MetricReporter"); logger.atInfo().log("Shut down MetricReporter");
} catch (TimeoutException e) { } catch (TimeoutException e) {
logger.severe(e, "Failed to stop MetricReporter."); logger.atSevere().withCause(e).log("Failed to stop MetricReporter.");
} }
}); });
} catch (Exception e) { } catch (Exception e) {
logger.severe(e, "Failed to initialize MetricReporter."); logger.atSevere().withCause(e).log("Failed to initialize MetricReporter.");
} }
} }
@Override @Override
public void service(HttpServletRequest req, HttpServletResponse rsp) throws IOException { public void service(HttpServletRequest req, HttpServletResponse rsp) throws IOException {
logger.info("Received frontend request"); logger.atInfo().log("Received frontend request");
requestHandler.handleRequest(req, rsp); requestHandler.handleRequest(req, rsp);
} }
} }

View file

@ -8,7 +8,6 @@ java_library(
name = "tools", name = "tools",
srcs = glob(["*.java"]), srcs = glob(["*.java"]),
deps = [ deps = [
"//java/com/google/common/logging:formatting_logger",
"//java/google/registry/backup", "//java/google/registry/backup",
"//java/google/registry/config", "//java/google/registry/config",
"//java/google/registry/dns", "//java/google/registry/dns",
@ -29,6 +28,8 @@ java_library(
"@com_google_appengine_api_1_0_sdk", "@com_google_appengine_api_1_0_sdk",
"@com_google_code_findbugs_jsr305", "@com_google_code_findbugs_jsr305",
"@com_google_dagger", "@com_google_dagger",
"@com_google_flogger",
"@com_google_flogger_system_backend",
"@com_google_guava", "@com_google_guava",
"@javax_servlet_api", "@javax_servlet_api",
"@org_bouncycastle_bcpkix_jdk15on", "@org_bouncycastle_bcpkix_jdk15on",

View file

@ -14,7 +14,7 @@
package google.registry.module.tools; package google.registry.module.tools;
import com.google.common.logging.FormattingLogger; import com.google.common.flogger.FluentLogger;
import java.io.IOException; import java.io.IOException;
import java.security.Security; import java.security.Security;
import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServlet;
@ -27,7 +27,7 @@ public final class ToolsServlet extends HttpServlet {
private static final ToolsComponent component = DaggerToolsComponent.create(); private static final ToolsComponent component = DaggerToolsComponent.create();
private static final ToolsRequestHandler requestHandler = component.requestHandler(); private static final ToolsRequestHandler requestHandler = component.requestHandler();
private static final FormattingLogger logger = FormattingLogger.getLoggerForCallerClass(); private static final FluentLogger logger = FluentLogger.forEnclosingClass();
@Override @Override
public void init() { public void init() {
@ -36,7 +36,7 @@ public final class ToolsServlet extends HttpServlet {
@Override @Override
public void service(HttpServletRequest req, HttpServletResponse rsp) throws IOException { public void service(HttpServletRequest req, HttpServletResponse rsp) throws IOException {
logger.info("Received tools request"); logger.atInfo().log("Received tools request");
requestHandler.handleRequest(req, rsp); requestHandler.handleRequest(req, rsp);
} }
} }

View file

@ -8,7 +8,6 @@ java_library(
name = "whitebox", name = "whitebox",
srcs = glob(["*.java"]), srcs = glob(["*.java"]),
deps = [ deps = [
"//java/com/google/common/logging:formatting_logger",
"//java/google/registry/bigquery", "//java/google/registry/bigquery",
"//java/google/registry/config", "//java/google/registry/config",
"//java/google/registry/model", "//java/google/registry/model",
@ -23,6 +22,8 @@ java_library(
"@com_google_auto_value", "@com_google_auto_value",
"@com_google_code_findbugs_jsr305", "@com_google_code_findbugs_jsr305",
"@com_google_dagger", "@com_google_dagger",
"@com_google_flogger",
"@com_google_flogger_system_backend",
"@com_google_guava", "@com_google_guava",
"@com_google_http_client", "@com_google_http_client",
"@com_google_monitoring_client_metrics", "@com_google_monitoring_client_metrics",

View file

@ -21,7 +21,7 @@ import com.google.appengine.api.taskqueue.Queue;
import com.google.appengine.api.taskqueue.TaskOptions; import com.google.appengine.api.taskqueue.TaskOptions;
import com.google.appengine.api.taskqueue.TransientFailureException; import com.google.appengine.api.taskqueue.TransientFailureException;
import com.google.common.base.Supplier; import com.google.common.base.Supplier;
import com.google.common.logging.FormattingLogger; import com.google.common.flogger.FluentLogger;
import java.util.Map.Entry; import java.util.Map.Entry;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Named; import javax.inject.Named;
@ -34,7 +34,7 @@ import javax.inject.Named;
*/ */
public class BigQueryMetricsEnqueuer { public class BigQueryMetricsEnqueuer {
private static final FormattingLogger logger = FormattingLogger.getLoggerForCallerClass(); private static final FluentLogger logger = FluentLogger.forEnclosingClass();
public static final String QUEUE_BIGQUERY_STREAMING_METRICS = "bigquery-streaming-metrics"; public static final String QUEUE_BIGQUERY_STREAMING_METRICS = "bigquery-streaming-metrics";
@ -58,7 +58,8 @@ public class BigQueryMetricsEnqueuer {
queue.add(opts); queue.add(opts);
} catch (TransientFailureException e) { } catch (TransientFailureException e) {
// Log and swallow. We may drop some metrics here but this should be rare. // Log and swallow. We may drop some metrics here but this should be rare.
logger.info(e, "Transient error occurred while recording metric; metric dropped."); logger.atInfo().withCause(e).log(
"Transient error occurred while recording metric; metric dropped.");
} }
} }
} }

View file

@ -17,7 +17,6 @@ package google.registry.monitoring.whitebox;
import static com.google.common.base.Predicates.in; import static com.google.common.base.Predicates.in;
import static com.google.common.base.Predicates.not; import static com.google.common.base.Predicates.not;
import static com.google.common.collect.Multimaps.filterKeys; import static com.google.common.collect.Multimaps.filterKeys;
import static com.google.common.logging.FormattingLogger.getLoggerForCallerClass;
import static google.registry.request.Action.Method.POST; import static google.registry.request.Action.Method.POST;
import static java.util.stream.Collectors.joining; import static java.util.stream.Collectors.joining;
@ -28,7 +27,7 @@ import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableListMultimap; import com.google.common.collect.ImmutableListMultimap;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.google.common.logging.FormattingLogger; import com.google.common.flogger.FluentLogger;
import google.registry.bigquery.BigqueryFactory; import google.registry.bigquery.BigqueryFactory;
import google.registry.config.RegistryConfig.Config; import google.registry.config.RegistryConfig.Config;
import google.registry.request.Action; import google.registry.request.Action;
@ -48,7 +47,7 @@ import javax.inject.Inject;
public class MetricsExportAction implements Runnable { public class MetricsExportAction implements Runnable {
public static final String PATH = "/_dr/task/metrics"; public static final String PATH = "/_dr/task/metrics";
private static final FormattingLogger logger = getLoggerForCallerClass(); private static final FluentLogger logger = FluentLogger.forEnclosingClass();
private static final String DATASET_ID = "metrics"; private static final String DATASET_ID = "metrics";
private static final ImmutableSet<String> SPECIAL_PARAMS = ImmutableSet.of("tableId", "insertId"); private static final ImmutableSet<String> SPECIAL_PARAMS = ImmutableSet.of("tableId", "insertId");
@ -97,7 +96,7 @@ public class MetricsExportAction implements Runnable {
.collect(joining("\n"))); .collect(joining("\n")));
} }
} catch (Throwable e) { } catch (Throwable e) {
logger.warning(e, "Unknown error while exporting metrics to BigQuery."); logger.atWarning().withCause(e).log("Unknown error while exporting metrics to BigQuery.");
} }
} }
} }

View file

@ -8,7 +8,6 @@ java_library(
name = "rdap", name = "rdap",
srcs = glob(["*.java"]), srcs = glob(["*.java"]),
deps = [ deps = [
"//java/com/google/common/logging:formatting_logger",
"//java/google/registry/config", "//java/google/registry/config",
"//java/google/registry/flows", "//java/google/registry/flows",
"//java/google/registry/model", "//java/google/registry/model",
@ -20,6 +19,8 @@ java_library(
"@com_google_auto_value", "@com_google_auto_value",
"@com_google_code_findbugs_jsr305", "@com_google_code_findbugs_jsr305",
"@com_google_dagger", "@com_google_dagger",
"@com_google_flogger",
"@com_google_flogger_system_backend",
"@com_google_guava", "@com_google_guava",
"@com_google_http_client_jackson2", "@com_google_http_client_jackson2",
"@com_google_monitoring_client_metrics", "@com_google_monitoring_client_metrics",

View file

@ -27,7 +27,7 @@ import static javax.servlet.http.HttpServletResponse.SC_OK;
import com.google.api.client.json.jackson2.JacksonFactory; import com.google.api.client.json.jackson2.JacksonFactory;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import com.google.common.logging.FormattingLogger; import com.google.common.flogger.FluentLogger;
import com.google.common.net.MediaType; import com.google.common.net.MediaType;
import com.google.re2j.Pattern; import com.google.re2j.Pattern;
import com.googlecode.objectify.Key; import com.googlecode.objectify.Key;
@ -69,7 +69,7 @@ import org.json.simple.JSONValue;
*/ */
public abstract class RdapActionBase implements Runnable { public abstract class RdapActionBase implements Runnable {
private static final FormattingLogger logger = FormattingLogger.getLoggerForCallerClass(); private static final FluentLogger logger = FluentLogger.forEnclosingClass();
/** /**
* Pattern for checking LDH names, which must officially contains only alphanumeric plus dots and * Pattern for checking LDH names, which must officially contains only alphanumeric plus dots and
@ -160,7 +160,7 @@ public abstract class RdapActionBase implements Runnable {
setError(SC_BAD_REQUEST, "Bad Request", "Not a valid " + getHumanReadableObjectTypeName()); setError(SC_BAD_REQUEST, "Bad Request", "Not a valid " + getHumanReadableObjectTypeName());
} catch (RuntimeException e) { } catch (RuntimeException e) {
setError(SC_INTERNAL_SERVER_ERROR, "Internal Server Error", "An error was encountered"); setError(SC_INTERNAL_SERVER_ERROR, "Internal Server Error", "An error was encountered");
logger.severe(e, "Exception encountered while processing RDAP command"); logger.atSevere().withCause(e).log("Exception encountered while processing RDAP command");
} }
rdapMetrics.updateMetrics(metricInformationBuilder.build()); rdapMetrics.updateMetrics(metricInformationBuilder.build());
} }
@ -185,8 +185,8 @@ public abstract class RdapActionBase implements Runnable {
response.setPayload(new JacksonFactory().toPrettyString(rdapJson)); response.setPayload(new JacksonFactory().toPrettyString(rdapJson));
return; return;
} catch (IOException e) { } catch (IOException e) {
logger.warning( logger.atWarning().withCause(e).log(
e, "Unable to pretty-print RDAP JSON response; falling back to unformatted output."); "Unable to pretty-print RDAP JSON response; falling back to unformatted output.");
} }
} }
response.setPayload(JSONValue.toJSONString(rdapJson)); response.setPayload(JSONValue.toJSONString(rdapJson));

View file

@ -26,7 +26,7 @@ import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSortedSet; import com.google.common.collect.ImmutableSortedSet;
import com.google.common.collect.Iterables; import com.google.common.collect.Iterables;
import com.google.common.collect.Streams; import com.google.common.collect.Streams;
import com.google.common.logging.FormattingLogger; import com.google.common.flogger.FluentLogger;
import com.google.common.net.InetAddresses; import com.google.common.net.InetAddresses;
import com.google.common.primitives.Booleans; import com.google.common.primitives.Booleans;
import com.googlecode.objectify.Key; import com.googlecode.objectify.Key;
@ -79,7 +79,7 @@ public class RdapDomainSearchAction extends RdapSearchActionBase {
public static final int MAX_NAMESERVERS_IN_FIRST_STAGE = 300; public static final int MAX_NAMESERVERS_IN_FIRST_STAGE = 300;
private static final FormattingLogger logger = FormattingLogger.getLoggerForCallerClass(); private static final FluentLogger logger = FluentLogger.forEnclosingClass();
@Inject Clock clock; @Inject Clock clock;
@Inject @Parameter("name") Optional<String> nameParam; @Inject @Parameter("name") Optional<String> nameParam;
@ -399,7 +399,7 @@ public class RdapDomainSearchAction extends RdapSearchActionBase {
if (hostKey != null) { if (hostKey != null) {
builder.add(hostKey); builder.add(hostKey);
} else { } else {
logger.warning("Host key unexpectedly null"); logger.atWarning().log("Host key unexpectedly null");
} }
} }
} }

View file

@ -29,7 +29,7 @@ import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import com.google.common.collect.Ordering; import com.google.common.collect.Ordering;
import com.google.common.collect.Streams; import com.google.common.collect.Streams;
import com.google.common.logging.FormattingLogger; import com.google.common.flogger.FluentLogger;
import com.google.common.net.InetAddresses; import com.google.common.net.InetAddresses;
import com.googlecode.objectify.Key; import com.googlecode.objectify.Key;
import google.registry.config.RdapNoticeDescriptor; import google.registry.config.RdapNoticeDescriptor;
@ -83,7 +83,7 @@ public class RdapJsonFormatter {
@Inject @Config("rdapHelpMap") ImmutableMap<String, RdapNoticeDescriptor> rdapHelpMap; @Inject @Config("rdapHelpMap") ImmutableMap<String, RdapNoticeDescriptor> rdapHelpMap;
@Inject RdapJsonFormatter() {} @Inject RdapJsonFormatter() {}
private static final FormattingLogger logger = FormattingLogger.getLoggerForCallerClass(); private static final FluentLogger logger = FluentLogger.forEnclosingClass();
/** /**
* What type of data to generate. Summary data includes only information about the object itself, * What type of data to generate. Summary data includes only information about the object itself,
@ -304,8 +304,8 @@ public class RdapJsonFormatter {
try { try {
return RdapJsonFormatter.makeRdapJsonNotice(rdapHelpMap.get(pathSearchString), rdapLinkBase); return RdapJsonFormatter.makeRdapJsonNotice(rdapHelpMap.get(pathSearchString), rdapLinkBase);
} catch (Exception e) { } catch (Exception e) {
logger.warningfmt(e, "Error reading RDAP help file: %s", pathSearchString); throw new InternalServerErrorException(
throw new InternalServerErrorException("unable to read help for " + pathSearchString); String.format("Error reading RDAP help file: %s", pathSearchString), e);
} }
} }

View file

@ -8,7 +8,6 @@ java_library(
name = "rde", name = "rde",
srcs = glob(["*.java"]), srcs = glob(["*.java"]),
deps = [ deps = [
"//java/com/google/common/logging:formatting_logger",
"//java/google/registry/config", "//java/google/registry/config",
"//java/google/registry/gcs", "//java/google/registry/gcs",
"//java/google/registry/keyring/api", "//java/google/registry/keyring/api",

View file

@ -19,8 +19,8 @@ import static google.registry.request.Action.Method.POST;
import static java.nio.charset.StandardCharsets.UTF_8; import static java.nio.charset.StandardCharsets.UTF_8;
import com.google.appengine.tools.cloudstorage.GcsFilename; import com.google.appengine.tools.cloudstorage.GcsFilename;
import com.google.common.flogger.FluentLogger;
import com.google.common.io.ByteStreams; import com.google.common.io.ByteStreams;
import com.google.common.logging.FormattingLogger;
import google.registry.config.RegistryConfig.Config; import google.registry.config.RegistryConfig.Config;
import google.registry.gcs.GcsUtils; import google.registry.gcs.GcsUtils;
import google.registry.keyring.api.KeyModule.Key; import google.registry.keyring.api.KeyModule.Key;
@ -63,7 +63,7 @@ public final class BrdaCopyAction implements Runnable {
static final String PATH = "/_dr/task/brdaCopy"; static final String PATH = "/_dr/task/brdaCopy";
private static final FormattingLogger logger = FormattingLogger.getLoggerForCallerClass(); private static final FluentLogger logger = FluentLogger.forEnclosingClass();
@Inject GcsUtils gcsUtils; @Inject GcsUtils gcsUtils;
@Inject Ghostryde ghostryde; @Inject Ghostryde ghostryde;
@ -99,7 +99,7 @@ public final class BrdaCopyAction implements Runnable {
long xmlLength = readXmlLength(xmlLengthFilename); long xmlLength = readXmlLength(xmlLengthFilename);
logger.infofmt("Writing %s", rydeFile); logger.atInfo().log("Writing %s", rydeFile);
byte[] signature; byte[] signature;
try (InputStream gcsInput = gcsUtils.openInputStream(xmlFilename); try (InputStream gcsInput = gcsUtils.openInputStream(xmlFilename);
Ghostryde.Decryptor decryptor = ghostryde.openDecryptor(gcsInput, stagingDecryptionKey); Ghostryde.Decryptor decryptor = ghostryde.openDecryptor(gcsInput, stagingDecryptionKey);
@ -118,7 +118,7 @@ public final class BrdaCopyAction implements Runnable {
signature = signLayer.getSignature(); signature = signLayer.getSignature();
} }
logger.infofmt("Writing %s", sigFile); logger.atInfo().log("Writing %s", sigFile);
try (OutputStream gcsOutput = gcsUtils.openOutputStream(sigFile)) { try (OutputStream gcsOutput = gcsUtils.openOutputStream(sigFile)) {
gcsOutput.write(signature); gcsOutput.write(signature);
} }

View file

@ -15,13 +15,12 @@
package google.registry.rde; package google.registry.rde;
import static com.google.common.base.Preconditions.checkState; import static com.google.common.base.Preconditions.checkState;
import static com.google.common.logging.FormattingLogger.getLoggerForCallerClass;
import static google.registry.model.ofy.ObjectifyService.ofy; import static google.registry.model.ofy.ObjectifyService.ofy;
import com.google.common.base.Ascii; import com.google.common.base.Ascii;
import com.google.common.base.Strings; import com.google.common.base.Strings;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.google.common.logging.FormattingLogger; import com.google.common.flogger.FluentLogger;
import com.googlecode.objectify.Key; import com.googlecode.objectify.Key;
import google.registry.model.contact.ContactResource; import google.registry.model.contact.ContactResource;
import google.registry.model.domain.DesignatedContact; import google.registry.model.domain.DesignatedContact;
@ -51,7 +50,7 @@ import org.joda.time.DateTime;
/** Utility class that turns {@link DomainResource} as {@link XjcRdeDomainElement}. */ /** Utility class that turns {@link DomainResource} as {@link XjcRdeDomainElement}. */
final class DomainResourceToXjcConverter { final class DomainResourceToXjcConverter {
private static final FormattingLogger logger = getLoggerForCallerClass(); private static final FluentLogger logger = FluentLogger.forEnclosingClass();
/** Converts {@link DomainResource} to {@link XjcRdeDomainElement}. */ /** Converts {@link DomainResource} to {@link XjcRdeDomainElement}. */
static XjcRdeDomainElement convert(DomainResource domain, RdeMode mode) { static XjcRdeDomainElement convert(DomainResource domain, RdeMode mode) {
@ -172,7 +171,7 @@ final class DomainResourceToXjcConverter {
// as the holder of the domain name object. // as the holder of the domain name object.
Key<ContactResource> registrant = model.getRegistrant(); Key<ContactResource> registrant = model.getRegistrant();
if (registrant == null) { if (registrant == null) {
logger.warningfmt("Domain %s has no registrant contact.", domainName); logger.atWarning().log("Domain %s has no registrant contact.", domainName);
} else { } else {
ContactResource registrantContact = ofy().load().key(registrant).now(); ContactResource registrantContact = ofy().load().key(registrant).now();
checkState( checkState(

View file

@ -16,7 +16,7 @@ package google.registry.rde;
import static google.registry.model.ofy.ObjectifyService.ofy; import static google.registry.model.ofy.ObjectifyService.ofy;
import com.google.common.logging.FormattingLogger; import com.google.common.flogger.FluentLogger;
import google.registry.model.common.Cursor; import google.registry.model.common.Cursor;
import google.registry.model.common.Cursor.CursorType; import google.registry.model.common.Cursor.CursorType;
import google.registry.model.registry.Registry; import google.registry.model.registry.Registry;
@ -64,7 +64,7 @@ class EscrowTaskRunner {
void runWithLock(DateTime watermark) throws Exception; void runWithLock(DateTime watermark) throws Exception;
} }
private static final FormattingLogger logger = FormattingLogger.getLoggerForCallerClass(); private static final FluentLogger logger = FluentLogger.forEnclosingClass();
@Inject Clock clock; @Inject Clock clock;
@Inject LockHandler lockHandler; @Inject LockHandler lockHandler;
@ -87,14 +87,14 @@ class EscrowTaskRunner {
final Duration interval) { final Duration interval) {
Callable<Void> lockRunner = Callable<Void> lockRunner =
() -> { () -> {
logger.infofmt("TLD: %s", registry.getTld()); logger.atInfo().log("TLD: %s", registry.getTld());
DateTime startOfToday = clock.nowUtc().withTimeAtStartOfDay(); DateTime startOfToday = clock.nowUtc().withTimeAtStartOfDay();
Cursor cursor = ofy().load().key(Cursor.createKey(cursorType, registry)).now(); Cursor cursor = ofy().load().key(Cursor.createKey(cursorType, registry)).now();
final DateTime nextRequiredRun = (cursor == null ? startOfToday : cursor.getCursorTime()); final DateTime nextRequiredRun = (cursor == null ? startOfToday : cursor.getCursorTime());
if (nextRequiredRun.isAfter(startOfToday)) { if (nextRequiredRun.isAfter(startOfToday)) {
throw new NoContentException("Already completed"); throw new NoContentException("Already completed");
} }
logger.infofmt("Cursor: %s", nextRequiredRun); logger.atInfo().log("Cursor: %s", nextRequiredRun);
task.runWithLock(nextRequiredRun); task.runWithLock(nextRequiredRun);
ofy() ofy()
.transact( .transact(

View file

@ -23,8 +23,8 @@ import static org.bouncycastle.jce.provider.BouncyCastleProvider.PROVIDER_NAME;
import static org.bouncycastle.openpgp.PGPLiteralData.BINARY; import static org.bouncycastle.openpgp.PGPLiteralData.BINARY;
import static org.joda.time.DateTimeZone.UTC; import static org.joda.time.DateTimeZone.UTC;
import com.google.common.flogger.FluentLogger;
import com.google.common.io.ByteStreams; import com.google.common.io.ByteStreams;
import com.google.common.logging.FormattingLogger;
import google.registry.config.RegistryConfig.Config; import google.registry.config.RegistryConfig.Config;
import google.registry.util.ImprovedInputStream; import google.registry.util.ImprovedInputStream;
import google.registry.util.ImprovedOutputStream; import google.registry.util.ImprovedOutputStream;
@ -125,7 +125,7 @@ import org.joda.time.DateTime;
@Immutable @Immutable
public final class Ghostryde { public final class Ghostryde {
private static final FormattingLogger logger = FormattingLogger.getLoggerForCallerClass(); private static final FluentLogger logger = FluentLogger.forEnclosingClass();
/** /**
* Compression algorithm to use when creating ghostryde files. * Compression algorithm to use when creating ghostryde files.
@ -455,7 +455,7 @@ public final class Ghostryde {
PGPEncryptedDataList crypts = pgpCast(fact.nextObject(), PGPEncryptedDataList.class); PGPEncryptedDataList crypts = pgpCast(fact.nextObject(), PGPEncryptedDataList.class);
checkState(crypts.size() > 0); checkState(crypts.size() > 0);
if (crypts.size() > 1) { if (crypts.size() > 1) {
logger.warningfmt("crypts.size() is %d (should be 1)", crypts.size()); logger.atWarning().log("crypts.size() is %d (should be 1)", crypts.size());
} }
PGPPublicKeyEncryptedData crypt = pgpCast(crypts.get(0), PGPPublicKeyEncryptedData.class); PGPPublicKeyEncryptedData crypt = pgpCast(crypts.get(0), PGPPublicKeyEncryptedData.class);
if (crypt.getKeyID() != privateKey.getKeyID()) { if (crypt.getKeyID() != privateKey.getKeyID()) {

View file

@ -15,7 +15,7 @@
package google.registry.rde; package google.registry.rde;
import com.google.common.base.Splitter; import com.google.common.base.Splitter;
import com.google.common.logging.FormattingLogger; import com.google.common.flogger.FluentLogger;
import com.jcraft.jsch.ChannelSftp; import com.jcraft.jsch.ChannelSftp;
import com.jcraft.jsch.JSch; import com.jcraft.jsch.JSch;
import com.jcraft.jsch.JSchException; import com.jcraft.jsch.JSchException;
@ -41,7 +41,7 @@ import org.joda.time.Duration;
*/ */
final class JSchSshSession implements Closeable { final class JSchSshSession implements Closeable {
private static final FormattingLogger logger = FormattingLogger.getLoggerForCallerClass(); private static final FluentLogger logger = FluentLogger.forEnclosingClass();
/** Factory for {@link JSchSshSession}. */ /** Factory for {@link JSchSshSession}. */
static final class JSchSshSessionFactory { static final class JSchSshSessionFactory {
@ -60,7 +60,7 @@ final class JSchSshSession implements Closeable {
*/ */
JSchSshSession create(JSch jsch, URI uri) throws JSchException { JSchSshSession create(JSch jsch, URI uri) throws JSchException {
RdeUploadUrl url = RdeUploadUrl.create(uri); RdeUploadUrl url = RdeUploadUrl.create(uri);
logger.infofmt("Connecting to SSH endpoint: %s", url); logger.atInfo().log("Connecting to SSH endpoint: %s", url);
Session session = jsch.getSession( Session session = jsch.getSession(
url.getUser().orElse("domain-registry"), url.getUser().orElse("domain-registry"),
url.getHost(), url.getHost(),
@ -99,7 +99,7 @@ final class JSchSshSession implements Closeable {
try { try {
chan.cd(dir); chan.cd(dir);
} catch (SftpException e) { } catch (SftpException e) {
logger.warning(e, "Could not open SFTP channel."); logger.atWarning().withCause(e).log("Could not open SFTP channel.");
mkdirs(chan, dir); mkdirs(chan, dir);
chan.cd(dir); chan.cd(dir);
} }

View file

@ -17,7 +17,7 @@ package google.registry.rde;
import static com.google.common.base.Verify.verify; import static com.google.common.base.Verify.verify;
import static java.nio.charset.StandardCharsets.UTF_8; import static java.nio.charset.StandardCharsets.UTF_8;
import com.google.common.logging.FormattingLogger; import com.google.common.flogger.FluentLogger;
import com.googlecode.objectify.Key; import com.googlecode.objectify.Key;
import google.registry.model.ImmutableObject; import google.registry.model.ImmutableObject;
import google.registry.model.contact.ContactResource; import google.registry.model.contact.ContactResource;
@ -50,7 +50,7 @@ import org.joda.time.DateTime;
@NotThreadSafe @NotThreadSafe
public final class RdeMarshaller implements Serializable { public final class RdeMarshaller implements Serializable {
private static final FormattingLogger logger = FormattingLogger.getLoggerForCallerClass(); private static final FluentLogger logger = FluentLogger.forEnclosingClass();
private static final long serialVersionUID = 202890386611768455L; private static final long serialVersionUID = 202890386611768455L;
private final ValidationMode validationMode; private final ValidationMode validationMode;
@ -168,7 +168,7 @@ public final class RdeMarshaller implements Serializable {
Key.create(resource), Key.create(resource),
e.getLinkedException(), e.getLinkedException(),
getMarshaller().marshalLenient(element)); getMarshaller().marshalLenient(element));
logger.severe(e, error); logger.atSevere().withCause(e).log(error);
} }
return DepositFragment.create(type, xml, error); return DepositFragment.create(type, xml, error);
} }

View file

@ -22,8 +22,8 @@ import static google.registry.model.rde.RdeMode.FULL;
import static google.registry.request.Action.Method.POST; import static google.registry.request.Action.Method.POST;
import com.google.appengine.tools.cloudstorage.GcsFilename; import com.google.appengine.tools.cloudstorage.GcsFilename;
import com.google.common.flogger.FluentLogger;
import com.google.common.io.ByteStreams; import com.google.common.io.ByteStreams;
import com.google.common.logging.FormattingLogger;
import google.registry.config.RegistryConfig.Config; import google.registry.config.RegistryConfig.Config;
import google.registry.gcs.GcsUtils; import google.registry.gcs.GcsUtils;
import google.registry.keyring.api.KeyModule.Key; import google.registry.keyring.api.KeyModule.Key;
@ -58,7 +58,7 @@ public final class RdeReportAction implements Runnable, EscrowTask {
static final String PATH = "/_dr/task/rdeReport"; static final String PATH = "/_dr/task/rdeReport";
private static final FormattingLogger logger = FormattingLogger.getLoggerForCallerClass(); private static final FluentLogger logger = FluentLogger.forEnclosingClass();
@Inject GcsUtils gcsUtils; @Inject GcsUtils gcsUtils;
@Inject Ghostryde ghostryde; @Inject Ghostryde ghostryde;
@ -83,7 +83,7 @@ public final class RdeReportAction implements Runnable, EscrowTask {
getCursorTimeOrStartOfTime( getCursorTimeOrStartOfTime(
ofy().load().key(Cursor.createKey(CursorType.RDE_UPLOAD, Registry.get(tld))).now()); ofy().load().key(Cursor.createKey(CursorType.RDE_UPLOAD, Registry.get(tld))).now());
if (!cursorTime.isAfter(watermark)) { if (!cursorTime.isAfter(watermark)) {
logger.infofmt("tld=%s reportCursor=%s uploadCursor=%s", tld, watermark, cursorTime); logger.atInfo().log("tld=%s reportCursor=%s uploadCursor=%s", tld, watermark, cursorTime);
throw new NoContentException("Waiting for RdeUploadAction to complete"); throw new NoContentException("Waiting for RdeUploadAction to complete");
} }
String prefix = RdeNamingUtils.makeRydeFilename(tld, watermark, FULL, 1, 0); String prefix = RdeNamingUtils.makeRydeFilename(tld, watermark, FULL, 1, 0);

View file

@ -28,7 +28,7 @@ import com.google.appengine.api.urlfetch.HTTPHeader;
import com.google.appengine.api.urlfetch.HTTPRequest; import com.google.appengine.api.urlfetch.HTTPRequest;
import com.google.appengine.api.urlfetch.HTTPResponse; import com.google.appengine.api.urlfetch.HTTPResponse;
import com.google.appengine.api.urlfetch.URLFetchService; import com.google.appengine.api.urlfetch.URLFetchService;
import com.google.common.logging.FormattingLogger; import com.google.common.flogger.FluentLogger;
import google.registry.config.RegistryConfig.Config; import google.registry.config.RegistryConfig.Config;
import google.registry.keyring.api.KeyModule.Key; import google.registry.keyring.api.KeyModule.Key;
import google.registry.request.HttpException.InternalServerErrorException; import google.registry.request.HttpException.InternalServerErrorException;
@ -53,7 +53,7 @@ import javax.inject.Inject;
*/ */
public class RdeReporter { public class RdeReporter {
private static final FormattingLogger logger = FormattingLogger.getLoggerForCallerClass(); private static final FluentLogger logger = FluentLogger.forEnclosingClass();
/** @see <a href="http://tools.ietf.org/html/draft-lozano-icann-registry-interfaces-05#section-4"> /** @see <a href="http://tools.ietf.org/html/draft-lozano-icann-registry-interfaces-05#section-4">
* ICANN Registry Interfaces - Interface details</a>*/ * ICANN Registry Interfaces - Interface details</a>*/
@ -79,7 +79,7 @@ public class RdeReporter {
req.addHeader(new HTTPHeader(CONTENT_TYPE, REPORT_MIME)); req.addHeader(new HTTPHeader(CONTENT_TYPE, REPORT_MIME));
req.addHeader(new HTTPHeader(AUTHORIZATION, "Basic " + token)); req.addHeader(new HTTPHeader(AUTHORIZATION, "Basic " + token));
req.setPayload(reportBytes); req.setPayload(reportBytes);
logger.infofmt("Sending report:\n%s", new String(reportBytes, UTF_8)); logger.atInfo().log("Sending report:\n%s", new String(reportBytes, UTF_8));
HTTPResponse rsp = HTTPResponse rsp =
retrier.callWithRetry( retrier.callWithRetry(
() -> { () -> {
@ -98,10 +98,9 @@ public class RdeReporter {
// Ensure the XML response is valid. // Ensure the XML response is valid.
XjcIirdeaResult result = parseResult(rsp); XjcIirdeaResult result = parseResult(rsp);
if (result.getCode().getValue() != 1000) { if (result.getCode().getValue() != 1000) {
logger.warningfmt("PUT rejected: %d %s\n%s", logger.atWarning().log(
result.getCode().getValue(), "PUT rejected: %d %s\n%s",
result.getMsg(), result.getCode().getValue(), result.getMsg(), result.getDescription());
result.getDescription());
throw new InternalServerErrorException(result.getMsg()); throw new InternalServerErrorException(result.getMsg());
} }
} }
@ -114,7 +113,7 @@ public class RdeReporter {
*/ */
private XjcIirdeaResult parseResult(HTTPResponse rsp) throws XmlException { private XjcIirdeaResult parseResult(HTTPResponse rsp) throws XmlException {
byte[] responseBytes = rsp.getContent(); byte[] responseBytes = rsp.getContent();
logger.infofmt("Received response:\n%s", new String(responseBytes, UTF_8)); logger.atInfo().log("Received response:\n%s", new String(responseBytes, UTF_8));
XjcIirdeaResponseElement response = XjcXmlTransformer.unmarshal( XjcIirdeaResponseElement response = XjcXmlTransformer.unmarshal(
XjcIirdeaResponseElement.class, new ByteArrayInputStream(responseBytes)); XjcIirdeaResponseElement.class, new ByteArrayInputStream(responseBytes));
return response.getResult(); return response.getResult();

View file

@ -30,7 +30,7 @@ import com.google.appengine.tools.cloudstorage.GcsFilename;
import com.google.appengine.tools.cloudstorage.RetryParams; import com.google.appengine.tools.cloudstorage.RetryParams;
import com.google.appengine.tools.mapreduce.Reducer; import com.google.appengine.tools.mapreduce.Reducer;
import com.google.appengine.tools.mapreduce.ReducerInput; import com.google.appengine.tools.mapreduce.ReducerInput;
import com.google.common.logging.FormattingLogger; import com.google.common.flogger.FluentLogger;
import google.registry.config.RegistryConfig.Config; import google.registry.config.RegistryConfig.Config;
import google.registry.gcs.GcsUtils; import google.registry.gcs.GcsUtils;
import google.registry.keyring.api.KeyModule; import google.registry.keyring.api.KeyModule;
@ -68,7 +68,7 @@ public final class RdeStagingReducer extends Reducer<PendingDeposit, DepositFrag
private static final long serialVersionUID = 60326234579091203L; private static final long serialVersionUID = 60326234579091203L;
private static final FormattingLogger logger = FormattingLogger.getLoggerForCallerClass(); private static final FluentLogger logger = FluentLogger.forEnclosingClass();
private final TaskQueueUtils taskQueueUtils; private final TaskQueueUtils taskQueueUtils;
private final LockHandler lockHandler; private final LockHandler lockHandler;
@ -108,12 +108,12 @@ public final class RdeStagingReducer extends Reducer<PendingDeposit, DepositFrag
}; };
String lockName = String.format("RdeStaging %s", key.mode()); String lockName = String.format("RdeStaging %s", key.mode());
if (!lockHandler.executeWithLocks(lockRunner, key.tld(), lockTimeout, lockName)) { if (!lockHandler.executeWithLocks(lockRunner, key.tld(), lockTimeout, lockName)) {
logger.warningfmt("Lock in use: %s", lockName); logger.atWarning().log("Lock in use: %s", lockName);
} }
} }
private void reduceWithLock(final PendingDeposit key, Iterator<DepositFragment> fragments) { private void reduceWithLock(final PendingDeposit key, Iterator<DepositFragment> fragments) {
logger.infofmt("RdeStagingReducer %s", key); logger.atInfo().log("RdeStagingReducer %s", key);
// Normally this is done by BackendServlet but it's not present in MapReduceServlet. // Normally this is done by BackendServlet but it's not present in MapReduceServlet.
Security.addProvider(new BouncyCastleProvider()); Security.addProvider(new BouncyCastleProvider());
@ -148,7 +148,7 @@ public final class RdeStagingReducer extends Reducer<PendingDeposit, DepositFrag
XjcRdeHeader header; XjcRdeHeader header;
// Write a gigantic XML file to GCS. We'll start by opening encrypted out/err file handles. // Write a gigantic XML file to GCS. We'll start by opening encrypted out/err file handles.
logger.infofmt("Writing %s", xmlFilename); logger.atInfo().log("Writing %s", xmlFilename);
try (OutputStream gcsOutput = cloudStorage.openOutputStream(xmlFilename); try (OutputStream gcsOutput = cloudStorage.openOutputStream(xmlFilename);
Ghostryde.Encryptor encryptor = ghostryde.openEncryptor(gcsOutput, stagingKey); Ghostryde.Encryptor encryptor = ghostryde.openEncryptor(gcsOutput, stagingKey);
Ghostryde.Compressor kompressor = ghostryde.openCompressor(encryptor); Ghostryde.Compressor kompressor = ghostryde.openCompressor(encryptor);
@ -167,7 +167,7 @@ public final class RdeStagingReducer extends Reducer<PendingDeposit, DepositFrag
} }
if (!fragment.error().isEmpty()) { if (!fragment.error().isEmpty()) {
failed = true; failed = true;
logger.severefmt("Fragment error: %s", fragment.error()); logger.atSevere().log("Fragment error: %s", fragment.error());
} }
} }
for (IdnTableEnum idn : IdnTableEnum.values()) { for (IdnTableEnum idn : IdnTableEnum.values()) {
@ -197,7 +197,7 @@ public final class RdeStagingReducer extends Reducer<PendingDeposit, DepositFrag
// This is necessary because RdeUploadAction creates a tar file which requires that the length // This is necessary because RdeUploadAction creates a tar file which requires that the length
// be outputted. We don't want to have to decrypt the entire ghostryde file to determine the // be outputted. We don't want to have to decrypt the entire ghostryde file to determine the
// length, so we just save it separately. // length, so we just save it separately.
logger.infofmt("Writing %s", xmlLengthFilename); logger.atInfo().log("Writing %s", xmlLengthFilename);
try (OutputStream gcsOutput = cloudStorage.openOutputStream(xmlLengthFilename)) { try (OutputStream gcsOutput = cloudStorage.openOutputStream(xmlLengthFilename)) {
gcsOutput.write(Long.toString(xmlLength).getBytes(US_ASCII)); gcsOutput.write(Long.toString(xmlLength).getBytes(US_ASCII));
} catch (IOException e) { } catch (IOException e) {
@ -208,7 +208,7 @@ public final class RdeStagingReducer extends Reducer<PendingDeposit, DepositFrag
// //
// This will be sent to ICANN once we're done uploading the big XML to the escrow provider. // This will be sent to ICANN once we're done uploading the big XML to the escrow provider.
if (mode == RdeMode.FULL) { if (mode == RdeMode.FULL) {
logger.infofmt("Writing %s", reportFilename); logger.atInfo().log("Writing %s", reportFilename);
String innerName = prefix + "-report.xml"; String innerName = prefix + "-report.xml";
try (OutputStream gcsOutput = cloudStorage.openOutputStream(reportFilename); try (OutputStream gcsOutput = cloudStorage.openOutputStream(reportFilename);
Ghostryde.Encryptor encryptor = ghostryde.openEncryptor(gcsOutput, stagingKey); Ghostryde.Encryptor encryptor = ghostryde.openEncryptor(gcsOutput, stagingKey);
@ -222,7 +222,7 @@ public final class RdeStagingReducer extends Reducer<PendingDeposit, DepositFrag
// Now that we're done, kick off RdeUploadAction and roll forward the cursor transactionally. // Now that we're done, kick off RdeUploadAction and roll forward the cursor transactionally.
if (key.manual()) { if (key.manual()) {
logger.info("Manual operation; not advancing cursor or enqueuing upload task"); logger.atInfo().log("Manual operation; not advancing cursor or enqueuing upload task");
return; return;
} }
ofy() ofy()
@ -235,7 +235,7 @@ public final class RdeStagingReducer extends Reducer<PendingDeposit, DepositFrag
checkState(key.interval() != null, "Interval must be present"); checkState(key.interval() != null, "Interval must be present");
DateTime newPosition = key.watermark().plus(key.interval()); DateTime newPosition = key.watermark().plus(key.interval());
if (!position.isBefore(newPosition)) { if (!position.isBefore(newPosition)) {
logger.warning("Cursor has already been rolled forward."); logger.atWarning().log("Cursor has already been rolled forward.");
return; return;
} }
verify( verify(
@ -244,7 +244,7 @@ public final class RdeStagingReducer extends Reducer<PendingDeposit, DepositFrag
position, position,
key); key);
ofy().save().entity(Cursor.create(key.cursor(), newPosition, registry)).now(); ofy().save().entity(Cursor.create(key.cursor(), newPosition, registry)).now();
logger.infofmt( logger.atInfo().log(
"Rolled forward %s on %s cursor to %s", key.cursor(), tld, newPosition); "Rolled forward %s on %s cursor to %s", key.cursor(), tld, newPosition);
RdeRevision.saveRevision(tld, watermark, mode, revision); RdeRevision.saveRevision(tld, watermark, mode, revision);
if (mode == RdeMode.FULL) { if (mode == RdeMode.FULL) {

View file

@ -29,8 +29,8 @@ import static java.util.Arrays.asList;
import com.google.appengine.api.taskqueue.Queue; import com.google.appengine.api.taskqueue.Queue;
import com.google.appengine.tools.cloudstorage.GcsFilename; import com.google.appengine.tools.cloudstorage.GcsFilename;
import com.google.common.annotations.VisibleForTesting; import com.google.common.annotations.VisibleForTesting;
import com.google.common.flogger.FluentLogger;
import com.google.common.io.ByteStreams; import com.google.common.io.ByteStreams;
import com.google.common.logging.FormattingLogger;
import com.jcraft.jsch.JSch; import com.jcraft.jsch.JSch;
import com.jcraft.jsch.JSchException; import com.jcraft.jsch.JSchException;
import dagger.Lazy; import dagger.Lazy;
@ -86,7 +86,7 @@ public final class RdeUploadAction implements Runnable, EscrowTask {
static final String PATH = "/_dr/task/rdeUpload"; static final String PATH = "/_dr/task/rdeUpload";
private static final FormattingLogger logger = FormattingLogger.getLoggerForCallerClass(); private static final FluentLogger logger = FluentLogger.forEnclosingClass();
@Inject Clock clock; @Inject Clock clock;
@Inject GcsUtils gcsUtils; @Inject GcsUtils gcsUtils;
@ -135,14 +135,15 @@ public final class RdeUploadAction implements Runnable, EscrowTask {
DateTime stagingCursorTime = getCursorTimeOrStartOfTime( DateTime stagingCursorTime = getCursorTimeOrStartOfTime(
ofy().load().key(Cursor.createKey(CursorType.RDE_STAGING, Registry.get(tld))).now()); ofy().load().key(Cursor.createKey(CursorType.RDE_STAGING, Registry.get(tld))).now());
if (!stagingCursorTime.isAfter(watermark)) { if (!stagingCursorTime.isAfter(watermark)) {
logger.infofmt("tld=%s uploadCursor=%s stagingCursor=%s", tld, watermark, stagingCursorTime); logger.atInfo().log(
"tld=%s uploadCursor=%s stagingCursor=%s", tld, watermark, stagingCursorTime);
throw new ServiceUnavailableException("Waiting for RdeStagingAction to complete"); throw new ServiceUnavailableException("Waiting for RdeStagingAction to complete");
} }
DateTime sftpCursorTime = getCursorTimeOrStartOfTime( DateTime sftpCursorTime = getCursorTimeOrStartOfTime(
ofy().load().key(Cursor.createKey(RDE_UPLOAD_SFTP, Registry.get(tld))).now()); ofy().load().key(Cursor.createKey(RDE_UPLOAD_SFTP, Registry.get(tld))).now());
if (sftpCursorTime.plus(sftpCooldown).isAfter(clock.nowUtc())) { if (sftpCursorTime.plus(sftpCooldown).isAfter(clock.nowUtc())) {
// Fail the task good and hard so it retries until the cooldown passes. // Fail the task good and hard so it retries until the cooldown passes.
logger.infofmt("tld=%s cursor=%s sftpCursor=%s", tld, watermark, sftpCursorTime); logger.atInfo().log("tld=%s cursor=%s sftpCursor=%s", tld, watermark, sftpCursorTime);
throw new ServiceUnavailableException("SFTP cooldown has not yet passed"); throw new ServiceUnavailableException("SFTP cooldown has not yet passed");
} }
int revision = RdeRevision.getNextRevision(tld, watermark, FULL) - 1; int revision = RdeRevision.getNextRevision(tld, watermark, FULL) - 1;
@ -199,7 +200,7 @@ public final class RdeUploadAction implements Runnable, EscrowTask {
@VisibleForTesting @VisibleForTesting
protected void upload( protected void upload(
GcsFilename xmlFile, long xmlLength, DateTime watermark, String name) throws Exception { GcsFilename xmlFile, long xmlLength, DateTime watermark, String name) throws Exception {
logger.infofmt("Uploading %s to %s", xmlFile, uploadUrl); logger.atInfo().log("Uploading %s to %s", xmlFile, uploadUrl);
try (InputStream gcsInput = gcsUtils.openInputStream(xmlFile); try (InputStream gcsInput = gcsUtils.openInputStream(xmlFile);
Ghostryde.Decryptor decryptor = ghostryde.openDecryptor(gcsInput, stagingDecryptionKey); Ghostryde.Decryptor decryptor = ghostryde.openDecryptor(gcsInput, stagingDecryptionKey);
Ghostryde.Decompressor decompressor = ghostryde.openDecompressor(decryptor); Ghostryde.Decompressor decompressor = ghostryde.openDecompressor(decryptor);
@ -221,12 +222,12 @@ public final class RdeUploadAction implements Runnable, EscrowTask {
ByteStreams.copy(xmlInput, tarLayer); ByteStreams.copy(xmlInput, tarLayer);
} }
signature = signer.getSignature(); signature = signer.getSignature();
logger.infofmt("uploaded %,d bytes: %s.ryde", signer.getBytesWritten(), name); logger.atInfo().log("uploaded %,d bytes: %s.ryde", signer.getBytesWritten(), name);
} }
String sigFilename = name + ".sig"; String sigFilename = name + ".sig";
gcsUtils.createFromBytes(new GcsFilename(bucket, sigFilename), signature); gcsUtils.createFromBytes(new GcsFilename(bucket, sigFilename), signature);
ftpChan.get().put(new ByteArrayInputStream(signature), sigFilename); ftpChan.get().put(new ByteArrayInputStream(signature), sigFilename);
logger.infofmt("uploaded %,d bytes: %s.sig", signature.length, name); logger.atInfo().log("uploaded %,d bytes: %s.sig", signature.length, name);
} }
} }
} }

Some files were not shown because too many files have changed in this diff Show more