Replace many Work and VoidWork usages with lambdas

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=176153460
This commit is contained in:
mcilwain 2017-11-17 13:38:53 -08:00 committed by jianglai
parent 603e0470cc
commit cd314bdc75
36 changed files with 443 additions and 680 deletions

View file

@ -22,7 +22,6 @@ import static google.registry.model.ofy.ObjectifyService.ofy;
import static google.registry.util.DateTimeUtils.isBeforeOrAt; import static google.registry.util.DateTimeUtils.isBeforeOrAt;
import static google.registry.util.FormattingLogger.getLoggerForCallerClass; import static google.registry.util.FormattingLogger.getLoggerForCallerClass;
import com.googlecode.objectify.VoidWork;
import google.registry.model.ofy.CommitLogCheckpoint; import google.registry.model.ofy.CommitLogCheckpoint;
import google.registry.model.ofy.CommitLogCheckpointRoot; import google.registry.model.ofy.CommitLogCheckpointRoot;
import google.registry.request.Action; import google.registry.request.Action;
@ -64,23 +63,25 @@ public final class CommitLogCheckpointAction implements Runnable {
public void run() { public void run() {
final CommitLogCheckpoint checkpoint = strategy.computeCheckpoint(); final CommitLogCheckpoint checkpoint = strategy.computeCheckpoint();
logger.info("Generated candidate checkpoint for time " + checkpoint.getCheckpointTime()); logger.info("Generated candidate checkpoint for time " + checkpoint.getCheckpointTime());
ofy().transact(new VoidWork() { ofy()
@Override .transact(
public void vrun() { () -> {
DateTime lastWrittenTime = CommitLogCheckpointRoot.loadRoot().getLastWrittenTime(); DateTime lastWrittenTime = CommitLogCheckpointRoot.loadRoot().getLastWrittenTime();
if (isBeforeOrAt(checkpoint.getCheckpointTime(), lastWrittenTime)) { if (isBeforeOrAt(checkpoint.getCheckpointTime(), lastWrittenTime)) {
logger.info("Newer checkpoint already written at time: " + lastWrittenTime); logger.info("Newer checkpoint already written at time: " + lastWrittenTime);
return; return;
} }
ofy().saveWithoutBackup().entities( ofy()
checkpoint, .saveWithoutBackup()
CommitLogCheckpointRoot.create(checkpoint.getCheckpointTime())); .entities(
checkpoint, CommitLogCheckpointRoot.create(checkpoint.getCheckpointTime()));
// Enqueue a diff task between previous and current checkpoints. // Enqueue a diff task between previous and current checkpoints.
taskEnqueuer.enqueue( taskEnqueuer.enqueue(
getQueue(QUEUE_NAME), getQueue(QUEUE_NAME),
withUrl(ExportCommitLogDiffAction.PATH) withUrl(ExportCommitLogDiffAction.PATH)
.param(LOWER_CHECKPOINT_TIME_PARAM, lastWrittenTime.toString()) .param(LOWER_CHECKPOINT_TIME_PARAM, lastWrittenTime.toString())
.param(UPPER_CHECKPOINT_TIME_PARAM, checkpoint.getCheckpointTime().toString())); .param(
}}); UPPER_CHECKPOINT_TIME_PARAM, checkpoint.getCheckpointTime().toString()));
});
} }
} }

View file

@ -38,7 +38,6 @@ import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Range; import com.google.common.collect.Range;
import com.google.common.collect.Streams; import com.google.common.collect.Streams;
import com.googlecode.objectify.Key; import com.googlecode.objectify.Key;
import com.googlecode.objectify.VoidWork;
import com.googlecode.objectify.Work; import com.googlecode.objectify.Work;
import google.registry.mapreduce.MapreduceRunner; import google.registry.mapreduce.MapreduceRunner;
import google.registry.mapreduce.inputs.NullInput; import google.registry.mapreduce.inputs.NullInput;
@ -315,22 +314,21 @@ public class ExpandRecurringBillingEventsAction implements Runnable {
isDryRun ? "(dry run) " : "", isDryRun ? "(dry run) " : "",
cursorTime, cursorTime,
executionTime); executionTime);
ofy().transact(new VoidWork() { ofy()
@Override .transact(
public void vrun() { () -> {
Cursor cursor = ofy().load().key(Cursor.createGlobalKey(RECURRING_BILLING)).now(); Cursor cursor = ofy().load().key(Cursor.createGlobalKey(RECURRING_BILLING)).now();
DateTime currentCursorTime = (cursor == null ? START_OF_TIME : cursor.getCursorTime()); DateTime currentCursorTime =
(cursor == null ? START_OF_TIME : cursor.getCursorTime());
if (!currentCursorTime.equals(expectedPersistedCursorTime)) { if (!currentCursorTime.equals(expectedPersistedCursorTime)) {
logger.severefmt( logger.severefmt(
"Current cursor position %s does not match expected cursor position %s.", "Current cursor position %s does not match expected cursor position %s.",
currentCursorTime, currentCursorTime, expectedPersistedCursorTime);
expectedPersistedCursorTime);
return; return;
} }
if (!isDryRun) { if (!isDryRun) {
ofy().save().entity(Cursor.createGlobal(RECURRING_BILLING, executionTime)); ofy().save().entity(Cursor.createGlobal(RECURRING_BILLING, executionTime));
} }
}
}); });
} }
} }

View file

@ -20,7 +20,6 @@ import static google.registry.util.PipelineUtils.createJobPath;
import com.google.appengine.tools.mapreduce.Mapper; import com.google.appengine.tools.mapreduce.Mapper;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.googlecode.objectify.Key; import com.googlecode.objectify.Key;
import com.googlecode.objectify.VoidWork;
import google.registry.mapreduce.MapreduceRunner; import google.registry.mapreduce.MapreduceRunner;
import google.registry.mapreduce.inputs.EppResourceInputs; import google.registry.mapreduce.inputs.EppResourceInputs;
import google.registry.model.EppResource; import google.registry.model.EppResource;
@ -70,13 +69,17 @@ public class ResaveAllEppResourcesAction implements Runnable {
@Override @Override
public final void map(final Key<EppResource> resourceKey) { public final void map(final Key<EppResource> resourceKey) {
ofy().transact(new VoidWork() { ofy()
@Override .transact(
public void vrun() { () -> {
EppResource projectedResource = EppResource projectedResource =
ofy().load().key(resourceKey).now().cloneProjectedAtTime(ofy().getTransactionTime()); ofy()
.load()
.key(resourceKey)
.now()
.cloneProjectedAtTime(ofy().getTransactionTime());
ofy().save().entity(projectedResource).now(); ofy().save().entity(projectedResource).now();
}}); });
getContext().incrementCounter(String.format("%s entities re-saved", resourceKey.getKind())); getContext().incrementCounter(String.format("%s entities re-saved", resourceKey.getKind()));
} }
} }

View file

