usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sfeld...@apache.org
Subject [1/4] git commit: start queues
Date Fri, 03 Oct 2014 19:10:23 GMT
Repository: incubator-usergrid
Updated Branches:
  refs/heads/sqs_queues [created] 2570c800f


start queues


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

Branch: refs/heads/sqs_queues
Commit: e0dcf34ab85f5dac5626e70cb4e94ce926ff766a
Parents: 9c4b26e
Author: Shawn Feldman <sfeldman@apache.org>
Authored: Fri Oct 3 10:34:19 2014 -0600
Committer: Shawn Feldman <sfeldman@apache.org>
Committed: Fri Oct 3 10:34:19 2014 -0600

----------------------------------------------------------------------
 stack/corepersistence/pom.xml                   |   1 +
 stack/corepersistence/queue/pom.xml             | 105 ++++++++++
 .../queue/guice/QueueManagerFactory.java        |   7 +
 .../persistence/queue/guice/QueueModule.java    |  61 ++++++
 .../persistence/queue/QueueManagerTest.java     | 206 +++++++++++++++++++
 .../queue/guice/TestQueueModule.java            |  16 ++
 stack/queue/pom.xml                             |  16 ++
 7 files changed, 412 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e0dcf34a/stack/corepersistence/pom.xml
----------------------------------------------------------------------
diff --git a/stack/corepersistence/pom.xml b/stack/corepersistence/pom.xml
index 5e6bf01..90b4838 100644
--- a/stack/corepersistence/pom.xml
+++ b/stack/corepersistence/pom.xml
@@ -68,6 +68,7 @@
         <module>queryindex</module>
         <module>common</module>
         <module>map</module>
+        <module>queue</module>
     </modules>
 
     <build>

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e0dcf34a/stack/corepersistence/queue/pom.xml
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queue/pom.xml b/stack/corepersistence/queue/pom.xml
new file mode 100644
index 0000000..2b0c6c7
--- /dev/null
+++ b/stack/corepersistence/queue/pom.xml
@@ -0,0 +1,105 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+~ Licensed to the Apache Software Foundation (ASF) under one
+~ or more contributor license agreements.  See the NOTICE file
+~ distributed with this work for additional information
+~ regarding copyright ownership.  The ASF licenses this file
+~ to you under the Apache License, Version 2.0 (the
+~ "License"); you may not use this file except in compliance
+~ with the License.  You may obtain a copy of the License at
+~
+~    http://www.apache.org/licenses/LICENSE-2.0
+~
+~ Unless required by applicable law or agreed to in writing,
+~ software distributed under the License is distributed on an
+~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+~ KIND, either express or implied.  See the License for the
+~ specific language governing permissions and limitations
+~ under the License.
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <parent>
+    <artifactId>persistence</artifactId>
+    <groupId>org.apache.usergrid</groupId>
+    <version>2.0.0-SNAPSHOT</version>
+  </parent>
+
+  <modelVersion>4.0.0</modelVersion>
+
+  <artifactId>queue</artifactId>
+
+  <name>Usergrid Queue</name>
+
+  <dependencies>
+
+    <dependency>
+      <groupId>org.apache.usergrid</groupId>
+      <artifactId>common</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.usergrid</groupId>
+      <artifactId>common</artifactId>
+      <version>${project.version}</version>
+      <classifier>tests</classifier>
+      <scope>test</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.commons</groupId>
+      <artifactId>commons-collections4</artifactId>
+      <version>4.0</version>
+    </dependency>
+
+
+
+    <dependency>
+      <groupId>org.apache.usergrid</groupId>
+      <artifactId>collection</artifactId>
+      <version>${project.version}</version>
+      <type>test-jar</type>
+      <scope>test</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>org.jukito</groupId>
+      <artifactId>jukito</artifactId>
+      <version>${jukito.version}</version>
+      <scope>test</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>com.codahale.metrics</groupId>
+      <artifactId>metrics-core</artifactId>
+      <version>3.0.2</version>
+      <scope>test</scope>
+    </dependency>
+
+
+
+  </dependencies>
+
+  <build>
+    <plugins>
+
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-surefire-plugin</artifactId>
+        <configuration>
+          <!-- We want to exclude any chop tests or stress tests.  They kill the embedded
cassandra and
+          aren't intended to be part of the build process-->
+          <excludes>
+            <exclude>**/*ChopTest.java</exclude>
+            <exclude>**/*LoadTest.java</exclude>
+            <exclude>**/*StressTest.java</exclude>
+          </excludes>
+        </configuration>
+      </plugin>
+
+    </plugins>
+  </build>
+</project>

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e0dcf34a/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/guice/QueueManagerFactory.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/guice/QueueManagerFactory.java
b/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/guice/QueueManagerFactory.java
new file mode 100644
index 0000000..11fe0d7
--- /dev/null
+++ b/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/guice/QueueManagerFactory.java
@@ -0,0 +1,7 @@
+package org.apache.usergrid.persistence.queue.guice;
+
+/**
+ * Created by ApigeeCorporation on 10/3/14.
+ */
+public class QueueManagerFactory {
+}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e0dcf34a/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/guice/QueueModule.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/guice/QueueModule.java
b/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/guice/QueueModule.java
new file mode 100644
index 0000000..6d7d56d
--- /dev/null
+++ b/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/guice/QueueModule.java
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  The ASF licenses this file to You
+ * under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+package org.apache.usergrid.persistence.queue.guice;
+
+
+import org.apache.usergrid.persistence.core.migration.Migration;
+import org.apache.usergrid.persistence.queue.MapManager;
+import org.apache.usergrid.persistence.queue.MapManagerFactory;
+import org.apache.usergrid.persistence.queue.impl.MapManagerImpl;
+import org.apache.usergrid.persistence.queue.impl.MapSerialization;
+import org.apache.usergrid.persistence.queue.impl.MapSerializationImpl;
+
+import com.google.inject.AbstractModule;
+import com.google.inject.Key;
+import com.google.inject.assistedinject.FactoryModuleBuilder;
+import com.google.inject.multibindings.Multibinder;
+
+
+/**
+ * Simple module for wiring our collection api
+ *
+ * @author tnine
+ */
+public class QueueModule extends AbstractModule {
+
+
+    @Override
+    protected void configure() {
+
+        // create a guice factory for getting our collection manager
+        install( new FactoryModuleBuilder().implement( MapManager.class, MapManagerImpl.class
)
+                                           .build( MapManagerFactory.class ) );
+
+
+        bind( MapSerialization.class).to( MapSerializationImpl.class );
+
+        Multibinder<Migration> migrationBinding = Multibinder.newSetBinder( binder(),
Migration.class );
+        migrationBinding.addBinding().to(  Key.get( MapSerialization.class ) );
+
+    }
+
+
+
+}
+
+

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e0dcf34a/stack/corepersistence/queue/src/test/java/org/apache/usergrid/persistence/queue/QueueManagerTest.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queue/src/test/java/org/apache/usergrid/persistence/queue/QueueManagerTest.java
b/stack/corepersistence/queue/src/test/java/org/apache/usergrid/persistence/queue/QueueManagerTest.java
new file mode 100644
index 0000000..240b42f
--- /dev/null
+++ b/stack/corepersistence/queue/src/test/java/org/apache/usergrid/persistence/queue/QueueManagerTest.java
@@ -0,0 +1,206 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.usergrid.persistence.queue;
+
+
+import org.jukito.UseModules;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import org.apache.usergrid.persistence.collection.guice.MigrationManagerRule;
+import org.apache.usergrid.persistence.core.cassandra.ITRunner;
+import org.apache.usergrid.persistence.queue.guice.TestMapModule;
+import org.apache.usergrid.persistence.queue.impl.MapScopeImpl;
+import org.apache.usergrid.persistence.model.entity.SimpleId;
+
+import com.google.inject.Inject;
+
+import java.util.UUID;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+
+@RunWith( ITRunner.class )
+@UseModules( { TestMapModule.class } )
+public class QueueManagerTest {
+
+
+    @Inject
+    @Rule
+    public MigrationManagerRule migrationManagerRule;
+
+
+    @Inject
+    protected MapManagerFactory mmf;
+
+    protected MapScope scope;
+
+
+    @Before
+    public void mockApp() {
+        this.scope = new MapScopeImpl( new SimpleId( "application" ), "testMap" );
+    }
+
+
+    @Test
+    public void writeReadString() {
+        MapManager mm = mmf.getMapManager( this.scope );
+
+        final String key = "key";
+        final String value = "value";
+
+        mm.putString( key, value );
+
+        final String returned = mm.getString( key );
+
+        assertEquals( value, returned );
+    }
+
+    @Test
+    public void writeReadUUID() {
+        MapManager mm = mmf.getMapManager( this.scope );
+
+        final String key = "key";
+        final UUID value = UUID.randomUUID();
+
+        mm.putUuid( key, value );
+
+        final UUID returned = mm.getUuid( key );
+
+        assertEquals( value, returned );
+    }
+
+    @Test
+    public void writeReadLong() {
+        MapManager mm = mmf.getMapManager( this.scope );
+
+        final String key = "key";
+        final Long value = 1234L;
+
+        mm.putLong( key, value );
+
+        final Long returned = mm.getLong( key );
+
+        assertEquals( value, returned );
+    }
+
+
+    @Test
+    public void readMissingEntry() {
+        MapManager mm = mmf.getMapManager( this.scope );
+
+        final String returned = mm.getString( "key" );
+
+        assertNull( returned );
+
+        final Long returnedL = mm.getLong( "key" );
+
+        assertNull( returnedL );
+
+        final UUID returnedUUID = mm.getUuid( "key" );
+
+        assertNull( returnedUUID );
+    }
+
+
+    @Test
+    public void deleteString() {
+        MapManager mm = mmf.getMapManager( this.scope );
+
+        final String key = "key";
+        final String value = "value";
+
+        mm.putString( key, value );
+
+        final String returned = mm.getString( key );
+
+        assertEquals( value, returned );
+
+        mm.delete( key );
+
+        final String postDelete = mm.getString( key );
+
+        assertNull( postDelete );
+    }
+
+    @Test
+    public void deleteUUID() {
+        MapManager mm = mmf.getMapManager( this.scope );
+
+        final String key = "key";
+        final UUID value = UUID.randomUUID();
+
+        mm.putUuid( key, value );
+
+        final UUID returned = mm.getUuid( key );
+
+        assertEquals( value, returned );
+
+        mm.delete( key );
+
+        final UUID postDelete = mm.getUuid( key );
+
+        assertNull( postDelete );
+    }
+
+    @Test
+    public void deleteLong() {
+        MapManager mm = mmf.getMapManager( this.scope );
+
+        final String key = "key";
+        final Long value = 1L;
+
+        mm.putLong( key, value );
+
+        final Long returned = mm.getLong( key );
+
+        assertEquals( value, returned );
+
+        mm.delete( key );
+
+        final Long postDelete = mm.getLong( key );
+
+        assertNull( postDelete );
+    }
+
+
+    @Test( expected = NullPointerException.class )
+    public void nullInputString() {
+        MapManager mm = mmf.getMapManager( this.scope );
+
+        mm.putString( null, null );
+    }
+
+    @Test( expected = NullPointerException.class )
+    public void nullInputLong() {
+        MapManager mm = mmf.getMapManager( this.scope );
+
+        mm.putLong( null, null );
+    }
+    @Test( expected = NullPointerException.class )
+     public void nullInputUUID() {
+        MapManager mm = mmf.getMapManager( this.scope );
+
+        mm.putUuid( null, null );
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e0dcf34a/stack/corepersistence/queue/src/test/java/org/apache/usergrid/persistence/queue/guice/TestQueueModule.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queue/src/test/java/org/apache/usergrid/persistence/queue/guice/TestQueueModule.java
b/stack/corepersistence/queue/src/test/java/org/apache/usergrid/persistence/queue/guice/TestQueueModule.java
new file mode 100644
index 0000000..b54740b
--- /dev/null
+++ b/stack/corepersistence/queue/src/test/java/org/apache/usergrid/persistence/queue/guice/TestQueueModule.java
@@ -0,0 +1,16 @@
+package org.apache.usergrid.persistence.queue.guice;
+
+
+import org.apache.usergrid.persistence.collection.guice.TestModule;
+import org.apache.usergrid.persistence.core.guice.CommonModule;
+
+
+
+public class TestMapModule extends TestModule {
+
+    @Override
+    protected void configure() {
+        install( new CommonModule());
+        install( new MapModule() );
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e0dcf34a/stack/queue/pom.xml
----------------------------------------------------------------------
diff --git a/stack/queue/pom.xml b/stack/queue/pom.xml
new file mode 100644
index 0000000..4cdf79d
--- /dev/null
+++ b/stack/queue/pom.xml
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <parent>
+    <artifactId>persistence</artifactId>
+    <groupId>org.apache.usergrid</groupId>
+    <version>2.0.0-SNAPSHOT</version>
+    <relativePath>../corepersistence/pom.xml</relativePath>
+  </parent>
+  <modelVersion>4.0.0</modelVersion>
+
+  <artifactId>queue</artifactId>
+
+
+</project>
\ No newline at end of file


Mime
View raw message