You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@usergrid.apache.org by sn...@apache.org on 2014/02/17 17:20:42 UTC
git commit: Renamed "clear" to "mark" since this is the operation
we're actually performing
Repository: incubator-usergrid
Updated Branches:
refs/heads/two-dot-o 82b342373 -> d9e0bf78f
Renamed "clear" to "mark" since this is the operation we're actually performing
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/d9e0bf78
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/d9e0bf78
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/d9e0bf78
Branch: refs/heads/two-dot-o
Commit: d9e0bf78f0fc97caac10589557292b198ebcd310
Parents: 82b3423
Author: Todd Nine <tn...@apigee.com>
Authored: Mon Feb 17 09:10:04 2014 -0700
Committer: Todd Nine <tn...@apigee.com>
Committed: Mon Feb 17 09:10:04 2014 -0700
----------------------------------------------------------------------
.../collection/EntityCollectionManager.java | 2 +-
.../collection/EntityCollectionManagerSync.java | 2 +-
.../impl/EntityCollectionManagerImpl.java | 18 +--
.../mvcc/MvccEntitySerializationStrategy.java | 6 +-
.../mvcc/MvccLogEntrySerializationStrategy.java | 2 +-
.../mvcc/stage/delete/DeleteCommit.java | 113 -----------------
.../mvcc/stage/delete/DeleteStart.java | 114 -----------------
.../mvcc/stage/delete/MarkCommit.java | 113 +++++++++++++++++
.../collection/mvcc/stage/delete/MarkStart.java | 112 +++++++++++++++++
.../MvccEntitySerializationStrategyImpl.java | 2 +-
.../mvcc/stage/delete/DeleteCommitTest.java | 125 -------------------
.../mvcc/stage/delete/DeleteStartTest.java | 97 --------------
.../mvcc/stage/delete/MarkCommitTest.java | 125 +++++++++++++++++++
.../mvcc/stage/delete/MarkStartTest.java | 97 ++++++++++++++
...MvccEntitySerializationStrategyImplTest.java | 9 +-
.../graph/impl/CollectionIndexObserver.java | 2 +-
.../serialization/util/EdgeHasherTest.java | 2 +-
17 files changed, 469 insertions(+), 472 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/d9e0bf78/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/EntityCollectionManager.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/EntityCollectionManager.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/EntityCollectionManager.java
index 3322164..d91a9b3 100644
--- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/EntityCollectionManager.java
+++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/EntityCollectionManager.java
@@ -42,7 +42,7 @@ public interface EntityCollectionManager {
/**
- * DeleteCommit the entity and remove it's indexes with the given entity id
+ * MarkCommit the entity and remove it's indexes with the given entity id
*/
public Observable<Void> delete( Id entityId );
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/d9e0bf78/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/EntityCollectionManagerSync.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/EntityCollectionManagerSync.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/EntityCollectionManagerSync.java
index 34181e9..cf89fb8 100644
--- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/EntityCollectionManagerSync.java
+++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/EntityCollectionManagerSync.java
@@ -38,7 +38,7 @@ public interface EntityCollectionManagerSync {
/**
- * DeleteCommit the entity and remove it's indexes with the given entity id
+ * MarkCommit the entity and remove it's indexes with the given entity id
*/
public void delete( Id entityId );
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/d9e0bf78/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/impl/EntityCollectionManagerImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/impl/EntityCollectionManagerImpl.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/impl/EntityCollectionManagerImpl.java
index b5b4cd4..4391d09 100644
--- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/impl/EntityCollectionManagerImpl.java
+++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/impl/EntityCollectionManagerImpl.java
@@ -29,8 +29,8 @@ import org.apache.usergrid.persistence.collection.EntityCollectionManager;
import org.apache.usergrid.persistence.collection.mvcc.entity.MvccEntity;
import org.apache.usergrid.persistence.collection.mvcc.entity.ValidationUtils;
import org.apache.usergrid.persistence.collection.mvcc.stage.CollectionIoEvent;
-import org.apache.usergrid.persistence.collection.mvcc.stage.delete.DeleteCommit;
-import org.apache.usergrid.persistence.collection.mvcc.stage.delete.DeleteStart;
+import org.apache.usergrid.persistence.collection.mvcc.stage.delete.MarkCommit;
+import org.apache.usergrid.persistence.collection.mvcc.stage.delete.MarkStart;
import org.apache.usergrid.persistence.collection.mvcc.stage.load.Load;
import org.apache.usergrid.persistence.collection.mvcc.stage.write.WriteCommit;
import org.apache.usergrid.persistence.collection.mvcc.stage.write.WriteOptimisticVerify;
@@ -79,8 +79,8 @@ public class EntityCollectionManagerImpl implements EntityCollectionManager {
//delete stages
- private final DeleteStart deleteStart;
- private final DeleteCommit deleteCommit;
+ private final MarkStart markStart;
+ private final MarkCommit markCommit;
@Inject
@@ -92,8 +92,8 @@ public class EntityCollectionManagerImpl implements EntityCollectionManager {
final WriteOptimisticVerify writeOptimisticVerify,
final WriteCommit writeCommit,
final Load load,
- final DeleteStart deleteStart,
- final DeleteCommit deleteCommit,
+ final MarkStart markStart,
+ final MarkCommit markCommit,
@Assisted final CollectionScope collectionScope ) {
Preconditions.checkNotNull( uuidService, "uuidService must be defined" );
@@ -104,8 +104,8 @@ public class EntityCollectionManagerImpl implements EntityCollectionManager {
this.writeOptimisticVerify = writeOptimisticVerify;
this.writeCommit = writeCommit;
this.load = load;
- this.deleteStart = deleteStart;
- this.deleteCommit = deleteCommit;
+ this.markStart = markStart;
+ this.markCommit = markCommit;
this.uuidService = uuidService;
this.scheduler = scheduler;
@@ -209,7 +209,7 @@ public class EntityCollectionManagerImpl implements EntityCollectionManager {
Preconditions.checkNotNull( entityId.getType(), "Entity type is required in this stage" );
return Observable.from( new CollectionIoEvent<Id>( collectionScope, entityId ) )
- .subscribeOn( scheduler ).map( deleteStart ).map( deleteCommit );
+ .subscribeOn( scheduler ).map( markStart ).map( markCommit );
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/d9e0bf78/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/MvccEntitySerializationStrategy.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/MvccEntitySerializationStrategy.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/MvccEntitySerializationStrategy.java
index c7fba3b..3bd2021 100644
--- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/MvccEntitySerializationStrategy.java
+++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/MvccEntitySerializationStrategy.java
@@ -71,15 +71,15 @@ public interface MvccEntitySerializationStrategy {
/**
- * DeleteCommit this version from the persistence store, but keep the version to mark that is has been cleared This
+ * Mark this this version as deleted from the persistence store, but keep the version to mark that is has been cleared This
* can be used in a mark+sweep system. The entity with the given version will exist in the context, but no data
* will be stored
*/
- public MutationBatch clear( CollectionScope context, Id entityId, UUID version );
+ public MutationBatch mark( CollectionScope context, Id entityId, UUID version );
/**
- * DeleteCommit the entity from the context with the given entityId and version
+ * Delete the entity from the context with the given entityId and version
*
* @param context The context that contains the entity
* @param entityId The entity id to delete
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/d9e0bf78/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/MvccLogEntrySerializationStrategy.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/MvccLogEntrySerializationStrategy.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/MvccLogEntrySerializationStrategy.java
index a7c9d64..2d218c1 100644
--- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/MvccLogEntrySerializationStrategy.java
+++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/MvccLogEntrySerializationStrategy.java
@@ -70,7 +70,7 @@ public interface MvccLogEntrySerializationStrategy {
throws ConnectionException;
/**
- * DeleteCommit the stage from the context with the given entityId and version
+ * MarkCommit the stage from the context with the given entityId and version
*
* @param context The context that contains the entity
* @param entityId The entity id to delete
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/d9e0bf78/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/delete/DeleteCommit.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/delete/DeleteCommit.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/delete/DeleteCommit.java
deleted file mode 100644
index 2cf393b..0000000
--- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/delete/DeleteCommit.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.usergrid.persistence.collection.mvcc.stage.delete;
-
-
-import java.util.UUID;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import org.apache.usergrid.persistence.collection.CollectionScope;
-import org.apache.usergrid.persistence.collection.exception.CollectionRuntimeException;
-import org.apache.usergrid.persistence.collection.mvcc.MvccEntitySerializationStrategy;
-import org.apache.usergrid.persistence.collection.mvcc.MvccLogEntrySerializationStrategy;
-import org.apache.usergrid.persistence.collection.mvcc.entity.MvccEntity;
-import org.apache.usergrid.persistence.collection.mvcc.entity.MvccLogEntry;
-import org.apache.usergrid.persistence.collection.mvcc.entity.ValidationUtils;
-import org.apache.usergrid.persistence.collection.mvcc.entity.impl.MvccLogEntryImpl;
-import org.apache.usergrid.persistence.collection.mvcc.stage.CollectionIoEvent;
-import org.apache.usergrid.persistence.model.entity.Id;
-
-import com.google.common.base.Preconditions;
-import com.google.inject.Inject;
-import com.google.inject.Singleton;
-import com.netflix.astyanax.MutationBatch;
-import com.netflix.astyanax.connectionpool.exceptions.ConnectionException;
-
-import rx.util.functions.Func1;
-
-
-/**
- * This phase should invoke any finalization, and mark the entity
- * as committed in the data store before returning
- */
-@Singleton
-public class DeleteCommit implements Func1<CollectionIoEvent<MvccEntity>, Void> {
-
- private static final Logger LOG = LoggerFactory.getLogger( DeleteCommit.class );
-
- private final MvccLogEntrySerializationStrategy logStrat;
- private final MvccEntitySerializationStrategy entityStrat;
-
- @Inject
- public DeleteCommit( final MvccLogEntrySerializationStrategy logStrat,
- final MvccEntitySerializationStrategy entityStrat ) {
-
- Preconditions.checkNotNull(
- logStrat, "logEntrySerializationStrategy is required" );
- Preconditions.checkNotNull(
- entityStrat, "entitySerializationStrategy is required" );
-
- this.logStrat = logStrat;
- this.entityStrat = entityStrat;
- }
-
-
- @Override
- public Void call( final CollectionIoEvent<MvccEntity> idIoEvent ) {
-
- final MvccEntity entity = idIoEvent.getEvent();
-
- ValidationUtils.verifyMvccEntityOptionalEntity( entity );
-
- final Id entityId = entity.getId();
- final UUID version = entity.getVersion();
-
-
- final CollectionScope collectionScope = idIoEvent.getEntityCollection();
-
-
- final MvccLogEntry startEntry = new MvccLogEntryImpl( entityId, version,
- org.apache.usergrid.persistence.collection.mvcc.entity.Stage.COMMITTED );
-
- MutationBatch logMutation = logStrat.write( collectionScope, startEntry );
-
- //insert a "cleared" value into the versions. Post processing should actually delete
- MutationBatch entityMutation = entityStrat.clear( collectionScope, entityId, version );
-
- //merge the 2 into 1 mutation
- logMutation.mergeShallow( entityMutation );
-
-
- try {
- logMutation.execute();
- }
- catch ( ConnectionException e ) {
- LOG.error( "Failed to execute write asynchronously ", e );
- throw new CollectionRuntimeException( "Failed to execute write asynchronously ", e );
- }
-
- /**
- * We're done executing.
- */
-
- return null;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/d9e0bf78/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/delete/DeleteStart.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/delete/DeleteStart.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/delete/DeleteStart.java
deleted file mode 100644
index d0f344f..0000000
--- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/delete/DeleteStart.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.usergrid.persistence.collection.mvcc.stage.delete;
-
-
-import java.util.UUID;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import org.apache.usergrid.persistence.collection.CollectionScope;
-import org.apache.usergrid.persistence.collection.exception.CollectionRuntimeException;
-import org.apache.usergrid.persistence.collection.mvcc.MvccLogEntrySerializationStrategy;
-import org.apache.usergrid.persistence.collection.mvcc.entity.MvccEntity;
-import org.apache.usergrid.persistence.collection.mvcc.entity.MvccLogEntry;
-import org.apache.usergrid.persistence.collection.mvcc.entity.Stage;
-import org.apache.usergrid.persistence.collection.mvcc.entity.ValidationUtils;
-import org.apache.usergrid.persistence.collection.mvcc.entity.impl.MvccEntityImpl;
-import org.apache.usergrid.persistence.collection.mvcc.entity.impl.MvccLogEntryImpl;
-import org.apache.usergrid.persistence.collection.mvcc.stage.CollectionIoEvent;
-import org.apache.usergrid.persistence.collection.service.UUIDService;
-import org.apache.usergrid.persistence.model.entity.Entity;
-import org.apache.usergrid.persistence.model.entity.Id;
-
-import com.google.common.base.Optional;
-import com.google.common.base.Preconditions;
-import com.google.inject.Inject;
-import com.google.inject.Singleton;
-import com.netflix.astyanax.MutationBatch;
-import com.netflix.astyanax.connectionpool.exceptions.ConnectionException;
-
-import rx.util.functions.Func1;
-
-
-/**
- * This is the first stage and should be invoked immediately when a write is started.
- * It should persist the start of a new write in the data store for
- * a checkpoint and recovery
- */
-@Singleton
-public class DeleteStart implements Func1<CollectionIoEvent<Id>, CollectionIoEvent<MvccEntity>> {
-
- private static final Logger LOG = LoggerFactory.getLogger( DeleteStart.class );
-
-
- private final MvccLogEntrySerializationStrategy logStrategy;
- private final UUIDService uuidService;
-
-
- /**
- * Create a new stage with the current context
- */
- @Inject
- public DeleteStart(
- final MvccLogEntrySerializationStrategy logStrategy,
- final UUIDService uuidService ) {
-
- Preconditions.checkNotNull( logStrategy, "logStrategy is required" );
- Preconditions.checkNotNull( uuidService, "uuidService is required" );
-
- this.logStrategy = logStrategy;
- this.uuidService = uuidService;
- }
-
-
- @Override
- public CollectionIoEvent<MvccEntity> call( final CollectionIoEvent<Id> entityIoEvent ) {
- final Id entityId = entityIoEvent.getEvent();
-
- ValidationUtils.verifyIdentity( entityId );
-
- final UUID version = uuidService.newTimeUUID();
-
-
- final CollectionScope collectionScope = entityIoEvent.getEntityCollection();
-
-
- final MvccLogEntry startEntry = new MvccLogEntryImpl( entityId, version, Stage.ACTIVE );
-
- MutationBatch write = logStrategy.write( collectionScope, startEntry );
-
-
- try {
- write.execute();
- }
- catch ( ConnectionException e ) {
- LOG.error( "Failed to execute write asynchronously ", e );
- throw new CollectionRuntimeException( "Failed to execute write asynchronously ", e );
- }
-
-
- //create the mvcc entity for the next stage
- final MvccEntityImpl nextStage = new MvccEntityImpl(entityId, version, MvccEntity.Status.COMPLETE, Optional.<Entity>absent() );
-
-
- return new CollectionIoEvent<MvccEntity>( collectionScope, nextStage );
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/d9e0bf78/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/delete/MarkCommit.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/delete/MarkCommit.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/delete/MarkCommit.java
new file mode 100644
index 0000000..9c1a432
--- /dev/null
+++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/delete/MarkCommit.java
@@ -0,0 +1,113 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.usergrid.persistence.collection.mvcc.stage.delete;
+
+
+import java.util.UUID;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.usergrid.persistence.collection.CollectionScope;
+import org.apache.usergrid.persistence.collection.exception.CollectionRuntimeException;
+import org.apache.usergrid.persistence.collection.mvcc.MvccEntitySerializationStrategy;
+import org.apache.usergrid.persistence.collection.mvcc.MvccLogEntrySerializationStrategy;
+import org.apache.usergrid.persistence.collection.mvcc.entity.MvccEntity;
+import org.apache.usergrid.persistence.collection.mvcc.entity.MvccLogEntry;
+import org.apache.usergrid.persistence.collection.mvcc.entity.ValidationUtils;
+import org.apache.usergrid.persistence.collection.mvcc.entity.impl.MvccLogEntryImpl;
+import org.apache.usergrid.persistence.collection.mvcc.stage.CollectionIoEvent;
+import org.apache.usergrid.persistence.model.entity.Id;
+
+import com.google.common.base.Preconditions;
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+import com.netflix.astyanax.MutationBatch;
+import com.netflix.astyanax.connectionpool.exceptions.ConnectionException;
+
+import rx.util.functions.Func1;
+
+
+/**
+ * This phase should invoke any finalization, and mark the entity
+ * as committed in the data store before returning
+ */
+@Singleton
+public class MarkCommit implements Func1<CollectionIoEvent<MvccEntity>, Void> {
+
+ private static final Logger LOG = LoggerFactory.getLogger( MarkCommit.class );
+
+ private final MvccLogEntrySerializationStrategy logStrat;
+ private final MvccEntitySerializationStrategy entityStrat;
+
+ @Inject
+ public MarkCommit( final MvccLogEntrySerializationStrategy logStrat,
+ final MvccEntitySerializationStrategy entityStrat ) {
+
+ Preconditions.checkNotNull(
+ logStrat, "logEntrySerializationStrategy is required" );
+ Preconditions.checkNotNull(
+ entityStrat, "entitySerializationStrategy is required" );
+
+ this.logStrat = logStrat;
+ this.entityStrat = entityStrat;
+ }
+
+
+ @Override
+ public Void call( final CollectionIoEvent<MvccEntity> idIoEvent ) {
+
+ final MvccEntity entity = idIoEvent.getEvent();
+
+ ValidationUtils.verifyMvccEntityOptionalEntity( entity );
+
+ final Id entityId = entity.getId();
+ final UUID version = entity.getVersion();
+
+
+ final CollectionScope collectionScope = idIoEvent.getEntityCollection();
+
+
+ final MvccLogEntry startEntry = new MvccLogEntryImpl( entityId, version,
+ org.apache.usergrid.persistence.collection.mvcc.entity.Stage.COMMITTED );
+
+ MutationBatch logMutation = logStrat.write( collectionScope, startEntry );
+
+ //insert a "cleared" value into the versions. Post processing should actually delete
+ MutationBatch entityMutation = entityStrat.mark( collectionScope, entityId, version );
+
+ //merge the 2 into 1 mutation
+ logMutation.mergeShallow( entityMutation );
+
+
+ try {
+ logMutation.execute();
+ }
+ catch ( ConnectionException e ) {
+ LOG.error( "Failed to execute write asynchronously ", e );
+ throw new CollectionRuntimeException( "Failed to execute write asynchronously ", e );
+ }
+
+ /**
+ * We're done executing.
+ */
+
+ return null;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/d9e0bf78/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/delete/MarkStart.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/delete/MarkStart.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/delete/MarkStart.java
new file mode 100644
index 0000000..4b0fae5
--- /dev/null
+++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/delete/MarkStart.java
@@ -0,0 +1,112 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.usergrid.persistence.collection.mvcc.stage.delete;
+
+
+import java.util.UUID;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.usergrid.persistence.collection.CollectionScope;
+import org.apache.usergrid.persistence.collection.exception.CollectionRuntimeException;
+import org.apache.usergrid.persistence.collection.mvcc.MvccLogEntrySerializationStrategy;
+import org.apache.usergrid.persistence.collection.mvcc.entity.MvccEntity;
+import org.apache.usergrid.persistence.collection.mvcc.entity.MvccLogEntry;
+import org.apache.usergrid.persistence.collection.mvcc.entity.Stage;
+import org.apache.usergrid.persistence.collection.mvcc.entity.ValidationUtils;
+import org.apache.usergrid.persistence.collection.mvcc.entity.impl.MvccEntityImpl;
+import org.apache.usergrid.persistence.collection.mvcc.entity.impl.MvccLogEntryImpl;
+import org.apache.usergrid.persistence.collection.mvcc.stage.CollectionIoEvent;
+import org.apache.usergrid.persistence.collection.service.UUIDService;
+import org.apache.usergrid.persistence.model.entity.Entity;
+import org.apache.usergrid.persistence.model.entity.Id;
+
+import com.google.common.base.Optional;
+import com.google.common.base.Preconditions;
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+import com.netflix.astyanax.MutationBatch;
+import com.netflix.astyanax.connectionpool.exceptions.ConnectionException;
+
+import rx.util.functions.Func1;
+
+
+/**
+ * This is the first stage and should be invoked immediately when a write is started.
+ * It should persist the start of a new write in the data store for
+ * a checkpoint and recovery
+ */
+@Singleton
+public class MarkStart implements Func1<CollectionIoEvent<Id>, CollectionIoEvent<MvccEntity>> {
+
+ private static final Logger LOG = LoggerFactory.getLogger( MarkStart.class );
+
+
+ private final MvccLogEntrySerializationStrategy logStrategy;
+ private final UUIDService uuidService;
+
+
+ /**
+ * Create a new stage with the current context
+ */
+ @Inject
+ public MarkStart( final MvccLogEntrySerializationStrategy logStrategy, final UUIDService uuidService ) {
+
+ Preconditions.checkNotNull( logStrategy, "logStrategy is required" );
+ Preconditions.checkNotNull( uuidService, "uuidService is required" );
+
+ this.logStrategy = logStrategy;
+ this.uuidService = uuidService;
+ }
+
+
+ @Override
+ public CollectionIoEvent<MvccEntity> call( final CollectionIoEvent<Id> entityIoEvent ) {
+ final Id entityId = entityIoEvent.getEvent();
+
+ ValidationUtils.verifyIdentity( entityId );
+
+ final UUID version = uuidService.newTimeUUID();
+
+
+ final CollectionScope collectionScope = entityIoEvent.getEntityCollection();
+
+
+ final MvccLogEntry startEntry = new MvccLogEntryImpl( entityId, version, Stage.ACTIVE );
+
+ MutationBatch write = logStrategy.write( collectionScope, startEntry );
+
+
+ try {
+ write.execute();
+ }
+ catch ( ConnectionException e ) {
+ LOG.error( "Failed to execute write asynchronously ", e );
+ throw new CollectionRuntimeException( "Failed to execute write asynchronously ", e );
+ }
+
+
+ //create the mvcc entity for the next stage
+ final MvccEntityImpl nextStage = new MvccEntityImpl(entityId, version, MvccEntity.Status.COMPLETE, Optional.<Entity>absent() );
+
+
+ return new CollectionIoEvent<MvccEntity>( collectionScope, nextStage );
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/d9e0bf78/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyImpl.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyImpl.java
index 82b673d..949b03e 100644
--- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyImpl.java
+++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyImpl.java
@@ -168,7 +168,7 @@ public class MvccEntitySerializationStrategyImpl implements MvccEntitySerializat
@Override
- public MutationBatch clear( final CollectionScope collectionScope, final Id entityId, final UUID version ) {
+ public MutationBatch mark( final CollectionScope collectionScope, final Id entityId, final UUID version ) {
Preconditions.checkNotNull( collectionScope, "collectionScope is required" );
Preconditions.checkNotNull( entityId, "entity id is required" );
Preconditions.checkNotNull( version, "version is required" );
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/d9e0bf78/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/delete/DeleteCommitTest.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/delete/DeleteCommitTest.java b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/delete/DeleteCommitTest.java
deleted file mode 100644
index c3c245c..0000000
--- a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/delete/DeleteCommitTest.java
+++ /dev/null
@@ -1,125 +0,0 @@
-package org.apache.usergrid.persistence.collection.mvcc.stage.delete;
-
-
-import org.junit.Test;
-import org.mockito.ArgumentCaptor;
-
-import org.apache.usergrid.persistence.collection.CollectionScope;
-import org.apache.usergrid.persistence.collection.mvcc.MvccEntitySerializationStrategy;
-import org.apache.usergrid.persistence.collection.mvcc.MvccLogEntrySerializationStrategy;
-import org.apache.usergrid.persistence.collection.mvcc.entity.MvccEntity;
-import org.apache.usergrid.persistence.collection.mvcc.entity.MvccLogEntry;
-import org.apache.usergrid.persistence.collection.mvcc.entity.Stage;
-import org.apache.usergrid.persistence.collection.mvcc.stage.AbstractMvccEntityStageTest;
-import org.apache.usergrid.persistence.collection.mvcc.stage.CollectionIoEvent;
-import org.apache.usergrid.persistence.collection.mvcc.stage.TestEntityGenerator;
-import org.apache.usergrid.persistence.collection.mvcc.stage.write.UniqueValueSerializationStrategy;
-import org.apache.usergrid.persistence.collection.mvcc.stage.write.WriteCommit;
-import org.apache.usergrid.persistence.model.entity.Entity;
-
-import com.netflix.astyanax.MutationBatch;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertSame;
-import static org.mockito.Matchers.any;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.same;
-import static org.mockito.Mockito.when;
-
-
-/** @author tnine */
-public class DeleteCommitTest extends AbstractMvccEntityStageTest {
-
- /** Standard flow */
- @Test
- public void testStartStage() throws Exception {
-
-
- final CollectionScope context = mock( CollectionScope.class );
-
-
- //mock returning a mock mutation when we do a log entry write
- final MvccLogEntrySerializationStrategy logStrategy = mock( MvccLogEntrySerializationStrategy.class );
-
- final ArgumentCaptor<MvccLogEntry> logEntry = ArgumentCaptor.forClass( MvccLogEntry.class );
-
- final MutationBatch logMutation = mock( MutationBatch.class );
-
- when( logStrategy.write( same( context ), logEntry.capture() ) ).thenReturn( logMutation );
-
-
- //mock up the serialization call for the entity and returning the mutation
- final MvccEntitySerializationStrategy mvccEntityStrategy = mock( MvccEntitySerializationStrategy.class );
-
- final UniqueValueSerializationStrategy uniqueValueStrategy = mock( UniqueValueSerializationStrategy.class );
-
- final ArgumentCaptor<MvccEntity> mvccEntityCapture = ArgumentCaptor.forClass( MvccEntity.class );
-
- final MutationBatch mvccEntityMutation = mock( MutationBatch.class );
-
- when( mvccEntityStrategy.write( same( context ), mvccEntityCapture.capture() ) )
- .thenReturn( mvccEntityMutation );
-
-
- //set up the mock to return the entity from the start phase
- final Entity entity = TestEntityGenerator.generateEntity();
-
-
- final MvccEntity mvccEntityInput = TestEntityGenerator.fromEntity( entity );
-
-
- //run the stage
- WriteCommit newStage = new WriteCommit( logStrategy, mvccEntityStrategy, uniqueValueStrategy );
-
-
- //verify the observable is correct
- Entity result = newStage.call( new CollectionIoEvent<MvccEntity>( context, mvccEntityInput ) );
-
-
-
-
- //verify the log entry is correct
- MvccLogEntry entry = logEntry.getValue();
-
- assertEquals( "id correct", entity.getId(), entry.getEntityId()) ;
- assertEquals( "version was not correct", entity.getVersion(), entry.getVersion() );
- assertEquals( "EventStage is correct", Stage.COMMITTED, entry.getStage() );
-
-
- MvccEntity written = mvccEntityCapture.getValue();
-
- //verify uuid and version in both the MvccEntity and the entity itself
- assertEquals( "version was correct", entity.getVersion(), written.getVersion() );
- assertSame( "Entity correct", entity, written.getEntity().get() );
- assertSame( "Entity Id is correct", entity.getId(), written.getId() );
-
- //now verify the output is correct
-
- assertSame( "Entity came from result", entity, result );
- }
-
-
- @Override
- protected void validateStage( final CollectionIoEvent<MvccEntity> event ) {
- /**
- * Write up mock mutations so we don't npe on the our operations, but rather on the input
- */
- final MvccLogEntrySerializationStrategy logStrategy = mock( MvccLogEntrySerializationStrategy.class );
- final MutationBatch logMutation = mock( MutationBatch.class );
-
- when( logStrategy.write( any( CollectionScope.class ), any( MvccLogEntry.class ) ) ).thenReturn( logMutation );
-
-
- final MvccEntitySerializationStrategy mvccEntityStrategy = mock( MvccEntitySerializationStrategy.class );
-
- final MutationBatch entityMutation = mock( MutationBatch.class );
-
- when( mvccEntityStrategy.write( any( CollectionScope.class ), any( MvccEntity.class ) ) )
- .thenReturn( entityMutation );
-
- new DeleteCommit( logStrategy, mvccEntityStrategy ).call( event );
- }
-
-}
-
-
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/d9e0bf78/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/delete/DeleteStartTest.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/delete/DeleteStartTest.java b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/delete/DeleteStartTest.java
deleted file mode 100644
index 1914f9a..0000000
--- a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/delete/DeleteStartTest.java
+++ /dev/null
@@ -1,97 +0,0 @@
-package org.apache.usergrid.persistence.collection.mvcc.stage.delete;
-
-
-import java.util.UUID;
-
-import org.junit.Test;
-import org.mockito.ArgumentCaptor;
-
-import org.apache.usergrid.persistence.collection.CollectionScope;
-import org.apache.usergrid.persistence.collection.mvcc.MvccLogEntrySerializationStrategy;
-import org.apache.usergrid.persistence.collection.mvcc.entity.MvccEntity;
-import org.apache.usergrid.persistence.collection.mvcc.entity.MvccLogEntry;
-import org.apache.usergrid.persistence.collection.mvcc.entity.Stage;
-import org.apache.usergrid.persistence.collection.mvcc.stage.AbstractIdStageTest;
-import org.apache.usergrid.persistence.collection.mvcc.stage.CollectionIoEvent;
-import org.apache.usergrid.persistence.collection.mvcc.stage.TestEntityGenerator;
-import org.apache.usergrid.persistence.collection.service.UUIDService;
-import org.apache.usergrid.persistence.model.entity.Id;
-import org.apache.usergrid.persistence.model.util.UUIDGenerator;
-
-import com.netflix.astyanax.MutationBatch;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertSame;
-import static org.mockito.Matchers.same;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-
-/** @author tnine */
-public class DeleteStartTest extends AbstractIdStageTest {
-
- @Test
- public void testWrite() {
-
- final CollectionScope context = mock( CollectionScope.class );
-
-
- //mock returning a mock mutation when we do a log entry write
- final MvccLogEntrySerializationStrategy logStrategy = mock( MvccLogEntrySerializationStrategy.class );
-
- final ArgumentCaptor<MvccLogEntry> logEntry = ArgumentCaptor.forClass( MvccLogEntry.class );
-
- final MutationBatch mutation = mock( MutationBatch.class );
-
- when( logStrategy.write( same( context ), logEntry.capture() ) ).thenReturn( mutation );
-
-
- //mock up the version
- final UUIDService uuidService = mock( UUIDService.class );
-
- final UUID version = UUIDGenerator.newTimeUUID();
-
- when( uuidService.newTimeUUID() ).thenReturn( version );
-
-
- //run the stage
- DeleteStart newStage = new DeleteStart( logStrategy, uuidService );
-
- final Id id = TestEntityGenerator.generateId();
-
-
- //verify the observable is correct
- CollectionIoEvent<MvccEntity> result = newStage.call( new CollectionIoEvent<Id>( context, id ) );
-
-
- //verify the log entry is correct
- MvccLogEntry entry = logEntry.getValue();
-
- assertEquals( "id correct", id, entry.getEntityId() );
- assertEquals( "version correct", version, entry.getVersion() );
- assertEquals( "EventStage is correct", Stage.ACTIVE, entry.getStage() );
-
-
- MvccEntity created = result.getEvent();
-
- //verify uuid and version in both the MvccEntity and the entity itself
- //verify uuid and version in both the MvccEntity and the entity itself
- //assertSame is used on purpose. We want to make sure the same instance is used, not a copy.
- //this way the caller's runtime type is retained.
- assertSame( "id correct", id, created.getId() );
- assertSame( "version did not not match entityId", version, created.getVersion() );
- assertFalse( "Entity correct", created.getEntity().isPresent() );
- }
-
-
- @Override
- protected void validateStage( final CollectionIoEvent<Id> event ) {
-
- MvccLogEntrySerializationStrategy logStrategy = mock( MvccLogEntrySerializationStrategy.class );
-
- UUIDService uuidService = mock( UUIDService.class );
-
- new DeleteStart( logStrategy, uuidService ).call( event );
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/d9e0bf78/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/delete/MarkCommitTest.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/delete/MarkCommitTest.java b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/delete/MarkCommitTest.java
new file mode 100644
index 0000000..7b4353c
--- /dev/null
+++ b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/delete/MarkCommitTest.java
@@ -0,0 +1,125 @@
+package org.apache.usergrid.persistence.collection.mvcc.stage.delete;
+
+
+import org.junit.Test;
+import org.mockito.ArgumentCaptor;
+
+import org.apache.usergrid.persistence.collection.CollectionScope;
+import org.apache.usergrid.persistence.collection.mvcc.MvccEntitySerializationStrategy;
+import org.apache.usergrid.persistence.collection.mvcc.MvccLogEntrySerializationStrategy;
+import org.apache.usergrid.persistence.collection.mvcc.entity.MvccEntity;
+import org.apache.usergrid.persistence.collection.mvcc.entity.MvccLogEntry;
+import org.apache.usergrid.persistence.collection.mvcc.entity.Stage;
+import org.apache.usergrid.persistence.collection.mvcc.stage.AbstractMvccEntityStageTest;
+import org.apache.usergrid.persistence.collection.mvcc.stage.CollectionIoEvent;
+import org.apache.usergrid.persistence.collection.mvcc.stage.TestEntityGenerator;
+import org.apache.usergrid.persistence.collection.mvcc.stage.write.UniqueValueSerializationStrategy;
+import org.apache.usergrid.persistence.collection.mvcc.stage.write.WriteCommit;
+import org.apache.usergrid.persistence.model.entity.Entity;
+
+import com.netflix.astyanax.MutationBatch;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertSame;
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.same;
+import static org.mockito.Mockito.when;
+
+
+/** @author tnine */
+public class MarkCommitTest extends AbstractMvccEntityStageTest {
+
+ /** Standard flow */
+ @Test
+ public void testStartStage() throws Exception {
+
+
+ final CollectionScope context = mock( CollectionScope.class );
+
+
+ //mock returning a mock mutation when we do a log entry write
+ final MvccLogEntrySerializationStrategy logStrategy = mock( MvccLogEntrySerializationStrategy.class );
+
+ final ArgumentCaptor<MvccLogEntry> logEntry = ArgumentCaptor.forClass( MvccLogEntry.class );
+
+ final MutationBatch logMutation = mock( MutationBatch.class );
+
+ when( logStrategy.write( same( context ), logEntry.capture() ) ).thenReturn( logMutation );
+
+
+ //mock up the serialization call for the entity and returning the mutation
+ final MvccEntitySerializationStrategy mvccEntityStrategy = mock( MvccEntitySerializationStrategy.class );
+
+ final UniqueValueSerializationStrategy uniqueValueStrategy = mock( UniqueValueSerializationStrategy.class );
+
+ final ArgumentCaptor<MvccEntity> mvccEntityCapture = ArgumentCaptor.forClass( MvccEntity.class );
+
+ final MutationBatch mvccEntityMutation = mock( MutationBatch.class );
+
+ when( mvccEntityStrategy.write( same( context ), mvccEntityCapture.capture() ) )
+ .thenReturn( mvccEntityMutation );
+
+
+ //set up the mock to return the entity from the start phase
+ final Entity entity = TestEntityGenerator.generateEntity();
+
+
+ final MvccEntity mvccEntityInput = TestEntityGenerator.fromEntity( entity );
+
+
+ //run the stage
+ WriteCommit newStage = new WriteCommit( logStrategy, mvccEntityStrategy, uniqueValueStrategy );
+
+
+ //verify the observable is correct
+ Entity result = newStage.call( new CollectionIoEvent<MvccEntity>( context, mvccEntityInput ) );
+
+
+
+
+ //verify the log entry is correct
+ MvccLogEntry entry = logEntry.getValue();
+
+ assertEquals( "id correct", entity.getId(), entry.getEntityId()) ;
+ assertEquals( "version was not correct", entity.getVersion(), entry.getVersion() );
+ assertEquals( "EventStage is correct", Stage.COMMITTED, entry.getStage() );
+
+
+ MvccEntity written = mvccEntityCapture.getValue();
+
+ //verify uuid and version in both the MvccEntity and the entity itself
+ assertEquals( "version was correct", entity.getVersion(), written.getVersion() );
+ assertSame( "Entity correct", entity, written.getEntity().get() );
+ assertSame( "Entity Id is correct", entity.getId(), written.getId() );
+
+ //now verify the output is correct
+
+ assertSame( "Entity came from result", entity, result );
+ }
+
+
+ @Override
+ protected void validateStage( final CollectionIoEvent<MvccEntity> event ) {
+ /**
+ * Write up mock mutations so we don't npe on the our operations, but rather on the input
+ */
+ final MvccLogEntrySerializationStrategy logStrategy = mock( MvccLogEntrySerializationStrategy.class );
+ final MutationBatch logMutation = mock( MutationBatch.class );
+
+ when( logStrategy.write( any( CollectionScope.class ), any( MvccLogEntry.class ) ) ).thenReturn( logMutation );
+
+
+ final MvccEntitySerializationStrategy mvccEntityStrategy = mock( MvccEntitySerializationStrategy.class );
+
+ final MutationBatch entityMutation = mock( MutationBatch.class );
+
+ when( mvccEntityStrategy.write( any( CollectionScope.class ), any( MvccEntity.class ) ) )
+ .thenReturn( entityMutation );
+
+ new MarkCommit( logStrategy, mvccEntityStrategy ).call( event );
+ }
+
+}
+
+
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/d9e0bf78/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/delete/MarkStartTest.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/delete/MarkStartTest.java b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/delete/MarkStartTest.java
new file mode 100644
index 0000000..ed870a3
--- /dev/null
+++ b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/delete/MarkStartTest.java
@@ -0,0 +1,97 @@
+package org.apache.usergrid.persistence.collection.mvcc.stage.delete;
+
+
+import java.util.UUID;
+
+import org.junit.Test;
+import org.mockito.ArgumentCaptor;
+
+import org.apache.usergrid.persistence.collection.CollectionScope;
+import org.apache.usergrid.persistence.collection.mvcc.MvccLogEntrySerializationStrategy;
+import org.apache.usergrid.persistence.collection.mvcc.entity.MvccEntity;
+import org.apache.usergrid.persistence.collection.mvcc.entity.MvccLogEntry;
+import org.apache.usergrid.persistence.collection.mvcc.entity.Stage;
+import org.apache.usergrid.persistence.collection.mvcc.stage.AbstractIdStageTest;
+import org.apache.usergrid.persistence.collection.mvcc.stage.CollectionIoEvent;
+import org.apache.usergrid.persistence.collection.mvcc.stage.TestEntityGenerator;
+import org.apache.usergrid.persistence.collection.service.UUIDService;
+import org.apache.usergrid.persistence.model.entity.Id;
+import org.apache.usergrid.persistence.model.util.UUIDGenerator;
+
+import com.netflix.astyanax.MutationBatch;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertSame;
+import static org.mockito.Matchers.same;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+
+/** @author tnine */
+public class MarkStartTest extends AbstractIdStageTest {
+
+ @Test
+ public void testWrite() {
+
+ final CollectionScope context = mock( CollectionScope.class );
+
+
+ //mock returning a mock mutation when we do a log entry write
+ final MvccLogEntrySerializationStrategy logStrategy = mock( MvccLogEntrySerializationStrategy.class );
+
+ final ArgumentCaptor<MvccLogEntry> logEntry = ArgumentCaptor.forClass( MvccLogEntry.class );
+
+ final MutationBatch mutation = mock( MutationBatch.class );
+
+ when( logStrategy.write( same( context ), logEntry.capture() ) ).thenReturn( mutation );
+
+
+ //mock up the version
+ final UUIDService uuidService = mock( UUIDService.class );
+
+ final UUID version = UUIDGenerator.newTimeUUID();
+
+ when( uuidService.newTimeUUID() ).thenReturn( version );
+
+
+ //run the stage
+ MarkStart newStage = new MarkStart( logStrategy, uuidService );
+
+ final Id id = TestEntityGenerator.generateId();
+
+
+ //verify the observable is correct
+ CollectionIoEvent<MvccEntity> result = newStage.call( new CollectionIoEvent<Id>( context, id ) );
+
+
+ //verify the log entry is correct
+ MvccLogEntry entry = logEntry.getValue();
+
+ assertEquals( "id correct", id, entry.getEntityId() );
+ assertEquals( "version correct", version, entry.getVersion() );
+ assertEquals( "EventStage is correct", Stage.ACTIVE, entry.getStage() );
+
+
+ MvccEntity created = result.getEvent();
+
+ //verify uuid and version in both the MvccEntity and the entity itself
+ //verify uuid and version in both the MvccEntity and the entity itself
+ //assertSame is used on purpose. We want to make sure the same instance is used, not a copy.
+ //this way the caller's runtime type is retained.
+ assertSame( "id correct", id, created.getId() );
+ assertSame( "version did not not match entityId", version, created.getVersion() );
+ assertFalse( "Entity correct", created.getEntity().isPresent() );
+ }
+
+
+ @Override
+ protected void validateStage( final CollectionIoEvent<Id> event ) {
+
+ MvccLogEntrySerializationStrategy logStrategy = mock( MvccLogEntrySerializationStrategy.class );
+
+ UUIDService uuidService = mock( UUIDService.class );
+
+ new MarkStart( logStrategy, uuidService ).call( event );
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/d9e0bf78/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyImplTest.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyImplTest.java b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyImplTest.java
index c4ccfd4..5375ead 100644
--- a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyImplTest.java
+++ b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyImplTest.java
@@ -29,7 +29,6 @@ import org.apache.usergrid.persistence.collection.impl.CollectionScopeImpl;
import org.apache.usergrid.persistence.collection.migration.MigrationManagerFig;
import org.apache.usergrid.persistence.collection.mvcc.MvccEntitySerializationStrategy;
import org.apache.usergrid.persistence.collection.mvcc.entity.MvccEntity;
-import org.apache.usergrid.persistence.collection.mvcc.entity.Stage;
import org.apache.usergrid.persistence.collection.mvcc.entity.impl.MvccEntityImpl;
import org.apache.usergrid.persistence.collection.serialization.SerializationFig;
import org.apache.usergrid.persistence.collection.util.EntityUtils;
@@ -256,9 +255,9 @@ public class MvccEntitySerializationStrategyImplTest {
assertEquals( entityId, returned.getEntity().get().getId() );
- //now clear it
+ //now mark it
- serializationStrategy.clear( context, entityId, version ).execute();
+ serializationStrategy.mark( context, entityId, version ).execute();
returned = serializationStrategy.load( context, entityId, version );
@@ -331,11 +330,11 @@ public class MvccEntitySerializationStrategyImplTest {
assertEquals( "Mvcc entities are the same", savedV2, returnedV2 );
- //now clear it at v3
+ //now mark it at v3
UUID version3 = UUIDGenerator.newTimeUUID();
- serializationStrategy.clear( context, id, version3 ).execute();
+ serializationStrategy.mark( context, id, version3 ).execute();
final Optional<Entity> empty = Optional.absent();
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/d9e0bf78/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/impl/CollectionIndexObserver.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/impl/CollectionIndexObserver.java b/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/impl/CollectionIndexObserver.java
index 648c029..b8b551a 100644
--- a/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/impl/CollectionIndexObserver.java
+++ b/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/impl/CollectionIndexObserver.java
@@ -70,7 +70,7 @@ public class CollectionIndexObserver implements PostProcessObserver {
if(entity.getEntity().isPresent()){
em.writeEdge( edge );
}
- //entity does not exist, it's been removed, clear the edge
+ //entity does not exist, it's been removed, mark the edge
else{
em.deleteEdge( edge );
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/d9e0bf78/stack/corepersistence/graph/src/test/java/org/apache/usergrid/persistence/graph/serialization/util/EdgeHasherTest.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/graph/src/test/java/org/apache/usergrid/persistence/graph/serialization/util/EdgeHasherTest.java b/stack/corepersistence/graph/src/test/java/org/apache/usergrid/persistence/graph/serialization/util/EdgeHasherTest.java
index c6ad1e6..c55138a 100644
--- a/stack/corepersistence/graph/src/test/java/org/apache/usergrid/persistence/graph/serialization/util/EdgeHasherTest.java
+++ b/stack/corepersistence/graph/src/test/java/org/apache/usergrid/persistence/graph/serialization/util/EdgeHasherTest.java
@@ -350,7 +350,7 @@ public class EdgeHasherTest {
assertEquals( "Check the sizes are equal", count, hashed.size() );
- //force a clear
+ //force a mark
hashed.clear();
}