mirror of
https://github.com/google/nomulus.git
synced 2025-05-13 07:57:13 +02:00
Delete obsoleted non-batched DNS refresh on host rename action
------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=135681285
This commit is contained in:
parent
f7a205975f
commit
94c549d960
7 changed files with 6 additions and 253 deletions
|
@ -17,7 +17,7 @@ package google.registry.flows.async;
|
|||
import static google.registry.flows.async.DeleteContactsAndHostsAction.PARAM_IS_SUPERUSER;
|
||||
import static google.registry.flows.async.DeleteContactsAndHostsAction.PARAM_REQUESTING_CLIENT_ID;
|
||||
import static google.registry.flows.async.DeleteContactsAndHostsAction.PARAM_RESOURCE_KEY;
|
||||
import static google.registry.flows.async.DnsRefreshForHostRenameAction.PARAM_HOST_KEY;
|
||||
import static google.registry.flows.async.RefreshDnsOnHostRenameAction.PARAM_HOST_KEY;
|
||||
import static google.registry.flows.async.RefreshDnsOnHostRenameAction.QUEUE_ASYNC_HOST_RENAME;
|
||||
|
||||
import com.google.appengine.api.taskqueue.Queue;
|
||||
|
|
|
@ -15,17 +15,13 @@
|
|||
package google.registry.flows.async;
|
||||
|
||||
import static google.registry.flows.async.DeleteContactsAndHostsAction.QUEUE_ASYNC_DELETE;
|
||||
import static google.registry.flows.async.DnsRefreshForHostRenameAction.PARAM_HOST_KEY;
|
||||
import static google.registry.flows.async.RefreshDnsOnHostRenameAction.QUEUE_ASYNC_HOST_RENAME;
|
||||
import static google.registry.request.RequestParameters.extractRequiredParameter;
|
||||
|
||||
import com.google.appengine.api.taskqueue.Queue;
|
||||
import com.google.appengine.api.taskqueue.QueueFactory;
|
||||
import dagger.Module;
|
||||
import dagger.Provides;
|
||||
import google.registry.request.Parameter;
|
||||
import javax.inject.Named;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
/** Dagger module for the async flows package. */
|
||||
@Module
|
||||
|
@ -42,11 +38,4 @@ public final class AsyncFlowsModule {
|
|||
static Queue provideAsyncHostRenamePullQueue() {
|
||||
return QueueFactory.getQueue(QUEUE_ASYNC_HOST_RENAME);
|
||||
}
|
||||
|
||||
//TODO(b/26140521): Delete this method once non-batched DNS host refresh mapreduce is deleted.
|
||||
@Provides
|
||||
@Parameter(PARAM_HOST_KEY)
|
||||
static String provideHostKey(HttpServletRequest req) {
|
||||
return extractRequiredParameter(req, PARAM_HOST_KEY);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,105 +0,0 @@
|
|||
// Copyright 2016 The Domain Registry 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.flows.async;
|
||||
|
||||
import static google.registry.model.EppResourceUtils.isActive;
|
||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
||||
import static google.registry.util.PipelineUtils.createJobPath;
|
||||
import static google.registry.util.PreconditionsUtils.checkArgumentNotNull;
|
||||
|
||||
import com.google.appengine.tools.mapreduce.Mapper;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.googlecode.objectify.Key;
|
||||
import google.registry.dns.DnsQueue;
|
||||
import google.registry.mapreduce.MapreduceRunner;
|
||||
import google.registry.mapreduce.inputs.EppResourceInputs;
|
||||
import google.registry.model.domain.DomainResource;
|
||||
import google.registry.model.host.HostResource;
|
||||
import google.registry.request.Action;
|
||||
import google.registry.request.HttpException.BadRequestException;
|
||||
import google.registry.request.Parameter;
|
||||
import google.registry.request.Response;
|
||||
import google.registry.util.FormattingLogger;
|
||||
import google.registry.util.NonFinalForTesting;
|
||||
import javax.inject.Inject;
|
||||
import org.joda.time.DateTime;
|
||||
|
||||
/**
|
||||
* Enqueues DNS refreshes for applicable domains following a host rename.
|
||||
*/
|
||||
//TODO(b/26140521): Delete this once non-batched DNS host refresh mapreduce is deleted.
|
||||
@Action(path = "/_dr/task/dnsRefreshForHostRename")
|
||||
public class DnsRefreshForHostRenameAction implements Runnable {
|
||||
|
||||
/** The HTTP parameter name used to specify the websafe key of the host to rename. */
|
||||
public static final String PARAM_HOST_KEY = "hostKey";
|
||||
|
||||
private static final FormattingLogger logger = FormattingLogger.getLoggerForCallerClass();
|
||||
|
||||
@NonFinalForTesting
|
||||
static DnsQueue dnsQueue = DnsQueue.create();
|
||||
|
||||
@Inject @Parameter(PARAM_HOST_KEY) String hostKeyString;
|
||||
@Inject MapreduceRunner mrRunner;
|
||||
@Inject Response response;
|
||||
@Inject DnsRefreshForHostRenameAction() {}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
Key<HostResource> resourceKey = null;
|
||||
HostResource host;
|
||||
try {
|
||||
resourceKey = Key.create(hostKeyString);
|
||||
host = checkArgumentNotNull(ofy().load().key(resourceKey).now());
|
||||
} catch (IllegalArgumentException e) {
|
||||
throw new BadRequestException(resourceKey == null
|
||||
? "Could not parse key string: " + hostKeyString
|
||||
: "Could not load resource for key: " + resourceKey);
|
||||
}
|
||||
response.sendJavaScriptRedirect(createJobPath(mrRunner
|
||||
.setJobName("Enqueue DNS refreshes for domains following a host rename")
|
||||
.setModuleName("backend")
|
||||
.runMapOnly(
|
||||
new DnsRefreshForHostRenameMapper(host),
|
||||
ImmutableList.of(EppResourceInputs.createEntityInput(DomainResource.class)))));
|
||||
}
|
||||
|
||||
/** Map over domains and refresh the dns of those that referenced this host. */
|
||||
public static class DnsRefreshForHostRenameMapper extends Mapper<DomainResource, Void, Void> {
|
||||
|
||||
private static final long serialVersionUID = -4707015136971008447L;
|
||||
|
||||
private final DateTime hostUpdateTime;
|
||||
private final Key<HostResource> targetHostKey;
|
||||
|
||||
DnsRefreshForHostRenameMapper(HostResource host) {
|
||||
this.targetHostKey = Key.create(host);
|
||||
this.hostUpdateTime = host.getUpdateAutoTimestamp().getTimestamp();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void map(DomainResource domain) {
|
||||
if (isActive(domain, hostUpdateTime)
|
||||
&& domain.getNameservers().contains(targetHostKey)) {
|
||||
try {
|
||||
dnsQueue.addDomainRefreshTask(domain.getFullyQualifiedDomainName());
|
||||
logger.infofmt("Enqueued refresh for domain %s", domain.getFullyQualifiedDomainName());
|
||||
} catch (Throwable t) {
|
||||
logger.severefmt(t, "Error while refreshing DNS for host rename %s", targetHostKey);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue