You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@usergrid.apache.org by sf...@apache.org on 2014/10/08 18:34:13 UTC
git commit: delete current version
Repository: incubator-usergrid
Updated Branches:
refs/heads/two-dot-o-events a09bdda68 -> 9bd46b5a5
delete current version
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/9bd46b5a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/9bd46b5a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/9bd46b5a
Branch: refs/heads/two-dot-o-events
Commit: 9bd46b5a543c88b177f514587882c9e4836d7bb6
Parents: a09bdda
Author: Shawn Feldman <sf...@apache.org>
Authored: Wed Oct 8 10:34:00 2014 -0600
Committer: Shawn Feldman <sf...@apache.org>
Committed: Wed Oct 8 10:34:00 2014 -0600
----------------------------------------------------------------------
.../collection/event/EntityDeleted.java | 5 ++-
.../event/impl/EntityDeletedImpl.java | 33 +++++++++++++++++---
.../impl/EntityVersionCleanupTask.java | 19 ++++-------
3 files changed, 39 insertions(+), 18 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/9bd46b5a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/event/EntityDeleted.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/event/EntityDeleted.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/event/EntityDeleted.java
index f25042c..39b266d 100644
--- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/event/EntityDeleted.java
+++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/event/EntityDeleted.java
@@ -21,6 +21,8 @@ package org.apache.usergrid.persistence.collection.event;
import org.apache.usergrid.persistence.collection.CollectionScope;
import org.apache.usergrid.persistence.model.entity.Id;
+import java.util.UUID;
+
/**
*
@@ -36,7 +38,8 @@ public interface EntityDeleted {
*
* @param scope The scope of the entity
* @param entityId The id of the entity
+ * @param inclusiveVersionToDeleteFrom the entity version
*/
- public void deleted( final CollectionScope scope, final Id entityId);
+ public void deleted( final CollectionScope scope, final Id entityId, final UUID inclusiveVersionToDeleteFrom);
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/9bd46b5a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/event/impl/EntityDeletedImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/event/impl/EntityDeletedImpl.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/event/impl/EntityDeletedImpl.java
index a3be8ff..f2b398f 100644
--- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/event/impl/EntityDeletedImpl.java
+++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/event/impl/EntityDeletedImpl.java
@@ -17,21 +17,46 @@
*/
package org.apache.usergrid.persistence.collection.event.impl;
+import com.netflix.astyanax.MutationBatch;
+import com.netflix.astyanax.connectionpool.exceptions.ConnectionException;
import org.apache.usergrid.persistence.collection.CollectionScope;
import org.apache.usergrid.persistence.collection.event.EntityDeleted;
+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.model.entity.Id;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.net.ConnectException;
+import java.util.UUID;
public class EntityDeletedImpl implements EntityDeleted {
- public EntityDeletedImpl(){
+ private static final Logger LOG = LoggerFactory.getLogger(EntityDeletedImpl.class);
+
+ private MvccEntitySerializationStrategy mvccEntitySerializationStrategy;
+ private MvccLogEntrySerializationStrategy logEntrySerializationStrategy;
+ public EntityDeletedImpl(MvccEntitySerializationStrategy mvccEntitySerializationStrategy, MvccLogEntrySerializationStrategy logEntrySerializationStrategy){
+
+ this.mvccEntitySerializationStrategy = mvccEntitySerializationStrategy;
+ this.logEntrySerializationStrategy = logEntrySerializationStrategy;
}
@Override
- public void deleted(CollectionScope scope, Id entityId) {
+ public void deleted(CollectionScope scope, Id entityId, UUID inclusiveVersionToDeleteFrom) {
//TODO: clean up cass versions
- //TODO: de-index
- //TODO: delete all versions
+ MvccEntity mvccEntity = mvccEntitySerializationStrategy.load(scope,entityId,inclusiveVersionToDeleteFrom);
+ final MutationBatch entityDelete = mvccEntitySerializationStrategy.delete(scope, entityId, mvccEntity.getVersion());
+ final MutationBatch logDelete = logEntrySerializationStrategy.delete(scope, entityId, inclusiveVersionToDeleteFrom);
+ try {
+ entityDelete.execute();
+ logDelete.execute();
+ }catch (ConnectionException ce){
+ LOG.error("Error deleing from", ce);
+ }
+
}
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/9bd46b5a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/impl/EntityVersionCleanupTask.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/impl/EntityVersionCleanupTask.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/impl/EntityVersionCleanupTask.java
index 4965396..0d954c7 100644
--- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/impl/EntityVersionCleanupTask.java
+++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/impl/EntityVersionCleanupTask.java
@@ -125,10 +125,6 @@ public class EntityVersionCleanupTask implements Task<Void> {
@Override
public Void call() throws Exception {
-
-
- final UUID maxVersion = version;
-
//TODO Refactor this logic into a a class that can be invoked from anywhere
//load every entity we have history of
Observable<List<MvccEntity>> deleteFieldsObservable =
@@ -139,8 +135,8 @@ public class EntityVersionCleanupTask implements Task<Void> {
return entities;
}
}) //buffer them for efficiency
+ .skip(1)
.buffer(serializationFig.getBufferSize()).doOnNext(
-
new Action1<List<MvccEntity>>() {
@Override
public void call(final List<MvccEntity> mvccEntities) {
@@ -173,7 +169,7 @@ public class EntityVersionCleanupTask implements Task<Void> {
batch.mergeShallow(deleteMutation);
}
- final MutationBatch entityDelete = entitySerializationStrategy.delete(scope, entityId,mvccEntity.getVersion() );
+ final MutationBatch entityDelete = entitySerializationStrategy.delete(scope, entityId, mvccEntity.getVersion());
entityBatch.mergeShallow(entityDelete);
@@ -182,7 +178,6 @@ public class EntityVersionCleanupTask implements Task<Void> {
logBatch.mergeShallow(logDelete);
-
}
try {
@@ -195,16 +190,14 @@ public class EntityVersionCleanupTask implements Task<Void> {
fireEvents(mvccEntities);
try {
entityBatch.execute();
- }
- catch ( ConnectionException e ) {
- throw new RuntimeException( "Unable to delete entities in cleanup", e );
+ } catch (ConnectionException e) {
+ throw new RuntimeException("Unable to delete entities in cleanup", e);
}
try {
logBatch.execute();
- }
- catch ( ConnectionException e ) {
- throw new RuntimeException( "Unable to delete entities from the log", e );
+ } catch (ConnectionException e) {
+ throw new RuntimeException("Unable to delete entities from the log", e);
}
}