@ -33,7 +33,6 @@ import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSortedSet; import com.google.common.collect.ImmutableSortedSet;
import com.google.common.collect.Ordering; import com.google.common.collect.Ordering;
import com.googlecode.objectify.VoidWork;
import google.registry.model.common.Cursor; import google.registry.model.common.Cursor;
import google.registry.model.registrar.Registrar; import google.registry.model.registrar.Registrar;
import google.registry.model.registrar.RegistrarAddress; import google.registry.model.registrar.RegistrarAddress;
@ -153,11 +152,9 @@ class SyncRegistrarsSheet {
return builder.build(); return builder.build();
}) })
.collect(toImmutableList())); .collect(toImmutableList()));
ofy().transact(new VoidWork() { ofy()
@Override .transact(
public void vrun() { () -> ofy().save().entity(Cursor.createGlobal(SYNC_REGISTRAR_SHEET, executionTime)));
ofy().save().entity(Cursor.createGlobal(SYNC_REGISTRAR_SHEET, executionTime));
}});
} }
private static String convertContacts( private static String convertContacts(

View file

@ -18,7 +18,6 @@ import static google.registry.model.ofy.ObjectifyService.ofy;
import static google.registry.xml.XmlTransformer.prettyPrint; import static google.registry.xml.XmlTransformer.prettyPrint;
import com.google.common.base.Strings; import com.google.common.base.Strings;
import com.googlecode.objectify.Work;
import google.registry.flows.FlowModule.ClientId; import google.registry.flows.FlowModule.ClientId;
import google.registry.flows.FlowModule.DryRun; import google.registry.flows.FlowModule.DryRun;
import google.registry.flows.FlowModule.InputXml; import google.registry.flows.FlowModule.InputXml;
@ -88,9 +87,9 @@ public class FlowRunner {
return eppOutput; return eppOutput;
} }
try { try {
return ofy().transact(new Work<EppOutput>() { return ofy()
@Override .transact(
public EppOutput run() { () -> {
eppMetricBuilder.incrementAttempts(); eppMetricBuilder.incrementAttempts();
try { try {
EppOutput output = EppOutput.create(flowProvider.get().run()); EppOutput output = EppOutput.create(flowProvider.get().run());
@ -101,7 +100,7 @@ public class FlowRunner {
} catch (EppException e) { } catch (EppException e) {
throw new EppRuntimeException(e); throw new EppRuntimeException(e);
} }
}}); });
} catch (DryRunException e) { } catch (DryRunException e) {
return e.output; return e.output;
} catch (EppRuntimeException e) { } catch (EppRuntimeException e) {

View file

@ -36,7 +36,6 @@ import static google.registry.model.ofy.ObjectifyService.ofy;
import static google.registry.util.PreconditionsUtils.checkArgumentNotNull; import static google.registry.util.PreconditionsUtils.checkArgumentNotNull;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import com.googlecode.objectify.VoidWork;
import google.registry.keyring.api.KeySerializer; import google.registry.keyring.api.KeySerializer;
import google.registry.keyring.kms.KmsKeyring.PrivateKeyLabel; import google.registry.keyring.kms.KmsKeyring.PrivateKeyLabel;
import google.registry.keyring.kms.KmsKeyring.PublicKeyLabel; import google.registry.keyring.kms.KmsKeyring.PublicKeyLabel;
@ -186,9 +185,7 @@ public final class KmsUpdater {
final ImmutableMap<String, EncryptResponse> encryptedValues) { final ImmutableMap<String, EncryptResponse> encryptedValues) {
ofy() ofy()
.transact( .transact(
new VoidWork() { () -> {
@Override
public void vrun() {
for (Map.Entry<String, EncryptResponse> entry : encryptedValues.entrySet()) { for (Map.Entry<String, EncryptResponse> entry : encryptedValues.entrySet()) {
String secretName = entry.getKey(); String secretName = entry.getKey();
EncryptResponse revisionData = entry.getValue(); EncryptResponse revisionData = entry.getValue();
@ -199,10 +196,7 @@ public final class KmsUpdater {
.setKmsCryptoKeyVersionName(revisionData.cryptoKeyVersionName()) .setKmsCryptoKeyVersionName(revisionData.cryptoKeyVersionName())
.setParent(secretName) .setParent(secretName)
.build(); .build();
ofy() ofy().save().entities(secretRevision, KmsSecret.create(secretName, secretRevision));
.save()
.entities(secretRevision, KmsSecret.create(secretName, secretRevision));
}
} }
}); });
} }

View file

@ -30,7 +30,6 @@ import com.google.common.collect.FluentIterable;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Iterables; import com.google.common.collect.Iterables;
import com.googlecode.objectify.Key; import com.googlecode.objectify.Key;
import com.googlecode.objectify.VoidWork;
import com.googlecode.objectify.Work; import com.googlecode.objectify.Work;
import com.googlecode.objectify.annotation.EmbedMap; import com.googlecode.objectify.annotation.EmbedMap;
import com.googlecode.objectify.annotation.Entity; import com.googlecode.objectify.annotation.Entity;
@ -157,9 +156,7 @@ public class SignedMarkRevocationList extends ImmutableObject {
public SignedMarkRevocationList save() { public SignedMarkRevocationList save() {
ofy() ofy()
.transact( .transact(
new VoidWork() { () -> {
@Override
public void vrun() {
ofy() ofy()
.deleteWithoutBackup() .deleteWithoutBackup()
.keys( .keys(
@ -174,14 +171,12 @@ public class SignedMarkRevocationList extends ImmutableObject {
FluentIterable.from(CollectionUtils.partitionMap(revokes, SHARD_SIZE)) FluentIterable.from(CollectionUtils.partitionMap(revokes, SHARD_SIZE))
.transform( .transform(
(ImmutableMap<String, DateTime> shardRevokes) -> { (ImmutableMap<String, DateTime> shardRevokes) -> {
SignedMarkRevocationList shard = SignedMarkRevocationList shard = create(creationTime, shardRevokes);
create(creationTime, shardRevokes);
shard.id = allocateId(); shard.id = allocateId();
shard.isShard = shard.isShard =
true; // Avoid the exception in disallowUnshardedSaves(). true; // Avoid the exception in disallowUnshardedSaves().
return shard; return shard;
})); }));
}
}); });
return this; return this;
} }

View file

@ -26,7 +26,6 @@ import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Supplier; import com.google.common.base.Supplier;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import com.googlecode.objectify.Key; import com.googlecode.objectify.Key;
import com.googlecode.objectify.VoidWork;
import com.googlecode.objectify.Work; import com.googlecode.objectify.Work;
import com.googlecode.objectify.annotation.EmbedMap; import com.googlecode.objectify.annotation.EmbedMap;
import com.googlecode.objectify.annotation.Entity; import com.googlecode.objectify.annotation.Entity;
@ -178,32 +177,30 @@ public class ClaimsListShard extends ImmutableObject {
(final ImmutableMap<String, String> labelsToKeysShard) -> (final ImmutableMap<String, String> labelsToKeysShard) ->
ofy() ofy()
.transactNew( .transactNew(
new Work<ClaimsListShard>() { () -> {
@Override
public ClaimsListShard run() {
ClaimsListShard shard = create(creationTime, labelsToKeysShard); ClaimsListShard shard = create(creationTime, labelsToKeysShard);
shard.isShard = true; shard.isShard = true;
shard.parent = parentKey; shard.parent = parentKey;
ofy().saveWithoutBackup().entity(shard); ofy().saveWithoutBackup().entity(shard);
return shard; return shard;
}
})); }));
// Persist the new revision, thus causing the newly created shards to go live. // Persist the new revision, thus causing the newly created shards to go live.
ofy().transactNew(new VoidWork() { ofy()
@Override .transactNew(
public void vrun() { () -> {
verify( verify(
(getCurrentRevision() == null && oldRevision == null) (getCurrentRevision() == null && oldRevision == null)
|| getCurrentRevision().equals(oldRevision), || getCurrentRevision().equals(oldRevision),
"ClaimsList on Registries was updated by someone else while attempting to update."); "Registries' ClaimsList was updated by someone else while attempting to update.");
ofy().saveWithoutBackup().entity(ClaimsListSingleton.create(parentKey)); ofy().saveWithoutBackup().entity(ClaimsListSingleton.create(parentKey));
// Delete the old ClaimsListShard entities. // Delete the old ClaimsListShard entities.
if (oldRevision != null) { if (oldRevision != null) {
ofy().deleteWithoutBackup() ofy()
.deleteWithoutBackup()
.keys(ofy().load().type(ClaimsListShard.class).ancestor(oldRevision).keys()); .keys(ofy().load().type(ClaimsListShard.class).ancestor(oldRevision).keys());
} }
}}); });
} }
public static ClaimsListShard create( public static ClaimsListShard create(

View file

@ -17,7 +17,6 @@ package google.registry.model.tmch;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
import static google.registry.model.ofy.ObjectifyService.ofy; import static google.registry.model.ofy.ObjectifyService.ofy;
import com.googlecode.objectify.VoidWork;
import com.googlecode.objectify.annotation.Entity; import com.googlecode.objectify.annotation.Entity;
import google.registry.model.annotations.NotBackedUp; import google.registry.model.annotations.NotBackedUp;
import google.registry.model.annotations.NotBackedUp.Reason; import google.registry.model.annotations.NotBackedUp.Reason;
@ -49,15 +48,15 @@ public final class TmchCrl extends CrossTldSingleton {
* and actually newer than the one currently in Datastore. * and actually newer than the one currently in Datastore.
*/ */
public static void set(final String crl, final String url) { public static void set(final String crl, final String url) {
ofy().transactNew(new VoidWork() { ofy()
@Override .transactNew(
public void vrun() { () -> {
TmchCrl tmchCrl = new TmchCrl(); TmchCrl tmchCrl = new TmchCrl();
tmchCrl.updated = ofy().getTransactionTime(); tmchCrl.updated = ofy().getTransactionTime();
tmchCrl.crl = checkNotNull(crl, "crl"); tmchCrl.crl = checkNotNull(crl, "crl");
tmchCrl.url = checkNotNull(url, "url"); tmchCrl.url = checkNotNull(url, "url");
ofy().saveWithoutBackup().entity(tmchCrl); ofy().saveWithoutBackup().entity(tmchCrl);
}}); });
} }
/** ASCII-armored X.509 certificate revocation list. */ /** ASCII-armored X.509 certificate revocation list. */

View file

@ -16,7 +16,6 @@ package google.registry.rde;
import static google.registry.model.ofy.ObjectifyService.ofy; import static google.registry.model.ofy.ObjectifyService.ofy;
import com.googlecode.objectify.VoidWork;
import google.registry.model.common.Cursor; import google.registry.model.common.Cursor;
import google.registry.model.common.Cursor.CursorType; import google.registry.model.common.Cursor.CursorType;
import google.registry.model.registry.Registry; import google.registry.model.registry.Registry;
@ -99,15 +98,11 @@ class EscrowTaskRunner {
task.runWithLock(nextRequiredRun); task.runWithLock(nextRequiredRun);
ofy() ofy()
.transact( .transact(
new VoidWork() { () ->
@Override
public void vrun() {
ofy() ofy()
.save() .save()
.entity( .entity(
Cursor.create(cursorType, nextRequiredRun.plus(interval), registry)); Cursor.create(cursorType, nextRequiredRun.plus(interval), registry)));
}
});
return null; return null;
}; };
String lockName = String.format("EscrowTaskRunner %s", task.getClass().getSimpleName()); String lockName = String.format("EscrowTaskRunner %s", task.getClass().getSimpleName());

View file

@ -30,7 +30,6 @@ import com.google.appengine.tools.cloudstorage.GcsFilename;
import com.google.appengine.tools.cloudstorage.RetryParams; import com.google.appengine.tools.cloudstorage.RetryParams;
import com.google.appengine.tools.mapreduce.Reducer; import com.google.appengine.tools.mapreduce.Reducer;
import com.google.appengine.tools.mapreduce.ReducerInput; import com.google.appengine.tools.mapreduce.ReducerInput;
import com.googlecode.objectify.VoidWork;
import google.registry.config.RegistryConfig.Config; import google.registry.config.RegistryConfig.Config;
import google.registry.gcs.GcsUtils; import google.registry.gcs.GcsUtils;
import google.registry.keyring.api.KeyModule; import google.registry.keyring.api.KeyModule;
@ -226,11 +225,12 @@ public final class RdeStagingReducer extends Reducer<PendingDeposit, DepositFrag
logger.info("Manual operation; not advancing cursor or enqueuing upload task"); logger.info("Manual operation; not advancing cursor or enqueuing upload task");
return; return;
} }
ofy().transact(new VoidWork() { ofy()
@Override .transact(
public void vrun() { () -> {
Registry registry = Registry.get(tld); Registry registry = Registry.get(tld);
DateTime position = getCursorTimeOrStartOfTime( DateTime position =
getCursorTimeOrStartOfTime(
ofy().load().key(Cursor.createKey(key.cursor(), registry)).now()); ofy().load().key(Cursor.createKey(key.cursor(), registry)).now());
checkState(key.interval() != null, "Interval must be present"); checkState(key.interval() != null, "Interval must be present");
DateTime newPosition = key.watermark().plus(key.interval()); DateTime newPosition = key.watermark().plus(key.interval());
@ -238,21 +238,26 @@ public final class RdeStagingReducer extends Reducer<PendingDeposit, DepositFrag
logger.warning("Cursor has already been rolled forward."); logger.warning("Cursor has already been rolled forward.");
return; return;
} }
verify(position.equals(key.watermark()), verify(
"Partial ordering of RDE deposits broken: %s %s", position, key); position.equals(key.watermark()),
"Partial ordering of RDE deposits broken: %s %s",
position,
key);
ofy().save().entity(Cursor.create(key.cursor(), newPosition, registry)).now(); ofy().save().entity(Cursor.create(key.cursor(), newPosition, registry)).now();
logger.infofmt("Rolled forward %s on %s cursor to %s", key.cursor(), tld, newPosition); logger.infofmt(
"Rolled forward %s on %s cursor to %s", key.cursor(), tld, newPosition);
RdeRevision.saveRevision(tld, watermark, mode, revision); RdeRevision.saveRevision(tld, watermark, mode, revision);
if (mode == RdeMode.FULL) { if (mode == RdeMode.FULL) {
taskEnqueuer.enqueue(getQueue("rde-upload"), taskEnqueuer.enqueue(
withUrl(RdeUploadAction.PATH) getQueue("rde-upload"),
.param(RequestParameters.PARAM_TLD, tld)); withUrl(RdeUploadAction.PATH).param(RequestParameters.PARAM_TLD, tld));
} else { } else {
taskEnqueuer.enqueue(getQueue("brda"), taskEnqueuer.enqueue(
getQueue("brda"),
withUrl(BrdaCopyAction.PATH) withUrl(BrdaCopyAction.PATH)
.param(RequestParameters.PARAM_TLD, tld) .param(RequestParameters.PARAM_TLD, tld)
.param(RdeModule.PARAM_WATERMARK, watermark.toString())); .param(RdeModule.PARAM_WATERMARK, watermark.toString()));
} }
}}); });
} }
} }

View file

@ -35,7 +35,6 @@ import com.google.common.collect.ImmutableSet;
import com.google.common.io.Files; import com.google.common.io.Files;
import com.google.common.io.LineReader; import com.google.common.io.LineReader;
import com.googlecode.objectify.Key; import com.googlecode.objectify.Key;
import com.googlecode.objectify.Work;
import google.registry.model.domain.LrpTokenEntity; import google.registry.model.domain.LrpTokenEntity;
import google.registry.tools.Command.RemoteApiCommand; import google.registry.tools.Command.RemoteApiCommand;
import google.registry.tools.params.KeyValueMapParameter.StringToIntegerMap; import google.registry.tools.params.KeyValueMapParameter.StringToIntegerMap;
@ -162,23 +161,14 @@ public class CreateLrpTokensCommand implements RemoteApiCommand {
} }
final ImmutableSet<LrpTokenEntity> tokensToSave = tokensToSaveBuilder.build(); final ImmutableSet<LrpTokenEntity> tokensToSave = tokensToSaveBuilder.build();
// Wrap in a retrier to deal with transient 404 errors (thrown as RemoteApiExceptions). // Wrap in a retrier to deal with transient 404 errors (thrown as RemoteApiExceptions).
retrier.callWithRetry( retrier.callWithRetry(() -> saveTokens(tokensToSave), RemoteApiException.class);
() -> {
saveTokens(tokensToSave);
return null;
},
RemoteApiException.class);
} while (line != null); } while (line != null);
} }
@VisibleForTesting @VisibleForTesting
void saveTokens(final ImmutableSet<LrpTokenEntity> tokens) { void saveTokens(final ImmutableSet<LrpTokenEntity> tokens) {
Collection<LrpTokenEntity> savedTokens = Collection<LrpTokenEntity> savedTokens =
ofy().transact(new Work<Collection<LrpTokenEntity>>() { ofy().transact(() -> ofy().save().entities(tokens).now().values());
@Override
public Collection<LrpTokenEntity> run() {
return ofy().save().entities(tokens).now().values();
}});
for (LrpTokenEntity token : savedTokens) { for (LrpTokenEntity token : savedTokens) {
System.out.printf("%s,%s%n", token.getAssignee(), token.getToken()); System.out.printf("%s,%s%n", token.getAssignee(), token.getToken());
} }

View file

@ -23,7 +23,6 @@ import static java.nio.charset.StandardCharsets.UTF_8;
import com.beust.jcommander.Parameter; import com.beust.jcommander.Parameter;
import com.beust.jcommander.Parameters; import com.beust.jcommander.Parameters;
import com.beust.jcommander.internal.Sets; import com.beust.jcommander.internal.Sets;
import com.googlecode.objectify.Work;
import google.registry.model.domain.DomainApplication; import google.registry.model.domain.DomainApplication;
import google.registry.model.domain.launch.ApplicationStatus; import google.registry.model.domain.launch.ApplicationStatus;
import google.registry.tools.Command.RemoteApiCommand; import google.registry.tools.Command.RemoteApiCommand;
@ -70,12 +69,13 @@ final class GetAppliedLabelsCommand implements RemoteApiCommand {
/** Return a set of all fully-qualified domain names with open applications. */ /** Return a set of all fully-qualified domain names with open applications. */
private static Set<String> getDomainApplicationMap(final String tld) { private static Set<String> getDomainApplicationMap(final String tld) {
return ofy().transact(new Work<Set<String>>() { return ofy()
@Override .transact(
public Set<String> run() { () -> {
Set<String> labels = Sets.newHashSet(); Set<String> labels = Sets.newHashSet();
List<DomainApplication> domainApplications; List<DomainApplication> domainApplications;
domainApplications = ofy().load().type(DomainApplication.class).filter("tld", tld).list(); domainApplications =
ofy().load().type(DomainApplication.class).filter("tld", tld).list();
for (DomainApplication domainApplication : domainApplications) { for (DomainApplication domainApplication : domainApplications) {
// Ignore deleted and rejected applications. They aren't under consideration. // Ignore deleted and rejected applications. They aren't under consideration.
ApplicationStatus applicationStatus = domainApplication.getApplicationStatus(); ApplicationStatus applicationStatus = domainApplication.getApplicationStatus();
@ -87,6 +87,6 @@ final class GetAppliedLabelsCommand implements RemoteApiCommand {
labels.add(domainApplication.getFullyQualifiedDomainName()); labels.add(domainApplication.getFullyQualifiedDomainName());
} }
return labels; return labels;
}}); });
} }
} }

View file

@ -20,7 +20,6 @@ import static google.registry.model.ofy.ObjectifyService.ofy;
import com.beust.jcommander.Parameters; import com.beust.jcommander.Parameters;
import com.googlecode.objectify.Key; import com.googlecode.objectify.Key;
import com.googlecode.objectify.VoidWork;
import google.registry.model.registrar.Registrar; import google.registry.model.registrar.Registrar;
import google.registry.model.registrar.RegistrarContact; import google.registry.model.registrar.RegistrarContact;
import google.registry.model.registry.Registry; import google.registry.model.registry.Registry;
@ -48,11 +47,7 @@ final class ResaveEnvironmentEntitiesCommand implements RemoteApiCommand {
System.out.printf("Re-saving %s entities.\n", clazz.getSimpleName()); System.out.printf("Re-saving %s entities.\n", clazz.getSimpleName());
for (final Iterable<Key<T>> batch : for (final Iterable<Key<T>> batch :
partition(ofy().load().type(clazz).ancestor(getCrossTldKey()).keys().list(), BATCH_SIZE)) { partition(ofy().load().type(clazz).ancestor(getCrossTldKey()).keys().list(), BATCH_SIZE)) {
ofy().transact(new VoidWork() { ofy().transact(() -> ofy().save().entities(ofy().load().keys(batch).values()));
@Override
public void vrun() {
ofy().save().entities(ofy().load().keys(batch).values());
}});
System.out.printf("Re-saved entities batch: %s.\n", batch); System.out.printf("Re-saved entities batch: %s.\n", batch);
} }
} }

View file

@ -25,7 +25,6 @@ import static google.registry.util.PreconditionsUtils.checkArgumentPresent;
import com.beust.jcommander.Parameter; import com.beust.jcommander.Parameter;
import com.beust.jcommander.Parameters; import com.beust.jcommander.Parameters;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.googlecode.objectify.VoidWork;
import google.registry.model.domain.DomainApplication; import google.registry.model.domain.DomainApplication;
import google.registry.model.domain.launch.ApplicationStatus; import google.registry.model.domain.launch.ApplicationStatus;
import google.registry.model.domain.launch.LaunchInfoResponseExtension; import google.registry.model.domain.launch.LaunchInfoResponseExtension;
@ -70,12 +69,7 @@ final class UpdateApplicationStatusCommand extends MutatingCommand {
checkArgumentPresent( checkArgumentPresent(
Registrar.loadByClientId(clientId), "Registrar with client ID %s not found", clientId); Registrar.loadByClientId(clientId), "Registrar with client ID %s not found", clientId);
for (final String applicationId : ids) { for (final String applicationId : ids) {
ofy().transact(new VoidWork() { ofy().transact(() -> updateApplicationStatus(applicationId));
@Override
public void vrun() {
updateApplicationStatus(applicationId);
}
});
} }
} }

View file

