diff --git a/core/src/main/java/google/registry/model/EntityClasses.java b/core/src/main/java/google/registry/model/EntityClasses.java index af2b660aa..d82e08f94 100644 --- a/core/src/main/java/google/registry/model/EntityClasses.java +++ b/core/src/main/java/google/registry/model/EntityClasses.java @@ -43,9 +43,6 @@ import google.registry.model.reporting.HistoryEntry; import google.registry.model.server.Lock; import google.registry.model.server.ServerSecret; import google.registry.model.tld.Registry; -import google.registry.model.tmch.ClaimsList; -import google.registry.model.tmch.ClaimsList.ClaimsListRevision; -import google.registry.model.tmch.ClaimsList.ClaimsListSingleton; import google.registry.model.tmch.TmchCrl; /** Sets of classes of the Objectify-registered entities in use throughout the model. */ @@ -59,9 +56,6 @@ public final class EntityClasses { BillingEvent.Modification.class, BillingEvent.OneTime.class, BillingEvent.Recurring.class, - ClaimsList.class, - ClaimsListRevision.class, - ClaimsListSingleton.class, CommitLogBucket.class, CommitLogCheckpoint.class, CommitLogCheckpointRoot.class, diff --git a/core/src/main/java/google/registry/model/tmch/ClaimsList.java b/core/src/main/java/google/registry/model/tmch/ClaimsList.java index ed1e5ab03..644c0298b 100644 --- a/core/src/main/java/google/registry/model/tmch/ClaimsList.java +++ b/core/src/main/java/google/registry/model/tmch/ClaimsList.java @@ -17,34 +17,21 @@ package google.registry.model.tmch; import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkState; import static com.google.common.collect.ImmutableMap.toImmutableMap; -import static google.registry.model.IdService.allocateId; -import static google.registry.model.ofy.ObjectifyService.auditedOfy; import static google.registry.persistence.transaction.QueryComposer.Comparator.EQ; import static google.registry.persistence.transaction.TransactionManagerFactory.jpaTm; -import com.google.common.annotations.VisibleForTesting; import com.google.common.collect.ImmutableMap; -import com.googlecode.objectify.Key; -import com.googlecode.objectify.annotation.Entity; -import com.googlecode.objectify.annotation.Id; -import com.googlecode.objectify.annotation.Ignore; -import com.googlecode.objectify.annotation.Parent; import google.registry.model.CreateAutoTimestamp; import google.registry.model.ImmutableObject; -import google.registry.model.annotations.InCrossTld; -import google.registry.model.annotations.NotBackedUp; -import google.registry.model.annotations.NotBackedUp.Reason; -import google.registry.model.annotations.VirtualEntity; -import google.registry.model.common.CrossTldSingleton; -import google.registry.model.replay.DatastoreOnlyEntity; -import google.registry.model.replay.NonReplicatedEntity; +import google.registry.model.replay.SqlOnlyEntity; import google.registry.model.tld.label.ReservedList.ReservedListEntry; import java.util.Map; import java.util.Optional; -import javax.annotation.Nullable; import javax.persistence.Column; +import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; +import javax.persistence.Id; import javax.persistence.PostPersist; import javax.persistence.PostUpdate; import javax.persistence.PreRemove; @@ -60,26 +47,15 @@ import org.joda.time.DateTime; * succeeds, we will end up with having two exact same claims list with only different {@link * #revisionId}. However, this is not an actual problem because we only use the claims list with * highest {@link #revisionId}. - * - *

TODO(b/162007765): Remove Datastore related fields and methods. */ -@Entity -@NotBackedUp(reason = Reason.EXTERNALLY_SOURCED) -@javax.persistence.Entity(name = "ClaimsList") +@Entity(name = "ClaimsList") @Table -@InCrossTld -public class ClaimsList extends ImmutableObject implements NonReplicatedEntity { +public class ClaimsList extends ImmutableObject implements SqlOnlyEntity { - @Transient @Id long id; - - @Transient @Parent Key parent; - - @Ignore - @javax.persistence.Id + @Id @GeneratedValue(strategy = GenerationType.IDENTITY) Long revisionId; - @Ignore @Column(nullable = false) CreateAutoTimestamp creationTimestamp = CreateAutoTimestamp.create(null); @@ -217,65 +193,8 @@ public class ClaimsList extends ImmutableObject implements NonReplicatedEntity { public static ClaimsList create( DateTime tmdbGenerationTime, ImmutableMap labelsToKeys) { ClaimsList instance = new ClaimsList(); - instance.id = allocateId(); instance.creationTime = checkNotNull(tmdbGenerationTime); instance.labelsToKeys = checkNotNull(labelsToKeys); return instance; } - - /** Virtual parent entity for claims list shards of a specific revision. */ - @Entity - @VirtualEntity - public static class ClaimsListRevision extends ImmutableObject implements DatastoreOnlyEntity { - @Parent Key parent; - - @Id long versionId; - - @VisibleForTesting - public static Key createKey(ClaimsListSingleton singleton) { - ClaimsListRevision revision = new ClaimsListRevision(); - revision.versionId = allocateId(); - revision.parent = Key.create(singleton); - return Key.create(revision); - } - - @VisibleForTesting - public static Key createKey() { - return createKey(new ClaimsListSingleton()); - } - } - - /** - * Serves as the coordinating claims list singleton linking to the {@link ClaimsListRevision} that - * is live. - */ - @Entity - @NotBackedUp(reason = Reason.EXTERNALLY_SOURCED) - public static class ClaimsListSingleton extends CrossTldSingleton implements DatastoreOnlyEntity { - Key activeRevision; - - static ClaimsListSingleton create(Key revision) { - ClaimsListSingleton instance = new ClaimsListSingleton(); - instance.activeRevision = revision; - return instance; - } - - @VisibleForTesting - public void setActiveRevision(Key revision) { - activeRevision = revision; - } - } - - /** - * Returns the current ClaimsListRevision if there is one, or null if no claims list revisions - * have ever been persisted yet. - */ - @Nullable - public static Key getCurrentRevision() { - ClaimsListSingleton singleton = auditedOfy().load().entity(new ClaimsListSingleton()).now(); - return singleton == null ? null : singleton.activeRevision; - } - - /** Exception when trying to directly save a {@link ClaimsList} without sharding. */ - public static class UnshardedSaveException extends RuntimeException {} } diff --git a/core/src/main/java/google/registry/persistence/transaction/JpaTransactionManagerImpl.java b/core/src/main/java/google/registry/persistence/transaction/JpaTransactionManagerImpl.java index 06fd11225..2f2eea9b1 100644 --- a/core/src/main/java/google/registry/persistence/transaction/JpaTransactionManagerImpl.java +++ b/core/src/main/java/google/registry/persistence/transaction/JpaTransactionManagerImpl.java @@ -40,7 +40,6 @@ import google.registry.model.index.ForeignKeyIndex.ForeignKeyHostIndex; import google.registry.model.ofy.DatastoreTransactionManager; import google.registry.model.replay.NonReplicatedEntity; import google.registry.model.replay.SqlOnlyEntity; -import google.registry.model.tmch.ClaimsList.ClaimsListSingleton; import google.registry.persistence.JpaRetries; import google.registry.persistence.VKey; import google.registry.util.Clock; @@ -90,7 +89,6 @@ public class JpaTransactionManagerImpl implements JpaTransactionManager { // TODO(b/176108270): Remove this property after database migration. private static final ImmutableSet> IGNORED_ENTITY_CLASSES = ImmutableSet.of( - ClaimsListSingleton.class, EppResourceIndex.class, ForeignKeyContactIndex.class, ForeignKeyDomainIndex.class, diff --git a/core/src/main/java/google/registry/tmch/TmchDnlAction.java b/core/src/main/java/google/registry/tmch/TmchDnlAction.java index a6bbdfdd1..a5ec90f3d 100644 --- a/core/src/main/java/google/registry/tmch/TmchDnlAction.java +++ b/core/src/main/java/google/registry/tmch/TmchDnlAction.java @@ -46,7 +46,7 @@ public final class TmchDnlAction implements Runnable { @Inject @Key("marksdbDnlLoginAndPassword") Optional marksdbDnlLoginAndPassword; @Inject TmchDnlAction() {} - /** Synchronously fetches latest domain name list and saves it to Datastore. */ + /** Synchronously fetches latest domain name list and saves it to Cloud SQL. */ @Override public void run() { List lines; diff --git a/core/src/test/java/google/registry/backup/ReplayCommitLogsToSqlActionTest.java b/core/src/test/java/google/registry/backup/ReplayCommitLogsToSqlActionTest.java index 701ce5ae5..9c45a959b 100644 --- a/core/src/test/java/google/registry/backup/ReplayCommitLogsToSqlActionTest.java +++ b/core/src/test/java/google/registry/backup/ReplayCommitLogsToSqlActionTest.java @@ -62,7 +62,7 @@ import google.registry.model.replay.SqlReplayCheckpoint; import google.registry.model.server.Lock; import google.registry.model.tld.label.PremiumList; import google.registry.model.tld.label.PremiumList.PremiumEntry; -import google.registry.model.tmch.ClaimsList; +import google.registry.model.tmch.TmchCrl; import google.registry.model.translators.VKeyTranslatorFactory; import google.registry.persistence.VKey; import google.registry.persistence.transaction.JpaTransactionManager; @@ -455,7 +455,7 @@ public class ReplayCommitLogsToSqlActionTest { jpaTm().transact(() -> SqlReplayCheckpoint.set(now.minusMinutes(1).minusMillis(1))); // Save a couple deletes that aren't propagated to SQL (the objects deleted are irrelevant) - Key claimsListKey = Key.create(ClaimsList.class, 1L); + Key tmchCrlKey = Key.create(TmchCrl.class, 1L); saveDiffFile( gcsUtils, createCheckpoint(now.minusMinutes(1)), @@ -463,7 +463,7 @@ public class ReplayCommitLogsToSqlActionTest { getBucketKey(1), now.minusMinutes(1), // one object only exists in Datastore, one is dually-written (so isn't replicated) - ImmutableSet.of(getCrossTldKey(), claimsListKey))); + ImmutableSet.of(getCrossTldKey(), tmchCrlKey))); runAndAssertSuccess(now.minusMinutes(1), 1, 1); verify(spy, times(0)).delete(any(VKey.class)); diff --git a/core/src/test/java/google/registry/flows/EppLifecycleDomainTest.java b/core/src/test/java/google/registry/flows/EppLifecycleDomainTest.java index 60e3f3da7..761ad4fdf 100644 --- a/core/src/test/java/google/registry/flows/EppLifecycleDomainTest.java +++ b/core/src/test/java/google/registry/flows/EppLifecycleDomainTest.java @@ -758,11 +758,11 @@ class EppLifecycleDomainTest extends EppTestCase { .hasResponse( "poll_response_autorenew.xml", ImmutableMap.of( - "ID", "1-C-EXAMPLE-13-16-2002", + "ID", "1-B-EXAMPLE-12-15-2002", "QDATE", "2002-06-01T00:04:00Z", "DOMAIN", "fakesite.example", "EXDATE", "2003-06-01T00:04:00Z")); - assertThatCommand("poll_ack.xml", ImmutableMap.of("ID", "1-C-EXAMPLE-13-16-2002")) + assertThatCommand("poll_ack.xml", ImmutableMap.of("ID", "1-B-EXAMPLE-12-15-2002")) .atTime("2002-07-01T00:02:00Z") .hasResponse("poll_ack_response_empty.xml"); @@ -776,13 +776,13 @@ class EppLifecycleDomainTest extends EppTestCase { .hasResponse( "poll_response_autorenew.xml", ImmutableMap.of( - "ID", "1-C-EXAMPLE-13-16-2003", // Note -- Year is different from previous ID. + "ID", "1-B-EXAMPLE-12-15-2003", // Note -- Year is different from previous ID. "QDATE", "2003-06-01T00:04:00Z", "DOMAIN", "fakesite.example", "EXDATE", "2004-06-01T00:04:00Z")); // Ack the second poll message and verify that none remain. - assertThatCommand("poll_ack.xml", ImmutableMap.of("ID", "1-C-EXAMPLE-13-16-2003")) + assertThatCommand("poll_ack.xml", ImmutableMap.of("ID", "1-B-EXAMPLE-12-15-2003")) .atTime("2003-07-01T00:05:05Z") .hasResponse("poll_ack_response_empty.xml"); assertThatCommand("poll.xml") @@ -812,7 +812,7 @@ class EppLifecycleDomainTest extends EppTestCase { // As the losing registrar, read the request poll message, and then ack it. assertThatLoginSucceeds("NewRegistrar", "foo-BAR2"); - String messageId = "1-C-EXAMPLE-19-25-2001"; + String messageId = "1-B-EXAMPLE-18-24-2001"; assertThatCommand("poll.xml") .atTime("2001-01-01T00:01:00Z") .hasResponse("poll_response_domain_transfer_request.xml", ImmutableMap.of("ID", messageId)); @@ -821,7 +821,7 @@ class EppLifecycleDomainTest extends EppTestCase { .hasResponse("poll_ack_response_empty.xml"); // Five days in the future, expect a server approval poll message to the loser, and ack it. - messageId = "1-C-EXAMPLE-19-24-2001"; + messageId = "1-B-EXAMPLE-18-23-2001"; assertThatCommand("poll.xml") .atTime("2001-01-06T00:01:00Z") .hasResponse( @@ -833,7 +833,7 @@ class EppLifecycleDomainTest extends EppTestCase { assertThatLogoutSucceeds(); // Also expect a server approval poll message to the winner, with the transfer request trid. - messageId = "1-C-EXAMPLE-19-23-2001"; + messageId = "1-B-EXAMPLE-18-22-2001"; assertThatLoginSucceeds("TheRegistrar", "password2"); assertThatCommand("poll.xml") .atTime("2001-01-06T00:02:00Z") diff --git a/core/src/test/java/google/registry/model/tmch/ClaimsListDaoTest.java b/core/src/test/java/google/registry/model/tmch/ClaimsListDaoTest.java index 2d06d545e..38ac20279 100644 --- a/core/src/test/java/google/registry/model/tmch/ClaimsListDaoTest.java +++ b/core/src/test/java/google/registry/model/tmch/ClaimsListDaoTest.java @@ -20,10 +20,8 @@ import static org.junit.jupiter.api.Assertions.assertThrows; import com.google.common.collect.ImmutableMap; import google.registry.persistence.transaction.JpaTestRules; import google.registry.persistence.transaction.JpaTestRules.JpaIntegrationWithCoverageExtension; -import google.registry.testing.DatastoreEntityExtension; import google.registry.testing.FakeClock; import javax.persistence.PersistenceException; -import org.junit.jupiter.api.Order; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; @@ -36,10 +34,6 @@ public class ClaimsListDaoTest { final JpaIntegrationWithCoverageExtension jpa = new JpaTestRules.Builder().withClock(fakeClock).buildIntegrationWithCoverageExtension(); - @RegisterExtension - @Order(value = 1) - final DatastoreEntityExtension datastoreEntityExtension = new DatastoreEntityExtension(); - @Test void save_insertsClaimsListSuccessfully() { ClaimsList claimsList = diff --git a/core/src/test/java/google/registry/tools/EppLifecycleToolsTest.java b/core/src/test/java/google/registry/tools/EppLifecycleToolsTest.java index 3855ea6a2..a7fb44452 100644 --- a/core/src/test/java/google/registry/tools/EppLifecycleToolsTest.java +++ b/core/src/test/java/google/registry/tools/EppLifecycleToolsTest.java @@ -109,7 +109,7 @@ class EppLifecycleToolsTest extends EppTestCase { .atTime("2001-06-08T00:00:00Z") .hasResponse("poll_response_unrenew.xml"); - assertThatCommand("poll_ack.xml", ImmutableMap.of("ID", "1-8-TLD-21-22-2001")) + assertThatCommand("poll_ack.xml", ImmutableMap.of("ID", "1-7-TLD-20-21-2001")) .atTime("2001-06-08T00:00:01Z") .hasResponse("poll_ack_response_empty.xml"); @@ -130,7 +130,7 @@ class EppLifecycleToolsTest extends EppTestCase { .hasResponse( "poll_response_autorenew.xml", ImmutableMap.of( - "ID", "1-8-TLD-21-24-2003", + "ID", "1-7-TLD-20-23-2003", "QDATE", "2003-06-01T00:02:00Z", "DOMAIN", "example.tld", "EXDATE", "2004-06-01T00:02:00Z")); diff --git a/core/src/test/resources/google/registry/export/crosstld_kinds.txt b/core/src/test/resources/google/registry/export/crosstld_kinds.txt index 04c4e7ca9..e7e0d57c0 100644 --- a/core/src/test/resources/google/registry/export/crosstld_kinds.txt +++ b/core/src/test/resources/google/registry/export/crosstld_kinds.txt @@ -1,5 +1,3 @@ -ClaimsList -ClaimsListSingleton Cursor Registrar RegistrarContact diff --git a/core/src/test/resources/google/registry/flows/poll_response_unrenew.xml b/core/src/test/resources/google/registry/flows/poll_response_unrenew.xml index e3b486809..f44fa8957 100644 --- a/core/src/test/resources/google/registry/flows/poll_response_unrenew.xml +++ b/core/src/test/resources/google/registry/flows/poll_response_unrenew.xml @@ -3,7 +3,7 @@ Command completed successfully; ack to dequeue - + 2001-06-07T00:00:00Z Domain example.tld was unrenewed by 3 years; now expires at 2003-06-01T00:02:00.000Z. diff --git a/core/src/test/resources/google/registry/model/schema.txt b/core/src/test/resources/google/registry/model/schema.txt index a3949eb23..e79600624 100644 --- a/core/src/test/resources/google/registry/model/schema.txt +++ b/core/src/test/resources/google/registry/model/schema.txt @@ -789,21 +789,6 @@ enum google.registry.model.tld.Registry$TldType { REAL; TEST; } -class google.registry.model.tmch.ClaimsList { - @Id long id; - @Parent com.googlecode.objectify.Key parent; - com.google.common.collect.ImmutableMap labelsToKeys; - org.joda.time.DateTime creationTime; -} -class google.registry.model.tmch.ClaimsList$ClaimsListRevision { - @Id long versionId; - @Parent com.googlecode.objectify.Key parent; -} -class google.registry.model.tmch.ClaimsList$ClaimsListSingleton { - @Id long id; - @Parent com.googlecode.objectify.Key parent; - com.googlecode.objectify.Key activeRevision; -} class google.registry.model.tmch.TmchCrl { @Id long id; @Parent com.googlecode.objectify.Key parent;