usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From snoopd...@apache.org
Subject [07/51] [abbrv] git commit: Use two methods instead of asking caller to pass null to indicate no TTL.
Date Mon, 20 Jan 2014 05:21:38 GMT
Use two methods instead of asking caller to pass null to indicate no TTL.


Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/f834a190
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/f834a190
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/f834a190

Branch: refs/pull/18/merge
Commit: f834a1908dfcc923e30ea37eb49f1f0d59003f6f
Parents: 075374b
Author: Dave Johnson <dmjohnson@apigee.com>
Authored: Mon Jan 13 15:05:05 2014 -0500
Committer: Dave Johnson <dmjohnson@apigee.com>
Committed: Mon Jan 13 15:05:05 2014 -0500

----------------------------------------------------------------------
 .../write/UniqueValueSerializationStrategy.java    | 10 +++++++++-
 .../UniqueValueSerializationStrategyImpl.java      | 17 +++++++++++++++--
 2 files changed, 24 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/f834a190/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/UniqueValueSerializationStrategy.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/UniqueValueSerializationStrategy.java
b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/UniqueValueSerializationStrategy.java
index 0169361..0a6b635 100644
--- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/UniqueValueSerializationStrategy.java
+++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/UniqueValueSerializationStrategy.java
@@ -31,7 +31,15 @@ public interface UniqueValueSerializationStrategy {
      * Write the specified UniqueValue to Cassandra with optional timeToLive in milliseconds.
      * 
      * @param uniqueValue Object to be written
-     * @param timeToLive How long object should live in seconds (or null to live forever)
+     * @return MutatationBatch that encapsulates operation, caller may or may not execute.
+     */
+    public MutationBatch write( UniqueValue uniqueValue );
+
+    /**
+     * Write the specified UniqueValue to Cassandra with optional timeToLive in milliseconds.
+     * 
+     * @param uniqueValue Object to be written
+     * @param timeToLive How long object should live in seconds 
      * @return MutatationBatch that encapsulates operation, caller may or may not execute.
      */
     public MutationBatch write( UniqueValue uniqueValue, Integer timeToLive );

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/f834a190/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/UniqueValueSerializationStrategyImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/UniqueValueSerializationStrategyImpl.java
b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/UniqueValueSerializationStrategyImpl.java
index 35c924f..8c2e9eb 100644
--- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/UniqueValueSerializationStrategyImpl.java
+++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/UniqueValueSerializationStrategyImpl.java
@@ -78,19 +78,32 @@ public class UniqueValueSerializationStrategyImpl implements UniqueValueSerializ
     } 
 
 
+    public MutationBatch write( UniqueValue uniqueValue ) {
+        return write( uniqueValue, Integer.MAX_VALUE );
+    }
+
+
     @Override
-    public MutationBatch write( UniqueValue value, final Integer timeToLive ) {
+    public MutationBatch write( UniqueValue value, Integer timeToLive ) {
 
         Preconditions.checkNotNull( value, "value is required" );
+        Preconditions.checkNotNull( timeToLive, "timeToLive is required" );
 
         final EntityVersion ev = new EntityVersion( value.getEntityId(), value.getEntityVersion()
);
 
+        final Integer ttl;
+        if ( timeToLive.equals( Integer.MAX_VALUE )) {
+            ttl = null;
+        } else {
+            ttl = timeToLive;
+        }
+
         return doWrite( value.getCollectionScope(), value.getField(), 
             new UniqueValueSerializationStrategyImpl.RowOp() {
 
             @Override
             public void doOp( final ColumnListMutation<EntityVersion> colMutation )
{
-                colMutation.putColumn( ev, 0x0, timeToLive );
+                colMutation.putColumn( ev, 0x0, ttl );
             }
         } );
     }


Mime
View raw message