Explicitly set the shard size when saving the claims list

This allows us to get rid of the use of InjectRule in tests.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=218221409
This commit is contained in:
jianglai 2018-10-22 13:21:06 -07:00
parent 6a560c18ce
commit 589e98a1db
2 changed files with 12 additions and 18 deletions

View file

@ -39,7 +39,6 @@ import google.registry.model.annotations.VirtualEntity;
import google.registry.model.common.CrossTldSingleton;
import google.registry.util.CollectionUtils;
import google.registry.util.Concurrent;
import google.registry.util.NonFinalForTesting;
import google.registry.util.Retrier;
import google.registry.util.SystemSleeper;
import java.util.HashMap;
@ -69,10 +68,8 @@ import org.joda.time.DateTime;
@NotBackedUp(reason = Reason.EXTERNALLY_SOURCED)
public class ClaimsListShard extends ImmutableObject {
/** The number of claims list entries to store per shard. Do not modify except for in tests. */
@VisibleForTesting
@NonFinalForTesting
static int shardSize = 10000;
/** The number of claims list entries to store per shard. */
private static final int SHARD_SIZE = 10000;
@Id
long id;
@ -165,6 +162,11 @@ public class ClaimsListShard extends ImmutableObject {
* switching over to using them atomically, then deleting the old ones.
*/
public void save() {
save(SHARD_SIZE);
}
@VisibleForTesting
void save(int shardSize) {
// Figure out what the next versionId should be based on which ones already exist.
final Key<ClaimsListRevision> oldRevision = getCurrentRevision();
final Key<ClaimsListRevision> parentKey = ClaimsListRevision.createKey();