polygene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nic...@apache.org
Subject [09/12] polygene-java git commit: Various improvements in Cassandra ES, from using it in an application.
Date Sun, 05 Mar 2017 15:45:39 GMT
Various improvements in Cassandra ES, from using it in an application.


Project: http://git-wip-us.apache.org/repos/asf/polygene-java/repo
Commit: http://git-wip-us.apache.org/repos/asf/polygene-java/commit/aeff80d3
Tree: http://git-wip-us.apache.org/repos/asf/polygene-java/tree/aeff80d3
Diff: http://git-wip-us.apache.org/repos/asf/polygene-java/diff/aeff80d3

Branch: refs/heads/develop
Commit: aeff80d3848dd8a91536dba1e91a634fa78204c2
Parents: 1648545
Author: niclas <niclas@spicter.com>
Authored: Sun Mar 5 13:39:40 2017 +0800
Committer: niclas <niclas@spicter.com>
Committed: Sun Mar 5 13:39:40 2017 +0800

----------------------------------------------------------------------
 .../entitystore/cassandra/CassandraCluster.java    | 17 ++++++++---------
 .../cassandra/CassandraEntityStoreMixin.java       | 12 ++++++------
 .../cassandra/CassandraEntityStoreService.java     |  3 +--
 .../assembly/CassandraEntityStoreAssembler.java    | 11 +++++------
 .../cassandra/CassandraMapEntityStoreTest.java     | 13 +++++--------
 5 files changed, 25 insertions(+), 31 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/polygene-java/blob/aeff80d3/extensions/entitystore-cassandra/src/main/java/org/apache/polygene/entitystore/cassandra/CassandraCluster.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-cassandra/src/main/java/org/apache/polygene/entitystore/cassandra/CassandraCluster.java
b/extensions/entitystore-cassandra/src/main/java/org/apache/polygene/entitystore/cassandra/CassandraCluster.java
index 6b5d4d4..c707652 100644
--- a/extensions/entitystore-cassandra/src/main/java/org/apache/polygene/entitystore/cassandra/CassandraCluster.java
+++ b/extensions/entitystore-cassandra/src/main/java/org/apache/polygene/entitystore/cassandra/CassandraCluster.java
@@ -25,7 +25,6 @@ import com.datastax.driver.core.KeyspaceMetadata;
 import com.datastax.driver.core.PreparedStatement;
 import com.datastax.driver.core.Session;
 import com.datastax.driver.core.exceptions.AlreadyExistsException;
-import java.util.Objects;
 import org.apache.polygene.api.common.Optional;
 import org.apache.polygene.api.configuration.Configuration;
 import org.apache.polygene.api.injection.scope.Service;
@@ -48,10 +47,10 @@ public interface CassandraCluster
     String MANYASSOCIATIONS_COLUMN = "manyassocs";
     String NAMEDASSOCIATIONS_COLUMN = "namedassocs";
 
-    Session session();
-
     String tableName();
 
+    Session cassandraClientSession();
+
     PreparedStatement entityRetrieveStatement();
 
     PreparedStatement versionRetrieveStatement();
@@ -87,12 +86,6 @@ public interface CassandraCluster
         private PreparedStatement getVersionStatement;
 
         @Override
-        public Session session()
-        {
-            return session;
-        }
-
-        @Override
         public PreparedStatement entityRetrieveStatement()
         {
             return getEntityStatement;
@@ -116,6 +109,12 @@ public interface CassandraCluster
             return keyspaceName;
         }
 
