mirror of
https://github.com/google/nomulus.git
synced 2025-05-19 18:59:35 +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 = "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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,6 @@ java_library(
|
|||
name = "imports",
|
||||
srcs = glob(["*.java"]),
|
||||
deps = [
|
||||
"//java/com/google/common/logging:formatting_logger",
|
||||
"//java/google/registry/config",
|
||||
"//java/google/registry/dns",
|
||||
"//java/google/registry/flows",
|
||||
|
@ -30,6 +29,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",
|
||||
"@javax_servlet_api",
|
||||
"@joda_time",
|
||||
|
|
|
@ -23,7 +23,7 @@ import com.google.appengine.tools.cloudstorage.GcsServiceFactory;
|
|||
import com.google.appengine.tools.cloudstorage.RetryParams;
|
||||
import com.google.appengine.tools.mapreduce.Mapper;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.logging.FormattingLogger;
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.googlecode.objectify.VoidWork;
|
||||
import google.registry.config.RegistryConfig.Config;
|
||||
import google.registry.config.RegistryConfig.ConfigModule;
|
||||
|
@ -52,7 +52,7 @@ import javax.inject.Inject;
|
|||
)
|
||||
public class RdeContactImportAction implements Runnable {
|
||||
|
||||
private static final FormattingLogger logger = FormattingLogger.getLoggerForCallerClass();
|
||||
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
|
||||
private static final GcsService GCS_SERVICE =
|
||||
GcsServiceFactory.createGcsService(RetryParams.getDefaultInstance());
|
||||
|
||||
|
@ -135,10 +135,10 @@ public class RdeContactImportAction implements Runnable {
|
|||
public void map(JaxbFragment<XjcRdeContactElement> fragment) {
|
||||
final XjcRdeContact xjcContact = fragment.getInstance().getValue();
|
||||
try {
|
||||
logger.infofmt("Converting xml for contact %s", xjcContact.getId());
|
||||
logger.atInfo().log("Converting xml for contact %s", xjcContact.getId());
|
||||
// Record number of attempted map operations
|
||||
getContext().incrementCounter("contact imports attempted");
|
||||
logger.infofmt("Saving contact %s", xjcContact.getId());
|
||||
logger.atInfo().log("Saving contact %s", xjcContact.getId());
|
||||
ofy().transact(new VoidWork() {
|
||||
@Override
|
||||
public void vrun() {
|
||||
|
@ -149,15 +149,16 @@ public class RdeContactImportAction implements Runnable {
|
|||
});
|
||||
// Record number of contacts imported
|
||||
getContext().incrementCounter("contacts saved");
|
||||
logger.infofmt("Contact %s was imported successfully", xjcContact.getId());
|
||||
logger.atInfo().log("Contact %s was imported successfully", xjcContact.getId());
|
||||
} catch (ResourceExistsException e) {
|
||||
// Record the number of contacts already in the registry
|
||||
getContext().incrementCounter("existing contacts skipped");
|
||||
logger.infofmt("Contact %s already exists", xjcContact.getId());
|
||||
logger.atInfo().log("Contact %s already exists", xjcContact.getId());
|
||||
} catch (Exception e) {
|
||||
// Record the number of contacts with unexpected errors
|
||||
getContext().incrementCounter("contact import errors");
|
||||
logger.severefmt(e, "Error importing contact %s; xml=%s", xjcContact.getId(), xjcContact);
|
||||
logger.atSevere().withCause(e).log(
|
||||
"Error importing contact %s; xml=%s", xjcContact.getId(), xjcContact);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ import com.google.appengine.tools.cloudstorage.GcsService;
|
|||
import com.google.appengine.tools.cloudstorage.GcsServiceFactory;
|
||||
import com.google.appengine.tools.cloudstorage.RetryParams;
|
||||
import com.google.appengine.tools.mapreduce.InputReader;
|
||||
import com.google.common.logging.FormattingLogger;
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import google.registry.config.RegistryConfig.ConfigModule;
|
||||
import google.registry.gcs.GcsUtils;
|
||||
import google.registry.xjc.JaxbFragment;
|
||||
|
@ -37,7 +37,7 @@ public class RdeContactReader extends InputReader<JaxbFragment<XjcRdeContactElem
|
|||
|
||||
private static final long serialVersionUID = -3688793834175577691L;
|
||||
|
||||
private static final FormattingLogger logger = FormattingLogger.getLoggerForCallerClass();
|
||||
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
|
||||
private static final GcsService GCS_SERVICE =
|
||||
GcsServiceFactory.createGcsService(RetryParams.getDefaultInstance());
|
||||
|
||||
|
@ -65,8 +65,8 @@ public class RdeContactReader extends InputReader<JaxbFragment<XjcRdeContactElem
|
|||
parser.skipContacts(offset + count);
|
||||
return parser;
|
||||
} catch (Exception e) {
|
||||
logger.severefmt(e, "Error opening rde file %s/%s", importBucketName, importFileName);
|
||||
throw new RuntimeException(e);
|
||||
throw new RuntimeException(
|
||||
String.format("Error opening rde file %s/%s", importBucketName, importFileName), e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ import com.google.appengine.tools.cloudstorage.RetryParams;
|
|||
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.VoidWork;
|
||||
import google.registry.config.RegistryConfig.Config;
|
||||
import google.registry.config.RegistryConfig.ConfigModule;
|
||||
|
@ -75,7 +75,7 @@ import org.joda.time.DateTime;
|
|||
)
|
||||
public class RdeDomainImportAction implements Runnable {
|
||||
|
||||
private static final FormattingLogger logger = FormattingLogger.getLoggerForCallerClass();
|
||||
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
|
||||
private static final GcsService GCS_SERVICE =
|
||||
GcsServiceFactory.createGcsService(RetryParams.getDefaultInstance());
|
||||
|
||||
|
@ -101,10 +101,9 @@ public class RdeDomainImportAction implements Runnable {
|
|||
|
||||
@Override
|
||||
public void run() {
|
||||
logger.infofmt(
|
||||
logger.atInfo().log(
|
||||
"Launching domains import mapreduce: bucket=%s, filename=%s",
|
||||
this.importBucketName,
|
||||
this.importFileName);
|
||||
this.importBucketName, this.importFileName);
|
||||
response.sendJavaScriptRedirect(createJobPath(mrRunner
|
||||
.setJobName("Import domains from escrow file")
|
||||
.setModuleName("backend")
|
||||
|
@ -173,7 +172,7 @@ public class RdeDomainImportAction implements Runnable {
|
|||
// Record number of attempted map operations
|
||||
getContext().incrementCounter("domain imports attempted");
|
||||
|
||||
logger.infofmt("Saving domain %s", xjcDomain.getName());
|
||||
logger.atInfo().log("Saving domain %s", xjcDomain.getName());
|
||||
ofy()
|
||||
.transact(
|
||||
new VoidWork() {
|
||||
|
@ -288,14 +287,15 @@ public class RdeDomainImportAction implements Runnable {
|
|||
});
|
||||
// Record the number of domains imported
|
||||
getContext().incrementCounter("domains saved");
|
||||
logger.infofmt("Domain %s was imported successfully", xjcDomain.getName());
|
||||
logger.atInfo().log("Domain %s was imported successfully", xjcDomain.getName());
|
||||
} catch (ResourceExistsException e) {
|
||||
// Record the number of domains already in the registry
|
||||
getContext().incrementCounter("existing domains skipped");
|
||||
logger.infofmt("Domain %s already exists", xjcDomain.getName());
|
||||
logger.atInfo().log("Domain %s already exists", xjcDomain.getName());
|
||||
} catch (Exception e) {
|
||||
getContext().incrementCounter("domain import errors");
|
||||
logger.severefmt(e, "Error processing domain %s; xml=%s", xjcDomain.getName(), xjcDomain);
|
||||
logger.atSevere().withCause(e).log(
|
||||
"Error processing domain %s; xml=%s", xjcDomain.getName(), xjcDomain);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ import com.google.appengine.tools.cloudstorage.GcsService;
|
|||
import com.google.appengine.tools.cloudstorage.GcsServiceFactory;
|
||||
import com.google.appengine.tools.cloudstorage.RetryParams;
|
||||
import com.google.appengine.tools.mapreduce.InputReader;
|
||||
import com.google.common.logging.FormattingLogger;
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import google.registry.config.RegistryConfig.ConfigModule;
|
||||
import google.registry.gcs.GcsUtils;
|
||||
import google.registry.xjc.JaxbFragment;
|
||||
|
@ -34,7 +34,7 @@ public class RdeDomainReader extends InputReader<JaxbFragment<XjcRdeDomainElemen
|
|||
implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -2175777052970160122L;
|
||||
private static final FormattingLogger logger = FormattingLogger.getLoggerForCallerClass();
|
||||
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
|
||||
private static final GcsService GCS_SERVICE =
|
||||
GcsServiceFactory.createGcsService(RetryParams.getDefaultInstance());
|
||||
|
||||
|
@ -62,8 +62,8 @@ public class RdeDomainReader extends InputReader<JaxbFragment<XjcRdeDomainElemen
|
|||
parser.skipDomains(offset + count);
|
||||
return parser;
|
||||
} catch (Exception e) {
|
||||
logger.severefmt(e, "Error opening rde file %s/%s", importBucketName, importFileName);
|
||||
throw new RuntimeException(e);
|
||||
throw new RuntimeException(
|
||||
String.format("Error opening rde file %s/%s", importBucketName, importFileName), e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ import com.google.appengine.tools.cloudstorage.GcsServiceFactory;
|
|||
import com.google.appengine.tools.cloudstorage.RetryParams;
|
||||
import com.google.appengine.tools.mapreduce.Mapper;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.logging.FormattingLogger;
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.googlecode.objectify.VoidWork;
|
||||
import google.registry.config.RegistryConfig.Config;
|
||||
import google.registry.config.RegistryConfig.ConfigModule;
|
||||
|
@ -52,7 +52,7 @@ import javax.inject.Inject;
|
|||
)
|
||||
public class RdeHostImportAction implements Runnable {
|
||||
|
||||
private static final FormattingLogger logger = FormattingLogger.getLoggerForCallerClass();
|
||||
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
|
||||
private static final GcsService GCS_SERVICE =
|
||||
GcsServiceFactory.createGcsService(RetryParams.getDefaultInstance());
|
||||
|
||||
|
@ -123,7 +123,7 @@ public class RdeHostImportAction implements Runnable {
|
|||
try {
|
||||
// Record number of attempted map operations
|
||||
getContext().incrementCounter("host imports attempted");
|
||||
logger.infofmt("Saving host %s", xjcHost.getName());
|
||||
logger.atInfo().log("Saving host %s", xjcHost.getName());
|
||||
ofy().transact(new VoidWork() {
|
||||
|
||||
@Override
|
||||
|
@ -134,15 +134,16 @@ public class RdeHostImportAction implements Runnable {
|
|||
});
|
||||
// Record number of hosts imported
|
||||
getContext().incrementCounter("hosts saved");
|
||||
logger.infofmt("Host %s was imported successfully", xjcHost.getName());
|
||||
logger.atInfo().log("Host %s was imported successfully", xjcHost.getName());
|
||||
} catch (ResourceExistsException e) {
|
||||
// Record the number of hosts already in the registry
|
||||
getContext().incrementCounter("existing hosts skipped");
|
||||
logger.infofmt("Host %s already exists", xjcHost.getName());
|
||||
logger.atInfo().log("Host %s already exists", xjcHost.getName());
|
||||
} catch (Exception e) {
|
||||
// Record the number of hosts with unexpected errors
|
||||
getContext().incrementCounter("host import errors");
|
||||
logger.severefmt(e, "Error processing host %s; xml=%s", xjcHost.getName(), xjcHost);
|
||||
logger.atSevere().withCause(e).log(
|
||||
"Error processing host %s; xml=%s", xjcHost.getName(), xjcHost);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ import static java.util.stream.Collectors.joining;
|
|||
|
||||
import com.google.appengine.tools.mapreduce.Mapper;
|
||||
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.googlecode.objectify.Key;
|
||||
import google.registry.config.RegistryConfig.Config;
|
||||
|
@ -62,7 +62,7 @@ import org.joda.time.DateTime;
|
|||
)
|
||||
public class RdeHostLinkAction implements Runnable {
|
||||
|
||||
private static final FormattingLogger logger = FormattingLogger.getLoggerForCallerClass();
|
||||
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
|
||||
|
||||
private final MapreduceRunner mrRunner;
|
||||
private final Response response;
|
||||
|
@ -105,7 +105,7 @@ public class RdeHostLinkAction implements Runnable {
|
|||
// Record number of attempted map operations
|
||||
getContext().incrementCounter("post-import hosts read");
|
||||
final XjcRdeHost xjcHost = fragment.getInstance().getValue();
|
||||
logger.infofmt("Attempting to link superordinate domain for host %s", xjcHost.getName());
|
||||
logger.atInfo().log("Attempting to link superordinate domain for host %s", xjcHost.getName());
|
||||
try {
|
||||
final InternetDomainName hostName = InternetDomainName.from(xjcHost.getName());
|
||||
|
||||
|
@ -142,31 +142,32 @@ public class RdeHostLinkAction implements Runnable {
|
|||
switch (hostLinkResult) {
|
||||
case HOST_LINKED:
|
||||
getContext().incrementCounter("post-import hosts linked");
|
||||
logger.infofmt(
|
||||
logger.atInfo().log(
|
||||
"Successfully linked host %s to superordinate domain", xjcHost.getName());
|
||||
// Record number of hosts successfully linked
|
||||
break;
|
||||
case HOST_NOT_FOUND:
|
||||
getContext().incrementCounter("hosts not found");
|
||||
logger.severefmt(
|
||||
logger.atSevere().log(
|
||||
"Host with name %s and repoid %s not found", xjcHost.getName(), xjcHost.getRoid());
|
||||
break;
|
||||
case SUPERORDINATE_DOMAIN_IN_PENDING_DELETE:
|
||||
getContext()
|
||||
.incrementCounter(
|
||||
"post-import hosts with superordinate domains in pending delete");
|
||||
logger.infofmt(
|
||||
logger.atInfo().log(
|
||||
"Host %s has a superordinate domain in pending delete", xjcHost.getName());
|
||||
break;
|
||||
case HOST_OUT_OF_ZONE:
|
||||
getContext().incrementCounter("post-import hosts out of zone");
|
||||
logger.infofmt("Host %s is out of zone", xjcHost.getName());
|
||||
logger.atInfo().log("Host %s is out of zone", xjcHost.getName());
|
||||
break;
|
||||
}
|
||||
} catch (RuntimeException e) {
|
||||
// Record the number of hosts with unexpected errors
|
||||
getContext().incrementCounter("post-import host errors");
|
||||
logger.severefmt(e, "Error linking host %s; xml=%s", xjcHost.getName(), xjcHost);
|
||||
logger.atSevere().withCause(e).log(
|
||||
"Error linking host %s; xml=%s", xjcHost.getName(), xjcHost);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ import com.google.appengine.tools.cloudstorage.GcsService;
|
|||
import com.google.appengine.tools.cloudstorage.GcsServiceFactory;
|
||||
import com.google.appengine.tools.cloudstorage.RetryParams;
|
||||
import com.google.appengine.tools.mapreduce.InputReader;
|
||||
import com.google.common.logging.FormattingLogger;
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import google.registry.config.RegistryConfig.ConfigModule;
|
||||
import google.registry.gcs.GcsUtils;
|
||||
import google.registry.xjc.JaxbFragment;
|
||||
|
@ -37,7 +37,7 @@ public class RdeHostReader extends InputReader<JaxbFragment<XjcRdeHostElement>>
|
|||
|
||||
private static final long serialVersionUID = 3037264959150412846L;
|
||||
|
||||
private static final FormattingLogger logger = FormattingLogger.getLoggerForCallerClass();
|
||||
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
|
||||
private static final GcsService GCS_SERVICE =
|
||||
GcsServiceFactory.createGcsService(RetryParams.getDefaultInstance());
|
||||
|
||||
|
@ -65,8 +65,8 @@ public class RdeHostReader extends InputReader<JaxbFragment<XjcRdeHostElement>>
|
|||
parser.skipHosts(offset + count);
|
||||
return parser;
|
||||
} catch (Exception e) {
|
||||
logger.severefmt(e, "Error opening RDE file %s/%s", importBucketName, importFileName);
|
||||
throw new RuntimeException(e);
|
||||
throw new RuntimeException(
|
||||
String.format("Error opening RDE file %s/%s", importBucketName, importFileName), e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -25,8 +25,8 @@ import static java.nio.charset.StandardCharsets.UTF_8;
|
|||
|
||||
import com.google.appengine.tools.cloudstorage.GcsFilename;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.google.common.io.BaseEncoding;
|
||||
import com.google.common.logging.FormattingLogger;
|
||||
import com.googlecode.objectify.Key;
|
||||
import google.registry.config.RegistryConfig.Config;
|
||||
import google.registry.flows.ServerTridProvider;
|
||||
|
@ -67,7 +67,7 @@ import javax.xml.stream.XMLStreamException;
|
|||
*/
|
||||
public class RdeImportUtils {
|
||||
|
||||
private static final FormattingLogger logger = FormattingLogger.getLoggerForCallerClass();
|
||||
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
|
||||
|
||||
private final Ofy ofy;
|
||||
private final Clock clock;
|
||||
|
@ -121,11 +121,9 @@ public class RdeImportUtils {
|
|||
.add(resource)
|
||||
.addAll(createIndexesForEppResource(resource))
|
||||
.build());
|
||||
logger.infofmt(
|
||||
logger.atInfo().log(
|
||||
"Imported %s resource - ROID=%s, id=%s",
|
||||
resource.getClass().getSimpleName(),
|
||||
resource.getRepoId(),
|
||||
resource.getForeignKey());
|
||||
resource.getClass().getSimpleName(), resource.getRepoId(), resource.getForeignKey());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue