Change commit log bucket counts in tests

I'm setting it to three buckets across all tests, because the default one bucket
wasn't realistic enough, and allowed some tests to pass that shouldn't have,
essentially by accident.

This also changes RegistryConfig from being an interface to being an abstract
base class. The medium term goal here is to have it be a static class so that it
can provide fields from the YAML-derived POJO in situations where Dagger
injection isn't feasible.

The expected end state is as follows:

default-config.yaml -- The master config file that provides defaults for all
values.

nomulus-config.yaml -- A per-environment config file that overrides the defaults
from the previous file.

YamlConfig.java -- The POJO that the aforementioned YAML files are deserialized
into.

RegistryConfig.java -- Contains a static, memoized instance of YamlConfig and
provides static methods for getting some of those values.

ConfigModule -- Will become a static inner class of RegistryConfig, using Dagger
to provide most of the fields from the memoized YamlConfig instance. This way,
all configuration will be coming from a single place: RegistryConfig.java.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=143567288
This commit is contained in:
mcilwain 2017-01-04 10:18:52 -08:00 committed by Ben McIlwain
parent 734130aa73
commit c35c3a678b
18 changed files with 119 additions and 206 deletions

View file

@ -17,6 +17,7 @@ package google.registry.model.ofy;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.collect.DiscreteDomain.integers;
import static com.googlecode.objectify.ObjectifyService.ofy;
import static google.registry.config.RegistryConfig.getCommitLogBucketCount;
import static google.registry.util.DateTimeUtils.START_OF_TIME;
import com.google.common.base.Function;
@ -29,7 +30,7 @@ import com.google.common.collect.Range;
import com.googlecode.objectify.Key;
import com.googlecode.objectify.annotation.Entity;
import com.googlecode.objectify.annotation.Id;
import google.registry.config.RegistryEnvironment;
import google.registry.config.RegistryConfig;
import google.registry.model.Buildable;
import google.registry.model.ImmutableObject;
import google.registry.model.annotations.NotBackedUp;
@ -41,8 +42,8 @@ import org.joda.time.DateTime;
/**
* Root for a random commit log bucket.
*
* <p>This is used to shard {@link CommitLogManifest} objects into {@link
* google.registry.config.RegistryConfig#getCommitLogBucketCount() N} entity groups. This increases
* <p>This is used to shard {@link CommitLogManifest} objects into
* {@link RegistryConfig#getCommitLogBucketCount() N} entity groups. This increases
* transaction throughput, while maintaining the ability to perform strongly-consistent ancestor
* queries.
*
@ -53,11 +54,11 @@ import org.joda.time.DateTime;
@NotBackedUp(reason = Reason.COMMIT_LOGS)
public class CommitLogBucket extends ImmutableObject implements Buildable {
private static final RegistryEnvironment ENVIRONMENT = RegistryEnvironment.get();
/** Ranges from 1 to {@link #getNumBuckets()}, inclusive; starts at 1 since IDs can't be 0. */
@Id
long bucketNum;
/**
* Ranges from 1 to {@link RegistryConfig#getCommitLogBucketCount()}, inclusive; starts at 1 since
* IDs can't be 0.
*/
@Id long bucketNum;
/** The timestamp of the last {@link CommitLogManifest} written to this bucket. */
DateTime lastWrittenTime = START_OF_TIME;
@ -90,12 +91,8 @@ public class CommitLogBucket extends ImmutableObject implements Buildable {
return ContiguousSet.create(getBucketIdRange(), integers());
}
private static int getNumBuckets() {
return ENVIRONMENT.config().getCommitLogBucketCount();
}
private static Range<Integer> getBucketIdRange() {
return Range.closed(1, getNumBuckets());
return Range.closed(1, getCommitLogBucketCount());
}
/** Returns an arbitrary numeric bucket ID. Default behavior is randomly chosen IDs. */
@ -116,7 +113,7 @@ public class CommitLogBucket extends ImmutableObject implements Buildable {
@Override
public Integer get() {
return random.nextInt(getNumBuckets()) + 1; // Add 1 since IDs can't be 0.
return random.nextInt(getCommitLogBucketCount()) + 1; // Add 1 since IDs can't be 0.
}
};