mirror of
https://github.com/google/nomulus.git
synced 2025-05-13 07:57:13 +02:00
Use some Java 8 features in commit log code
------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=190985373
This commit is contained in:
parent
c40eda3235
commit
54a8cd09ea
2 changed files with 8 additions and 9 deletions
|
@ -116,13 +116,12 @@ class CommitLogCheckpointStrategy {
|
|||
ImmutableMap<Integer, DateTime> readBucketTimestamps() {
|
||||
// Use a fresh session cache so that we get the latest data from Datastore.
|
||||
return ofy.doWithFreshSessionCache(
|
||||
() -> {
|
||||
ImmutableMap.Builder<Integer, DateTime> results = new ImmutableMap.Builder<>();
|
||||
for (CommitLogBucket bucket : CommitLogBucket.loadAllBuckets()) {
|
||||
results.put(bucket.getBucketNum(), bucket.getLastWrittenTime());
|
||||
}
|
||||
return results.build();
|
||||
});
|
||||
() ->
|
||||
CommitLogBucket.loadAllBuckets()
|
||||
.stream()
|
||||
.collect(
|
||||
ImmutableMap.toImmutableMap(
|
||||
CommitLogBucket::getBucketNum, CommitLogBucket::getLastWrittenTime)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -21,7 +21,6 @@ import static google.registry.config.RegistryConfig.getCommitLogBucketCount;
|
|||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
||||
import static google.registry.util.DateTimeUtils.START_OF_TIME;
|
||||
|
||||
import com.google.common.base.Supplier;
|
||||
import com.google.common.collect.ContiguousSet;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.ImmutableSortedSet;
|
||||
|
@ -36,6 +35,7 @@ import google.registry.model.annotations.NotBackedUp;
|
|||
import google.registry.model.annotations.NotBackedUp.Reason;
|
||||
import google.registry.util.NonFinalForTesting;
|
||||
import java.util.Random;
|
||||
import java.util.function.Supplier;
|
||||
import org.joda.time.DateTime;
|
||||
|
||||
/**
|
||||
|
@ -119,7 +119,7 @@ public class CommitLogBucket extends ImmutableObject implements Buildable {
|
|||
/** Returns the loaded bucket for the given key, or a new object if the bucket doesn't exist. */
|
||||
public static CommitLogBucket loadBucket(Key<CommitLogBucket> bucketKey) {
|
||||
CommitLogBucket bucket = ofy().load().key(bucketKey).now();
|
||||
return bucket == null
|
||||
return (bucket == null)
|
||||
? new CommitLogBucket.Builder().setBucketNum(bucketKey.getId()).build()
|
||||
: bucket;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue