usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From snoopd...@apache.org
Subject [34/51] [abbrv] git commit: making changes to prevent performance tests from blowing up
Date Thu, 16 Jan 2014 17:30:30 GMT
making changes to prevent performance tests from blowing up


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

Branch: refs/pull/18/merge
Commit: 2795d0cdbffa4e981037c3d8b851cf43f1f8b7eb
Parents: 35fddfe
Author: Alex Karasulu <akarasulu@gmail.com>
Authored: Thu Jan 16 02:27:22 2014 +0200
Committer: Alex Karasulu <akarasulu@gmail.com>
Committed: Thu Jan 16 02:27:22 2014 +0200

----------------------------------------------------------------------
 .../astyanax/AstyanaxKeyspaceProvider.java      | 27 +++++++++++++++++++-
 ...MvccEntitySerializationStrategyImplTest.java | 13 +++++++++-
 2 files changed, 38 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/2795d0cd/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/astyanax/AstyanaxKeyspaceProvider.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/astyanax/AstyanaxKeyspaceProvider.java
b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/astyanax/AstyanaxKeyspaceProvider.java
index e1fc105..923e7c3 100644
--- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/astyanax/AstyanaxKeyspaceProvider.java
+++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/astyanax/AstyanaxKeyspaceProvider.java
@@ -1,6 +1,11 @@
 package org.apache.usergrid.persistence.collection.astyanax;
 
 
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.concurrent.ConcurrentSkipListSet;
+
 import com.google.inject.Inject;
 import com.google.inject.Provider;
 import com.netflix.astyanax.AstyanaxConfiguration;
@@ -23,6 +28,8 @@ import com.netflix.astyanax.thrift.ThriftFamilyFactory;
 public class AstyanaxKeyspaceProvider implements Provider<Keyspace> {
     private final CassandraFig cassandraConfig;
 
+    private final static Set<AstyanaxContext<Keyspace>> contexts =
+            new HashSet<AstyanaxContext<Keyspace>>();
 
     @Inject
     public AstyanaxKeyspaceProvider( final CassandraFig cassandraConfig ) {
@@ -32,6 +39,7 @@ public class AstyanaxKeyspaceProvider implements Provider<Keyspace>
{
 
     @Override
     public Keyspace get() {
+
         AstyanaxConfiguration config = new AstyanaxConfigurationImpl()
                 .setDiscoveryType( NodeDiscoveryType.TOKEN_AWARE )
                 .setTargetCassandraVersion( cassandraConfig.getVersion() );
@@ -61,8 +69,25 @@ public class AstyanaxKeyspaceProvider implements Provider<Keyspace>
{
                         .buildKeyspace( ThriftFamilyFactory.getInstance() );
 
         context.start();
+        synchronized ( contexts ) {
+            contexts.add( context );
+        }
+        return context.getClient();
+    }
 
 
-        return context.getClient();
+    // @todo by aok - this must be considered to enable stress tests to shutdown or else
+    // @todo the system will run out of file descriptors (sockets) and tests will fail.
+    // this is where the lifecycle management annotations would come in handy.
+    public void shutdown() {
+        synchronized ( contexts ) {
+            HashSet<AstyanaxContext<Keyspace>> copy = new HashSet<AstyanaxContext<Keyspace>>(
contexts.size() );
+            copy.addAll( contexts );
+
+            for ( AstyanaxContext<Keyspace> context : copy ) {
+                context.shutdown();
+                contexts.remove( context );
+            }
+        }
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/2795d0cd/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 c18158d..e62a471 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
@@ -9,6 +9,8 @@ import java.util.UUID;
 
 import org.jukito.JukitoRunner;
 import org.jukito.UseModules;
+import org.junit.After;
+import org.junit.AfterClass;
 import org.junit.Before;
 import org.junit.ClassRule;
 import org.junit.Rule;
@@ -21,6 +23,7 @@ import org.safehaus.guicyfig.Option;
 import org.safehaus.guicyfig.Overrides;
 
 import org.apache.usergrid.persistence.collection.CollectionScope;
+import org.apache.usergrid.persistence.collection.astyanax.AstyanaxKeyspaceProvider;
 import org.apache.usergrid.persistence.collection.astyanax.CassandraFig;
 import org.apache.usergrid.persistence.collection.cassandra.CassandraRule;
 import org.apache.usergrid.persistence.collection.guice.CollectionModule;
@@ -77,6 +80,8 @@ public class MvccEntitySerializationStrategyImplTest {
     @ClassRule
     public static CassandraRule rule = new CassandraRule();
 
+    @Inject
+    AstyanaxKeyspaceProvider provider;
 
     @Inject
     @Rule
@@ -110,12 +115,18 @@ public class MvccEntitySerializationStrategyImplTest {
 
 
     @Before
-    public void setupClass() {
+    public void setup() {
         assertNotNull( cassandraFig );
         assertNotNull( rxFig );
     }
 
 
+    @After
+    public void tearDown() {
+        provider.shutdown();
+    }
+
+
     @Test
     public void writeLoadDelete() throws ConnectionException {
 


Mime
View raw message