@ -21,7 +21,6 @@ import static google.registry.model.ofy.ObjectifyService.ofy;
import com.beust.jcommander.Parameter; import com.beust.jcommander.Parameter;
import com.beust.jcommander.Parameters; import com.beust.jcommander.Parameters;
import com.google.common.net.InternetDomainName; import com.google.common.net.InternetDomainName;
import com.googlecode.objectify.VoidWork;
import google.registry.model.domain.DomainApplication; import google.registry.model.domain.DomainApplication;
import google.registry.model.domain.launch.LaunchNotice; import google.registry.model.domain.launch.LaunchNotice;
import google.registry.model.domain.launch.LaunchNotice.InvalidChecksumException; import google.registry.model.domain.launch.LaunchNotice.InvalidChecksumException;
@ -67,15 +66,15 @@ final class UpdateClaimsNoticeCommand implements RemoteApiCommand {
final LaunchNotice launchNotice = LaunchNotice.create( final LaunchNotice launchNotice = LaunchNotice.create(
tcnId, validatorId, DateTime.parse(expirationTime), DateTime.parse(acceptedTime)); tcnId, validatorId, DateTime.parse(expirationTime), DateTime.parse(acceptedTime));
ofy().transact(new VoidWork() { ofy()
@Override .transact(
public void vrun() { () -> {
try { try {
updateClaimsNotice(id, launchNotice); updateClaimsNotice(id, launchNotice);
} catch (InvalidChecksumException e) { } catch (InvalidChecksumException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
}}); });
} }
private void updateClaimsNotice(String applicationId, LaunchNotice launchNotice) private void updateClaimsNotice(String applicationId, LaunchNotice launchNotice)

View file

@ -24,7 +24,6 @@ import com.beust.jcommander.Parameter;
import com.beust.jcommander.Parameters; import com.beust.jcommander.Parameters;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.net.InternetDomainName; import com.google.common.net.InternetDomainName;
import com.googlecode.objectify.VoidWork;
import google.registry.flows.EppException; import google.registry.flows.EppException;
import google.registry.flows.domain.DomainFlowTmchUtils; import google.registry.flows.domain.DomainFlowTmchUtils;
import google.registry.model.domain.DomainApplication; import google.registry.model.domain.DomainApplication;
@ -67,15 +66,15 @@ final class UpdateSmdCommand implements RemoteApiCommand {
final EncodedSignedMark encodedSignedMark = final EncodedSignedMark encodedSignedMark =
readEncodedSignedMark(new String(Files.readAllBytes(smdFile), US_ASCII)); readEncodedSignedMark(new String(Files.readAllBytes(smdFile), US_ASCII));
ofy().transact(new VoidWork() { ofy()
@Override .transact(
public void vrun() { () -> {
try { try {
updateSmd(id, encodedSignedMark, reason); updateSmd(id, encodedSignedMark, reason);
} catch (EppException e) { } catch (EppException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
}}); });
} }
private void updateSmd( private void updateSmd(

View file

@ -20,7 +20,6 @@ import static google.registry.model.ofy.ObjectifyService.ofy;
import com.google.appengine.tools.mapreduce.Reducer; import com.google.appengine.tools.mapreduce.Reducer;
import com.google.appengine.tools.mapreduce.ReducerInput; import com.google.appengine.tools.mapreduce.ReducerInput;
import com.googlecode.objectify.Key; import com.googlecode.objectify.Key;
import com.googlecode.objectify.VoidWork;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
@ -37,11 +36,7 @@ public class KillAllEntitiesReducer extends Reducer<Key<?>, Key<?>, Void> {
while (batches.hasNext()) { while (batches.hasNext()) {
final List<Key<?>> batch = batches.next(); final List<Key<?>> batch = batches.next();
// Use a transaction to get retrying for free. // Use a transaction to get retrying for free.
ofy().transact(new VoidWork() { ofy().transact(() -> ofy().deleteWithoutBackup().keys(batch));
@Override
public void vrun() {
ofy().deleteWithoutBackup().keys(batch);
}});
getContext().incrementCounter("entities deleted", batch.size()); getContext().incrementCounter("entities deleted", batch.size());
for (Key<?> key : batch) { for (Key<?> key : batch) {
getContext().incrementCounter(String.format("%s deleted", key.getKind())); getContext().incrementCounter(String.format("%s deleted", key.getKind()));

View file

@ -20,7 +20,6 @@ import static google.registry.util.PipelineUtils.createJobPath;
import com.google.appengine.tools.mapreduce.Mapper; import com.google.appengine.tools.mapreduce.Mapper;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.googlecode.objectify.VoidWork;
import google.registry.mapreduce.MapreduceRunner; import google.registry.mapreduce.MapreduceRunner;
import google.registry.mapreduce.inputs.EppResourceInputs; import google.registry.mapreduce.inputs.EppResourceInputs;
import google.registry.model.EppResource; import google.registry.model.EppResource;
@ -70,11 +69,7 @@ public class ResaveAllHistoryEntriesAction implements Runnable {
@Override @Override
public final void map(final HistoryEntry historyEntry) { public final void map(final HistoryEntry historyEntry) {
ofy().transact(new VoidWork() { ofy().transact(() -> ofy().save().entity(ofy().load().entity(historyEntry).now()).now());
@Override
public void vrun() {
ofy().save().entity(ofy().load().entity(historyEntry).now()).now();
}});
getContext().incrementCounter( getContext().incrementCounter(
String.format( String.format(
"HistoryEntries parented under %s re-saved", historyEntry.getParent().getKind())); "HistoryEntries parented under %s re-saved", historyEntry.getParent().getKind()));

View file

@ -119,9 +119,10 @@ public class RegistrarSettingsAction implements Runnable, JsonActionRunner.JsonA
Map<String, Object> update(final Map<String, ?> args, final Registrar registrar) { Map<String, Object> update(final Map<String, ?> args, final Registrar registrar) {
final String clientId = sessionUtils.getRegistrarClientId(request); final String clientId = sessionUtils.getRegistrarClientId(request);
return ofy().transact(new Work<Map<String, Object>>() { return ofy()
@Override .transact(
public Map<String, Object> run() { (Work<Map<String, Object>>)
() -> {
ImmutableSet<RegistrarContact> oldContacts = registrar.getContacts(); ImmutableSet<RegistrarContact> oldContacts = registrar.getContacts();
Map<String, Object> existingRegistrarMap = Map<String, Object> existingRegistrarMap =
expandRegistrarWithContacts(oldContacts, registrar); expandRegistrarWithContacts(oldContacts, registrar);
@ -137,8 +138,8 @@ public class RegistrarSettingsAction implements Runnable, JsonActionRunner.JsonA
checkContactRequirements(oldContacts, updatedContacts); checkContactRequirements(oldContacts, updatedContacts);
RegistrarContact.updateContacts(updatedRegistrar, updatedContacts); RegistrarContact.updateContacts(updatedRegistrar, updatedContacts);
} }
// Update the registrar map with updated contacts to bypass Objectify caching issues that // Update the registrar map with updated contacts to bypass Objectify caching
// come into play with calling getContacts(). // issues that come into play with calling getContacts().
Map<String, Object> updatedRegistrarMap = Map<String, Object> updatedRegistrarMap =
expandRegistrarWithContacts(updatedContacts, updatedRegistrar); expandRegistrarWithContacts(updatedContacts, updatedRegistrar);
sendExternalUpdatesIfNecessary( sendExternalUpdatesIfNecessary(
@ -146,10 +147,8 @@ public class RegistrarSettingsAction implements Runnable, JsonActionRunner.JsonA
existingRegistrarMap, existingRegistrarMap,
updatedRegistrarMap); updatedRegistrarMap);
return JsonResponseHelper.create( return JsonResponseHelper.create(
SUCCESS, SUCCESS, "Saved " + clientId, updatedRegistrar.toJsonMap());
"Saved " + clientId, });
updatedRegistrar.toJsonMap());
}});
} }
private Map<String, Object> expandRegistrarWithContacts(Iterable<RegistrarContact> contacts, private Map<String, Object> expandRegistrarWithContacts(Iterable<RegistrarContact> contacts,

View file

@ -15,6 +15,7 @@
package google.registry.backup; package google.registry.backup;
import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertThat;
import static google.registry.model.common.Cursor.CursorType.RDE_REPORT;
import static google.registry.model.ofy.CommitLogBucket.getBucketKey; import static google.registry.model.ofy.CommitLogBucket.getBucketKey;
import static google.registry.model.ofy.ObjectifyService.ofy; import static google.registry.model.ofy.ObjectifyService.ofy;
import static google.registry.testing.DatastoreHelper.createTld; import static google.registry.testing.DatastoreHelper.createTld;
@ -23,9 +24,7 @@ import static google.registry.util.DateTimeUtils.START_OF_TIME;
import com.google.common.base.Supplier; import com.google.common.base.Supplier;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import com.googlecode.objectify.VoidWork;
import google.registry.model.common.Cursor; import google.registry.model.common.Cursor;
import google.registry.model.common.Cursor.CursorType;
import google.registry.model.ofy.CommitLogBucket; import google.registry.model.ofy.CommitLogBucket;
import google.registry.model.ofy.CommitLogCheckpoint; import google.registry.model.ofy.CommitLogCheckpoint;
import google.registry.model.ofy.Ofy; import google.registry.model.ofy.Ofy;
@ -291,25 +290,22 @@ public class CommitLogCheckpointStrategyTest {
private void writeCommitLogToBucket(final int bucketId) { private void writeCommitLogToBucket(final int bucketId) {
fakeBucketIdSupplier.value = bucketId; fakeBucketIdSupplier.value = bucketId;
ofy.transact( ofy.transact(
new VoidWork() { () -> {
@Override Cursor cursor =
public void vrun() { Cursor.create(RDE_REPORT, ofy.getTransactionTime(), Registry.get("tld" + bucketId));
String tld = "tld" + bucketId; ofy().save().entity(cursor);
ofy().save().entity(
Cursor.create(CursorType.RDE_REPORT, ofy.getTransactionTime(), Registry.get(tld)));
}
}); });
fakeBucketIdSupplier.value = null; fakeBucketIdSupplier.value = null;
} }
private void saveBucketWithLastWrittenTime(final int bucketId, final DateTime lastWrittenTime) { private void saveBucketWithLastWrittenTime(final int bucketId, final DateTime lastWrittenTime) {
ofy.transact(new VoidWork() { ofy.transact(
@Override () ->
public void vrun() { ofy.saveWithoutBackup()
ofy.saveWithoutBackup().entity( .entity(
CommitLogBucket.loadBucket(getBucketKey(bucketId)).asBuilder() CommitLogBucket.loadBucket(getBucketKey(bucketId))
.asBuilder()
.setLastWrittenTime(lastWrittenTime) .setLastWrittenTime(lastWrittenTime)
.build()); .build()));
}});
} }
} }

View file

@ -36,7 +36,6 @@ import com.google.common.collect.ImmutableSet;
import com.google.common.collect.ImmutableSortedMap; import com.google.common.collect.ImmutableSortedMap;
import com.google.common.collect.Iterables; import com.google.common.collect.Iterables;
import com.googlecode.objectify.Key; import com.googlecode.objectify.Key;
import com.googlecode.objectify.VoidWork;
import google.registry.model.billing.BillingEvent; import google.registry.model.billing.BillingEvent;
import google.registry.model.billing.BillingEvent.Flag; import google.registry.model.billing.BillingEvent.Flag;
import google.registry.model.billing.BillingEvent.OneTime; import google.registry.model.billing.BillingEvent.OneTime;
@ -106,11 +105,7 @@ public class ExpandRecurringBillingEventsActionTest
} }
void saveCursor(final DateTime cursorTime) throws Exception { void saveCursor(final DateTime cursorTime) throws Exception {
ofy().transact(new VoidWork() { ofy().transact(() -> ofy().save().entity(Cursor.createGlobal(RECURRING_BILLING, cursorTime)));
@Override
public void vrun() {
ofy().save().entity(Cursor.createGlobal(RECURRING_BILLING, cursorTime));
}});
} }
void runMapreduce() throws Exception { void runMapreduce() throws Exception {

View file

@ -19,8 +19,6 @@ import static google.registry.model.ofy.ObjectifyService.ofy;
import static org.joda.time.DateTimeZone.UTC; import static org.joda.time.DateTimeZone.UTC;
import com.googlecode.objectify.ObjectifyService; import com.googlecode.objectify.ObjectifyService;
import com.googlecode.objectify.VoidWork;
import com.googlecode.objectify.Work;
import com.googlecode.objectify.annotation.Entity; import com.googlecode.objectify.annotation.Entity;
import google.registry.model.common.CrossTldSingleton; import google.registry.model.common.CrossTldSingleton;
import google.registry.testing.AppEngineRule; import google.registry.testing.AppEngineRule;
@ -57,14 +55,15 @@ public class CreateAutoTimestampTest {
@Test @Test
public void testSaveSetsTime() throws Exception { public void testSaveSetsTime() throws Exception {
DateTime transactionTime = ofy().transact(new Work<DateTime>() { DateTime transactionTime =
@Override ofy()
public DateTime run() { .transact(
() -> {
TestObject object = new TestObject(); TestObject object = new TestObject();
assertThat(object.createTime.getTimestamp()).isNull(); assertThat(object.createTime.getTimestamp()).isNull();
ofy().save().entity(object); ofy().save().entity(object);
return ofy().getTransactionTime(); return ofy().getTransactionTime();
}}); });
ofy().clearSessionCache(); ofy().clearSessionCache();
assertThat(reload().createTime.timestamp).isEqualTo(transactionTime); assertThat(reload().createTime.timestamp).isEqualTo(transactionTime);
} }
@ -72,13 +71,13 @@ public class CreateAutoTimestampTest {
@Test @Test
public void testResavingRespectsOriginalTime() throws Exception { public void testResavingRespectsOriginalTime() throws Exception {
final DateTime oldCreateTime = DateTime.now(UTC).minusDays(1); final DateTime oldCreateTime = DateTime.now(UTC).minusDays(1);
ofy().transact(new VoidWork() { ofy()
@Override .transact(
public void vrun() { () -> {
TestObject object = new TestObject(); TestObject object = new TestObject();
object.createTime = CreateAutoTimestamp.create(oldCreateTime); object.createTime = CreateAutoTimestamp.create(oldCreateTime);
ofy().save().entity(object); ofy().save().entity(object);
}}); });
ofy().clearSessionCache(); ofy().clearSessionCache();
assertThat(reload().createTime.timestamp).isEqualTo(oldCreateTime); assertThat(reload().createTime.timestamp).isEqualTo(oldCreateTime);
} }

View file

@ -19,7 +19,6 @@ import static google.registry.model.ofy.ObjectifyService.ofy;
import static org.joda.time.DateTimeZone.UTC; import static org.joda.time.DateTimeZone.UTC;
import com.googlecode.objectify.ObjectifyService; import com.googlecode.objectify.ObjectifyService;
import com.googlecode.objectify.Work;
import com.googlecode.objectify.annotation.Entity; import com.googlecode.objectify.annotation.Entity;
import google.registry.model.common.CrossTldSingleton; import google.registry.model.common.CrossTldSingleton;
import google.registry.testing.AppEngineRule; import google.registry.testing.AppEngineRule;
@ -56,28 +55,30 @@ public class UpdateAutoTimestampTest {
@Test @Test
public void testSaveSetsTime() throws Exception { public void testSaveSetsTime() throws Exception {
DateTime transactionTime = ofy().transact(new Work<DateTime>() { DateTime transactionTime =
@Override ofy()
public DateTime run() { .transact(
() -> {
TestObject object = new TestObject(); TestObject object = new TestObject();
assertThat(object.updateTime.timestamp).isNull(); assertThat(object.updateTime.timestamp).isNull();
ofy().save().entity(object); ofy().save().entity(object);
return ofy().getTransactionTime(); return ofy().getTransactionTime();
}}); });
ofy().clearSessionCache(); ofy().clearSessionCache();
assertThat(reload().updateTime.timestamp).isEqualTo(transactionTime); assertThat(reload().updateTime.timestamp).isEqualTo(transactionTime);
} }
@Test @Test
public void testResavingOverwritesOriginalTime() throws Exception { public void testResavingOverwritesOriginalTime() throws Exception {
DateTime transactionTime = ofy().transact(new Work<DateTime>() { DateTime transactionTime =
@Override ofy()
public DateTime run() { .transact(
() -> {
TestObject object = new TestObject(); TestObject object = new TestObject();
object.updateTime = UpdateAutoTimestamp.create(DateTime.now(UTC).minusDays(1)); object.updateTime = UpdateAutoTimestamp.create(DateTime.now(UTC).minusDays(1));
ofy().save().entity(object); ofy().save().entity(object);
return ofy().getTransactionTime(); return ofy().getTransactionTime();
}}); });
ofy().clearSessionCache(); ofy().clearSessionCache();
assertThat(reload().updateTime.timestamp).isEqualTo(transactionTime); assertThat(reload().updateTime.timestamp).isEqualTo(transactionTime);
} }

View file

@ -23,7 +23,6 @@ import static google.registry.testing.DatastoreHelper.createTld;
import static google.registry.testing.DatastoreHelper.persistActiveDomain; import static google.registry.testing.DatastoreHelper.persistActiveDomain;
import static google.registry.util.DateTimeUtils.START_OF_TIME; import static google.registry.util.DateTimeUtils.START_OF_TIME;
import com.googlecode.objectify.VoidWork;
import google.registry.model.EntityTestCase; import google.registry.model.EntityTestCase;
import google.registry.model.domain.DomainResource; import google.registry.model.domain.DomainResource;
import google.registry.model.registry.Registry; import google.registry.model.registry.Registry;
@ -42,14 +41,7 @@ public class CursorTest extends EntityTestCase {
createTld("tld"); createTld("tld");
clock.advanceOneMilli(); clock.advanceOneMilli();
final DateTime time = DateTime.parse("2012-07-12T03:30:00.000Z"); final DateTime time = DateTime.parse("2012-07-12T03:30:00.000Z");
ofy() ofy().transact(() -> ofy().save().entity(Cursor.create(RDE_UPLOAD, time, Registry.get("tld"))));
.transact(
new VoidWork() {
@Override
public void vrun() {
ofy().save().entity(Cursor.create(RDE_UPLOAD, time, Registry.get("tld")));
}
});
assertThat(ofy().load().key(Cursor.createKey(BRDA, Registry.get("tld"))).now()).isNull(); assertThat(ofy().load().key(Cursor.createKey(BRDA, Registry.get("tld"))).now()).isNull();
assertThat( assertThat(
ofy() ofy()
@ -63,14 +55,7 @@ public class CursorTest extends EntityTestCase {
@Test @Test
public void testSuccess_persistGlobalCursor() { public void testSuccess_persistGlobalCursor() {
final DateTime time = DateTime.parse("2012-07-12T03:30:00.000Z"); final DateTime time = DateTime.parse("2012-07-12T03:30:00.000Z");
ofy() ofy().transact(() -> ofy().save().entity(Cursor.createGlobal(RECURRING_BILLING, time)));
.transact(
new VoidWork() {
@Override
public void vrun() {
ofy().save().entity(Cursor.createGlobal(RECURRING_BILLING, time));
}
});
assertThat(ofy().load().key(Cursor.createGlobalKey(RECURRING_BILLING)).now().getCursorTime()) assertThat(ofy().load().key(Cursor.createGlobalKey(RECURRING_BILLING)).now().getCursorTime())
.isEqualTo(time); .isEqualTo(time);
} }
@ -78,14 +63,7 @@ public class CursorTest extends EntityTestCase {
@Test @Test
public void testIndexing() throws Exception { public void testIndexing() throws Exception {
final DateTime time = DateTime.parse("2012-07-12T03:30:00.000Z"); final DateTime time = DateTime.parse("2012-07-12T03:30:00.000Z");
ofy() ofy().transact(() -> ofy().save().entity(Cursor.createGlobal(RECURRING_BILLING, time)));
.transact(
new VoidWork() {
@Override
public void vrun() {
ofy().save().entity(Cursor.createGlobal(RECURRING_BILLING, time));
}
});
Cursor cursor = ofy().load().key(Cursor.createGlobalKey(RECURRING_BILLING)).now(); Cursor cursor = ofy().load().key(Cursor.createGlobalKey(RECURRING_BILLING)).now();
verifyIndexing(cursor); verifyIndexing(cursor);
} }
@ -98,14 +76,7 @@ public class CursorTest extends EntityTestCase {
final DomainResource domain = persistActiveDomain("notaregistry.tld"); final DomainResource domain = persistActiveDomain("notaregistry.tld");
thrown.expect( thrown.expect(
IllegalArgumentException.class, "Class required for cursor does not match scope class"); IllegalArgumentException.class, "Class required for cursor does not match scope class");
ofy() ofy().transact(() -> ofy().save().entity(Cursor.create(RDE_UPLOAD, time, domain)));
.transact(
new VoidWork() {
@Override
public void vrun() {
ofy().save().entity(Cursor.create(RDE_UPLOAD, time, domain));
}
});
} }
@Test @Test

View file

@ -28,7 +28,6 @@ import static org.joda.time.DateTimeZone.UTC;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.googlecode.objectify.Key; import com.googlecode.objectify.Key;
import com.googlecode.objectify.VoidWork;
import google.registry.model.EntityTestCase; import google.registry.model.EntityTestCase;
import google.registry.model.domain.DomainApplication; import google.registry.model.domain.DomainApplication;
import google.registry.testing.ExceptionRule; import google.registry.testing.ExceptionRule;
@ -132,12 +131,12 @@ public class DomainApplicationIndexTest extends EntityTestCase {
persistResource(createUpdatedInstance(application)); persistResource(createUpdatedInstance(application));
applicationsBuilder.add(application); applicationsBuilder.add(application);
} }
ofy().transact(new VoidWork() { ofy()
@Override .transact(
public void vrun() { () -> {
assertThat(DomainApplicationIndex.load("example.com")).isNotNull(); assertThat(DomainApplicationIndex.load("example.com")).isNotNull();
assertThat(loadActiveApplicationsByDomainName("example.com", clock.nowUtc())) assertThat(loadActiveApplicationsByDomainName("example.com", clock.nowUtc()))
.containsExactlyElementsIn(applicationsBuilder.build()); .containsExactlyElementsIn(applicationsBuilder.build());
}}); });
} }
} }

View file

@ -22,7 +22,6 @@ import com.google.appengine.api.datastore.Entity;
import com.google.appengine.api.datastore.EntityTranslator; import com.google.appengine.api.datastore.EntityTranslator;
import com.google.appengine.api.datastore.KeyFactory; import com.google.appengine.api.datastore.KeyFactory;
import com.googlecode.objectify.Key; import com.googlecode.objectify.Key;
import com.googlecode.objectify.Work;
import google.registry.model.ImmutableObject; import google.registry.model.ImmutableObject;
import google.registry.model.registry.Registry; import google.registry.model.registry.Registry;
import google.registry.testing.AppEngineRule; import google.registry.testing.AppEngineRule;
@ -69,11 +68,8 @@ public class CommitLogMutationTest {
public void test_create_createsExpectedMutation() { public void test_create_createsExpectedMutation() {
Entity rawEntity = convertToEntityInTxn(someObject); Entity rawEntity = convertToEntityInTxn(someObject);
// Needs to be in a transaction so that registry-saving-to-entity will work. // Needs to be in a transaction so that registry-saving-to-entity will work.
CommitLogMutation mutation = ofy().transact(new Work<CommitLogMutation>() { CommitLogMutation mutation =
@Override ofy().transact(() -> CommitLogMutation.create(manifestKey, someObject));
public CommitLogMutation run() {
return CommitLogMutation.create(manifestKey, someObject);
}});
assertThat(Key.create(mutation)) assertThat(Key.create(mutation))
.isEqualTo(CommitLogMutation.createKey(manifestKey, Key.create(someObject))); .isEqualTo(CommitLogMutation.createKey(manifestKey, Key.create(someObject)));
assertThat(mutation.getEntity()).isEqualTo(rawEntity); assertThat(mutation.getEntity()).isEqualTo(rawEntity);
@ -93,10 +89,6 @@ public class CommitLogMutationTest {
} }
private static Entity convertToEntityInTxn(final ImmutableObject object) { private static Entity convertToEntityInTxn(final ImmutableObject object) {
return ofy().transact(new Work<Entity>() { return ofy().transact(() -> ofy().save().toEntity(object));
@Override
public Entity run() {
return ofy().save().toEntity(object);
}});
} }
} }

View file

@ -20,11 +20,9 @@ import static com.googlecode.objectify.ObjectifyService.register;
import static google.registry.model.common.EntityGroupRoot.getCrossTldKey; import static google.registry.model.common.EntityGroupRoot.getCrossTldKey;
import static google.registry.model.ofy.CommitLogBucket.getBucketKey; import static google.registry.model.ofy.CommitLogBucket.getBucketKey;
import static google.registry.model.ofy.ObjectifyService.ofy; import static google.registry.model.ofy.ObjectifyService.ofy;
import static google.registry.testing.TestObject.TestVirtualObject;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.googlecode.objectify.Key; import com.googlecode.objectify.Key;
import com.googlecode.objectify.VoidWork;
import com.googlecode.objectify.annotation.Entity; import com.googlecode.objectify.annotation.Entity;
import com.googlecode.objectify.annotation.Id; import com.googlecode.objectify.annotation.Id;
import com.googlecode.objectify.annotation.Parent; import com.googlecode.objectify.annotation.Parent;
@ -35,6 +33,7 @@ import google.registry.testing.AppEngineRule;
import google.registry.testing.ExceptionRule; import google.registry.testing.ExceptionRule;
import google.registry.testing.FakeClock; import google.registry.testing.FakeClock;
import google.registry.testing.InjectRule; import google.registry.testing.InjectRule;
import google.registry.testing.TestObject.TestVirtualObject;
import org.joda.time.DateTime; import org.joda.time.DateTime;
import org.junit.Before; import org.junit.Before;
import org.junit.Rule; import org.junit.Rule;
@ -68,20 +67,13 @@ public class OfyCommitLogTest {
@Test @Test
public void testTransact_doesNothing_noCommitLogIsSaved() throws Exception { public void testTransact_doesNothing_noCommitLogIsSaved() throws Exception {
ofy().transact(new VoidWork() { ofy().transact(() -> {});
@Override
public void vrun() {}
});
assertThat(ofy().load().type(CommitLogManifest.class)).isEmpty(); assertThat(ofy().load().type(CommitLogManifest.class)).isEmpty();
} }
@Test @Test
public void testTransact_savesDataAndCommitLog() throws Exception { public void testTransact_savesDataAndCommitLog() throws Exception {
ofy().transact(new VoidWork() { ofy().transact(() -> ofy().save().entity(Root.create(1, getCrossTldKey())).now());
@Override
public void vrun() {
ofy().save().entity(Root.create(1, getCrossTldKey())).now();
}});
assertThat(ofy().load().key(Key.create(getCrossTldKey(), Root.class, 1)).now().value) assertThat(ofy().load().key(Key.create(getCrossTldKey(), Root.class, 1)).now().value)
.isEqualTo("value"); .isEqualTo("value");
assertThat(ofy().load().type(CommitLogManifest.class)).hasSize(1); assertThat(ofy().load().type(CommitLogManifest.class)).hasSize(1);
@ -90,11 +82,7 @@ public class OfyCommitLogTest {
@Test @Test
public void testTransact_saveWithoutBackup_noCommitLogIsSaved() throws Exception { public void testTransact_saveWithoutBackup_noCommitLogIsSaved() throws Exception {
ofy().transact(new VoidWork() { ofy().transact(() -> ofy().saveWithoutBackup().entity(Root.create(1, getCrossTldKey())).now());
@Override
public void vrun() {
ofy().saveWithoutBackup().entity(Root.create(1, getCrossTldKey())).now();
}});
assertThat(ofy().load().key(Key.create(getCrossTldKey(), Root.class, 1)).now().value) assertThat(ofy().load().key(Key.create(getCrossTldKey(), Root.class, 1)).now().value)
.isEqualTo("value"); .isEqualTo("value");
assertThat(ofy().load().type(CommitLogManifest.class)).isEmpty(); assertThat(ofy().load().type(CommitLogManifest.class)).isEmpty();
@ -103,16 +91,8 @@ public class OfyCommitLogTest {
@Test @Test
public void testTransact_deleteWithoutBackup_noCommitLogIsSaved() throws Exception { public void testTransact_deleteWithoutBackup_noCommitLogIsSaved() throws Exception {
ofy().transact(new VoidWork() { ofy().transact(() -> ofy().saveWithoutBackup().entity(Root.create(1, getCrossTldKey())).now());
@Override ofy().transact(() -> ofy().deleteWithoutBackup().key(Key.create(Root.class, 1)));
public void vrun() {
ofy().saveWithoutBackup().entity(Root.create(1, getCrossTldKey())).now();
}});
ofy().transact(new VoidWork() {
@Override
public void vrun() {
ofy().deleteWithoutBackup().key(Key.create(Root.class, 1));
}});
assertThat(ofy().load().key(Key.create(Root.class, 1)).now()).isNull(); assertThat(ofy().load().key(Key.create(Root.class, 1)).now()).isNull();
assertThat(ofy().load().type(CommitLogManifest.class)).isEmpty(); assertThat(ofy().load().type(CommitLogManifest.class)).isEmpty();
assertThat(ofy().load().type(CommitLogMutation.class)).isEmpty(); assertThat(ofy().load().type(CommitLogMutation.class)).isEmpty();
@ -120,31 +100,26 @@ public class OfyCommitLogTest {
@Test @Test
public void testTransact_savesEntity_itsProtobufFormIsStoredInCommitLog() throws Exception { public void testTransact_savesEntity_itsProtobufFormIsStoredInCommitLog() throws Exception {
ofy().transact(new VoidWork() { ofy().transact(() -> ofy().save().entity(Root.create(1, getCrossTldKey())).now());
@Override
public void vrun() {
ofy().save().entity(Root.create(1, getCrossTldKey())).now();
}});
final byte[] entityProtoBytes = final byte[] entityProtoBytes =
ofy().load().type(CommitLogMutation.class).first().now().entityProtoBytes; ofy().load().type(CommitLogMutation.class).first().now().entityProtoBytes;
// This transaction is needed so that save().toEntity() can access ofy().getTransactionTime() // This transaction is needed so that save().toEntity() can access ofy().getTransactionTime()
// when it attempts to set the update timestamp. // when it attempts to set the update timestamp.
ofy().transact(new VoidWork() { ofy()
@Override .transact(
public void vrun() { () ->
assertThat(entityProtoBytes).isEqualTo( assertThat(entityProtoBytes)
convertToPb(ofy().save().toEntity(Root.create(1, getCrossTldKey()))).toByteArray()); .isEqualTo(
}}); convertToPb(ofy().save().toEntity(Root.create(1, getCrossTldKey())))
.toByteArray()));
} }
@Test @Test
public void testTransact_savesEntity_mutationIsChildOfManifest() throws Exception { public void testTransact_savesEntity_mutationIsChildOfManifest() throws Exception {
ofy().transact(new VoidWork() { ofy().transact(() -> ofy().save().entity(Root.create(1, getCrossTldKey())).now());
@Override assertThat(
public void vrun() { ofy()
ofy().save().entity(Root.create(1, getCrossTldKey())).now(); .load()
}});
assertThat(ofy().load()
.type(CommitLogMutation.class) .type(CommitLogMutation.class)
.ancestor(ofy().load().type(CommitLogManifest.class).first().now())) .ancestor(ofy().load().type(CommitLogManifest.class).first().now()))
.hasSize(1); .hasSize(1);
@ -152,44 +127,31 @@ public class OfyCommitLogTest {
@Test @Test
public void testTransactNew_savesDataAndCommitLog() throws Exception { public void testTransactNew_savesDataAndCommitLog() throws Exception {
ofy().transactNew(new VoidWork() { ofy().transactNew(() -> ofy().save().entity(Root.create(1, getCrossTldKey())).now());
@Override assertThat(ofy().load().key(Key.create(getCrossTldKey(), Root.class, 1)).now().value)
public void vrun() { .isEqualTo("value");
ofy().save().entity(Root.create(1, getCrossTldKey())).now();
}});
assertThat(ofy().load()
.key(Key.create(getCrossTldKey(), Root.class, 1))
.now().value).isEqualTo("value");
assertThat(ofy().load().type(CommitLogManifest.class)).hasSize(1); assertThat(ofy().load().type(CommitLogManifest.class)).hasSize(1);
assertThat(ofy().load().type(CommitLogMutation.class)).hasSize(1); assertThat(ofy().load().type(CommitLogMutation.class)).hasSize(1);
} }
@Test @Test
public void testTransact_multipleSaves_logsMultipleMutations() throws Exception { public void testTransact_multipleSaves_logsMultipleMutations() throws Exception {
ofy().transact(new VoidWork() { ofy()
@Override .transact(
public void vrun() { () -> {
ofy().save().entity(Root.create(1, getCrossTldKey())).now(); ofy().save().entity(Root.create(1, getCrossTldKey())).now();
ofy().save().entity(Root.create(2, getCrossTldKey())).now(); ofy().save().entity(Root.create(2, getCrossTldKey())).now();
}}); });
assertThat(ofy().load().type(CommitLogManifest.class)).hasSize(1); assertThat(ofy().load().type(CommitLogManifest.class)).hasSize(1);
assertThat(ofy().load().type(CommitLogMutation.class)).hasSize(2); assertThat(ofy().load().type(CommitLogMutation.class)).hasSize(2);
} }
@Test @Test
public void testTransact_deletion_deletesAndLogsWithoutMutation() throws Exception { public void testTransact_deletion_deletesAndLogsWithoutMutation() throws Exception {
ofy().transact(new VoidWork() { ofy().transact(() -> ofy().saveWithoutBackup().entity(Root.create(1, getCrossTldKey())).now());
@Override
public void vrun() {
ofy().saveWithoutBackup().entity(Root.create(1, getCrossTldKey())).now();
}});
clock.advanceOneMilli(); clock.advanceOneMilli();
final Key<Root> otherTldKey = Key.create(getCrossTldKey(), Root.class, 1); final Key<Root> otherTldKey = Key.create(getCrossTldKey(), Root.class, 1);
ofy().transact(new VoidWork() { ofy().transact(() -> ofy().delete().key(otherTldKey));
@Override
public void vrun() {
ofy().delete().key(otherTldKey);
}});
assertThat(ofy().load().key(otherTldKey).now()).isNull(); assertThat(ofy().load().key(otherTldKey).now()).isNull();
assertThat(ofy().load().type(CommitLogManifest.class)).hasSize(1); assertThat(ofy().load().type(CommitLogManifest.class)).hasSize(1);
assertThat(ofy().load().type(CommitLogMutation.class)).isEmpty(); assertThat(ofy().load().type(CommitLogMutation.class)).isEmpty();
@ -202,11 +164,7 @@ public class OfyCommitLogTest {
final CommitLogManifest backupsArentAllowedOnMe = final CommitLogManifest backupsArentAllowedOnMe =
CommitLogManifest.create(getBucketKey(1), clock.nowUtc(), ImmutableSet.<Key<?>>of()); CommitLogManifest.create(getBucketKey(1), clock.nowUtc(), ImmutableSet.<Key<?>>of());
thrown.expect(IllegalArgumentException.class, "Can't save/delete a @NotBackedUp"); thrown.expect(IllegalArgumentException.class, "Can't save/delete a @NotBackedUp");
ofy().transactNew(new VoidWork() { ofy().transactNew(() -> ofy().delete().entity(backupsArentAllowedOnMe));
@Override
public void vrun() {
ofy().delete().entity(backupsArentAllowedOnMe);
}});
} }
@Test @Test
@ -214,33 +172,21 @@ public class OfyCommitLogTest {
final CommitLogManifest backupsArentAllowedOnMe = final CommitLogManifest backupsArentAllowedOnMe =
CommitLogManifest.create(getBucketKey(1), clock.nowUtc(), ImmutableSet.<Key<?>>of()); CommitLogManifest.create(getBucketKey(1), clock.nowUtc(), ImmutableSet.<Key<?>>of());
thrown.expect(IllegalArgumentException.class, "Can't save/delete a @NotBackedUp"); thrown.expect(IllegalArgumentException.class, "Can't save/delete a @NotBackedUp");
ofy().transactNew(new VoidWork() { ofy().transactNew(() -> ofy().save().entity(backupsArentAllowedOnMe));
@Override
public void vrun() {
ofy().save().entity(backupsArentAllowedOnMe);
}});
} }
@Test @Test
public void testTransactNew_deleteVirtualEntityKey_throws() throws Exception { public void testTransactNew_deleteVirtualEntityKey_throws() throws Exception {
final Key<TestVirtualObject> virtualEntityKey = TestVirtualObject.createKey("virtual"); final Key<TestVirtualObject> virtualEntityKey = TestVirtualObject.createKey("virtual");
thrown.expect(IllegalArgumentException.class, "Can't save/delete a @VirtualEntity"); thrown.expect(IllegalArgumentException.class, "Can't save/delete a @VirtualEntity");
ofy().transactNew(new VoidWork() { ofy().transactNew(() -> ofy().delete().key(virtualEntityKey));
@Override
public void vrun() {
ofy().delete().key(virtualEntityKey);
}});
} }
@Test @Test
public void testTransactNew_saveVirtualEntity_throws() throws Exception { public void testTransactNew_saveVirtualEntity_throws() throws Exception {
final TestVirtualObject virtualEntity = TestVirtualObject.create("virtual"); final TestVirtualObject virtualEntity = TestVirtualObject.create("virtual");
thrown.expect(IllegalArgumentException.class, "Can't save/delete a @VirtualEntity"); thrown.expect(IllegalArgumentException.class, "Can't save/delete a @VirtualEntity");
ofy().transactNew(new VoidWork() { ofy().transactNew(() -> ofy().save().entity(virtualEntity));
@Override
public void vrun() {
ofy().save().entity(virtualEntity);
}});
} }
@Test @Test
@ -260,42 +206,38 @@ public class OfyCommitLogTest {
@Test @Test
public void testTransact_twoSavesOnSameKey_throws() throws Exception { public void testTransact_twoSavesOnSameKey_throws() throws Exception {
thrown.expect(IllegalArgumentException.class, "Multiple entries with same key"); thrown.expect(IllegalArgumentException.class, "Multiple entries with same key");
ofy().transact(new VoidWork() { ofy()
@Override .transact(
public void vrun() { () -> {
ofy().save().entity(Root.create(1, getCrossTldKey())); ofy().save().entity(Root.create(1, getCrossTldKey()));
ofy().save().entity(Root.create(1, getCrossTldKey())); ofy().save().entity(Root.create(1, getCrossTldKey()));
}}); });
} }
@Test @Test
public void testTransact_saveAndDeleteSameKey_throws() throws Exception { public void testTransact_saveAndDeleteSameKey_throws() throws Exception {
thrown.expect(IllegalArgumentException.class, "Multiple entries with same key"); thrown.expect(IllegalArgumentException.class, "Multiple entries with same key");
ofy().transact(new VoidWork() { ofy()
@Override .transact(
public void vrun() { () -> {
ofy().save().entity(Root.create(1, getCrossTldKey())); ofy().save().entity(Root.create(1, getCrossTldKey()));
ofy().delete().entity(Root.create(1, getCrossTldKey())); ofy().delete().entity(Root.create(1, getCrossTldKey()));
}}); });
} }
@Test @Test
public void testSavingRootAndChild_updatesTimestampOnBackupGroupRoot() throws Exception { public void testSavingRootAndChild_updatesTimestampOnBackupGroupRoot() throws Exception {
ofy().transact(new VoidWork() { ofy().transact(() -> ofy().save().entity(Root.create(1, getCrossTldKey())));
@Override
public void vrun() {
ofy().save().entity(Root.create(1, getCrossTldKey()));
}});
ofy().clearSessionCache(); ofy().clearSessionCache();
assertThat(ofy().load().key(Key.create(getCrossTldKey(), Root.class, 1)).now() assertThat(ofy().load().key(Key.create(getCrossTldKey(), Root.class, 1)).now()
.getUpdateAutoTimestamp().getTimestamp()).isEqualTo(clock.nowUtc()); .getUpdateAutoTimestamp().getTimestamp()).isEqualTo(clock.nowUtc());
clock.advanceOneMilli(); clock.advanceOneMilli();
ofy().transact(new VoidWork() { ofy()
@Override .transact(
public void vrun() { () -> {
ofy().save().entity(Root.create(1, getCrossTldKey())); ofy().save().entity(Root.create(1, getCrossTldKey()));
ofy().save().entity(new Child()); ofy().save().entity(new Child());
}}); });
ofy().clearSessionCache(); ofy().clearSessionCache();
assertThat(ofy().load().key(Key.create(getCrossTldKey(), Root.class, 1)).now() assertThat(ofy().load().key(Key.create(getCrossTldKey(), Root.class, 1)).now()
.getUpdateAutoTimestamp().getTimestamp()).isEqualTo(clock.nowUtc()); .getUpdateAutoTimestamp().getTimestamp()).isEqualTo(clock.nowUtc());
@ -303,20 +245,12 @@ public class OfyCommitLogTest {
@Test @Test
public void testSavingOnlyChild_updatesTimestampOnBackupGroupRoot() throws Exception { public void testSavingOnlyChild_updatesTimestampOnBackupGroupRoot() throws Exception {
ofy().transact(new VoidWork() { ofy().transact(() -> ofy().save().entity(Root.create(1, getCrossTldKey())));
@Override
public void vrun() {
ofy().save().entity(Root.create(1, getCrossTldKey()));
}});
ofy().clearSessionCache(); ofy().clearSessionCache();
assertThat(ofy().load().key(Key.create(getCrossTldKey(), Root.class, 1)).now() assertThat(ofy().load().key(Key.create(getCrossTldKey(), Root.class, 1)).now()
.getUpdateAutoTimestamp().getTimestamp()).isEqualTo(clock.nowUtc()); .getUpdateAutoTimestamp().getTimestamp()).isEqualTo(clock.nowUtc());
clock.advanceOneMilli(); clock.advanceOneMilli();
ofy().transact(new VoidWork() { ofy().transact(() -> ofy().save().entity(new Child()));
@Override
public void vrun() {
ofy().save().entity(new Child());
}});
ofy().clearSessionCache(); ofy().clearSessionCache();
assertThat(ofy().load().key(Key.create(getCrossTldKey(), Root.class, 1)).now() assertThat(ofy().load().key(Key.create(getCrossTldKey(), Root.class, 1)).now()
.getUpdateAutoTimestamp().getTimestamp()).isEqualTo(clock.nowUtc()); .getUpdateAutoTimestamp().getTimestamp()).isEqualTo(clock.nowUtc());
@ -324,21 +258,13 @@ public class OfyCommitLogTest {
@Test @Test
public void testDeletingChild_updatesTimestampOnBackupGroupRoot() throws Exception { public void testDeletingChild_updatesTimestampOnBackupGroupRoot() throws Exception {
ofy().transact(new VoidWork() { ofy().transact(() -> ofy().save().entity(Root.create(1, getCrossTldKey())));
@Override
public void vrun() {
ofy().save().entity(Root.create(1, getCrossTldKey()));
}});
ofy().clearSessionCache(); ofy().clearSessionCache();
assertThat(ofy().load().key(Key.create(getCrossTldKey(), Root.class, 1)).now() assertThat(ofy().load().key(Key.create(getCrossTldKey(), Root.class, 1)).now()
.getUpdateAutoTimestamp().getTimestamp()).isEqualTo(clock.nowUtc()); .getUpdateAutoTimestamp().getTimestamp()).isEqualTo(clock.nowUtc());
clock.advanceOneMilli(); clock.advanceOneMilli();
ofy().transact(new VoidWork() {
@Override
public void vrun() {
// The fact that the child was never persisted is irrelevant. // The fact that the child was never persisted is irrelevant.
ofy().delete().entity(new Child()); ofy().transact(() -> ofy().delete().entity(new Child()));
}});
ofy().clearSessionCache(); ofy().clearSessionCache();
assertThat(ofy().load().key(Key.create(getCrossTldKey(), Root.class, 1)).now() assertThat(ofy().load().key(Key.create(getCrossTldKey(), Root.class, 1)).now()
.getUpdateAutoTimestamp().getTimestamp()).isEqualTo(clock.nowUtc()); .getUpdateAutoTimestamp().getTimestamp()).isEqualTo(clock.nowUtc());
@ -346,23 +272,19 @@ public class OfyCommitLogTest {
@Test @Test
public void testReadingRoot_doesntUpdateTimestamp() throws Exception { public void testReadingRoot_doesntUpdateTimestamp() throws Exception {
ofy().transact(new VoidWork() { ofy().transact(() -> ofy().save().entity(Root.create(1, getCrossTldKey())));
@Override
public void vrun() {
ofy().save().entity(Root.create(1, getCrossTldKey()));
}});
ofy().clearSessionCache(); ofy().clearSessionCache();
assertThat(ofy().load().key(Key.create(getCrossTldKey(), Root.class, 1)).now() assertThat(ofy().load().key(Key.create(getCrossTldKey(), Root.class, 1)).now()
.getUpdateAutoTimestamp().getTimestamp()).isEqualTo(clock.nowUtc()); .getUpdateAutoTimestamp().getTimestamp()).isEqualTo(clock.nowUtc());
clock.advanceOneMilli(); clock.advanceOneMilli();
ofy().transact(new VoidWork() { ofy()
@Override .transact(
public void vrun() { () -> {
// Don't remove this line, as without saving *something* the commit log co/de will never // Don't remove this line, as without saving *something* the commit log code will
// be invoked and the test will trivially pass // never be invoked and the test will trivially pass.
ofy().save().entity(Root.create(2, getCrossTldKey())); ofy().save().entity(Root.create(2, getCrossTldKey()));
ofy().load().entity(Root.create(1, getCrossTldKey())); ofy().load().entity(Root.create(1, getCrossTldKey()));
}}); });
ofy().clearSessionCache(); ofy().clearSessionCache();
assertThat(ofy().load().key(Key.create(getCrossTldKey(), Root.class, 1)).now() assertThat(ofy().load().key(Key.create(getCrossTldKey(), Root.class, 1)).now()
.getUpdateAutoTimestamp().getTimestamp()).isEqualTo(clock.nowUtc().minusMillis(1)); .getUpdateAutoTimestamp().getTimestamp()).isEqualTo(clock.nowUtc().minusMillis(1));
@ -370,23 +292,19 @@ public class OfyCommitLogTest {
@Test @Test
public void testReadingChild_doesntUpdateTimestampOnBackupGroupRoot() throws Exception { public void testReadingChild_doesntUpdateTimestampOnBackupGroupRoot() throws Exception {
ofy().transact(new VoidWork() { ofy().transact(() -> ofy().save().entity(Root.create(1, getCrossTldKey())));
@Override
public void vrun() {
ofy().save().entity(Root.create(1, getCrossTldKey()));
}});
ofy().clearSessionCache(); ofy().clearSessionCache();
assertThat(ofy().load().key(Key.create(getCrossTldKey(), Root.class, 1)).now() assertThat(ofy().load().key(Key.create(getCrossTldKey(), Root.class, 1)).now()
.getUpdateAutoTimestamp().getTimestamp()).isEqualTo(clock.nowUtc()); .getUpdateAutoTimestamp().getTimestamp()).isEqualTo(clock.nowUtc());
clock.advanceOneMilli(); clock.advanceOneMilli();
ofy().transact(new VoidWork() { ofy()
@Override .transact(
public void vrun() { () -> {
// Don't remove this line, as without saving *something* the commit log co/de will never // Don't remove this line, as without saving *something* the commit log code will
// be invoked and the test will trivially pass // never be invoked and the test will trivially pass
ofy().save().entity(Root.create(2, getCrossTldKey())); ofy().save().entity(Root.create(2, getCrossTldKey()));
ofy().load().entity(new Child()); // All Child objects are under Root(1). ofy().load().entity(new Child()); // All Child objects are under Root(1).
}}); });
ofy().clearSessionCache(); ofy().clearSessionCache();
assertThat(ofy().load().key(Key.create(getCrossTldKey(), Root.class, 1)).now() assertThat(ofy().load().key(Key.create(getCrossTldKey(), Root.class, 1)).now()
.getUpdateAutoTimestamp().getTimestamp()).isEqualTo(clock.nowUtc().minusMillis(1)); .getUpdateAutoTimestamp().getTimestamp()).isEqualTo(clock.nowUtc().minusMillis(1));
@ -395,13 +313,13 @@ public class OfyCommitLogTest {
@Test @Test
public void testSavingAcrossBackupGroupRoots_updatesCorrectTimestamps() throws Exception { public void testSavingAcrossBackupGroupRoots_updatesCorrectTimestamps() throws Exception {
// Create three roots. // Create three roots.
ofy().transact(new VoidWork() { ofy()
@Override .transact(
public void vrun() { () -> {
ofy().save().entity(Root.create(1, getCrossTldKey())); ofy().save().entity(Root.create(1, getCrossTldKey()));
ofy().save().entity(Root.create(2, getCrossTldKey())); ofy().save().entity(Root.create(2, getCrossTldKey()));
ofy().save().entity(Root.create(3, getCrossTldKey())); ofy().save().entity(Root.create(3, getCrossTldKey()));
}}); });
ofy().clearSessionCache(); ofy().clearSessionCache();
for (int i = 1; i <= 3; i++) { for (int i = 1; i <= 3; i++) {
assertThat(ofy().load().key(Key.create(getCrossTldKey(), Root.class, i)).now() assertThat(ofy().load().key(Key.create(getCrossTldKey(), Root.class, i)).now()
@ -409,12 +327,12 @@ public class OfyCommitLogTest {
} }
clock.advanceOneMilli(); clock.advanceOneMilli();
// Mutate one root, and a child of a second, ignoring the third. // Mutate one root, and a child of a second, ignoring the third.
ofy().transact(new VoidWork() { ofy()
@Override .transact(
public void vrun() { () -> {
ofy().save().entity(new Child()); // All Child objects are under Root(1). ofy().save().entity(new Child()); // All Child objects are under Root(1).
ofy().save().entity(Root.create(2, getCrossTldKey())); ofy().save().entity(Root.create(2, getCrossTldKey()));
}}); });
ofy().clearSessionCache(); ofy().clearSessionCache();
// Child was touched. // Child was touched.
assertThat(ofy().load().key(Key.create(getCrossTldKey(), Root.class, 1)).now() assertThat(ofy().load().key(Key.create(getCrossTldKey(), Root.class, 1)).now()

View file

@ -21,7 +21,6 @@ import static google.registry.util.DateTimeUtils.START_OF_TIME;
import static org.joda.time.Duration.standardDays; import static org.joda.time.Duration.standardDays;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import com.googlecode.objectify.VoidWork;
import google.registry.testing.AppEngineRule; import google.registry.testing.AppEngineRule;
import google.registry.testing.ExceptionRule; import google.registry.testing.ExceptionRule;
import google.registry.testing.FakeClock; import google.registry.testing.FakeClock;
@ -49,14 +48,15 @@ public class SignedMarkRevocationListTest {
public void testUnshardedSaveFails() throws Exception { public void testUnshardedSaveFails() throws Exception {
thrown.expect(SignedMarkRevocationList.UnshardedSaveException.class); thrown.expect(SignedMarkRevocationList.UnshardedSaveException.class);
// Our @Entity's @OnSave method will notice that this shouldn't be saved. // Our @Entity's @OnSave method will notice that this shouldn't be saved.
ofy().transact(new VoidWork() { ofy()
@Override .transact(
public void vrun() { () -> {
SignedMarkRevocationList smdrl = SignedMarkRevocationList.create( SignedMarkRevocationList smdrl =
SignedMarkRevocationList.create(
ofy().getTransactionTime(), ImmutableMap.of("a", ofy().getTransactionTime())); ofy().getTransactionTime(), ImmutableMap.of("a", ofy().getTransactionTime()));
smdrl.id = 1; // Without an id this won't save anyways. smdrl.id = 1; // Without an id this won't save anyways.
ofy().saveWithoutBackup().entity(smdrl).now(); ofy().saveWithoutBackup().entity(smdrl).now();
}}); });
} }
@Test @Test

View file

@ -21,7 +21,6 @@ import static org.joda.time.DateTimeZone.UTC;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import com.googlecode.objectify.Key; import com.googlecode.objectify.Key;
import com.googlecode.objectify.VoidWork;
import google.registry.model.tmch.ClaimsListShard.ClaimsListRevision; import google.registry.model.tmch.ClaimsListShard.ClaimsListRevision;
import google.registry.model.tmch.ClaimsListShard.UnshardedSaveException; import google.registry.model.tmch.ClaimsListShard.UnshardedSaveException;
import google.registry.testing.AppEngineRule; import google.registry.testing.AppEngineRule;
@ -60,15 +59,15 @@ public class ClaimsListShardTest {
@Test @Test
public void test_unshardedSaveFails() throws Exception { public void test_unshardedSaveFails() throws Exception {
thrown.expect(UnshardedSaveException.class); thrown.expect(UnshardedSaveException.class);
ofy().transact(new VoidWork() { ofy()
@Override .transact(
public void vrun() { () -> {
ClaimsListShard claimsList = ClaimsListShard claimsList =
ClaimsListShard.create(ofy().getTransactionTime(), ImmutableMap.of("a", "b")); ClaimsListShard.create(ofy().getTransactionTime(), ImmutableMap.of("a", "b"));
claimsList.id = 1; // Without an id this won't save anyways. claimsList.id = 1; // Without an id this won't save anyways.
claimsList.parent = ClaimsListRevision.createKey(); claimsList.parent = ClaimsListRevision.createKey();
ofy().saveWithoutBackup().entity(claimsList).now(); ofy().saveWithoutBackup().entity(claimsList).now();
}}); });
} }
@Test @Test

View file

@ -23,7 +23,6 @@ import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSortedMap; import com.google.common.collect.ImmutableSortedMap;
import com.googlecode.objectify.Key; import com.googlecode.objectify.Key;
import com.googlecode.objectify.ObjectifyService; import com.googlecode.objectify.ObjectifyService;
import com.googlecode.objectify.VoidWork;
import com.googlecode.objectify.Work; import com.googlecode.objectify.Work;
import com.googlecode.objectify.annotation.Entity; import com.googlecode.objectify.annotation.Entity;
import google.registry.model.common.CrossTldSingleton; import google.registry.model.common.CrossTldSingleton;
@ -72,11 +71,7 @@ public class CommitLogRevisionsTranslatorFactoryTest {
} }
private void save(final TestObject object) { private void save(final TestObject object) {
ofy().transact(new VoidWork() { ofy().transact(() -> ofy().save().entity(object));
@Override
public void vrun() {
ofy().save().entity(object);
}});
} }
private TestObject reload() { private TestObject reload() {

View file

@ -26,7 +26,6 @@ import static org.joda.time.DateTimeConstants.TUESDAY;
import static org.joda.time.Duration.standardDays; import static org.joda.time.Duration.standardDays;
import com.google.common.collect.ImmutableSetMultimap; import com.google.common.collect.ImmutableSetMultimap;
import com.googlecode.objectify.VoidWork;
import google.registry.model.common.Cursor; import google.registry.model.common.Cursor;
import google.registry.model.common.Cursor.CursorType; import google.registry.model.common.Cursor.CursorType;
import google.registry.model.ofy.Ofy; import google.registry.model.ofy.Ofy;
@ -165,11 +164,7 @@ public class PendingDepositCheckerTest {
private static void setCursor( private static void setCursor(
final Registry registry, final CursorType cursorType, final DateTime value) { final Registry registry, final CursorType cursorType, final DateTime value) {
ofy().transact(new VoidWork() { ofy().transact(() -> ofy().save().entity(Cursor.create(cursorType, value, registry)));
@Override
public void vrun() {
ofy().save().entity(Cursor.create(cursorType, value, registry));
}});
} }
private static void createTldWithEscrowEnabled(final String tld) { private static void createTldWithEscrowEnabled(final String tld) {

View file

@ -44,7 +44,6 @@ import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.google.common.net.InetAddresses; import com.google.common.net.InetAddresses;
import com.googlecode.objectify.VoidWork;
import google.registry.keyring.api.Keyring; import google.registry.keyring.api.Keyring;
import google.registry.keyring.api.PgpHelper; import google.registry.keyring.api.PgpHelper;
import google.registry.model.common.Cursor; import google.registry.model.common.Cursor;
@ -864,11 +863,7 @@ public class RdeStagingActionTest extends MapreduceTestCase<RdeStagingAction> {
private void setCursor( private void setCursor(
final Registry registry, final CursorType cursorType, final DateTime value) { final Registry registry, final CursorType cursorType, final DateTime value) {
clock.advanceOneMilli(); clock.advanceOneMilli();
ofy().transact(new VoidWork() { ofy().transact(() -> ofy().save().entity(Cursor.create(cursorType, value, registry)).now());
@Override
public void vrun() {
ofy().save().entity(Cursor.create(cursorType, value, registry)).now();
}});
} }
public static <T> T unmarshal(Class<T> clazz, byte[] xml) throws XmlException { public static <T> T unmarshal(Class<T> clazz, byte[] xml) throws XmlException {

View file

@ -47,7 +47,6 @@ import com.google.appengine.tools.cloudstorage.GcsServiceFactory;
import com.google.common.io.ByteSource; import com.google.common.io.ByteSource;
import com.google.common.io.CharStreams; import com.google.common.io.CharStreams;
import com.google.common.io.Files; import com.google.common.io.Files;
import com.googlecode.objectify.VoidWork;
import com.jcraft.jsch.JSch; import com.jcraft.jsch.JSch;
import com.jcraft.jsch.JSchException; import com.jcraft.jsch.JSchException;
import com.jcraft.jsch.Session; import com.jcraft.jsch.Session;
@ -252,12 +251,12 @@ public class RdeUploadActionTest {
Ghostryde.encode(REPORT_XML.read(), encryptKey, "dieform.xml", clock.nowUtc())); Ghostryde.encode(REPORT_XML.read(), encryptKey, "dieform.xml", clock.nowUtc()));
writeGcsFile(gcsService, REPORT_R1_FILE, writeGcsFile(gcsService, REPORT_R1_FILE,
Ghostryde.encode(REPORT_XML.read(), encryptKey, "dieform.xml", clock.nowUtc())); Ghostryde.encode(REPORT_XML.read(), encryptKey, "dieform.xml", clock.nowUtc()));
ofy().transact(new VoidWork() { ofy()
@Override .transact(
public void vrun() { () -> {
RdeRevision.saveRevision("lol", DateTime.parse("2010-10-17TZ"), FULL, 0); RdeRevision.saveRevision("lol", DateTime.parse("2010-10-17TZ"), FULL, 0);
RdeRevision.saveRevision("tld", DateTime.parse("2010-10-17TZ"), FULL, 0); RdeRevision.saveRevision("tld", DateTime.parse("2010-10-17TZ"), FULL, 0);
}}); });
} }
@Test @Test
@ -342,11 +341,7 @@ public class RdeUploadActionTest {
@Test @Test
public void testRunWithLock_resend() throws Exception { public void testRunWithLock_resend() throws Exception {
ofy().transact(new VoidWork() { ofy().transact(() -> RdeRevision.saveRevision("tld", DateTime.parse("2010-10-17TZ"), FULL, 1));
@Override
public void vrun() {
RdeRevision.saveRevision("tld", DateTime.parse("2010-10-17TZ"), FULL, 1);
}});
int port = sftpd.serve("user", "password", folder.getRoot()); int port = sftpd.serve("user", "password", folder.getRoot());
URI uploadUrl = URI.create(String.format("sftp://user:password@localhost:%d/", port)); URI uploadUrl = URI.create(String.format("sftp://user:password@localhost:%d/", port));
DateTime stagingCursor = DateTime.parse("2010-10-18TZ"); DateTime stagingCursor = DateTime.parse("2010-10-18TZ");

View file

@ -34,8 +34,6 @@ import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Streams; import com.google.common.collect.Streams;
import com.google.common.io.ByteSource; import com.google.common.io.ByteSource;
import com.googlecode.objectify.Key; import com.googlecode.objectify.Key;
import com.googlecode.objectify.VoidWork;
import com.googlecode.objectify.Work;
import google.registry.gcs.GcsUtils; import google.registry.gcs.GcsUtils;
import google.registry.model.EppResource; import google.registry.model.EppResource;
import google.registry.model.contact.ContactResource; import google.registry.model.contact.ContactResource;
@ -111,11 +109,7 @@ public class RdeImportUtilsTest extends ShardableTestCase {
@Test @Test
public void testImportNewContact() { public void testImportNewContact() {
final ContactResource newContact = buildNewContact(); final ContactResource newContact = buildNewContact();
ofy().transact(new VoidWork() { ofy().transact(() -> rdeImportUtils.importEppResource(newContact));
@Override
public void vrun() {
rdeImportUtils.importEppResource(newContact);
}});
assertEppResourceIndexEntityFor(newContact); assertEppResourceIndexEntityFor(newContact);
assertForeignKeyIndexFor(newContact); assertForeignKeyIndexFor(newContact);
@ -138,11 +132,7 @@ public class RdeImportUtilsTest extends ShardableTestCase {
.setLastEppUpdateTime(newContact.getLastEppUpdateTime().plusSeconds(1)) .setLastEppUpdateTime(newContact.getLastEppUpdateTime().plusSeconds(1))
.build(); .build();
try { try {
ofy().transact(new VoidWork() { ofy().transact(() -> rdeImportUtils.importEppResource(updatedContact));
@Override
public void vrun() {
rdeImportUtils.importEppResource(updatedContact);
}});
fail("Expected ResourceExistsException"); fail("Expected ResourceExistsException");
} catch (ResourceExistsException expected) { } catch (ResourceExistsException expected) {
// verify the updated contact was not saved // verify the updated contact was not saved
@ -158,11 +148,7 @@ public class RdeImportUtilsTest extends ShardableTestCase {
@Test @Test
public void testImportNewHost() throws UnknownHostException { public void testImportNewHost() throws UnknownHostException {
final HostResource newHost = buildNewHost(); final HostResource newHost = buildNewHost();
ofy().transact(new VoidWork() { ofy().transact(() -> rdeImportUtils.importEppResource(newHost));
@Override
public void vrun() {
rdeImportUtils.importEppResource(newHost);
}});
assertEppResourceIndexEntityFor(newHost); assertEppResourceIndexEntityFor(newHost);
assertForeignKeyIndexFor(newHost); assertForeignKeyIndexFor(newHost);
@ -186,11 +172,7 @@ public class RdeImportUtilsTest extends ShardableTestCase {
.setLastEppUpdateTime(newHost.getLastEppUpdateTime().plusSeconds(1)) .setLastEppUpdateTime(newHost.getLastEppUpdateTime().plusSeconds(1))
.build(); .build();
try { try {
ofy().transact(new VoidWork() { ofy().transact(() -> rdeImportUtils.importEppResource(updatedHost));
@Override
public void vrun() {
rdeImportUtils.importEppResource(updatedHost);
}});
fail("Expected ResourceExistsException"); fail("Expected ResourceExistsException");
} catch (ResourceExistsException expected) { } catch (ResourceExistsException expected) {
// verify the contact was not updated // verify the contact was not updated
@ -205,12 +187,7 @@ public class RdeImportUtilsTest extends ShardableTestCase {
@Test @Test
public void testImportNewDomain() throws Exception { public void testImportNewDomain() throws Exception {
final DomainResource newDomain = buildNewDomain(); final DomainResource newDomain = buildNewDomain();
ofy().transact(new VoidWork() { ofy().transact(() -> rdeImportUtils.importEppResource(newDomain));
@Override
public void vrun() {
rdeImportUtils.importEppResource(newDomain);
}
});
DomainResource saved = getDomain("Dexample1-TEST"); DomainResource saved = getDomain("Dexample1-TEST");
assertThat(saved.getFullyQualifiedDomainName()) assertThat(saved.getFullyQualifiedDomainName())
@ -229,15 +206,13 @@ public class RdeImportUtilsTest extends ShardableTestCase {
public void testImportExistingDomain() throws Exception { public void testImportExistingDomain() throws Exception {
DomainResource newDomain = buildNewDomain(); DomainResource newDomain = buildNewDomain();
persistResource(newDomain); persistResource(newDomain);
final DomainResource updatedDomain = newDomain.asBuilder() final DomainResource updatedDomain =
newDomain
.asBuilder()
.setFullyQualifiedDomainName("1" + newDomain.getFullyQualifiedDomainName()) .setFullyQualifiedDomainName("1" + newDomain.getFullyQualifiedDomainName())
.build(); .build();
try { try {
ofy().transact(new VoidWork() { ofy().transact(() -> rdeImportUtils.importEppResource(updatedDomain));
@Override
public void vrun() {
rdeImportUtils.importEppResource(updatedDomain);
}});
fail("Expected ResourceExistsException"); fail("Expected ResourceExistsException");
} catch (ResourceExistsException expected) { } catch (ResourceExistsException expected) {
DomainResource saved = getDomain("Dexample1-TEST"); DomainResource saved = getDomain("Dexample1-TEST");
@ -339,32 +314,19 @@ public class RdeImportUtilsTest extends ShardableTestCase {
/** Gets the contact with the specified ROID */ /** Gets the contact with the specified ROID */
private static ContactResource getContact(String repoId) { private static ContactResource getContact(String repoId) {
final Key<ContactResource> key = Key.create(ContactResource.class, repoId); final Key<ContactResource> key = Key.create(ContactResource.class, repoId);
return ofy().transact(new Work<ContactResource>() { return ofy().transact(() -> ofy().load().key(key).now());
@Override
public ContactResource run() {
return ofy().load().key(key).now();
}});
} }
/** Gets the host with the specified ROID */ /** Gets the host with the specified ROID */
private static HostResource getHost(String repoId) { private static HostResource getHost(String repoId) {
final Key<HostResource> key = Key.create(HostResource.class, repoId); final Key<HostResource> key = Key.create(HostResource.class, repoId);
return ofy().transact(new Work<HostResource>() { return ofy().transact(() -> ofy().load().key(key).now());
@Override
public HostResource run() {
return ofy().load().key(key).now();
}
});
} }
/** Gets the domain with the specified ROID */ /** Gets the domain with the specified ROID */
private static DomainResource getDomain(String repoId) { private static DomainResource getDomain(String repoId) {
final Key<DomainResource> key = Key.create(DomainResource.class, repoId); final Key<DomainResource> key = Key.create(DomainResource.class, repoId);
return ofy().transact(new Work<DomainResource>() { return ofy().transact(() -> ofy().load().key(key).now());
@Override
public DomainResource run() {
return ofy().load().key(key).now();
}});
} }
/** Confirms that a ForeignKeyIndex exists in Datastore for a given resource. */ /** Confirms that a ForeignKeyIndex exists in Datastore for a given resource. */

View file

@ -138,17 +138,19 @@ public class LordnTaskTest {
@Test @Test
public void test_oteRegistrarWithNullIanaId() throws Exception { public void test_oteRegistrarWithNullIanaId() throws Exception {
ofy().transact(new VoidWork() { ofy()
@Override .transact(
public void vrun() { () ->
ofy().save().entity(loadRegistrar("TheRegistrar").asBuilder() ofy()
.save()
.entity(
loadRegistrar("TheRegistrar")
.asBuilder()
.setType(Type.OTE) .setType(Type.OTE)
.setIanaIdentifier(null) .setIanaIdentifier(null)
.build()); .build()));
}}); DomainResource domain =
DomainResource domain = newDomainBuilder(DateTime.parse("2010-05-01T10:11:12Z")) newDomainBuilder(DateTime.parse("2010-05-01T10:11:12Z")).setRepoId("3-EXAMPLE").build();
.setRepoId("3-EXAMPLE")
.build();
persistDomainAndEnqueueLordn(domain); persistDomainAndEnqueueLordn(domain);
String expectedPayload = String expectedPayload =
"3-EXAMPLE,fleece.example,smdzzzz,null,2010-05-01T10:11:12.000Z,2010-05-01T10:11:12.000Z"; "3-EXAMPLE,fleece.example,smdzzzz,null,2010-05-01T10:11:12.000Z,2010-05-01T10:11:12.000Z";