You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@usergrid.apache.org by sf...@apache.org on 2014/10/03 21:10:23 UTC
[1/4] git commit: start queues
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 <sf...@apache.org>
Authored: Fri Oct 3 10:34:19 2014 -0600
Committer: Shawn Feldman <sf...@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
[4/4] git commit: queues!!!
Posted by sf...@apache.org.
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/2570c800
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/2570c800
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/2570c800
Branch: refs/heads/sqs_queues
Commit: 2570c800f8c61f606be102a8b9cdc050419a27c0
Parents: 92cac3d
Author: Shawn Feldman <sf...@apache.org>
Authored: Fri Oct 3 13:09:49 2014 -0600
Committer: Shawn Feldman <sf...@apache.org>
Committed: Fri Oct 3 13:09:49 2014 -0600
----------------------------------------------------------------------
.../util/UsergridAwsCredentialsProvider.java | 57 ++++++++++++++++++++
.../usergrid/persistence/queue/QueueFig.java | 2 +-
.../persistence/queue/QueueManager.java | 2 +
.../queue/impl/QueueManagerImpl.java | 49 +++++++++++++++--
.../persistence/queue/QueueManagerTest.java | 24 +++++++--
5 files changed, 125 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/2570c800/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/util/UsergridAwsCredentialsProvider.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/util/UsergridAwsCredentialsProvider.java b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/util/UsergridAwsCredentialsProvider.java
new file mode 100644
index 0000000..6792bde
--- /dev/null
+++ b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/util/UsergridAwsCredentialsProvider.java
@@ -0,0 +1,57 @@
+/*
+ * 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.core.util;
+
+import com.amazonaws.SDKGlobalConfiguration;
+import com.amazonaws.auth.AWSCredentials;
+import com.amazonaws.auth.AWSCredentialsProvider;
+
+
+public class UsergridAwsCredentialsProvider implements AWSCredentialsProvider {
+
+ private AWSCredentials creds;
+
+ public UsergridAwsCredentialsProvider(){
+ init();
+ }
+
+ private void init() {
+ creds = new AWSCredentials() {
+ @Override
+ public String getAWSAccessKeyId() {
+ return System.getProperty(SDKGlobalConfiguration.ACCESS_KEY_ENV_VAR);
+ }
+
+ @Override
+ public String getAWSSecretKey() {
+ return System.getProperty(SDKGlobalConfiguration.SECRET_KEY_ENV_VAR);
+ }
+ };
+ }
+
+ @Override
+ public AWSCredentials getCredentials() {
+ return creds;
+ }
+
+
+ @Override
+ public void refresh() {
+ init();
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/2570c800/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/QueueFig.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/QueueFig.java b/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/QueueFig.java
index 479fb97..fd71f9e 100644
--- a/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/QueueFig.java
+++ b/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/QueueFig.java
@@ -9,7 +9,7 @@ import org.safehaus.guicyfig.Key;
public interface QueueFig extends GuicyFig {
@Key( "queue.region" )
- @Default("US_EAST_1")
+ @Default("us-east-1")
public String getRegion();
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/2570c800/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/QueueManager.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/QueueManager.java b/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/QueueManager.java
index e29310b..992b533 100644
--- a/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/QueueManager.java
+++ b/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/QueueManager.java
@@ -28,4 +28,6 @@ public interface QueueManager {
List<QueueMessage> getMessages(int limit,int timeout);
void commitMessage( QueueMessage queueMessage);
void commitMessages( List<QueueMessage> queueMessages);
+ void sendMessages(List<String> bodies);
+ void sendMessage(String body);
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/2570c800/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/impl/QueueManagerImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/impl/QueueManagerImpl.java b/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/impl/QueueManagerImpl.java
index 6547f9f..26d127f 100644
--- a/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/impl/QueueManagerImpl.java
+++ b/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/impl/QueueManagerImpl.java
@@ -1,12 +1,34 @@
+/*
+ * 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.impl;
+import com.amazonaws.SDKGlobalConfiguration;
+import com.amazonaws.auth.AWSCredentials;
+import com.amazonaws.auth.AWSCredentialsProvider;
import com.amazonaws.auth.EnvironmentVariableCredentialsProvider;
+import com.amazonaws.auth.SystemPropertiesCredentialsProvider;
import com.amazonaws.regions.Region;
import com.amazonaws.regions.Regions;
import com.amazonaws.services.sqs.AmazonSQSClient;
import com.amazonaws.services.sqs.model.*;
import com.google.inject.Inject;
import com.google.inject.assistedinject.Assisted;
+import org.apache.usergrid.persistence.core.util.UsergridAwsCredentialsProvider;
import org.apache.usergrid.persistence.queue.*;
import java.util.ArrayList;
@@ -22,8 +44,8 @@ public class QueueManagerImpl implements QueueManager {
public QueueManagerImpl(@Assisted QueueScope scope, QueueFig fig){
this.fig = fig;
this.scope = scope;
- EnvironmentVariableCredentialsProvider credsProvider = new EnvironmentVariableCredentialsProvider();
- this.sqs = new AmazonSQSClient(credsProvider.getCredentials());
+ UsergridAwsCredentialsProvider ugProvider = new UsergridAwsCredentialsProvider();
+ this.sqs = new AmazonSQSClient(ugProvider.getCredentials());
Regions regions = Regions.fromName(fig.getRegion());
Region region = Region.getRegion(regions);
sqs.setRegion(region);
@@ -38,7 +60,7 @@ public class QueueManagerImpl implements QueueManager {
}
private String getName() {
- return scope.getApplication().getUuid().toString()+ scope.getName();
+ return scope.getApplication().getType() + scope.getApplication().getUuid().toString() + scope.getName();
}
public Queue getQueue(){
@@ -51,9 +73,29 @@ public class QueueManagerImpl implements QueueManager {
}
}
}
+ if(queue == null) {
+ queue = createQueue();
+ }
return queue;
}
+ public void sendMessage(String body){
+ SendMessageRequest request = new SendMessageRequest(getQueue().getUrl(),body);
+ sqs.sendMessage(request);
+ }
+
+ public void sendMessages(List<String> bodies){
+ SendMessageBatchRequest request = new SendMessageBatchRequest(getQueue().getUrl());
+ List<SendMessageBatchRequestEntry> entries = new ArrayList<>(bodies.size());
+ for(String body : bodies){
+ SendMessageBatchRequestEntry entry = new SendMessageBatchRequestEntry();
+ entry.setMessageBody(body);
+ entries.add(entry);
+ }
+ request.setEntries(entries);
+ sqs.sendMessageBatch(request);
+ }
+
public List<QueueMessage> getMessages( int limit,int timeout){
System.out.println("Receiving messages from MyQueue.\n");
ReceiveMessageRequest receiveMessageRequest = new ReceiveMessageRequest(getQueue().getUrl());
@@ -73,6 +115,7 @@ public class QueueManagerImpl implements QueueManager {
.withQueueUrl(getQueue().getUrl())
.withReceiptHandle(queueMessage.getHandle()));
}
+
public void commitMessages( List<QueueMessage> queueMessages){
List<DeleteMessageBatchRequestEntry> entries = new ArrayList<>();
for(QueueMessage message : queueMessages){
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/2570c800/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
index 8892e3c..e5f3832 100644
--- 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
@@ -36,10 +36,10 @@ import org.apache.usergrid.persistence.model.entity.SimpleId;
import com.google.inject.Inject;
+import java.util.List;
import java.util.UUID;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
+import static org.junit.Assert.*;
@RunWith( ITRunner.class )
@@ -51,19 +51,33 @@ public class QueueManagerTest {
protected QueueManagerFactory qmf;
protected QueueScope scope;
+ private QueueManager qm;
@Before
public void mockApp() {
this.scope = new QueueScopeImpl( new SimpleId( "application" ), "testQueue" );
+ qm = qmf.getQueueManager(scope);
}
@Test
- public void createQueue() {
- QueueManager qm = qmf.getQueueManager(scope);
- qm.createQueue();
+ public void get() {
Queue queue = qm.getQueue();
+ assertNotNull(queue);
+ }
+
+ @Test
+ public void send(){
+ qm.sendMessage("bodytest");
+ List<QueueMessage> messageList = qm.getMessages(1,5000);
+ assertTrue(messageList.size() >= 1);
+ for(QueueMessage message : messageList){
+ qm.commitMessage(message);
+ }
+ messageList = qm.getMessages(1,5000);
+ assertTrue(messageList.size() <= 0);
+
}
}
[3/4] git commit: added fig
Posted by sf...@apache.org.
added fig
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/92cac3d2
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/92cac3d2
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/92cac3d2
Branch: refs/heads/sqs_queues
Commit: 92cac3d262a8ebe1d25c21f132c50e670c20027c
Parents: 95d3a8c
Author: Shawn Feldman <sf...@apache.org>
Authored: Fri Oct 3 12:26:57 2014 -0600
Committer: Shawn Feldman <sf...@apache.org>
Committed: Fri Oct 3 12:26:57 2014 -0600
----------------------------------------------------------------------
stack/corepersistence/queue/pom.xml | 22 +-----
.../usergrid/persistence/queue/Queue.java | 31 ++++++++
.../usergrid/persistence/queue/QueueFig.java | 16 ++++
.../persistence/queue/QueueManager.java | 24 ++++++
.../persistence/queue/QueueMessage.java | 43 +++++++++++
.../persistence/queue/guice/QueueModule.java | 11 ++-
.../queue/impl/QueueManagerImpl.java | 79 +++++++++++++++++++-
.../persistence/queue/QueueManagerTest.java | 13 ++--
8 files changed, 203 insertions(+), 36 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/92cac3d2/stack/corepersistence/queue/pom.xml
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queue/pom.xml b/stack/corepersistence/queue/pom.xml
index 09d66c6..6795248 100644
--- a/stack/corepersistence/queue/pom.xml
+++ b/stack/corepersistence/queue/pom.xml
@@ -82,28 +82,10 @@
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk</artifactId>
- <version>1.0.002</version>
+ <version>1.8.11</version>
</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/92cac3d2/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/Queue.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/Queue.java b/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/Queue.java
new file mode 100644
index 0000000..2cc49aa
--- /dev/null
+++ b/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/Queue.java
@@ -0,0 +1,31 @@
+/*
+ * 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;
+
+
+public class Queue {
+ private final String url;
+
+ public Queue(String url) {
+ this.url = url;
+ }
+
+ public String getUrl(){
+ return url;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/92cac3d2/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/QueueFig.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/QueueFig.java b/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/QueueFig.java
new file mode 100644
index 0000000..479fb97
--- /dev/null
+++ b/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/QueueFig.java
@@ -0,0 +1,16 @@
+package org.apache.usergrid.persistence.queue;
+
+import org.safehaus.guicyfig.Default;
+import org.safehaus.guicyfig.FigSingleton;
+import org.safehaus.guicyfig.GuicyFig;
+import org.safehaus.guicyfig.Key;
+
+@FigSingleton
+public interface QueueFig extends GuicyFig {
+
+ @Key( "queue.region" )
+ @Default("US_EAST_1")
+ public String getRegion();
+
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/92cac3d2/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/QueueManager.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/QueueManager.java b/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/QueueManager.java
index 9d8a6aa..e29310b 100644
--- a/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/QueueManager.java
+++ b/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/QueueManager.java
@@ -1,7 +1,31 @@
+/*
+ * 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;
+import java.util.List;
+
/**
* Created by ApigeeCorporation on 10/3/14.
*/
public interface QueueManager {
+ Queue createQueue( );
+ Queue getQueue();
+ List<QueueMessage> getMessages(int limit,int timeout);
+ void commitMessage( QueueMessage queueMessage);
+ void commitMessages( List<QueueMessage> queueMessages);
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/92cac3d2/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/QueueMessage.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/QueueMessage.java b/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/QueueMessage.java
new file mode 100644
index 0000000..b07d220
--- /dev/null
+++ b/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/QueueMessage.java
@@ -0,0 +1,43 @@
+/*
+ * 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;
+
+
+public class QueueMessage {
+ private final String body;
+ private final String messageId;
+ private final String handle;
+
+ public QueueMessage(String messageId, String handle, String body) {
+ this.body = body;
+ this.messageId = messageId;
+ this.handle = handle;
+ }
+
+ public String getHandle() {
+ return handle;
+ }
+
+ public String getBody(){
+ return body;
+ }
+
+ public String getMessageId() {
+ return messageId;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/92cac3d2/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
index 2168db9..a74754f 100644
--- 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
@@ -17,16 +17,15 @@
*/
package org.apache.usergrid.persistence.queue.guice;
-
-import org.apache.usergrid.persistence.core.migration.Migration;
-
import com.google.inject.AbstractModule;
-import com.google.inject.Key;
import com.google.inject.assistedinject.FactoryModuleBuilder;
-import com.google.inject.multibindings.Multibinder;
+import org.apache.usergrid.persistence.core.astyanax.CassandraFig;
+import org.apache.usergrid.persistence.core.migration.MigrationManagerFig;
+import org.apache.usergrid.persistence.queue.QueueFig;
import org.apache.usergrid.persistence.queue.QueueManager;
import org.apache.usergrid.persistence.queue.QueueManagerFactory;
import org.apache.usergrid.persistence.queue.impl.QueueManagerImpl;
+import org.safehaus.guicyfig.GuicyFigModule;
/**
@@ -40,11 +39,11 @@ public class QueueModule extends AbstractModule {
@Override
protected void configure() {
+ install( new GuicyFigModule( QueueFig.class) );
// create a guice factory for getting our collection manager
install( new FactoryModuleBuilder().implement( QueueManager.class, QueueManagerImpl.class )
.build( QueueManagerFactory.class ) );
-
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/92cac3d2/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/impl/QueueManagerImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/impl/QueueManagerImpl.java b/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/impl/QueueManagerImpl.java
index acf1d80..6547f9f 100644
--- a/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/impl/QueueManagerImpl.java
+++ b/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/impl/QueueManagerImpl.java
@@ -1,9 +1,84 @@
package org.apache.usergrid.persistence.queue.impl;
-import org.apache.usergrid.persistence.queue.QueueManager;
+import com.amazonaws.auth.EnvironmentVariableCredentialsProvider;
+import com.amazonaws.regions.Region;
+import com.amazonaws.regions.Regions;
+import com.amazonaws.services.sqs.AmazonSQSClient;
+import com.amazonaws.services.sqs.model.*;
+import com.google.inject.Inject;
+import com.google.inject.assistedinject.Assisted;
+import org.apache.usergrid.persistence.queue.*;
+
+import java.util.ArrayList;
+import java.util.List;
public class QueueManagerImpl implements QueueManager {
- public QueueManagerImpl(){
+ private final AmazonSQSClient sqs;
+ private final QueueScope scope;
+ private final QueueFig fig;
+ private Queue queue;
+
+ @Inject
+ public QueueManagerImpl(@Assisted QueueScope scope, QueueFig fig){
+ this.fig = fig;
+ this.scope = scope;
+ EnvironmentVariableCredentialsProvider credsProvider = new EnvironmentVariableCredentialsProvider();
+ this.sqs = new AmazonSQSClient(credsProvider.getCredentials());
+ Regions regions = Regions.fromName(fig.getRegion());
+ Region region = Region.getRegion(regions);
+ sqs.setRegion(region);
+ }
+
+ public Queue createQueue(){
+ CreateQueueRequest createQueueRequest = new CreateQueueRequest()
+ .withQueueName(getName());
+ CreateQueueResult result = sqs.createQueue(createQueueRequest);
+ return new Queue(result.getQueueUrl());
+ }
+
+ private String getName() {
+ return scope.getApplication().getUuid().toString()+ scope.getName();
+ }
+
+ public Queue getQueue(){
+ if(queue == null) {
+ for (String queueUrl : sqs.listQueues().getQueueUrls()) {
+ boolean found = queueUrl.contains(getName());
+ if (found) {
+ queue = new Queue(queueUrl);
+ break;
+ }
+ }
+ }
+ return queue;
+ }
+
+ public List<QueueMessage> getMessages( int limit,int timeout){
+ System.out.println("Receiving messages from MyQueue.\n");
+ ReceiveMessageRequest receiveMessageRequest = new ReceiveMessageRequest(getQueue().getUrl());
+ receiveMessageRequest.setMaxNumberOfMessages(limit);
+ receiveMessageRequest.setVisibilityTimeout(timeout);
+ List<Message> messages = sqs.receiveMessage(receiveMessageRequest).getMessages();
+ List<QueueMessage> queueMessages = new ArrayList<>(messages.size());
+ for (Message message : messages) {
+ QueueMessage queueMessage = new QueueMessage(message.getMessageId(),message.getReceiptHandle(),message.getBody());
+ queueMessages.add(queueMessage);
+ }
+ return queueMessages;
+ }
+
+ public void commitMessage( QueueMessage queueMessage){
+ sqs.deleteMessage(new DeleteMessageRequest()
+ .withQueueUrl(getQueue().getUrl())
+ .withReceiptHandle(queueMessage.getHandle()));
+ }
+ public void commitMessages( List<QueueMessage> queueMessages){
+ List<DeleteMessageBatchRequestEntry> entries = new ArrayList<>();
+ for(QueueMessage message : queueMessages){
+ entries.add(new DeleteMessageBatchRequestEntry(message.getMessageId(),message.getHandle()));
+ }
+ DeleteMessageBatchRequest request = new DeleteMessageBatchRequest(getQueue().getUrl(),entries);
+ DeleteMessageBatchResult result = sqs.deleteMessageBatch(request);
}
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/92cac3d2/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
index e34d877..8892e3c 100644
--- 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
@@ -48,12 +48,7 @@ public class QueueManagerTest {
@Inject
- @Rule
- public MigrationManagerRule migrationManagerRule;
-
-
- @Inject
- protected QueueManagerFactory mmf;
+ protected QueueManagerFactory qmf;
protected QueueScope scope;
@@ -65,8 +60,10 @@ public class QueueManagerTest {
@Test
- public void writeReadString() {
-
+ public void createQueue() {
+ QueueManager qm = qmf.getQueueManager(scope);
+ qm.createQueue();
+ Queue queue = qm.getQueue();
}
}
[2/4] git commit: moving files
Posted by sf...@apache.org.
moving files
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/95d3a8c7
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/95d3a8c7
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/95d3a8c7
Branch: refs/heads/sqs_queues
Commit: 95d3a8c717d256d6160e2faac57ec52f85764b76
Parents: e0dcf34
Author: Shawn Feldman <sf...@apache.org>
Authored: Fri Oct 3 10:53:42 2014 -0600
Committer: Shawn Feldman <sf...@apache.org>
Committed: Fri Oct 3 10:53:42 2014 -0600
----------------------------------------------------------------------
stack/corepersistence/queue/pom.xml | 36 +++--
.../persistence/queue/QueueManager.java | 7 +
.../persistence/queue/QueueManagerFactory.java | 26 ++++
.../usergrid/persistence/queue/QueueScope.java | 31 ++++
.../queue/guice/QueueManagerFactory.java | 7 -
.../persistence/queue/guice/QueueModule.java | 17 +--
.../queue/impl/QueueManagerImpl.java | 9 ++
.../persistence/queue/impl/QueueScopeImpl.java | 87 +++++++++++
.../persistence/queue/QueueManagerTest.java | 150 +------------------
.../queue/guice/TestQueueModule.java | 21 ++-
10 files changed, 212 insertions(+), 179 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/95d3a8c7/stack/corepersistence/queue/pom.xml
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queue/pom.xml b/stack/corepersistence/queue/pom.xml
index 2b0c6c7..09d66c6 100644
--- a/stack/corepersistence/queue/pom.xml
+++ b/stack/corepersistence/queue/pom.xml
@@ -35,36 +35,34 @@
<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>
+
+
+ <!-- lang utils for setting uuids etc -->
+
<dependency>
<groupId>org.apache.commons</groupId>
- <artifactId>commons-collections4</artifactId>
- <version>4.0</version>
+ <artifactId>commons-lang3</artifactId>
+ <version>${commons.lang.version}</version>
</dependency>
-
+ <!-- tests -->
<dependency>
<groupId>org.apache.usergrid</groupId>
- <artifactId>collection</artifactId>
+ <artifactId>common</artifactId>
<version>${project.version}</version>
- <type>test-jar</type>
+ <classifier>tests</classifier>
<scope>test</scope>
</dependency>
+
<dependency>
<groupId>org.jukito</groupId>
<artifactId>jukito</artifactId>
@@ -72,14 +70,20 @@
<scope>test</scope>
</dependency>
+
<dependency>
- <groupId>com.codahale.metrics</groupId>
- <artifactId>metrics-core</artifactId>
- <version>3.0.2</version>
+ <groupId>org.apache.usergrid</groupId>
+ <artifactId>collection</artifactId>
+ <version>${project.version}</version>
+ <type>test-jar</type>
<scope>test</scope>
</dependency>
-
+ <dependency>
+ <groupId>com.amazonaws</groupId>
+ <artifactId>aws-java-sdk</artifactId>
+ <version>1.0.002</version>
+ </dependency>
</dependencies>
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/95d3a8c7/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/QueueManager.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/QueueManager.java b/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/QueueManager.java
new file mode 100644
index 0000000..9d8a6aa
--- /dev/null
+++ b/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/QueueManager.java
@@ -0,0 +1,7 @@
+package org.apache.usergrid.persistence.queue;
+
+/**
+ * Created by ApigeeCorporation on 10/3/14.
+ */
+public interface QueueManager {
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/95d3a8c7/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/QueueManagerFactory.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/QueueManagerFactory.java b/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/QueueManagerFactory.java
new file mode 100644
index 0000000..79bcba9
--- /dev/null
+++ b/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/QueueManagerFactory.java
@@ -0,0 +1,26 @@
+/*
+ * 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;
+
+/**
+ * Created by ApigeeCorporation on 10/3/14.
+ */
+public interface QueueManagerFactory {
+ public QueueManager getQueueManager( final QueueScope scope );
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/95d3a8c7/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/QueueScope.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/QueueScope.java b/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/QueueScope.java
new file mode 100644
index 0000000..b2b2ec6
--- /dev/null
+++ b/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/QueueScope.java
@@ -0,0 +1,31 @@
+/*
+ * 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.apache.usergrid.persistence.core.scope.ApplicationScope;
+
+
+public interface QueueScope extends ApplicationScope {
+
+ /**
+ * Get the name of the the map
+ * @return
+ */
+ public String getName();
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/95d3a8c7/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
deleted file mode 100644
index 11fe0d7..0000000
--- a/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/guice/QueueManagerFactory.java
+++ /dev/null
@@ -1,7 +0,0 @@
-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/95d3a8c7/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
index 6d7d56d..2168db9 100644
--- 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
@@ -19,16 +19,14 @@ 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;
+import org.apache.usergrid.persistence.queue.QueueManager;
+import org.apache.usergrid.persistence.queue.QueueManagerFactory;
+import org.apache.usergrid.persistence.queue.impl.QueueManagerImpl;
/**
@@ -43,15 +41,10 @@ public class QueueModule extends AbstractModule {
protected void configure() {
// create a guice factory for getting our collection manager
- install( new FactoryModuleBuilder().implement( MapManager.class, MapManagerImpl.class )
- .build( MapManagerFactory.class ) );
+ install( new FactoryModuleBuilder().implement( QueueManager.class, QueueManagerImpl.class )
+ .build( QueueManagerFactory.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/95d3a8c7/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/impl/QueueManagerImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/impl/QueueManagerImpl.java b/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/impl/QueueManagerImpl.java
new file mode 100644
index 0000000..acf1d80
--- /dev/null
+++ b/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/impl/QueueManagerImpl.java
@@ -0,0 +1,9 @@
+package org.apache.usergrid.persistence.queue.impl;
+
+import org.apache.usergrid.persistence.queue.QueueManager;
+
+public class QueueManagerImpl implements QueueManager {
+ public QueueManagerImpl(){
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/95d3a8c7/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/impl/QueueScopeImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/impl/QueueScopeImpl.java b/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/impl/QueueScopeImpl.java
new file mode 100644
index 0000000..d78a66d
--- /dev/null
+++ b/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/impl/QueueScopeImpl.java
@@ -0,0 +1,87 @@
+/*
+ * 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.impl;
+
+import org.apache.usergrid.persistence.model.entity.Id;
+import org.apache.usergrid.persistence.queue.QueueScope;
+
+/**
+ * Created by ApigeeCorporation on 10/3/14.
+ */
+public class QueueScopeImpl implements QueueScope {
+ private final Id owner;
+ private final String name;
+
+
+ public QueueScopeImpl( final Id owner, final String name ) {
+ this.owner = owner;
+ this.name = name;
+ }
+
+
+
+ @Override
+ public Id getApplication() {
+ return owner;
+ }
+
+
+ @Override
+ public String getName() {
+ return name;
+ }
+
+
+ @Override
+ public boolean equals( final Object o ) {
+ if ( this == o ) {
+ return true;
+ }
+ if ( !( o instanceof QueueScopeImpl ) ) {
+ return false;
+ }
+
+ final QueueScopeImpl queueScope = ( QueueScopeImpl ) o;
+
+ if ( !name.equals( queueScope.name ) ) {
+ return false;
+ }
+ if ( !owner.equals( queueScope.owner ) ) {
+ return false;
+ }
+
+ return true;
+ }
+
+
+ @Override
+ public int hashCode() {
+ int result = owner.hashCode();
+ result = 31 * result + name.hashCode();
+ return result;
+ }
+
+
+ @Override
+ public String toString() {
+ return "QueueScopeImpl{" +
+ "owner=" + owner +
+ ", name='" + name + '\'' +
+ '}';
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/95d3a8c7/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
index 240b42f..e34d877 100644
--- 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
@@ -20,6 +20,10 @@
package org.apache.usergrid.persistence.queue;
+import org.apache.usergrid.persistence.queue.QueueManagerFactory;
+import org.apache.usergrid.persistence.queue.QueueScope;
+import org.apache.usergrid.persistence.queue.guice.TestQueueModule;
+import org.apache.usergrid.persistence.queue.impl.QueueScopeImpl;
import org.jukito.UseModules;
import org.junit.Before;
import org.junit.Rule;
@@ -28,8 +32,6 @@ 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;
@@ -41,7 +43,7 @@ import static org.junit.Assert.assertNull;
@RunWith( ITRunner.class )
-@UseModules( { TestMapModule.class } )
+@UseModules( { TestQueueModule.class } )
public class QueueManagerTest {
@@ -51,156 +53,20 @@ public class QueueManagerTest {
@Inject
- protected MapManagerFactory mmf;
+ protected QueueManagerFactory mmf;
- protected MapScope scope;
+ protected QueueScope scope;
@Before
public void mockApp() {
- this.scope = new MapScopeImpl( new SimpleId( "application" ), "testMap" );
+ this.scope = new QueueScopeImpl( new SimpleId( "application" ), "testQueue" );
}
@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/95d3a8c7/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
index b54740b..b65725f 100644
--- 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
@@ -1,3 +1,20 @@
+/*
+ * 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;
@@ -6,11 +23,11 @@ import org.apache.usergrid.persistence.core.guice.CommonModule;
-public class TestMapModule extends TestModule {
+public class TestQueueModule extends TestModule {
@Override
protected void configure() {
install( new CommonModule());
- install( new MapModule() );
+ install( new QueueModule() );
}
}