+        @Override
+        public Session cassandraClientSession()
+        {
+            return session;
+        }
+
         public String tableName()
         {
             CassandraEntityStoreConfiguration config = configuration.get();

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/aeff80d3/extensions/entitystore-cassandra/src/main/java/org/apache/polygene/entitystore/cassandra/CassandraEntityStoreMixin.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-cassandra/src/main/java/org/apache/polygene/entitystore/cassandra/CassandraEntityStoreMixin.java
b/extensions/entitystore-cassandra/src/main/java/org/apache/polygene/entitystore/cassandra/CassandraEntityStoreMixin.java
index ab3631d..234a76f 100644
--- a/extensions/entitystore-cassandra/src/main/java/org/apache/polygene/entitystore/cassandra/CassandraEntityStoreMixin.java
+++ b/extensions/entitystore-cassandra/src/main/java/org/apache/polygene/entitystore/cassandra/CassandraEntityStoreMixin.java
@@ -121,7 +121,7 @@ public class CassandraEntityStoreMixin
 
     private EntityState queryFor( BoundStatement statement, ModuleDescriptor module, EntityReference
reference )
     {
-        ResultSet result = cluster.session().execute( statement );
+        ResultSet result = cluster.cassandraClientSession().execute( statement );
         Row row = result.one();
         if( row == null )
         {
@@ -143,7 +143,7 @@ public class CassandraEntityStoreMixin
         {
             if( migration != null )
             {
-                migration.migrate( row, application.version(), cluster.session() );
+                migration.migrate( row, application.version(), cluster.cassandraClientSession()
);
                 // State may have changed
                 status[ 0 ] = EntityStatus.UPDATED;
             }
@@ -294,7 +294,7 @@ public class CassandraEntityStoreMixin
     @Override
     public String versionOf( EntityStoreUnitOfWork unitOfWork, EntityReference reference
)
     {
-        ResultSet result = cluster.session().execute( cluster.versionRetrieveStatement().bind(
reference.identity().toString() ) );
+        ResultSet result = cluster.cassandraClientSession().execute( cluster.versionRetrieveStatement().bind(
reference.identity().toString() ) );
         Row row = result.one();
         return row.getString( VERSION_COLUMN );
     }
@@ -348,7 +348,7 @@ public class CassandraEntityStoreMixin
                                 assocs,
                                 many,
                                 named );
-                            ResultSet result = cluster.session().execute( statement );
+                            ResultSet result = cluster.cassandraClientSession().execute(
statement );
                             System.out.println( result );
                         } );
                 String ids = stream( state.spliterator(), false )
@@ -357,7 +357,7 @@ public class CassandraEntityStoreMixin
                     .collect( Collectors.joining( "," ) );
                 if( !ids.isEmpty() )
                 {
-                    cluster.session().execute( "DELETE FROM " + cluster.tableName() + " WHERE
id IN (" + ids + ");" );
+                    cluster.cassandraClientSession().execute( "DELETE FROM " + cluster.tableName()
+ " WHERE id IN (" + ids + ");" );
                 }
             }
 
@@ -444,7 +444,7 @@ public class CassandraEntityStoreMixin
     @Override
     public Stream<EntityState> entityStates( ModuleDescriptor module )
     {
-        Session session = cluster.session();
+        Session session = cluster.cassandraClientSession();
         String tableName = cluster.tableName();
         ResultSet resultSet = session.execute( "SELECT "
                                                + IDENTITY_COLUMN + ", "

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/aeff80d3/extensions/entitystore-cassandra/src/main/java/org/apache/polygene/entitystore/cassandra/CassandraEntityStoreService.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-cassandra/src/main/java/org/apache/polygene/entitystore/cassandra/CassandraEntityStoreService.java
b/extensions/entitystore-cassandra/src/main/java/org/apache/polygene/entitystore/cassandra/CassandraEntityStoreService.java
index 051c29b..98d7298 100644
--- a/extensions/entitystore-cassandra/src/main/java/org/apache/polygene/entitystore/cassandra/CassandraEntityStoreService.java
+++ b/extensions/entitystore-cassandra/src/main/java/org/apache/polygene/entitystore/cassandra/CassandraEntityStoreService.java
@@ -29,8 +29,6 @@ import org.apache.polygene.spi.entitystore.ConcurrentModificationCheckConcern;
 import org.apache.polygene.spi.entitystore.EntityStateVersions;
 import org.apache.polygene.spi.entitystore.EntityStore;
 import org.apache.polygene.spi.entitystore.StateChangeNotificationConcern;
-import org.apache.polygene.spi.entitystore.helpers.JSONMapEntityStoreActivation;
-import org.apache.polygene.spi.entitystore.helpers.JSONMapEntityStoreMixin;
 
 /**
  * Cassandra EntityStore service.
@@ -48,4 +46,5 @@ public interface CassandraEntityStoreService
     String CURRENT_STORAGE_VERSION = "1";
     String DEFAULT_KEYSPACE_NAME = "polygene";
     String DEFAULT_TABLE_NAME = "entitystore";
+
 }

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/aeff80d3/extensions/entitystore-cassandra/src/main/java/org/apache/polygene/entitystore/cassandra/assembly/CassandraEntityStoreAssembler.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-cassandra/src/main/java/org/apache/polygene/entitystore/cassandra/assembly/CassandraEntityStoreAssembler.java
b/extensions/entitystore-cassandra/src/main/java/org/apache/polygene/entitystore/cassandra/assembly/CassandraEntityStoreAssembler.java
index 70b4525..2736dfd 100644
--- a/extensions/entitystore-cassandra/src/main/java/org/apache/polygene/entitystore/cassandra/assembly/CassandraEntityStoreAssembler.java
+++ b/extensions/entitystore-cassandra/src/main/java/org/apache/polygene/entitystore/cassandra/assembly/CassandraEntityStoreAssembler.java
@@ -22,7 +22,6 @@ package org.apache.polygene.entitystore.cassandra.assembly;
 import org.apache.polygene.bootstrap.Assemblers;
 import org.apache.polygene.bootstrap.AssemblyException;
 import org.apache.polygene.bootstrap.ModuleAssembly;
-import org.apache.polygene.bootstrap.ServiceDeclaration;
 import org.apache.polygene.entitystore.cassandra.CassandraEntityStoreConfiguration;
 import org.apache.polygene.entitystore.cassandra.CassandraEntityStoreService;
 
@@ -33,11 +32,11 @@ public class CassandraEntityStoreAssembler
     public void assemble( ModuleAssembly module )
         throws AssemblyException
     {
-        ServiceDeclaration service = module.services( CassandraEntityStoreService.class ).visibleIn(
visibility() );
-        if( hasIdentity() )
-        {
-            service.identifiedBy( identity() );
-        }
+        module.services( CassandraEntityStoreService.class )
+              .visibleIn( visibility() )
+              .identifiedBy( identity() )
+              .instantiateOnStartup();
+
         if( hasConfig() )
         {
             configModule().entities( CassandraEntityStoreConfiguration.class ).visibleIn(
configVisibility() );

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/aeff80d3/extensions/entitystore-cassandra/src/test/java/org/apache/polygene/entitystore/cassandra/CassandraMapEntityStoreTest.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-cassandra/src/test/java/org/apache/polygene/entitystore/cassandra/CassandraMapEntityStoreTest.java
b/extensions/entitystore-cassandra/src/test/java/org/apache/polygene/entitystore/cassandra/CassandraMapEntityStoreTest.java
index 9b1f0ac..45e35e1 100644
--- a/extensions/entitystore-cassandra/src/test/java/org/apache/polygene/entitystore/cassandra/CassandraMapEntityStoreTest.java
+++ b/extensions/entitystore-cassandra/src/test/java/org/apache/polygene/entitystore/cassandra/CassandraMapEntityStoreTest.java
@@ -19,20 +19,17 @@
  */
 package org.apache.polygene.entitystore.cassandra;
 
-import org.apache.polygene.entitystore.cassandra.assembly.CassandraDBEntityStoreAssembler;
-import org.apache.polygene.test.entity.CanRemoveAll;
-import org.apache.polygene.test.internal.DockerRule;
-import org.apache.polygene.valueserialization.jackson.JacksonValueSerializationAssembler;
-import org.junit.BeforeClass;
 import org.apache.polygene.api.common.Visibility;
 import org.apache.polygene.bootstrap.AssemblyException;
 import org.apache.polygene.bootstrap.ModuleAssembly;
+import org.apache.polygene.entitystore.cassandra.assembly.CassandraEntityStoreAssembler;
 import org.apache.polygene.test.EntityTestAssembler;
 import org.apache.polygene.test.entity.AbstractEntityStoreTest;
+import org.apache.polygene.test.entity.CanRemoveAll;
+import org.apache.polygene.test.internal.DockerRule;
+import org.apache.polygene.valueserialization.jackson.JacksonValueSerializationAssembler;
 import org.junit.ClassRule;
 
-import static org.apache.polygene.test.util.Assume.assumeConnectivity;
-
 /**
  * Test the CassandraEntityStoreService.
  * <p>Installing Cassandra and starting it should suffice as the test use Cassandra
defaults: 127.0.0.1:3000</p>
@@ -57,7 +54,7 @@ public class CassandraMapEntityStoreTest
         new JacksonValueSerializationAssembler().assemble( module );
 
         // START SNIPPET: assembly
-        new CassandraDBEntityStoreAssembler().withConfig( config, Visibility.layer ).assemble(
module );
+        new CassandraEntityStoreAssembler().withConfig( config, Visibility.layer ).assemble(
module );
         // END SNIPPET: assembly
 
         CassandraEntityStoreConfiguration cassandraConfig = config.forMixin( CassandraEntityStoreConfiguration.class
).declareDefaults();


Mime
View raw message