Action to delete all cross-tld entities.

Plus refactoring of the KillAllXXXActions and tests to share
common code.

This essentially completes the KillAll []s. We can now reliably
clean out everything except for:
 * Lock - harmless to leave alone or delete from the gae console
 * GaeUserIdConverter - same
 * RdeRevision - filed [] to track, but harmless if not cleaned up
 * ForeignKeyHostIndex of renamed hosts - tracked in []
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=120781975
This commit is contained in:
cgoldfeder 2016-04-25 22:09:58 -07:00 committed by Justine Tunney
parent ac2f17e10f
commit a41677aea1
9 changed files with 508 additions and 205 deletions

View file

@ -15,16 +15,15 @@
package com.google.domain.registry.tools.server;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.collect.Lists.partition;
import static com.google.domain.registry.model.ofy.ObjectifyService.ofy;
import static com.google.domain.registry.request.Action.Method.POST;
import static com.google.domain.registry.util.PipelineUtils.createJobPath;
import com.google.appengine.tools.mapreduce.Input;
import com.google.appengine.tools.mapreduce.Mapper;
import com.google.appengine.tools.mapreduce.inputs.InMemoryInput;
import com.google.common.collect.FluentIterable;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
import com.google.domain.registry.config.RegistryEnvironment;
import com.google.domain.registry.mapreduce.MapreduceAction;
import com.google.domain.registry.mapreduce.MapreduceRunner;
@ -48,27 +47,27 @@ public class KillAllCommitLogsAction implements MapreduceAction {
@Inject KillAllCommitLogsAction() {}
@Override
public void run() {
public final void run() {
checkArgument( // safety
RegistryEnvironment.get() == RegistryEnvironment.CRASH
|| RegistryEnvironment.get() == RegistryEnvironment.UNITTEST,
"DO NOT RUN ANYWHERE ELSE EXCEPT CRASH OR TESTS.");
// Create a in-memory input, assigning each bucket to its own shard for maximum parallelization,
// with one extra shard for the CommitLogCheckpointRoot.
Input<Key<?>> input = new InMemoryInput<>(
Lists.partition(
FluentIterable
.from(Arrays.<Key<?>>asList(CommitLogCheckpointRoot.getKey()))
.append(CommitLogBucket.getAllBucketKeys())
.toList(),
1));
response.sendJavaScriptRedirect(createJobPath(mrRunner
.setJobName("Delete all commit logs")
.setJobName("Delete all commit logs and checkpoints")
.setModuleName("tools")
.runMapreduce(
new KillAllCommitLogsMapper(),
new KillAllEntitiesReducer(),
ImmutableList.of(input))));
// Create a in-memory input, assigning each bucket to its own shard for maximum
// parallelization, with one extra shard for the CommitLogCheckpointRoot.
ImmutableList.of(
new InMemoryInput<>(
partition(
FluentIterable
.from(Arrays.<Key<?>>asList(CommitLogCheckpointRoot.getKey()))
.append(CommitLogBucket.getAllBucketKeys())
.toList(),
1))))));
}
/**