usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mru...@apache.org
Subject [30/33] usergrid git commit: Unique Value serialization table creation now via CQL instead of Astyanax/Thrift.
Date Wed, 11 May 2016 05:46:23 GMT
Unique Value serialization table creation now via CQL instead of Astyanax/Thrift.


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

Branch: refs/heads/datastax-cass-driver
Commit: 24b42856293470f87bba701e01359a2f56a0850a
Parents: 866d11b
Author: Michael Russo <mrusso@apigee.com>
Authored: Sun May 8 22:16:37 2016 +0800
Committer: Michael Russo <mrusso@apigee.com>
Committed: Sun May 8 22:16:37 2016 +0800

----------------------------------------------------------------------
 .../corepersistence/CpEntityManagerFactory.java |  6 ++---
 .../UniqueValueSerializationStrategyImpl.java   | 26 ++------------------
 .../UniqueValueSerializationStrategyV1Impl.java | 18 +++++++++++---
 .../UniqueValueSerializationStrategyV2Impl.java | 18 ++++++++++----
 .../persistence/core/datastax/CQLUtils.java     | 12 ++++++++-
 5 files changed, 43 insertions(+), 37 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/24b42856/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManagerFactory.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManagerFactory.java
b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManagerFactory.java
index c3bcaf6..91a936d 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManagerFactory.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManagerFactory.java
@@ -530,12 +530,12 @@ public class CpEntityManagerFactory implements EntityManagerFactory,
Application
         // Always make sure the database schema is initialized
         getSetup().initSchema();
 
-        // Make sure the management application is created
-        initMgmtAppInternal();
-
         // Roll the new 2.x Migration classes to the latest version supported
         getSetup().runDataMigration();
 
+        // Make sure the management application is created
+        initMgmtAppInternal();
+
         // Ensure management app is initialized
         getSetup().initMgmtApp();
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/24b42856/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/UniqueValueSerializationStrategyImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/UniqueValueSerializationStrategyImpl.java
b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/UniqueValueSerializationStrategyImpl.java
index e0a9035..fe4e06f 100644
--- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/UniqueValueSerializationStrategyImpl.java
+++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/UniqueValueSerializationStrategyImpl.java
@@ -361,32 +361,10 @@ public abstract class UniqueValueSerializationStrategyImpl<FieldKey,
EntityKey>
 
 
     @Override
-    public Collection<MultiTenantColumnFamilyDefinition> getColumnFamilies() {
-
-        final MultiTenantColumnFamilyDefinition uniqueLookupCF =
-            new MultiTenantColumnFamilyDefinition( CF_UNIQUE_VALUES, BytesType.class.getSimpleName(),
-                ColumnTypes.DYNAMIC_COMPOSITE_TYPE, BytesType.class.getSimpleName(),
-                MultiTenantColumnFamilyDefinition.CacheOption.KEYS );
-
-        final MultiTenantColumnFamilyDefinition uniqueLogCF =
-            new MultiTenantColumnFamilyDefinition( CF_ENTITY_UNIQUE_VALUE_LOG, BytesType.class.getSimpleName(),
-                ColumnTypes.DYNAMIC_COMPOSITE_TYPE, BytesType.class.getSimpleName(),
-                MultiTenantColumnFamilyDefinition.CacheOption.KEYS );
-
-        return Arrays.asList( uniqueLookupCF, uniqueLogCF );
-    }
+    public abstract Collection<MultiTenantColumnFamilyDefinition> getColumnFamilies();
 
     @Override
-    public Collection<TableDefinition> getTables() {
-
-        final TableDefinition uniqueValues = getUniqueValuesTable();
-
-        final TableDefinition uniqueValuesLog = getEntityUniqueLogTable();
-
-
-        return Arrays.asList( uniqueValues, uniqueValuesLog );
-
-    }
+    public abstract Collection<TableDefinition> getTables();
 
 
     /**

http://git-wip-us.apache.org/repos/asf/usergrid/blob/24b42856/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/UniqueValueSerializationStrategyV1Impl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/UniqueValueSerializationStrategyV1Impl.java
b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/UniqueValueSerializationStrategyV1Impl.java
index cbd8a3e..73df64a 100644
--- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/UniqueValueSerializationStrategyV1Impl.java
+++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/UniqueValueSerializationStrategyV1Impl.java
@@ -61,10 +61,10 @@ public class UniqueValueSerializationStrategyV1Impl  extends UniqueValueSerializ
     private static final Map<String, DataType.Name> UNIQUE_VALUES_COLUMNS =
         new HashMap<String, DataType.Name>() {{
             put( "key", DataType.Name.BLOB );
-            put( "column1", DataType.Name.BLOB );
+            put( "column1", DataType.Name.CUSTOM );
             put( "value", DataType.Name.BLOB ); }};
     private static final Map<String, String> UNIQUE_VALUES_CLUSTERING_ORDER =
-        new HashMap<String, String>(){{ put( "column1", "ASC" ); }};
+        new HashMap<String, String>(){{ put( "column1", "ASC" );}};
 
 
     private static final String UNIQUE_VALUES_LOG_TABLE = CQLUtils.quote("Entity_Unique_Values");
@@ -73,7 +73,7 @@ public class UniqueValueSerializationStrategyV1Impl  extends UniqueValueSerializ
     private static final Map<String, DataType.Name> UNIQUE_VALUES_LOG_COLUMNS =
         new HashMap<String, DataType.Name>() {{
             put( "key", DataType.Name.BLOB );
-            put( "column1", DataType.Name.BLOB );
+            put( "column1", DataType.Name.CUSTOM );
             put( "value", DataType.Name.BLOB ); }};
     private static final Map<String, String> UNIQUE_VALUES_LOG_CLUSTERING_ORDER =
         new HashMap<String, String>(){{ put( "column1", "ASC" ); }};
@@ -138,13 +138,23 @@ public class UniqueValueSerializationStrategyV1Impl  extends UniqueValueSerializ
                 ColumnTypes.DYNAMIC_COMPOSITE_TYPE, BytesType.class.getSimpleName(),
                 MultiTenantColumnFamilyDefinition.CacheOption.KEYS );
 
-        return Arrays.asList( uniqueLookupCF, uniqueLogCF );
+        //return Collections.emptyList();
+
+        return Arrays.asList(uniqueLookupCF, uniqueLogCF);
     }
 
     @Override
     public Collection<TableDefinition> getTables() {
 
+        final TableDefinition uniqueValues = getUniqueValuesTable();
+
+        final TableDefinition uniqueValuesLog = getEntityUniqueLogTable();
+
+
+        //return Arrays.asList( uniqueValues, uniqueValuesLog );
+
         return Collections.emptyList();
+
     }
 
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/24b42856/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/UniqueValueSerializationStrategyV2Impl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/UniqueValueSerializationStrategyV2Impl.java
b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/UniqueValueSerializationStrategyV2Impl.java
index 3e4932a..8e13f86 100644
--- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/UniqueValueSerializationStrategyV2Impl.java
+++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/UniqueValueSerializationStrategyV2Impl.java
@@ -58,10 +58,10 @@ public class UniqueValueSerializationStrategyV2Impl  extends UniqueValueSerializ
     private static final Map<String, DataType.Name> UNIQUE_VALUES_COLUMNS =
         new HashMap<String, DataType.Name>() {{
             put( "key", DataType.Name.BLOB );
-            put( "column1", DataType.Name.BLOB );
+            put( "column1", DataType.Name.CUSTOM );
             put( "value", DataType.Name.BLOB ); }};
     private static final Map<String, String> UNIQUE_VALUES_CLUSTERING_ORDER =
-        new HashMap<String, String>(){{ put( "column1", "ASC" ); }};
+        new HashMap<String, String>(){{ put( "column1", "ASC" );}};
 
 
     private static final String UNIQUE_VALUES_LOG_TABLE = CQLUtils.quote("Entity_Unique_Values_V2");
@@ -70,10 +70,10 @@ public class UniqueValueSerializationStrategyV2Impl  extends UniqueValueSerializ
     private static final Map<String, DataType.Name> UNIQUE_VALUES_LOG_COLUMNS =
         new HashMap<String, DataType.Name>() {{
             put( "key", DataType.Name.BLOB );
-            put( "column1", DataType.Name.BLOB );
+            put( "column1", DataType.Name.CUSTOM );
             put( "value", DataType.Name.BLOB ); }};
     private static final Map<String, String> UNIQUE_VALUES_LOG_CLUSTERING_ORDER =
-        new HashMap<String, String>(){{ put( "column1", "ASC" ); }};
+        new HashMap<String, String>(){{ put( "column1", "ASC" );}};
 
     private final static TableDefinition uniqueValues =
         new TableDefinition( UNIQUE_VALUES_TABLE, UNIQUE_VALUES_PARTITION_KEYS, UNIQUE_VALUES_COLUMN_KEYS,
@@ -134,15 +134,23 @@ public class UniqueValueSerializationStrategyV2Impl  extends UniqueValueSerializ
                 ColumnTypes.DYNAMIC_COMPOSITE_TYPE, BytesType.class.getSimpleName(),
                 MultiTenantColumnFamilyDefinition.CacheOption.KEYS );
 
-        return Arrays.asList( uniqueLookupCF, uniqueLogCF );
+        return Collections.emptyList();
+
+        //return Arrays.asList(uniqueLookupCF, uniqueLogCF);
     }
 
     @Override
     public Collection<TableDefinition> getTables() {
 
+        final TableDefinition uniqueValues = getUniqueValuesTable();
+
+        final TableDefinition uniqueValuesLog = getEntityUniqueLogTable();
+
 
         return Arrays.asList( uniqueValues, uniqueValuesLog );
 
+        //return Collections.emptyList();
+
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/usergrid/blob/24b42856/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/datastax/CQLUtils.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/datastax/CQLUtils.java
b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/datastax/CQLUtils.java
index f65a260..0d6a312 100644
--- a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/datastax/CQLUtils.java
+++ b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/datastax/CQLUtils.java
@@ -18,6 +18,7 @@
  */
 package org.apache.usergrid.persistence.core.datastax;
 
