mirror of
https://github.com/google/nomulus.git
synced 2025-05-12 22:38:16 +02:00
Ad-hoc refresh of all domains to clean up orphan glues
------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=130424917
This commit is contained in:
parent
467286d79e
commit
d2f033d9ed
5 changed files with 90 additions and 1 deletions
|
@ -14,9 +14,11 @@ java_library(
|
|||
"//third_party/java/appengine:appengine-api",
|
||||
"//third_party/java/appengine_mapreduce2:appengine_mapreduce",
|
||||
"//third_party/java/dagger",
|
||||
"//third_party/java/joda_time",
|
||||
"//third_party/java/jsr305_annotations",
|
||||
"//third_party/java/jsr330_inject",
|
||||
"//third_party/java/objectify:objectify-v4_1",
|
||||
"//java/google/registry/dns",
|
||||
"//java/google/registry/mapreduce",
|
||||
"//java/google/registry/mapreduce/inputs",
|
||||
"//java/google/registry/model",
|
||||
|
|
|
@ -0,0 +1,79 @@
|
|||
// 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.tools.server.javascrap;
|
||||
|
||||
import static google.registry.mapreduce.inputs.EppResourceInputs.createEntityInput;
|
||||
import static google.registry.util.PipelineUtils.createJobPath;
|
||||
|
||||
import com.google.appengine.tools.mapreduce.Mapper;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import google.registry.dns.DnsQueue;
|
||||
import google.registry.mapreduce.MapreduceRunner;
|
||||
import google.registry.model.EppResourceUtils;
|
||||
import google.registry.model.domain.DomainResource;
|
||||
import google.registry.request.Action;
|
||||
import google.registry.request.Response;
|
||||
import google.registry.util.FormattingLogger;
|
||||
import javax.inject.Inject;
|
||||
import org.joda.time.DateTime;
|
||||
import org.joda.time.DateTimeZone;
|
||||
|
||||
/** A mapreduce that runs publishHost() on all active domains. */
|
||||
@Action(path = "/_dr/task/refreshAllDomains")
|
||||
public class RefreshAllDomainsAction implements Runnable {
|
||||
|
||||
private static final FormattingLogger logger = FormattingLogger.getLoggerForCallerClass();
|
||||
|
||||
static DnsQueue dnsQueue = DnsQueue.create();
|
||||
|
||||
@Inject MapreduceRunner mrRunner;
|
||||
@Inject Response response;
|
||||
@Inject RefreshAllDomainsAction() {}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
response.sendJavaScriptRedirect(
|
||||
createJobPath(
|
||||
mrRunner
|
||||
.setJobName("Refresh all domains")
|
||||
.setModuleName("backend")
|
||||
.setDefaultMapShards(10)
|
||||
.runMapOnly(
|
||||
new RefreshAllDomainsActionMapper(),
|
||||
ImmutableList.of(createEntityInput(DomainResource.class)))));
|
||||
}
|
||||
|
||||
/** Mapper to refresh all active domain resources. */
|
||||
public static class RefreshAllDomainsActionMapper extends Mapper<DomainResource, Void, Void> {
|
||||
|
||||
private static final long serialVersionUID = 1356876487351666133L;
|
||||
|
||||
@Override
|
||||
public final void map(final DomainResource domain) {
|
||||
final String domainName = domain.getFullyQualifiedDomainName();
|
||||
if (EppResourceUtils.isActive(domain, DateTime.now(DateTimeZone.UTC))) {
|
||||
try {
|
||||
dnsQueue.addDomainRefreshTask(domainName);
|
||||
getContext().incrementCounter("active domains refreshed");
|
||||
} catch (Throwable t) {
|
||||
logger.severefmt(t, "Error while refreshing DNS for domain %s", domainName);
|
||||
getContext().incrementCounter("active domains errored");
|
||||
}
|
||||
} else {
|
||||
getContext().incrementCounter("inactive domains skipped");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue