From e01bdf7918f2bc39dc45c5c2f560827d6171c0da Mon Sep 17 00:00:00 2001 From: Wolfgang Werner Date: Thu, 5 Mar 2020 16:56:08 +0100 Subject: [PATCH 1/3] Catch up w/ API changes in 1.2.7 --- src/main/java/io/vlingo/schemata/Bootstrap.java | 4 ++-- src/main/java/io/vlingo/schemata/model/ContextEntity.java | 6 ++++++ .../java/io/vlingo/schemata/model/OrganizationEntity.java | 6 ++++++ src/main/java/io/vlingo/schemata/model/SchemaEntity.java | 5 +++++ .../java/io/vlingo/schemata/model/SchemaVersionEntity.java | 6 ++++++ src/main/java/io/vlingo/schemata/model/UnitEntity.java | 6 ++++++ src/test/java/io/vlingo/schemata/resource/ResourceTest.java | 4 ++-- 7 files changed, 33 insertions(+), 4 deletions(-) diff --git a/src/main/java/io/vlingo/schemata/Bootstrap.java b/src/main/java/io/vlingo/schemata/Bootstrap.java index 0dfdfe91..dd0eedfc 100644 --- a/src/main/java/io/vlingo/schemata/Bootstrap.java +++ b/src/main/java/io/vlingo/schemata/Bootstrap.java @@ -7,14 +7,14 @@ package io.vlingo.schemata; +import io.vlingo.actors.Grid; +import io.vlingo.actors.GridAddressFactory; import io.vlingo.actors.Stage; import io.vlingo.actors.World; import io.vlingo.common.identity.IdentityGeneratorType; import io.vlingo.http.resource.Configuration; import io.vlingo.http.resource.Resources; import io.vlingo.http.resource.Server; -import io.vlingo.lattice.grid.Grid; -import io.vlingo.lattice.grid.GridAddressFactory; import io.vlingo.lattice.model.object.ObjectTypeRegistry; import io.vlingo.schemata.infra.persistence.SchemataObjectStore; import io.vlingo.schemata.query.Queries; diff --git a/src/main/java/io/vlingo/schemata/model/ContextEntity.java b/src/main/java/io/vlingo/schemata/model/ContextEntity.java index 3d94cdf1..c03c9ba6 100644 --- a/src/main/java/io/vlingo/schemata/model/ContextEntity.java +++ b/src/main/java/io/vlingo/schemata/model/ContextEntity.java @@ -68,4 +68,10 @@ protected void stateObject(final ContextState stateObject) { protected Class stateObjectType() { return ContextState.class; } + + @Override + public void applyRelocationSnapshot(String snapshot) { + throw new UnsupportedOperationException("not implemented"); + } + } diff --git a/src/main/java/io/vlingo/schemata/model/OrganizationEntity.java b/src/main/java/io/vlingo/schemata/model/OrganizationEntity.java index fbf9d641..62707364 100644 --- a/src/main/java/io/vlingo/schemata/model/OrganizationEntity.java +++ b/src/main/java/io/vlingo/schemata/model/OrganizationEntity.java @@ -65,4 +65,10 @@ protected void stateObject(final OrganizationState stateObject) { protected Class stateObjectType() { return OrganizationState.class; } + + @Override + public void applyRelocationSnapshot(String snapshot) { + throw new UnsupportedOperationException("not implemented"); + } + } diff --git a/src/main/java/io/vlingo/schemata/model/SchemaEntity.java b/src/main/java/io/vlingo/schemata/model/SchemaEntity.java index 4ceb3609..00c9d647 100644 --- a/src/main/java/io/vlingo/schemata/model/SchemaEntity.java +++ b/src/main/java/io/vlingo/schemata/model/SchemaEntity.java @@ -79,4 +79,9 @@ protected void stateObject(final SchemaState stateObject) { protected Class stateObjectType() { return SchemaState.class; } + + @Override + public void applyRelocationSnapshot(String snapshot) { + throw new UnsupportedOperationException("not implemented"); + } } diff --git a/src/main/java/io/vlingo/schemata/model/SchemaVersionEntity.java b/src/main/java/io/vlingo/schemata/model/SchemaVersionEntity.java index 8e1b8339..b215ab01 100644 --- a/src/main/java/io/vlingo/schemata/model/SchemaVersionEntity.java +++ b/src/main/java/io/vlingo/schemata/model/SchemaVersionEntity.java @@ -218,4 +218,10 @@ private static TypeDefinition asTypeDefinition(Node n) { private static FieldDefinition asFieldDefinition(Node n) { return Processor.requireBeing(n, FieldDefinition.class); } + + @Override + public void applyRelocationSnapshot(String snapshot) { + throw new UnsupportedOperationException("not implemented"); + } + } diff --git a/src/main/java/io/vlingo/schemata/model/UnitEntity.java b/src/main/java/io/vlingo/schemata/model/UnitEntity.java index 1f29a2c7..cb7a69b1 100644 --- a/src/main/java/io/vlingo/schemata/model/UnitEntity.java +++ b/src/main/java/io/vlingo/schemata/model/UnitEntity.java @@ -61,4 +61,10 @@ protected void stateObject(final UnitState stateObject) { protected Class stateObjectType() { return UnitState.class; } + + @Override + public void applyRelocationSnapshot(String snapshot) { + throw new UnsupportedOperationException("not implemented"); + } + } diff --git a/src/test/java/io/vlingo/schemata/resource/ResourceTest.java b/src/test/java/io/vlingo/schemata/resource/ResourceTest.java index 114c07da..cb374f17 100644 --- a/src/test/java/io/vlingo/schemata/resource/ResourceTest.java +++ b/src/test/java/io/vlingo/schemata/resource/ResourceTest.java @@ -15,8 +15,8 @@ import io.vlingo.actors.Stage; import io.vlingo.actors.World; import io.vlingo.common.identity.IdentityGeneratorType; -import io.vlingo.lattice.grid.Grid; -import io.vlingo.lattice.grid.GridAddressFactory; +import io.vlingo.actors.Grid; +import io.vlingo.actors.GridAddressFactory; import io.vlingo.lattice.model.object.ObjectTypeRegistry; import io.vlingo.schemata.NoopDispatcher; import io.vlingo.schemata.Schemata; From c2a72e077e29b7505dcab8beaeadf0c5a99e58f2 Mon Sep 17 00:00:00 2001 From: Wolfgang Werner Date: Fri, 6 Mar 2020 16:34:58 +0100 Subject: [PATCH 2/3] Implement relocation snapshot application --- src/main/java/io/vlingo/schemata/model/ContextEntity.java | 2 +- src/main/java/io/vlingo/schemata/model/OrganizationEntity.java | 2 +- src/main/java/io/vlingo/schemata/model/SchemaEntity.java | 2 +- src/main/java/io/vlingo/schemata/model/SchemaVersionEntity.java | 2 +- src/main/java/io/vlingo/schemata/model/UnitEntity.java | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/io/vlingo/schemata/model/ContextEntity.java b/src/main/java/io/vlingo/schemata/model/ContextEntity.java index c03c9ba6..166a70fb 100644 --- a/src/main/java/io/vlingo/schemata/model/ContextEntity.java +++ b/src/main/java/io/vlingo/schemata/model/ContextEntity.java @@ -71,7 +71,7 @@ protected Class stateObjectType() { @Override public void applyRelocationSnapshot(String snapshot) { - throw new UnsupportedOperationException("not implemented"); + stateObject(ContextState.from(ContextId.existing(snapshot))); } } diff --git a/src/main/java/io/vlingo/schemata/model/OrganizationEntity.java b/src/main/java/io/vlingo/schemata/model/OrganizationEntity.java index 62707364..5a6ddd71 100644 --- a/src/main/java/io/vlingo/schemata/model/OrganizationEntity.java +++ b/src/main/java/io/vlingo/schemata/model/OrganizationEntity.java @@ -68,7 +68,7 @@ protected Class stateObjectType() { @Override public void applyRelocationSnapshot(String snapshot) { - throw new UnsupportedOperationException("not implemented"); + stateObject(OrganizationState.from(OrganizationId.existing(snapshot))); } } diff --git a/src/main/java/io/vlingo/schemata/model/SchemaEntity.java b/src/main/java/io/vlingo/schemata/model/SchemaEntity.java index 00c9d647..4ec23505 100644 --- a/src/main/java/io/vlingo/schemata/model/SchemaEntity.java +++ b/src/main/java/io/vlingo/schemata/model/SchemaEntity.java @@ -82,6 +82,6 @@ protected Class stateObjectType() { @Override public void applyRelocationSnapshot(String snapshot) { - throw new UnsupportedOperationException("not implemented"); + stateObject(SchemaState.from(SchemaId.existing(snapshot))); } } diff --git a/src/main/java/io/vlingo/schemata/model/SchemaVersionEntity.java b/src/main/java/io/vlingo/schemata/model/SchemaVersionEntity.java index b215ab01..d3fe4abe 100644 --- a/src/main/java/io/vlingo/schemata/model/SchemaVersionEntity.java +++ b/src/main/java/io/vlingo/schemata/model/SchemaVersionEntity.java @@ -221,7 +221,7 @@ private static FieldDefinition asFieldDefinition(Node n) { @Override public void applyRelocationSnapshot(String snapshot) { - throw new UnsupportedOperationException("not implemented"); + stateObject(SchemaVersionState.from(SchemaVersionId.existing(snapshot))); } } diff --git a/src/main/java/io/vlingo/schemata/model/UnitEntity.java b/src/main/java/io/vlingo/schemata/model/UnitEntity.java index cb7a69b1..6d6dfd9b 100644 --- a/src/main/java/io/vlingo/schemata/model/UnitEntity.java +++ b/src/main/java/io/vlingo/schemata/model/UnitEntity.java @@ -64,7 +64,7 @@ protected Class stateObjectType() { @Override public void applyRelocationSnapshot(String snapshot) { - throw new UnsupportedOperationException("not implemented"); + stateObject(UnitState.from(UnitId.existing(snapshot))); } } From 26d2b0a0650d677fd2cf1e36c176e9bebd6c682b Mon Sep 17 00:00:00 2001 From: Wolfgang Werner Date: Fri, 6 Mar 2020 16:37:43 +0100 Subject: [PATCH 3/3] Don't run on an actual Grid, simply use a stage for now To start the grid, we need to provide the grid config for tests and runtime first --- src/main/java/io/vlingo/schemata/Bootstrap.java | 3 ++- .../java/io/vlingo/schemata/resource/ResourceTest.java | 9 ++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/java/io/vlingo/schemata/Bootstrap.java b/src/main/java/io/vlingo/schemata/Bootstrap.java index dd0eedfc..2d7dfc73 100644 --- a/src/main/java/io/vlingo/schemata/Bootstrap.java +++ b/src/main/java/io/vlingo/schemata/Bootstrap.java @@ -39,7 +39,8 @@ public Bootstrap(final String runtimeType) throws Exception { SchemataConfig config = SchemataConfig.forRuntime(runtimeType); world = World.startWithDefaults("vlingo-schemata"); - world.stageNamed(StageName, Grid.class, new GridAddressFactory(IdentityGeneratorType.RANDOM)); + // TODO: Start an actual Grid here using Grid.start(...). Needs a complete grid configuration first + world.stageNamed(StageName, Stage.class, new GridAddressFactory(IdentityGeneratorType.RANDOM)); final NoopDispatcher dispatcher = new NoopDispatcher<>(); diff --git a/src/test/java/io/vlingo/schemata/resource/ResourceTest.java b/src/test/java/io/vlingo/schemata/resource/ResourceTest.java index cb374f17..bd227830 100644 --- a/src/test/java/io/vlingo/schemata/resource/ResourceTest.java +++ b/src/test/java/io/vlingo/schemata/resource/ResourceTest.java @@ -7,16 +7,13 @@ package io.vlingo.schemata.resource; +import io.vlingo.actors.*; import io.vlingo.http.Response; import io.vlingo.http.ResponseHeader; import io.vlingo.schemata.SchemataConfig; import org.junit.Before; -import io.vlingo.actors.Stage; -import io.vlingo.actors.World; import io.vlingo.common.identity.IdentityGeneratorType; -import io.vlingo.actors.Grid; -import io.vlingo.actors.GridAddressFactory; import io.vlingo.lattice.model.object.ObjectTypeRegistry; import io.vlingo.schemata.NoopDispatcher; import io.vlingo.schemata.Schemata; @@ -37,6 +34,7 @@ public abstract class ResourceTest { protected ObjectStore objectStore; protected ObjectTypeRegistry registry; protected Stage stage; + protected Grid grid; protected World world; protected OrganizationQueries organizationQueries; @@ -50,7 +48,8 @@ public abstract class ResourceTest { @SuppressWarnings({ "unchecked", "rawtypes" }) public void setUp() throws Exception { world = World.startWithDefaults("test-command-router"); - world.stageNamed(Schemata.StageName, Grid.class, new GridAddressFactory(IdentityGeneratorType.RANDOM)); + // TODO: Start an actual Grid here using Grid.start(...). Needs a test grid configuration first + world.stageNamed(Schemata.StageName, Stage.class, new GridAddressFactory(IdentityGeneratorType.RANDOM)); stage = world.stageNamed(Schemata.StageName); final SchemataObjectStore schemataObjectStore = SchemataObjectStore.instance(SchemataConfig.forRuntime("test"));