+import com.datastax.driver.core.DataType;
 import com.fasterxml.jackson.core.JsonProcessingException;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.google.inject.Inject;
@@ -52,6 +53,8 @@ public class CQLUtils {
     static String PAREN_LEFT = "(";
     static String PAREN_RIGHT = ")";
 
+    static String COMPOSITE_TYPE = "'org.apache.cassandra.db.marshal.DynamicCompositeType(a=>org.apache.cassandra.db.marshal.AsciiType,A=>org.apache.cassandra.db.marshal.ReversedType(org.apache.cassandra.db.marshal.AsciiType),b=>org.apache.cassandra.db.marshal.BytesType,B=>org.apache.cassandra.db.marshal.ReversedType(org.apache.cassandra.db.marshal.BytesType),i=>org.apache.cassandra.db.marshal.IntegerType,I=>org.apache.cassandra.db.marshal.ReversedType(org.apache.cassandra.db.marshal.IntegerType),l=>org.apache.cassandra.db.marshal.LongType,L=>org.apache.cassandra.db.marshal.ReversedType(org.apache.cassandra.db.marshal.LongType),s=>org.apache.cassandra.db.marshal.UTF8Type,S=>org.apache.cassandra.db.marshal.ReversedType(org.apache.cassandra.db.marshal.UTF8Type),t=>org.apache.cassandra.db.marshal.TimeUUIDType,T=>org.apache.cassandra.db.marshal.ReversedType(org.apache.cassandra.db.marshal.TimeUUIDType),u=>org.apache.cassandra.db.marshal.UUIDType,U=>org.apache.cassandra.db.marshal.Revers
 edType(org.apache.cassandra.db.marshal.UUIDType),x=>org.apache.cassandra.db.marshal.LexicalUUIDType,X=>org.apache.cassandra.db.marshal.ReversedType(org.apache.cassandra.db.marshal.LexicalUUIDType))'";
+
     @Inject
     public CQLUtils ( final CassandraFig cassandraFig ){
 
@@ -145,7 +148,14 @@ public class CQLUtils {
     public static String spaceSeparatedKeyValue(Map<String, ?> columns){
 
         StringJoiner columnsSchema = new StringJoiner(",");
-        columns.forEach( (key, value) -> columnsSchema.add(key+" "+String.valueOf(value)));
+        columns.forEach( (key, value) -> {
+
+            if( value == DataType.Name.CUSTOM ){
+                columnsSchema.add(key+" "+COMPOSITE_TYPE);
+            }else {
+                columnsSchema.add(key + " " + String.valueOf(value));
+            }
+        });
 
         return columnsSchema.toString();
 


Mime
View raw message