mirror of
https://github.com/google/nomulus
synced 2026-09-04 15:17:13 +00:00
Make DnsWriter truly atomic
Right now - if there's an error during DnsWriter.publish*, all the publish from before that error will be committed, while all the publish after that error will not. More than that - in some writers partial publishes can be committed, depending on implementation. This defines a new contract that publish* are only committed when .commit is called. That way any error will simply mean no publish is committed. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=165708063
This commit is contained in:
@@ -14,6 +14,8 @@
|
||||
|
||||
package google.registry.dns.writer;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkState;
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
@@ -35,6 +37,8 @@ public final class VoidDnsWriter implements DnsWriter {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(VoidDnsWriter.class.getName());
|
||||
|
||||
private boolean committed = false;
|
||||
|
||||
private final Set<String> names = new HashSet<>();
|
||||
|
||||
@Inject
|
||||
@@ -51,7 +55,10 @@ public final class VoidDnsWriter implements DnsWriter {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
public void commit() {
|
||||
checkState(!committed, "commit() has already been called");
|
||||
committed = true;
|
||||
|
||||
logger.warning("Ignoring DNS zone updates! No DnsWriterFactory implementation specified!\n"
|
||||
+ Joiner.on('\n').join(names));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user