diff --git a/src/main/java/io/vlingo/schemata/Bootstrap.java b/src/main/java/io/vlingo/schemata/Bootstrap.java index 0dfdfe91..2d7dfc73 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; @@ -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/main/java/io/vlingo/schemata/model/ContextEntity.java b/src/main/java/io/vlingo/schemata/model/ContextEntity.java index 3d94cdf1..166a70fb 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) { + 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 fbf9d641..5a6ddd71 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) { + 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 4ceb3609..4ec23505 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) { + 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 8e1b8339..d3fe4abe 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) { + 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 1f29a2c7..6d6dfd9b 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) { + stateObject(UnitState.from(UnitId.existing(snapshot))); + } + } diff --git a/src/test/java/io/vlingo/schemata/resource/ResourceTest.java b/src/test/java/io/vlingo/schemata/resource/ResourceTest.java index 114c07da..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.lattice.grid.Grid; -import io.vlingo.lattice.grid.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"));