mirror of
https://github.com/google/nomulus.git
synced 2025-05-13 07:57:13 +02:00
Add sharded DNS publishing capability
This enables sharded DNS publishing on a per-TLD basis. Instead of a TLD-wide lock, the sharded scheme locks each update on the shard number, allowing parallel writes to DNS. We allow N (the number of shards) to be 0 or 1 for no sharding, and N > 1 for an N-way sharding scheme. Unless explicitly set, all TLDs default to a numShards of 0, so we don't have to reload all registry objects explicitly. WARNING: This will change the lock name upon deployment for the PublishDnsAction from "<TLD> Dns Updates" to "<TLD> Dns Updates shard 0". This may cause concurrency issues if the underlying DNSWriter is not parallel-write tolerant (currently all production usages are ZonemanWriter, which is parallel-tolerant, so no issues are expected). ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=187525655
This commit is contained in:
parent
24799b394d
commit
fa989e754b
16 changed files with 474 additions and 64 deletions
|
@ -18,7 +18,9 @@ import static com.google.common.base.Preconditions.checkArgument;
|
|||
import static google.registry.util.PreconditionsUtils.checkArgumentNotNull;
|
||||
|
||||
import com.google.common.base.Ascii;
|
||||
import com.google.common.base.Joiner;
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.net.InternetDomainName;
|
||||
|
||||
/** Utility methods related to domain names. */
|
||||
|
@ -78,5 +80,34 @@ public final class DomainNameUtils {
|
|||
return domainName.parent().toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the second level domain name for a fully qualified host name under a given tld.
|
||||
*
|
||||
* <p>This function is merely a string parsing utility, and does not verify if the tld is operated
|
||||
* by the registry.
|
||||
*
|
||||
* @throws IllegalArgumentException if either argument is null or empty, or the domain name is not
|
||||
* under the tld
|
||||
*/
|
||||
public static String getSecondLevelDomain(String hostName, String tld) {
|
||||
checkArgument(
|
||||
!Strings.isNullOrEmpty(hostName),
|
||||
"hostName cannot be null or empty");
|
||||
checkArgument(!Strings.isNullOrEmpty(tld), "tld cannot be null or empty");
|
||||
ImmutableList<String> domainParts = InternetDomainName.from(hostName).parts();
|
||||
ImmutableList<String> tldParts = InternetDomainName.from(tld).parts();
|
||||
checkArgument(
|
||||
domainParts.size() > tldParts.size(),
|
||||
"hostName must be at least one level below the tld");
|
||||
checkArgument(
|
||||
domainParts
|
||||
.subList(domainParts.size() - tldParts.size(), domainParts.size())
|
||||
.equals(tldParts),
|
||||
"hostName must be under the tld");
|
||||
ImmutableList<String> sldParts =
|
||||
domainParts.subList(domainParts.size() - tldParts.size() - 1, domainParts.size());
|
||||
return Joiner.on(".").join(sldParts);
|
||||
}
|
||||
|
||||
private DomainNameUtils() {}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue