Send a plaintext link to the mapreduce console in fluent style

The link was previously being sent using a JS redirect, which doesn't work
because the endpoints that trigger mapreduces can only be hit from the command
line (because they require auth). This commit switches the link to be in
plaintext and renders the full URL instead of just the path, so that clicking it
directly from the terminal works.

This also improves how these links are sent from callsites by using a fluent
style.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=228764606
This commit is contained in:
mcilwain 2019-01-10 13:20:08 -08:00 committed by Ben McIlwain
parent 072576ec9d
commit 765e63e7e9
31 changed files with 202 additions and 239 deletions

View file

@ -16,7 +16,6 @@ package google.registry.rde;
import static google.registry.request.Action.Method.GET;
import static google.registry.request.Action.Method.POST;
import static google.registry.util.PipelineUtils.createJobPath;
import static google.registry.xml.ValidationMode.LENIENT;
import static google.registry.xml.ValidationMode.STRICT;
import static javax.servlet.http.HttpServletResponse.SC_NO_CONTENT;
@ -228,7 +227,7 @@ public final class RdeStagingAction implements Runnable {
}
RdeStagingMapper mapper = new RdeStagingMapper(lenient ? LENIENT : STRICT, pendings);
response.sendJavaScriptRedirect(createJobPath(mrRunner
mrRunner
.setJobName("Stage escrow deposits for all TLDs")
.setModuleName("backend")
.setDefaultReduceShards(pendings.size())
@ -237,8 +236,8 @@ public final class RdeStagingAction implements Runnable {
reducer,
ImmutableList.of(
// Add an extra shard that maps over a null resource. See the mapper code for why.
new NullInput<>(),
EppResourceInputs.createEntityInput(EppResource.class)))));
new NullInput<>(), EppResourceInputs.createEntityInput(EppResource.class)))
.sendLinkToMapreduceConsole(response);
}
private ImmutableSetMultimap<String, PendingDeposit> getStandardPendingDeposits() {

View file

@ -16,7 +16,6 @@ package google.registry.rde.imports;
import static google.registry.mapreduce.MapreduceRunner.PARAM_MAP_SHARDS;
import static google.registry.model.ofy.ObjectifyService.ofy;
import static google.registry.util.PipelineUtils.createJobPath;
import com.google.appengine.tools.cloudstorage.GcsService;
import com.google.appengine.tools.cloudstorage.GcsServiceFactory;
@ -77,12 +76,11 @@ public class RdeContactImportAction implements Runnable {
@Override
public void run() {
response.sendJavaScriptRedirect(createJobPath(mrRunner
mrRunner
.setJobName("Import contacts from escrow file")
.setModuleName("backend")
.runMapOnly(
createMapper(),
ImmutableList.of(createInput()))));
.runMapOnly(createMapper(), ImmutableList.of(createInput()))
.sendLinkToMapreduceConsole(response);
}
/**

View file

@ -25,7 +25,6 @@ import static google.registry.rde.imports.RdeImportUtils.createAutoRenewBillingE
import static google.registry.rde.imports.RdeImportUtils.createAutoRenewPollMessageForDomainImport;
import static google.registry.rde.imports.RdeImportUtils.createHistoryEntryForDomainImport;
import static google.registry.rde.imports.RdeImportsModule.PATH;
import static google.registry.util.PipelineUtils.createJobPath;
import static google.registry.util.PreconditionsUtils.checkArgumentNotNull;
import com.google.appengine.tools.cloudstorage.GcsService;
@ -107,12 +106,11 @@ public class RdeDomainImportAction implements Runnable {
logger.atInfo().log(
"Launching domains import mapreduce: bucket=%s, filename=%s",
this.importBucketName, this.importFileName);
response.sendJavaScriptRedirect(createJobPath(mrRunner
mrRunner
.setJobName("Import domains from escrow file")
.setModuleName("backend")
.runMapOnly(
createMapper(),
ImmutableList.of(createInput()))));
.runMapOnly(createMapper(), ImmutableList.of(createInput()))
.sendLinkToMapreduceConsole(response);
}
/**

View file

@ -16,7 +16,6 @@ package google.registry.rde.imports;
import static google.registry.mapreduce.MapreduceRunner.PARAM_MAP_SHARDS;
import static google.registry.model.ofy.ObjectifyService.ofy;
import static google.registry.util.PipelineUtils.createJobPath;
import com.google.appengine.tools.cloudstorage.GcsService;
import com.google.appengine.tools.cloudstorage.GcsServiceFactory;
@ -77,12 +76,13 @@ public class RdeHostImportAction implements Runnable {
@Override
public void run() {
response.sendJavaScriptRedirect(createJobPath(mrRunner
mrRunner
.setJobName("Import hosts from escrow file")
.setModuleName("backend")
.runMapOnly(
new RdeHostImportMapper(importBucketName),
ImmutableList.of(new RdeHostInput(mapShards, importBucketName, importFileName)))));
ImmutableList.of(new RdeHostInput(mapShards, importBucketName, importFileName)))
.sendLinkToMapreduceConsole(response);
}
/** Mapper to import hosts from an escrow file. */

View file

@ -19,7 +19,6 @@ import static google.registry.mapreduce.MapreduceRunner.PARAM_MAP_SHARDS;
import static google.registry.model.EppResourceUtils.loadByForeignKey;
import static google.registry.model.ofy.ObjectifyService.ofy;
import static google.registry.model.registry.Registries.findTldForName;
import static google.registry.util.PipelineUtils.createJobPath;
import static java.util.stream.Collectors.joining;
import com.google.appengine.tools.mapreduce.Mapper;
@ -86,12 +85,13 @@ public class RdeHostLinkAction implements Runnable {
@Override
public void run() {
response.sendJavaScriptRedirect(createJobPath(mrRunner
mrRunner
.setJobName("Link hosts from escrow file")
.setModuleName("backend")
.runMapOnly(
new RdeHostPostImportMapper(),
ImmutableList.of(new RdeHostInput(mapShards, importBucketName, importFileName)))));
ImmutableList.of(new RdeHostInput(mapShards, importBucketName, importFileName)))
.sendLinkToMapreduceConsole(response);
}
/** Mapper to link hosts from an escrow file to their superordinate domains. */