mirror of
https://github.com/google/nomulus.git
synced 2025-06-27 06:44:51 +02:00
Run automatic Java 8 conversion over codebase
------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=171174380
This commit is contained in:
parent
44df5da771
commit
5edb7935ed
190 changed files with 2312 additions and 3096 deletions
|
@ -18,6 +18,7 @@ import static com.google.appengine.api.taskqueue.QueueConstants.maxLeaseCount;
|
|||
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.math.IntMath.divide;
|
||||
import static com.googlecode.objectify.Key.getKind;
|
||||
import static google.registry.flows.ResourceFlowUtils.denyPendingTransfer;
|
||||
|
@ -52,8 +53,6 @@ import com.google.appengine.tools.mapreduce.Mapper;
|
|||
import com.google.appengine.tools.mapreduce.Reducer;
|
||||
import com.google.appengine.tools.mapreduce.ReducerInput;
|
||||
import com.google.auto.value.AutoValue;
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.collect.FluentIterable;
|
||||
import com.google.common.collect.HashMultiset;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
@ -94,7 +93,6 @@ import google.registry.util.SystemClock;
|
|||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.Callable;
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
import org.joda.time.DateTime;
|
||||
|
@ -180,22 +178,11 @@ public class DeleteContactsAndHostsAction implements Runnable {
|
|||
return;
|
||||
}
|
||||
final List<TaskHandle> tasks =
|
||||
FluentIterable.from(deletionRequests)
|
||||
.transform(
|
||||
new Function<DeletionRequest, TaskHandle>() {
|
||||
@Override
|
||||
public TaskHandle apply(DeletionRequest deletionRequest) {
|
||||
return deletionRequest.task();
|
||||
}
|
||||
})
|
||||
.toList();
|
||||
deletionRequests.stream().map(DeletionRequest::task).collect(toImmutableList());
|
||||
retrier.callWithRetry(
|
||||
new Callable<Void>() {
|
||||
@Override
|
||||
public Void call() throws Exception {
|
||||
queue.deleteTask(tasks);
|
||||
return null;
|
||||
}
|
||||
() -> {
|
||||
queue.deleteTask(tasks);
|
||||
return null;
|
||||
},
|
||||
TransientFailureException.class);
|
||||
for (DeletionRequest deletionRequest : deletionRequests) {
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
package google.registry.batch;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkState;
|
||||
import static com.google.common.collect.ImmutableSet.toImmutableSet;
|
||||
import static google.registry.flows.ResourceFlowUtils.updateForeignKeyIndexDeletionTime;
|
||||
import static google.registry.mapreduce.MapreduceRunner.PARAM_DRY_RUN;
|
||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
||||
|
@ -24,11 +25,8 @@ import static google.registry.request.Action.Method.POST;
|
|||
import static org.joda.time.DateTimeZone.UTC;
|
||||
|
||||
import com.google.appengine.tools.mapreduce.Mapper;
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.base.Splitter;
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.collect.FluentIterable;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Iterables;
|
||||
|
@ -94,21 +92,11 @@ public class DeleteProberDataAction implements Runnable {
|
|||
}
|
||||
|
||||
private static ImmutableSet<String> getProberRoidSuffixes() {
|
||||
return FluentIterable.from(getTldsOfType(TldType.TEST))
|
||||
.filter(new Predicate<String>() {
|
||||
@Override
|
||||
public boolean apply(String tld) {
|
||||
// Extra sanity check to prevent us from nuking prod data if a real TLD accidentally
|
||||
// gets set to type TEST.
|
||||
return tld.endsWith(".test");
|
||||
}})
|
||||
.transform(
|
||||
new Function<String, String>() {
|
||||
@Override
|
||||
public String apply(String tld) {
|
||||
return Registry.get(tld).getRoidSuffix();
|
||||
}})
|
||||
.toSet();
|
||||
return getTldsOfType(TldType.TEST)
|
||||
.stream()
|
||||
.filter(tld -> tld.endsWith(".test"))
|
||||
.map(tld -> Registry.get(tld).getRoidSuffix())
|
||||
.collect(toImmutableSet());
|
||||
}
|
||||
|
||||
/** Provides the map method that runs for each existing DomainBase entity. */
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
package google.registry.batch;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.collect.ImmutableSet.toImmutableSet;
|
||||
import static com.google.common.collect.Sets.difference;
|
||||
import static google.registry.mapreduce.MapreduceRunner.PARAM_DRY_RUN;
|
||||
import static google.registry.mapreduce.inputs.EppResourceInputs.createChildEntityInput;
|
||||
|
@ -32,13 +33,11 @@ import static google.registry.util.PipelineUtils.createJobPath;
|
|||
import com.google.appengine.tools.mapreduce.Mapper;
|
||||
import com.google.appengine.tools.mapreduce.Reducer;
|
||||
import com.google.appengine.tools.mapreduce.ReducerInput;
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Optional;
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.collect.FluentIterable;
|
||||
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.googlecode.objectify.Key;
|
||||
import com.googlecode.objectify.VoidWork;
|
||||
import com.googlecode.objectify.Work;
|
||||
|
@ -262,14 +261,10 @@ public class ExpandRecurringBillingEventsAction implements Runnable {
|
|||
DateTime cursorTime,
|
||||
DateTime executeTime,
|
||||
final Registry tld) {
|
||||
return FluentIterable.from(eventTimes)
|
||||
.transform(new Function<DateTime, DateTime>() {
|
||||
@Override
|
||||
public DateTime apply(DateTime eventTime) {
|
||||
return eventTime.plus(tld.getAutoRenewGracePeriodLength());
|
||||
}})
|
||||
return Streams.stream(eventTimes)
|
||||
.map(eventTime -> eventTime.plus(tld.getAutoRenewGracePeriodLength()))
|
||||
.filter(Range.closedOpen(cursorTime, executeTime))
|
||||
.toSet();
|
||||
.collect(toImmutableSet());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -279,19 +274,13 @@ public class ExpandRecurringBillingEventsAction implements Runnable {
|
|||
private ImmutableSet<DateTime> getExistingBillingTimes(
|
||||
Iterable<BillingEvent.OneTime> oneTimesForDomain,
|
||||
final BillingEvent.Recurring recurringEvent) {
|
||||
return FluentIterable.from(oneTimesForDomain)
|
||||
.filter(new Predicate<BillingEvent.OneTime>() {
|
||||
@Override
|
||||
public boolean apply(OneTime billingEvent) {
|
||||
return Key.create(recurringEvent)
|
||||
.equals(billingEvent.getCancellationMatchingBillingEvent());
|
||||
}})
|
||||
.transform(new Function<OneTime, DateTime>() {
|
||||
@Override
|
||||
public DateTime apply(OneTime billingEvent) {
|
||||
return billingEvent.getBillingTime();
|
||||
}})
|
||||
.toSet();
|
||||
return Streams.stream(oneTimesForDomain)
|
||||
.filter(
|
||||
billingEvent ->
|
||||
Key.create(recurringEvent)
|
||||
.equals(billingEvent.getCancellationMatchingBillingEvent()))
|
||||
.map(OneTime::getBillingTime)
|
||||
.collect(toImmutableSet());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@ package google.registry.batch;
|
|||
import static com.google.appengine.api.taskqueue.QueueConstants.maxLeaseCount;
|
||||
import static com.google.appengine.api.taskqueue.QueueFactory.getQueue;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static com.google.common.collect.ImmutableList.toImmutableList;
|
||||
import static google.registry.flows.async.AsyncFlowEnqueuer.PARAM_HOST_KEY;
|
||||
import static google.registry.flows.async.AsyncFlowEnqueuer.PARAM_REQUESTED_TIME;
|
||||
import static google.registry.flows.async.AsyncFlowEnqueuer.QUEUE_ASYNC_HOST_RENAME;
|
||||
|
@ -38,8 +39,6 @@ import com.google.appengine.tools.mapreduce.Mapper;
|
|||
import com.google.appengine.tools.mapreduce.Reducer;
|
||||
import com.google.appengine.tools.mapreduce.ReducerInput;
|
||||
import com.google.auto.value.AutoValue;
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.collect.FluentIterable;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.googlecode.objectify.Key;
|
||||
|
@ -61,7 +60,6 @@ import google.registry.util.SystemClock;
|
|||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.Callable;
|
||||
import javax.annotation.Nullable;
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
|
@ -180,12 +178,11 @@ public class RefreshDnsOnHostRenameAction implements Runnable {
|
|||
}
|
||||
if (referencingHostKey != null) {
|
||||
retrier.callWithRetry(
|
||||
new Callable<Void>() {
|
||||
@Override
|
||||
public Void call() throws Exception {
|
||||
dnsQueue.addDomainRefreshTask(domain.getFullyQualifiedDomainName());
|
||||
return null;
|
||||
}}, TransientFailureException.class);
|
||||
() -> {
|
||||
dnsQueue.addDomainRefreshTask(domain.getFullyQualifiedDomainName());
|
||||
return null;
|
||||
},
|
||||
TransientFailureException.class);
|
||||
logger.infofmt(
|
||||
"Enqueued DNS refresh for domain %s referenced by host %s.",
|
||||
domain.getFullyQualifiedDomainName(), referencingHostKey);
|
||||
|
@ -244,22 +241,13 @@ public class RefreshDnsOnHostRenameAction implements Runnable {
|
|||
return;
|
||||
}
|
||||
final List<TaskHandle> tasks =
|
||||
FluentIterable.from(refreshRequests)
|
||||
.transform(
|
||||
new Function<DnsRefreshRequest, TaskHandle>() {
|
||||
@Override
|
||||
public TaskHandle apply(DnsRefreshRequest refreshRequest) {
|
||||
return refreshRequest.task();
|
||||
}
|
||||
})
|
||||
.toList();
|
||||
refreshRequests.stream().map(DnsRefreshRequest::task).collect(toImmutableList());
|
||||
retrier.callWithRetry(
|
||||
new Callable<Void>() {
|
||||
@Override
|
||||
public Void call() throws Exception {
|
||||
queue.deleteTask(tasks);
|
||||
return null;
|
||||
}}, TransientFailureException.class);
|
||||
() -> {
|
||||
queue.deleteTask(tasks);
|
||||
return null;
|
||||
},
|
||||
TransientFailureException.class);
|
||||
for (DnsRefreshRequest refreshRequest : refreshRequests) {
|
||||
asyncFlowMetrics.recordAsyncFlowResult(DNS_REFRESH, result, refreshRequest.requestedTime());
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
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.googlecode.objectify.Key.getKind;
|
||||
import static google.registry.model.EppResourceUtils.isActive;
|
||||
|
@ -36,7 +37,6 @@ import com.google.appengine.tools.mapreduce.ReducerInput;
|
|||
import com.google.appengine.tools.mapreduce.inputs.DatastoreKeyInput;
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.collect.FluentIterable;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.googlecode.objectify.Key;
|
||||
|
@ -259,18 +259,24 @@ public class VerifyEntityIntegrityAction implements Runnable {
|
|||
verifyExistence(key, domain.getTransferData().getServerApproveAutorenewEvent());
|
||||
verifyExistence(key, domain.getTransferData().getServerApproveAutorenewPollMessage());
|
||||
verifyExistence(key, domain.getTransferData().getServerApproveBillingEvent());
|
||||
verifyExistence(key, FluentIterable
|
||||
.from(domain.getTransferData().getServerApproveEntities())
|
||||
.transform(
|
||||
new Function<Key<? extends TransferServerApproveEntity>,
|
||||
Key<TransferServerApproveEntity>>() {
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public Key<TransferServerApproveEntity> apply(
|
||||
Key<? extends TransferServerApproveEntity> key) {
|
||||
return (Key<TransferServerApproveEntity>) key;
|
||||
}})
|
||||
.toSet());
|
||||
verifyExistence(
|
||||
key,
|
||||
domain
|
||||
.getTransferData()
|
||||
.getServerApproveEntities()
|
||||
.stream()
|
||||
.map(
|
||||
new Function<
|
||||
Key<? extends TransferServerApproveEntity>,
|
||||
Key<TransferServerApproveEntity>>() {
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public Key<TransferServerApproveEntity> apply(
|
||||
Key<? extends TransferServerApproveEntity> key) {
|
||||
return (Key<TransferServerApproveEntity>) key;
|
||||
}
|
||||
})
|
||||
.collect(toImmutableSet()));
|
||||
verifyExistence(key, domain.getApplication());
|
||||
verifyExistence(key, domain.getAutorenewBillingEvent());
|
||||
for (GracePeriod gracePeriod : domain.getGracePeriods()) {
|
||||
|
|
|
@ -21,19 +21,16 @@ import static google.registry.batch.EntityIntegrityAlertsSchema.FIELD_SCANTIME;
|
|||
import static google.registry.batch.EntityIntegrityAlertsSchema.FIELD_SOURCE;
|
||||
import static google.registry.batch.EntityIntegrityAlertsSchema.FIELD_TARGET;
|
||||
import static google.registry.batch.EntityIntegrityAlertsSchema.TABLE_ID;
|
||||
import static java.util.stream.Collectors.joining;
|
||||
|
||||
import com.google.api.services.bigquery.Bigquery;
|
||||
import com.google.api.services.bigquery.Bigquery.Tabledata.InsertAll;
|
||||
import com.google.api.services.bigquery.model.TableDataInsertAllRequest;
|
||||
import com.google.api.services.bigquery.model.TableDataInsertAllRequest.Rows;
|
||||
import com.google.api.services.bigquery.model.TableDataInsertAllResponse;
|
||||
import com.google.api.services.bigquery.model.TableDataInsertAllResponse.InsertErrors;
|
||||
import com.google.auto.factory.AutoFactory;
|
||||
import com.google.auto.factory.Provided;
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Joiner;
|
||||
import com.google.common.base.Supplier;
|
||||
import com.google.common.collect.FluentIterable;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import google.registry.bigquery.BigqueryFactory;
|
||||
|
@ -183,30 +180,26 @@ public class VerifyEntityIntegrityStreamer {
|
|||
new TableDataInsertAllRequest().setRows(rows));
|
||||
|
||||
Callable<Void> callable =
|
||||
new Callable<Void>() {
|
||||
@Override
|
||||
public Void call() throws Exception {
|
||||
TableDataInsertAllResponse response = request.execute();
|
||||
// Turn errors on the response object into RuntimeExceptions that the retrier will
|
||||
// retry.
|
||||
if (response.getInsertErrors() != null && !response.getInsertErrors().isEmpty()) {
|
||||
throw new RuntimeException(
|
||||
FluentIterable.from(response.getInsertErrors())
|
||||
.transform(
|
||||
new Function<InsertErrors, String>() {
|
||||
@Override
|
||||
public String apply(InsertErrors error) {
|
||||
try {
|
||||
return error.toPrettyString();
|
||||
} catch (IOException e) {
|
||||
return error.toString();
|
||||
}
|
||||
}
|
||||
})
|
||||
.join(Joiner.on('\n')));
|
||||
}
|
||||
return null;
|
||||
() -> {
|
||||
TableDataInsertAllResponse response = request.execute();
|
||||
// Turn errors on the response object into RuntimeExceptions that the retrier will
|
||||
// retry.
|
||||
if (response.getInsertErrors() != null && !response.getInsertErrors().isEmpty()) {
|
||||
throw new RuntimeException(
|
||||
response
|
||||
.getInsertErrors()
|
||||
.stream()
|
||||
.map(
|
||||
error -> {
|
||||
try {
|
||||
return error.toPrettyString();
|
||||
} catch (IOException e) {
|
||||
return error.toString();
|
||||
}
|
||||
})
|
||||
.collect(joining("\n")));
|
||||
}
|
||||
return null;
|
||||
};
|
||||
retrier.callWithRetry(callable, RuntimeException.class);
|
||||
} catch (IOException e) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue