mirror of
https://github.com/google/nomulus.git
synced 2025-05-16 09:27:16 +02:00
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:
parent
0d2fb3a8f0
commit
70b13596e4
178 changed files with 984 additions and 988 deletions
|
@ -8,7 +8,6 @@ java_library(
|
|||
name = "backup",
|
||||
srcs = glob(["*.java"]),
|
||||
deps = [
|
||||
"//java/com/google/common/logging:formatting_logger",
|
||||
"//java/google/registry/config",
|
||||
"//java/google/registry/cron",
|
||||
"//java/google/registry/mapreduce",
|
||||
|
@ -24,6 +23,8 @@ java_library(
|
|||
"@com_google_auto_value",
|
||||
"@com_google_code_findbugs_jsr305",
|
||||
"@com_google_dagger",
|
||||
"@com_google_flogger",
|
||||
"@com_google_flogger_system_backend",
|
||||
"@com_google_guava",
|
||||
"@com_googlecode_json_simple",
|
||||
"@javax_servlet_api",
|
||||
|
|
|
@ -16,13 +16,12 @@ package google.registry.backup;
|
|||
|
||||
import static com.google.appengine.api.taskqueue.QueueFactory.getQueue;
|
||||
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.UPPER_CHECKPOINT_TIME_PARAM;
|
||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
||||
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.CommitLogCheckpointRoot;
|
||||
import google.registry.request.Action;
|
||||
|
@ -50,7 +49,7 @@ import org.joda.time.DateTime;
|
|||
)
|
||||
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";
|
||||
|
||||
|
@ -62,13 +61,15 @@ public final class CommitLogCheckpointAction implements Runnable {
|
|||
@Override
|
||||
public void run() {
|
||||
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()
|
||||
.transact(
|
||||
() -> {
|
||||
DateTime lastWrittenTime = CommitLogCheckpointRoot.loadRoot().getLastWrittenTime();
|
||||
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;
|
||||
}
|
||||
ofy()
|
||||
|
|
|
@ -16,7 +16,6 @@ package google.registry.backup;
|
|||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
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.model.ofy.ObjectifyService.ofy;
|
||||
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.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMultiset;
|
||||
import com.google.common.logging.FormattingLogger;
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.googlecode.objectify.Key;
|
||||
import google.registry.config.RegistryConfig.Config;
|
||||
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_REDUCE_SHARDS = 10;
|
||||
private static final FormattingLogger logger = getLoggerForCallerClass();
|
||||
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
|
||||
|
||||
@Inject MapreduceRunner mrRunner;
|
||||
@Inject Response response;
|
||||
|
@ -85,7 +84,7 @@ public final class DeleteOldCommitLogsAction implements Runnable {
|
|||
@Override
|
||||
public void run() {
|
||||
DateTime deletionThreshold = clock.nowUtc().minus(maxAge);
|
||||
logger.infofmt(
|
||||
logger.atInfo().log(
|
||||
"Processing asynchronous deletion of unreferenced CommitLogManifests older than %s",
|
||||
deletionThreshold);
|
||||
|
||||
|
@ -182,7 +181,7 @@ public final class DeleteOldCommitLogsAction implements Runnable {
|
|||
// First - check if there even are revisions
|
||||
if (eppResource.getRevisions().isEmpty()) {
|
||||
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;
|
||||
}
|
||||
// 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.
|
||||
getContext().incrementCounter("EPP resources missing pre-threshold revision (SEE LOGS)");
|
||||
logger.severefmt(
|
||||
logger.atSevere().log(
|
||||
"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),
|
||||
eppResource.getCreationTime(),
|
||||
eppResource.getRevisions().size(),
|
||||
|
@ -320,7 +319,8 @@ public final class DeleteOldCommitLogsAction implements Runnable {
|
|||
getContext().incrementCounter("attempts to delete an already deleted manifest");
|
||||
break;
|
||||
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)");
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -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.Iterables.concat;
|
||||
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.NUM_TRANSACTIONS;
|
||||
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.ImmutableSet;
|
||||
import com.google.common.collect.Streams;
|
||||
import com.google.common.logging.FormattingLogger;
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.googlecode.objectify.Key;
|
||||
import google.registry.config.RegistryConfig.Config;
|
||||
import google.registry.model.ImmutableObject;
|
||||
|
@ -68,7 +67,7 @@ import org.joda.time.DateTime;
|
|||
)
|
||||
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 UPPER_CHECKPOINT_TIME_PARAM = "upperCheckpointTime";
|
||||
|
@ -85,7 +84,7 @@ public final class ExportCommitLogDiffAction implements Runnable {
|
|||
|
||||
@Override
|
||||
public void run() {
|
||||
logger.infofmt(
|
||||
logger.atInfo().log(
|
||||
"Exporting commit log diffs between %s and %s.", lowerCheckpointTime, upperCheckpointTime);
|
||||
checkArgument(isAtOrAfter(lowerCheckpointTime, START_OF_TIME));
|
||||
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.
|
||||
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.
|
||||
try (OutputStream gcsStream = newOutputStream(gcsService.createOrReplace(
|
||||
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++) {
|
||||
// Force the async load to finish.
|
||||
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
|
||||
// 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.
|
||||
|
@ -133,12 +132,12 @@ public final class ExportCommitLogDiffAction implements Runnable {
|
|||
nextChunkToExport = ofy().load().keys(keyChunks.get(i + 1));
|
||||
}
|
||||
exportChunk(gcsStream, chunkValues);
|
||||
logger.infofmt("Exported %d manifests", chunkValues.size());
|
||||
logger.atInfo().log("Exported %d manifests", chunkValues.size());
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
logger.infofmt("Exported %d manifests in total", sortedKeys.size());
|
||||
logger.atInfo().log("Exported %d manifests in total", sortedKeys.size());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -27,7 +27,7 @@ import com.google.appengine.tools.cloudstorage.GcsService;
|
|||
import com.google.appengine.tools.cloudstorage.ListItem;
|
||||
import com.google.appengine.tools.cloudstorage.ListOptions;
|
||||
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.ListenableFuture;
|
||||
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. */
|
||||
class GcsDiffFileLister {
|
||||
|
||||
private static final FormattingLogger logger = FormattingLogger.getLoggerForCallerClass();
|
||||
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
|
||||
|
||||
@Inject GcsService gcsService;
|
||||
@Inject @Config("commitLogGcsBucket") String gcsBucket;
|
||||
|
@ -68,30 +68,29 @@ class GcsDiffFileLister {
|
|||
metadata = Futures.getUnchecked(upperBoundTimesToMetadata.get(checkpointTime));
|
||||
} else {
|
||||
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);
|
||||
|
||||
// If we hit a gap, quit.
|
||||
if (metadata == null) {
|
||||
logger.infofmt(
|
||||
logger.atInfo().log(
|
||||
"Gap discovered in sequence terminating at %s, missing file: %s",
|
||||
sequence.lastKey(),
|
||||
filename);
|
||||
logger.infofmt("Found sequence from %s to %s", checkpointTime, lastTime);
|
||||
sequence.lastKey(), filename);
|
||||
logger.atInfo().log("Found sequence from %s to %s", checkpointTime, lastTime);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
sequence.put(checkpointTime, 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;
|
||||
}
|
||||
|
||||
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) {
|
||||
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
|
||||
// (extracted from the filename) to its asynchronously-loaded metadata, keeping only files with
|
||||
|
@ -117,7 +116,7 @@ class GcsDiffFileLister {
|
|||
}
|
||||
}
|
||||
if (upperBoundTimesToMetadata.isEmpty()) {
|
||||
logger.info("No files found");
|
||||
logger.atInfo().log("No files found");
|
||||
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
|
||||
// may be missing files at the end).
|
||||
TreeMap<DateTime, GcsFileMetadata> sequence = new TreeMap<>();
|
||||
logger.infofmt("Restoring until: %s", lastUpperBoundTime);
|
||||
logger.atInfo().log("Restoring until: %s", lastUpperBoundTime);
|
||||
boolean inconsistentFileSet = !constructDiffSequence(
|
||||
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 "
|
||||
+ "file set. Check log for details.");
|
||||
|
||||
logger.infofmt(
|
||||
logger.atInfo().log(
|
||||
"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());
|
||||
}
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ import com.google.appengine.tools.cloudstorage.GcsService;
|
|||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.PeekingIterator;
|
||||
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.Result;
|
||||
import com.googlecode.objectify.util.ResultNow;
|
||||
|
@ -64,7 +64,7 @@ import org.joda.time.DateTime;
|
|||
)
|
||||
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.
|
||||
|
||||
|
@ -90,17 +90,17 @@ public class RestoreCommitLogsAction implements Runnable {
|
|||
|| RegistryEnvironment.get() == RegistryEnvironment.UNITTEST,
|
||||
"DO NOT RUN ANYWHERE ELSE EXCEPT ALPHA, CRASH OR TESTS.");
|
||||
if (dryRun) {
|
||||
logger.info("Running in dryRun mode");
|
||||
logger.atInfo().log("Running in dryRun mode");
|
||||
}
|
||||
List<GcsFileMetadata> diffFiles = diffLister.listDiffFiles(fromTime, toTime);
|
||||
if (diffFiles.isEmpty()) {
|
||||
logger.info("Nothing to restore");
|
||||
logger.atInfo().log("Nothing to restore");
|
||||
return;
|
||||
}
|
||||
Map<Integer, DateTime> bucketTimestamps = new HashMap<>();
|
||||
CommitLogCheckpoint lastCheckpoint = null;
|
||||
for (GcsFileMetadata metadata : diffFiles) {
|
||||
logger.infofmt("Restoring: %s", metadata.getFilename().getObjectName());
|
||||
logger.atInfo().log("Restoring: %s", metadata.getFilename().getObjectName());
|
||||
try (InputStream input = Channels.newInputStream(
|
||||
gcsService.openPrefetchingReadChannel(metadata.getFilename(), 0, BLOCK_SIZE))) {
|
||||
PeekingIterator<ImmutableObject> commitLogs =
|
||||
|
@ -129,7 +129,7 @@ public class RestoreCommitLogsAction implements Runnable {
|
|||
.build()),
|
||||
Stream.of(CommitLogCheckpointRoot.create(lastCheckpoint.getCheckpointTime())))
|
||||
.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) {
|
||||
if (dryRun) {
|
||||
logger.infofmt("Would have saved entities: %s", entitiesToSave);
|
||||
logger.atInfo().log("Would have saved entities: %s", entitiesToSave);
|
||||
return;
|
||||
}
|
||||
retrier.callWithRetry(() -> datastoreService.put(entitiesToSave), RuntimeException.class);
|
||||
|
@ -172,7 +172,7 @@ public class RestoreCommitLogsAction implements Runnable {
|
|||
|
||||
private void saveOfy(Iterable<? extends ImmutableObject> objectsToSave) {
|
||||
if (dryRun) {
|
||||
logger.infofmt("Would have saved entities: %s", objectsToSave);
|
||||
logger.atInfo().log("Would have saved entities: %s", objectsToSave);
|
||||
return;
|
||||
}
|
||||
retrier.callWithRetry(
|
||||
|
@ -181,7 +181,7 @@ public class RestoreCommitLogsAction implements Runnable {
|
|||
|
||||
private Result<?> deleteAsync(Set<Key<?>> keysToDelete) {
|
||||
if (dryRun) {
|
||||
logger.infofmt("Would have deleted entities: %s", keysToDelete);
|
||||
logger.atInfo().log("Would have deleted entities: %s", keysToDelete);
|
||||
}
|
||||
return dryRun || keysToDelete.isEmpty()
|
||||
? new ResultNow<Void>(null)
|
||||
|
|
|
@ -8,7 +8,6 @@ java_library(
|
|||
name = "batch",
|
||||
srcs = glob(["*.java"]),
|
||||
deps = [
|
||||
"//java/com/google/common/logging:formatting_logger",
|
||||
"//java/google/registry/bigquery",
|
||||
"//java/google/registry/config",
|
||||
"//java/google/registry/dns",
|
||||
|
@ -32,6 +31,8 @@ java_library(
|
|||
"@com_google_auto_value",
|
||||
"@com_google_code_findbugs_jsr305",
|
||||
"@com_google_dagger",
|
||||
"@com_google_flogger",
|
||||
"@com_google_flogger_system_backend",
|
||||
"@com_google_guava",
|
||||
"@com_google_http_client",
|
||||
"@com_googlecode_json_simple",
|
||||
|
|
|
@ -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.checkState;
|
||||
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.googlecode.objectify.Key.getKind;
|
||||
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.Iterators;
|
||||
import com.google.common.collect.Multiset;
|
||||
import com.google.common.logging.FormattingLogger;
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.googlecode.objectify.Key;
|
||||
import google.registry.batch.DeleteContactsAndHostsAction.DeletionResult.Type;
|
||||
import google.registry.dns.DnsQueue;
|
||||
|
@ -112,7 +111,7 @@ public class DeleteContactsAndHostsAction implements Runnable {
|
|||
static final String KIND_HOST = getKind(HostResource.class);
|
||||
|
||||
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 DELETES_PER_SHARD = 5;
|
||||
|
||||
|
@ -149,8 +148,8 @@ public class DeleteContactsAndHostsAction implements Runnable {
|
|||
requestsToDelete.add(deletionRequest);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.severefmt(
|
||||
e, "Could not parse async deletion request, delaying task for a day: %s", task);
|
||||
logger.atSevere().withCause(e).log(
|
||||
"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
|
||||
// minutes.
|
||||
queue.modifyTaskLease(task, 1L, DAYS);
|
||||
|
@ -159,10 +158,10 @@ public class DeleteContactsAndHostsAction implements Runnable {
|
|||
deleteStaleTasksWithRetry(requestsToDelete);
|
||||
ImmutableList<DeletionRequest> deletionRequests = builder.build();
|
||||
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.");
|
||||
} else {
|
||||
logger.infofmt(
|
||||
logger.atInfo().log(
|
||||
"Processing asynchronous deletion of %d contacts and %d hosts: %s",
|
||||
kindCounts.count(KIND_CONTACT), kindCounts.count(KIND_HOST), resourceKeys.build());
|
||||
runMapreduce(deletionRequests);
|
||||
|
@ -204,7 +203,8 @@ public class DeleteContactsAndHostsAction implements Runnable {
|
|||
new NullInput<>(),
|
||||
EppResourceInputs.createEntityInput(DomainBase.class)))));
|
||||
} 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
|
||||
public void reduce(final DeletionRequest deletionRequest, ReducerInput<Boolean> values) {
|
||||
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 =
|
||||
ofy()
|
||||
.transactNew(
|
||||
|
@ -290,7 +290,7 @@ public class DeleteContactsAndHostsAction implements Runnable {
|
|||
deletionRequest.requestedTime());
|
||||
String resourceNamePlural = deletionRequest.key().getKind() + "s";
|
||||
getContext().incrementCounter(result.type().renderCounterText(resourceNamePlural));
|
||||
logger.infofmt(
|
||||
logger.atInfo().log(
|
||||
"Result of async deletion for resource %s: %s",
|
||||
deletionRequest.key(), result.pollMessageText());
|
||||
}
|
||||
|
@ -563,11 +563,12 @@ public class DeleteContactsAndHostsAction implements Runnable {
|
|||
static boolean doesResourceStateAllowDeletion(EppResource resource, DateTime now) {
|
||||
Key<EppResource> key = Key.create(resource);
|
||||
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;
|
||||
}
|
||||
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 true;
|
||||
|
|
|
@ -24,7 +24,7 @@ import static google.registry.request.Action.Method.POST;
|
|||
import com.google.appengine.tools.mapreduce.Mapper;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.logging.FormattingLogger;
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.googlecode.objectify.Key;
|
||||
import google.registry.config.RegistryEnvironment;
|
||||
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)
|
||||
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.
|
||||
|
@ -136,7 +136,7 @@ public class DeleteLoadTestDataAction implements Runnable {
|
|||
.addAll(resourceAndDependentKeys)
|
||||
.build();
|
||||
if (isDryRun) {
|
||||
logger.infofmt("Would hard-delete the following entities: %s", allKeys);
|
||||
logger.atInfo().log("Would hard-delete the following entities: %s", allKeys);
|
||||
} else {
|
||||
ofy().deleteWithoutBackup().keys(allKeys);
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ import com.google.common.collect.ImmutableList;
|
|||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.google.common.logging.FormattingLogger;
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.googlecode.objectify.Key;
|
||||
import google.registry.config.RegistryConfig.Config;
|
||||
import google.registry.config.RegistryEnvironment;
|
||||
|
@ -72,7 +72,7 @@ import org.joda.time.Duration;
|
|||
)
|
||||
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;
|
||||
/** 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");
|
||||
}
|
||||
} 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()));
|
||||
}
|
||||
}
|
||||
|
@ -194,7 +194,7 @@ public class DeleteProberDataAction implements Runnable {
|
|||
return;
|
||||
}
|
||||
if (!domain.getSubordinateHosts().isEmpty()) {
|
||||
logger.warningfmt(
|
||||
logger.atWarning().log(
|
||||
"Cannot delete domain %s (%s) because it has subordinate hosts.",
|
||||
domainName, domainKey);
|
||||
getContext().incrementCounter("skipped, had subordinate host(s)");
|
||||
|
@ -207,7 +207,8 @@ public class DeleteProberDataAction implements Runnable {
|
|||
// time the mapreduce is run.
|
||||
if (EppResourceUtils.isActive(domain, now)) {
|
||||
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 {
|
||||
softDeleteDomain(domain);
|
||||
}
|
||||
|
@ -225,22 +226,28 @@ public class DeleteProberDataAction implements Runnable {
|
|||
final Key<EppResourceIndex> eppIndex = Key.create(EppResourceIndex.create(domainKey));
|
||||
final Key<? extends ForeignKeyIndex<?>> fki = ForeignKeyIndex.createKey(domain);
|
||||
|
||||
int entitiesDeleted = ofy().transact(() -> {
|
||||
// This ancestor query selects all descendant HistoryEntries, BillingEvents, PollMessages,
|
||||
// and TLD-specific entities, as well as the domain itself.
|
||||
List<Key<Object>> domainAndDependentKeys = ofy().load().ancestor(domainKey).keys().list();
|
||||
ImmutableSet<Key<?>> allKeys = new ImmutableSet.Builder<Key<?>>()
|
||||
.add(fki)
|
||||
.add(eppIndex)
|
||||
.addAll(domainAndDependentKeys)
|
||||
.build();
|
||||
if (isDryRun) {
|
||||
logger.infofmt("Would hard-delete the following entities: %s", allKeys);
|
||||
} else {
|
||||
ofy().deleteWithoutBackup().keys(allKeys);
|
||||
}
|
||||
return allKeys.size();
|
||||
});
|
||||
int entitiesDeleted =
|
||||
ofy()
|
||||
.transact(
|
||||
() -> {
|
||||
// This ancestor query selects all descendant HistoryEntries, BillingEvents,
|
||||
// PollMessages,
|
||||
// and TLD-specific entities, as well as the domain itself.
|
||||
List<Key<Object>> domainAndDependentKeys =
|
||||
ofy().load().ancestor(domainKey).keys().list();
|
||||
ImmutableSet<Key<?>> allKeys =
|
||||
new ImmutableSet.Builder<Key<?>>()
|
||||
.add(fki)
|
||||
.add(eppIndex)
|
||||
.addAll(domainAndDependentKeys)
|
||||
.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("total entities hard-deleted", entitiesDeleted);
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ import com.google.common.collect.ImmutableList;
|
|||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Range;
|
||||
import com.google.common.collect.Streams;
|
||||
import com.google.common.logging.FormattingLogger;
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.googlecode.objectify.Key;
|
||||
import google.registry.mapreduce.MapreduceRunner;
|
||||
import google.registry.mapreduce.inputs.NullInput;
|
||||
|
@ -81,7 +81,7 @@ public class ExpandRecurringBillingEventsAction implements Runnable {
|
|||
|
||||
public static final String PARAM_CURSOR_TIME = "cursorTime";
|
||||
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 MapreduceRunner mrRunner;
|
||||
|
@ -99,10 +99,9 @@ public class ExpandRecurringBillingEventsAction implements Runnable {
|
|||
checkArgument(
|
||||
cursorTime.isBefore(executeTime),
|
||||
"Cursor time must be earlier than execution time.");
|
||||
logger.infofmt(
|
||||
logger.atInfo().log(
|
||||
"Running Recurring billing event expansion for billing time range [%s, %s).",
|
||||
cursorTime,
|
||||
executeTime);
|
||||
cursorTime, executeTime);
|
||||
response.sendJavaScriptRedirect(createJobPath(mrRunner
|
||||
.setJobName("Expand Recurring billing events into synthetic OneTime events.")
|
||||
.setModuleName("backend")
|
||||
|
@ -232,11 +231,12 @@ public class ExpandRecurringBillingEventsAction implements Runnable {
|
|||
return syntheticOneTimes.size();
|
||||
});
|
||||
} 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_COUNTER);
|
||||
throw t;
|
||||
throw new RuntimeException(
|
||||
String.format(
|
||||
"Error while expanding Recurring billing events for %d", recurring.getId()),
|
||||
t);
|
||||
}
|
||||
if (!isDryRun) {
|
||||
getContext().incrementCounter("Saved OneTime billing events", numBillingEventsSaved);
|
||||
|
@ -300,16 +300,15 @@ public class ExpandRecurringBillingEventsAction implements Runnable {
|
|||
@Override
|
||||
public void reduce(final DateTime cursorTime, final ReducerInput<DateTime> executionTimeInput) {
|
||||
if (getContext().getCounter(ERROR_COUNTER).getValue() > 0) {
|
||||
logger.severefmt("One or more errors logged during recurring event expansion. Cursor will"
|
||||
+ " not be advanced.");
|
||||
logger.atSevere().log(
|
||||
"One or more errors logged during recurring event expansion. Cursor will"
|
||||
+ " not be advanced.");
|
||||
return;
|
||||
}
|
||||
final DateTime executionTime = executionTimeInput.next();
|
||||
logger.infofmt(
|
||||
logger.atInfo().log(
|
||||
"Recurring event expansion %s complete for billing event range [%s, %s).",
|
||||
isDryRun ? "(dry run) " : "",
|
||||
cursorTime,
|
||||
executionTime);
|
||||
isDryRun ? "(dry run) " : "", cursorTime, executionTime);
|
||||
ofy()
|
||||
.transact(
|
||||
() -> {
|
||||
|
@ -317,7 +316,7 @@ public class ExpandRecurringBillingEventsAction implements Runnable {
|
|||
DateTime currentCursorTime =
|
||||
(cursor == null ? START_OF_TIME : cursor.getCursorTime());
|
||||
if (!currentCursorTime.equals(expectedPersistedCursorTime)) {
|
||||
logger.severefmt(
|
||||
logger.atSevere().log(
|
||||
"Current cursor position %s does not match expected cursor position %s.",
|
||||
currentCursorTime, expectedPersistedCursorTime);
|
||||
return;
|
||||
|
|
|
@ -19,7 +19,7 @@ import static javax.servlet.http.HttpServletResponse.SC_BAD_REQUEST;
|
|||
|
||||
import com.google.appengine.api.datastore.DatastoreService;
|
||||
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.mapreduce.MapreduceRunner;
|
||||
import google.registry.request.Action;
|
||||
|
@ -88,7 +88,7 @@ public class MapreduceEntityCleanupAction implements Runnable {
|
|||
private static final String ERROR_NON_POSITIVE_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> jobName;
|
||||
|
@ -133,7 +133,7 @@ public class MapreduceEntityCleanupAction implements Runnable {
|
|||
}
|
||||
|
||||
private void handleBadRequest(String message) {
|
||||
logger.severe(message);
|
||||
logger.atSevere().log(message);
|
||||
response.setPayload(message);
|
||||
response.setStatus(SC_BAD_REQUEST);
|
||||
}
|
||||
|
@ -198,12 +198,12 @@ public class MapreduceEntityCleanupAction implements Runnable {
|
|||
&& (!numJobsToDelete.isPresent() || (numJobsProcessed < numJobsToDelete.get())));
|
||||
|
||||
if (numJobsProcessed == 0) {
|
||||
logger.infofmt(
|
||||
"No eligible jobs found with name '%s' older than %s days old.",
|
||||
logger.atInfo().log(
|
||||
"No eligible jobs found with name '%s' older than %d days old.",
|
||||
jobName.orElse("(any)"), defaultedDaysOld);
|
||||
payload.append("No eligible jobs found");
|
||||
} 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));
|
||||
}
|
||||
response.setPayload(payload.toString());
|
||||
|
@ -219,16 +219,15 @@ public class MapreduceEntityCleanupAction implements Runnable {
|
|||
if (error.isPresent()) {
|
||||
errorCount++;
|
||||
}
|
||||
logger.infofmt("%s: %s", actualJobId, error.orElse("deletion requested"));
|
||||
logger.atInfo().log("%s: %s", actualJobId, error.orElse("deletion requested"));
|
||||
payloadChunkBuilder.ifPresent(
|
||||
stringBuilder ->
|
||||
stringBuilder.append(
|
||||
String.format("%s: %s\n", actualJobId, error.orElse("deletion requested"))));
|
||||
}
|
||||
logger.infofmt(
|
||||
"successfully requested async deletion of %s job(s); errors received on %s",
|
||||
actualJobIds.size() - errorCount,
|
||||
errorCount);
|
||||
logger.atInfo().log(
|
||||
"successfully requested async deletion of %d job(s); errors received on %d",
|
||||
actualJobIds.size() - errorCount, errorCount);
|
||||
if (payloadChunkBuilder.isPresent()) {
|
||||
payloadChunkBuilder.get().append(String.format(
|
||||
"successfully requested async deletion of %d job(s); errors received on %d\n",
|
||||
|
|
|
@ -41,7 +41,7 @@ import com.google.appengine.tools.mapreduce.ReducerInput;
|
|||
import com.google.auto.value.AutoValue;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.logging.FormattingLogger;
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.googlecode.objectify.Key;
|
||||
import google.registry.dns.DnsQueue;
|
||||
import google.registry.flows.async.AsyncFlowMetrics;
|
||||
|
@ -72,7 +72,7 @@ import org.joda.time.DateTime;
|
|||
)
|
||||
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;
|
||||
|
||||
@Inject AsyncFlowMetrics asyncFlowMetrics;
|
||||
|
@ -108,8 +108,8 @@ public class RefreshDnsOnHostRenameAction implements Runnable {
|
|||
requestsToDelete.add(request);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.severefmt(
|
||||
e, "Could not parse DNS refresh for host request, delaying task for a day: %s", task);
|
||||
logger.atSevere().withCause(e).log(
|
||||
"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.
|
||||
pullQueue.modifyTaskLease(task, 1L, DAYS);
|
||||
}
|
||||
|
@ -119,11 +119,12 @@ public class RefreshDnsOnHostRenameAction implements Runnable {
|
|||
requestsToDelete, pullQueue, asyncFlowMetrics, retrier, OperationResult.STALE);
|
||||
ImmutableList<DnsRefreshRequest> refreshRequests = requestsBuilder.build();
|
||||
if (refreshRequests.isEmpty()) {
|
||||
logger.info(
|
||||
logger.atInfo().log(
|
||||
"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.");
|
||||
} 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);
|
||||
}
|
||||
}
|
||||
|
@ -141,7 +142,8 @@ public class RefreshDnsOnHostRenameAction implements Runnable {
|
|||
ImmutableList.of(
|
||||
new NullInput<>(), createEntityInput(DomainResource.class)))));
|
||||
} 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(
|
||||
() -> dnsQueue.addDomainRefreshTask(domain.getFullyQualifiedDomainName()),
|
||||
TransientFailureException.class);
|
||||
logger.infofmt(
|
||||
logger.atInfo().log(
|
||||
"Enqueued DNS refresh for domain %s referenced by host %s.",
|
||||
domain.getFullyQualifiedDomainName(), referencingHostKey);
|
||||
getContext().incrementCounter("domains refreshed");
|
||||
|
@ -278,7 +280,7 @@ public class RefreshDnsOnHostRenameAction implements Runnable {
|
|||
boolean isHostDeleted =
|
||||
isDeleted(host, latestOf(now, host.getUpdateAutoTimestamp().getTimestamp()));
|
||||
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()
|
||||
.setHostKey(hostKey)
|
||||
|
|
|
@ -17,7 +17,6 @@ package google.registry.batch;
|
|||
import static com.google.common.base.Preconditions.checkState;
|
||||
import static com.google.common.collect.ImmutableSet.toImmutableSet;
|
||||
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 google.registry.model.EppResourceUtils.isActive;
|
||||
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.collect.ImmutableSet;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.google.common.logging.FormattingLogger;
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.googlecode.objectify.Key;
|
||||
import google.registry.mapreduce.MapreduceRunner;
|
||||
import google.registry.mapreduce.inputs.EppResourceInputs;
|
||||
|
@ -95,7 +94,7 @@ import org.joda.time.DateTime;
|
|||
)
|
||||
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;
|
||||
@NonFinalForTesting
|
||||
@VisibleForTesting
|
||||
|
@ -220,7 +219,8 @@ public class VerifyEntityIntegrityAction implements Runnable {
|
|||
mapEntity(keyOrEntity);
|
||||
} catch (Throwable e) {
|
||||
// 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);
|
||||
} catch (Throwable e) {
|
||||
// Log and swallow so that the mapreduce doesn't abort on first error.
|
||||
logger.severefmt(
|
||||
e, "Exception while checking foreign key integrity constraints for: %s", mapperKey);
|
||||
logger.atSevere().withCause(e).log(
|
||||
"Exception while checking foreign key integrity constraints for: %s", mapperKey);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -9,13 +9,14 @@ java_library(
|
|||
srcs = glob(["*.java"]),
|
||||
resources = glob(["sql/*"]),
|
||||
deps = [
|
||||
"//java/com/google/common/logging:formatting_logger",
|
||||
"//java/google/registry/config",
|
||||
"//java/google/registry/reporting/billing",
|
||||
"//java/google/registry/util",
|
||||
"@com_google_apis_google_api_services_bigquery",
|
||||
"@com_google_auto_value",
|
||||
"@com_google_dagger",
|
||||
"@com_google_flogger",
|
||||
"@com_google_flogger_system_backend",
|
||||
"@com_google_guava",
|
||||
"@org_apache_avro",
|
||||
"@org_apache_beam_runners_direct_java",
|
||||
|
|
|
@ -18,7 +18,7 @@ import com.google.auto.value.AutoValue;
|
|||
import com.google.common.annotations.VisibleForTesting;
|
||||
import com.google.common.base.Joiner;
|
||||
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 java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
@ -46,7 +46,7 @@ import org.apache.beam.sdk.io.gcp.bigquery.SchemaAndRecord;
|
|||
@AutoValue
|
||||
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 =
|
||||
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)
|
||||
.collect(ImmutableList.toImmutableList());
|
||||
if (!nullFields.isEmpty()) {
|
||||
logger.severefmt(
|
||||
logger.atSevere().log(
|
||||
"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");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,6 @@ java_library(
|
|||
name = "bigquery",
|
||||
srcs = glob(["*.java"]),
|
||||
deps = [
|
||||
"//java/com/google/common/logging:formatting_logger",
|
||||
"//java/google/registry/config",
|
||||
"//java/google/registry/util",
|
||||
"@com_google_api_client",
|
||||
|
@ -16,6 +15,8 @@ java_library(
|
|||
"@com_google_apis_google_api_services_bigquery",
|
||||
"@com_google_code_findbugs_jsr305",
|
||||
"@com_google_dagger",
|
||||
"@com_google_flogger",
|
||||
"@com_google_flogger_system_backend",
|
||||
"@com_google_guava",
|
||||
"@com_google_http_client",
|
||||
"@com_google_http_client_appengine",
|
||||
|
|
|
@ -53,8 +53,8 @@ import com.google.api.services.bigquery.model.TableRow;
|
|||
import com.google.api.services.bigquery.model.ViewDefinition;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableTable;
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
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.ListenableFuture;
|
||||
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. */
|
||||
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);
|
||||
|
||||
|
@ -642,10 +642,10 @@ public class BigqueryConnection implements AutoCloseable {
|
|||
if (jobStatus.getErrorResult() != null) {
|
||||
throw BigqueryJobFailureException.create(jobStatus);
|
||||
} else {
|
||||
logger.info(summarizeCompletedJob(job));
|
||||
logger.atInfo().log(summarizeCompletedJob(job));
|
||||
if (jobStatus.getErrors() != null) {
|
||||
for (ErrorProto error : jobStatus.getErrors()) {
|
||||
logger.warningfmt("%s: %s", error.getReason(), error.getMessage());
|
||||
logger.atWarning().log("%s: %s", error.getReason(), error.getMessage());
|
||||
}
|
||||
}
|
||||
return job;
|
||||
|
|
|
@ -16,7 +16,6 @@ package google.registry.bigquery;
|
|||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
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.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.TableSchema;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.logging.FormattingLogger;
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
@ -43,7 +42,7 @@ import javax.inject.Inject;
|
|||
/** Factory for creating {@link Bigquery} connections. */
|
||||
public class BigqueryFactory {
|
||||
|
||||
private static final FormattingLogger logger = getLoggerForCallerClass();
|
||||
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
|
||||
|
||||
// Cross-request caches to avoid unnecessary RPCs.
|
||||
private static Set<String> knownExistingDatasets = newConcurrentHashSet();
|
||||
|
@ -152,8 +151,9 @@ public class BigqueryFactory {
|
|||
.setSchema(new TableSchema().setFields(schema))
|
||||
.setTableReference(table))
|
||||
.execute();
|
||||
logger.infofmt("Created BigQuery table %s:%s.%s", table.getProjectId(), table.getDatasetId(),
|
||||
table.getTableId());
|
||||
logger.atInfo().log(
|
||||
"Created BigQuery table %s:%s.%s",
|
||||
table.getProjectId(), table.getDatasetId(), table.getTableId());
|
||||
} catch (IOException e) {
|
||||
// Swallow errors about a table that exists, and throw any other ones.
|
||||
if (!BigqueryJobFailureException.create(e).getReason().equals("duplicate")) {
|
||||
|
|
|
@ -9,12 +9,13 @@ java_library(
|
|||
srcs = glob(["*.java"]),
|
||||
resources = glob(["files/*.yaml"]),
|
||||
deps = [
|
||||
"//java/com/google/common/logging:formatting_logger",
|
||||
"//java/google/registry/util",
|
||||
"@com_google_appengine_api_1_0_sdk",
|
||||
"@com_google_auto_value",
|
||||
"@com_google_code_findbugs_jsr305",
|
||||
"@com_google_dagger",
|
||||
"@com_google_flogger",
|
||||
"@com_google_flogger_system_backend",
|
||||
"@com_google_guava",
|
||||
"@joda_time",
|
||||
"@org_joda_money",
|
||||
|
|
|
@ -15,10 +15,9 @@
|
|||
package google.registry.config;
|
||||
|
||||
import static com.google.common.base.Ascii.toLowerCase;
|
||||
import static com.google.common.logging.FormattingLogger.getLoggerForCallerClass;
|
||||
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.Optional;
|
||||
import org.yaml.snakeyaml.Yaml;
|
||||
|
@ -34,7 +33,7 @@ import org.yaml.snakeyaml.Yaml;
|
|||
*/
|
||||
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 YAML_CONFIG_PROD =
|
||||
|
@ -92,9 +91,9 @@ public final class YamlUtils {
|
|||
Optional<Map<String, Object>> customMap = loadAsMap(yaml, customYaml);
|
||||
if (customMap.isPresent()) {
|
||||
yamlMap = mergeMaps(yamlMap, customMap.get());
|
||||
logger.fine("Successfully loaded environment configuration YAML file.");
|
||||
logger.atFine().log("Successfully loaded environment configuration YAML file.");
|
||||
} else {
|
||||
logger.warning("Ignoring empty environment configuration YAML file.");
|
||||
logger.atWarning().log("Ignoring empty environment configuration YAML file.");
|
||||
}
|
||||
return yaml.dump(yamlMap);
|
||||
}
|
||||
|
|
|
@ -8,7 +8,6 @@ java_library(
|
|||
name = "cron",
|
||||
srcs = glob(["*.java"]),
|
||||
deps = [
|
||||
"//java/com/google/common/logging:formatting_logger",
|
||||
"//java/google/registry/model",
|
||||
"//java/google/registry/request",
|
||||
"//java/google/registry/request/auth",
|
||||
|
@ -17,6 +16,8 @@ java_library(
|
|||
"@com_google_appengine_api_1_0_sdk",
|
||||
"@com_google_code_findbugs_jsr305",
|
||||
"@com_google_dagger",
|
||||
"@com_google_flogger",
|
||||
"@com_google_flogger_system_backend",
|
||||
"@com_google_guava",
|
||||
"@javax_servlet_api",
|
||||
"@joda_time",
|
||||
|
|
|
@ -36,7 +36,7 @@ import com.google.common.collect.ImmutableListMultimap;
|
|||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Multimap;
|
||||
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.Parameter;
|
||||
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 FormattingLogger logger = FormattingLogger.getLoggerForCallerClass();
|
||||
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
|
||||
|
||||
@Inject TaskQueueUtils taskQueueUtils;
|
||||
@Inject Response response;
|
||||
|
@ -138,9 +138,9 @@ public final class TldFanoutAction implements Runnable {
|
|||
StringBuilder outputPayload =
|
||||
new StringBuilder(
|
||||
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()) {
|
||||
logger.warning("No TLDs to fan-out!");
|
||||
logger.atWarning().log("No TLDs to fan-out!");
|
||||
}
|
||||
for (String tld : tlds) {
|
||||
TaskOptions taskOptions = createTaskOptions(tld, flowThruParams);
|
||||
|
@ -149,8 +149,8 @@ public final class TldFanoutAction implements Runnable {
|
|||
String.format(
|
||||
"- Task: '%s', tld: '%s', endpoint: '%s'\n",
|
||||
taskHandle.getName(), tld, taskOptions.getUrl()));
|
||||
logger.infofmt("Task: '%s', tld: '%s', endpoint: '%s'",
|
||||
taskHandle.getName(), tld, taskOptions.getUrl());
|
||||
logger.atInfo().log(
|
||||
"Task: '%s', tld: '%s', endpoint: '%s'", taskHandle.getName(), tld, taskOptions.getUrl());
|
||||
}
|
||||
response.setContentType(PLAIN_TEXT_UTF_8);
|
||||
response.setPayload(outputPayload.toString());
|
||||
|
|
|
@ -20,7 +20,6 @@ java_library(
|
|||
),
|
||||
deps = [
|
||||
":constants",
|
||||
"//java/com/google/common/logging:formatting_logger",
|
||||
"//java/google/registry/config",
|
||||
"//java/google/registry/dns/writer",
|
||||
"//java/google/registry/model",
|
||||
|
@ -33,6 +32,8 @@ java_library(
|
|||
"@com_google_auto_value",
|
||||
"@com_google_code_findbugs_jsr305",
|
||||
"@com_google_dagger",
|
||||
"@com_google_flogger",
|
||||
"@com_google_flogger_system_backend",
|
||||
"@com_google_guava",
|
||||
"@com_google_monitoring_client_metrics",
|
||||
"@javax_servlet_api",
|
||||
|
|
|
@ -34,7 +34,7 @@ import com.google.appengine.api.taskqueue.TransientFailureException;
|
|||
import com.google.apphosting.api.DeadlineExceededException;
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
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.util.concurrent.RateLimiter;
|
||||
import google.registry.dns.DnsConstants.TargetType;
|
||||
|
@ -65,7 +65,7 @@ import org.joda.time.Duration;
|
|||
*/
|
||||
public class DnsQueue {
|
||||
|
||||
private static final FormattingLogger logger = FormattingLogger.getLoggerForCallerClass();
|
||||
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
|
||||
|
||||
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.
|
||||
*/
|
||||
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)",
|
||||
targetType, targetName, tld, DNS_PULL_QUEUE_NAME, queue.fetchStatistics().getNumTasks());
|
||||
return queue.add(
|
||||
|
@ -159,14 +159,11 @@ public class DnsQueue {
|
|||
try {
|
||||
rateLimiter.acquire();
|
||||
int numTasks = queue.fetchStatistics().getNumTasks();
|
||||
logger.logfmt(
|
||||
(numTasks >= leaseTasksBatchSize) ? Level.WARNING : Level.INFO,
|
||||
"There are %d tasks in the DNS queue '%s'.",
|
||||
numTasks,
|
||||
DNS_PULL_QUEUE_NAME);
|
||||
logger.at((numTasks >= leaseTasksBatchSize) ? Level.WARNING : Level.INFO).log(
|
||||
"There are %d tasks in the DNS queue '%s'.", numTasks, DNS_PULL_QUEUE_NAME);
|
||||
return queue.leaseTasks(leaseDuration.getMillis(), MILLISECONDS, leaseTasksBatchSize);
|
||||
} 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();
|
||||
}
|
||||
}
|
||||
|
@ -176,7 +173,7 @@ public class DnsQueue {
|
|||
try {
|
||||
queue.deleteTask(tasks);
|
||||
} catch (TransientFailureException | DeadlineExceededException e) {
|
||||
logger.severe(e, "Failed deleting tasks too fast");
|
||||
logger.atSevere().withCause(e).log("Failed deleting tasks too fast");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,10 +15,9 @@
|
|||
package google.registry.dns;
|
||||
|
||||
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.logging.FormattingLogger;
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import google.registry.dns.writer.DnsWriter;
|
||||
import google.registry.model.registry.Registry;
|
||||
import java.util.Map;
|
||||
|
@ -27,7 +26,7 @@ import javax.inject.Inject;
|
|||
/** Proxy for retrieving {@link DnsWriter} implementations. */
|
||||
public final class DnsWriterProxy {
|
||||
|
||||
private static final FormattingLogger logger = getLoggerForCallerClass();
|
||||
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
|
||||
|
||||
private final ImmutableMap<String, DnsWriter> dnsWriters;
|
||||
|
||||
|
@ -43,9 +42,8 @@ public final class DnsWriterProxy {
|
|||
*/
|
||||
public DnsWriter getByClassNameForTld(String className, String tld) {
|
||||
if (!Registry.get(tld).getDnsWriters().contains(className)) {
|
||||
logger.warningfmt(
|
||||
"Loaded potentially stale DNS writer %s which is not active on TLD %s.",
|
||||
className, tld);
|
||||
logger.atWarning().log(
|
||||
"Loaded potentially stale DNS writer %s which is not active on TLD %s.", className, tld);
|
||||
return null;
|
||||
}
|
||||
DnsWriter dnsWriter = dnsWriters.get(className);
|
||||
|
|
|
@ -18,7 +18,7 @@ import static google.registry.request.Action.Method.POST;
|
|||
import static google.registry.request.RequestParameters.PARAM_TLD;
|
||||
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 google.registry.config.RegistryConfig.Config;
|
||||
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 LOCK_NAME = "DNS updates";
|
||||
|
||||
private static final FormattingLogger logger = FormattingLogger.getLoggerForCallerClass();
|
||||
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
|
||||
|
||||
@Inject DnsQueue dnsQueue;
|
||||
@Inject DnsWriterProxy dnsWriterProxy;
|
||||
|
@ -101,9 +101,9 @@ public final class PublishDnsUpdatesAction implements Runnable, Callable<Void> {
|
|||
nullToEmpty(domains).size() + nullToEmpty(hosts).size(),
|
||||
new Duration(itemsCreateTime, now),
|
||||
new Duration(enqueuedTime, now));
|
||||
logger.infofmt(
|
||||
logger.atInfo().log(
|
||||
"publishDnsWriter latency statistics: TLD: %s, dnsWriter: %s, actionStatus: %s, "
|
||||
+ "numItems: %s, timeSinceCreation: %s, timeInQueue: %s",
|
||||
+ "numItems: %d, timeSinceCreation: %s, timeInQueue: %s",
|
||||
tld,
|
||||
dnsWriter,
|
||||
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. */
|
||||
private void requeueBatch() {
|
||||
logger.infofmt("Requeueing batch for retry");
|
||||
logger.atInfo().log("Requeueing batch for retry");
|
||||
for (String domain : nullToEmpty(domains)) {
|
||||
dnsQueue.addDomainRefreshTask(domain);
|
||||
}
|
||||
|
@ -156,14 +156,14 @@ public final class PublishDnsUpdatesAction implements Runnable, Callable<Void> {
|
|||
private boolean validLockParams() {
|
||||
// LockIndex should always be within [1, numPublishLocks]
|
||||
if (lockIndex > numPublishLocks || lockIndex <= 0) {
|
||||
logger.severefmt(
|
||||
logger.atSevere().log(
|
||||
"Lock index should be within [1,%d], got %d instead", numPublishLocks, lockIndex);
|
||||
return false;
|
||||
}
|
||||
// Check if the Registry object's num locks has changed since this task was batched
|
||||
int registryNumPublishLocks = Registry.get(tld).getNumDnsPublishLocks();
|
||||
if (registryNumPublishLocks != numPublishLocks) {
|
||||
logger.warningfmt(
|
||||
logger.atWarning().log(
|
||||
"Registry numDnsPublishLocks %d out of sync with parameter %d",
|
||||
registryNumPublishLocks, numPublishLocks);
|
||||
return false;
|
||||
|
@ -178,7 +178,7 @@ public final class PublishDnsUpdatesAction implements Runnable, Callable<Void> {
|
|||
DnsWriter writer = dnsWriterProxy.getByClassNameForTld(dnsWriter, tld);
|
||||
|
||||
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);
|
||||
requeueBatch();
|
||||
return;
|
||||
|
@ -189,11 +189,11 @@ public final class PublishDnsUpdatesAction implements Runnable, Callable<Void> {
|
|||
for (String domain : nullToEmpty(domains)) {
|
||||
if (!DomainNameUtils.isUnder(
|
||||
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;
|
||||
} else {
|
||||
writer.publishDomain(domain);
|
||||
logger.infofmt("%s: published domain %s", tld, domain);
|
||||
logger.atInfo().log("%s: published domain %s", tld, domain);
|
||||
domainsPublished += 1;
|
||||
}
|
||||
}
|
||||
|
@ -205,11 +205,11 @@ public final class PublishDnsUpdatesAction implements Runnable, Callable<Void> {
|
|||
for (String host : nullToEmpty(hosts)) {
|
||||
if (!DomainNameUtils.isUnder(
|
||||
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;
|
||||
} else {
|
||||
writer.publishHost(host);
|
||||
logger.infofmt("%s: published host %s", tld, host);
|
||||
logger.atInfo().log("%s: published host %s", tld, host);
|
||||
hostsPublished += 1;
|
||||
}
|
||||
}
|
||||
|
@ -234,7 +234,7 @@ public final class PublishDnsUpdatesAction implements Runnable, Callable<Void> {
|
|||
duration,
|
||||
domainsPublished,
|
||||
hostsPublished);
|
||||
logger.infofmt(
|
||||
logger.atInfo().log(
|
||||
"writer.commit() statistics: TLD: %s, dnsWriter: %s, commitStatus: %s, duration: %s, "
|
||||
+ "domainsPublished: %d, domainsRejected: %d, hostsPublished: %d, hostsRejected: %d",
|
||||
tld,
|
||||
|
|
|
@ -35,9 +35,9 @@ import com.google.common.collect.ImmutableSet;
|
|||
import com.google.common.collect.ImmutableSetMultimap;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Ordering;
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.google.common.hash.HashFunction;
|
||||
import com.google.common.hash.Hashing;
|
||||
import com.google.common.logging.FormattingLogger;
|
||||
import google.registry.config.RegistryConfig.Config;
|
||||
import google.registry.dns.DnsConstants.TargetType;
|
||||
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 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.
|
||||
|
@ -134,7 +134,7 @@ public final class ReadDnsQueueAction implements Runnable {
|
|||
ImmutableSet<String> tlds = Registries.getTlds();
|
||||
while (requestedEndTime.isAfterNow()) {
|
||||
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()) {
|
||||
dispatchTasks(ImmutableSet.copyOf(tasks), tlds);
|
||||
}
|
||||
|
@ -220,15 +220,16 @@ public final class ReadDnsQueueAction implements Runnable {
|
|||
private void dispatchTasks(ImmutableSet<TaskHandle> tasks, ImmutableSet<String> tlds) {
|
||||
ClassifiedTasks classifiedTasks = classifyTasks(tasks, tlds);
|
||||
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()) {
|
||||
logger.warningfmt(
|
||||
logger.atWarning().log(
|
||||
"The dns-pull queue has unknown TLDs: %s.", classifiedTasks.unknownTlds());
|
||||
}
|
||||
bucketRefreshItems(classifiedTasks.refreshItemsByTld());
|
||||
if (!classifiedTasks.tasksToKeep().isEmpty()) {
|
||||
logger.warningfmt(
|
||||
logger.atWarning().log(
|
||||
"Keeping %d DNS update tasks in the queue.", classifiedTasks.tasksToKeep().size());
|
||||
}
|
||||
// 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.
|
||||
ImmutableSet<TaskHandle> tasksToDelete =
|
||||
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());
|
||||
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));
|
||||
String tld = params.get(RequestParameters.PARAM_TLD);
|
||||
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)) {
|
||||
classifiedTasksBuilder.tasksToKeepBuilder().add(task);
|
||||
classifiedTasksBuilder.unknownTldsBuilder().add(tld);
|
||||
|
@ -285,12 +287,13 @@ public final class ReadDnsQueueAction implements Runnable {
|
|||
.put(tld, RefreshItem.create(type, name, creationTime));
|
||||
break;
|
||||
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;
|
||||
}
|
||||
}
|
||||
} 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();
|
||||
|
|
|
@ -8,8 +8,9 @@ java_library(
|
|||
name = "writer",
|
||||
srcs = glob(["*.java"]),
|
||||
deps = [
|
||||
"//java/com/google/common/logging:formatting_logger",
|
||||
"@com_google_dagger",
|
||||
"@com_google_flogger",
|
||||
"@com_google_flogger_system_backend",
|
||||
"@com_google_guava",
|
||||
],
|
||||
)
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
package google.registry.dns.writer;
|
||||
|
||||
import com.google.common.logging.FormattingLogger;
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import javax.inject.Inject;
|
||||
|
@ -32,7 +32,7 @@ public final class VoidDnsWriter extends BaseDnsWriter {
|
|||
*/
|
||||
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<>();
|
||||
|
||||
|
@ -51,7 +51,7 @@ public final class VoidDnsWriter extends BaseDnsWriter {
|
|||
|
||||
@Override
|
||||
protected void commitUnchecked() {
|
||||
logger.warningfmt(
|
||||
logger.atWarning().log(
|
||||
"No DnsWriterFactory implementation specified; ignoring names to commit: %s", names);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,6 @@ java_library(
|
|||
name = "clouddns",
|
||||
srcs = glob(["*.java"]),
|
||||
deps = [
|
||||
"//java/com/google/common/logging:formatting_logger",
|
||||
"//java/google/registry/config",
|
||||
"//java/google/registry/dns/writer",
|
||||
"//java/google/registry/model",
|
||||
|
@ -16,6 +15,8 @@ java_library(
|
|||
"@com_google_api_client",
|
||||
"@com_google_apis_google_api_services_dns",
|
||||
"@com_google_dagger",
|
||||
"@com_google_flogger",
|
||||
"@com_google_flogger_system_backend",
|
||||
"@com_google_guava",
|
||||
"@com_google_http_client",
|
||||
"@joda_time",
|
||||
|
|
|
@ -29,7 +29,7 @@ import com.google.common.collect.ImmutableList;
|
|||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
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.util.concurrent.RateLimiter;
|
||||
import google.registry.config.RegistryConfig.Config;
|
||||
|
@ -72,7 +72,7 @@ public class CloudDnsWriter extends BaseDnsWriter {
|
|||
*/
|
||||
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 =
|
||||
ImmutableSet.of("preconditionFailed", "notFound", "alreadyExists");
|
||||
|
||||
|
@ -179,12 +179,12 @@ public class CloudDnsWriter extends BaseDnsWriter {
|
|||
}
|
||||
|
||||
desiredRecords.put(absoluteDomainName, domainRecords.build());
|
||||
logger.finefmt(
|
||||
"Will write %s records for domain %s", domainRecords.build().size(), absoluteDomainName);
|
||||
logger.atFine().log(
|
||||
"Will write %d records for domain %s", domainRecords.build().size(), absoluteDomainName);
|
||||
}
|
||||
|
||||
private void publishSubordinateHost(String hostName) {
|
||||
logger.infofmt("Publishing glue records for %s", hostName);
|
||||
logger.atInfo().log("Publishing glue records for %s", hostName);
|
||||
// Canonicalize name
|
||||
String absoluteHostName = getAbsoluteHostName(hostName);
|
||||
|
||||
|
@ -251,7 +251,7 @@ public class CloudDnsWriter extends BaseDnsWriter {
|
|||
|
||||
// Host not managed by our registry, no need to update DNS.
|
||||
if (!tld.isPresent()) {
|
||||
logger.severefmt("publishHost called for invalid host %s", hostName);
|
||||
logger.atSevere().log("publishHost called for invalid host %s", hostName);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -274,7 +274,7 @@ public class CloudDnsWriter extends BaseDnsWriter {
|
|||
ImmutableMap<String, ImmutableSet<ResourceRecordSet>> desiredRecordsCopy =
|
||||
ImmutableMap.copyOf(desiredRecords);
|
||||
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. */
|
||||
|
@ -324,7 +324,7 @@ public class CloudDnsWriter extends BaseDnsWriter {
|
|||
*/
|
||||
private Map<String, List<ResourceRecordSet>> getResourceRecordsForDomains(
|
||||
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
|
||||
// threading.
|
||||
return ImmutableMap.copyOf(
|
||||
|
@ -373,12 +373,12 @@ public class CloudDnsWriter extends BaseDnsWriter {
|
|||
// the result.
|
||||
ImmutableSet<ResourceRecordSet> intersection =
|
||||
Sets.intersection(additions, deletions).immutableCopy();
|
||||
logger.infofmt(
|
||||
"There are %s common items out of the %s items in 'additions' and %s items in 'deletions'",
|
||||
logger.atInfo().log(
|
||||
"There are %d common items out of the %d items in 'additions' and %d items in 'deletions'",
|
||||
intersection.size(), additions.size(), deletions.size());
|
||||
// Exit early if we have nothing to update - dnsConnection doesn't work on empty changes
|
||||
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;
|
||||
}
|
||||
Change change =
|
||||
|
|
|
@ -29,7 +29,7 @@ import com.google.common.collect.ImmutableList;
|
|||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
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.util.concurrent.RateLimiter;
|
||||
import google.registry.config.RegistryConfig.Config;
|
||||
|
@ -91,7 +91,7 @@ public class MultiplyingCloudDnsWriter extends BaseDnsWriter {
|
|||
*/
|
||||
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 =
|
||||
ImmutableSet.of("preconditionFailed", "notFound", "alreadyExists");
|
||||
|
||||
|
@ -199,13 +199,13 @@ public class MultiplyingCloudDnsWriter extends BaseDnsWriter {
|
|||
}
|
||||
|
||||
desiredRecords.put(absoluteDomainName, domainRecords.build());
|
||||
logger.finefmt(
|
||||
"Will write %s records for domain %s", domainRecords.build().size(), absoluteDomainName);
|
||||
logger.atFine().log(
|
||||
"Will write %d records for domain %s", domainRecords.build().size(), absoluteDomainName);
|
||||
}
|
||||
}
|
||||
|
||||
private void publishSubordinateHost(String hostName) {
|
||||
logger.infofmt("Publishing glue records for %s", hostName);
|
||||
logger.atInfo().log("Publishing glue records for %s", hostName);
|
||||
// Canonicalize name
|
||||
String absoluteHostName = getAbsoluteHostName(hostName);
|
||||
|
||||
|
@ -272,7 +272,7 @@ public class MultiplyingCloudDnsWriter extends BaseDnsWriter {
|
|||
|
||||
// Host not managed by our registry, no need to update DNS.
|
||||
if (!tld.isPresent()) {
|
||||
logger.severefmt("publishHost called for invalid host %s", hostName);
|
||||
logger.atSevere().log("publishHost called for invalid host %s", hostName);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -303,7 +303,7 @@ public class MultiplyingCloudDnsWriter extends BaseDnsWriter {
|
|||
ImmutableMap<String, ImmutableSet<ResourceRecordSet>> desiredRecordsCopy =
|
||||
ImmutableMap.copyOf(desiredRecords);
|
||||
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(
|
||||
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
|
||||
// threading.
|
||||
return ImmutableMap.copyOf(
|
||||
|
@ -406,12 +406,12 @@ public class MultiplyingCloudDnsWriter extends BaseDnsWriter {
|
|||
// the result.
|
||||
ImmutableSet<ResourceRecordSet> intersection =
|
||||
Sets.intersection(additions, deletions).immutableCopy();
|
||||
logger.infofmt(
|
||||
"There are %s common items out of the %s items in 'additions' and %s items in 'deletions'",
|
||||
logger.atInfo().log(
|
||||
"There are %d common items out of the %d items in 'additions' and %d items in 'deletions'",
|
||||
intersection.size(), additions.size(), deletions.size());
|
||||
// Exit early if we have nothing to update - dnsConnection doesn't work on empty changes
|
||||
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;
|
||||
}
|
||||
Change change =
|
||||
|
|
|
@ -8,7 +8,6 @@ java_library(
|
|||
name = "export",
|
||||
srcs = glob(["*.java"]),
|
||||
deps = [
|
||||
"//java/com/google/common/logging:formatting_logger",
|
||||
"//java/google/registry/bigquery",
|
||||
"//java/google/registry/config",
|
||||
"//java/google/registry/gcs",
|
||||
|
@ -30,6 +29,8 @@ java_library(
|
|||
"@com_google_appengine_tools_appengine_mapreduce",
|
||||
"@com_google_code_findbugs_jsr305",
|
||||
"@com_google_dagger",
|
||||
"@com_google_flogger",
|
||||
"@com_google_flogger_system_backend",
|
||||
"@com_google_guava",
|
||||
"@com_google_http_client",
|
||||
"@com_googlecode_json_simple",
|
||||
|
|
|
@ -25,7 +25,7 @@ import com.google.appengine.api.taskqueue.Queue;
|
|||
import com.google.appengine.api.taskqueue.TaskHandle;
|
||||
import com.google.appengine.api.taskqueue.TaskOptions;
|
||||
import com.google.appengine.api.taskqueue.TaskOptions.Method;
|
||||
import com.google.common.logging.FormattingLogger;
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import dagger.Lazy;
|
||||
import google.registry.request.Action;
|
||||
import google.registry.request.Header;
|
||||
|
@ -54,7 +54,7 @@ import org.joda.time.Duration;
|
|||
)
|
||||
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 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);
|
||||
}
|
||||
String taskName = taskQueueUtils.enqueue(getQueue(chainedQueueName.get()), task).getName();
|
||||
logger.infofmt(
|
||||
logger.atInfo().log(
|
||||
"Added chained task %s for %s to queue %s: %s",
|
||||
taskName,
|
||||
task.getUrl(),
|
||||
chainedQueueName.get(),
|
||||
task.toString());
|
||||
taskName, task.getUrl(), chainedQueueName.get(), task);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -106,7 +103,7 @@ public class BigqueryPollJobAction implements Runnable {
|
|||
job = bigquery.jobs().get(projectId, jobId).execute();
|
||||
} catch (IOException e) {
|
||||
// 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
|
||||
// code and the task will be retried.
|
||||
|
@ -116,10 +113,10 @@ public class BigqueryPollJobAction implements Runnable {
|
|||
|
||||
// Check if the job ended with an error.
|
||||
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;
|
||||
}
|
||||
logger.infofmt("Bigquery job succeeded - %s", jobRefString);
|
||||
logger.atInfo().log("Bigquery job succeeded - %s", jobRefString);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
package google.registry.export;
|
||||
|
||||
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.request.Action.Method.GET;
|
||||
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.collect.ImmutableSet;
|
||||
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.request.Action;
|
||||
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. */
|
||||
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 @RequestMethod Action.Method requestMethod;
|
||||
|
@ -133,7 +132,7 @@ public class CheckSnapshotAction implements Runnable {
|
|||
: backup.getStartTime().toString("YYYYMMdd_HHmmss");
|
||||
// Log a warning if kindsToLoad is not a subset of the exported snapshot kinds.
|
||||
if (!backup.getKinds().containsAll(kindsToLoad)) {
|
||||
logger.warningfmt(
|
||||
logger.atWarning().log(
|
||||
"Kinds to load included non-exported kinds: %s",
|
||||
Sets.difference(kindsToLoad, backup.getKinds()));
|
||||
}
|
||||
|
@ -147,7 +146,7 @@ public class CheckSnapshotAction implements Runnable {
|
|||
enqueueLoadSnapshotTask(snapshotId, backup.getGcsFilename().get(), exportedKindsToLoad);
|
||||
message += "BigQuery load task enqueued";
|
||||
}
|
||||
logger.info(message);
|
||||
logger.atInfo().log(message);
|
||||
response.setPayload(message);
|
||||
}
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ import com.google.appengine.tools.mapreduce.ReducerInput;
|
|||
import com.google.common.base.Joiner;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
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 google.registry.config.RegistryConfig.Config;
|
||||
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)
|
||||
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;
|
||||
|
||||
@Inject MapreduceRunner mrRunner;
|
||||
|
@ -72,7 +72,7 @@ public class ExportDomainListsAction implements Runnable {
|
|||
@Override
|
||||
public void run() {
|
||||
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
|
||||
.setJobName("Export domain lists")
|
||||
.setModuleName("backend")
|
||||
|
@ -131,7 +131,7 @@ public class ExportDomainListsAction implements Runnable {
|
|||
try {
|
||||
Registry registry = Registry.get(tld);
|
||||
if (registry.getDriveFolderId() == null) {
|
||||
logger.infofmt(
|
||||
logger.atInfo().log(
|
||||
"Skipping registered domains export for TLD %s because Drive folder isn't specified",
|
||||
tld);
|
||||
} else {
|
||||
|
@ -141,12 +141,13 @@ public class ExportDomainListsAction implements Runnable {
|
|||
EXPORT_MIME_TYPE,
|
||||
registry.getDriveFolderId(),
|
||||
domains.getBytes(UTF_8));
|
||||
logger.infofmt(
|
||||
logger.atInfo().log(
|
||||
"Exporting registered domains succeeded for TLD %s, response was: %s",
|
||||
tld, resultMsg);
|
||||
}
|
||||
} 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");
|
||||
}
|
||||
|
@ -159,7 +160,8 @@ public class ExportDomainListsAction implements Runnable {
|
|||
Writer osWriter = new OutputStreamWriter(gcsOutput, UTF_8)) {
|
||||
osWriter.write(domains);
|
||||
} 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");
|
||||
}
|
||||
|
@ -168,7 +170,7 @@ public class ExportDomainListsAction implements Runnable {
|
|||
public void reduce(String tld, ReducerInput<String> fqdns) {
|
||||
ImmutableList<String> domains = ImmutableList.sortedCopyOf(() -> fqdns);
|
||||
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);
|
||||
exportToDrive(tld, domainsList);
|
||||
}
|
||||
|
|
|
@ -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_OK;
|
||||
|
||||
import com.google.common.logging.FormattingLogger;
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.google.common.net.MediaType;
|
||||
import google.registry.model.registry.Registry;
|
||||
import google.registry.request.Action;
|
||||
|
@ -40,7 +40,7 @@ import javax.inject.Inject;
|
|||
)
|
||||
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 String RESERVED_TERMS_FILENAME = "reserved_terms.txt";
|
||||
|
||||
|
@ -65,10 +65,10 @@ public class ExportReservedTermsAction implements Runnable {
|
|||
String resultMsg;
|
||||
if (registry.getReservedLists().isEmpty() && isNullOrEmpty(registry.getDriveFolderId())) {
|
||||
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) {
|
||||
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);
|
||||
} else {
|
||||
resultMsg = driveConnection.createOrUpdateFile(
|
||||
|
@ -76,8 +76,8 @@ public class ExportReservedTermsAction implements Runnable {
|
|||
EXPORT_MIME_TYPE,
|
||||
registry.getDriveFolderId(),
|
||||
exportUtils.exportReservedTerms(registry).getBytes(UTF_8));
|
||||
logger.infofmt("Exporting reserved terms succeeded for TLD %s, response was: %s",
|
||||
tld, resultMsg);
|
||||
logger.atInfo().log(
|
||||
"Exporting reserved terms succeeded for TLD %s, response was: %s", tld, resultMsg);
|
||||
}
|
||||
response.setStatus(SC_OK);
|
||||
response.setPayload(resultMsg);
|
||||
|
|
|
@ -17,7 +17,7 @@ package google.registry.export;
|
|||
import static google.registry.export.CheckSnapshotAction.enqueuePollTask;
|
||||
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.request.Action;
|
||||
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. */
|
||||
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 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.
|
||||
enqueuePollTask(snapshotName, ExportConstants.getReportingKinds());
|
||||
String message = "Datastore backup started with name: " + snapshotName;
|
||||
logger.info(message);
|
||||
logger.atInfo().log(message);
|
||||
response.setPayload(message);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,7 +17,6 @@ package google.registry.export;
|
|||
import static com.google.appengine.api.taskqueue.QueueFactory.getQueue;
|
||||
import static com.google.common.base.MoreObjects.firstNonNull;
|
||||
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.request.Action.Method.POST;
|
||||
|
||||
|
@ -34,7 +33,7 @@ import com.google.common.base.Joiner;
|
|||
import com.google.common.base.Splitter;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
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.BigqueryUtils.SourceFormat;
|
||||
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 PATH = "/_dr/task/loadSnapshot"; // See web.xml.
|
||||
|
||||
private static final FormattingLogger logger = getLoggerForCallerClass();
|
||||
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
|
||||
|
||||
@Inject BigqueryFactory bigqueryFactory;
|
||||
@Inject BigqueryPollJobEnqueuer bigqueryPollEnqueuer;
|
||||
|
@ -96,9 +95,9 @@ public class LoadSnapshotAction implements Runnable {
|
|||
try {
|
||||
String message =
|
||||
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) {
|
||||
logger.severe(e, "Error loading snapshot");
|
||||
logger.atSevere().withCause(e).log("Error loading snapshot");
|
||||
if (e instanceof IllegalArgumentException) {
|
||||
throw new BadRequestException("Error calling load snapshot: " + e.getMessage(), e);
|
||||
} else {
|
||||
|
@ -114,7 +113,7 @@ public class LoadSnapshotAction implements Runnable {
|
|||
DateTime now = clock.nowUtc();
|
||||
String loadMessage =
|
||||
String.format("Loading Datastore snapshot %s from %s...", snapshotId, gcsFilename);
|
||||
logger.info(loadMessage);
|
||||
logger.atInfo().log(loadMessage);
|
||||
StringBuilder builder = new StringBuilder(loadMessage + "\n");
|
||||
builder.append("Load jobs:\n");
|
||||
|
||||
|
@ -136,7 +135,7 @@ public class LoadSnapshotAction implements Runnable {
|
|||
getQueue(UpdateSnapshotViewAction.QUEUE));
|
||||
|
||||
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();
|
||||
}
|
||||
|
|
|
@ -20,8 +20,8 @@ import static google.registry.util.PreconditionsUtils.checkArgumentPresent;
|
|||
|
||||
import com.google.appengine.tools.cloudstorage.GcsFilename;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.google.common.io.ByteStreams;
|
||||
import com.google.common.logging.FormattingLogger;
|
||||
import com.google.common.net.MediaType;
|
||||
import google.registry.gcs.GcsUtils;
|
||||
import google.registry.model.registrar.Registrar;
|
||||
|
@ -52,7 +52,7 @@ import javax.inject.Inject;
|
|||
@Deprecated
|
||||
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. */
|
||||
private static final MediaType REPORT_MIME_TYPE = MediaType.CSV_UTF_8;
|
||||
|
@ -91,7 +91,7 @@ public final class PublishDetailReportAction implements Runnable, JsonAction {
|
|||
@Override
|
||||
public Map<String, Object> handleJsonRequest(Map<String, ?> json) {
|
||||
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);
|
||||
Registrar registrar =
|
||||
checkArgumentPresent(
|
||||
|
@ -111,11 +111,9 @@ public final class PublishDetailReportAction implements Runnable, JsonAction {
|
|||
REPORT_MIME_TYPE,
|
||||
driveFolderId,
|
||||
ByteStreams.toByteArray(input));
|
||||
logger.infofmt("Published detail report for %s to folder %s using GCS file gs://%s/%s.",
|
||||
registrarId,
|
||||
driveFolderId,
|
||||
gcsBucketName,
|
||||
gcsObjectName);
|
||||
logger.atInfo().log(
|
||||
"Published detail report for %s to folder %s using GCS file gs://%s/%s.",
|
||||
registrarId, driveFolderId, gcsBucketName, gcsObjectName);
|
||||
return ImmutableMap.of("driveId", driveId);
|
||||
} catch (FileNotFoundException e) {
|
||||
throw new IllegalArgumentException(e.getMessage(), e);
|
||||
|
|
|
@ -27,7 +27,7 @@ import com.google.common.collect.ImmutableList;
|
|||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.Sets;
|
||||
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.groups.GroupsConnection;
|
||||
import google.registry.groups.GroupsConnection.Role;
|
||||
|
@ -58,7 +58,7 @@ import javax.inject.Inject;
|
|||
)
|
||||
public final class SyncGroupMembersAction implements Runnable {
|
||||
|
||||
private static final FormattingLogger logger = FormattingLogger.getLoggerForCallerClass();
|
||||
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
|
||||
|
||||
private enum Result {
|
||||
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.") {
|
||||
@Override
|
||||
protected void log(Throwable cause) {
|
||||
logger.severe(cause, message);
|
||||
logger.atSevere().withCause(cause).log(message);
|
||||
}};
|
||||
|
||||
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. */
|
||||
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);
|
||||
resultsBuilder.put(registrar, Optional.empty());
|
||||
} catch (Throwable e) {
|
||||
logger.severe(e, e.getMessage());
|
||||
logger.atSevere().withCause(e).log(e.getMessage());
|
||||
resultsBuilder.put(registrar, Optional.of(e));
|
||||
}
|
||||
}
|
||||
|
@ -193,10 +193,9 @@ public final class SyncGroupMembersAction implements Runnable {
|
|||
totalRemoved++;
|
||||
}
|
||||
}
|
||||
logger.infofmt("Successfully synced contacts for registrar %s: added %d and removed %d",
|
||||
registrar.getClientId(),
|
||||
totalAdded,
|
||||
totalRemoved);
|
||||
logger.atInfo().log(
|
||||
"Successfully synced contacts for registrar %s: added %d and removed %d",
|
||||
registrar.getClientId(), totalAdded, totalRemoved);
|
||||
} catch (IOException e) {
|
||||
// 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",
|
||||
|
|
|
@ -23,7 +23,7 @@ import com.google.api.services.bigquery.model.TableReference;
|
|||
import com.google.api.services.bigquery.model.ViewDefinition;
|
||||
import com.google.appengine.api.taskqueue.TaskOptions;
|
||||
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.config.RegistryConfig.Config;
|
||||
import google.registry.request.Action;
|
||||
|
@ -52,7 +52,7 @@ public class UpdateSnapshotViewAction implements Runnable {
|
|||
|
||||
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
|
||||
@Parameter(UPDATE_SNAPSHOT_DATASET_ID_PARAM)
|
||||
|
@ -101,8 +101,8 @@ public class UpdateSnapshotViewAction implements Runnable {
|
|||
datasetId, tableId, kindName, STANDARD_LATEST_SNAPSHOT_DATASET, standardTemplate, false);
|
||||
|
||||
} catch (Throwable e) {
|
||||
logger.severefmt(e, "Could not update snapshot view for table %s", tableId);
|
||||
throw new InternalServerErrorException("Error in update snapshot view action");
|
||||
throw new InternalServerErrorException(
|
||||
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)
|
||||
.build())));
|
||||
|
||||
logger.infofmt(
|
||||
logger.atInfo().log(
|
||||
"Updated view [%s:%s.%s] to point at snapshot table [%s:%s.%s].",
|
||||
projectId, viewDataset, kindName, projectId, sourceDatasetId, sourceTableId);
|
||||
}
|
||||
|
@ -150,8 +150,8 @@ public class UpdateSnapshotViewAction implements Runnable {
|
|||
if (e.getDetails().getCode() == 404) {
|
||||
bigquery.tables().insert(ref.getProjectId(), ref.getDatasetId(), table).execute();
|
||||
} else {
|
||||
logger.warningfmt(
|
||||
e, "UpdateSnapshotViewAction failed, caught exception %s", e.getDetails());
|
||||
logger.atWarning().withCause(e).log(
|
||||
"UpdateSnapshotViewAction failed, caught exception %s", e.getDetails());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,6 @@ java_library(
|
|||
name = "sheet",
|
||||
srcs = glob(["*.java"]),
|
||||
deps = [
|
||||
"//java/com/google/common/logging:formatting_logger",
|
||||
"//java/google/registry/config",
|
||||
"//java/google/registry/model",
|
||||
"//java/google/registry/request",
|
||||
|
@ -21,6 +20,8 @@ java_library(
|
|||
"@com_google_appengine_api_1_0_sdk",
|
||||
"@com_google_code_findbugs_jsr305",
|
||||
"@com_google_dagger",
|
||||
"@com_google_flogger",
|
||||
"@com_google_flogger_system_backend",
|
||||
"@com_google_guava",
|
||||
"@com_google_http_client",
|
||||
"@javax_servlet_api",
|
||||
|
|
|
@ -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.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.logging.FormattingLogger;
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
@ -34,7 +34,7 @@ import javax.inject.Inject;
|
|||
/** Generic data synchronization utility for Google Spreadsheets. */
|
||||
class SheetSynchronizer {
|
||||
|
||||
private static final FormattingLogger logger = FormattingLogger.getLoggerForCallerClass();
|
||||
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
|
||||
|
||||
private static final String SHEET_NAME = "Registrars";
|
||||
|
||||
|
@ -117,7 +117,7 @@ class SheetSynchronizer {
|
|||
BatchUpdateValuesResponse response =
|
||||
sheetsService.spreadsheets().values().batchUpdate(spreadsheetId, updateRequest).execute();
|
||||
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
|
||||
|
@ -139,7 +139,7 @@ class SheetSynchronizer {
|
|||
.setValueInputOption("RAW")
|
||||
.setInsertDataOption("INSERT_ROWS")
|
||||
.execute();
|
||||
logger.infofmt(
|
||||
logger.atInfo().log(
|
||||
"Appended %d rows to range %s",
|
||||
data.size() - originalVals.size(), appendResponse.getTableRange());
|
||||
// Clear the extra rows if necessary
|
||||
|
@ -154,7 +154,7 @@ class SheetSynchronizer {
|
|||
getRowRange(data.size(), originalVals.size()),
|
||||
new ClearValuesRequest())
|
||||
.execute();
|
||||
logger.infofmt(
|
||||
logger.atInfo().log(
|
||||
"Cleared %d rows from range %s",
|
||||
originalVals.size() - data.size(), clearResponse.getClearedRange());
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ import com.google.appengine.api.modules.ModulesService;
|
|||
import com.google.appengine.api.modules.ModulesServiceFactory;
|
||||
import com.google.appengine.api.taskqueue.TaskHandle;
|
||||
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.request.Action;
|
||||
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.") {
|
||||
@Override
|
||||
protected void log(Exception cause) {
|
||||
logger.warning(cause, message);
|
||||
logger.atWarning().withCause(cause).log(message);
|
||||
}},
|
||||
FAILED(SC_INTERNAL_SERVER_ERROR, "Spreadsheet synchronization failed") {
|
||||
@Override
|
||||
protected void log(Exception cause) {
|
||||
logger.severe(cause, message);
|
||||
logger.atSevere().withCause(cause).log(message);
|
||||
}};
|
||||
|
||||
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. */
|
||||
protected void log(@Nullable Exception cause) {
|
||||
logger.info(cause, message);
|
||||
logger.atInfo().withCause(cause).log(message);
|
||||
}
|
||||
|
||||
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";
|
||||
private static final String QUEUE = "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
|
||||
private static ModulesService modulesService = ModulesServiceFactory.getModulesService();
|
||||
|
|
|
@ -23,7 +23,6 @@ java_library(
|
|||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
":soy_java_wrappers",
|
||||
"//java/com/google/common/logging:formatting_logger",
|
||||
"//java/google/registry/config",
|
||||
"//java/google/registry/dns",
|
||||
"//java/google/registry/model",
|
||||
|
@ -40,6 +39,8 @@ java_library(
|
|||
"@com_google_auto_value",
|
||||
"@com_google_code_findbugs_jsr305",
|
||||
"@com_google_dagger",
|
||||
"@com_google_flogger",
|
||||
"@com_google_flogger_system_backend",
|
||||
"@com_google_guava",
|
||||
"@com_google_monitoring_client_metrics",
|
||||
"@com_googlecode_json_simple",
|
||||
|
|
|
@ -29,7 +29,7 @@ import static org.json.simple.JSONValue.toJSONString;
|
|||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
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.MediaType;
|
||||
import com.google.template.soy.SoyFileSet;
|
||||
|
@ -64,7 +64,7 @@ import javax.servlet.http.HttpServletRequest;
|
|||
)
|
||||
public class CheckApiAction implements Runnable {
|
||||
|
||||
private static final FormattingLogger logger = FormattingLogger.getLoggerForCallerClass();
|
||||
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
|
||||
|
||||
private static final SoyTofu TOFU =
|
||||
SoyFileSet.builder().add(getResource(DomainCheckFeeEppSoyInfo.class,
|
||||
|
@ -138,7 +138,7 @@ public class CheckApiAction implements Runnable {
|
|||
}
|
||||
return builder.build();
|
||||
} catch (Exception e) {
|
||||
logger.warning(e, "Unknown error");
|
||||
logger.atWarning().withCause(e).log("Unknown error");
|
||||
return fail("Invalid request");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
package google.registry.flows;
|
||||
|
||||
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 google.registry.flows.EppXmlTransformer.unmarshal;
|
||||
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.Strings;
|
||||
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.model.eppcommon.Trid;
|
||||
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.EppMetric;
|
||||
import java.util.Optional;
|
||||
import java.util.logging.Level;
|
||||
import javax.inject.Inject;
|
||||
import org.json.simple.JSONValue;
|
||||
|
||||
|
@ -46,7 +46,8 @@ import org.json.simple.JSONValue;
|
|||
*/
|
||||
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 EppMetric.Builder eppMetricBuilder;
|
||||
|
@ -71,25 +72,27 @@ public final class EppController {
|
|||
eppInput = unmarshal(EppInput.class, inputXmlBytes);
|
||||
} catch (EppException e) {
|
||||
// Log the unmarshalling error, with the raw bytes (in base64) to help with debugging.
|
||||
if (logger.isLoggable(Level.INFO)) {
|
||||
logger.infofmt(
|
||||
e,
|
||||
"EPP request XML unmarshalling failed - \"%s\":\n%s\n%s\n%s\n%s",
|
||||
e.getMessage(),
|
||||
JSONValue.toJSONString(
|
||||
ImmutableMap.<String, Object>of(
|
||||
"clientId",
|
||||
nullToEmpty(sessionMetadata.getClientId()),
|
||||
"resultCode",
|
||||
e.getResult().getCode().code,
|
||||
"resultMessage",
|
||||
e.getResult().getCode().msg,
|
||||
"xmlBytes",
|
||||
base64().encode(inputXmlBytes))),
|
||||
Strings.repeat("=", 40),
|
||||
new String(inputXmlBytes, UTF_8).trim(), // Charset decoding failures are swallowed.
|
||||
Strings.repeat("=", 40));
|
||||
}
|
||||
logger.atInfo().withCause(e).log(
|
||||
"EPP request XML unmarshalling failed - \"%s\":\n%s\n%s\n%s\n%s",
|
||||
e.getMessage(),
|
||||
lazy(
|
||||
() ->
|
||||
JSONValue.toJSONString(
|
||||
ImmutableMap.<String, Object>of(
|
||||
"clientId",
|
||||
nullToEmpty(sessionMetadata.getClientId()),
|
||||
"resultCode",
|
||||
e.getResult().getCode().code,
|
||||
"resultMessage",
|
||||
e.getResult().getCode().msg,
|
||||
"xmlBytes",
|
||||
base64().encode(inputXmlBytes)))),
|
||||
LOG_SEPARATOR,
|
||||
lazy(
|
||||
() ->
|
||||
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.
|
||||
eppMetricBuilder.setStatus(e.getResult().getCode());
|
||||
return getErrorResponse(
|
||||
|
@ -133,12 +136,12 @@ public final class EppController {
|
|||
} catch (EppException | EppExceptionInProviderException e) {
|
||||
// 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.
|
||||
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());
|
||||
return getErrorResponse(eppEx.getResult(), flowComponent.trid());
|
||||
} catch (Throwable e) {
|
||||
// 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());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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_OK;
|
||||
|
||||
import com.google.common.logging.FormattingLogger;
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.google.common.net.MediaType;
|
||||
import google.registry.model.eppoutput.EppOutput;
|
||||
import google.registry.request.Response;
|
||||
|
@ -32,7 +32,7 @@ public class EppRequestHandler {
|
|||
private static final MediaType APPLICATION_EPP_XML =
|
||||
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 Response response;
|
||||
|
@ -71,7 +71,7 @@ public class EppRequestHandler {
|
|||
response.setHeader("Epp-Session", "close");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.warning(e, "handleEppCommand general exception");
|
||||
logger.atWarning().withCause(e).log("handleEppCommand general exception");
|
||||
response.setStatus(SC_BAD_REQUEST);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
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.Method;
|
||||
import google.registry.request.Payload;
|
||||
|
@ -33,7 +33,7 @@ import javax.servlet.http.HttpSession;
|
|||
)
|
||||
public class EppTlsAction implements Runnable {
|
||||
|
||||
private static final FormattingLogger logger = FormattingLogger.getLoggerForCallerClass();
|
||||
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
|
||||
|
||||
@Inject @Payload byte[] inputXmlBytes;
|
||||
@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
|
||||
// GFE, which is the expectation of this servlet. The value is unused.
|
||||
if (!tlsCredentials.hasSni()) {
|
||||
logger.warning("Request did not include required SNI header.");
|
||||
logger.atWarning().log("Request did not include required SNI header.");
|
||||
}
|
||||
eppRequestHandler.executeEpp(
|
||||
new HttpSessionMetadata(session),
|
||||
|
|
|
@ -22,7 +22,7 @@ import static java.nio.charset.StandardCharsets.UTF_8;
|
|||
import com.google.common.annotations.VisibleForTesting;
|
||||
import com.google.common.base.Throwables;
|
||||
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.ParameterValueSyntaxErrorException;
|
||||
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. */
|
||||
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.
|
||||
private static final ImmutableList<String> SCHEMAS = ImmutableList.of(
|
||||
|
@ -130,8 +130,8 @@ public class EppXmlTransformer {
|
|||
try {
|
||||
byte[] lenient = EppXmlTransformer.marshal(eppOutput, LENIENT);
|
||||
// Marshaling worked even though the results didn't validate against the schema.
|
||||
logger.severefmt(
|
||||
e, "Result marshaled but did not validate: %s", new String(lenient, UTF_8));
|
||||
logger.atSevere().withCause(e).log(
|
||||
"Result marshaled but did not validate: %s", new String(lenient, UTF_8));
|
||||
return lenient;
|
||||
} catch (XmlException e2) {
|
||||
throw new RuntimeException(e2); // Failing to marshal at all is not recoverable.
|
||||
|
|
|
@ -22,7 +22,7 @@ import static google.registry.model.eppcommon.ProtocolDefinition.ServiceExtensio
|
|||
import com.google.common.base.Joiner;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
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.SyntaxErrorException;
|
||||
import google.registry.flows.EppException.UnimplementedExtensionException;
|
||||
|
@ -45,7 +45,7 @@ import javax.inject.Inject;
|
|||
*/
|
||||
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. */
|
||||
private static final ImmutableSet<String> UNDECLARED_URIS_BLACKLIST = FEE_EXTENSION_URIS;
|
||||
|
@ -99,11 +99,9 @@ public final class ExtensionManager {
|
|||
if (!undeclaredUrisThatError.isEmpty()) {
|
||||
throw new UndeclaredServiceExtensionException(undeclaredUrisThatError);
|
||||
}
|
||||
logger.infofmt(
|
||||
logger.atInfo().log(
|
||||
"Client %s is attempting to run %s without declaring URIs %s on login",
|
||||
clientId,
|
||||
flowClass.getSimpleName(),
|
||||
undeclaredUris);
|
||||
clientId, flowClass.getSimpleName(), undeclaredUris);
|
||||
}
|
||||
|
||||
private void checkForRestrictedExtensions(
|
||||
|
@ -155,7 +153,7 @@ public final class ExtensionManager {
|
|||
ImmutableSet<Class<? extends CommandExtension>> unimplementedExtensions =
|
||||
unimplementedExtensionsBuilder.build();
|
||||
if (!unimplementedExtensions.isEmpty()) {
|
||||
logger.infofmt("Unimplemented extensions: %s", unimplementedExtensions);
|
||||
logger.atInfo().log("Unimplemented extensions: %s", unimplementedExtensions);
|
||||
throw new UnimplementedExtensionException();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,14 +24,13 @@ import com.google.common.collect.ImmutableList;
|
|||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
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.InputXml;
|
||||
import google.registry.flows.annotations.ReportingSpec;
|
||||
import google.registry.model.eppcommon.Trid;
|
||||
import google.registry.model.eppinput.EppInput;
|
||||
import java.util.Optional;
|
||||
import java.util.logging.Level;
|
||||
import javax.inject.Inject;
|
||||
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 FormattingLogger logger = FormattingLogger.getLoggerForCallerClass();
|
||||
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
|
||||
|
||||
@Inject Trid trid;
|
||||
@Inject @ClientId String clientId;
|
||||
|
@ -65,44 +64,38 @@ public class FlowReporter {
|
|||
public void recordToLogs() {
|
||||
// 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.
|
||||
if (logger.isLoggable(Level.INFO)) {
|
||||
logger.infofmt(
|
||||
"%s: %s",
|
||||
EPPINPUT_LOG_SIGNATURE,
|
||||
JSONValue.toJSONString(
|
||||
ImmutableMap.<String, Object>of(
|
||||
"xml", prettyPrint(inputXmlBytes),
|
||||
"xmlBytes", base64().encode(inputXmlBytes))));
|
||||
}
|
||||
logger.atInfo().log(
|
||||
"%s: %s",
|
||||
EPPINPUT_LOG_SIGNATURE,
|
||||
JSONValue.toJSONString(
|
||||
ImmutableMap.<String, Object>of(
|
||||
"xml", prettyPrint(inputXmlBytes),
|
||||
"xmlBytes", base64().encode(inputXmlBytes))));
|
||||
// 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 overflow into multiple log entries, breaking routine parsing of the JSON format).
|
||||
String singleTargetId = eppInput.getSingleTargetId().orElse("");
|
||||
ImmutableList<String> targetIds = eppInput.getTargetIds();
|
||||
if (logger.isLoggable(Level.INFO)) {
|
||||
logger.infofmt(
|
||||
"%s: %s",
|
||||
METADATA_LOG_SIGNATURE,
|
||||
JSONValue.toJSONString(
|
||||
new ImmutableMap.Builder<String, Object>()
|
||||
.put("serverTrid", trid.getServerTransactionId())
|
||||
.put("clientId", clientId)
|
||||
.put("commandType", eppInput.getCommandType())
|
||||
.put("resourceType", eppInput.getResourceType().orElse(""))
|
||||
.put("flowClassName", flowClass.getSimpleName())
|
||||
.put("targetId", singleTargetId)
|
||||
.put("targetIds", targetIds)
|
||||
.put(
|
||||
"tld",
|
||||
eppInput.isDomainResourceType() ? extractTld(singleTargetId).orElse("") : "")
|
||||
.put(
|
||||
"tlds",
|
||||
eppInput.isDomainResourceType()
|
||||
? extractTlds(targetIds).asList()
|
||||
: EMPTY_LIST)
|
||||
.put("icannActivityReportField", extractActivityReportField(flowClass))
|
||||
.build()));
|
||||
}
|
||||
logger.atInfo().log(
|
||||
"%s: %s",
|
||||
METADATA_LOG_SIGNATURE,
|
||||
JSONValue.toJSONString(
|
||||
new ImmutableMap.Builder<String, Object>()
|
||||
.put("serverTrid", trid.getServerTransactionId())
|
||||
.put("clientId", clientId)
|
||||
.put("commandType", eppInput.getCommandType())
|
||||
.put("resourceType", eppInput.getResourceType().orElse(""))
|
||||
.put("flowClassName", flowClass.getSimpleName())
|
||||
.put("targetId", singleTargetId)
|
||||
.put("targetIds", targetIds)
|
||||
.put(
|
||||
"tld",
|
||||
eppInput.isDomainResourceType() ? extractTld(singleTargetId).orElse("") : "")
|
||||
.put(
|
||||
"tlds",
|
||||
eppInput.isDomainResourceType() ? extractTlds(targetIds).asList() : EMPTY_LIST)
|
||||
.put("icannActivityReportField", extractActivityReportField(flowClass))
|
||||
.build()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -18,7 +18,7 @@ import static google.registry.model.ofy.ObjectifyService.ofy;
|
|||
import static google.registry.xml.XmlTransformer.prettyPrint;
|
||||
|
||||
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.DryRun;
|
||||
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.eppoutput.EppOutput;
|
||||
import google.registry.monitoring.whitebox.EppMetric;
|
||||
import java.util.logging.Level;
|
||||
import javax.inject.Inject;
|
||||
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 FormattingLogger logger = FormattingLogger.getLoggerForCallerClass();
|
||||
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
|
||||
|
||||
@Inject @ClientId String clientId;
|
||||
@Inject TransportCredentials credentials;
|
||||
|
@ -57,18 +56,16 @@ public class FlowRunner {
|
|||
public EppOutput run(final EppMetric.Builder eppMetricBuilder) throws EppException {
|
||||
String prettyXml = prettyPrint(inputXmlBytes);
|
||||
|
||||
if (logger.isLoggable(Level.INFO)) {
|
||||
logger.infofmt(
|
||||
COMMAND_LOG_FORMAT,
|
||||
trid.getServerTransactionId(),
|
||||
clientId,
|
||||
sessionMetadata,
|
||||
prettyXml.replace("\n", "\n\t"),
|
||||
credentials,
|
||||
eppRequestSource,
|
||||
isDryRun ? "DRY_RUN" : "LIVE",
|
||||
isSuperuser ? "SUPERUSER" : "NORMAL");
|
||||
}
|
||||
logger.atInfo().log(
|
||||
COMMAND_LOG_FORMAT,
|
||||
trid.getServerTransactionId(),
|
||||
clientId,
|
||||
sessionMetadata,
|
||||
prettyXml.replace("\n", "\n\t"),
|
||||
credentials,
|
||||
eppRequestSource,
|
||||
isDryRun ? "DRY_RUN" : "LIVE",
|
||||
isSuperuser ? "SUPERUSER" : "NORMAL");
|
||||
// Record flow info to the GAE request logs for reporting purposes if it's not a dry run.
|
||||
if (!isDryRun) {
|
||||
flowReporter.recordToLogs();
|
||||
|
|
|
@ -21,7 +21,7 @@ import static google.registry.request.RequestParameters.extractRequiredHeader;
|
|||
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
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.InetAddresses;
|
||||
import dagger.Module;
|
||||
|
@ -55,7 +55,7 @@ import javax.servlet.http.HttpServletRequest;
|
|||
*/
|
||||
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 sni;
|
||||
|
@ -100,7 +100,7 @@ public class TlsCredentials implements TransportCredentials {
|
|||
private void validateIp(Registrar registrar) throws AuthenticationErrorException {
|
||||
ImmutableList<CidrAddressBlock> ipWhitelist = registrar.getIpAddressWhitelist();
|
||||
if (ipWhitelist.isEmpty()) {
|
||||
logger.infofmt(
|
||||
logger.atInfo().log(
|
||||
"Skipping IP whitelist check because %s doesn't have an IP whitelist",
|
||||
registrar.getClientId());
|
||||
return;
|
||||
|
@ -111,7 +111,7 @@ public class TlsCredentials implements TransportCredentials {
|
|||
return;
|
||||
}
|
||||
}
|
||||
logger.infofmt(
|
||||
logger.atInfo().log(
|
||||
"Authentication error: IP address %s is not whitelisted for registrar %s; whitelist is: %s",
|
||||
clientInetAddr, registrar.getClientId(), ipWhitelist);
|
||||
throw new BadRegistrarIpAddressException();
|
||||
|
@ -127,7 +127,7 @@ public class TlsCredentials implements TransportCredentials {
|
|||
private void validateCertificate(Registrar registrar) throws AuthenticationErrorException {
|
||||
if (isNullOrEmpty(registrar.getClientCertificateHash())
|
||||
&& isNullOrEmpty(registrar.getFailoverClientCertificateHash())) {
|
||||
logger.infofmt(
|
||||
logger.atInfo().log(
|
||||
"Skipping SSL certificate check because %s doesn't have any certificate hashes on file",
|
||||
registrar.getClientId());
|
||||
return;
|
||||
|
@ -138,12 +138,12 @@ public class TlsCredentials implements TransportCredentials {
|
|||
if (!hasSni()) {
|
||||
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();
|
||||
}
|
||||
if (!clientCertificateHash.equals(registrar.getClientCertificateHash())
|
||||
&& !clientCertificateHash.equals(registrar.getFailoverClientCertificateHash())) {
|
||||
logger.warningfmt(
|
||||
logger.atWarning().log(
|
||||
"bad certificate hash (%s) for %s, wanted either %s or %s",
|
||||
clientCertificateHash,
|
||||
registrar.getClientId(),
|
||||
|
|
|
@ -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.TransientFailureException;
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import com.google.common.logging.FormattingLogger;
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.googlecode.objectify.Key;
|
||||
import google.registry.config.RegistryConfig.Config;
|
||||
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_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 Queue asyncDeletePullQueue;
|
||||
|
@ -75,7 +75,7 @@ public final class AsyncFlowEnqueuer {
|
|||
Trid trid,
|
||||
boolean isSuperuser) {
|
||||
Key<EppResource> resourceKey = Key.create(resourceToDelete);
|
||||
logger.infofmt(
|
||||
logger.atInfo().log(
|
||||
"Enqueuing async deletion of %s on behalf of registrar %s.",
|
||||
resourceKey, requestingClientId);
|
||||
TaskOptions task =
|
||||
|
@ -95,7 +95,7 @@ public final class AsyncFlowEnqueuer {
|
|||
/** Enqueues a task to asynchronously refresh DNS for a renamed host. */
|
||||
public void enqueueAsyncDnsRefresh(HostResource host, DateTime now) {
|
||||
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(
|
||||
asyncDnsRefreshPullQueue,
|
||||
TaskOptions.Builder.withMethod(Method.PULL)
|
||||
|
|
|
@ -15,14 +15,13 @@
|
|||
package google.registry.flows.async;
|
||||
|
||||
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 google.registry.flows.async.AsyncFlowMetrics.OperationType.CONTACT_AND_HOST_DELETE;
|
||||
import static google.registry.flows.async.AsyncFlowMetrics.OperationType.DNS_REFRESH;
|
||||
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
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.EventMetric;
|
||||
import com.google.monitoring.metrics.FibonacciFitter;
|
||||
|
@ -42,7 +41,7 @@ import org.joda.time.Duration;
|
|||
*/
|
||||
public class AsyncFlowMetrics {
|
||||
|
||||
private static final FormattingLogger logger = getLoggerForCallerClass();
|
||||
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
|
||||
|
||||
private final Clock clock;
|
||||
|
||||
|
@ -153,7 +152,7 @@ public class AsyncFlowMetrics {
|
|||
processingMillis,
|
||||
operationType.getMetricLabelValue(),
|
||||
operationResult.getMetricLabelValue());
|
||||
logger.infofmt(
|
||||
logger.atInfo().log(
|
||||
"Asynchronous %s operation took %d ms to process, yielding result: %s.",
|
||||
operationType.getMetricLabelValue(),
|
||||
processingMillis,
|
||||
|
|
|
@ -18,7 +18,7 @@ import static com.google.common.collect.Sets.difference;
|
|||
import static google.registry.util.CollectionUtils.nullToEmpty;
|
||||
|
||||
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.AuthenticationErrorClosingConnectionException;
|
||||
import google.registry.flows.EppException.AuthenticationErrorException;
|
||||
|
@ -67,7 +67,7 @@ import javax.inject.Inject;
|
|||
*/
|
||||
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. */
|
||||
private static final int MAX_FAILED_LOGIN_ATTEMPTS_PER_CONNECTION = 3;
|
||||
|
@ -86,7 +86,7 @@ public class LoginFlow implements Flow {
|
|||
try {
|
||||
return runWithoutLogging();
|
||||
} catch (EppException e) {
|
||||
logger.warning("Login failed: " + e.getMessage());
|
||||
logger.atWarning().log("Login failed: %s", e.getMessage());
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,6 @@ java_library(
|
|||
name = "gcs",
|
||||
srcs = glob(["*.java"]),
|
||||
deps = [
|
||||
"//java/com/google/common/logging:formatting_logger",
|
||||
"//java/google/registry/config",
|
||||
"@com_google_appengine_tools_appengine_gcs_client",
|
||||
"@com_google_code_findbugs_jsr305",
|
||||
|
|
|
@ -26,7 +26,7 @@ import com.google.appengine.tools.cloudstorage.ListResult;
|
|||
import com.google.common.base.Splitter;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
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 google.registry.config.RegistryConfig.Config;
|
||||
import java.io.IOException;
|
||||
|
@ -40,7 +40,7 @@ import javax.inject.Inject;
|
|||
/** Utilities for working with Google Cloud Storage. */
|
||||
public class GcsUtils {
|
||||
|
||||
private static final FormattingLogger logger = FormattingLogger.getLoggerForCallerClass();
|
||||
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
|
||||
|
||||
private static final ImmutableMap<String, MediaType> EXTENSIONS =
|
||||
new ImmutableMap.Builder<String, MediaType>()
|
||||
|
@ -105,7 +105,7 @@ public class GcsUtils {
|
|||
try {
|
||||
metadata = gcsService.getMetadata(file);
|
||||
} 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 metadata != null && metadata.getLength() > 0;
|
||||
|
|
|
@ -8,7 +8,6 @@ java_library(
|
|||
name = "groups",
|
||||
srcs = glob(["*.java"]),
|
||||
deps = [
|
||||
"//java/com/google/common/logging:formatting_logger",
|
||||
"//java/google/registry/config",
|
||||
"//java/google/registry/util",
|
||||
"@com_google_api_client",
|
||||
|
@ -16,6 +15,8 @@ java_library(
|
|||
"@com_google_apis_google_api_services_groupssettings",
|
||||
"@com_google_code_findbugs_jsr305",
|
||||
"@com_google_dagger",
|
||||
"@com_google_flogger",
|
||||
"@com_google_flogger_system_backend",
|
||||
"@com_google_guava",
|
||||
"@javax_servlet_api",
|
||||
"@joda_time",
|
||||
|
|
|
@ -29,7 +29,7 @@ import com.google.api.services.groupssettings.model.Groups;
|
|||
import com.google.common.annotations.VisibleForTesting;
|
||||
import com.google.common.base.Strings;
|
||||
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 java.io.IOException;
|
||||
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_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();
|
||||
|
||||
@VisibleForTesting
|
||||
|
@ -80,11 +80,9 @@ public class DirectoryGroupsConnection implements GroupsConnection {
|
|||
// return it.
|
||||
GoogleJsonError err = e.getDetails();
|
||||
if (err.getCode() == SC_NOT_FOUND && err.getMessage().equals(GROUP_NOT_FOUND_MSG)) {
|
||||
logger.infofmt(
|
||||
e,
|
||||
logger.atInfo().withCause(e).log(
|
||||
"Creating group %s during addition of member %s because the group doesn't exist.",
|
||||
groupKey,
|
||||
email);
|
||||
groupKey, email);
|
||||
createGroup(groupKey);
|
||||
addMemberToGroup(groupKey, email, role);
|
||||
} 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
|
||||
// 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.
|
||||
logger.infofmt(
|
||||
e,
|
||||
logger.atInfo().withCause(e).log(
|
||||
"Could not add email %s to group %s because it is already a member "
|
||||
+ "(likely because the email address is bouncing incoming messages).",
|
||||
email,
|
||||
groupKey);
|
||||
email, groupKey);
|
||||
} else {
|
||||
throw e;
|
||||
}
|
||||
|
@ -159,7 +155,8 @@ public class DirectoryGroupsConnection implements GroupsConnection {
|
|||
// Ignore the error thrown if the group already exists.
|
||||
if (e.getDetails().getCode() == SC_CONFLICT
|
||||
&& 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();
|
||||
} else {
|
||||
throw e;
|
||||
|
|
|
@ -9,7 +9,6 @@ java_library(
|
|||
srcs = glob(["*.java"]),
|
||||
resources = glob(["*.asc"]),
|
||||
deps = [
|
||||
"//java/com/google/common/logging:formatting_logger",
|
||||
"//java/google/registry/util",
|
||||
"@com_google_code_findbugs_jsr305",
|
||||
"@com_google_dagger",
|
||||
|
|
|
@ -9,7 +9,6 @@ java_library(
|
|||
srcs = glob(["*.java"]),
|
||||
resources = glob(["templates/*.xml"]),
|
||||
deps = [
|
||||
"//java/com/google/common/logging:formatting_logger",
|
||||
"//java/google/registry/config",
|
||||
"//java/google/registry/request",
|
||||
"//java/google/registry/request/auth",
|
||||
|
@ -18,6 +17,8 @@ java_library(
|
|||
"//third_party/objectify:objectify-v4_1",
|
||||
"@com_google_appengine_api_1_0_sdk",
|
||||
"@com_google_dagger",
|
||||
"@com_google_flogger",
|
||||
"@com_google_flogger_system_backend",
|
||||
"@com_google_guava",
|
||||
"@javax_servlet_api",
|
||||
"@joda_time",
|
||||
|
|
|
@ -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.collect.ImmutableList.toImmutableList;
|
||||
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.util.ResourceUtils.readResourceUtf8;
|
||||
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.common.collect.ImmutableList;
|
||||
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.request.Action;
|
||||
import google.registry.request.Parameter;
|
||||
|
@ -60,7 +59,7 @@ import org.joda.time.DateTime;
|
|||
)
|
||||
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 ARBITRARY_VALID_HOST_LENGTH = 40;
|
||||
|
@ -257,7 +256,7 @@ public class LoadTestAction implements Runnable {
|
|||
}
|
||||
ImmutableList<TaskOptions> taskOptions = tasks.build();
|
||||
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() {
|
||||
|
@ -276,7 +275,7 @@ public class LoadTestAction implements Runnable {
|
|||
|| failedHostCreatesPerSecond > 0
|
||||
|| hostInfosPerSecond > 0,
|
||||
"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, "
|
||||
+ "runSeconds: %d, successful|failed domain creates/s: %d|%d, domain infos/s: %d, "
|
||||
+ "domain checks/s: %d, successful|failed contact creates/s: %d|%d, "
|
||||
|
|
|
@ -8,7 +8,6 @@ java_library(
|
|||
name = "mapreduce",
|
||||
srcs = glob(["*.java"]),
|
||||
deps = [
|
||||
"//java/com/google/common/logging:formatting_logger",
|
||||
"//java/google/registry/mapreduce/inputs",
|
||||
"//java/google/registry/request",
|
||||
"//java/google/registry/util",
|
||||
|
@ -17,6 +16,8 @@ java_library(
|
|||
"@com_google_appengine_tools_appengine_mapreduce",
|
||||
"@com_google_appengine_tools_appengine_pipeline",
|
||||
"@com_google_dagger",
|
||||
"@com_google_flogger",
|
||||
"@com_google_flogger_system_backend",
|
||||
"@com_google_guava",
|
||||
"@javax_servlet_api",
|
||||
"@joda_time",
|
||||
|
|
|
@ -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.JobSetting;
|
||||
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.request.Parameter;
|
||||
import google.registry.util.PipelineUtils;
|
||||
|
@ -50,7 +50,7 @@ import org.joda.time.Duration;
|
|||
*/
|
||||
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_MAP_SHARDS = "mapShards";
|
||||
|
@ -273,11 +273,9 @@ public class MapreduceRunner {
|
|||
job,
|
||||
new JobSetting.OnModule(moduleName),
|
||||
new JobSetting.OnQueue(QUEUE_NAME));
|
||||
logger.infofmt(
|
||||
logger.atInfo().log(
|
||||
"Started '%s' %s job: %s",
|
||||
jobName,
|
||||
job instanceof MapJob ? "map" : "mapreduce",
|
||||
PipelineUtils.createJobPath(jobId));
|
||||
jobName, job instanceof MapJob ? "map" : "mapreduce", PipelineUtils.createJobPath(jobId));
|
||||
return jobId;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,6 @@ java_library(
|
|||
name = "inputs",
|
||||
srcs = glob(["*.java"]),
|
||||
deps = [
|
||||
"//java/com/google/common/logging:formatting_logger",
|
||||
"//java/google/registry/model",
|
||||
"//java/google/registry/util",
|
||||
"//third_party/objectify:objectify-v4_1",
|
||||
|
|
|
@ -21,7 +21,7 @@ import com.google.appengine.api.datastore.Cursor;
|
|||
import com.google.appengine.api.datastore.DatastoreTimeoutException;
|
||||
import com.google.appengine.api.datastore.QueryResultIterator;
|
||||
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 google.registry.util.Retrier;
|
||||
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 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;
|
||||
private int total;
|
||||
|
@ -136,9 +136,9 @@ abstract class RetryingInputReader<I, T> extends InputReader<T> {
|
|||
() -> queryIterator.next(),
|
||||
(thrown, failures, maxAttempts) -> {
|
||||
checkNotNull(cursor, "Can't retry because cursor is null. Giving up.");
|
||||
logger.infofmt(
|
||||
"Retriable failure while reading item %d/%d - attempt %d/%d: %s",
|
||||
loaded, total, failures, maxAttempts, thrown);
|
||||
logger.atInfo().withCause(thrown).log(
|
||||
"Retriable failure while reading item %d/%d - attempt %d/%d.",
|
||||
loaded, total, failures, maxAttempts);
|
||||
queryIterator = getQueryIterator(cursor);
|
||||
},
|
||||
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.
|
||||
throw e;
|
||||
} catch (Throwable e) {
|
||||
logger.warningfmt(e, "Got an unrecoverable failure while reading item %d/%d.", loaded, total);
|
||||
throw e;
|
||||
throw new RuntimeException(
|
||||
String.format("Got an unrecoverable failure while reading item %d/%d.", loaded, total),
|
||||
e);
|
||||
} finally {
|
||||
ofy().clearSessionCache();
|
||||
}
|
||||
|
|
|
@ -13,7 +13,6 @@ java_library(
|
|||
]),
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//java/com/google/common/logging:formatting_logger",
|
||||
"//java/google/registry/config",
|
||||
"//java/google/registry/util",
|
||||
"//java/google/registry/xml",
|
||||
|
@ -23,6 +22,8 @@ java_library(
|
|||
"@com_google_auto_value",
|
||||
"@com_google_code_findbugs_jsr305",
|
||||
"@com_google_dagger",
|
||||
"@com_google_flogger",
|
||||
"@com_google_flogger_system_backend",
|
||||
"@com_google_guava",
|
||||
"@com_google_monitoring_client_metrics",
|
||||
"@com_google_re2j",
|
||||
|
|
|
@ -22,7 +22,7 @@ import static google.registry.util.DateTimeUtils.isBeforeOrAt;
|
|||
import static google.registry.util.DateTimeUtils.latestOf;
|
||||
|
||||
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.Result;
|
||||
import com.googlecode.objectify.cmd.Query;
|
||||
|
@ -53,7 +53,7 @@ import org.joda.time.Interval;
|
|||
/** Utilities for working with {@link EppResource}. */
|
||||
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. */
|
||||
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<CommitLogManifest> revision = findMostRecentRevisionAtTime(resource, timestamp);
|
||||
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);
|
||||
}
|
||||
final Result<CommitLogMutation> mutationResult =
|
||||
|
@ -341,7 +341,7 @@ public final class EppResourceUtils {
|
|||
if (mutation != null) {
|
||||
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."
|
||||
+ " Revision: %s",
|
||||
timestamp, resourceKey, revision);
|
||||
|
@ -355,18 +355,20 @@ public final class EppResourceUtils {
|
|||
final Key<T> resourceKey = Key.create(resource);
|
||||
Entry<?, Key<CommitLogManifest>> revision = resource.getRevisions().floorEntry(timestamp);
|
||||
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();
|
||||
}
|
||||
// Fall back to the earliest revision if we don't have one before the requested timestamp.
|
||||
revision = resource.getRevisions().firstEntry();
|
||||
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);
|
||||
return revision.getValue();
|
||||
}
|
||||
// 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;
|
||||
}
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ import com.google.common.annotations.VisibleForTesting;
|
|||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
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.Objectify;
|
||||
import com.googlecode.objectify.ObjectifyFactory;
|
||||
|
@ -59,7 +59,7 @@ import org.joda.time.Duration;
|
|||
*/
|
||||
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. */
|
||||
@NonFinalForTesting
|
||||
|
@ -263,7 +263,8 @@ public class Ofy {
|
|||
throw e; // Give up.
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ import static google.registry.util.DateTimeUtils.isAtOrAfter;
|
|||
import com.google.auto.value.AutoValue;
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
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.annotation.Entity;
|
||||
import com.googlecode.objectify.annotation.Id;
|
||||
|
@ -48,7 +48,7 @@ import org.joda.time.Duration;
|
|||
@NotBackedUp(reason = Reason.TRANSIENT)
|
||||
public class Lock extends ImmutableObject {
|
||||
|
||||
private static final FormattingLogger logger = FormattingLogger.getLoggerForCallerClass();
|
||||
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
|
||||
|
||||
/** Disposition of locking, for monitoring. */
|
||||
enum LockState { IN_USE, FREE, TIMED_OUT, OWNER_DIED }
|
||||
|
@ -133,28 +133,19 @@ public class Lock extends ImmutableObject {
|
|||
DateTime now = acquireResult.transactionTime();
|
||||
switch (acquireResult.lockState()) {
|
||||
case IN_USE:
|
||||
logger.infofmt(
|
||||
logger.atInfo().log(
|
||||
"Existing lock by request %s is still valid now %s (until %s) lock: %s",
|
||||
lock.requestLogId,
|
||||
now,
|
||||
lock.expirationTime,
|
||||
lock.lockId);
|
||||
lock.requestLogId, now, lock.expirationTime, lock.lockId);
|
||||
break;
|
||||
case TIMED_OUT:
|
||||
logger.infofmt(
|
||||
logger.atInfo().log(
|
||||
"Existing lock by request %s is timed out now %s (was valid until %s) lock: %s",
|
||||
lock.requestLogId,
|
||||
now,
|
||||
lock.expirationTime,
|
||||
lock.lockId);
|
||||
lock.requestLogId, now, lock.expirationTime, lock.lockId);
|
||||
break;
|
||||
case OWNER_DIED:
|
||||
logger.infofmt(
|
||||
logger.atInfo().log(
|
||||
"Existing lock is valid now %s (until %s), but owner (%s) isn't running lock: %s",
|
||||
now,
|
||||
lock.expirationTime,
|
||||
lock.requestLogId,
|
||||
lock.lockId);
|
||||
now, lock.expirationTime, lock.requestLogId, lock.lockId);
|
||||
break;
|
||||
case FREE:
|
||||
// There was no existing lock
|
||||
|
@ -162,15 +153,13 @@ public class Lock extends ImmutableObject {
|
|||
}
|
||||
Lock newLock = acquireResult.newLock();
|
||||
if (acquireResult.newLock() != null) {
|
||||
logger.infofmt(
|
||||
"acquire succeeded %s lock: %s",
|
||||
newLock,
|
||||
newLock.lockId);
|
||||
logger.atInfo().log("acquire succeeded %s lock: %s", newLock, newLock.lockId);
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
// 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
|
||||
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
|
||||
// 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.
|
||||
AcquireResult acquireResult = ofy().transactNew(() -> {
|
||||
DateTime now = ofy().getTransactionTime();
|
||||
AcquireResult acquireResult =
|
||||
ofy()
|
||||
.transactNew(
|
||||
() -> {
|
||||
DateTime now = ofy().getTransactionTime();
|
||||
|
||||
// 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();
|
||||
if (lock != null) {
|
||||
logger.infofmt(
|
||||
"Loaded existing lock: %s for request: %s", lock.lockId, lock.requestLogId);
|
||||
}
|
||||
LockState lockState;
|
||||
if (lock == null) {
|
||||
lockState = LockState.FREE;
|
||||
} else if (isAtOrAfter(now, lock.expirationTime)) {
|
||||
lockState = LockState.TIMED_OUT;
|
||||
} else if (!requestStatusChecker.isRunning(lock.requestLogId)) {
|
||||
lockState = LockState.OWNER_DIED;
|
||||
} else {
|
||||
lockState = LockState.IN_USE;
|
||||
return AcquireResult.create(now, lock, null, lockState);
|
||||
}
|
||||
// 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();
|
||||
if (lock != null) {
|
||||
logger.atInfo().log(
|
||||
"Loaded existing lock: %s for request: %s", lock.lockId, lock.requestLogId);
|
||||
}
|
||||
LockState lockState;
|
||||
if (lock == null) {
|
||||
lockState = LockState.FREE;
|
||||
} else if (isAtOrAfter(now, lock.expirationTime)) {
|
||||
lockState = LockState.TIMED_OUT;
|
||||
} else if (!requestStatusChecker.isRunning(lock.requestLogId)) {
|
||||
lockState = LockState.OWNER_DIED;
|
||||
} else {
|
||||
lockState = LockState.IN_USE;
|
||||
return AcquireResult.create(now, lock, null, lockState);
|
||||
}
|
||||
|
||||
Lock newLock = create(
|
||||
resourceName,
|
||||
tld,
|
||||
requestStatusChecker.getLogId(),
|
||||
now,
|
||||
leaseLength);
|
||||
// Locks are not parented under an EntityGroupRoot (so as to avoid write contention) and
|
||||
// don't need to be backed up.
|
||||
ofy().saveWithoutBackup().entity(newLock);
|
||||
return AcquireResult.create(now, lock, newLock, lockState);
|
||||
});
|
||||
Lock newLock =
|
||||
create(resourceName, tld, requestStatusChecker.getLogId(), now, leaseLength);
|
||||
// Locks are not parented under an EntityGroupRoot (so as to avoid write
|
||||
// contention) and
|
||||
// don't need to be backed up.
|
||||
ofy().saveWithoutBackup().entity(newLock);
|
||||
return AcquireResult.create(now, lock, newLock, lockState);
|
||||
});
|
||||
|
||||
logAcquireResult(acquireResult);
|
||||
lockMetrics.recordAcquire(resourceName, tld, acquireResult.lockState());
|
||||
|
@ -225,28 +214,33 @@ public class Lock extends ImmutableObject {
|
|||
/** Release the lock. */
|
||||
public void release() {
|
||||
// Just use the default clock because we aren't actually doing anything that will use the clock.
|
||||
ofy().transact(new VoidWork() {
|
||||
@Override
|
||||
public void vrun() {
|
||||
// To release a lock, check that no one else has already obtained it and if not delete it.
|
||||
// If the lock in Datastore was different then this lock is gone already; this can happen
|
||||
// if release() is called around the expiration time and the lock expires underneath us.
|
||||
Lock loadedLock = ofy().load().type(Lock.class).id(lockId).now();
|
||||
if (Lock.this.equals(loadedLock)) {
|
||||
// Use noBackupOfy() so that we don't create a commit log entry for deleting the lock.
|
||||
logger.infofmt("Deleting lock: %s", lockId);
|
||||
ofy().deleteWithoutBackup().entity(Lock.this);
|
||||
lockMetrics.recordRelease(
|
||||
resourceName, tld, new Duration(acquiredTime, ofy().getTransactionTime()));
|
||||
} else {
|
||||
logger.severefmt(
|
||||
"The lock we acquired was transferred to someone else before we"
|
||||
+ " released it! Did action take longer than lease length?"
|
||||
+ " Our lock: %s, current lock: %s",
|
||||
Lock.this,
|
||||
loadedLock);
|
||||
logger.infofmt("Not deleting lock: %s - someone else has it: %s", lockId, loadedLock);
|
||||
}
|
||||
}});
|
||||
ofy()
|
||||
.transact(
|
||||
new VoidWork() {
|
||||
@Override
|
||||
public void vrun() {
|
||||
// To release a lock, check that no one else has already obtained it and if not
|
||||
// delete it. If the lock in Datastore was different then this lock is gone already;
|
||||
// this can happen if release() is called around the expiration time and the lock
|
||||
// expires underneath us.
|
||||
Lock loadedLock = ofy().load().type(Lock.class).id(lockId).now();
|
||||
if (Lock.this.equals(loadedLock)) {
|
||||
// Use noBackupOfy() so that we don't create a commit log entry for deleting the
|
||||
// lock.
|
||||
logger.atInfo().log("Deleting lock: %s", lockId);
|
||||
ofy().deleteWithoutBackup().entity(Lock.this);
|
||||
lockMetrics.recordRelease(
|
||||
resourceName, tld, new Duration(acquiredTime, ofy().getTransactionTime()));
|
||||
} else {
|
||||
logger.atSevere().log(
|
||||
"The lock we acquired was transferred to someone else before we"
|
||||
+ " 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);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,6 @@ java_library(
|
|||
name = "backend",
|
||||
srcs = glob(["*.java"]),
|
||||
deps = [
|
||||
"//java/com/google/common/logging:formatting_logger",
|
||||
"//java/google/registry/backup",
|
||||
"//java/google/registry/batch",
|
||||
"//java/google/registry/bigquery",
|
||||
|
@ -41,6 +40,8 @@ java_library(
|
|||
"@com_google_appengine_api_1_0_sdk",
|
||||
"@com_google_code_findbugs_jsr305",
|
||||
"@com_google_dagger",
|
||||
"@com_google_flogger",
|
||||
"@com_google_flogger_system_backend",
|
||||
"@com_google_guava",
|
||||
"@com_google_monitoring_client_metrics",
|
||||
"@javax_servlet_api",
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
package google.registry.module.backend;
|
||||
|
||||
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 dagger.Lazy;
|
||||
import java.io.IOException;
|
||||
|
@ -33,7 +33,7 @@ public final class BackendServlet extends HttpServlet {
|
|||
private static final BackendComponent component = DaggerBackendComponent.create();
|
||||
private static final BackendRequestHandler requestHandler = component.requestHandler();
|
||||
private static final Lazy<MetricReporter> metricReporter = component.metricReporter();
|
||||
private static final FormattingLogger logger = FormattingLogger.getLoggerForCallerClass();
|
||||
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
|
@ -44,25 +44,26 @@ public final class BackendServlet extends HttpServlet {
|
|||
// registered if metric reporter starts up correctly.
|
||||
try {
|
||||
metricReporter.get().startAsync().awaitRunning(10, TimeUnit.SECONDS);
|
||||
logger.info("Started up MetricReporter");
|
||||
logger.atInfo().log("Started up MetricReporter");
|
||||
LifecycleManager.getInstance()
|
||||
.setShutdownHook(
|
||||
() -> {
|
||||
try {
|
||||
metricReporter.get().stopAsync().awaitTerminated(10, TimeUnit.SECONDS);
|
||||
logger.info("Shut down MetricReporter");
|
||||
logger.atInfo().log("Shut down MetricReporter");
|
||||
} 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) {
|
||||
logger.severefmt(e, "Failed to initialize MetricReporter.");
|
||||
logger.atSevere().withCause(e).log("Failed to initialize MetricReporter.");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void service(HttpServletRequest req, HttpServletResponse rsp) throws IOException {
|
||||
logger.info("Received backend request");
|
||||
logger.atInfo().log("Received backend request");
|
||||
requestHandler.handleRequest(req, rsp);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,6 @@ java_library(
|
|||
name = "frontend",
|
||||
srcs = glob(["*.java"]),
|
||||
deps = [
|
||||
"//java/com/google/common/logging:formatting_logger",
|
||||
"//java/google/registry/braintree",
|
||||
"//java/google/registry/config",
|
||||
"//java/google/registry/dns",
|
||||
|
|
|
@ -16,7 +16,6 @@ package google.registry.module.frontend;
|
|||
|
||||
import com.google.appengine.api.LifecycleManager;
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.google.common.logging.FormattingLogger;
|
||||
import com.google.monitoring.metrics.MetricReporter;
|
||||
import dagger.Lazy;
|
||||
import java.io.IOException;
|
||||
|
@ -34,9 +33,7 @@ public final class FrontendServlet extends HttpServlet {
|
|||
private static final FrontendComponent component = DaggerFrontendComponent.create();
|
||||
private static final FrontendRequestHandler requestHandler = component.requestHandler();
|
||||
private static final Lazy<MetricReporter> metricReporter = component.metricReporter();
|
||||
private static final FormattingLogger logger = FormattingLogger.getLoggerForCallerClass();
|
||||
// TODO(b/): Remove this static field.
|
||||
private static final FluentLogger flogger = FluentLogger.forEnclosingClass();
|
||||
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
|
@ -47,25 +44,25 @@ public final class FrontendServlet extends HttpServlet {
|
|||
// registered if metric reporter starts up correctly.
|
||||
try {
|
||||
metricReporter.get().startAsync().awaitRunning(10, TimeUnit.SECONDS);
|
||||
logger.info("Started up MetricReporter");
|
||||
logger.atInfo().log("Started up MetricReporter");
|
||||
LifecycleManager.getInstance()
|
||||
.setShutdownHook(
|
||||
() -> {
|
||||
try {
|
||||
metricReporter.get().stopAsync().awaitTerminated(10, TimeUnit.SECONDS);
|
||||
logger.info("Shut down MetricReporter");
|
||||
logger.atInfo().log("Shut down MetricReporter");
|
||||
} catch (TimeoutException e) {
|
||||
logger.severe(e, "Failed to stop MetricReporter.");
|
||||
logger.atSevere().withCause(e).log("Failed to stop MetricReporter.");
|
||||
}
|
||||
});
|
||||
} catch (Exception e) {
|
||||
logger.severe(e, "Failed to initialize MetricReporter.");
|
||||
logger.atSevere().withCause(e).log("Failed to initialize MetricReporter.");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,6 @@ java_library(
|
|||
name = "pubapi",
|
||||
srcs = glob(["*.java"]),
|
||||
deps = [
|
||||
"//java/com/google/common/logging:formatting_logger",
|
||||
"//java/google/registry/config",
|
||||
"//java/google/registry/dns",
|
||||
"//java/google/registry/flows",
|
||||
|
@ -24,6 +23,8 @@ java_library(
|
|||
"@com_google_appengine_api_1_0_sdk",
|
||||
"@com_google_code_findbugs_jsr305",
|
||||
"@com_google_dagger",
|
||||
"@com_google_flogger",
|
||||
"@com_google_flogger_system_backend",
|
||||
"@com_google_guava",
|
||||
"@com_google_monitoring_client_metrics",
|
||||
"@javax_servlet_api",
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
package google.registry.module.pubapi;
|
||||
|
||||
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 dagger.Lazy;
|
||||
import java.io.IOException;
|
||||
|
@ -33,7 +33,7 @@ public final class PubApiServlet extends HttpServlet {
|
|||
private static final PubApiComponent component = DaggerPubApiComponent.create();
|
||||
private static final PubApiRequestHandler requestHandler = component.requestHandler();
|
||||
private static final Lazy<MetricReporter> metricReporter = component.metricReporter();
|
||||
private static final FormattingLogger logger = FormattingLogger.getLoggerForCallerClass();
|
||||
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
|
@ -44,25 +44,25 @@ public final class PubApiServlet extends HttpServlet {
|
|||
// registered if metric reporter starts up correctly.
|
||||
try {
|
||||
metricReporter.get().startAsync().awaitRunning(10, TimeUnit.SECONDS);
|
||||
logger.info("Started up MetricReporter");
|
||||
logger.atInfo().log("Started up MetricReporter");
|
||||
LifecycleManager.getInstance()
|
||||
.setShutdownHook(
|
||||
() -> {
|
||||
try {
|
||||
metricReporter.get().stopAsync().awaitTerminated(10, TimeUnit.SECONDS);
|
||||
logger.info("Shut down MetricReporter");
|
||||
logger.atInfo().log("Shut down MetricReporter");
|
||||
} catch (TimeoutException e) {
|
||||
logger.severe(e, "Failed to stop MetricReporter.");
|
||||
logger.atSevere().withCause(e).log("Failed to stop MetricReporter.");
|
||||
}
|
||||
});
|
||||
} catch (Exception e) {
|
||||
logger.severe(e, "Failed to initialize MetricReporter.");
|
||||
logger.atSevere().withCause(e).log("Failed to initialize MetricReporter.");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void service(HttpServletRequest req, HttpServletResponse rsp) throws IOException {
|
||||
logger.info("Received frontend request");
|
||||
logger.atInfo().log("Received frontend request");
|
||||
requestHandler.handleRequest(req, rsp);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,6 @@ java_library(
|
|||
name = "tools",
|
||||
srcs = glob(["*.java"]),
|
||||
deps = [
|
||||
"//java/com/google/common/logging:formatting_logger",
|
||||
"//java/google/registry/backup",
|
||||
"//java/google/registry/config",
|
||||
"//java/google/registry/dns",
|
||||
|
@ -29,6 +28,8 @@ java_library(
|
|||
"@com_google_appengine_api_1_0_sdk",
|
||||
"@com_google_code_findbugs_jsr305",
|
||||
"@com_google_dagger",
|
||||
"@com_google_flogger",
|
||||
"@com_google_flogger_system_backend",
|
||||
"@com_google_guava",
|
||||
"@javax_servlet_api",
|
||||
"@org_bouncycastle_bcpkix_jdk15on",
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
package google.registry.module.tools;
|
||||
|
||||
import com.google.common.logging.FormattingLogger;
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import java.io.IOException;
|
||||
import java.security.Security;
|
||||
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 ToolsRequestHandler requestHandler = component.requestHandler();
|
||||
private static final FormattingLogger logger = FormattingLogger.getLoggerForCallerClass();
|
||||
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
|
@ -36,7 +36,7 @@ public final class ToolsServlet extends HttpServlet {
|
|||
|
||||
@Override
|
||||
public void service(HttpServletRequest req, HttpServletResponse rsp) throws IOException {
|
||||
logger.info("Received tools request");
|
||||
logger.atInfo().log("Received tools request");
|
||||
requestHandler.handleRequest(req, rsp);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,6 @@ java_library(
|
|||
name = "whitebox",
|
||||
srcs = glob(["*.java"]),
|
||||
deps = [
|
||||
"//java/com/google/common/logging:formatting_logger",
|
||||
"//java/google/registry/bigquery",
|
||||
"//java/google/registry/config",
|
||||
"//java/google/registry/model",
|
||||
|
@ -23,6 +22,8 @@ java_library(
|
|||
"@com_google_auto_value",
|
||||
"@com_google_code_findbugs_jsr305",
|
||||
"@com_google_dagger",
|
||||
"@com_google_flogger",
|
||||
"@com_google_flogger_system_backend",
|
||||
"@com_google_guava",
|
||||
"@com_google_http_client",
|
||||
"@com_google_monitoring_client_metrics",
|
||||
|
|
|
@ -21,7 +21,7 @@ import com.google.appengine.api.taskqueue.Queue;
|
|||
import com.google.appengine.api.taskqueue.TaskOptions;
|
||||
import com.google.appengine.api.taskqueue.TransientFailureException;
|
||||
import com.google.common.base.Supplier;
|
||||
import com.google.common.logging.FormattingLogger;
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import java.util.Map.Entry;
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
|
@ -34,7 +34,7 @@ import javax.inject.Named;
|
|||
*/
|
||||
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";
|
||||
|
||||
|
@ -58,7 +58,8 @@ public class BigQueryMetricsEnqueuer {
|
|||
queue.add(opts);
|
||||
} catch (TransientFailureException e) {
|
||||
// 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.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,7 +17,6 @@ package google.registry.monitoring.whitebox;
|
|||
import static com.google.common.base.Predicates.in;
|
||||
import static com.google.common.base.Predicates.not;
|
||||
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 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.ImmutableMap;
|
||||
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.config.RegistryConfig.Config;
|
||||
import google.registry.request.Action;
|
||||
|
@ -48,7 +47,7 @@ import javax.inject.Inject;
|
|||
public class MetricsExportAction implements Runnable {
|
||||
|
||||
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 ImmutableSet<String> SPECIAL_PARAMS = ImmutableSet.of("tableId", "insertId");
|
||||
|
||||
|
@ -97,7 +96,7 @@ public class MetricsExportAction implements Runnable {
|
|||
.collect(joining("\n")));
|
||||
}
|
||||
} 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.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,6 @@ java_library(
|
|||
name = "rdap",
|
||||
srcs = glob(["*.java"]),
|
||||
deps = [
|
||||
"//java/com/google/common/logging:formatting_logger",
|
||||
"//java/google/registry/config",
|
||||
"//java/google/registry/flows",
|
||||
"//java/google/registry/model",
|
||||
|
@ -20,6 +19,8 @@ java_library(
|
|||
"@com_google_auto_value",
|
||||
"@com_google_code_findbugs_jsr305",
|
||||
"@com_google_dagger",
|
||||
"@com_google_flogger",
|
||||
"@com_google_flogger_system_backend",
|
||||
"@com_google_guava",
|
||||
"@com_google_http_client_jackson2",
|
||||
"@com_google_monitoring_client_metrics",
|
||||
|
|
|
@ -27,7 +27,7 @@ import static javax.servlet.http.HttpServletResponse.SC_OK;
|
|||
|
||||
import com.google.api.client.json.jackson2.JacksonFactory;
|
||||
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.re2j.Pattern;
|
||||
import com.googlecode.objectify.Key;
|
||||
|
@ -69,7 +69,7 @@ import org.json.simple.JSONValue;
|
|||
*/
|
||||
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
|
||||
|
@ -160,7 +160,7 @@ public abstract class RdapActionBase implements Runnable {
|
|||
setError(SC_BAD_REQUEST, "Bad Request", "Not a valid " + getHumanReadableObjectTypeName());
|
||||
} catch (RuntimeException e) {
|
||||
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());
|
||||
}
|
||||
|
@ -185,8 +185,8 @@ public abstract class RdapActionBase implements Runnable {
|
|||
response.setPayload(new JacksonFactory().toPrettyString(rdapJson));
|
||||
return;
|
||||
} catch (IOException e) {
|
||||
logger.warning(
|
||||
e, "Unable to pretty-print RDAP JSON response; falling back to unformatted output.");
|
||||
logger.atWarning().withCause(e).log(
|
||||
"Unable to pretty-print RDAP JSON response; falling back to unformatted output.");
|
||||
}
|
||||
}
|
||||
response.setPayload(JSONValue.toJSONString(rdapJson));
|
||||
|
|
|
@ -26,7 +26,7 @@ import com.google.common.collect.ImmutableMap;
|
|||
import com.google.common.collect.ImmutableSortedSet;
|
||||
import com.google.common.collect.Iterables;
|
||||
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.primitives.Booleans;
|
||||
import com.googlecode.objectify.Key;
|
||||
|
@ -79,7 +79,7 @@ public class RdapDomainSearchAction extends RdapSearchActionBase {
|
|||
|
||||
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 @Parameter("name") Optional<String> nameParam;
|
||||
|
@ -399,7 +399,7 @@ public class RdapDomainSearchAction extends RdapSearchActionBase {
|
|||
if (hostKey != null) {
|
||||
builder.add(hostKey);
|
||||
} else {
|
||||
logger.warning("Host key unexpectedly null");
|
||||
logger.atWarning().log("Host key unexpectedly null");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ import com.google.common.collect.ImmutableSet;
|
|||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Ordering;
|
||||
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.googlecode.objectify.Key;
|
||||
import google.registry.config.RdapNoticeDescriptor;
|
||||
|
@ -83,7 +83,7 @@ public class RdapJsonFormatter {
|
|||
@Inject @Config("rdapHelpMap") ImmutableMap<String, RdapNoticeDescriptor> rdapHelpMap;
|
||||
@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,
|
||||
|
@ -304,8 +304,8 @@ public class RdapJsonFormatter {
|
|||
try {
|
||||
return RdapJsonFormatter.makeRdapJsonNotice(rdapHelpMap.get(pathSearchString), rdapLinkBase);
|
||||
} catch (Exception e) {
|
||||
logger.warningfmt(e, "Error reading RDAP help file: %s", pathSearchString);
|
||||
throw new InternalServerErrorException("unable to read help for " + pathSearchString);
|
||||
throw new InternalServerErrorException(
|
||||
String.format("Error reading RDAP help file: %s", pathSearchString), e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,6 @@ java_library(
|
|||
name = "rde",
|
||||
srcs = glob(["*.java"]),
|
||||
deps = [
|
||||
"//java/com/google/common/logging:formatting_logger",
|
||||
"//java/google/registry/config",
|
||||
"//java/google/registry/gcs",
|
||||
"//java/google/registry/keyring/api",
|
||||
|
|
|
@ -19,8 +19,8 @@ import static google.registry.request.Action.Method.POST;
|
|||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
|
||||
import com.google.appengine.tools.cloudstorage.GcsFilename;
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.google.common.io.ByteStreams;
|
||||
import com.google.common.logging.FormattingLogger;
|
||||
import google.registry.config.RegistryConfig.Config;
|
||||
import google.registry.gcs.GcsUtils;
|
||||
import google.registry.keyring.api.KeyModule.Key;
|
||||
|
@ -63,7 +63,7 @@ public final class BrdaCopyAction implements Runnable {
|
|||
|
||||
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 Ghostryde ghostryde;
|
||||
|
@ -99,7 +99,7 @@ public final class BrdaCopyAction implements Runnable {
|
|||
|
||||
long xmlLength = readXmlLength(xmlLengthFilename);
|
||||
|
||||
logger.infofmt("Writing %s", rydeFile);
|
||||
logger.atInfo().log("Writing %s", rydeFile);
|
||||
byte[] signature;
|
||||
try (InputStream gcsInput = gcsUtils.openInputStream(xmlFilename);
|
||||
Ghostryde.Decryptor decryptor = ghostryde.openDecryptor(gcsInput, stagingDecryptionKey);
|
||||
|
@ -118,7 +118,7 @@ public final class BrdaCopyAction implements Runnable {
|
|||
signature = signLayer.getSignature();
|
||||
}
|
||||
|
||||
logger.infofmt("Writing %s", sigFile);
|
||||
logger.atInfo().log("Writing %s", sigFile);
|
||||
try (OutputStream gcsOutput = gcsUtils.openOutputStream(sigFile)) {
|
||||
gcsOutput.write(signature);
|
||||
}
|
||||
|
|
|
@ -15,13 +15,12 @@
|
|||
package google.registry.rde;
|
||||
|
||||
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 com.google.common.base.Ascii;
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.logging.FormattingLogger;
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.googlecode.objectify.Key;
|
||||
import google.registry.model.contact.ContactResource;
|
||||
import google.registry.model.domain.DesignatedContact;
|
||||
|
@ -51,7 +50,7 @@ import org.joda.time.DateTime;
|
|||
/** Utility class that turns {@link DomainResource} as {@link XjcRdeDomainElement}. */
|
||||
final class DomainResourceToXjcConverter {
|
||||
|
||||
private static final FormattingLogger logger = getLoggerForCallerClass();
|
||||
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
|
||||
|
||||
/** Converts {@link DomainResource} to {@link XjcRdeDomainElement}. */
|
||||
static XjcRdeDomainElement convert(DomainResource domain, RdeMode mode) {
|
||||
|
@ -172,7 +171,7 @@ final class DomainResourceToXjcConverter {
|
|||
// as the holder of the domain name object.
|
||||
Key<ContactResource> registrant = model.getRegistrant();
|
||||
if (registrant == null) {
|
||||
logger.warningfmt("Domain %s has no registrant contact.", domainName);
|
||||
logger.atWarning().log("Domain %s has no registrant contact.", domainName);
|
||||
} else {
|
||||
ContactResource registrantContact = ofy().load().key(registrant).now();
|
||||
checkState(
|
||||
|
|
|
@ -16,7 +16,7 @@ package google.registry.rde;
|
|||
|
||||
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.CursorType;
|
||||
import google.registry.model.registry.Registry;
|
||||
|
@ -64,7 +64,7 @@ class EscrowTaskRunner {
|
|||
void runWithLock(DateTime watermark) throws Exception;
|
||||
}
|
||||
|
||||
private static final FormattingLogger logger = FormattingLogger.getLoggerForCallerClass();
|
||||
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
|
||||
|
||||
@Inject Clock clock;
|
||||
@Inject LockHandler lockHandler;
|
||||
|
@ -87,14 +87,14 @@ class EscrowTaskRunner {
|
|||
final Duration interval) {
|
||||
Callable<Void> lockRunner =
|
||||
() -> {
|
||||
logger.infofmt("TLD: %s", registry.getTld());
|
||||
logger.atInfo().log("TLD: %s", registry.getTld());
|
||||
DateTime startOfToday = clock.nowUtc().withTimeAtStartOfDay();
|
||||
Cursor cursor = ofy().load().key(Cursor.createKey(cursorType, registry)).now();
|
||||
final DateTime nextRequiredRun = (cursor == null ? startOfToday : cursor.getCursorTime());
|
||||
if (nextRequiredRun.isAfter(startOfToday)) {
|
||||
throw new NoContentException("Already completed");
|
||||
}
|
||||
logger.infofmt("Cursor: %s", nextRequiredRun);
|
||||
logger.atInfo().log("Cursor: %s", nextRequiredRun);
|
||||
task.runWithLock(nextRequiredRun);
|
||||
ofy()
|
||||
.transact(
|
||||
|
|
|
@ -23,8 +23,8 @@ import static org.bouncycastle.jce.provider.BouncyCastleProvider.PROVIDER_NAME;
|
|||
import static org.bouncycastle.openpgp.PGPLiteralData.BINARY;
|
||||
import static org.joda.time.DateTimeZone.UTC;
|
||||
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.google.common.io.ByteStreams;
|
||||
import com.google.common.logging.FormattingLogger;
|
||||
import google.registry.config.RegistryConfig.Config;
|
||||
import google.registry.util.ImprovedInputStream;
|
||||
import google.registry.util.ImprovedOutputStream;
|
||||
|
@ -125,7 +125,7 @@ import org.joda.time.DateTime;
|
|||
@Immutable
|
||||
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.
|
||||
|
@ -455,7 +455,7 @@ public final class Ghostryde {
|
|||
PGPEncryptedDataList crypts = pgpCast(fact.nextObject(), PGPEncryptedDataList.class);
|
||||
checkState(crypts.size() > 0);
|
||||
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);
|
||||
if (crypt.getKeyID() != privateKey.getKeyID()) {
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
package google.registry.rde;
|
||||
|
||||
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.JSch;
|
||||
import com.jcraft.jsch.JSchException;
|
||||
|
@ -41,7 +41,7 @@ import org.joda.time.Duration;
|
|||
*/
|
||||
final class JSchSshSession implements Closeable {
|
||||
|
||||
private static final FormattingLogger logger = FormattingLogger.getLoggerForCallerClass();
|
||||
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
|
||||
|
||||
/** Factory for {@link JSchSshSession}. */
|
||||
static final class JSchSshSessionFactory {
|
||||
|
@ -60,7 +60,7 @@ final class JSchSshSession implements Closeable {
|
|||
*/
|
||||
JSchSshSession create(JSch jsch, URI uri) throws JSchException {
|
||||
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(
|
||||
url.getUser().orElse("domain-registry"),
|
||||
url.getHost(),
|
||||
|
@ -99,7 +99,7 @@ final class JSchSshSession implements Closeable {
|
|||
try {
|
||||
chan.cd(dir);
|
||||
} catch (SftpException e) {
|
||||
logger.warning(e, "Could not open SFTP channel.");
|
||||
logger.atWarning().withCause(e).log("Could not open SFTP channel.");
|
||||
mkdirs(chan, dir);
|
||||
chan.cd(dir);
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ package google.registry.rde;
|
|||
import static com.google.common.base.Verify.verify;
|
||||
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 google.registry.model.ImmutableObject;
|
||||
import google.registry.model.contact.ContactResource;
|
||||
|
@ -50,7 +50,7 @@ import org.joda.time.DateTime;
|
|||
@NotThreadSafe
|
||||
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 final ValidationMode validationMode;
|
||||
|
@ -168,7 +168,7 @@ public final class RdeMarshaller implements Serializable {
|
|||
Key.create(resource),
|
||||
e.getLinkedException(),
|
||||
getMarshaller().marshalLenient(element));
|
||||
logger.severe(e, error);
|
||||
logger.atSevere().withCause(e).log(error);
|
||||
}
|
||||
return DepositFragment.create(type, xml, error);
|
||||
}
|
||||
|
|
|
@ -22,8 +22,8 @@ import static google.registry.model.rde.RdeMode.FULL;
|
|||
import static google.registry.request.Action.Method.POST;
|
||||
|
||||
import com.google.appengine.tools.cloudstorage.GcsFilename;
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.google.common.io.ByteStreams;
|
||||
import com.google.common.logging.FormattingLogger;
|
||||
import google.registry.config.RegistryConfig.Config;
|
||||
import google.registry.gcs.GcsUtils;
|
||||
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";
|
||||
|
||||
private static final FormattingLogger logger = FormattingLogger.getLoggerForCallerClass();
|
||||
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
|
||||
|
||||
@Inject GcsUtils gcsUtils;
|
||||
@Inject Ghostryde ghostryde;
|
||||
|
@ -83,7 +83,7 @@ public final class RdeReportAction implements Runnable, EscrowTask {
|
|||
getCursorTimeOrStartOfTime(
|
||||
ofy().load().key(Cursor.createKey(CursorType.RDE_UPLOAD, Registry.get(tld))).now());
|
||||
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");
|
||||
}
|
||||
String prefix = RdeNamingUtils.makeRydeFilename(tld, watermark, FULL, 1, 0);
|
||||
|
|
|
@ -28,7 +28,7 @@ import com.google.appengine.api.urlfetch.HTTPHeader;
|
|||
import com.google.appengine.api.urlfetch.HTTPRequest;
|
||||
import com.google.appengine.api.urlfetch.HTTPResponse;
|
||||
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.keyring.api.KeyModule.Key;
|
||||
import google.registry.request.HttpException.InternalServerErrorException;
|
||||
|
@ -53,7 +53,7 @@ import javax.inject.Inject;
|
|||
*/
|
||||
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">
|
||||
* 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(AUTHORIZATION, "Basic " + token));
|
||||
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 =
|
||||
retrier.callWithRetry(
|
||||
() -> {
|
||||
|
@ -98,10 +98,9 @@ public class RdeReporter {
|
|||
// Ensure the XML response is valid.
|
||||
XjcIirdeaResult result = parseResult(rsp);
|
||||
if (result.getCode().getValue() != 1000) {
|
||||
logger.warningfmt("PUT rejected: %d %s\n%s",
|
||||
result.getCode().getValue(),
|
||||
result.getMsg(),
|
||||
result.getDescription());
|
||||
logger.atWarning().log(
|
||||
"PUT rejected: %d %s\n%s",
|
||||
result.getCode().getValue(), result.getMsg(), result.getDescription());
|
||||
throw new InternalServerErrorException(result.getMsg());
|
||||
}
|
||||
}
|
||||
|
@ -114,7 +113,7 @@ public class RdeReporter {
|
|||
*/
|
||||
private XjcIirdeaResult parseResult(HTTPResponse rsp) throws XmlException {
|
||||
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.class, new ByteArrayInputStream(responseBytes));
|
||||
return response.getResult();
|
||||
|
|
|
@ -30,7 +30,7 @@ import com.google.appengine.tools.cloudstorage.GcsFilename;
|
|||
import com.google.appengine.tools.cloudstorage.RetryParams;
|
||||
import com.google.appengine.tools.mapreduce.Reducer;
|
||||
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.gcs.GcsUtils;
|
||||
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 FormattingLogger logger = FormattingLogger.getLoggerForCallerClass();
|
||||
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
|
||||
|
||||
private final TaskQueueUtils taskQueueUtils;
|
||||
private final LockHandler lockHandler;
|
||||
|
@ -108,12 +108,12 @@ public final class RdeStagingReducer extends Reducer<PendingDeposit, DepositFrag
|
|||
};
|
||||
String lockName = String.format("RdeStaging %s", key.mode());
|
||||
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) {
|
||||
logger.infofmt("RdeStagingReducer %s", key);
|
||||
logger.atInfo().log("RdeStagingReducer %s", key);
|
||||
|
||||
// Normally this is done by BackendServlet but it's not present in MapReduceServlet.
|
||||
Security.addProvider(new BouncyCastleProvider());
|
||||
|
@ -148,7 +148,7 @@ public final class RdeStagingReducer extends Reducer<PendingDeposit, DepositFrag
|
|||
XjcRdeHeader header;
|
||||
|
||||
// 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);
|
||||
Ghostryde.Encryptor encryptor = ghostryde.openEncryptor(gcsOutput, stagingKey);
|
||||
Ghostryde.Compressor kompressor = ghostryde.openCompressor(encryptor);
|
||||
|
@ -167,7 +167,7 @@ public final class RdeStagingReducer extends Reducer<PendingDeposit, DepositFrag
|
|||
}
|
||||
if (!fragment.error().isEmpty()) {
|
||||
failed = true;
|
||||
logger.severefmt("Fragment error: %s", fragment.error());
|
||||
logger.atSevere().log("Fragment error: %s", fragment.error());
|
||||
}
|
||||
}
|
||||
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
|
||||
// be outputted. We don't want to have to decrypt the entire ghostryde file to determine the
|
||||
// length, so we just save it separately.
|
||||
logger.infofmt("Writing %s", xmlLengthFilename);
|
||||
logger.atInfo().log("Writing %s", xmlLengthFilename);
|
||||
try (OutputStream gcsOutput = cloudStorage.openOutputStream(xmlLengthFilename)) {
|
||||
gcsOutput.write(Long.toString(xmlLength).getBytes(US_ASCII));
|
||||
} 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.
|
||||
if (mode == RdeMode.FULL) {
|
||||
logger.infofmt("Writing %s", reportFilename);
|
||||
logger.atInfo().log("Writing %s", reportFilename);
|
||||
String innerName = prefix + "-report.xml";
|
||||
try (OutputStream gcsOutput = cloudStorage.openOutputStream(reportFilename);
|
||||
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.
|
||||
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;
|
||||
}
|
||||
ofy()
|
||||
|
@ -235,7 +235,7 @@ public final class RdeStagingReducer extends Reducer<PendingDeposit, DepositFrag
|
|||
checkState(key.interval() != null, "Interval must be present");
|
||||
DateTime newPosition = key.watermark().plus(key.interval());
|
||||
if (!position.isBefore(newPosition)) {
|
||||
logger.warning("Cursor has already been rolled forward.");
|
||||
logger.atWarning().log("Cursor has already been rolled forward.");
|
||||
return;
|
||||
}
|
||||
verify(
|
||||
|
@ -244,7 +244,7 @@ public final class RdeStagingReducer extends Reducer<PendingDeposit, DepositFrag
|
|||
position,
|
||||
key);
|
||||
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);
|
||||
RdeRevision.saveRevision(tld, watermark, mode, revision);
|
||||
if (mode == RdeMode.FULL) {
|
||||
|
|
|
@ -29,8 +29,8 @@ import static java.util.Arrays.asList;
|
|||
import com.google.appengine.api.taskqueue.Queue;
|
||||
import com.google.appengine.tools.cloudstorage.GcsFilename;
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.google.common.io.ByteStreams;
|
||||
import com.google.common.logging.FormattingLogger;
|
||||
import com.jcraft.jsch.JSch;
|
||||
import com.jcraft.jsch.JSchException;
|
||||
import dagger.Lazy;
|
||||
|
@ -86,7 +86,7 @@ public final class RdeUploadAction implements Runnable, EscrowTask {
|
|||
|
||||
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 GcsUtils gcsUtils;
|
||||
|
@ -135,14 +135,15 @@ public final class RdeUploadAction implements Runnable, EscrowTask {
|
|||
DateTime stagingCursorTime = getCursorTimeOrStartOfTime(
|
||||
ofy().load().key(Cursor.createKey(CursorType.RDE_STAGING, Registry.get(tld))).now());
|
||||
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");
|
||||
}
|
||||
DateTime sftpCursorTime = getCursorTimeOrStartOfTime(
|
||||
ofy().load().key(Cursor.createKey(RDE_UPLOAD_SFTP, Registry.get(tld))).now());
|
||||
if (sftpCursorTime.plus(sftpCooldown).isAfter(clock.nowUtc())) {
|
||||
// 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");
|
||||
}
|
||||
int revision = RdeRevision.getNextRevision(tld, watermark, FULL) - 1;
|
||||
|
@ -199,7 +200,7 @@ public final class RdeUploadAction implements Runnable, EscrowTask {
|
|||
@VisibleForTesting
|
||||
protected void upload(
|
||||
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);
|
||||
Ghostryde.Decryptor decryptor = ghostryde.openDecryptor(gcsInput, stagingDecryptionKey);
|
||||
Ghostryde.Decompressor decompressor = ghostryde.openDecompressor(decryptor);
|
||||
|
@ -221,12 +222,12 @@ public final class RdeUploadAction implements Runnable, EscrowTask {
|
|||
ByteStreams.copy(xmlInput, tarLayer);
|
||||
}
|
||||
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";
|
||||
gcsUtils.createFromBytes(new GcsFilename(bucket, sigFilename), signature);
|
||||
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
Loading…
Add table
Add a link
Reference in a new issue