mirror of
https://github.com/google/nomulus.git
synced 2025-05-13 16:07:15 +02:00
Delete the mapreduce poll action
We never used it for anything. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=232024489
This commit is contained in:
parent
7596a0b773
commit
339202e879
5 changed files with 0 additions and 161 deletions
|
@ -121,11 +121,6 @@
|
||||||
<url-pattern>/_dr/task/generateZoneFiles</url-pattern>
|
<url-pattern>/_dr/task/generateZoneFiles</url-pattern>
|
||||||
</servlet-mapping>
|
</servlet-mapping>
|
||||||
|
|
||||||
<servlet-mapping>
|
|
||||||
<servlet-name>tools-servlet</servlet-name>
|
|
||||||
<url-pattern>/_dr/task/pollMapreduce</url-pattern>
|
|
||||||
</servlet-mapping>
|
|
||||||
|
|
||||||
<!-- Security config -->
|
<!-- Security config -->
|
||||||
<security-constraint>
|
<security-constraint>
|
||||||
<web-resource-collection>
|
<web-resource-collection>
|
||||||
|
|
|
@ -41,7 +41,6 @@ import google.registry.tools.server.ListPremiumListsAction;
|
||||||
import google.registry.tools.server.ListRegistrarsAction;
|
import google.registry.tools.server.ListRegistrarsAction;
|
||||||
import google.registry.tools.server.ListReservedListsAction;
|
import google.registry.tools.server.ListReservedListsAction;
|
||||||
import google.registry.tools.server.ListTldsAction;
|
import google.registry.tools.server.ListTldsAction;
|
||||||
import google.registry.tools.server.PollMapreduceAction;
|
|
||||||
import google.registry.tools.server.RefreshDnsForAllDomainsAction;
|
import google.registry.tools.server.RefreshDnsForAllDomainsAction;
|
||||||
import google.registry.tools.server.ResaveAllHistoryEntriesAction;
|
import google.registry.tools.server.ResaveAllHistoryEntriesAction;
|
||||||
import google.registry.tools.server.ToolsServerModule;
|
import google.registry.tools.server.ToolsServerModule;
|
||||||
|
@ -77,7 +76,6 @@ interface ToolsRequestComponent {
|
||||||
ListReservedListsAction listReservedListsAction();
|
ListReservedListsAction listReservedListsAction();
|
||||||
ListTldsAction listTldsAction();
|
ListTldsAction listTldsAction();
|
||||||
LoadTestAction loadTestAction();
|
LoadTestAction loadTestAction();
|
||||||
PollMapreduceAction pollMapReduceAction();
|
|
||||||
RefreshDnsForAllDomainsAction refreshDnsForAllDomainsAction();
|
RefreshDnsForAllDomainsAction refreshDnsForAllDomainsAction();
|
||||||
ResaveAllHistoryEntriesAction resaveAllHistoryEntriesAction();
|
ResaveAllHistoryEntriesAction resaveAllHistoryEntriesAction();
|
||||||
RestoreCommitLogsAction restoreCommitLogsAction();
|
RestoreCommitLogsAction restoreCommitLogsAction();
|
||||||
|
|
|
@ -1,62 +0,0 @@
|
||||||
// Copyright 2017 The Nomulus Authors. All Rights Reserved.
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
package google.registry.tools.server;
|
|
||||||
|
|
||||||
import static com.google.appengine.tools.pipeline.PipelineServiceFactory.newPipelineService;
|
|
||||||
import static google.registry.request.Action.Method.POST;
|
|
||||||
import static javax.servlet.http.HttpServletResponse.SC_OK;
|
|
||||||
|
|
||||||
import com.google.appengine.tools.mapreduce.MapReduceResult;
|
|
||||||
import com.google.appengine.tools.pipeline.JobInfo;
|
|
||||||
import com.google.appengine.tools.pipeline.NoSuchObjectException;
|
|
||||||
import com.google.common.collect.ImmutableMap;
|
|
||||||
import google.registry.request.Action;
|
|
||||||
import google.registry.request.HttpException.InternalServerErrorException;
|
|
||||||
import google.registry.request.JsonResponse;
|
|
||||||
import google.registry.request.Parameter;
|
|
||||||
import google.registry.request.auth.Auth;
|
|
||||||
import javax.inject.Inject;
|
|
||||||
|
|
||||||
/** Action to poll the status of a mapreduce job. */
|
|
||||||
@Action(
|
|
||||||
service = Action.Service.TOOLS,
|
|
||||||
path = PollMapreduceAction.PATH,
|
|
||||||
method = POST,
|
|
||||||
auth = Auth.AUTH_INTERNAL_ONLY)
|
|
||||||
public class PollMapreduceAction implements Runnable {
|
|
||||||
|
|
||||||
public static final String PATH = "/_dr/task/pollMapreduce";
|
|
||||||
|
|
||||||
@Inject @Parameter("jobId") String jobId;
|
|
||||||
@Inject JsonResponse response;
|
|
||||||
@Inject PollMapreduceAction() {}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
JobInfo jobInfo;
|
|
||||||
try {
|
|
||||||
jobInfo = newPipelineService().getJobInfo(jobId);
|
|
||||||
} catch (NoSuchObjectException e) {
|
|
||||||
throw new InternalServerErrorException("Job not found: " + e);
|
|
||||||
}
|
|
||||||
ImmutableMap.Builder<String, String> json = new ImmutableMap.Builder<>();
|
|
||||||
json.put("state", jobInfo.getJobState().toString());
|
|
||||||
if (jobInfo.getJobState() == JobInfo.State.COMPLETED_SUCCESSFULLY) {
|
|
||||||
json.put("output", ((MapReduceResult<?>) jobInfo.getOutput()).getOutputResult().toString());
|
|
||||||
}
|
|
||||||
response.setPayload(json.build());
|
|
||||||
response.setStatus(SC_OK);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -15,7 +15,6 @@ PATH CLASS METHODS OK AUTH
|
||||||
/_dr/task/generateZoneFiles GenerateZoneFilesAction POST n INTERNAL,API APP ADMIN
|
/_dr/task/generateZoneFiles GenerateZoneFilesAction POST n INTERNAL,API APP ADMIN
|
||||||
/_dr/task/killAllCommitLogs KillAllCommitLogsAction POST n INTERNAL APP IGNORED
|
/_dr/task/killAllCommitLogs KillAllCommitLogsAction POST n INTERNAL APP IGNORED
|
||||||
/_dr/task/killAllEppResources KillAllEppResourcesAction POST n INTERNAL APP IGNORED
|
/_dr/task/killAllEppResources KillAllEppResourcesAction POST n INTERNAL APP IGNORED
|
||||||
/_dr/task/pollMapreduce PollMapreduceAction POST n INTERNAL APP IGNORED
|
|
||||||
/_dr/task/refreshDnsForAllDomains RefreshDnsForAllDomainsAction GET n INTERNAL,API APP ADMIN
|
/_dr/task/refreshDnsForAllDomains RefreshDnsForAllDomainsAction GET n INTERNAL,API APP ADMIN
|
||||||
/_dr/task/resaveAllHistoryEntries ResaveAllHistoryEntriesAction GET n INTERNAL,API APP ADMIN
|
/_dr/task/resaveAllHistoryEntries ResaveAllHistoryEntriesAction GET n INTERNAL,API APP ADMIN
|
||||||
/_dr/task/restoreCommitLogs RestoreCommitLogsAction POST y INTERNAL,API APP ADMIN
|
/_dr/task/restoreCommitLogs RestoreCommitLogsAction POST y INTERNAL,API APP ADMIN
|
||||||
|
|
|
@ -1,91 +0,0 @@
|
||||||
// Copyright 2017 The Nomulus Authors. All Rights Reserved.
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
package google.registry.tools.server;
|
|
||||||
|
|
||||||
import static com.google.appengine.tools.pipeline.PipelineServiceFactory.newPipelineService;
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
|
||||||
|
|
||||||
import com.google.appengine.tools.mapreduce.Counters;
|
|
||||||
import com.google.appengine.tools.mapreduce.MapReduceResult;
|
|
||||||
import com.google.appengine.tools.pipeline.Job0;
|
|
||||||
import com.google.appengine.tools.pipeline.JobInfo.State;
|
|
||||||
import com.google.appengine.tools.pipeline.Value;
|
|
||||||
import google.registry.testing.FakeJsonResponse;
|
|
||||||
import google.registry.testing.mapreduce.MapreduceTestCase;
|
|
||||||
import java.util.Map;
|
|
||||||
import org.junit.Before;
|
|
||||||
import org.junit.Test;
|
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
import org.junit.runners.JUnit4;
|
|
||||||
|
|
||||||
/** Tests for {@link PollMapreduceAction}.*/
|
|
||||||
@RunWith(JUnit4.class)
|
|
||||||
public class PollMapreduceActionTest extends MapreduceTestCase<PollMapreduceAction> {
|
|
||||||
|
|
||||||
@Before
|
|
||||||
public void init() {
|
|
||||||
action = new PollMapreduceAction();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testPollUntilSuccess() throws Exception {
|
|
||||||
action.jobId = newPipelineService().startNewPipeline(new SuccessfulJob());
|
|
||||||
assertThat(poll()).containsExactly("state", State.RUNNING.toString());
|
|
||||||
executeTasksUntilEmpty("default");
|
|
||||||
assertThat(poll()).containsExactly(
|
|
||||||
"state", State.COMPLETED_SUCCESSFULLY.toString(), "output", "foobar");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testPollUntilFailure() throws Exception {
|
|
||||||
action.jobId = newPipelineService().startNewPipeline(new ThrowingJob());
|
|
||||||
assertThat(poll()).containsExactly("state", State.RUNNING.toString());
|
|
||||||
executeTasksUntilEmpty("default");
|
|
||||||
assertThat(poll()).containsExactly("state", State.STOPPED_BY_ERROR.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
Map<String, ?> poll() {
|
|
||||||
action.response = new FakeJsonResponse();
|
|
||||||
action.run();
|
|
||||||
return ((FakeJsonResponse) action.response).getResponseMap();
|
|
||||||
}
|
|
||||||
|
|
||||||
/** A job that returns a string. */
|
|
||||||
static class SuccessfulJob extends Job0<MapReduceResult<String>> {
|
|
||||||
@Override
|
|
||||||
public Value<MapReduceResult<String>> run() {
|
|
||||||
MapReduceResult<String> result =
|
|
||||||
new MapReduceResult<String>() {
|
|
||||||
@Override
|
|
||||||
public Counters getCounters() {
|
|
||||||
throw new UnsupportedOperationException();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getOutputResult() {
|
|
||||||
return "foobar";
|
|
||||||
}};
|
|
||||||
return immediate(result);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** A job that throws a RunTimeException when run. */
|
|
||||||
static class ThrowingJob extends Job0<Void> {
|
|
||||||
@Override
|
|
||||||
public Value<Void> run() {
|
|
||||||
throw new RuntimeException("expected");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Add table
Add a link
Reference in a new issue