You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@usergrid.apache.org by sn...@apache.org on 2014/12/03 20:59:11 UTC
[01/50] [abbrv] incubator-usergrid git commit: Refactored generation
of collection scope to be re-used with CpNamingUtils for consistency
Repository: incubator-usergrid
Updated Branches:
refs/heads/no-source-in-es [created] c3fc1515b
refs/heads/two-dot-o c2bc921db -> 6210092f0
refs/heads/two-dot-o-events 32276938d -> 532a02cb3
Refactored generation of collection scope to be re-used with CpNamingUtils for consistency
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/9ed79642
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/9ed79642
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/9ed79642
Branch: refs/heads/two-dot-o-events
Commit: 9ed796423f15a8ef33137b113f6e04c578994b21
Parents: 68f4e0f
Author: Todd Nine <tn...@apigee.com>
Authored: Thu Nov 20 14:15:24 2014 -0700
Committer: Todd Nine <tn...@apigee.com>
Committed: Thu Nov 20 14:23:38 2014 -0700
----------------------------------------------------------------------
.../migration/EntityDataMigration.java | 139 +++++++++++++++++
.../migration/EntityTypeMappingMigration.java | 28 ++--
.../migration/GraphShardVersionMigration.java | 104 +++++++------
.../rx/AllEntitiesInSystemObservable.java | 27 ++--
.../corepersistence/StaleIndexCleanupTest.java | 5 +-
.../migration/EntityTypeMappingMigrationIT.java | 74 +++++-----
.../migration/GraphShardVersionMigrationIT.java | 148 +++++++++++--------
.../rx/AllEntitiesInSystemObservableIT.java | 23 ++-
8 files changed, 364 insertions(+), 184 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/9ed79642/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/EntityDataMigration.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/EntityDataMigration.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/EntityDataMigration.java
new file mode 100644
index 0000000..79d31a8
--- /dev/null
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/EntityDataMigration.java
@@ -0,0 +1,139 @@
+/*
+ * 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.corepersistence.migration;
+
+
+import java.util.Iterator;
+import java.util.UUID;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.usergrid.corepersistence.ManagerCache;
+import org.apache.usergrid.corepersistence.rx.AllEntitiesInSystemObservable;
+import org.apache.usergrid.corepersistence.util.CpNamingUtils;
+import org.apache.usergrid.persistence.collection.CollectionScope;
+import org.apache.usergrid.persistence.collection.MvccEntity;
+import org.apache.usergrid.persistence.collection.mvcc.MvccEntitySerializationStrategy;
+import org.apache.usergrid.persistence.core.guice.CurrentImpl;
+import org.apache.usergrid.persistence.core.guice.PreviousImpl;
+import org.apache.usergrid.persistence.core.migration.data.DataMigration;
+import org.apache.usergrid.persistence.core.migration.data.DataMigrationException;
+import org.apache.usergrid.persistence.model.entity.Id;
+import org.apache.usergrid.persistence.model.util.UUIDGenerator;
+
+import com.google.inject.Inject;
+import com.netflix.astyanax.Keyspace;
+import com.netflix.astyanax.MutationBatch;
+import com.netflix.astyanax.connectionpool.exceptions.ConnectionException;
+
+import rx.functions.Action1;
+
+
+/**
+ * Migration for migrating graph edges to the new Shards
+ */
+public class EntityDataMigration implements DataMigration {
+
+
+ private static final Logger logger = LoggerFactory.getLogger( EntityDataMigration.class );
+
+
+ private final MvccEntitySerializationStrategy v1Serialization;
+ private final MvccEntitySerializationStrategy v2Serialization;
+
+ private final ManagerCache managerCache;
+ private final Keyspace keyspace;
+
+
+ @Inject
+ public EntityDataMigration( @PreviousImpl final MvccEntitySerializationStrategy v1Serialization,
+ @CurrentImpl final MvccEntitySerializationStrategy v2Serialization,
+ final ManagerCache managerCache, final Keyspace keyspace ) {
+ this.v1Serialization = v1Serialization;
+ this.v2Serialization = v2Serialization;
+ this.managerCache = managerCache;
+ this.keyspace = keyspace;
+ }
+
+
+ @Override
+ public void migrate( final ProgressObserver observer ) throws Throwable {
+
+
+ AllEntitiesInSystemObservable.getAllEntitiesInSystem( managerCache, 1000 ).doOnNext(
+ new Action1<AllEntitiesInSystemObservable.ApplicationEntityGroup>() {
+
+
+ @Override
+ public void call(
+ final AllEntitiesInSystemObservable.ApplicationEntityGroup applicationEntityGroup ) {
+
+
+ final UUID now = UUIDGenerator.newTimeUUID();
+
+ final Id appScopeId = applicationEntityGroup.applicationScope.getApplication();
+
+
+ final MutationBatch totalBatch = keyspace.prepareMutationBatch();
+
+ for ( Id entityId : applicationEntityGroup.entityIds ) {
+
+ CollectionScope currentScope = CpNamingUtils.getCollectionScopeNameFromEntityType(
+ appScopeId, entityId.getType() );
+
+
+ Iterator<MvccEntity> allVersions =
+ v1Serialization.loadDescendingHistory( currentScope, entityId, now, 1000 );
+
+ while ( allVersions.hasNext() ) {
+ final MvccEntity version = allVersions.next();
+
+ final MutationBatch versionBatch = v2Serialization.write( currentScope, version );
+
+ totalBatch.mergeShallow( versionBatch );
+
+ if ( totalBatch.getRowCount() >= 50 ) {
+ try {
+ totalBatch.execute();
+ }
+ catch ( ConnectionException e ) {
+ throw new DataMigrationException( "Unable to migrate batches ", e );
+ }
+ }
+ }
+ }
+
+ try {
+ totalBatch.execute();
+ }
+ catch ( ConnectionException e ) {
+ throw new DataMigrationException( "Unable to migrate batches ", e );
+ }
+ }
+ } ).toBlocking().last();
+ }
+
+
+ @Override
+ public int getVersion() {
+ return Versions.VERSION_3;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/9ed79642/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/EntityTypeMappingMigration.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/EntityTypeMappingMigration.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/EntityTypeMappingMigration.java
index 1adfe73..8089dfd 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/EntityTypeMappingMigration.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/EntityTypeMappingMigration.java
@@ -29,13 +29,10 @@ import org.slf4j.LoggerFactory;
import org.apache.usergrid.corepersistence.ManagerCache;
import org.apache.usergrid.corepersistence.rx.AllEntitiesInSystemObservable;
import org.apache.usergrid.corepersistence.util.CpNamingUtils;
-import org.apache.usergrid.persistence.collection.EntityCollectionManagerFactory;
import org.apache.usergrid.persistence.core.migration.data.DataMigration;
-import org.apache.usergrid.persistence.graph.GraphManagerFactory;
import org.apache.usergrid.persistence.map.MapManager;
-import org.apache.usergrid.persistence.map.MapManagerFactory;
import org.apache.usergrid.persistence.map.MapScope;
-import org.apache.usergrid.persistence.map.impl.MapScopeImpl;
+import org.apache.usergrid.persistence.model.entity.Id;
import com.google.inject.Inject;
@@ -47,9 +44,6 @@ import rx.functions.Action1;
*/
public class EntityTypeMappingMigration implements DataMigration {
-
- private static final Logger logger = LoggerFactory.getLogger( EntityTypeMappingMigration.class );
-
private final ManagerCache managerCache;
@@ -65,25 +59,27 @@ public class EntityTypeMappingMigration implements DataMigration {
final AtomicLong atomicLong = new AtomicLong();
- AllEntitiesInSystemObservable.getAllEntitiesInSystem(managerCache )
- .doOnNext( new Action1<AllEntitiesInSystemObservable.EntityData>() {
+ AllEntitiesInSystemObservable.getAllEntitiesInSystem(managerCache, 1000 )
+ .doOnNext( new Action1<AllEntitiesInSystemObservable.ApplicationEntityGroup>() {
@Override
- public void call( final AllEntitiesInSystemObservable.EntityData entityData ) {
+ public void call( final AllEntitiesInSystemObservable.ApplicationEntityGroup applicationEntityGroup ) {
- final MapScope ms = CpNamingUtils.getEntityTypeMapScope( entityData.applicationScope.getApplication() );
+ final MapScope ms = CpNamingUtils.getEntityTypeMapScope( applicationEntityGroup.applicationScope.getApplication() );
final MapManager mapManager = managerCache.getMapManager( ms );
- final UUID entityUuid = entityData.entityId.getUuid();
- final String entityType = entityData.entityId.getType();
+ for(Id entityId: applicationEntityGroup.entityIds) {
+ final UUID entityUuid = entityId.getUuid();
+ final String entityType = entityId.getType();
- mapManager.putString( entityUuid.toString(), entityType );
+ mapManager.putString( entityUuid.toString(), entityType );
- if ( atomicLong.incrementAndGet() % 100 == 0 ) {
- updateStatus( atomicLong, observer );
+ if ( atomicLong.incrementAndGet() % 100 == 0 ) {
+ updateStatus( atomicLong, observer );
+ }
}
}
} ).toBlocking().lastOrDefault( null );
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/9ed79642/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/GraphShardVersionMigration.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/GraphShardVersionMigration.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/GraphShardVersionMigration.java
index ac4cd58..3b92570 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/GraphShardVersionMigration.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/GraphShardVersionMigration.java
@@ -36,6 +36,7 @@ import org.apache.usergrid.persistence.core.migration.data.DataMigration;
import org.apache.usergrid.persistence.graph.Edge;
import org.apache.usergrid.persistence.graph.GraphManager;
import org.apache.usergrid.persistence.graph.serialization.EdgeMetadataSerialization;
+import org.apache.usergrid.persistence.model.entity.Id;
import com.google.inject.Inject;
import com.netflix.astyanax.Keyspace;
@@ -64,8 +65,7 @@ public class GraphShardVersionMigration implements DataMigration {
@Inject
public GraphShardVersionMigration( @CurrentImpl final EdgeMetadataSerialization v2Serialization,
- final ManagerCache managerCache, final
- Keyspace keyspace ) {
+ final ManagerCache managerCache, final Keyspace keyspace ) {
this.v2Serialization = v2Serialization;
this.managerCache = managerCache;
this.keyspace = keyspace;
@@ -77,51 +77,71 @@ public class GraphShardVersionMigration implements DataMigration {
final AtomicLong counter = new AtomicLong();
- AllEntitiesInSystemObservable.getAllEntitiesInSystem( managerCache).flatMap(
- new Func1<AllEntitiesInSystemObservable.EntityData, Observable<List<Edge>>>() {
+ AllEntitiesInSystemObservable.getAllEntitiesInSystem( managerCache, 1000 ).flatMap(
+ new Func1<AllEntitiesInSystemObservable.ApplicationEntityGroup, Observable<List<Edge>>>() {
@Override
- public Observable<List<Edge>> call( final AllEntitiesInSystemObservable.EntityData entityData ) {
- logger.info( "Migrating edges from node {} in scope {}", entityData.entityId,
- entityData.applicationScope );
-
- final GraphManager gm = managerCache.getGraphManager( entityData.applicationScope );
-
- //get each edge from this node as a source
- return EdgesFromSourceObservable.edgesFromSource( gm, entityData.entityId )
-
- //for each edge, re-index it in v2 every 1000 edges or less
- .buffer( 1000 ).doOnNext( new Action1<List<Edge>>() {
- @Override
- public void call( final List<Edge> edges ) {
-
- final MutationBatch batch = keyspace.prepareMutationBatch();
-
- for ( final Edge edge : edges ) {
- logger.info( "Migrating meta for edge {}", edge );
- final MutationBatch edgeBatch =
- v2Serialization.writeEdge( entityData.applicationScope, edge );
- batch.mergeShallow( edgeBatch );
- }
-
- try {
- batch.execute();
- }
- catch ( ConnectionException e ) {
- throw new RuntimeException( "Unable to perform migration", e );
- }
-
- //update the observer so the admin can see it
- final long newCount = counter.addAndGet( edges.size() );
-
- observer.update( getVersion(), String.format("Currently running. Rewritten %d edge types", newCount) );
-
-
- }
- } );
+ public Observable<List<Edge>> call(
+ final AllEntitiesInSystemObservable.ApplicationEntityGroup applicationEntityGroup ) {
+
+ //emit a stream of all ids from this group
+ return Observable.from( applicationEntityGroup.entityIds )
+ .flatMap( new Func1<Id, Observable<List<Edge>>>() {
+
+
+ //for each id in the group, get it's edges
+ @Override
+ public Observable<List<Edge>> call( final Id id ) {
+ logger.info( "Migrating edges from node {} in scope {}", id,
+ applicationEntityGroup.applicationScope );
+
+ final GraphManager gm = managerCache
+ .getGraphManager( applicationEntityGroup.applicationScope );
+
+ //get each edge from this node as a source
+ return EdgesFromSourceObservable.edgesFromSource( gm, id )
+
+ //for each edge, re-index it in v2 every 1000 edges or less
+ .buffer( 1000 ).doOnNext( new Action1<List<Edge>>() {
+ @Override
+ public void call( final List<Edge> edges ) {
+
+ final MutationBatch batch =
+ keyspace.prepareMutationBatch();
+
+ for ( final Edge edge : edges ) {
+ logger.info( "Migrating meta for edge {}", edge );
+ final MutationBatch edgeBatch = v2Serialization
+ .writeEdge(
+ applicationEntityGroup
+ .applicationScope,
+ edge );
+ batch.mergeShallow( edgeBatch );
+ }
+
+ try {
+ batch.execute();
+ }
+ catch ( ConnectionException e ) {
+ throw new RuntimeException(
+ "Unable to perform migration", e );
+ }
+
+ //update the observer so the admin can see it
+ final long newCount =
+ counter.addAndGet( edges.size() );
+
+ observer.update( getVersion(), String.format(
+ "Currently running. Rewritten %d edge types",
+ newCount ) );
+ }
+ } );
+ }
+ } );
}
} ).toBlocking().lastOrDefault( null );
+ ;
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/9ed79642/stack/core/src/main/java/org/apache/usergrid/corepersistence/rx/AllEntitiesInSystemObservable.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/rx/AllEntitiesInSystemObservable.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/rx/AllEntitiesInSystemObservable.java
index 291bbe9..771b81f 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/rx/AllEntitiesInSystemObservable.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/rx/AllEntitiesInSystemObservable.java
@@ -20,6 +20,8 @@
package org.apache.usergrid.corepersistence.rx;
+import java.util.List;
+
import org.apache.usergrid.corepersistence.ManagerCache;
import org.apache.usergrid.persistence.core.scope.ApplicationScope;
import org.apache.usergrid.persistence.core.scope.ApplicationScopeImpl;
@@ -40,14 +42,17 @@ public class AllEntitiesInSystemObservable {
/**
* Return an observable that emits all entities in the system.
+ * @param managerCache the managerCache to use
+ * @param bufferSize The amount of entityIds to buffer into each ApplicationEntityGroup. Note that if we exceed the buffer size
+ * you may be more than 1 ApplicationEntityGroup with the same application and different ids
*/
- public static Observable<EntityData> getAllEntitiesInSystem( final ManagerCache managerCache) {
+ public static Observable<ApplicationEntityGroup> getAllEntitiesInSystem( final ManagerCache managerCache, final int bufferSize) {
//traverse all nodes in the graph, load all source edges from them, then re-save the meta data
return ApplicationObservable.getAllApplicationIds( managerCache )
- .flatMap( new Func1<Id, Observable<EntityData>>() {
+ .flatMap( new Func1<Id, Observable<ApplicationEntityGroup>>() {
@Override
- public Observable<EntityData> call( final Id applicationId ) {
+ public Observable<ApplicationEntityGroup> call( final Id applicationId ) {
//set up our application scope and graph manager
final ApplicationScope applicationScope = new ApplicationScopeImpl(
@@ -68,11 +73,11 @@ public class AllEntitiesInSystemObservable {
//merge both the specified application node and the entity node
// so they all get used
- return Observable.merge( applicationNode, entityNodes )
- .map( new Func1<Id, EntityData>() {
+ return Observable.merge( applicationNode, entityNodes ).buffer(bufferSize)
+ .map( new Func1<List<Id>, ApplicationEntityGroup>() {
@Override
- public EntityData call( final Id id ) {
- return new EntityData( applicationScope, id );
+ public ApplicationEntityGroup call( final List<Id> id ) {
+ return new ApplicationEntityGroup( applicationScope, id );
}
} );
}
@@ -83,14 +88,14 @@ public class AllEntitiesInSystemObservable {
/**
* Get the entity data. Immutable bean for fast access
*/
- public static final class EntityData {
+ public static final class ApplicationEntityGroup {
public final ApplicationScope applicationScope;
- public final Id entityId;
+ public final List<Id> entityIds;
- public EntityData( final ApplicationScope applicationScope, final Id entityId ) {
+ public ApplicationEntityGroup( final ApplicationScope applicationScope, final List<Id> entityIds ) {
this.applicationScope = applicationScope;
- this.entityId = entityId;
+ this.entityIds = entityIds;
}
}
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/9ed79642/stack/core/src/test/java/org/apache/usergrid/corepersistence/StaleIndexCleanupTest.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/corepersistence/StaleIndexCleanupTest.java b/stack/core/src/test/java/org/apache/usergrid/corepersistence/StaleIndexCleanupTest.java
index fa9f9df..9d0c9e6 100644
--- a/stack/core/src/test/java/org/apache/usergrid/corepersistence/StaleIndexCleanupTest.java
+++ b/stack/core/src/test/java/org/apache/usergrid/corepersistence/StaleIndexCleanupTest.java
@@ -52,6 +52,7 @@ import org.apache.usergrid.persistence.model.entity.SimpleId;
import com.fasterxml.uuid.UUIDComparator;
+import static org.apache.usergrid.corepersistence.util.CpNamingUtils.getCollectionScopeNameFromEntityType;
import static org.apache.usergrid.persistence.Schema.TYPE_APPLICATION;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
@@ -220,9 +221,7 @@ public class StaleIndexCleanupTest extends AbstractCoreIT {
EntityManager em = app.getEntityManager();
- CollectionScope cs = new CollectionScopeImpl( new SimpleId( em.getApplicationId(), TYPE_APPLICATION ),
- new SimpleId( em.getApplicationId(), TYPE_APPLICATION ),
- CpNamingUtils.getCollectionScopeNameFromEntityType( eref.getType() ) );
+ CollectionScope cs = getCollectionScopeNameFromEntityType( new SimpleId( em.getApplicationId(), TYPE_APPLICATION ), eref.getType() );
EntityCollectionManagerFactory ecmf = CpSetup.getInjector().getInstance( EntityCollectionManagerFactory.class );
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/9ed79642/stack/core/src/test/java/org/apache/usergrid/corepersistence/migration/EntityTypeMappingMigrationIT.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/corepersistence/migration/EntityTypeMappingMigrationIT.java b/stack/core/src/test/java/org/apache/usergrid/corepersistence/migration/EntityTypeMappingMigrationIT.java
index dafdb00..1f0665a 100644
--- a/stack/core/src/test/java/org/apache/usergrid/corepersistence/migration/EntityTypeMappingMigrationIT.java
+++ b/stack/core/src/test/java/org/apache/usergrid/corepersistence/migration/EntityTypeMappingMigrationIT.java
@@ -35,7 +35,6 @@ import org.apache.usergrid.corepersistence.util.CpNamingUtils;
import org.apache.usergrid.persistence.Entity;
import org.apache.usergrid.persistence.EntityManager;
import org.apache.usergrid.persistence.EntityManagerFactory;
-import org.apache.usergrid.persistence.core.migration.schema.MigrationManager;
import org.apache.usergrid.persistence.map.impl.MapSerializationImpl;
import org.apache.usergrid.persistence.model.entity.Id;
@@ -46,7 +45,6 @@ import rx.functions.Action1;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
@@ -75,7 +73,7 @@ public class EntityTypeMappingMigrationIT extends AbstractCoreIT {
@Test
public void testIdMapping() throws Throwable {
- assertEquals("version 1 expected", 1, entityTypeMappingMigration.getVersion());
+ assertEquals( "version 1 expected", 1, entityTypeMappingMigration.getVersion() );
final EntityManager newAppEm = app.getEntityManager();
@@ -87,7 +85,6 @@ public class EntityTypeMappingMigrationIT extends AbstractCoreIT {
final Set<Id> type2Identities = EntityWriteHelper.createTypes( newAppEm, type2, size );
-
final Set<Id> allEntities = new HashSet<>();
allEntities.addAll( type1Identities );
allEntities.addAll( type2Identities );
@@ -106,38 +103,45 @@ public class EntityTypeMappingMigrationIT extends AbstractCoreIT {
entityTypeMappingMigration.migrate( progressObserver );
-
-
-
- AllEntitiesInSystemObservable.getAllEntitiesInSystem( managerCache )
- .doOnNext( new Action1<AllEntitiesInSystemObservable.EntityData>() {
+ AllEntitiesInSystemObservable.getAllEntitiesInSystem( managerCache, 1000 )
+ .doOnNext( new Action1<AllEntitiesInSystemObservable.ApplicationEntityGroup>() {
@Override
- public void call( final AllEntitiesInSystemObservable.EntityData entity ) {
+ public void call(
+ final AllEntitiesInSystemObservable.ApplicationEntityGroup entity ) {
//ensure that each one has a type
- try {
-
- final EntityManager em = emf.getEntityManager( entity.applicationScope.getApplication().getUuid() );
- final Entity returned = em.get( entity.entityId.getUuid() );
-
- //we seem to occasionally get phantom edges. If this is the case we'll store the type _> uuid mapping, but we won't have anything to load
- if(returned != null) {
- assertEquals( entity.entityId.getUuid(), returned.getUuid() );
- assertEquals( entity.entityId.getType(), returned.getType() );
- }
- else {
- final String type = managerCache.getMapManager( CpNamingUtils.getEntityTypeMapScope(
- entity.applicationScope.getApplication() ) )
- .getString( entity.entityId.getUuid().toString() );
-
- assertEquals(entity.entityId.getType(), type);
- }
- }
- catch ( Exception e ) {
- throw new RuntimeException( "Unable to get entity " + entity.entityId
- + " by UUID, migration failed", e );
- }
- allEntities.remove( entity.entityId );
+ final EntityManager em = emf.getEntityManager(
+ entity.applicationScope.getApplication().getUuid() );
+
+ for ( final Id id : entity.entityIds ) {
+ try {
+ final Entity returned = em.get( id.getUuid() );
+
+ //we seem to occasionally get phantom edges. If this is the
+ // case we'll store the type _> uuid mapping, but we won't have
+ // anything to load
+
+ if ( returned != null ) {
+ assertEquals( id.getUuid(), returned.getUuid() );
+ assertEquals( id.getType(), returned.getType() );
+ }
+ else {
+ final String type = managerCache.getMapManager( CpNamingUtils
+ .getEntityTypeMapScope(
+ entity.applicationScope.getApplication() ) )
+ .getString( id.getUuid()
+ .toString() );
+
+ assertEquals( id.getType(), type );
+ }
+ }
+ catch ( Exception e ) {
+ throw new RuntimeException( "Unable to get entity " + id
+ + " by UUID, migration failed", e );
+ }
+
+ allEntities.remove( id );
+ }
}
} ).toBlocking().lastOrDefault( null );
@@ -145,9 +149,5 @@ public class EntityTypeMappingMigrationIT extends AbstractCoreIT {
assertEquals( "Every element should have been encountered", 0, allEntities.size() );
assertFalse( "Progress observer should not have failed", progressObserver.getFailed() );
assertTrue( "Progress observer should have update messages", progressObserver.getUpdates().size() > 0 );
-
-
}
-
-
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/9ed79642/stack/core/src/test/java/org/apache/usergrid/corepersistence/migration/GraphShardVersionMigrationIT.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/corepersistence/migration/GraphShardVersionMigrationIT.java b/stack/core/src/test/java/org/apache/usergrid/corepersistence/migration/GraphShardVersionMigrationIT.java
index aab47a0..88c02cd 100644
--- a/stack/core/src/test/java/org/apache/usergrid/corepersistence/migration/GraphShardVersionMigrationIT.java
+++ b/stack/core/src/test/java/org/apache/usergrid/corepersistence/migration/GraphShardVersionMigrationIT.java
@@ -32,12 +32,9 @@ import org.apache.usergrid.corepersistence.EntityWriteHelper;
import org.apache.usergrid.corepersistence.ManagerCache;
import org.apache.usergrid.corepersistence.rx.AllEntitiesInSystemObservable;
import org.apache.usergrid.persistence.EntityManager;
-import org.apache.usergrid.persistence.EntityManagerFactory;
import org.apache.usergrid.persistence.core.migration.data.DataMigrationManager;
import org.apache.usergrid.persistence.core.migration.data.DataMigrationManagerImpl;
import org.apache.usergrid.persistence.core.migration.data.MigrationInfoSerialization;
-import org.apache.usergrid.persistence.core.migration.data.MigrationInfoSerializationImpl;
-import org.apache.usergrid.persistence.core.migration.schema.MigrationManager;
import org.apache.usergrid.persistence.graph.GraphManager;
import org.apache.usergrid.persistence.graph.impl.SimpleSearchEdgeType;
import org.apache.usergrid.persistence.model.entity.Id;
@@ -114,40 +111,41 @@ public class GraphShardVersionMigrationIT extends AbstractCoreIT {
//read everything in previous version format and put it into our types.
- AllEntitiesInSystemObservable.getAllEntitiesInSystem( managerCache )
- .doOnNext( new Action1<AllEntitiesInSystemObservable.EntityData>() {
+ AllEntitiesInSystemObservable.getAllEntitiesInSystem( managerCache, 1000)
+ .doOnNext( new Action1<AllEntitiesInSystemObservable.ApplicationEntityGroup>() {
@Override
- public void call( final AllEntitiesInSystemObservable.EntityData entity ) {
+ public void call( final AllEntitiesInSystemObservable.ApplicationEntityGroup entity ) {
final GraphManager gm =
managerCache.getGraphManager( entity.applicationScope );
- /**
- * Get our edge types from the source
- */
- gm.getEdgeTypesFromSource(
- new SimpleSearchEdgeType( entity.entityId, null, null ) )
- .doOnNext( new Action1<String>() {
- @Override
- public void call( final String s ) {
- sourceTypes.put( entity.entityId, s );
- }
- } ).toBlocking().lastOrDefault( null );
-
-
- /**
- * Get the edge types to the target
- */
- gm.getEdgeTypesToTarget(
- new SimpleSearchEdgeType( entity.entityId, null, null ) )
- .doOnNext( new Action1<String>() {
- @Override
- public void call( final String s ) {
- targetTypes.put( entity.entityId, s );
- }
- } ).toBlocking().lastOrDefault( null );
-
- allEntities.remove( entity.entityId );
+ for(final Id id: entity.entityIds) {
+ /**
+ * Get our edge types from the source
+ */
+ gm.getEdgeTypesFromSource( new SimpleSearchEdgeType( id, null, null ) )
+ .doOnNext( new Action1<String>() {
+ @Override
+ public void call( final String s ) {
+ sourceTypes.put( id, s );
+ }
+ } ).toBlocking().lastOrDefault( null );
+
+
+ /**
+ * Get the edge types to the target
+ */
+ gm.getEdgeTypesToTarget( new SimpleSearchEdgeType( id,
+ null, null ) )
+ .doOnNext( new Action1<String>() {
+ @Override
+ public void call( final String s ) {
+ targetTypes.put( id, s );
+ }
+ } ).toBlocking().lastOrDefault( null );
+
+ allEntities.remove( id );
+ }
}
} ).toBlocking().lastOrDefault( null );
@@ -169,42 +167,66 @@ public class GraphShardVersionMigrationIT extends AbstractCoreIT {
//now visit all nodes in the system and remove their types from the multi maps, it should be empty at the end
- AllEntitiesInSystemObservable.getAllEntitiesInSystem( managerCache )
- .doOnNext( new Action1<AllEntitiesInSystemObservable.EntityData>() {
+ AllEntitiesInSystemObservable.getAllEntitiesInSystem( managerCache, 1000 )
+ .doOnNext( new Action1<AllEntitiesInSystemObservable.ApplicationEntityGroup>() {
@Override
- public void call( final AllEntitiesInSystemObservable.EntityData entity ) {
+ public void call(
+ final AllEntitiesInSystemObservable.ApplicationEntityGroup entity ) {
final GraphManager gm =
managerCache.getGraphManager( entity.applicationScope );
- /**
- * Get our edge types from the source
- */
- gm.getEdgeTypesFromSource(
- new SimpleSearchEdgeType( entity.entityId, null, null ) )
- .doOnNext( new Action1<String>() {
- @Override
- public void call( final String s ) {
- sourceTypes.remove( entity.entityId, s );
- }
- } ).toBlocking().lastOrDefault( null );
-
-
- /**
- * Get the edge types to the target
- */
- gm.getEdgeTypesToTarget(
- new SimpleSearchEdgeType( entity.entityId, null, null ) )
- .doOnNext( new Action1<String>() {
- @Override
- public void call( final String s ) {
- targetTypes.remove( entity.entityId, s );
- }
- } ).toBlocking().lastOrDefault( null );
+ for ( final Id id : entity.entityIds ) {
+ /**
+ * Get our edge types from the source
+ */
+ gm.getEdgeTypesFromSource(
+ new SimpleSearchEdgeType( id, null, null ) )
+ .doOnNext( new Action1<String>() {
+ @Override
+ public void call( final String s ) {
+ sourceTypes.remove( id, s );
+ }
+ } ).toBlocking().lastOrDefault( null );
+
+
+ /**
+ * Get the edge types to the target
+ */
+ gm.getEdgeTypesToTarget(
+ new SimpleSearchEdgeType( id, null, null ) )
+ .doOnNext( new Action1<String>() {
+ @Override
+ public void call( final String s ) {
+ targetTypes.remove( id, s );
+ }
+ } ).toBlocking().lastOrDefault( null );
+ }
+ }
}
- } ).toBlocking().lastOrDefault( null );
- assertEquals( "All source types migrated", 0, sourceTypes.size() );
- assertEquals( "All target types migrated", 0, targetTypes.size() );
+
+ ).
+
+
+ toBlocking()
+
+
+ .
+
+
+ lastOrDefault( null );
+
+
+ assertEquals( "All source types migrated",0,sourceTypes.size( )
+
+
+ );
+
+
+ assertEquals( "All target types migrated",0,targetTypes.size( )
+
+
+ );
+ }
}
-}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/9ed79642/stack/core/src/test/java/org/apache/usergrid/corepersistence/rx/AllEntitiesInSystemObservableIT.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/corepersistence/rx/AllEntitiesInSystemObservableIT.java b/stack/core/src/test/java/org/apache/usergrid/corepersistence/rx/AllEntitiesInSystemObservableIT.java
index 423dc1f..4d1c6c9 100644
--- a/stack/core/src/test/java/org/apache/usergrid/corepersistence/rx/AllEntitiesInSystemObservableIT.java
+++ b/stack/core/src/test/java/org/apache/usergrid/corepersistence/rx/AllEntitiesInSystemObservableIT.java
@@ -20,7 +20,6 @@
package org.apache.usergrid.corepersistence.rx;
-import java.util.HashMap;
import java.util.HashSet;
import java.util.Set;
@@ -33,13 +32,11 @@ import org.apache.usergrid.corepersistence.CpSetup;
import org.apache.usergrid.corepersistence.EntityWriteHelper;
import org.apache.usergrid.corepersistence.ManagerCache;
import org.apache.usergrid.corepersistence.util.CpNamingUtils;
-import org.apache.usergrid.persistence.Entity;
import org.apache.usergrid.persistence.EntityManager;
import org.apache.usergrid.persistence.SimpleEntityRef;
import org.apache.usergrid.persistence.core.scope.ApplicationScope;
import org.apache.usergrid.persistence.graph.GraphManager;
import org.apache.usergrid.persistence.model.entity.Id;
-import org.apache.usergrid.persistence.model.entity.SimpleId;
import rx.functions.Action1;
@@ -95,26 +92,28 @@ public class AllEntitiesInSystemObservableIT extends AbstractCoreIT {
final GraphManager gm = managerCache.getGraphManager( scope );
- AllEntitiesInSystemObservable.getAllEntitiesInSystem( managerCache ).doOnNext( new Action1<AllEntitiesInSystemObservable.EntityData>() {
+ AllEntitiesInSystemObservable.getAllEntitiesInSystem( managerCache, 1000 ).doOnNext( new Action1<AllEntitiesInSystemObservable.ApplicationEntityGroup>() {
@Override
- public void call( final AllEntitiesInSystemObservable.EntityData entity ) {
+ public void call( final AllEntitiesInSystemObservable.ApplicationEntityGroup entity ) {
assertNotNull(entity);
assertNotNull(entity.applicationScope);
- assertNotNull(entity.entityId);
+ assertNotNull(entity.entityIds);
//not from our test, don't check it
if(!applicationId.equals( entity.applicationScope.getApplication() )){
return;
}
+ for(Id id: entity.entityIds) {
- //we should only emit each node once
- if ( entity.entityId.getType().equals( type1 ) ) {
- assertTrue( "Element should be present on removal", type1Identities.remove( entity.entityId ) );
- }
- else if ( entity.entityId.getType().equals( type2 ) ) {
- assertTrue( "Element should be present on removal", type2Identities.remove( entity.entityId ) );
+ //we should only emit each node once
+ if ( id.getType().equals( type1 ) ) {
+ assertTrue( "Element should be present on removal", type1Identities.remove( id ) );
+ }
+ else if ( id.getType().equals( type2 ) ) {
+ assertTrue( "Element should be present on removal", type2Identities.remove( id ) );
+ }
}
}
} ).toBlocking().lastOrDefault( null );
[46/50] [abbrv] incubator-usergrid git commit: Beginning of a
migration that re-applies mappings to all indexes, i.e. all applications.
Posted by sn...@apache.org.
Beginning of a migration that re-applies mappings to all indexes, i.e. all applications.
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/79f19f8e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/79f19f8e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/79f19f8e
Branch: refs/heads/no-source-in-es
Commit: 79f19f8e1c96fd0799a68196df0fdd6f832f8005
Parents: 716793f
Author: Dave Johnson <dm...@apigee.com>
Authored: Wed Dec 3 10:49:46 2014 -0500
Committer: Dave Johnson <dm...@apigee.com>
Committed: Wed Dec 3 10:49:46 2014 -0500
----------------------------------------------------------------------
.../ApplyQueryIndexMappingsMigration.java | 77 ++++++++++++++++++++
1 file changed, 77 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/79f19f8e/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/ApplyQueryIndexMappingsMigration.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/ApplyQueryIndexMappingsMigration.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/ApplyQueryIndexMappingsMigration.java
new file mode 100644
index 0000000..782c48e
--- /dev/null
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/ApplyQueryIndexMappingsMigration.java
@@ -0,0 +1,77 @@
+/*
+ * 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.corepersistence.migration;
+
+
+import java.util.concurrent.atomic.AtomicLong;
+
+
+import org.apache.usergrid.corepersistence.ManagerCache;
+import org.apache.usergrid.persistence.core.migration.data.DataMigration;
+import org.apache.usergrid.persistence.model.entity.Id;
+
+import com.google.inject.Inject;
+import org.apache.usergrid.corepersistence.rx.ApplicationObservable;
+import org.apache.usergrid.persistence.core.scope.ApplicationScopeImpl;
+import org.apache.usergrid.persistence.index.EntityIndex;
+
+import rx.functions.Action1;
+
+
+/**
+ * Migration applies the current Query Index mappings to every Query Index,
+ * and thus every Application in the system.
+ */
+public class ApplyQueryIndexMappingsMigration implements DataMigration {
+
+ private final ManagerCache managerCache;
+
+ @Inject
+ public ApplyQueryIndexMappingsMigration( final ManagerCache managerCache) {
+ this.managerCache = managerCache;
+ }
+
+
+ @Override
+ public void migrate( final ProgressObserver observer ) throws Throwable {
+
+ ApplicationObservable.getAllApplicationIds( managerCache )
+ .doOnNext( new Action1<Id>() {
+
+ @Override
+ public void call( final Id appId ) {
+ EntityIndex ei = managerCache.getEntityIndex(new ApplicationScopeImpl( appId ));
+ ei.initializeIndex();
+ }
+
+ } ).toBlocking().lastOrDefault( null );
+ }
+
+
+ private void updateStatus( final AtomicLong counter, final ProgressObserver observer ) {
+ observer.update( getVersion(), String.format( "Updated %d entities", counter.get() ) );
+ }
+
+
+ @Override
+ public int getVersion() {
+ return Versions.VERSION_1;
+ }
+}
[49/50] [abbrv] incubator-usergrid git commit: Merge branch
'two-dot-o' into two-dot-o-events
Posted by sn...@apache.org.
Merge branch 'two-dot-o' into two-dot-o-events
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/532a02cb
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/532a02cb
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/532a02cb
Branch: refs/heads/two-dot-o-events
Commit: 532a02cb3e4bfecaa91f4174d764d4e8e24fb235
Parents: 21c93f1 6210092
Author: Dave Johnson <dm...@apigee.com>
Authored: Wed Dec 3 14:55:25 2014 -0500
Committer: Dave Johnson <dm...@apigee.com>
Committed: Wed Dec 3 14:55:25 2014 -0500
----------------------------------------------------------------------
stack/awscluster/gatling-cluster-cf.json | 387 +++++++++++++++++++
stack/awscluster/pom.xml | 2 +-
.../main/dist/init_instance/install_yourkit.sh | 6 +-
.../src/main/groovy/NodeRegistry.groovy | 197 +++++++---
.../main/groovy/configure_elasticsearch.groovy | 31 +-
.../src/main/groovy/registry_list.groovy | 36 --
stack/awscluster/ugcluster-cf.json | 7 +-
.../MvccEntitySerializationStrategyImpl.java | 2 +-
.../core/astyanax/BucketScopedRowKey.java | 3 +-
.../core/astyanax/CassandraConfig.java | 18 +
.../core/astyanax/ColumnNameIterator.java | 1 -
.../persistence/core/astyanax/ColumnSearch.java | 30 +-
.../persistence/core/astyanax/ColumnTypes.java | 19 +-
.../core/astyanax/FieldBufferBuilder.java | 1 -
.../astyanax/MultiKeyColumnNameIterator.java | 2 -
.../core/astyanax/MultiRowColumnIterator.java | 4 -
.../core/astyanax/MultiTennantColumnFamily.java | 1 -
.../persistence/core/astyanax/ScopedRowKey.java | 1 -
.../astyanax/StringRowCompositeSerializer.java | 35 +-
.../core/hystrix/HystrixCassandra.java | 3 -
.../core/migration/data/DataMigration.java | 31 +-
.../migration/data/DataMigrationException.java | 30 +-
.../migration/data/DataMigrationManager.java | 30 +-
.../data/DataMigrationManagerImpl.java | 3 -
.../data/MigrationInfoSerialization.java | 31 +-
.../data/MigrationInfoSerializationImpl.java | 31 +-
.../migration/schema/MigrationManagerFig.java | 18 +
.../migration/schema/MigrationManagerImpl.java | 18 +
.../core/shard/ExpandingShardLocator.java | 23 +-
.../persistence/core/shard/StringHashUtils.java | 22 +-
.../usergrid/persistence/core/task/Task.java | 19 +-
.../persistence/core/task/TaskExecutor.java | 18 +
.../persistence/model/field/LocationField.java | 8 +
stack/loadtests/README.md | 19 +
stack/loadtests/pom.xml | 4 +-
.../usergrid/scenarios/DeviceScenarios.scala | 2 +-
.../usergrid/scenarios/UserScenarios.scala | 54 ++-
.../org/apache/usergrid/settings/Settings.scala | 2 +-
.../simulations/PostUsersSimulation.scala | 49 +--
.../usergrid/simulations/SetupSimulation.scala | 4 +-
stack/loadtests/src/test/scala/Engine.scala | 4 +-
stack/pom.xml | 1 +
42 files changed, 865 insertions(+), 342 deletions(-)
----------------------------------------------------------------------
[12/50] [abbrv] incubator-usergrid git commit: Fixing many more merge
problems.
Posted by sn...@apache.org.
Fixing many more merge problems.
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/2ee0eff3
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/2ee0eff3
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/2ee0eff3
Branch: refs/heads/two-dot-o-events
Commit: 2ee0eff3cd7a7b4bff53ed92cc411324634c9244
Parents: 3227693
Author: Dave Johnson <dm...@apigee.com>
Authored: Mon Nov 24 10:25:58 2014 -0500
Committer: Dave Johnson <dm...@apigee.com>
Committed: Mon Nov 24 10:25:58 2014 -0500
----------------------------------------------------------------------
.../usergrid/corepersistence/CpSetup.java | 16 +++---
.../usergrid/corepersistence/GuiceModule.java | 28 +++++++----
.../events/EntityDeletedHandler.java | 8 +--
.../events/EntityVersionCreatedHandler.java | 18 +++----
.../events/EntityVersionDeletedHandler.java | 7 ++-
.../corepersistence/StaleIndexCleanupTest.java | 51 ++++++++++++--------
.../corepersistence/TestGuiceModule.java | 12 +++--
.../usergrid/persistence/index/EntityIndex.java | 1 -
.../apache/usergrid/rest/TestContextSetup.java | 6 +--
.../collection/DuplicateNameIT.java | 2 +-
.../rest/test/resource/TestContext.java | 3 +-
11 files changed, 90 insertions(+), 62 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/2ee0eff3/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpSetup.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpSetup.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpSetup.java
index d48a20c..35ef63b 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpSetup.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpSetup.java
@@ -62,15 +62,11 @@ public class CpSetup implements Setup {
private static final Logger logger = LoggerFactory.getLogger( CpSetup.class );
private static Injector injector = null;
+ private static EntityManagerFactory emf;
-
- private final org.apache.usergrid.persistence.EntityManagerFactory emf;
private final CassandraService cass;
-
-
-
/**
* Instantiates a new setup object.
*
@@ -82,11 +78,9 @@ public class CpSetup implements Setup {
}
-
-
public static Injector getInjector() {
if ( injector == null ) {
- injector = Guice.createInjector( new GuiceModule() );
+ injector = Guice.createInjector( new GuiceModule( emf ) );
}
return injector;
}
@@ -175,14 +169,16 @@ public class CpSetup implements Setup {
emf.initializeApplication( DEFAULT_ORGANIZATION,
emf.getDefaultAppId(), DEFAULT_APPLICATION, null );
} catch (ApplicationAlreadyExistsException ex) {
- logger.warn("Application {}/{} already exists", DEFAULT_ORGANIZATION, DEFAULT_APPLICATION);
+ logger.warn("Application {}/{} already exists",
+ DEFAULT_ORGANIZATION, DEFAULT_APPLICATION);
}
try {
emf.initializeApplication( DEFAULT_ORGANIZATION,
emf.getManagementAppId(), MANAGEMENT_APPLICATION, null );
} catch (ApplicationAlreadyExistsException ex) {
- logger.warn("Application {}/{} already exists", DEFAULT_ORGANIZATION, MANAGEMENT_APPLICATION);
+ logger.warn("Application {}/{} already exists",
+ DEFAULT_ORGANIZATION, MANAGEMENT_APPLICATION);
}
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/2ee0eff3/stack/core/src/main/java/org/apache/usergrid/corepersistence/GuiceModule.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/GuiceModule.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/GuiceModule.java
index 2697958..98f473a 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/GuiceModule.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/GuiceModule.java
@@ -23,6 +23,7 @@ import org.apache.usergrid.corepersistence.migration.GraphShardVersionMigration;
import org.apache.usergrid.corepersistence.events.EntityDeletedHandler;
import org.apache.usergrid.corepersistence.events.EntityVersionCreatedHandler;
import org.apache.usergrid.corepersistence.events.EntityVersionDeletedHandler;
+import org.apache.usergrid.persistence.EntityManagerFactory;
import org.apache.usergrid.persistence.collection.event.EntityDeleted;
import org.apache.usergrid.persistence.collection.event.EntityVersionCreated;
import org.apache.usergrid.persistence.collection.event.EntityVersionDeleted;
@@ -44,9 +45,19 @@ public class GuiceModule extends AbstractModule {
private static final Logger logger = LoggerFactory.getLogger(GuiceModule.class);
+ private EntityManagerFactory emf;
+
+ GuiceModule( EntityManagerFactory emf ) {
+ this.emf = emf;
+ }
+
@Override
protected void configure() {
+ if ( emf != null ) {
+ bind( EntityManagerFactory.class ).toInstance( emf );
+ }
+
install(new CommonModule());
install(new CollectionModule());
install(new GraphModule());
@@ -54,23 +65,22 @@ public class GuiceModule extends AbstractModule {
install(new MapModule());
install(new QueueModule());
- Multibinder<EntityDeleted> entityBinder
- = Multibinder.newSetBinder(binder(), EntityDeleted.class);
+ Multibinder<EntityDeleted> entityBinder =
+ Multibinder.newSetBinder(binder(), EntityDeleted.class);
entityBinder.addBinding().to(EntityDeletedHandler.class);
- Multibinder<EntityVersionDeleted> versionBinder
- = Multibinder.newSetBinder(binder(), EntityVersionDeleted.class);
+ Multibinder<EntityVersionDeleted> versionBinder =
+ Multibinder.newSetBinder(binder(), EntityVersionDeleted.class);
versionBinder.addBinding().to(EntityVersionDeletedHandler.class);
- Multibinder<EntityVersionCreated> versionCreatedMultibinder
- = Multibinder.newSetBinder( binder(),EntityVersionCreated.class );
+ Multibinder<EntityVersionCreated> versionCreatedMultibinder =
+ Multibinder.newSetBinder( binder(), EntityVersionCreated.class );
versionCreatedMultibinder.addBinding().to(EntityVersionCreatedHandler.class);
- Multibinder<DataMigration> dataMigrationMultibinder = Multibinder.newSetBinder( binder(), DataMigration.class );
+ Multibinder<DataMigration> dataMigrationMultibinder =
+ Multibinder.newSetBinder( binder(), DataMigration.class );
dataMigrationMultibinder.addBinding().to( EntityTypeMappingMigration.class );
dataMigrationMultibinder.addBinding().to( GraphShardVersionMigration.class );
-
-
}
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/2ee0eff3/stack/core/src/main/java/org/apache/usergrid/corepersistence/events/EntityDeletedHandler.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/events/EntityDeletedHandler.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/events/EntityDeletedHandler.java
index bd738fe..d34b51c 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/events/EntityDeletedHandler.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/events/EntityDeletedHandler.java
@@ -17,15 +17,15 @@
*/
package org.apache.usergrid.corepersistence.events;
+import com.google.inject.Inject;
import org.apache.usergrid.persistence.collection.CollectionScope;
import org.apache.usergrid.persistence.collection.event.EntityDeleted;
-import org.apache.usergrid.persistence.index.EntityIndexBatch;
import org.apache.usergrid.persistence.model.entity.Id;
import java.util.UUID;
import org.apache.usergrid.corepersistence.CpEntityManagerFactory;
-import org.apache.usergrid.corepersistence.CpSetup;
import org.apache.usergrid.corepersistence.HybridEntityManagerFactory;
+import org.apache.usergrid.persistence.EntityManagerFactory;
import org.apache.usergrid.persistence.index.EntityIndex;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -37,6 +37,8 @@ import org.slf4j.LoggerFactory;
public class EntityDeletedHandler implements EntityDeleted {
private static final Logger logger = LoggerFactory.getLogger(EntityDeletedHandler.class );
+ @Inject
+ EntityManagerFactory emf;
public EntityDeletedHandler() {
logger.debug("Created");
@@ -50,7 +52,7 @@ public class EntityDeletedHandler implements EntityDeleted {
new Object[] { entityId.getType(), entityId.getUuid(), version,
scope.getName(), scope.getOwner(), scope.getApplication()});
- HybridEntityManagerFactory hemf = (HybridEntityManagerFactory)CpSetup.getEntityManagerFactory();
+ HybridEntityManagerFactory hemf = (HybridEntityManagerFactory)emf;
CpEntityManagerFactory cpemf = (CpEntityManagerFactory)hemf.getImplementation();
final EntityIndex ei = cpemf.getManagerCache().getEntityIndex(scope);
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/2ee0eff3/stack/core/src/main/java/org/apache/usergrid/corepersistence/events/EntityVersionCreatedHandler.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/events/EntityVersionCreatedHandler.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/events/EntityVersionCreatedHandler.java
index 08b8fbd..3462ecb 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/events/EntityVersionCreatedHandler.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/events/EntityVersionCreatedHandler.java
@@ -17,33 +17,36 @@
*/
package org.apache.usergrid.corepersistence.events;
+import com.google.inject.Inject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.usergrid.corepersistence.CpEntityManagerFactory;
-import org.apache.usergrid.corepersistence.CpSetup;
import org.apache.usergrid.corepersistence.HybridEntityManagerFactory;
+import org.apache.usergrid.persistence.EntityManagerFactory;
import org.apache.usergrid.persistence.collection.CollectionScope;
import org.apache.usergrid.persistence.collection.event.EntityVersionCreated;
import org.apache.usergrid.persistence.index.EntityIndex;
-import org.apache.usergrid.persistence.index.EntityIndexBatch;
import org.apache.usergrid.persistence.model.entity.Entity;
-
/**
* Clean up stale entity indexes when new version of Entity created. Called when an Entity is
* updated by the Collections module and we react by calling the Query Index module and removing
* any indexes that exist for previous versions of the the Entity.
*/
public class EntityVersionCreatedHandler implements EntityVersionCreated {
-
private static final Logger logger = LoggerFactory.getLogger(EntityVersionCreatedHandler.class );
+ @Inject
+ EntityManagerFactory emf;
+
+
public EntityVersionCreatedHandler() {
logger.debug("EntityVersionCreated");
}
+
@Override
public void versionCreated( final CollectionScope scope, final Entity entity ) {
logger.debug("Entering deleted for entity {}:{} v {} "
@@ -51,17 +54,14 @@ public class EntityVersionCreatedHandler implements EntityVersionCreated {
new Object[] { entity.getId().getType(), entity.getId().getUuid(), entity.getVersion(),
scope.getName(), scope.getOwner(), scope.getApplication()});
- HybridEntityManagerFactory hemf = (HybridEntityManagerFactory)CpSetup.getEntityManagerFactory();
+ HybridEntityManagerFactory hemf = (HybridEntityManagerFactory)emf;
CpEntityManagerFactory cpemf = (CpEntityManagerFactory)hemf.getImplementation();
final EntityIndex ei = cpemf.getManagerCache().getEntityIndex(scope);
- EntityIndexBatch batch = ei.createBatch();
-
//TODO why aren't we using a collection fig here? This seems kludgy
if ( System.getProperty( "allow.stale.entities", "false" ).equals( "false" )) {
- batch.deindexPreviousVersions( entity );
- batch.execute();
+ ei.deletePreviousVersions( entity.getId(), entity.getVersion() );
}
}
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/2ee0eff3/stack/core/src/main/java/org/apache/usergrid/corepersistence/events/EntityVersionDeletedHandler.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/events/EntityVersionDeletedHandler.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/events/EntityVersionDeletedHandler.java
index 046e9c2..d63edb7 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/events/EntityVersionDeletedHandler.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/events/EntityVersionDeletedHandler.java
@@ -36,6 +36,7 @@ import java.util.List;
import com.google.inject.Inject;
import org.apache.usergrid.corepersistence.HybridEntityManagerFactory;
+import org.apache.usergrid.persistence.EntityManagerFactory;
/**
@@ -47,8 +48,10 @@ public class EntityVersionDeletedHandler implements EntityVersionDeleted {
private final SerializationFig serializationFig;
+ private EntityManagerFactory emf;
+
@Inject
- public EntityVersionDeletedHandler(SerializationFig fig) {
+ public EntityVersionDeletedHandler(SerializationFig fig, EntityManagerFactory emf) {
this.serializationFig = fig;
}
@@ -56,7 +59,7 @@ public class EntityVersionDeletedHandler implements EntityVersionDeleted {
public void versionDeleted(
final CollectionScope scope, final Id entityId, final List<MvccEntity> entityVersions) {
- HybridEntityManagerFactory hemf = (HybridEntityManagerFactory)CpSetup.getEntityManagerFactory();
+ HybridEntityManagerFactory hemf = (HybridEntityManagerFactory)emf;
CpEntityManagerFactory cpemf = (CpEntityManagerFactory)hemf.getImplementation();
final EntityIndex ei = cpemf.getManagerCache().getEntityIndex(scope);
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/2ee0eff3/stack/core/src/test/java/org/apache/usergrid/corepersistence/StaleIndexCleanupTest.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/corepersistence/StaleIndexCleanupTest.java b/stack/core/src/test/java/org/apache/usergrid/corepersistence/StaleIndexCleanupTest.java
index 95d77d0..e1c0214 100644
--- a/stack/core/src/test/java/org/apache/usergrid/corepersistence/StaleIndexCleanupTest.java
+++ b/stack/core/src/test/java/org/apache/usergrid/corepersistence/StaleIndexCleanupTest.java
@@ -35,7 +35,6 @@ import org.apache.usergrid.persistence.Entity;
import org.apache.usergrid.persistence.EntityManager;
import org.apache.usergrid.persistence.EntityRef;
import org.apache.usergrid.persistence.Results;
-import static org.apache.usergrid.persistence.Schema.TYPE_APPLICATION;
import org.apache.usergrid.persistence.collection.CollectionScope;
import org.apache.usergrid.persistence.collection.EntityCollectionManager;
import org.apache.usergrid.persistence.collection.EntityCollectionManagerFactory;
@@ -52,10 +51,14 @@ import org.apache.usergrid.persistence.index.query.Query;
import org.apache.usergrid.persistence.model.entity.SimpleId;
import com.fasterxml.uuid.UUIDComparator;
+import java.util.concurrent.locks.Lock;
+import java.util.concurrent.locks.ReentrantLock;
import static org.apache.usergrid.persistence.Schema.TYPE_APPLICATION;
+import org.junit.After;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
+import org.junit.Before;
//need to create system properties in test that can get applied
@@ -65,6 +68,9 @@ import static org.junit.Assert.assertTrue;
public class StaleIndexCleanupTest extends AbstractCoreIT {
private static final Logger logger = LoggerFactory.getLogger( StaleIndexCleanupTest.class );
+ // take it easy on Cassandra
+ private static final long writeDelayMs = 50;
+ private static final long readDelayMs = 50;
Lock sequential = new ReentrantLock();
@@ -108,14 +114,16 @@ public class StaleIndexCleanupTest extends AbstractCoreIT {
assertEquals( "widget", cpUpdated.getField( "stuff" ).getValue() );
UUID newVersion = cpUpdated.getVersion();
- assertTrue( "New version is greater than old", UUIDComparator.staticCompare( newVersion, oldVersion ) > 0 );
+ assertTrue( "New version is greater than old",
+ UUIDComparator.staticCompare( newVersion, oldVersion ) > 0 );
assertEquals( 2, queryCollectionCp( "things", "thing", "select *" ).size() );
}
/**
- * Test that the CpRelationManager cleans up and stale indexes that it finds when it is building search results.
+ * Test that the CpRelationManager cleans up and stale indexes that it finds when
+ * it is building search results.
*/
@Test
public void testStaleIndexCleanup() throws Exception {
@@ -185,8 +193,8 @@ public class StaleIndexCleanupTest extends AbstractCoreIT {
// should return numEntities becuase it filters out the stale entities
final int limit = 8;
- //we order by updateCount asc, this forces old versions to appear first, otherwise, we don't clean them up in
- // our versions
+ // we order by updateCount asc, this forces old versions to appear first, otherwise,
+ // we don't clean them up in our versions
Query q = Query.fromQL( "select * order by updateCount asc" );
q.setLimit( limit );
int thingCount = 0;
@@ -258,7 +266,7 @@ public class StaleIndexCleanupTest extends AbstractCoreIT {
}
em.refreshIndex();
- CandidateResults crs = queryCollectionCp( "things", "select *");
+ CandidateResults crs = queryCollectionCp( "things", "thing", "select *");
Assert.assertEquals( "Expect no stale candidates yet", numEntities, crs.size() );
// update each one a bunch of times
@@ -287,7 +295,7 @@ public class StaleIndexCleanupTest extends AbstractCoreIT {
em.refreshIndex();
// query Core Persistence directly for total number of result candidates
- crs = queryCollectionCp("things", "select *");
+ crs = queryCollectionCp("things", "thing", "select *");
Assert.assertEquals( "Expect stale candidates", numEntities * (numUpdates + 1), crs.size());
// delete all entities
@@ -300,7 +308,7 @@ public class StaleIndexCleanupTest extends AbstractCoreIT {
count = 0;
do {
Thread.sleep(100);
- crs = queryCollectionCp("things", "select *");
+ crs = queryCollectionCp("things", "thing", "select *");
} while ( crs.size() > 0 && count++ < 14 );
Assert.assertEquals( "Expect no candidates", 0, crs.size() );
@@ -332,7 +340,7 @@ public class StaleIndexCleanupTest extends AbstractCoreIT {
}
em.refreshIndex();
- CandidateResults crs = queryCollectionCp( "things", "select *");
+ CandidateResults crs = queryCollectionCp( "things", "things", "select *");
Assert.assertEquals( "Expect no stale candidates yet", numEntities, crs.size() );
// update each one a bunch of times
@@ -361,7 +369,7 @@ public class StaleIndexCleanupTest extends AbstractCoreIT {
em.refreshIndex();
// query Core Persistence directly for total number of result candidates
- crs = queryCollectionCp("things", "select *");
+ crs = queryCollectionCp("things", "thing", "select *");
Assert.assertEquals( "Expect candidates without earlier stale entities", numEntities, crs.size() );
}
@@ -374,29 +382,34 @@ public class StaleIndexCleanupTest extends AbstractCoreIT {
EntityManager em = app.getEntityManager();
- CollectionScope cs = new CollectionScopeImpl( new SimpleId( em.getApplicationId(), TYPE_APPLICATION ),
- new SimpleId( em.getApplicationId(), TYPE_APPLICATION ),
- CpNamingUtils.getCollectionScopeNameFromEntityType( eref.getType() ) );
+ CollectionScope cs = new CollectionScopeImpl(
+ new SimpleId( em.getApplicationId(), TYPE_APPLICATION ),
+ new SimpleId( em.getApplicationId(), TYPE_APPLICATION ),
+ CpNamingUtils.getCollectionScopeNameFromEntityType( eref.getType() ) );
- EntityCollectionManagerFactory ecmf = CpSetup.getInjector().getInstance( EntityCollectionManagerFactory.class );
+ EntityCollectionManagerFactory ecmf =
+ CpSetup.getInjector().getInstance( EntityCollectionManagerFactory.class );
EntityCollectionManager ecm = ecmf.createCollectionManager( cs );
- return ecm.load( new SimpleId( eref.getUuid(), eref.getType() ) ).toBlocking().lastOrDefault( null );
+ return ecm.load( new SimpleId( eref.getUuid(), eref.getType() ) )
+ .toBlocking().lastOrDefault( null );
}
/**
- * Go around EntityManager and execute query directly against Core Persistence. Results may include stale index
- * entries.
+ * Go around EntityManager and execute query directly against Core Persistence.
+ * Results may include stale index entries.
*/
- private CandidateResults queryCollectionCp( final String collName, final String type, final String query ) {
+ private CandidateResults queryCollectionCp(
+ final String collName, final String type, final String query ) {
EntityManager em = app.getEntityManager();
EntityIndexFactory eif = CpSetup.getInjector().getInstance( EntityIndexFactory.class );
- ApplicationScope as = new ApplicationScopeImpl( new SimpleId( em.getApplicationId(), TYPE_APPLICATION ) );
+ ApplicationScope as = new ApplicationScopeImpl(
+ new SimpleId( em.getApplicationId(), TYPE_APPLICATION ) );
EntityIndex ei = eif.createEntityIndex( as );
IndexScope is = new IndexScopeImpl( new SimpleId( em.getApplicationId(), TYPE_APPLICATION ),
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/2ee0eff3/stack/core/src/test/java/org/apache/usergrid/corepersistence/TestGuiceModule.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/corepersistence/TestGuiceModule.java b/stack/core/src/test/java/org/apache/usergrid/corepersistence/TestGuiceModule.java
index 7d1bd69..9a0b195 100644
--- a/stack/core/src/test/java/org/apache/usergrid/corepersistence/TestGuiceModule.java
+++ b/stack/core/src/test/java/org/apache/usergrid/corepersistence/TestGuiceModule.java
@@ -19,15 +19,19 @@
package org.apache.usergrid.corepersistence;
import com.google.inject.AbstractModule;
+import org.apache.usergrid.persistence.EntityManagerFactory;
public class TestGuiceModule extends AbstractModule {
- @Override
- protected void configure() {
+ private static EntityManagerFactory emf;
- install( new GuiceModule() );
+ public TestGuiceModule( EntityManagerFactory emf ) {
+ this.emf = emf;
}
-
+ @Override
+ protected void configure() {
+ install( new GuiceModule( emf ) );
+ }
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/2ee0eff3/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/EntityIndex.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/EntityIndex.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/EntityIndex.java
index 29d8015..6d2cdd2 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/EntityIndex.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/EntityIndex.java
@@ -24,7 +24,6 @@ import java.util.UUID;
import org.apache.usergrid.persistence.core.util.Health;
import org.apache.usergrid.persistence.index.query.Query;
import org.apache.usergrid.persistence.index.query.CandidateResults;
-import org.apache.usergrid.persistence.model.entity.Entity;
import org.apache.usergrid.persistence.model.entity.Id;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/2ee0eff3/stack/rest/src/test/java/org/apache/usergrid/rest/TestContextSetup.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/TestContextSetup.java b/stack/rest/src/test/java/org/apache/usergrid/rest/TestContextSetup.java
index 2da1033..4b7cc69 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/TestContextSetup.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/TestContextSetup.java
@@ -22,7 +22,6 @@ import org.junit.runner.Description;
import org.junit.runners.model.Statement;
import org.apache.usergrid.persistence.index.utils.UUIDUtils;
-import org.apache.usergrid.rest.management.OrganizationsIT;
import org.apache.usergrid.rest.test.resource.TestContext;
import org.apache.usergrid.rest.test.security.TestAdminUser;
@@ -31,8 +30,9 @@ import java.io.IOException;
/**
- * A self configuring TestContext which sets itself up it implements TestRule. With a @Rule annotation, an instance of
- * this Class as a public member in any test class or abstract test class will auto svcSetup itself before each test.
+ * A self configuring TestContext which sets itself up it implements TestRule. With a @Rule
+ * annotation, an instance of this Class as a public member in any test class or abstract
+ * test class will auto svcSetup itself before each test.
*/
public class TestContextSetup extends TestContext implements TestRule {
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/2ee0eff3/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/DuplicateNameIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/DuplicateNameIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/DuplicateNameIT.java
index 39344d0..5c98785 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/DuplicateNameIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/DuplicateNameIT.java
@@ -55,7 +55,7 @@ public class DuplicateNameIT extends AbstractRestIT {
refreshIndex( context.getAppUuid() );
- Injector injector = Guice.createInjector( new TestGuiceModule() );
+ Injector injector = Guice.createInjector( new TestGuiceModule( null ) );
SerializationFig sfig = injector.getInstance( SerializationFig.class );
// wait for any temporary unique value records to timeout
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/2ee0eff3/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/TestContext.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/TestContext.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/TestContext.java
index 24a05e7..814dd35 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/TestContext.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/TestContext.java
@@ -124,7 +124,8 @@ public class TestContext {
}
- /** Create the app if it doesn't exist with the given TestUser. If the app exists, the user is logged in */
+ /** Create the app if it doesn't exist with the given TestUser.
+ * If the app exists, the user is logged in */
public TestContext loginUser() {
// nothing to do
if ( activeUser.isLoggedIn() ) {
[29/50] [abbrv] incubator-usergrid git commit: Fixes bug with gatling
registration
Posted by sn...@apache.org.
Fixes bug with gatling registration
Fixes bug with instance states and not running instances
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/fd5be569
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/fd5be569
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/fd5be569
Branch: refs/heads/two-dot-o-events
Commit: fd5be56925885b74739c9f16b6d37bd5a8ab7abf
Parents: 65a018f
Author: Todd Nine <tn...@apigee.com>
Authored: Wed Nov 26 16:32:50 2014 -0700
Committer: Todd Nine <tn...@apigee.com>
Committed: Wed Nov 26 17:08:25 2014 -0700
----------------------------------------------------------------------
stack/awscluster/gatling-cluster-cf.json | 12 ++-
.../src/main/groovy/NodeRegistry.groovy | 81 +++++++++++++++-----
2 files changed, 67 insertions(+), 26 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/fd5be569/stack/awscluster/gatling-cluster-cf.json
----------------------------------------------------------------------
diff --git a/stack/awscluster/gatling-cluster-cf.json b/stack/awscluster/gatling-cluster-cf.json
index 59090de..4345e1e 100644
--- a/stack/awscluster/gatling-cluster-cf.json
+++ b/stack/awscluster/gatling-cluster-cf.json
@@ -216,10 +216,10 @@
},
"/etc/profile.d/maven.sh" : {
"content" : { "Fn::Join" : ["", [
- "export M2_HOME=/usr/local/apache-maven/apache-maven-3.1.1\n",
- "export M2=$M2_HOME/bin\n",
+ "export M3_HOME=/usr/local/apache-maven/apache-maven-3.1.1\n",
+ "export M3=$M3_HOME/bin\n",
"export MAVEN_OPTS=\"-Xms256m -Xmx512m\"\n",
- "export PATH=$M2:$PATH\n"
+ "export PATH=$M3:$PATH\n"
]]}
},
@@ -265,10 +265,8 @@
"git clone -b ",{ "Ref":"Branch" } , " https://github.com/apache/incubator-usergrid.git usergrid\n",
"chown -R ubuntu:ubuntu usergrid\n",
-
- "/usr/local/bin/cfn-signal --success true --stack ", { "Ref" : "AWS::StackName" }, " --resource GatlingServerGroup --region ", { "Ref" : "AWS::Region" }, "\n",
-
- "ec2-create-tags $(curl -k http://169.254.169.254/latest/meta-data/instance-id) --aws-access-key ",{ "Ref":"GatlingKey" }, " --aws-secret-key ", { "Fn::GetAtt":[ "GatlingKey", "SecretAccessKey" ] } ," --tag Name=", { "Ref":"AWS::StackName" }, "-Gatling\n"
+ "ec2-create-tags $(curl -k http://169.254.169.254/latest/meta-data/instance-id) --aws-access-key ",{ "Ref":"GatlingKey" }, " --aws-secret-key ", { "Fn::GetAtt":[ "GatlingKey", "SecretAccessKey" ] } ," --tag Name=", { "Ref":"AWS::StackName" }, "-Gatling\n",
+ "/usr/local/bin/cfn-signal --success true --stack ", { "Ref" : "AWS::StackName" }, " --resource GatlingServerGroup --region ", { "Ref" : "AWS::Region" }, "\n"
]]}}
}
},
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/fd5be569/stack/awscluster/src/main/groovy/NodeRegistry.groovy
----------------------------------------------------------------------
diff --git a/stack/awscluster/src/main/groovy/NodeRegistry.groovy b/stack/awscluster/src/main/groovy/NodeRegistry.groovy
index 277631b..80a20eb 100644
--- a/stack/awscluster/src/main/groovy/NodeRegistry.groovy
+++ b/stack/awscluster/src/main/groovy/NodeRegistry.groovy
@@ -22,14 +22,8 @@
import com.amazonaws.auth.BasicAWSCredentials
import com.amazonaws.regions.Region
import com.amazonaws.regions.Regions
-import com.amazonaws.services.ec2.model.DescribeInstancesRequest
-import com.amazonaws.services.ec2.model.DescribeInstancesResult
-import com.amazonaws.services.ec2.model.DescribeTagsRequest
import com.amazonaws.services.ec2.AmazonEC2Client
-import com.amazonaws.services.ec2.model.CreateTagsRequest
-import com.amazonaws.services.ec2.model.Filter
-import com.amazonaws.services.ec2.model.Instance
-import com.amazonaws.services.ec2.model.Tag
+import com.amazonaws.services.ec2.model.*
class NodeRegistry {
@@ -86,36 +80,66 @@ class NodeRegistry {
*/
def searchNode(def nodeType) {
- def stackNameFilter = new Filter(TAG_PREFIX+STACK_NAME).withValues(stackName);
- def nodeTypeFilter = new Filter(TAG_PREFIX+NODE_TYPE).withValues(nodeType);
+ def stackNameFilter = new Filter(TAG_PREFIX+STACK_NAME).withValues(stackName)
+ def nodeTypeFilter = new Filter(TAG_PREFIX+NODE_TYPE).withValues(nodeType)
- def describeRequest = new DescribeInstancesRequest().withFilters(stackNameFilter, nodeTypeFilter);
- def nodes = ec2Client.describeInstances(describeRequest)
+ //sort by created date
+ def servers = new TreeSet<ServerEntry>();
- //sort by created date
- def servers = [];
- for(reservation in nodes.getReservations()){
+ def token = null
- //TODO, add these to a list then sort them by date, then name
- for(instance in reservation.getInstances()){
- servers.add(new ServerEntry(instance.launchTime, instance.publicDnsName))
+
+ while(true){
+
+ def describeRequest = new DescribeInstancesRequest().withFilters(stackNameFilter, nodeTypeFilter)
+
+ if(token != null){
+ describeRequest.withNextToken(token);
+ }
+
+
+ def nodes = ec2Client.describeInstances(describeRequest)
+
+ for (reservation in nodes.getReservations()) {
+
+ //TODO, add these to a list then sort them by date, then name
+ for (instance in reservation.getInstances()) {
+
+ //ignore instances that aren't running
+ if (instance.state.getName() == InstanceStateName.Running.toString()) {
+ servers.add(new ServerEntry(instance.launchTime, instance.publicDnsName));
+ }
+
+
+ }
+
}
+ //nothing to do, exit the loop
+ if(nodes.nextToken != null){
+ token = nodes.nextToken;
+ }
+ else{
+ break;
+ }
+
+
+
+
}
+
return createResults(servers);
}
def createResults(def servers){
-
- Collections.sort(servers);
def results = [];
for(server in servers){
@@ -164,6 +188,25 @@ class NodeRegistry {
}
+
+ boolean equals(final o) {
+ if (this.is(o)) return true
+ if (getClass() != o.class) return false
+
+ final ServerEntry that = (ServerEntry) o
+
+ if (launchDate != that.launchDate) return false
+ if (publicIp != that.publicIp) return false
+
+ return true
+ }
+
+ int hashCode() {
+ int result
+ result = launchDate.hashCode()
+ result = 31 * result + publicIp.hashCode()
+ return result
+ }
}
}
[18/50] [abbrv] incubator-usergrid git commit: temp name change to
fix caps
Posted by sn...@apache.org.
temp name change to fix caps
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/c4511789
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/c4511789
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/c4511789
Branch: refs/heads/two-dot-o-events
Commit: c4511789591870ab14b063ae934f6f526fc3f478
Parents: 09333ac
Author: Rod Simpson <ro...@apigee.com>
Authored: Mon Nov 24 18:32:48 2014 -0700
Committer: Rod Simpson <ro...@apigee.com>
Committed: Mon Nov 24 18:32:48 2014 -0700
----------------------------------------------------------------------
.../applications/queries/StandardGeoTests.java | 268 +++++++++++++++++++
.../applications/queries/basicGeoTests.java | 268 -------------------
2 files changed, 268 insertions(+), 268 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c4511789/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/StandardGeoTests.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/StandardGeoTests.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/StandardGeoTests.java
new file mode 100644
index 0000000..1879c55
--- /dev/null
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/StandardGeoTests.java
@@ -0,0 +1,268 @@
+/*
+ * 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.rest.applications.queries;
+
+
+import java.util.*;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.sun.jersey.api.client.UniformInterfaceException;
+
+import java.io.IOException;
+
+import org.apache.usergrid.persistence.Entity;
+import org.apache.usergrid.persistence.EntityManager;
+import org.apache.usergrid.persistence.Results;
+
+import org.jclouds.json.Json;
+import org.junit.Rule;
+import org.junit.Test;
+
+import org.apache.usergrid.persistence.geo.model.Point;
+import org.apache.usergrid.persistence.index.query.Query;
+import org.apache.usergrid.persistence.index.utils.UUIDUtils;
+import org.apache.usergrid.rest.AbstractRestIT;
+import org.apache.usergrid.rest.TestContextSetup;
+import org.apache.usergrid.rest.test.resource.CustomCollection;
+
+import static org.junit.Assert.assertEquals;
+import static org.apache.usergrid.utils.MapUtils.hashMap;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
+
+
+/**
+ * Basic Geo Tests - CRUD entities with geo points, exceptions for malformed calls
+ *
+ * @author rockerston
+ */
+public class StandardGeoTests extends AbstractRestIT {
+
+ @Rule
+ public TestContextSetup context = new TestContextSetup( this );
+
+ public final String latitude = "latitude";
+
+ /**
+ * Create a entity with a geo location point in it
+ * 1. Create entity
+ * 2. Verify that the entity was created
+ */
+ @Test
+ public void createEntityWithGeoLocationPoint() throws IOException {
+
+ String collectionType = "stores";
+ JsonNode node = null;
+ Double lat = 37.776753;
+ Double lon = -122.407846;
+ //1. Create entity
+ Map<String, Double> latLon = hashMap("latitude", lat);
+ latLon.put( "longitude", lon );
+ Map<String, Object> entityData = new HashMap<String, Object>();
+ entityData.put( "location", latLon );
+
+ try {
+ node = context.collection( collectionType ).post( entityData );
+ }
+ catch ( UniformInterfaceException e ) {
+ JsonNode nodeError = mapper.readTree( e.getResponse().getEntity( String.class ) );
+ fail( nodeError.get( "error" ).textValue() );
+ }
+
+ //2. Verify that the entity was created
+ assertNotNull( node );
+ assertEquals( lat.toString(), node.get("location").get("latitude").asText() );
+ assertEquals( lon.toString(), node.get( "location" ).get("longitude").asText() );
+
+ }
+
+ /**
+ * Update an entity with a geo location point in it
+ * 1. create an entity with a geo point
+ * 2. read back that entity make sure it is accurate
+ * 3. update the geo point to a new value
+ * 4. read back the updated entity, make sure it is accurate
+ */
+ @Test
+ public void updateEntityWithGeoLocationPoint() throws IOException {
+
+ String collectionType = "stores";
+ String entityName = "cornerStore";
+ JsonNode entity = null;
+ Double lat = 37.776753;
+ Double lon = -122.407846;
+
+ //1. create an entity with a geo point
+ Map<String, Double> latLon = hashMap("latitude", lat);
+ latLon.put( "longitude", lon );
+ Map<String, Object> entityData = new HashMap<String, Object>();
+ entityData.put( "location", latLon );
+ entityData.put( "name", entityName );
+
+ try {
+ entity = context.collection( collectionType ).post( entityData );
+ }
+ catch ( UniformInterfaceException e ) {
+ JsonNode nodeError = mapper.readTree( e.getResponse().getEntity( String.class ) );
+ fail( nodeError.get( "error" ).textValue() );
+ }
+
+ assertNotNull(entity);
+ assertEquals( lat.toString(), entity.get("location").get("latitude").asText() );
+ assertEquals( lon.toString(), entity.get( "location" ).get("longitude").asText() );
+
+ context.refreshIndex();
+
+ //2. read back that entity make sure it is accurate
+ /*
+ try {
+ node = context.collection( collectionType ).get(entityName);
+ }
+ catch ( UniformInterfaceException e ) {
+ JsonNode nodeError = mapper.readTree( e.getResponse().getEntity( String.class ) );
+ fail( nodeError.get( "error" ).textValue() );
+ }
+
+ //3. update the geo point to a new value
+ Double newLat = 35.776753;
+ Double newLon = -119.407846;
+ latLon.put( "latitude", newLat );
+ latLon.put( "longitude", newLon );
+ entityData.put( "location", latLon );
+
+ //TODO PUT should take name property and append it to URL - e.g. PUT /cats/fluffy not PUT /cats {"name":"fluffy"}
+ try {
+ //node = context.collection( collectionType ).put(entityData);
+ //entity.put(entityData);
+
+ }
+ catch ( UniformInterfaceException e ) {
+ JsonNode nodeError = mapper.readTree( e.getResponse().getEntity( String.class ) );
+ fail( nodeError.get( "error" ).textValue() );
+ }
+
+ assertNotNull(entity);
+ assertEquals( newLat.toString(), entity.get("location").get("latitude").asText() );
+ assertEquals( newLon.toString(), entity.get( "location" ).get("longitude").asText() );
+ */
+
+ context.refreshIndex();
+
+ //4. read back the updated entity, make sure it is accurate
+
+
+
+
+
+ }
+
+ /**
+ * Test exceptions for entities with poorly created geo points
+ * 1. misspell latitude
+ * 2. misspell longitude
+ */
+ @Test
+ public void createEntitiesWithBadSpelling() throws IOException {
+
+ String collectionType = "stores";
+ JsonNode node = null;
+ Double lat = 37.776753;
+ Double lon = -122.407846;
+
+ // 1. misspell latitude
+ Map<String, Double> misspelledLatitude = hashMap("latitudee", lat);
+ misspelledLatitude.put( "longitude", lon );
+ Map<String, Object> misspelledLatitudeEntityData = new HashMap<String, Object>();
+ misspelledLatitudeEntityData.put( "location", misspelledLatitude );
+
+ try {
+ node = context.collection( collectionType ).post( misspelledLatitudeEntityData );
+ fail("System allowed misspelled location property - latitudee, which it should not");
+ }
+ catch ( UniformInterfaceException e ) {
+ //verify the correct error was returned
+ JsonNode nodeError = mapper.readTree( e.getResponse().getEntity( String.class ));
+ assertEquals( "illegal_argument", nodeError.get( "error" ).textValue() );
+ }
+
+ // 2. misspell longitude
+ Map<String, Double> misspelledLongitude = hashMap("latitude", lat);
+ misspelledLongitude.put( "longitudee", lon );
+ Map<String, Object> misspelledLongitudeEntityData = new HashMap<String, Object>();
+ misspelledLongitudeEntityData.put( "location", misspelledLongitude );
+
+ try {
+ node = context.collection( collectionType ).post( misspelledLongitudeEntityData );
+ fail("System allowed misspelled location property - longitudee, which it should not");
+ }
+ catch ( UniformInterfaceException e ) {
+ //verify the correct error was returned
+ JsonNode nodeError = mapper.readTree( e.getResponse().getEntity( String.class ));
+ assertEquals( "illegal_argument", nodeError.get( "error" ).textValue() );
+ }
+
+ }
+
+
+ /**
+ * Test exceptions for entities with poorly created geo points
+ * 1. pass only one point instead of two
+ * 2. pass a values that are not doubles
+ */
+ @Test
+ public void createEntitiesWithBadPoints() throws IOException {
+
+ String collectionType = "stores";
+ JsonNode node = null;
+ Double lat = 37.776753;
+ Double lon = -122.407846;
+
+ // 1. pass only one point instead of two
+ Map<String, Double> latitudeOnly = hashMap("latitude", lat);
+ Map<String, Object> latitudeOnlyEntityData = new HashMap<String, Object>();
+ latitudeOnlyEntityData.put( "location", latitudeOnly );
+
+ try {
+ node = context.collection( collectionType ).post( latitudeOnlyEntityData );
+ fail("System allowed location with only one point, latitude, which it should not");
+ }
+ catch ( UniformInterfaceException e ) {
+ //verify the correct error was returned
+ JsonNode nodeError = mapper.readTree( e.getResponse().getEntity( String.class ));
+ assertEquals( "illegal_argument", nodeError.get( "error" ).textValue() );
+ }
+
+ // 2. pass a values that are not doubles
+ Map<String, String> notDoubleLatLon = hashMap("latitude", "fred");
+ notDoubleLatLon.put( "longitude", "barney" );
+ Map<String, Object> notDoubleLatLonEntityData = new HashMap<String, Object>();
+ notDoubleLatLonEntityData.put( "location", notDoubleLatLon );
+
+ try {
+ node = context.collection( collectionType ).post( notDoubleLatLonEntityData );
+ fail("System allowed misspelled location values that are not doubles for latitude and longitude, which it should not");
+ }
+ catch ( UniformInterfaceException e ) {
+ //verify the correct error was returned
+ JsonNode nodeError = mapper.readTree( e.getResponse().getEntity( String.class ));
+ assertEquals( "illegal_argument", nodeError.get( "error" ).textValue() );
+ }
+
+
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c4511789/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/basicGeoTests.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/basicGeoTests.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/basicGeoTests.java
deleted file mode 100644
index abaf6dd..0000000
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/basicGeoTests.java
+++ /dev/null
@@ -1,268 +0,0 @@
-/*
- * 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.rest.applications.queries;
-
-
-import java.util.*;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.sun.jersey.api.client.UniformInterfaceException;
-
-import java.io.IOException;
-
-import org.apache.usergrid.persistence.Entity;
-import org.apache.usergrid.persistence.EntityManager;
-import org.apache.usergrid.persistence.Results;
-
-import org.jclouds.json.Json;
-import org.junit.Rule;
-import org.junit.Test;
-
-import org.apache.usergrid.persistence.geo.model.Point;
-import org.apache.usergrid.persistence.index.query.Query;
-import org.apache.usergrid.persistence.index.utils.UUIDUtils;
-import org.apache.usergrid.rest.AbstractRestIT;
-import org.apache.usergrid.rest.TestContextSetup;
-import org.apache.usergrid.rest.test.resource.CustomCollection;
-
-import static org.junit.Assert.assertEquals;
-import static org.apache.usergrid.utils.MapUtils.hashMap;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.fail;
-
-
-/**
- * Basic Geo Tests - CRUD entities with geo points, exceptions for malformed calls
- *
- * @author rockerston
- */
-public class basicGeoTests extends AbstractRestIT {
-
- @Rule
- public TestContextSetup context = new TestContextSetup( this );
-
- public final String latitude = "latitude";
-
- /**
- * Create a entity with a geo location point in it
- * 1. Create entity
- * 2. Verify that the entity was created
- */
- @Test
- public void createEntityWithGeoLocationPoint() throws IOException {
-
- String collectionType = "stores";
- JsonNode node = null;
- Double lat = 37.776753;
- Double lon = -122.407846;
- //1. Create entity
- Map<String, Double> latLon = hashMap("latitude", lat);
- latLon.put( "longitude", lon );
- Map<String, Object> entityData = new HashMap<String, Object>();
- entityData.put( "location", latLon );
-
- try {
- node = context.collection( collectionType ).post( entityData );
- }
- catch ( UniformInterfaceException e ) {
- JsonNode nodeError = mapper.readTree( e.getResponse().getEntity( String.class ) );
- fail( nodeError.get( "error" ).textValue() );
- }
-
- //2. Verify that the entity was created
- assertNotNull( node );
- assertEquals( lat.toString(), node.get("location").get("latitude").asText() );
- assertEquals( lon.toString(), node.get( "location" ).get("longitude").asText() );
-
- }
-
- /**
- * Update an entity with a geo location point in it
- * 1. create an entity with a geo point
- * 2. read back that entity make sure it is accurate
- * 3. update the geo point to a new value
- * 4. read back the updated entity, make sure it is accurate
- */
- @Test
- public void updateEntityWithGeoLocationPoint() throws IOException {
-
- String collectionType = "stores";
- String entityName = "cornerStore";
- JsonNode entity = null;
- Double lat = 37.776753;
- Double lon = -122.407846;
-
- //1. create an entity with a geo point
- Map<String, Double> latLon = hashMap("latitude", lat);
- latLon.put( "longitude", lon );
- Map<String, Object> entityData = new HashMap<String, Object>();
- entityData.put( "location", latLon );
- entityData.put( "name", entityName );
-
- try {
- entity = context.collection( collectionType ).post( entityData );
- }
- catch ( UniformInterfaceException e ) {
- JsonNode nodeError = mapper.readTree( e.getResponse().getEntity( String.class ) );
- fail( nodeError.get( "error" ).textValue() );
- }
-
- assertNotNull(entity);
- assertEquals( lat.toString(), entity.get("location").get("latitude").asText() );
- assertEquals( lon.toString(), entity.get( "location" ).get("longitude").asText() );
-
- context.refreshIndex();
-
- //2. read back that entity make sure it is accurate
- /*
- try {
- node = context.collection( collectionType ).get(entityName);
- }
- catch ( UniformInterfaceException e ) {
- JsonNode nodeError = mapper.readTree( e.getResponse().getEntity( String.class ) );
- fail( nodeError.get( "error" ).textValue() );
- }
-
- //3. update the geo point to a new value
- Double newLat = 35.776753;
- Double newLon = -119.407846;
- latLon.put( "latitude", newLat );
- latLon.put( "longitude", newLon );
- entityData.put( "location", latLon );
-
- //TODO PUT should take name property and append it to URL - e.g. PUT /cats/fluffy not PUT /cats {"name":"fluffy"}
- try {
- //node = context.collection( collectionType ).put(entityData);
- //entity.put(entityData);
-
- }
- catch ( UniformInterfaceException e ) {
- JsonNode nodeError = mapper.readTree( e.getResponse().getEntity( String.class ) );
- fail( nodeError.get( "error" ).textValue() );
- }
-
- assertNotNull(entity);
- assertEquals( newLat.toString(), entity.get("location").get("latitude").asText() );
- assertEquals( newLon.toString(), entity.get( "location" ).get("longitude").asText() );
- */
-
- context.refreshIndex();
-
- //4. read back the updated entity, make sure it is accurate
-
-
-
-
-
- }
-
- /**
- * Test exceptions for entities with poorly created geo points
- * 1. misspell latitude
- * 2. misspell longitude
- */
- @Test
- public void createEntitiesWithBadSpelling() throws IOException {
-
- String collectionType = "stores";
- JsonNode node = null;
- Double lat = 37.776753;
- Double lon = -122.407846;
-
- // 1. misspell latitude
- Map<String, Double> misspelledLatitude = hashMap("latitudee", lat);
- misspelledLatitude.put( "longitude", lon );
- Map<String, Object> misspelledLatitudeEntityData = new HashMap<String, Object>();
- misspelledLatitudeEntityData.put( "location", misspelledLatitude );
-
- try {
- node = context.collection( collectionType ).post( misspelledLatitudeEntityData );
- fail("System allowed misspelled location property - latitudee, which it should not");
- }
- catch ( UniformInterfaceException e ) {
- //verify the correct error was returned
- JsonNode nodeError = mapper.readTree( e.getResponse().getEntity( String.class ));
- assertEquals( "illegal_argument", nodeError.get( "error" ).textValue() );
- }
-
- // 2. misspell longitude
- Map<String, Double> misspelledLongitude = hashMap("latitude", lat);
- misspelledLongitude.put( "longitudee", lon );
- Map<String, Object> misspelledLongitudeEntityData = new HashMap<String, Object>();
- misspelledLongitudeEntityData.put( "location", misspelledLongitude );
-
- try {
- node = context.collection( collectionType ).post( misspelledLongitudeEntityData );
- fail("System allowed misspelled location property - longitudee, which it should not");
- }
- catch ( UniformInterfaceException e ) {
- //verify the correct error was returned
- JsonNode nodeError = mapper.readTree( e.getResponse().getEntity( String.class ));
- assertEquals( "illegal_argument", nodeError.get( "error" ).textValue() );
- }
-
- }
-
-
- /**
- * Test exceptions for entities with poorly created geo points
- * 1. pass only one point instead of two
- * 2. pass a values that are not doubles
- */
- @Test
- public void createEntitiesWithBadPoints() throws IOException {
-
- String collectionType = "stores";
- JsonNode node = null;
- Double lat = 37.776753;
- Double lon = -122.407846;
-
- // 1. pass only one point instead of two
- Map<String, Double> latitudeOnly = hashMap("latitude", lat);
- Map<String, Object> latitudeOnlyEntityData = new HashMap<String, Object>();
- latitudeOnlyEntityData.put( "location", latitudeOnly );
-
- try {
- node = context.collection( collectionType ).post( latitudeOnlyEntityData );
- fail("System allowed location with only one point, latitude, which it should not");
- }
- catch ( UniformInterfaceException e ) {
- //verify the correct error was returned
- JsonNode nodeError = mapper.readTree( e.getResponse().getEntity( String.class ));
- assertEquals( "illegal_argument", nodeError.get( "error" ).textValue() );
- }
-
- // 2. pass a values that are not doubles
- Map<String, String> notDoubleLatLon = hashMap("latitude", "fred");
- notDoubleLatLon.put( "longitude", "barney" );
- Map<String, Object> notDoubleLatLonEntityData = new HashMap<String, Object>();
- notDoubleLatLonEntityData.put( "location", notDoubleLatLon );
-
- try {
- node = context.collection( collectionType ).post( notDoubleLatLonEntityData );
- fail("System allowed misspelled location values that are not doubles for latitude and longitude, which it should not");
- }
- catch ( UniformInterfaceException e ) {
- //verify the correct error was returned
- JsonNode nodeError = mapper.readTree( e.getResponse().getEntity( String.class ));
- assertEquals( "illegal_argument", nodeError.get( "error" ).textValue() );
- }
-
-
- }
-
-}
[44/50] [abbrv] incubator-usergrid git commit: Adding missing headers
and cleaning up imports only.
Posted by sn...@apache.org.
Adding missing headers and cleaning up imports only.
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/5d86227b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/5d86227b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/5d86227b
Branch: refs/heads/two-dot-o-events
Commit: 5d86227b011412d51c7b5e0c8f807e1af3e7105d
Parents: 277eb73
Author: Dave Johnson <dm...@apigee.com>
Authored: Wed Dec 3 07:46:18 2014 -0500
Committer: Dave Johnson <dm...@apigee.com>
Committed: Wed Dec 3 07:46:18 2014 -0500
----------------------------------------------------------------------
.../core/astyanax/BucketScopedRowKey.java | 3 +-
.../core/astyanax/CassandraConfig.java | 18 ++++++++++
.../core/astyanax/ColumnNameIterator.java | 1 -
.../persistence/core/astyanax/ColumnSearch.java | 30 ++++++++---------
.../persistence/core/astyanax/ColumnTypes.java | 19 ++++++++++-
.../core/astyanax/FieldBufferBuilder.java | 1 -
.../astyanax/MultiKeyColumnNameIterator.java | 2 --
.../core/astyanax/MultiRowColumnIterator.java | 4 ---
.../core/astyanax/MultiTennantColumnFamily.java | 1 -
.../persistence/core/astyanax/ScopedRowKey.java | 1 -
.../astyanax/StringRowCompositeSerializer.java | 35 ++++++++------------
.../core/hystrix/HystrixCassandra.java | 3 --
.../core/migration/data/DataMigration.java | 31 ++++++++---------
.../migration/data/DataMigrationException.java | 30 ++++++++---------
.../migration/data/DataMigrationManager.java | 30 ++++++++---------
.../data/DataMigrationManagerImpl.java | 3 --
.../data/MigrationInfoSerialization.java | 31 ++++++++---------
.../data/MigrationInfoSerializationImpl.java | 31 ++++++++---------
.../migration/schema/MigrationManagerFig.java | 18 ++++++++++
.../migration/schema/MigrationManagerImpl.java | 18 ++++++++++
.../core/shard/ExpandingShardLocator.java | 23 ++-----------
.../persistence/core/shard/StringHashUtils.java | 22 +-----------
.../usergrid/persistence/core/task/Task.java | 19 ++++++++++-
.../persistence/core/task/TaskExecutor.java | 18 ++++++++++
24 files changed, 211 insertions(+), 181 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/5d86227b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/BucketScopedRowKey.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/BucketScopedRowKey.java b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/BucketScopedRowKey.java
index 265afa5..a20b710 100644
--- a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/BucketScopedRowKey.java
+++ b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/BucketScopedRowKey.java
@@ -1,4 +1,4 @@
-package org.apache.usergrid.persistence.core.astyanax;/*
+/*
* 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
@@ -18,6 +18,7 @@ package org.apache.usergrid.persistence.core.astyanax;/*
*/
+package org.apache.usergrid.persistence.core.astyanax;
import java.util.ArrayList;
import java.util.List;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/5d86227b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/CassandraConfig.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/CassandraConfig.java b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/CassandraConfig.java
index 0ce7df1..ad4463a 100644
--- a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/CassandraConfig.java
+++ b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/CassandraConfig.java
@@ -1,3 +1,21 @@
+/*
+ * 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.core.astyanax;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/5d86227b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/ColumnNameIterator.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/ColumnNameIterator.java b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/ColumnNameIterator.java
index 6256e9c..b38ffda 100644
--- a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/ColumnNameIterator.java
+++ b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/ColumnNameIterator.java
@@ -25,7 +25,6 @@ import java.util.NoSuchElementException;
import com.netflix.astyanax.connectionpool.exceptions.ConnectionException;
import com.netflix.astyanax.model.Column;
import com.netflix.astyanax.query.RowQuery;
-import com.netflix.hystrix.HystrixCommandGroupKey;
/**
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/5d86227b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/ColumnSearch.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/ColumnSearch.java b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/ColumnSearch.java
index 41ee7c4..112f4aa 100644
--- a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/ColumnSearch.java
+++ b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/ColumnSearch.java
@@ -1,22 +1,20 @@
/*
+ * 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
*
- * * 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.
+ * 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.core.astyanax;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/5d86227b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/ColumnTypes.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/ColumnTypes.java b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/ColumnTypes.java
index a055ca7..3f29f78 100644
--- a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/ColumnTypes.java
+++ b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/ColumnTypes.java
@@ -1,7 +1,24 @@
+/*
+ * 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.core.astyanax;
-import org.apache.cassandra.db.marshal.BooleanType;
import org.apache.cassandra.db.marshal.DynamicCompositeType;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/5d86227b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/FieldBufferBuilder.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/FieldBufferBuilder.java b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/FieldBufferBuilder.java
index 88cfb62..fc4b13f 100644
--- a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/FieldBufferBuilder.java
+++ b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/FieldBufferBuilder.java
@@ -20,7 +20,6 @@
package org.apache.usergrid.persistence.core.astyanax;
-import com.netflix.astyanax.serializers.ByteBufferSerializer;
import com.netflix.astyanax.serializers.ByteSerializer;
import com.netflix.astyanax.serializers.BytesArraySerializer;
import com.netflix.astyanax.serializers.IntegerSerializer;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/5d86227b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/MultiKeyColumnNameIterator.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/MultiKeyColumnNameIterator.java b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/MultiKeyColumnNameIterator.java
index 16ae97a..15f9aab 100644
--- a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/MultiKeyColumnNameIterator.java
+++ b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/MultiKeyColumnNameIterator.java
@@ -35,10 +35,8 @@ import org.apache.usergrid.persistence.core.rx.OrderedMerge;
import com.amazonaws.services.redshift.model.UnsupportedOptionException;
-import rx.Notification;
import rx.Observable;
import rx.Subscriber;
-import rx.functions.Action1;
import rx.schedulers.Schedulers;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/5d86227b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/MultiRowColumnIterator.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/MultiRowColumnIterator.java b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/MultiRowColumnIterator.java
index 46405ad..fdc4768 100644
--- a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/MultiRowColumnIterator.java
+++ b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/MultiRowColumnIterator.java
@@ -27,16 +27,12 @@ import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.Iterator;
-import java.util.LinkedHashSet;
import java.util.List;
import java.util.NoSuchElementException;
-import java.util.Set;
-import java.util.TreeSet;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.apache.commons.collections4.iterators.PushbackIterator;
import org.apache.usergrid.persistence.core.hystrix.HystrixCassandra;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/5d86227b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/MultiTennantColumnFamily.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/MultiTennantColumnFamily.java b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/MultiTennantColumnFamily.java
index faaa76d..38851a5 100644
--- a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/MultiTennantColumnFamily.java
+++ b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/MultiTennantColumnFamily.java
@@ -19,7 +19,6 @@
package org.apache.usergrid.persistence.core.astyanax;
-import org.apache.usergrid.persistence.core.scope.ApplicationScope;
import com.netflix.astyanax.Serializer;
import com.netflix.astyanax.model.ColumnFamily;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/5d86227b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/ScopedRowKey.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/ScopedRowKey.java b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/ScopedRowKey.java
index 2fe7259..b1eef87 100644
--- a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/ScopedRowKey.java
+++ b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/ScopedRowKey.java
@@ -19,7 +19,6 @@
package org.apache.usergrid.persistence.core.astyanax;
-import org.apache.usergrid.persistence.core.scope.ApplicationScope;
import org.apache.usergrid.persistence.model.entity.Id;
import com.google.common.base.Preconditions;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/5d86227b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/StringRowCompositeSerializer.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/StringRowCompositeSerializer.java b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/StringRowCompositeSerializer.java
index 3a246a5..ef7f19d 100644
--- a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/StringRowCompositeSerializer.java
+++ b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/StringRowCompositeSerializer.java
@@ -1,31 +1,24 @@
/*
+ * 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
*
- * * 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.
+ * 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.core.astyanax;
-import java.util.UUID;
-
-import org.apache.usergrid.persistence.model.entity.Id;
-import org.apache.usergrid.persistence.model.entity.SimpleId;
-
import com.netflix.astyanax.model.CompositeBuilder;
import com.netflix.astyanax.model.CompositeParser;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/5d86227b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/hystrix/HystrixCassandra.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/hystrix/HystrixCassandra.java b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/hystrix/HystrixCassandra.java
index 356850e..7d5316f 100644
--- a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/hystrix/HystrixCassandra.java
+++ b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/hystrix/HystrixCassandra.java
@@ -21,11 +21,8 @@ package org.apache.usergrid.persistence.core.hystrix;
import com.netflix.astyanax.Execution;
-import com.netflix.astyanax.MutationBatch;
import com.netflix.astyanax.connectionpool.OperationResult;
import com.netflix.astyanax.connectionpool.exceptions.ConnectionException;
-import com.netflix.astyanax.model.ColumnList;
-import com.netflix.astyanax.query.RowQuery;
import com.netflix.hystrix.HystrixCommand;
import com.netflix.hystrix.HystrixCommandGroupKey;
import com.netflix.hystrix.HystrixThreadPoolProperties;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/5d86227b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/DataMigration.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/DataMigration.java b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/DataMigration.java
index ecf9946..775df5d 100644
--- a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/DataMigration.java
+++ b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/DataMigration.java
@@ -1,24 +1,21 @@
/*
+ * 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
*
- * * 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.
+ * 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.core.migration.data;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/5d86227b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/DataMigrationException.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/DataMigrationException.java b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/DataMigrationException.java
index 0e1f29f..104ef95 100644
--- a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/DataMigrationException.java
+++ b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/DataMigrationException.java
@@ -1,22 +1,20 @@
/*
+ * 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
*
- * * 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.
+ * 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.core.migration.data;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/5d86227b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/DataMigrationManager.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/DataMigrationManager.java b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/DataMigrationManager.java
index c633a08..e47e264 100644
--- a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/DataMigrationManager.java
+++ b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/DataMigrationManager.java
@@ -1,22 +1,20 @@
/*
+ * 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
*
- * * 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.
+ * 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.core.migration.data;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/5d86227b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/DataMigrationManagerImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/DataMigrationManagerImpl.java b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/DataMigrationManagerImpl.java
index 38c24e4..b9cc851 100644
--- a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/DataMigrationManagerImpl.java
+++ b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/DataMigrationManagerImpl.java
@@ -1,5 +1,4 @@
/*
- *
* 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
@@ -16,9 +15,7 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- *
*/
-
package org.apache.usergrid.persistence.core.migration.data;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/5d86227b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/MigrationInfoSerialization.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/MigrationInfoSerialization.java b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/MigrationInfoSerialization.java
index 5cd8a76..db2a747 100644
--- a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/MigrationInfoSerialization.java
+++ b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/MigrationInfoSerialization.java
@@ -1,24 +1,21 @@
/*
+ * 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
*
- * * 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.
+ * 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.core.migration.data;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/5d86227b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/MigrationInfoSerializationImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/MigrationInfoSerializationImpl.java b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/MigrationInfoSerializationImpl.java
index 5dbadee..603ebb3 100644
--- a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/MigrationInfoSerializationImpl.java
+++ b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/MigrationInfoSerializationImpl.java
@@ -1,24 +1,21 @@
/*
+ * 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
*
- * * 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.
+ * 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.core.migration.data;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/5d86227b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/schema/MigrationManagerFig.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/schema/MigrationManagerFig.java b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/schema/MigrationManagerFig.java
index 9595020..b95338a 100644
--- a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/schema/MigrationManagerFig.java
+++ b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/schema/MigrationManagerFig.java
@@ -1,3 +1,21 @@
+/*
+ * 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.core.migration.schema;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/5d86227b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/schema/MigrationManagerImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/schema/MigrationManagerImpl.java b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/schema/MigrationManagerImpl.java
index 70ab713..346d2c9 100644
--- a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/schema/MigrationManagerImpl.java
+++ b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/schema/MigrationManagerImpl.java
@@ -1,3 +1,21 @@
+/*
+ * 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.core.migration.schema;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/5d86227b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/shard/ExpandingShardLocator.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/shard/ExpandingShardLocator.java b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/shard/ExpandingShardLocator.java
index 02d4d1e..1fadf9f 100644
--- a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/shard/ExpandingShardLocator.java
+++ b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/shard/ExpandingShardLocator.java
@@ -1,25 +1,4 @@
/*
- *
- * * 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.core.shard;/*
* 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
@@ -38,6 +17,8 @@ package org.apache.usergrid.persistence.core.shard;/*
* under the License.
*/
+package org.apache.usergrid.persistence.core.shard;
+
import com.google.common.hash.Funnel;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/5d86227b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/shard/StringHashUtils.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/shard/StringHashUtils.java b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/shard/StringHashUtils.java
index afe94a9..b033dbd 100644
--- a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/shard/StringHashUtils.java
+++ b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/shard/StringHashUtils.java
@@ -1,25 +1,4 @@
/*
- *
- * * 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.core.shard;/*
* 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
@@ -38,6 +17,7 @@ package org.apache.usergrid.persistence.core.shard;/*
* under the License.
*/
+package org.apache.usergrid.persistence.core.shard;
import java.nio.charset.Charset;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/5d86227b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/task/Task.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/task/Task.java b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/task/Task.java
index 5890627..5582161 100644
--- a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/task/Task.java
+++ b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/task/Task.java
@@ -1,8 +1,25 @@
+/*
+ * 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.core.task;
import java.util.concurrent.Callable;
-import java.util.concurrent.RecursiveTask;
/**
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/5d86227b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/task/TaskExecutor.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/task/TaskExecutor.java b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/task/TaskExecutor.java
index aaa9d60..5e9aa4c 100644
--- a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/task/TaskExecutor.java
+++ b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/task/TaskExecutor.java
@@ -1,3 +1,21 @@
+/*
+ * 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.core.task;
[35/50] [abbrv] incubator-usergrid git commit: Merge remote-tracking
branch 'origin/two-dot-o' into USERGRID-252
Posted by sn...@apache.org.
Merge remote-tracking branch 'origin/two-dot-o' into USERGRID-252
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/e3a2595a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/e3a2595a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/e3a2595a
Branch: refs/heads/two-dot-o-events
Commit: e3a2595a46f1b17c6443440acc9cc4ac9ffe20bf
Parents: 2e1d8bd de455c3
Author: Todd Nine <tn...@apigee.com>
Authored: Mon Dec 1 15:26:11 2014 -0700
Committer: Todd Nine <tn...@apigee.com>
Committed: Mon Dec 1 15:26:11 2014 -0700
----------------------------------------------------------------------
.../rest/management/users/UsersResource.java | 38 ++-
.../applications/queries/BasicGeoTests.java | 268 +++++++++++++++++++
.../applications/queries/basicGeoTests.java | 184 -------------
3 files changed, 292 insertions(+), 198 deletions(-)
----------------------------------------------------------------------
[45/50] [abbrv] incubator-usergrid git commit: Adding missing headers
and cleaning up imports only.
Posted by sn...@apache.org.
Adding missing headers and cleaning up imports only.
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/5d86227b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/5d86227b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/5d86227b
Branch: refs/heads/two-dot-o
Commit: 5d86227b011412d51c7b5e0c8f807e1af3e7105d
Parents: 277eb73
Author: Dave Johnson <dm...@apigee.com>
Authored: Wed Dec 3 07:46:18 2014 -0500
Committer: Dave Johnson <dm...@apigee.com>
Committed: Wed Dec 3 07:46:18 2014 -0500
----------------------------------------------------------------------
.../core/astyanax/BucketScopedRowKey.java | 3 +-
.../core/astyanax/CassandraConfig.java | 18 ++++++++++
.../core/astyanax/ColumnNameIterator.java | 1 -
.../persistence/core/astyanax/ColumnSearch.java | 30 ++++++++---------
.../persistence/core/astyanax/ColumnTypes.java | 19 ++++++++++-
.../core/astyanax/FieldBufferBuilder.java | 1 -
.../astyanax/MultiKeyColumnNameIterator.java | 2 --
.../core/astyanax/MultiRowColumnIterator.java | 4 ---
.../core/astyanax/MultiTennantColumnFamily.java | 1 -
.../persistence/core/astyanax/ScopedRowKey.java | 1 -
.../astyanax/StringRowCompositeSerializer.java | 35 ++++++++------------
.../core/hystrix/HystrixCassandra.java | 3 --
.../core/migration/data/DataMigration.java | 31 ++++++++---------
.../migration/data/DataMigrationException.java | 30 ++++++++---------
.../migration/data/DataMigrationManager.java | 30 ++++++++---------
.../data/DataMigrationManagerImpl.java | 3 --
.../data/MigrationInfoSerialization.java | 31 ++++++++---------
.../data/MigrationInfoSerializationImpl.java | 31 ++++++++---------
.../migration/schema/MigrationManagerFig.java | 18 ++++++++++
.../migration/schema/MigrationManagerImpl.java | 18 ++++++++++
.../core/shard/ExpandingShardLocator.java | 23 ++-----------
.../persistence/core/shard/StringHashUtils.java | 22 +-----------
.../usergrid/persistence/core/task/Task.java | 19 ++++++++++-
.../persistence/core/task/TaskExecutor.java | 18 ++++++++++
24 files changed, 211 insertions(+), 181 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/5d86227b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/BucketScopedRowKey.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/BucketScopedRowKey.java b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/BucketScopedRowKey.java
index 265afa5..a20b710 100644
--- a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/BucketScopedRowKey.java
+++ b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/BucketScopedRowKey.java
@@ -1,4 +1,4 @@
-package org.apache.usergrid.persistence.core.astyanax;/*
+/*
* 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
@@ -18,6 +18,7 @@ package org.apache.usergrid.persistence.core.astyanax;/*
*/
+package org.apache.usergrid.persistence.core.astyanax;
import java.util.ArrayList;
import java.util.List;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/5d86227b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/CassandraConfig.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/CassandraConfig.java b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/CassandraConfig.java
index 0ce7df1..ad4463a 100644
--- a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/CassandraConfig.java
+++ b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/CassandraConfig.java
@@ -1,3 +1,21 @@
+/*
+ * 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.core.astyanax;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/5d86227b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/ColumnNameIterator.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/ColumnNameIterator.java b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/ColumnNameIterator.java
index 6256e9c..b38ffda 100644
--- a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/ColumnNameIterator.java
+++ b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/ColumnNameIterator.java
@@ -25,7 +25,6 @@ import java.util.NoSuchElementException;
import com.netflix.astyanax.connectionpool.exceptions.ConnectionException;
import com.netflix.astyanax.model.Column;
import com.netflix.astyanax.query.RowQuery;
-import com.netflix.hystrix.HystrixCommandGroupKey;
/**
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/5d86227b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/ColumnSearch.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/ColumnSearch.java b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/ColumnSearch.java
index 41ee7c4..112f4aa 100644
--- a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/ColumnSearch.java
+++ b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/ColumnSearch.java
@@ -1,22 +1,20 @@
/*
+ * 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
*
- * * 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.
+ * 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.core.astyanax;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/5d86227b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/ColumnTypes.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/ColumnTypes.java b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/ColumnTypes.java
index a055ca7..3f29f78 100644
--- a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/ColumnTypes.java
+++ b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/ColumnTypes.java
@@ -1,7 +1,24 @@
+/*
+ * 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.core.astyanax;
-import org.apache.cassandra.db.marshal.BooleanType;
import org.apache.cassandra.db.marshal.DynamicCompositeType;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/5d86227b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/FieldBufferBuilder.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/FieldBufferBuilder.java b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/FieldBufferBuilder.java
index 88cfb62..fc4b13f 100644
--- a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/FieldBufferBuilder.java
+++ b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/FieldBufferBuilder.java
@@ -20,7 +20,6 @@
package org.apache.usergrid.persistence.core.astyanax;
-import com.netflix.astyanax.serializers.ByteBufferSerializer;
import com.netflix.astyanax.serializers.ByteSerializer;
import com.netflix.astyanax.serializers.BytesArraySerializer;
import com.netflix.astyanax.serializers.IntegerSerializer;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/5d86227b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/MultiKeyColumnNameIterator.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/MultiKeyColumnNameIterator.java b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/MultiKeyColumnNameIterator.java
index 16ae97a..15f9aab 100644
--- a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/MultiKeyColumnNameIterator.java
+++ b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/MultiKeyColumnNameIterator.java
@@ -35,10 +35,8 @@ import org.apache.usergrid.persistence.core.rx.OrderedMerge;
import com.amazonaws.services.redshift.model.UnsupportedOptionException;
-import rx.Notification;
import rx.Observable;
import rx.Subscriber;
-import rx.functions.Action1;
import rx.schedulers.Schedulers;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/5d86227b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/MultiRowColumnIterator.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/MultiRowColumnIterator.java b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/MultiRowColumnIterator.java
index 46405ad..fdc4768 100644
--- a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/MultiRowColumnIterator.java
+++ b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/MultiRowColumnIterator.java
@@ -27,16 +27,12 @@ import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.Iterator;
-import java.util.LinkedHashSet;
import java.util.List;
import java.util.NoSuchElementException;
-import java.util.Set;
-import java.util.TreeSet;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.apache.commons.collections4.iterators.PushbackIterator;
import org.apache.usergrid.persistence.core.hystrix.HystrixCassandra;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/5d86227b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/MultiTennantColumnFamily.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/MultiTennantColumnFamily.java b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/MultiTennantColumnFamily.java
index faaa76d..38851a5 100644
--- a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/MultiTennantColumnFamily.java
+++ b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/MultiTennantColumnFamily.java
@@ -19,7 +19,6 @@
package org.apache.usergrid.persistence.core.astyanax;
-import org.apache.usergrid.persistence.core.scope.ApplicationScope;
import com.netflix.astyanax.Serializer;
import com.netflix.astyanax.model.ColumnFamily;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/5d86227b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/ScopedRowKey.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/ScopedRowKey.java b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/ScopedRowKey.java
index 2fe7259..b1eef87 100644
--- a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/ScopedRowKey.java
+++ b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/ScopedRowKey.java
@@ -19,7 +19,6 @@
package org.apache.usergrid.persistence.core.astyanax;
-import org.apache.usergrid.persistence.core.scope.ApplicationScope;
import org.apache.usergrid.persistence.model.entity.Id;
import com.google.common.base.Preconditions;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/5d86227b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/StringRowCompositeSerializer.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/StringRowCompositeSerializer.java b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/StringRowCompositeSerializer.java
index 3a246a5..ef7f19d 100644
--- a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/StringRowCompositeSerializer.java
+++ b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/StringRowCompositeSerializer.java
@@ -1,31 +1,24 @@
/*
+ * 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
*
- * * 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.
+ * 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.core.astyanax;
-import java.util.UUID;
-
-import org.apache.usergrid.persistence.model.entity.Id;
-import org.apache.usergrid.persistence.model.entity.SimpleId;
-
import com.netflix.astyanax.model.CompositeBuilder;
import com.netflix.astyanax.model.CompositeParser;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/5d86227b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/hystrix/HystrixCassandra.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/hystrix/HystrixCassandra.java b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/hystrix/HystrixCassandra.java
index 356850e..7d5316f 100644
--- a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/hystrix/HystrixCassandra.java
+++ b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/hystrix/HystrixCassandra.java
@@ -21,11 +21,8 @@ package org.apache.usergrid.persistence.core.hystrix;
import com.netflix.astyanax.Execution;
-import com.netflix.astyanax.MutationBatch;
import com.netflix.astyanax.connectionpool.OperationResult;
import com.netflix.astyanax.connectionpool.exceptions.ConnectionException;
-import com.netflix.astyanax.model.ColumnList;
-import com.netflix.astyanax.query.RowQuery;
import com.netflix.hystrix.HystrixCommand;
import com.netflix.hystrix.HystrixCommandGroupKey;
import com.netflix.hystrix.HystrixThreadPoolProperties;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/5d86227b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/DataMigration.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/DataMigration.java b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/DataMigration.java
index ecf9946..775df5d 100644
--- a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/DataMigration.java
+++ b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/DataMigration.java
@@ -1,24 +1,21 @@
/*
+ * 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
*
- * * 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.
+ * 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.core.migration.data;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/5d86227b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/DataMigrationException.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/DataMigrationException.java b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/DataMigrationException.java
index 0e1f29f..104ef95 100644
--- a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/DataMigrationException.java
+++ b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/DataMigrationException.java
@@ -1,22 +1,20 @@
/*
+ * 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
*
- * * 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.
+ * 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.core.migration.data;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/5d86227b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/DataMigrationManager.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/DataMigrationManager.java b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/DataMigrationManager.java
index c633a08..e47e264 100644
--- a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/DataMigrationManager.java
+++ b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/DataMigrationManager.java
@@ -1,22 +1,20 @@
/*
+ * 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
*
- * * 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.
+ * 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.core.migration.data;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/5d86227b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/DataMigrationManagerImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/DataMigrationManagerImpl.java b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/DataMigrationManagerImpl.java
index 38c24e4..b9cc851 100644
--- a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/DataMigrationManagerImpl.java
+++ b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/DataMigrationManagerImpl.java
@@ -1,5 +1,4 @@
/*
- *
* 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
@@ -16,9 +15,7 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- *
*/
-
package org.apache.usergrid.persistence.core.migration.data;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/5d86227b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/MigrationInfoSerialization.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/MigrationInfoSerialization.java b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/MigrationInfoSerialization.java
index 5cd8a76..db2a747 100644
--- a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/MigrationInfoSerialization.java
+++ b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/MigrationInfoSerialization.java
@@ -1,24 +1,21 @@
/*
+ * 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
*
- * * 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.
+ * 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.core.migration.data;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/5d86227b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/MigrationInfoSerializationImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/MigrationInfoSerializationImpl.java b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/MigrationInfoSerializationImpl.java
index 5dbadee..603ebb3 100644
--- a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/MigrationInfoSerializationImpl.java
+++ b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/MigrationInfoSerializationImpl.java
@@ -1,24 +1,21 @@
/*
+ * 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
*
- * * 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.
+ * 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.core.migration.data;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/5d86227b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/schema/MigrationManagerFig.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/schema/MigrationManagerFig.java b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/schema/MigrationManagerFig.java
index 9595020..b95338a 100644
--- a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/schema/MigrationManagerFig.java
+++ b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/schema/MigrationManagerFig.java
@@ -1,3 +1,21 @@
+/*
+ * 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.core.migration.schema;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/5d86227b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/schema/MigrationManagerImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/schema/MigrationManagerImpl.java b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/schema/MigrationManagerImpl.java
index 70ab713..346d2c9 100644
--- a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/schema/MigrationManagerImpl.java
+++ b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/schema/MigrationManagerImpl.java
@@ -1,3 +1,21 @@
+/*
+ * 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.core.migration.schema;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/5d86227b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/shard/ExpandingShardLocator.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/shard/ExpandingShardLocator.java b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/shard/ExpandingShardLocator.java
index 02d4d1e..1fadf9f 100644
--- a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/shard/ExpandingShardLocator.java
+++ b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/shard/ExpandingShardLocator.java
@@ -1,25 +1,4 @@
/*
- *
- * * 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.core.shard;/*
* 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
@@ -38,6 +17,8 @@ package org.apache.usergrid.persistence.core.shard;/*
* under the License.
*/
+package org.apache.usergrid.persistence.core.shard;
+
import com.google.common.hash.Funnel;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/5d86227b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/shard/StringHashUtils.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/shard/StringHashUtils.java b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/shard/StringHashUtils.java
index afe94a9..b033dbd 100644
--- a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/shard/StringHashUtils.java
+++ b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/shard/StringHashUtils.java
@@ -1,25 +1,4 @@
/*
- *
- * * 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.core.shard;/*
* 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
@@ -38,6 +17,7 @@ package org.apache.usergrid.persistence.core.shard;/*
* under the License.
*/
+package org.apache.usergrid.persistence.core.shard;
import java.nio.charset.Charset;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/5d86227b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/task/Task.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/task/Task.java b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/task/Task.java
index 5890627..5582161 100644
--- a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/task/Task.java
+++ b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/task/Task.java
@@ -1,8 +1,25 @@
+/*
+ * 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.core.task;
import java.util.concurrent.Callable;
-import java.util.concurrent.RecursiveTask;
/**
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/5d86227b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/task/TaskExecutor.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/task/TaskExecutor.java b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/task/TaskExecutor.java
index aaa9d60..5e9aa4c 100644
--- a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/task/TaskExecutor.java
+++ b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/task/TaskExecutor.java
@@ -1,3 +1,21 @@
+/*
+ * 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.core.task;
[40/50] [abbrv] incubator-usergrid git commit: Merge branch
'two-dot-o' into no-source-in-es
Posted by sn...@apache.org.
Merge branch 'two-dot-o' into no-source-in-es
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/716793f6
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/716793f6
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/716793f6
Branch: refs/heads/no-source-in-es
Commit: 716793f6ede2de3d4e122f8af73229cfea2ef9a8
Parents: 5ba1e7e 277eb73
Author: Dave Johnson <dm...@apigee.com>
Authored: Tue Dec 2 07:32:46 2014 -0500
Committer: Dave Johnson <dm...@apigee.com>
Committed: Tue Dec 2 07:32:46 2014 -0500
----------------------------------------------------------------------
.../rest/management/users/UsersResource.java | 38 ++++++++++++--------
1 file changed, 24 insertions(+), 14 deletions(-)
----------------------------------------------------------------------
[10/50] [abbrv] incubator-usergrid git commit: cleaned up location
map processing - added exceptions + REST tests to verify success and
exceptions
Posted by sn...@apache.org.
cleaned up location map processing - added exceptions + REST tests to verify success and exceptions
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/bd0a1e97
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/bd0a1e97
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/bd0a1e97
Branch: refs/heads/two-dot-o-events
Commit: bd0a1e97b56639f93b1260ff7fe4abd1e510f2f4
Parents: 3e21011
Author: Rod Simpson <ro...@apigee.com>
Authored: Fri Nov 21 17:42:35 2014 -0700
Committer: Rod Simpson <ro...@apigee.com>
Committed: Fri Nov 21 17:42:35 2014 -0700
----------------------------------------------------------------------
.../corepersistence/util/CpEntityMapUtils.java | 62 ++++---
.../persistence/model/field/LocationField.java | 3 -
.../index/impl/EntityIndexMapUtils.java | 4 +-
.../collection/groups/GroupResourceIT.java | 182 +-----------------
.../applications/queries/GeoPagingTest.java | 41 +++--
.../applications/queries/basicGeoTests.java | 184 +++++++++++++++++++
6 files changed, 251 insertions(+), 225 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/bd0a1e97/stack/core/src/main/java/org/apache/usergrid/corepersistence/util/CpEntityMapUtils.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/util/CpEntityMapUtils.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/util/CpEntityMapUtils.java
index c110509..ba59154 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/util/CpEntityMapUtils.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/util/CpEntityMapUtils.java
@@ -137,37 +137,45 @@ public class CpEntityMapUtils {
private static void processMapValue(
Object value, String fieldName, Entity entity, String entityType) {
- Field field = null;
-
// is the map really a location element?
- Map<String, Object> m = (Map<String, Object>)value;
- if ( m.size() == 2) {
- Double lat = null;
- Double lon = null;
- try {
- if ( m.get("latitude") != null && m.get("longitude") != null ) {
- lat = Double.parseDouble( m.get("latitude").toString() );
- lon = Double.parseDouble( m.get("longitude").toString() );
-
- } else if ( m.get("lat") != null && m.get("lon") != null ) {
- lat = Double.parseDouble( m.get("lat").toString() );
- lon = Double.parseDouble( m.get("lon").toString() );
+ if ("location" .equals(fieldName.toString().toLowerCase()) ) {
+ // get the object to inspect
+ Map<String, Object> m = (Map<String, Object>) value;
+ // should have two elements
+ if (m.size() == 2) {
+ Double lat = null;
+ Double lon = null;
+ // check the properties to make sure they are set and are doubles
+ if (m.get("latitude") != null && m.get("longitude") != null) {
+ try {
+ lat = Double.parseDouble(m.get("latitude").toString());
+ lon = Double.parseDouble(m.get("longitude").toString());
+ } catch (NumberFormatException ignored) {
+ throw new IllegalArgumentException("Latitude and longitude must be doubles (e.g. 32.1234).");
+ }
+ } else if (m.get("lat") != null && m.get("lon") != null) {
+ try {
+ lat = Double.parseDouble(m.get("lat").toString());
+ lon = Double.parseDouble(m.get("lon").toString());
+ } catch (NumberFormatException ignored) {
+ throw new IllegalArgumentException("Latitude and longitude must be doubles (e.g. 32.1234).");
+ }
+ } else {
+ throw new IllegalArgumentException("Location properties require two fields - latitude and longitude, or lat and lon");
}
- } catch ( NumberFormatException ignored ) {}
-
- if ( lat != null && lon != null ) {
- field = new LocationField( fieldName, new Location( lat, lon ));
+
+ if (lat != null && lon != null) {
+ entity.setField( new LocationField(fieldName, new Location(lat, lon)));
+ } else {
+ throw new IllegalArgumentException("Unable to parse location field properties - make sure they conform - lat and lon, and should be doubles.");
+ }
+ } else {
+ throw new IllegalArgumentException("Location properties require two fields - latitude and longitude, or lat and lon.");
}
- }
-
- if ( field == null ) {
-
- // not a location element, process it as map
- entity.setField( new EntityObjectField( fieldName,
- fromMap( (Map<String, Object>)value, entityType, false ))); // recursion
-
} else {
- entity.setField( field );
+ // not a location element, process it as map
+ entity.setField(new EntityObjectField(fieldName,
+ fromMap((Map<String, Object>) value, entityType, false))); // recursion
}
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/bd0a1e97/stack/corepersistence/model/src/main/java/org/apache/usergrid/persistence/model/field/LocationField.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/model/src/main/java/org/apache/usergrid/persistence/model/field/LocationField.java b/stack/corepersistence/model/src/main/java/org/apache/usergrid/persistence/model/field/LocationField.java
index e220099..407fd44 100644
--- a/stack/corepersistence/model/src/main/java/org/apache/usergrid/persistence/model/field/LocationField.java
+++ b/stack/corepersistence/model/src/main/java/org/apache/usergrid/persistence/model/field/LocationField.java
@@ -32,9 +32,6 @@ public class LocationField extends AbstractField<Location> {
super( name, value );
}
- public LocationField() {
-
- }
@Override
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/bd0a1e97/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityIndexMapUtils.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityIndexMapUtils.java b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityIndexMapUtils.java
index af3c7ea..6701a7c 100644
--- a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityIndexMapUtils.java
+++ b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityIndexMapUtils.java
@@ -99,8 +99,10 @@ class EntityIndexMapUtils {
} else if ( value instanceof Map ) {
- Field field = null;
+ // CpEntityMapUtils.processMapValue(value);
+ Field field = null;
+//TODO remove this and use the code in CpEntityMapUtils.java
// is the map really a location element?
Map<String, Object> m = (Map<String, Object>)value;
if ( m.size() == 2) {
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/bd0a1e97/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/groups/GroupResourceIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/groups/GroupResourceIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/groups/GroupResourceIT.java
index 5d21eb9..704ca17 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/groups/GroupResourceIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/groups/GroupResourceIT.java
@@ -143,9 +143,9 @@ public class GroupResourceIT extends AbstractRestIT {
* Verify that we cannot create a group with a space in the path
*/
@Test
- public void postGroupActivity() {
+ public void postGroupActivity() throws IOException {
+
-/*
//1. create a group
GroupsCollection groups = context.groups();
@@ -157,184 +157,17 @@ public class GroupResourceIT extends AbstractRestIT {
assertNull(testGroup.get("errors"));
assertEquals(testGroup.get("path").asText(), groupPath);
- //2.
- /*
- UUID id = UUIDUtils.newTimeUUID();
-
- String groupPath = "groupPath" + id;
- String groupTitle = "groupTitle " + id;
- String groupName = "groupName" + id;
-
- ApiResponse response = client.createGroup( groupPath, groupTitle, groupName );
-
- assertNull( "Error was: " + response.getErrorDescription(), response.getError() );
-
- refreshIndex("test-organization", "test-app");
-
- UUID newId = response.getEntities().get( 0 ).getUuid();
-
- Query results = client.queryGroups( String.format( "name='%s'", groupName ) );
-
- response = results.getResponse();
-
- UUID entityId = response.getEntities().get( 0 ).getUuid();
-
- assertEquals( newId, entityId );
-
- results = client.queryGroups( String.format( "title='%s'", groupTitle ) );
-
- response = results.getResponse();
-
- entityId = response.getEntities().get( 0 ).getUuid();
-
- assertEquals( newId, entityId );
-
- results = client.queryGroups( String.format( "title contains '%s'", id ) );
-
- response = results.getResponse();
-
- entityId = response.getEntities().get( 0 ).getUuid();
-
- assertEquals( newId, entityId );
+ //2. post group activity
- results = client.queryGroups( String.format( "path='%s'", groupPath ) );
-
- response = results.getResponse();
-
- entityId = response.getEntities().get( 0 ).getUuid();
-
- assertEquals( newId, entityId );
- */
+ //TODO: actually post a group activity
}
-}
-
-/*
- @Test(expected = IllegalArgumentException.class)
- public void failGroupNameValidation() throws IOException{
-
-
-
- //context.application().groups().group("mygroup").connection("likes").collection("users").entity("bob").post();
-
-
- /*
- Map user1 =
- hashMap( "username", "user1" ).map( "email", "testuser1@usergrid.com" ).map( "fullname", "Bob Smith" );
-
- users.create( user1 );
-
- GroupsCollection groups = context.groups();
-
- /*
- // set up context
- String orgName = context.getOrgName();
- String appName = context.getAppName();
- String path = "/"+orgName+"/"+appName+"/groups/";
-
- //-----------------------------------------------
- // 1. test for group path with slash
- //-----------------------------------------------
- String groupPath = "grouppath/slash" + UUIDUtils.newTimeUUID();
-
- String json = "{\"path\":\""+ groupPath +"\"}";
- JsonNode node = mapper.readTree( resource().path( path )
- .queryParam( "access_token", context.getActiveUser().getToken() ).accept( MediaType.APPLICATION_JSON )
- .type( MediaType.APPLICATION_JSON_TYPE ).post( String.class, json ));
-
- //verify
- assertNull( node.get( "errors" ) );
- assertEquals( node.get( "entities" ).get(0).get("path").asText(), groupPath);
- //-----------------------------------------------
- //2. test for group path with space
- //-----------------------------------------------
- groupPath = "grouppath space" + UUIDUtils.newTimeUUID();
- try {
- json = "{\"path\":\"" + groupPath + "\"}";
- node = mapper.readTree(resource().path(path)
- .queryParam("access_token", context.getActiveUser().getToken()).accept(MediaType.APPLICATION_JSON)
- .type(MediaType.APPLICATION_JSON_TYPE).post(String.class, json));
- } catch (Exception e) {
-
- //verify
- //assertNull( node.get( "errors" ) );
- String doug = node.get("error").asText();
- assertEquals( node.get("error").asText(), "illegal_argument");
- }
-
-
- refreshIndex("test-organization", "test-app");
-
- {
- boolean failed = false;
- try {
- ApiResponse groupResponse = client.createGroup( "groupName withspace" );
- failed = groupResponse.getError() != null;
- } catch ( Exception e ) {
- failed = true;
- }
- assertTrue( failed );
- }
-
- }
-
-/*
@Test
- public void postGroupActivity() {
-
- // don't populate the user, it will use the currently authenticated
- // user.
-
- UUID id = UUIDUtils.newTimeUUID();
-
- String groupPath = "groupPath" + id;
- String groupTitle = "groupTitle " + id;
- String groupName = "groupName" + id;
-
- ApiResponse response = client.createGroup( groupPath, groupTitle, groupName );
-
- assertNull( "Error was: " + response.getErrorDescription(), response.getError() );
-
- refreshIndex("test-organization", "test-app");
-
- UUID newId = response.getEntities().get( 0 ).getUuid();
-
- Query results = client.queryGroups( String.format( "name='%s'", groupName ) );
-
- response = results.getResponse();
-
- UUID entityId = response.getEntities().get( 0 ).getUuid();
-
- assertEquals( newId, entityId );
-
- results = client.queryGroups( String.format( "title='%s'", groupTitle ) );
-
- response = results.getResponse();
-
- entityId = response.getEntities().get( 0 ).getUuid();
-
- assertEquals( newId, entityId );
-
- results = client.queryGroups( String.format( "title contains '%s'", id ) );
-
- response = results.getResponse();
-
- entityId = response.getEntities().get( 0 ).getUuid();
-
- assertEquals( newId, entityId );
-
- results = client.queryGroups( String.format( "path='%s'", groupPath ) );
-
- response = results.getResponse();
-
- entityId = response.getEntities().get( 0 ).getUuid();
+ public void addRemovePermission() throws IOException {
- assertEquals( newId, entityId );
- }
+ GroupsCollection groups = context.groups();
- @Test
- public void addRemovePermission() throws IOException {
UUID id = UUIDUtils.newTimeUUID();
@@ -389,7 +222,7 @@ public class GroupResourceIT extends AbstractRestIT {
assertTrue( node.get( "data" ).size() == 0 );
}
-
+/*
@Test
public void addRemoveRole() throws IOException {
@@ -481,3 +314,4 @@ public class GroupResourceIT extends AbstractRestIT {
}
*/
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/bd0a1e97/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/GeoPagingTest.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/GeoPagingTest.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/GeoPagingTest.java
index a3b4a93..2944fce 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/GeoPagingTest.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/GeoPagingTest.java
@@ -151,25 +151,25 @@ public class GeoPagingTest extends AbstractRestIT {
public void testFarAwayLocationFromCenter() throws IOException {
JsonNode node = null;
- String collectionName = "testFarAwayLocation" + UUIDUtils.newTimeUUID();
+ String collectionType = "testFarAwayLocation" + UUIDUtils.newTimeUUID();
Point center = new Point( 37.776753, -122.407846 );
String queryClose = locationQuery( 10000, center );
- String queryFar = locationQuery( 40000000, center );
+ String queryFar = locationQuery(40000000, center);
//TODO: move test setup out of the test.
/*Create */
- createGeoUser( "usergrid", collectionName, -33.746369, 150.952183 );
+ createGeoUser( "usergrid", collectionType, -33.746369, 150.952183 );
- createGeoUser( "usergrid2", collectionName, -33.889058, 151.124024 );
+ createGeoUser( "usergrid2", collectionType, -33.889058, 151.124024 );
/* run queries */
- node = queryCollection( collectionName, queryClose );
+ node = queryCollection( collectionType, queryClose );
assertEquals( "Results from nearby, should return nothing", 0, node.get( "entities" ).size() );
- node = queryCollection( collectionName, queryFar );
+ node = queryCollection( collectionType, queryFar );
assertEquals( "Results from center point to ridiculously far", 2, node.get( "entities" ).size() );
}
@@ -182,26 +182,26 @@ public class GeoPagingTest extends AbstractRestIT {
@Test
public void testFarAwayLocationWithOneResultCloser() throws IOException {
JsonNode node = null;
- String collectionName = "testFarAwayLocation" + UUIDUtils.newTimeUUID();
+ String collectionType = "testFarAwayLocation" + UUIDUtils.newTimeUUID();
Point center = new Point( -33.746369, 150.952183 );
String queryClose = locationQuery( 10000, center );
String queryFar = locationQuery( 40000000, center );
/*Create */
- createGeoUser( "usergrid", collectionName, -33.746369, 150.952183 );
+ createGeoUser( "usergrid", collectionType, -33.746369, 150.952183 );
- createGeoUser( "usergrid2", collectionName, -33.889058, 151.124024 );
+ createGeoUser("usergrid2", collectionType, -33.889058, 151.124024);
/* run queries */
- node = queryCollection( collectionName, queryClose );
+ node = queryCollection( collectionType, queryClose );
- assertEquals( "Results from nearby, should return 1 store", 1, node.get( "entities" ).size() );
+ assertEquals("Results from nearby, should return 1 store", 1, node.get("entities").size());
- node = queryCollection( collectionName, queryFar );
+ node = queryCollection( collectionType, queryFar );
- assertEquals( "Results from center point to ridiculously far", 2, node.get( "entities" ).size() );
+ assertEquals("Results from center point to ridiculously far", 2, node.get("entities").size());
}
@@ -261,7 +261,7 @@ public class GeoPagingTest extends AbstractRestIT {
}
catch ( UniformInterfaceException e ) {
JsonNode nodeError = mapper.readTree( e.getResponse().getEntity( String.class ) );
- fail( node.get( "error" ).textValue() );
+ fail( nodeError.get( "error" ).textValue() );
}
/*
@@ -282,14 +282,14 @@ public class GeoPagingTest extends AbstractRestIT {
}
- private JsonNode queryCollection( String collectionName, String query ) throws IOException {
+ private JsonNode queryCollection( String collectionType, String query ) throws IOException {
JsonNode node = null;
try {
- node = context.collection( collectionName ).withQuery( query ).get();
+ node = context.collection( collectionType ).withQuery( query ).get();
}
catch ( UniformInterfaceException e ) {
JsonNode nodeError = mapper.readTree( e.getResponse().getEntity( String.class ) );
- fail( node.get( "error" ).textValue() );
+ fail( nodeError.get( "error" ).textValue() );
}
assertNotNull( node );
@@ -297,7 +297,7 @@ public class GeoPagingTest extends AbstractRestIT {
}
- private void createGeoUser( String username, String collectionName, Double lat, Double lon ) throws IOException {
+ private void createGeoUser( String username, String collectionType, Double lat, Double lon ) throws IOException {
JsonNode node = null;
@@ -306,11 +306,11 @@ public class GeoPagingTest extends AbstractRestIT {
user.put( "name", username );
try {
- node = context.collection( collectionName ).post( user );
+ node = context.collection( collectionType ).post( user );
}
catch ( UniformInterfaceException e ) {
JsonNode nodeError = mapper.readTree( e.getResponse().getEntity( String.class ) );
- fail( node.get( "error" ).textValue() );
+ fail( nodeError.get( "error" ).textValue() );
}
assertNotNull( node );
@@ -330,6 +330,7 @@ public class GeoPagingTest extends AbstractRestIT {
}
+
private String locationQuery( int metersAway, Point startingPoint ) {
return "select * where location within " + String.valueOf( metersAway ) + " of " + startingPoint.getLat() + ","
+ startingPoint.getLon();
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/bd0a1e97/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/basicGeoTests.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/basicGeoTests.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/basicGeoTests.java
new file mode 100644
index 0000000..e921b37
--- /dev/null
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/basicGeoTests.java
@@ -0,0 +1,184 @@
+/*
+ * 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.rest.applications.queries;
+
+
+import java.util.*;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.sun.jersey.api.client.UniformInterfaceException;
+
+import java.io.IOException;
+
+import org.apache.usergrid.persistence.Entity;
+import org.apache.usergrid.persistence.EntityManager;
+import org.apache.usergrid.persistence.Results;
+
+import org.jclouds.json.Json;
+import org.junit.Rule;
+import org.junit.Test;
+
+import org.apache.usergrid.persistence.geo.model.Point;
+import org.apache.usergrid.persistence.index.query.Query;
+import org.apache.usergrid.persistence.index.utils.UUIDUtils;
+import org.apache.usergrid.rest.AbstractRestIT;
+import org.apache.usergrid.rest.TestContextSetup;
+import org.apache.usergrid.rest.test.resource.CustomCollection;
+
+import static org.junit.Assert.assertEquals;
+import static org.apache.usergrid.utils.MapUtils.hashMap;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
+
+
+/**
+ * Basic Geo Tests - CRUD entities with geo points, exceptions for malformed calls
+ *
+ * @author rockerston
+ */
+public class basicGeoTests extends AbstractRestIT {
+
+ @Rule
+ public TestContextSetup context = new TestContextSetup( this );
+
+ public final String latitude = "latitude";
+
+ /**
+ * Create a entity with a geo location point in it
+ */
+ @Test
+ public void createEntityWithGeoLocationPoint() throws IOException {
+
+ String collectionType = "stores";
+ JsonNode node = null;
+ Double lat = 37.776753;
+ Double lon = -122.407846;
+ Map<String, Double> latLon = hashMap("latitude", lat);
+ latLon.put( "longitude", lon );
+ Map<String, Object> entityData = new HashMap<String, Object>();
+ entityData.put( "location", latLon );
+
+ try {
+ node = context.collection( collectionType ).post( entityData );
+ }
+ catch ( UniformInterfaceException e ) {
+ JsonNode nodeError = mapper.readTree( e.getResponse().getEntity( String.class ) );
+ fail( node.get( "error" ).textValue() );
+ }
+
+ assertNotNull( node );
+ assertEquals(lat.toString(), node.get("location").get("latitude").asText() );
+ assertEquals( lon.toString(), node.get( "location" ).get("longitude").asText() );
+
+ }
+
+ /**
+ * Test exceptions for entities with poorly created geo points
+ * 1. misspell latitude
+ * 2. misspell longitude
+ */
+ @Test
+ public void createEntitiesWithBadSpelling() throws IOException {
+
+ String collectionType = "stores";
+ JsonNode node = null;
+ Double lat = 37.776753;
+ Double lon = -122.407846;
+
+ // 1. misspell latitude
+ Map<String, Double> misspelledLatitude = hashMap("latitudee", lat);
+ misspelledLatitude.put( "longitude", lon );
+ Map<String, Object> misspelledLatitudeEntityData = new HashMap<String, Object>();
+ misspelledLatitudeEntityData.put( "location", misspelledLatitude );
+
+ try {
+ node = context.collection( collectionType ).post( misspelledLatitudeEntityData );
+ fail("System allowed misspelled location property - latitudee, which it should not");
+ }
+ catch ( UniformInterfaceException e ) {
+ //verify the correct error was returned
+ JsonNode nodeError = mapper.readTree( e.getResponse().getEntity( String.class ));
+ assertEquals( "illegal_argument", nodeError.get( "error" ).textValue() );
+ }
+
+ // 2. misspell longitude
+ Map<String, Double> misspelledLongitude = hashMap("latitude", lat);
+ misspelledLongitude.put( "longitudee", lon );
+ Map<String, Object> misspelledLongitudeEntityData = new HashMap<String, Object>();
+ misspelledLongitudeEntityData.put( "location", misspelledLongitude );
+
+ try {
+ node = context.collection( collectionType ).post( misspelledLongitudeEntityData );
+ fail("System allowed misspelled location property - longitudee, which it should not");
+ }
+ catch ( UniformInterfaceException e ) {
+ //verify the correct error was returned
+ JsonNode nodeError = mapper.readTree( e.getResponse().getEntity( String.class ));
+ assertEquals( "illegal_argument", nodeError.get( "error" ).textValue() );
+ }
+
+ }
+
+
+ /**
+ * Test exceptions for entities with poorly created geo points
+ * 1. pass only one point instead of two
+ * 2. pass a values that are not doubles
+ */
+ @Test
+ public void createEntitiesWithBadPoints() throws IOException {
+
+ String collectionType = "stores";
+ JsonNode node = null;
+ Double lat = 37.776753;
+ Double lon = -122.407846;
+
+ // 1. pass only one point instead of two
+ Map<String, Double> latitudeOnly = hashMap("latitude", lat);
+ Map<String, Object> latitudeOnlyEntityData = new HashMap<String, Object>();
+ latitudeOnlyEntityData.put( "location", latitudeOnly );
+
+ try {
+ node = context.collection( collectionType ).post( latitudeOnlyEntityData );
+ fail("System allowed location with only one point, latitude, which it should not");
+ }
+ catch ( UniformInterfaceException e ) {
+ //verify the correct error was returned
+ JsonNode nodeError = mapper.readTree( e.getResponse().getEntity( String.class ));
+ assertEquals( "illegal_argument", nodeError.get( "error" ).textValue() );
+ }
+
+ // 2. pass a values that are not doubles
+ Map<String, String> notDoubleLatLon = hashMap("latitude", "fred");
+ notDoubleLatLon.put( "longitude", "barney" );
+ Map<String, Object> notDoubleLatLonEntityData = new HashMap<String, Object>();
+ notDoubleLatLonEntityData.put( "location", notDoubleLatLon );
+
+ try {
+ node = context.collection( collectionType ).post( notDoubleLatLonEntityData );
+ fail("System allowed misspelled location values that are not doubles for latitude and longitude, which it should not");
+ }
+ catch ( UniformInterfaceException e ) {
+ //verify the correct error was returned
+ JsonNode nodeError = mapper.readTree( e.getResponse().getEntity( String.class ));
+ assertEquals( "illegal_argument", nodeError.get( "error" ).textValue() );
+ }
+
+
+ }
+
+}
[25/50] [abbrv] incubator-usergrid git commit: Updated NodeRegistry
to use only tags instead of external simple db
Posted by sn...@apache.org.
Updated NodeRegistry to use only tags instead of external simple db
Upgraded AWS client
Removed unused registry list groovy script
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/b12130f0
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/b12130f0
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/b12130f0
Branch: refs/heads/two-dot-o-events
Commit: b12130f06d503f8c5a3fc29d6049a4df89eb5a7e
Parents: 1f75549
Author: Todd Nine <tn...@apigee.com>
Authored: Tue Nov 25 17:38:42 2014 -0700
Committer: Todd Nine <tn...@apigee.com>
Committed: Tue Nov 25 17:38:42 2014 -0700
----------------------------------------------------------------------
stack/awscluster/gatling-cluster-cf.json | 86 +++++++---
stack/awscluster/pom.xml | 2 +-
.../src/main/groovy/NodeRegistry.groovy | 165 ++++++++++++-------
.../src/main/groovy/registry_list.groovy | 36 ----
4 files changed, 168 insertions(+), 121 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/b12130f0/stack/awscluster/gatling-cluster-cf.json
----------------------------------------------------------------------
diff --git a/stack/awscluster/gatling-cluster-cf.json b/stack/awscluster/gatling-cluster-cf.json
index ff41f14..b9f9752 100644
--- a/stack/awscluster/gatling-cluster-cf.json
+++ b/stack/awscluster/gatling-cluster-cf.json
@@ -1,53 +1,89 @@
{
"AWSTemplateFormatVersion" : "2010-09-09",
"Description" : "Gatling cluster",
-
- "Parameters" : {
+ "Parameters": {
"InstanceCount": {
- "Description" : "The number of gatling instances to create",
+ "Description": "The number of gatling instances to create",
"Type": "Number",
"Default": "1",
"MinValue": "1"
},
-
"KeyName": {
- "Description" : "Name of an existing EC2 KeyPair to enable SSH access to the instance",
+ "Description": "Name of an existing EC2 KeyPair to enable SSH access to the instance",
"Type": "AWS::EC2::KeyPair::KeyName",
- "Default" : "jenkins-east",
- "ConstraintDescription" : "must be the name of an existing EC2 KeyPair."
+ "Default": "jenkins-east",
+ "ConstraintDescription": "must be the name of an existing EC2 KeyPair."
},
-
- "InstanceType" : {
- "Description" : "WebServer EC2 instance type",
- "Type" : "String",
- "Default" : "m1.xlarge",
- "AllowedValues" : [ "t1.micro", "t2.micro", "t2.small", "t2.medium", "m1.small", "m1.medium", "m1.large", "m1.xlarge", "m2.xlarge", "m2.2xlarge", "m2.4xlarge", "m3.medium", "m3.large", "m3.xlarge", "m3.2xlarge", "c1.medium", "c1.xlarge", "c3.large", "c3.xlarge", "c3.2xlarge", "c3.4xlarge", "c3.8xlarge", "g2.2xlarge", "r3.large", "r3.xlarge", "r3.2xlarge", "r3.4xlarge", "r3.8xlarge", "i2.xlarge", "i2.2xlarge", "i2.4xlarge", "i2.8xlarge", "hi1.4xlarge", "hs1.8xlarge", "cr1.8xlarge", "cc2.8xlarge", "cg1.4xlarge"]
- ,
- "ConstraintDescription" : "must be a valid EC2 instance type."
+ "InstanceType": {
+ "Description": "WebServer EC2 instance type",
+ "Type": "String",
+ "Default": "m1.xlarge",
+ "AllowedValues": [
+ "t1.micro",
+ "t2.micro",
+ "t2.small",
+ "t2.medium",
+ "m1.small",
+ "m1.medium",
+ "m1.large",
+ "m1.xlarge",
+ "m2.xlarge",
+ "m2.2xlarge",
+ "m2.4xlarge",
+ "m3.medium",
+ "m3.large",
+ "m3.xlarge",
+ "m3.2xlarge",
+ "c1.medium",
+ "c1.xlarge",
+ "c3.large",
+ "c3.xlarge",
+ "c3.2xlarge",
+ "c3.4xlarge",
+ "c3.8xlarge",
+ "g2.2xlarge",
+ "r3.large",
+ "r3.xlarge",
+ "r3.2xlarge",
+ "r3.4xlarge",
+ "r3.8xlarge",
+ "i2.xlarge",
+ "i2.2xlarge",
+ "i2.4xlarge",
+ "i2.8xlarge",
+ "hi1.4xlarge",
+ "hs1.8xlarge",
+ "cr1.8xlarge",
+ "cc2.8xlarge",
+ "cg1.4xlarge"
+ ],
+ "ConstraintDescription": "must be a valid EC2 instance type."
},
-
"OperatorEMail": {
"Description": "EMail address to notify if there are any scaling operations",
"Type": "String",
"AllowedPattern": "([a-zA-Z0-9_\\-\\.]+)@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.)|(([a-zA-Z0-9\\-]+\\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)",
"ConstraintDescription": "must be a valid email address.",
- "Default":"rbridges@apigee.com"
+ "Default": "rbridges@apigee.com"
},
-
"ReleaseBucket": {
"Description": "S3 Bucket where Usergrid assembly is to be found.",
"Type": "String",
"Default": "usergrid-jenkins-builds"
},
-
- "SSHLocation" : {
- "Description" : "The IP address range that can be used to SSH to the EC2 instances",
+ "SSHLocation": {
+ "Description": "The IP address range that can be used to SSH to the EC2 instances",
"Type": "String",
"MinLength": "9",
"MaxLength": "18",
"Default": "0.0.0.0/0",
"AllowedPattern": "(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})/(\\d{1,2})",
"ConstraintDescription": "must be a valid IP CIDR range of the form x.x.x.x/x."
+ },
+ "Branch": {
+ "Description": "The branch of usergrid to check out",
+ "Type": "String",
+ "Default": "two-dot-o"
}
},
@@ -231,15 +267,11 @@
"apt-add-repository ppa:awstools-dev/awstools --yes\n",
"apt-get update\n",
"echo oracle-java7-installer shared/accepted-oracle-license-v1-1 select true | /usr/bin/debconf-set-selections\n",
- "apt-get install oracle-java7-installer oracle-java7-set-default expect expect-dev git ec2-api-tools -y --force-yes\n",
+ "apt-get install oracle-java7-installer oracle-java7-set-default expect expect-dev git ec2-api-tools maven -y --force-yes\n",
"update-java-alternatives -s java-7-oracle\n",
- "mkdir -p /usr/local/apache-maven\n",
- "cd /usr/local/apache-maven\n",
- "wget http://apache.mirrors.timporter.net/maven/maven-3/3.1.1/binaries/apache-maven-3.1.1-bin.tar.gz\n",
- "tar -xzvf apache-maven-3.1.1-bin.tar.gz\n",
"cd ~ubuntu\n",
- "git clone https://github.com/apache/incubator-usergrid.git usergrid\n",
+ "git clone -b ",{ "Ref":"Branch" } , " https://github.com/apache/incubator-usergrid.git usergrid\n",
"chown -R ubuntu:ubuntu usergrid\n",
"ec2-create-tags $(curl -k http://169.254.169.254/latest/meta-data/instance-id) --aws-access-key ",{ "Ref":"GatlingKey" }, " --aws-secret-key ", { "Fn::GetAtt":[ "GatlingKey", "SecretAccessKey" ] } ," --tag Name=", { "Ref":"AWS::StackName" }, "-Gatling\n"
]]}}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/b12130f0/stack/awscluster/pom.xml
----------------------------------------------------------------------
diff --git a/stack/awscluster/pom.xml b/stack/awscluster/pom.xml
index 4a8f4d6..46157ab 100644
--- a/stack/awscluster/pom.xml
+++ b/stack/awscluster/pom.xml
@@ -215,7 +215,7 @@
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk</artifactId>
- <version>1.6.7</version>
+ <version>1.9.7</version>
</dependency>
<dependency>
<artifactId>groovy-all</artifactId>
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/b12130f0/stack/awscluster/src/main/groovy/NodeRegistry.groovy
----------------------------------------------------------------------
diff --git a/stack/awscluster/src/main/groovy/NodeRegistry.groovy b/stack/awscluster/src/main/groovy/NodeRegistry.groovy
index 6291f93..277631b 100644
--- a/stack/awscluster/src/main/groovy/NodeRegistry.groovy
+++ b/stack/awscluster/src/main/groovy/NodeRegistry.groovy
@@ -20,34 +20,64 @@
* A utility class that search simple db for the node type provided and returns a list of hostnames as a string array
*/
import com.amazonaws.auth.BasicAWSCredentials
-import com.amazonaws.services.simpledb.AmazonSimpleDBClient
-import com.amazonaws.services.simpledb.model.*
+import com.amazonaws.regions.Region
+import com.amazonaws.regions.Regions
+import com.amazonaws.services.ec2.model.DescribeInstancesRequest
+import com.amazonaws.services.ec2.model.DescribeInstancesResult
+import com.amazonaws.services.ec2.model.DescribeTagsRequest
+import com.amazonaws.services.ec2.AmazonEC2Client
+import com.amazonaws.services.ec2.model.CreateTagsRequest
+import com.amazonaws.services.ec2.model.Filter
+import com.amazonaws.services.ec2.model.Instance
+import com.amazonaws.services.ec2.model.Tag
class NodeRegistry {
+
+ public static final String TAG_PREFIX = "tag:"
+ //taken from aws
+ public static final String STACK_NAME = "usergrid:stack-name";
+ public static final String NODE_TYPE = "usergrid:node_type";
+
private String accessKey = (String) System.getenv().get("AWS_ACCESS_KEY")
private String secretKey = (String) System.getenv().get("AWS_SECRET_KEY")
private String stackName = (String) System.getenv().get("STACK_NAME")
- private hostName = (String) System.getenv().get("PUBLIC_HOSTNAME")
+ private String instanceId = (String) System.getenv().get("EC2_INSTANCE_ID");
+ private String region = (String) System.getenv().get("EC2_REGION");
private String domain = stackName
- private def creds;
- private def sdbClient;
+ private BasicAWSCredentials creds;
+ private AmazonEC2Client ec2Client;
NodeRegistry() {
- while ( true ) {
- try {
- // creates domain or no-op if it already exists
- creds = new BasicAWSCredentials(accessKey, secretKey)
- sdbClient = new AmazonSimpleDBClient(creds)
- sdbClient.createDomain(new CreateDomainRequest(domain))
-
- } catch ( Exception e ) {
- continue
- }
- break
+
+ if (region == null) {
+ throw new IllegalArgumentException("EC2_REGION must be defined")
+ }
+
+ if (instanceId == null) {
+ throw new IllegalArgumentException("EC2_INSTANCE_ID must be defined")
+ }
+
+ if (stackName == null) {
+ throw new IllegalArgumentException("STACK_NAME must be defined")
+ }
+
+ if (accessKey == null) {
+ throw new IllegalArgumentException("AWS_ACCESS_KEY must be defined")
+ }
+
+ if (secretKey == null) {
+ throw new IllegalArgumentException("AWS_SECRET_KEY must be defined")
}
+
+ creds = new BasicAWSCredentials(accessKey, secretKey)
+ ec2Client = new AmazonEC2Client(creds)
+ def regionEnum = Regions.fromName(region);
+ ec2Client.setRegion(Region.getRegion(regionEnum))
+
+
}
/**
@@ -55,64 +85,85 @@ class NodeRegistry {
* @param defNodeType
*/
def searchNode(def nodeType) {
- //order by create time, if we have a conflict, then order by item name
- def selectResult = sdbClient.select(new SelectRequest((String) \
- "select * from `${domain}` where itemName() is not null AND createtime is not null AND nodetype = '${nodeType}' order by createtime"))
- def result = []
-
- for (item in selectResult.getItems()) {
- def hostname = item.getName()
- result.add(hostname)
+
+ def stackNameFilter = new Filter(TAG_PREFIX+STACK_NAME).withValues(stackName);
+ def nodeTypeFilter = new Filter(TAG_PREFIX+NODE_TYPE).withValues(nodeType);
+
+ def describeRequest = new DescribeInstancesRequest().withFilters(stackNameFilter, nodeTypeFilter);
+
+
+ def nodes = ec2Client.describeInstances(describeRequest)
+
+ //sort by created date
+ def servers = [];
+
+ for(reservation in nodes.getReservations()){
+
+ //TODO, add these to a list then sort them by date, then name
+ for(instance in reservation.getInstances()){
+
+ servers.add(new ServerEntry(instance.launchTime, instance.publicDnsName))
+ }
+
}
- return result
+
+ return createResults(servers);
}
- /**
- * Get the entire database back in raw form
- * @return
- */
- def selectAll() {
- def selectResult = sdbClient.select(new SelectRequest((String) "select * from `${domain}`")).getItems()
+ def createResults(def servers){
+
+
+ Collections.sort(servers);
+ def results = [];
- return selectResult;
+ for(server in servers){
+ results.add(server.publicIp)
+ }
+
+ return results;
}
+
+
/**
* Add the node to the database if it doesn't exist
*/
def addNode(def nodeType) {
- def gar = new GetAttributesRequest(domain, hostName);
- def response = sdbClient.getAttributes(gar);
- if (response.getAttributes().size() == 1) {
- println "Already registered"
- def attrs = response.getAttributes()
- for (att in attrs) {
- println("${hostName} -> ${att.getName()} : ${att.getValue()}")
- }
- return false;
-
- } else {
- println "Registering..."
- def stackAtt = new ReplaceableAttribute("nodetype", nodeType, true)
- def nowString = Calendar.getInstance(TimeZone.getTimeZone('UTC')).format("yyyy-MM-dd'T'HH:mm:ss.SSSZ")
- def createTime = new ReplaceableAttribute("createtime", nowString, true)
- def attrs = new ArrayList()
- attrs.add(stackAtt)
- attrs.add(createTime)
- def par = new PutAttributesRequest(domain, hostName, attrs)
- sdbClient.putAttributes(par);
- println "Registration done."
- return true;
- }
+ //add the node type
+ def tagRequest = new CreateTagsRequest().withTags(new Tag(NODE_TYPE, nodeType), new Tag(STACK_NAME, stackName)).withResources(instanceId)
+
+
+
+ ec2Client.createTags(tagRequest)
}
- def deleteRegistry(){
- sdbClient.deleteDomain(new DeleteDomainRequest(domain))
+
+ class ServerEntry implements Comparable<ServerEntry>{
+ private final Date launchDate;
+ private final String publicIp;
+
+ ServerEntry(final Date launchDate, final String publicIp) {
+ this.launchDate = launchDate
+ this.publicIp = publicIp
+ }
+
+ @Override
+ int compareTo(final ServerEntry o) {
+ if(launchDate.before(o.launchDate)){
+ -1;
+ }else if (launchDate.after(o.launchDate)){
+ return 1;
+ }
+
+ return publicIp.compareTo(o.publicIp);
+
+
+ }
}
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/b12130f0/stack/awscluster/src/main/groovy/registry_list.groovy
----------------------------------------------------------------------
diff --git a/stack/awscluster/src/main/groovy/registry_list.groovy b/stack/awscluster/src/main/groovy/registry_list.groovy
deleted file mode 100644
index ca3bcda..0000000
--- a/stack/awscluster/src/main/groovy/registry_list.groovy
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * 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.
- */
-
-
-//
-// registry_list.groovy
-//
-// List contents of registry as debugging aid. Not used in any other scripts.
-//
-NodeRegistry registry = new NodeRegistry();
-
-
-
-
-for (item in registry.selectAll()) {
- for(att in item.getAttributes()){
- println "${item.getName()} -> ${att.getName()} : ${att.getValue()}"
- }
-
- println "\n"
-}
[04/50] [abbrv] incubator-usergrid git commit: Refactored tests.
Posted by sn...@apache.org.
Refactored tests.
Made configuration options easier to override in tests
Added checks for entity too large on write.
Changed default max load size to 100.
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/fb90ae70
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/fb90ae70
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/fb90ae70
Branch: refs/heads/two-dot-o-events
Commit: fb90ae705c29ee2cf61063d57f1e4e97d05ee5aa
Parents: e32d521
Author: Todd Nine <tn...@apigee.com>
Authored: Thu Nov 20 17:49:13 2014 -0700
Committer: Todd Nine <tn...@apigee.com>
Committed: Thu Nov 20 17:49:13 2014 -0700
----------------------------------------------------------------------
.../usergrid/corepersistence/GuiceModule.java | 2 +
.../org/apache/usergrid/CoreITSetupImpl.java | 13 ++
.../usergrid/persistence/LargeEntityIT.java | 30 +++-
.../exception/EntityTooLargeException.java | 67 ++++++++
.../serialization/SerializationFig.java | 14 +-
.../MvccEntitySerializationStrategyImpl.java | 41 ++---
.../MvccEntitySerializationStrategyV2Impl.java | 82 ++++++----
.../collection/EntityCollectionManagerIT.java | 16 +-
...MvccEntitySerializationStrategyImplTest.java | 52 +-----
...cEntitySerializationStrategyProxyV1Test.java | 17 --
...cEntitySerializationStrategyProxyV2Test.java | 19 +--
...ccEntitySerializationStrategyV1ImplTest.java | 18 --
...ccEntitySerializationStrategyV2ImplTest.java | 19 +--
.../MvccEntitySerializationStrategyV2Test.java | 164 +++++++++++++++++++
.../impl/MvccLESSTransientTest.java | 53 +-----
.../collection/util/EntityHelper.java | 35 ++--
.../persistence/core/astyanax/CassandraFig.java | 12 ++
.../core/guicyfig/SetConfigTestBypass.java | 108 ++++++++++++
.../persistence/queue/QueueManagerTest.java | 26 +--
19 files changed, 522 insertions(+), 266 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/fb90ae70/stack/core/src/main/java/org/apache/usergrid/corepersistence/GuiceModule.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/GuiceModule.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/GuiceModule.java
index 2d80672..018a9b7 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/GuiceModule.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/GuiceModule.java
@@ -20,6 +20,7 @@ package org.apache.usergrid.corepersistence;
import com.google.inject.AbstractModule;
import com.google.inject.multibindings.Multibinder;
+import org.apache.usergrid.corepersistence.migration.EntityDataMigration;
import org.apache.usergrid.corepersistence.migration.EntityTypeMappingMigration;
import org.apache.usergrid.corepersistence.migration.GraphShardVersionMigration;
import org.apache.usergrid.persistence.collection.guice.CollectionModule;
@@ -56,6 +57,7 @@ public class GuiceModule extends AbstractModule {
Multibinder<DataMigration> dataMigrationMultibinder = Multibinder.newSetBinder( binder(), DataMigration.class );
dataMigrationMultibinder.addBinding().to( EntityTypeMappingMigration.class );
dataMigrationMultibinder.addBinding().to( GraphShardVersionMigration.class );
+ dataMigrationMultibinder.addBinding().to( EntityDataMigration.class );
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/fb90ae70/stack/core/src/test/java/org/apache/usergrid/CoreITSetupImpl.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/CoreITSetupImpl.java b/stack/core/src/test/java/org/apache/usergrid/CoreITSetupImpl.java
index b3cc046..a5f59ed 100644
--- a/stack/core/src/test/java/org/apache/usergrid/CoreITSetupImpl.java
+++ b/stack/core/src/test/java/org/apache/usergrid/CoreITSetupImpl.java
@@ -24,10 +24,13 @@ import org.junit.runners.model.Statement;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.usergrid.cassandra.CassandraResource;
+import org.apache.usergrid.corepersistence.CpSetup;
import org.apache.usergrid.mq.QueueManagerFactory;
import org.apache.usergrid.persistence.EntityManagerFactory;
import org.apache.usergrid.persistence.IndexBucketLocator;
import org.apache.usergrid.persistence.cassandra.CassandraService;
+import org.apache.usergrid.persistence.core.migration.data.DataMigrationManager;
+import org.apache.usergrid.persistence.core.migration.schema.MigrationException;
import org.apache.usergrid.persistence.index.impl.ElasticSearchResource;
import org.apache.usergrid.utils.JsonUtils;
@@ -90,7 +93,17 @@ public class CoreITSetupImpl implements CoreITSetup {
emf = cassandraResource.getBean( EntityManagerFactory.class );
qmf = cassandraResource.getBean( QueueManagerFactory.class );
indexBucketLocator = cassandraResource.getBean( IndexBucketLocator.class );
+
+ //run the migration
+ try {
+ CpSetup.getInjector().getInstance( DataMigrationManager.class ).migrate();
+ }
+ catch ( MigrationException e ) {
+ throw new RuntimeException( "Unable to run migration", e );
+ }
+
enabled = true;
+
}
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/fb90ae70/stack/core/src/test/java/org/apache/usergrid/persistence/LargeEntityIT.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/LargeEntityIT.java b/stack/core/src/test/java/org/apache/usergrid/persistence/LargeEntityIT.java
index eef2820..c95f7d6 100644
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/LargeEntityIT.java
+++ b/stack/core/src/test/java/org/apache/usergrid/persistence/LargeEntityIT.java
@@ -25,7 +25,7 @@ import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Map;
-import org.aspectj.lang.annotation.Before;
+import org.junit.After;
import org.junit.Rule;
import org.junit.Test;
import org.slf4j.Logger;
@@ -35,6 +35,9 @@ import org.apache.usergrid.AbstractCoreIT;
import org.apache.usergrid.Application;
import org.apache.usergrid.CoreApplication;
import org.apache.usergrid.cassandra.Concurrent;
+import org.apache.usergrid.corepersistence.CpSetup;
+import org.apache.usergrid.persistence.collection.serialization.SerializationFig;
+import org.apache.usergrid.persistence.core.guicyfig.SetConfigTestBypass;
import org.apache.usergrid.utils.JsonUtils;
import static org.junit.Assert.assertEquals;
@@ -48,6 +51,28 @@ public class LargeEntityIT extends AbstractCoreIT {
public Application app = new CoreApplication( setup );
+ /**
+ * Set our max size before and after so we can override it in our runtime tests
+ */
+ private int setMaxEntitySize;
+
+ private SerializationFig serializationFig;
+
+
+ @org.junit.Before
+ public void setUp() {
+
+ serializationFig = CpSetup.getInjector().getInstance( SerializationFig.class );
+
+ setMaxEntitySize = serializationFig.getMaxEntitySize();
+ }
+
+
+ @After
+ public void tearDown() {
+ SetConfigTestBypass.setValueByPass( serializationFig, "getMaxEntitySize", setMaxEntitySize + "" );
+ }
+
/**
* Tests creating a large entity, then loading it, modifying it, saving it, then loading it again
@@ -57,6 +82,9 @@ public class LargeEntityIT extends AbstractCoreIT {
LOG.debug( "testLargeEntityCrud" );
+ SetConfigTestBypass.setValueByPass( serializationFig, "getMaxEntitySize", 641814 + "" );
+
+
final URL resource = this.getClass().getClassLoader().getResource( TEST_DATA_FILE );
final byte[] fileData = Files.readAllBytes( Paths.get( resource.toURI() ) );
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/fb90ae70/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/exception/EntityTooLargeException.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/exception/EntityTooLargeException.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/exception/EntityTooLargeException.java
new file mode 100644
index 0000000..11224db
--- /dev/null
+++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/exception/EntityTooLargeException.java
@@ -0,0 +1,67 @@
+/*
+ * 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.collection.exception;
+
+import org.apache.usergrid.persistence.collection.CollectionScope;
+import org.apache.usergrid.persistence.collection.MvccEntity;
+import org.apache.usergrid.persistence.model.entity.Entity;
+
+
+public class EntityTooLargeException extends RuntimeException {
+
+ private final Entity entity;
+ private final int maxSize;
+ private final int attemptedSize;
+
+
+ public EntityTooLargeException( Entity entity, int maxSize,final int attemptedSize, final String message ) {
+ super( message );
+ this.entity = entity;
+ this.maxSize = maxSize;
+
+ this.attemptedSize = attemptedSize;
+ }
+
+
+ /**
+ * Get the max size allowed
+ * @return
+ */
+ public int getMaxSize() {
+ return maxSize;
+ }
+
+
+ /**
+ * Get the size of the entity we attempted to save
+ * @return
+ */
+ public int getAttemptedSize() {
+ return attemptedSize;
+ }
+
+
+ /**
+ * Entity involved in operation.
+ * @return Entity or null if entity not instantiated yet in operation.
+ */
+ public Entity getEntity() {
+ return entity;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/fb90ae70/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/SerializationFig.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/SerializationFig.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/SerializationFig.java
index 294c7ab..0687312 100644
--- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/SerializationFig.java
+++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/SerializationFig.java
@@ -58,17 +58,21 @@ public interface SerializationFig extends GuicyFig {
int getTaskPoolQueueSize();
/**
- * The maximum amount of entites we can load at any one time
+ * The maximum amount of entities we can load at any one time
*/
@Key( "collection.max.load.size" )
- @Default( "1000" )
+ @Default( "100" )
int getMaxLoadSize();
/**
* The maximum number of bytes a serialized entity can be. Any thing beyond this is rejected
+ * This default is based on the following equation
+ *
+ * (15mb thrift buffer * .9) / 100 (default max load size)
*/
- @Key( "collection.max.entry.size" )
- @Default( "512" )
- int getMaxEntrySize();
+ @Key( "collection.max.entity.size" )
+ @Default( "141557" )
+ int getMaxEntitySize();
+
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/fb90ae70/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyImpl.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyImpl.java
index 4ac5d24..f3f4c13 100644
--- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyImpl.java
+++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyImpl.java
@@ -77,7 +77,6 @@ public abstract class MvccEntitySerializationStrategyImpl implements MvccEntityS
protected final Keyspace keyspace;
protected final SerializationFig serializationFig;
protected final EntityRepair repair;
- private final AbstractSerializer<EntityWrapper> entityJsonSerializer;
private final MultiTennantColumnFamily<ScopedRowKey<CollectionPrefixedKey<Id>>, UUID> columnFamily;
@@ -86,7 +85,6 @@ public abstract class MvccEntitySerializationStrategyImpl implements MvccEntityS
this.keyspace = keyspace;
this.serializationFig = serializationFig;
this.repair = new EntityRepairImpl( this, serializationFig );
- this.entityJsonSerializer = getEntitySerializer();
this.columnFamily = getColumnFamily();
}
@@ -102,17 +100,17 @@ public abstract class MvccEntitySerializationStrategyImpl implements MvccEntityS
return doWrite( collectionScope, entityId, new RowOp() {
@Override
public void doOp( final ColumnListMutation<UUID> colMutation ) {
- try {
- colMutation.putColumn( colName, entityJsonSerializer
+// try {
+ colMutation.putColumn( colName, getEntitySerializer()
.toByteBuffer( new EntityWrapper( entity.getStatus(), entity.getEntity() ) ) );
- }
- catch ( Exception e ) {
- // throw better exception if we can
- if ( entity != null || entity.getEntity().get() != null ) {
- throw new CollectionRuntimeException( entity, collectionScope, e );
- }
- throw e;
- }
+// }
+// catch ( Exception e ) {
+// // throw better exception if we can
+// if ( entity != null || entity.getEntity().get() != null ) {
+// throw new CollectionRuntimeException( entity, collectionScope, e );
+// }
+// throw e;
+// }
}
} );
}
@@ -129,9 +127,9 @@ public abstract class MvccEntitySerializationStrategyImpl implements MvccEntityS
Preconditions.checkNotNull( maxVersion, "version is required" );
- //didn't put the max in the error message, I don't want to take the string construction hit every time
- Preconditions.checkArgument( entityIds.size() <= serializationFig.getMaxLoadSize(),
- "requested size cannot be over configured maximum" );
+ if( entityIds.size() > serializationFig.getMaxLoadSize()){
+ throw new IllegalArgumentException( "requested load size cannot be over configured maximum of " + serializationFig.getMaxLoadSize() );
+ }
final Id applicationId = collectionScope.getApplication();
@@ -185,7 +183,7 @@ public abstract class MvccEntitySerializationStrategyImpl implements MvccEntityS
final Column<UUID> column = columns.getColumnByIndex( 0 );
final MvccEntity parsedEntity =
- new MvccColumnParser( entityId, entityJsonSerializer ).parseColumn( column );
+ new MvccColumnParser( entityId, getEntitySerializer() ).parseColumn( column );
//we *might* need to repair, it's not clear so check before loading into result sets
final MvccEntity maybeRepaired = repair.maybeRepair( collectionScope, parsedEntity );
@@ -223,7 +221,7 @@ public abstract class MvccEntitySerializationStrategyImpl implements MvccEntityS
keyspace.prepareQuery( columnFamily ).getKey( rowKey )
.withColumnRange( version, null, false, fetchSize );
- return new ColumnNameIterator( query, new MvccColumnParser( entityId, entityJsonSerializer ), false );
+ return new ColumnNameIterator( query, new MvccColumnParser( entityId, getEntitySerializer() ), false );
}
@@ -253,7 +251,7 @@ public abstract class MvccEntitySerializationStrategyImpl implements MvccEntityS
keyspace.prepareQuery( columnFamily ).getKey( rowKey )
.withColumnRange( null, version, true, fetchSize );
- return new ColumnNameIterator( query, new MvccColumnParser( entityId, entityJsonSerializer ), false );
+ return new ColumnNameIterator( query, new MvccColumnParser( entityId, getEntitySerializer() ), false );
}
@@ -268,7 +266,7 @@ public abstract class MvccEntitySerializationStrategyImpl implements MvccEntityS
return doWrite( collectionScope, entityId, new RowOp() {
@Override
public void doOp( final ColumnListMutation<UUID> colMutation ) {
- colMutation.putColumn( version, entityJsonSerializer
+ colMutation.putColumn( version, getEntitySerializer()
.toByteBuffer( new EntityWrapper( MvccEntity.Status.COMPLETE, Optional.<Entity>absent() ) ) );
}
} );
@@ -410,10 +408,5 @@ public abstract class MvccEntitySerializationStrategyImpl implements MvccEntityS
* @return
*/
protected abstract MultiTennantColumnFamily<ScopedRowKey<CollectionPrefixedKey<Id>>, UUID> getColumnFamily();
- /**
- *
- private static final MultiTennantColumnFamily<ScopedRowKey<CollectionPrefixedKey<Id>>, UUID> CF_ENTITY_DATA =
- new MultiTennantColumnFamily<>( "Entity_Version_Data", ROW_KEY_SER, UUIDSerializer.get() );
- */
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/fb90ae70/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyV2Impl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyV2Impl.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyV2Impl.java
index 723bb38..923c399 100644
--- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyV2Impl.java
+++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyV2Impl.java
@@ -25,6 +25,7 @@ import java.util.UUID;
import org.apache.usergrid.persistence.collection.MvccEntity;
import org.apache.usergrid.persistence.collection.exception.DataCorruptionException;
+import org.apache.usergrid.persistence.collection.exception.EntityTooLargeException;
import org.apache.usergrid.persistence.collection.serialization.SerializationFig;
import org.apache.usergrid.persistence.core.astyanax.FieldBuffer;
import org.apache.usergrid.persistence.core.astyanax.FieldBufferBuilder;
@@ -36,6 +37,7 @@ import org.apache.usergrid.persistence.core.astyanax.ScopedRowKey;
import org.apache.usergrid.persistence.model.entity.Entity;
import org.apache.usergrid.persistence.model.entity.Id;
+import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.dataformat.smile.SmileFactory;
import com.google.common.base.Optional;
@@ -52,8 +54,6 @@ import com.netflix.astyanax.serializers.UUIDSerializer;
@Singleton
public class MvccEntitySerializationStrategyV2Impl extends MvccEntitySerializationStrategyImpl {
- private static final EntitySerializer ENTITY_JSON_SER = new EntitySerializer();
-
private static final IdRowCompositeSerializer ID_SER = IdRowCompositeSerializer.get();
@@ -63,21 +63,24 @@ public class MvccEntitySerializationStrategyV2Impl extends MvccEntitySerializati
private static final MultiTennantColumnFamily<ScopedRowKey<CollectionPrefixedKey<Id>>, UUID> CF_ENTITY_DATA =
- new MultiTennantColumnFamily<>( "Entity_Version_Data_V2", ROW_KEY_SER, UUIDSerializer.get() );
+ new MultiTennantColumnFamily<>( "Entity_Version_Data_V2", ROW_KEY_SER, UUIDSerializer.get() );
private static final FieldBufferSerializer FIELD_BUFFER_SERIALIZER = FieldBufferSerializer.get();
+ private final EntitySerializer entitySerializer;
+
@Inject
public MvccEntitySerializationStrategyV2Impl( final Keyspace keyspace, final SerializationFig serializationFig ) {
super( keyspace, serializationFig );
+ entitySerializer = new EntitySerializer( serializationFig );
}
@Override
protected AbstractSerializer<EntityWrapper> getEntitySerializer() {
- return ENTITY_JSON_SER;
+ return entitySerializer;
}
@@ -87,35 +90,33 @@ public class MvccEntitySerializationStrategyV2Impl extends MvccEntitySerializati
}
- public static class EntitySerializer extends AbstractSerializer<EntityWrapper> {
+ /**
+ * We should only ever create this once, since this impl is a singleton
+ */
+ public final class EntitySerializer extends AbstractSerializer<EntityWrapper> {
-// private static final ByteBufferSerializer BUFFER_SERIALIZER = ByteBufferSerializer.get();
-//
-// private static final BytesArraySerializer BYTES_ARRAY_SERIALIZER = BytesArraySerializer.get();
+ private final SmileFactory SMILE_FACTORY = new SmileFactory();
+ private final ObjectMapper MAPPER = new ObjectMapper( SMILE_FACTORY );
- public static final SmileFactory f = new SmileFactory();
- public static ObjectMapper mapper;
+ private SerializationFig serializationFig;
- private static byte STATE_COMPLETE = 0 ;
- private static byte STATE_DELETED = 1 ;
- private static byte STATE_PARTIAL = 2 ;
- private static byte VERSION = 1;
+ private byte STATE_COMPLETE = 0;
+ private byte STATE_DELETED = 1;
+ private byte STATE_PARTIAL = 2;
+ private byte VERSION = 1;
- public EntitySerializer() {
- try {
- mapper = new ObjectMapper( f );
- // mapper.enable(SerializationFeature.INDENT_OUTPUT); don't indent output,
- // causes slowness
- mapper.enableDefaultTypingAsProperty( ObjectMapper.DefaultTyping.JAVA_LANG_OBJECT, "@class" );
- }
- catch ( Exception e ) {
- throw new RuntimeException( "Error setting up mapper", e );
- }
+
+ public EntitySerializer( final SerializationFig serializationFig ) {
+ this.serializationFig = serializationFig;
+
+ // mapper.enable(SerializationFeature.INDENT_OUTPUT); don't indent output,
+ // causes slowness
+ MAPPER.enableDefaultTypingAsProperty( ObjectMapper.DefaultTyping.JAVA_LANG_OBJECT, "@class" );
}
@@ -126,7 +127,7 @@ public class MvccEntitySerializationStrategyV2Impl extends MvccEntitySerializati
}
//we always have a max of 3 fields
- FieldBufferBuilder builder = new FieldBufferBuilder( 3 );
+ FieldBufferBuilder builder = new FieldBufferBuilder( 3 );
builder.addByte( VERSION );
@@ -149,14 +150,28 @@ public class MvccEntitySerializationStrategyV2Impl extends MvccEntitySerializati
builder.addByte( STATE_PARTIAL );
}
+
+ final Entity entity = wrapper.entity.get();
+ final byte[] entityBytes;
+
try {
- final byte[] entityBytes = mapper.writeValueAsBytes( wrapper.entity.get() );
- builder.addBytes( entityBytes );
+ entityBytes = MAPPER.writeValueAsBytes( entity );
}
- catch ( Exception e ) {
+ catch ( JsonProcessingException e ) {
throw new RuntimeException( "Unable to serialize entity", e );
}
+
+ final int maxEntrySize = serializationFig.getMaxEntitySize();
+
+ if ( entityBytes.length > maxEntrySize ) {
+ throw new EntityTooLargeException( entity, maxEntrySize, entityBytes.length,
+ "Your entity cannot exceed " + maxEntrySize + " bytes. The entity you tried to save was "
+ + entityBytes.length + " bytes" );
+ }
+
+ builder.addBytes( entityBytes );
+
return FIELD_BUFFER_SERIALIZER.toByteBuffer( builder.build() );
}
@@ -181,13 +196,12 @@ public class MvccEntitySerializationStrategyV2Impl extends MvccEntitySerializati
throw new DataCorruptionException( "Unable to de-serialze entity", e );
}
- FieldBufferParser parser = new FieldBufferParser( fieldBuffer );
-
+ FieldBufferParser parser = new FieldBufferParser( fieldBuffer );
byte version = parser.readByte();
- if ( VERSION != version ) {
+ if ( VERSION != version ) {
throw new UnsupportedOperationException( "A version of type " + version + " is unsupported" );
}
@@ -195,7 +209,7 @@ public class MvccEntitySerializationStrategyV2Impl extends MvccEntitySerializati
// it's been deleted, remove it
- if ( STATE_DELETED == state ) {
+ if ( STATE_DELETED == state ) {
return new EntityWrapper( MvccEntity.Status.COMPLETE, Optional.<Entity>absent() );
}
@@ -204,7 +218,7 @@ public class MvccEntitySerializationStrategyV2Impl extends MvccEntitySerializati
byte[] array = parser.readBytes();
try {
- storedEntity = mapper.readValue( array, Entity.class );
+ storedEntity = MAPPER.readValue( array, Entity.class );
}
catch ( Exception e ) {
throw new DataCorruptionException( "Unable to read entity data", e );
@@ -212,7 +226,7 @@ public class MvccEntitySerializationStrategyV2Impl extends MvccEntitySerializati
final Optional<Entity> entity = Optional.of( storedEntity );
- if ( STATE_COMPLETE == state ) {
+ if ( STATE_COMPLETE == state ) {
return new EntityWrapper( MvccEntity.Status.COMPLETE, entity );
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/fb90ae70/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/EntityCollectionManagerIT.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/EntityCollectionManagerIT.java b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/EntityCollectionManagerIT.java
index 21e3260..5eba979 100644
--- a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/EntityCollectionManagerIT.java
+++ b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/EntityCollectionManagerIT.java
@@ -28,12 +28,13 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.apache.usergrid.persistence.collection.exception.WriteUniqueVerifyException;
-import org.apache.usergrid.persistence.collection.util.EntityHelper;
-import org.apache.usergrid.persistence.core.guice.MigrationManagerRule;
import org.apache.usergrid.persistence.collection.guice.TestCollectionModule;
import org.apache.usergrid.persistence.collection.impl.CollectionScopeImpl;
import org.apache.usergrid.persistence.collection.mvcc.entity.Stage;
import org.apache.usergrid.persistence.collection.serialization.SerializationFig;
+import org.apache.usergrid.persistence.collection.util.EntityHelper;
+import org.apache.usergrid.persistence.core.guice.MigrationManagerRule;
+import org.apache.usergrid.persistence.core.guicyfig.SetConfigTestBypass;
import org.apache.usergrid.persistence.core.test.ITRunner;
import org.apache.usergrid.persistence.core.test.UseModules;
import org.apache.usergrid.persistence.core.util.Health;
@@ -713,8 +714,13 @@ public class EntityCollectionManagerIT {
public void largeEntityWriteRead() {
final int setSize = 65535 * 2;
+ final int currentMaxSize = serializationFig.getMaxEntitySize();
- final Entity entity = EntityHelper.generateEntity( setSize );
+ //override our default
+ SetConfigTestBypass.setValueByPass( serializationFig, "getMaxEntitySize", 65535 * 10 + "" );
+
+
+ final Entity entity = EntityHelper.generateEntity( setSize );
//now we have one massive, entity, save it and retrieve it.
CollectionScope context =
@@ -732,5 +738,9 @@ public class EntityCollectionManagerIT {
EntityHelper.verifyDeepEquals( entity, loaded );
+
+
+ //override our default
+ SetConfigTestBypass.setValueByPass( serializationFig, "getMaxEntitySize", currentMaxSize + "" );
}
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/fb90ae70/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 0cdc320..6ce88cf 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
@@ -75,7 +75,7 @@ import static org.mockito.Mockito.mock;
public abstract class MvccEntitySerializationStrategyImplTest {
- private MvccEntitySerializationStrategy serializationStrategy;
+ protected MvccEntitySerializationStrategy serializationStrategy;
@Inject
@@ -582,56 +582,6 @@ public abstract class MvccEntitySerializationStrategyImplTest {
- /**
- * Tests an entity with more than 65535 bytes worth of data is successfully stored and retrieved
- */
- @Test
- public void largeEntityWriteRead() throws ConnectionException {
- final int setSize = 65535 * 2;
-
- final Entity entity = EntityHelper.generateEntity( setSize );
-
- //now we have one massive, entity, save it and retrieve it.
- CollectionScope context =
- new CollectionScopeImpl( new SimpleId( "organization" ), new SimpleId( "parent" ), "tests" );
-
-
- final Id id = entity.getId();
- ValidationUtils.verifyIdentity( id );
- final UUID version = UUIDGenerator.newTimeUUID();
- final MvccEntity.Status status = MvccEntity.Status.COMPLETE;
-
- final MvccEntity mvccEntity = new MvccEntityImpl( id, version, status, entity );
-
-
- getMvccEntitySerializationStrategy().write( context, mvccEntity ).execute();
-
- //now load it
- final Iterator<MvccEntity> loaded =
- getMvccEntitySerializationStrategy().loadDescendingHistory( context, id, version, 100 );
-
-
- assertLargeEntity( mvccEntity, loaded );
-
- MvccEntity returned = serializationStrategy.load( context, Collections.singleton( id ) , version ).getEntity( id );
-
- assertLargeEntity( mvccEntity, returned );
- }
-
-
- /**
- * Assertion for the loaded values of a large entity. Note the returned may be nullable
- * @param expected
- * @param returned
- */
- protected abstract void assertLargeEntity(final MvccEntity expected, final Iterator<MvccEntity> returned);
-
- /**
- * Tests large entity that is directly returned
- * @param expected
- * @param returned
- */
- protected abstract void assertLargeEntity(final MvccEntity expected, final MvccEntity returned);
@Test(expected = NullPointerException.class)
public void writeParamsContext() throws ConnectionException {
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/fb90ae70/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyProxyV1Test.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyProxyV1Test.java b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyProxyV1Test.java
index df5f7d1..a936d2a 100644
--- a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyProxyV1Test.java
+++ b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyProxyV1Test.java
@@ -76,23 +76,6 @@ public class MvccEntitySerializationStrategyProxyV1Test extends MvccEntitySerial
- @Override
- protected void assertLargeEntity( final MvccEntity expected, final Iterator<MvccEntity> returned ) {
- //known bug in v1, it should return null. Fixed in v2
- assertTrue( "V1 should be broken, but still have a next", returned.hasNext() );
-
- final MvccEntity entity = returned.next();
-
-
- assertLargeEntity( expected, entity );
- }
-
-
- protected void assertLargeEntity( final MvccEntity expected, final MvccEntity returned ) {
- assertEquals( "Marked as deleted since we can't parse", MvccEntity.Status.DELETED, returned.getStatus() );
-
- assertFalse( "V1 returns empty b/c parse fails", returned.getEntity().isPresent() );
- }
@After
public void reSetMigrationVersion() {
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/fb90ae70/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyProxyV2Test.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyProxyV2Test.java b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyProxyV2Test.java
index dc31ff7..1709cc1 100644
--- a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyProxyV2Test.java
+++ b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyProxyV2Test.java
@@ -42,7 +42,7 @@ import static org.junit.Assert.assertTrue;
@RunWith( ITRunner.class )
@UseModules( TestCollectionModule.class )
-public class MvccEntitySerializationStrategyProxyV2Test extends MvccEntitySerializationStrategyImplTest {
+public class MvccEntitySerializationStrategyProxyV2Test extends MvccEntitySerializationStrategyV2Test {
@Inject
@ProxyImpl
@@ -74,23 +74,6 @@ public class MvccEntitySerializationStrategyProxyV2Test extends MvccEntitySerial
}
- @Override
- protected void assertLargeEntity( final MvccEntity expected, final Iterator<MvccEntity> returned ) {
- assertTrue( returned.hasNext() );
-
- final MvccEntity loadedEntity = returned.next();
-
- assertLargeEntity( expected, loadedEntity );
- }
-
-
- @Override
- protected void assertLargeEntity( final MvccEntity expected, final MvccEntity returned ) {
-
- org.junit.Assert.assertEquals( "The loaded entity should match the stored entity", expected, returned );
-
- EntityHelper.verifyDeepEquals( expected.getEntity().get(), returned.getEntity().get() );
- }
@After
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/fb90ae70/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyV1ImplTest.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyV1ImplTest.java b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyV1ImplTest.java
index 9b0ccfb..e59426d 100644
--- a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyV1ImplTest.java
+++ b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyV1ImplTest.java
@@ -47,24 +47,6 @@ public class MvccEntitySerializationStrategyV1ImplTest extends MvccEntitySeriali
private MvccEntitySerializationStrategy serializationStrategy;
- @Override
- protected void assertLargeEntity( final MvccEntity expected, final Iterator<MvccEntity> returned ) {
- //known bug in v1, it should return null. Fixed in v2
- assertTrue( "V1 should be broken, but still have a next", returned.hasNext() );
-
- final MvccEntity entity = returned.next();
-
-
- assertLargeEntity( expected, entity );
- }
-
-
- protected void assertLargeEntity( final MvccEntity expected, final MvccEntity returned ) {
- assertEquals( "Marked as deleted since we can't parse", MvccEntity.Status.DELETED, returned.getStatus() );
-
- assertFalse( "V1 returns empty b/c parse fails", returned.getEntity().isPresent() );
- }
-
@Override
protected MvccEntitySerializationStrategy getMvccEntitySerializationStrategy() {
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/fb90ae70/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyV2ImplTest.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyV2ImplTest.java b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyV2ImplTest.java
index 53952d0..c931904 100644
--- a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyV2ImplTest.java
+++ b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyV2ImplTest.java
@@ -39,7 +39,7 @@ import static org.junit.Assert.assertTrue;
@RunWith( ITRunner.class )
@UseModules( TestCollectionModule.class )
-public class MvccEntitySerializationStrategyV2ImplTest extends MvccEntitySerializationStrategyImplTest {
+public class MvccEntitySerializationStrategyV2ImplTest extends MvccEntitySerializationStrategyV2Test {
@Inject
@CurrentImpl
@@ -52,21 +52,4 @@ public class MvccEntitySerializationStrategyV2ImplTest extends MvccEntitySeriali
}
- @Override
- protected void assertLargeEntity( final MvccEntity expected, final Iterator<MvccEntity> returned ) {
- assertTrue( returned.hasNext() );
-
- final MvccEntity loadedEntity = returned.next();
-
- assertLargeEntity( expected, loadedEntity );
- }
-
-
- @Override
- protected void assertLargeEntity( final MvccEntity expected, final MvccEntity returned ) {
-
- org.junit.Assert.assertEquals( "The loaded entity should match the stored entity", expected, returned );
-
- EntityHelper.verifyDeepEquals( expected.getEntity().get(), returned.getEntity().get() );
- }
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/fb90ae70/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyV2Test.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyV2Test.java b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyV2Test.java
new file mode 100644
index 0000000..a496519
--- /dev/null
+++ b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyV2Test.java
@@ -0,0 +1,164 @@
+/*
+ * 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.collection.serialization.impl;
+
+
+import java.lang.annotation.Annotation;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.UUID;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.safehaus.guicyfig.Bypass;
+import org.safehaus.guicyfig.Env;
+import org.safehaus.guicyfig.Option;
+
+import org.apache.usergrid.persistence.collection.CollectionScope;
+import org.apache.usergrid.persistence.collection.MvccEntity;
+import org.apache.usergrid.persistence.collection.exception.EntityTooLargeException;
+import org.apache.usergrid.persistence.collection.impl.CollectionScopeImpl;
+import org.apache.usergrid.persistence.collection.mvcc.entity.impl.MvccEntityImpl;
+import org.apache.usergrid.persistence.collection.serialization.SerializationFig;
+import org.apache.usergrid.persistence.collection.util.EntityHelper;
+import org.apache.usergrid.persistence.core.guicyfig.SetConfigTestBypass;
+import org.apache.usergrid.persistence.core.util.ValidationUtils;
+import org.apache.usergrid.persistence.model.entity.Entity;
+import org.apache.usergrid.persistence.model.entity.Id;
+import org.apache.usergrid.persistence.model.entity.SimpleId;
+import org.apache.usergrid.persistence.model.util.UUIDGenerator;
+
+import com.google.inject.Inject;
+import com.netflix.astyanax.connectionpool.exceptions.ConnectionException;
+
+import static org.junit.Assert.assertTrue;
+
+
+public abstract class MvccEntitySerializationStrategyV2Test extends MvccEntitySerializationStrategyImplTest {
+
+
+ @Inject
+ protected SerializationFig serializationFig;
+
+ private int setMaxEntitySize;
+
+
+ @Before
+ public void setUp(){
+
+
+ setMaxEntitySize = serializationFig.getMaxEntitySize();
+ }
+
+ @After
+ public void tearDown(){
+ SetConfigTestBypass.setValueByPass( serializationFig, "getMaxEntitySize", setMaxEntitySize + "" );
+ }
+
+ /**
+ * Tests an entity with more than 65535 bytes worth of data is successfully stored and retrieved
+ */
+ @Test
+ public void largeEntityWriteRead() throws ConnectionException {
+ final int setSize = 65535 * 2;
+
+
+ //this is the size it works out to be when serialized, we want to allow this size
+
+ SetConfigTestBypass.setValueByPass( serializationFig, "getMaxEntitySize", 65535*10+"");
+ final Entity entity = EntityHelper.generateEntity( setSize );
+
+ //now we have one massive, entity, save it and retrieve it.
+ CollectionScope context =
+ new CollectionScopeImpl( new SimpleId( "organization" ), new SimpleId( "parent" ), "tests" );
+
+
+ final Id id = entity.getId();
+ ValidationUtils.verifyIdentity( id );
+ final UUID version = UUIDGenerator.newTimeUUID();
+ final MvccEntity.Status status = MvccEntity.Status.COMPLETE;
+
+ final MvccEntity mvccEntity = new MvccEntityImpl( id, version, status, entity );
+
+
+ getMvccEntitySerializationStrategy().write( context, mvccEntity ).execute();
+
+ //now load it
+ final Iterator<MvccEntity> loaded =
+ getMvccEntitySerializationStrategy().loadDescendingHistory( context, id, version, 100 );
+
+
+ assertLargeEntity( mvccEntity, loaded );
+
+ MvccEntity returned =
+ serializationStrategy.load( context, Collections.singleton( id ), version ).getEntity( id );
+
+ assertLargeEntity( mvccEntity, returned );
+ }
+
+
+
+ /**
+ * Tests an entity with more than 65535 bytes worth of data is successfully stored and retrieved
+ */
+ @Test( expected = EntityTooLargeException.class )
+ public void entityLargerThanAllowedWrite() throws ConnectionException {
+ final int setSize = serializationFig.getMaxEntitySize() + 1;
+
+ final Entity entity = EntityHelper.generateEntity( setSize );
+
+ //now we have one massive, entity, save it and retrieve it.
+ CollectionScope context =
+ new CollectionScopeImpl( new SimpleId( "organization" ), new SimpleId( "parent" ), "tests" );
+
+
+ final Id id = entity.getId();
+ ValidationUtils.verifyIdentity( id );
+ final UUID version = UUIDGenerator.newTimeUUID();
+ final MvccEntity.Status status = MvccEntity.Status.COMPLETE;
+
+ final MvccEntity mvccEntity = new MvccEntityImpl( id, version, status, entity );
+
+
+ getMvccEntitySerializationStrategy().write( context, mvccEntity ).execute();
+ }
+
+
+ protected void assertLargeEntity( final MvccEntity expected, final Iterator<MvccEntity> returned ) {
+ assertTrue( returned.hasNext() );
+
+ final MvccEntity loadedEntity = returned.next();
+
+ assertLargeEntity( expected, loadedEntity );
+ }
+
+
+ protected void assertLargeEntity( final MvccEntity expected, final MvccEntity returned ) {
+
+ org.junit.Assert.assertEquals( "The loaded entity should match the stored entity", expected, returned );
+
+ EntityHelper.verifyDeepEquals( expected.getEntity().get(), returned.getEntity().get() );
+ }
+
+
+
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/fb90ae70/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccLESSTransientTest.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccLESSTransientTest.java b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccLESSTransientTest.java
index 4f96594..09b350c 100644
--- a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccLESSTransientTest.java
+++ b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccLESSTransientTest.java
@@ -24,6 +24,7 @@ import java.lang.annotation.Annotation;
import java.util.Collections;
import java.util.UUID;
+import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
@@ -41,6 +42,7 @@ import org.apache.usergrid.persistence.collection.mvcc.MvccLogEntrySerialization
import org.apache.usergrid.persistence.collection.mvcc.entity.Stage;
import org.apache.usergrid.persistence.collection.mvcc.entity.impl.MvccLogEntryImpl;
import org.apache.usergrid.persistence.collection.serialization.SerializationFig;
+import org.apache.usergrid.persistence.core.guicyfig.SetConfigTestBypass;
import org.apache.usergrid.persistence.core.test.ITRunner;
import org.apache.usergrid.persistence.core.test.UseModules;
import org.apache.usergrid.persistence.model.entity.Id;
@@ -80,58 +82,15 @@ public class MvccLESSTransientTest {
public void setTimeout() {
originalTimeout = serializationFig.getTimeout();
//set the bypass options
- serializationFig.setBypass( new TestByPass() );
+ SetConfigTestBypass.setValueByPass( serializationFig,"getTimeout", "1" );
}
-
- /**
- * Test bypass that sets all environments to use the timeout of 1 second
- */
- public class TestByPass implements Bypass {
-
-
- @Override
- public Option[] options() {
- return new Option[] { new TestOption() };
- }
-
-
- @Override
- public Env[] environments() {
- return new Env[] { Env.ALL, Env.UNIT };
- }
-
-
- @Override
- public Class<? extends Annotation> annotationType() {
- return Bypass.class;
- }
+ @After
+ public void resetTimeout(){
+ SetConfigTestBypass.setValueByPass( serializationFig,"getTimeout", originalTimeout + "" );
}
- /**
- * TestOption
- */
- public class TestOption implements Option {
-
-
- @Override
- public Class<? extends Annotation> annotationType() {
- return Bypass.class;
- }
-
-
- @Override
- public String method() {
- return "getTimeout";
- }
-
-
- @Override
- public String override() {
- return "1";
- }
- }
@Test
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/fb90ae70/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/util/EntityHelper.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/util/EntityHelper.java b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/util/EntityHelper.java
index 5c99121..4dafbaf 100644
--- a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/util/EntityHelper.java
+++ b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/util/EntityHelper.java
@@ -40,34 +40,33 @@ import static org.junit.Assert.assertNotNull;
public class EntityHelper {
/**
- * Generates an entity with all string fields to have at least the minSize
- * number of characters in the field names + field values
- * @param minSize
- * @return
+ * Generates an entity with all string fields to have at least the minSize number of characters in the field names +
+ * field values
*/
- public static Entity generateEntity(final int minSize){
+ public static Entity generateEntity( final int minSize ) {
int currentLength = 0;
- final Entity entity = new Entity( new SimpleId( "test" ) );
+ final Entity entity = new Entity( new SimpleId( "test" ) );
- //generate a really large string value
- StringBuilder builder = new StringBuilder();
+ //generate a really large string value
- for ( int i = 0; i < 100; i++ ) {
- builder.append( UUIDGenerator.newTimeUUID().toString() );
- }
- final String value = builder.toString();
+ //loop until our size is beyond the set size
+ for ( int i = 0; currentLength < minSize; i++ ) {
+ final String key = "newStringField" + i;
+ currentLength += key.length();
- //loop until our size is beyond the set size
- for ( int i = 0; currentLength < minSize; i++ ) {
- final String key = "newStringField" + i;
+ StringBuilder builder = new StringBuilder();
- entity.setField( new StringField( key, value ) );
+ for ( int j = 0; j < 1000 && currentLength < minSize; j++ ) {
+ builder.append( "a" );
+ currentLength ++;
+ }
- currentLength += key.length() + value.length();
- }
+
+ entity.setField( new StringField( key, builder.toString() ) );
+ }
return entity;
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/fb90ae70/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/CassandraFig.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/CassandraFig.java b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/CassandraFig.java
index 4cf76f4..df94adc 100644
--- a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/CassandraFig.java
+++ b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/CassandraFig.java
@@ -39,6 +39,9 @@ public interface CassandraFig extends GuicyFig {
public static final String SHARD_VALUES = "cassandra.shardvalues";
+ public static final String THRIFT_TRANSPORT_SIZE = "cassandra.thrift.transport.frame";
+
+
@Key( "cassandra.hosts" )
String getHosts();
@@ -94,5 +97,14 @@ public interface CassandraFig extends GuicyFig {
@Key(SHARD_VALUES)
String getShardValues();
+ /**
+ * Get the thrift transport size. Should be set to what is on the cassandra servers. As we move to CQL, this will become obsolete
+ * @return
+ */
+ @Key( THRIFT_TRANSPORT_SIZE)
+ @Default( "15728640" )
+ int getThriftBufferSize();
+
+
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/fb90ae70/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/guicyfig/SetConfigTestBypass.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/guicyfig/SetConfigTestBypass.java b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/guicyfig/SetConfigTestBypass.java
new file mode 100644
index 0000000..cb28449
--- /dev/null
+++ b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/guicyfig/SetConfigTestBypass.java
@@ -0,0 +1,108 @@
+/*
+ * 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.core.guicyfig;
+
+
+import java.lang.annotation.Annotation;
+
+import org.safehaus.guicyfig.Bypass;
+import org.safehaus.guicyfig.Env;
+import org.safehaus.guicyfig.GuicyFig;
+import org.safehaus.guicyfig.Option;
+
+
+public class SetConfigTestBypass {
+
+
+ /**
+ * Set the value bypass on the guicyfig
+ * @param guicyFig
+ * @param methodName
+ * @param valueToSet
+ */
+ public static void setValueByPass(final GuicyFig guicyFig, final String methodName, final String valueToSet){
+ guicyFig.setBypass( new TestByPass( methodName, valueToSet ) );
+ }
+
+ /**
+ * Test bypass that sets all environments to use the timeout of 1 second
+ */
+ public static final class TestByPass implements Bypass {
+
+ private Option[] options;
+
+
+ public TestByPass( final String methodName, final String value ) {
+ options = new Option[] { new TestOption( methodName, value ) };
+ }
+
+
+ @Override
+ public Option[] options() {
+ return options;
+ }
+
+
+ @Override
+ public Env[] environments() {
+ return new Env[] { Env.ALL, Env.UNIT };
+ }
+
+
+ @Override
+ public Class<? extends Annotation> annotationType() {
+ return Bypass.class;
+ }
+ }
+
+
+ /**
+ * TestOption
+ */
+ public static final class TestOption implements Option {
+
+ private final String methodName;
+ private final String valueToReturn;
+
+
+ public TestOption( final String methodName, final String valueToReturn ) {
+ this.methodName = methodName;
+ this.valueToReturn = valueToReturn;
+ }
+
+
+ @Override
+ public Class<? extends Annotation> annotationType() {
+ return Bypass.class;
+ }
+
+
+ @Override
+ public String method() {
+ return methodName;
+ }
+
+
+ @Override
+ public String override() {
+ return valueToReturn;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/fb90ae70/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 8eb5625..935fd16 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
@@ -19,28 +19,30 @@
package org.apache.usergrid.persistence.queue;
-import org.apache.usergrid.persistence.queue.guice.TestQueueModule;
-import org.apache.usergrid.persistence.queue.impl.QueueScopeFactoryImpl;
-import org.apache.usergrid.persistence.queue.impl.QueueScopeImpl;
-import org.apache.usergrid.persistence.core.test.UseModules;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.apache.usergrid.persistence.core.test.ITRunner;
+import org.apache.usergrid.persistence.core.test.UseModules;
import org.apache.usergrid.persistence.model.entity.SimpleId;
+import org.apache.usergrid.persistence.queue.guice.TestQueueModule;
+import org.apache.usergrid.persistence.queue.impl.QueueScopeFactoryImpl;
+import org.apache.usergrid.persistence.queue.impl.QueueScopeImpl;
import com.google.inject.Inject;
-import org.safehaus.guicyfig.Bypass;
-import org.safehaus.guicyfig.OptionState;
-import org.safehaus.guicyfig.Overrides;
-
-import java.beans.PropertyChangeListener;
-import java.io.IOException;
-import java.util.*;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
@RunWith( ITRunner.class )
@UseModules( { TestQueueModule.class } )
[11/50] [abbrv] incubator-usergrid git commit: Fixes bugs when
migrations are run by rolling back the the migration version -1,
creating the application at that system version, then running the migration
Posted by sn...@apache.org.
Fixes bugs when migrations are run by rolling back the the migration version -1, creating the application at that system version, then running the migration
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/0857947f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/0857947f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/0857947f
Branch: refs/heads/two-dot-o-events
Commit: 0857947f03a1c9646e0163b4a8485124e6ed6a6c
Parents: 3e21011
Author: Todd Nine <tn...@apigee.com>
Authored: Fri Nov 21 17:54:51 2014 -0700
Committer: Todd Nine <tn...@apigee.com>
Committed: Fri Nov 21 17:54:51 2014 -0700
----------------------------------------------------------------------
.../org/apache/usergrid/CoreApplication.java | 17 +++-
.../migration/EntityDataMigrationIT.java | 16 +--
.../migration/EntityTypeMappingMigrationIT.java | 17 ++++
.../migration/GraphShardVersionMigrationIT.java | 20 ++--
.../migration/MigrationTestRule.java | 101 +++++++++++++++++++
5 files changed, 155 insertions(+), 16 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/0857947f/stack/core/src/test/java/org/apache/usergrid/CoreApplication.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/CoreApplication.java b/stack/core/src/test/java/org/apache/usergrid/CoreApplication.java
index edc887d..1970af5 100644
--- a/stack/core/src/test/java/org/apache/usergrid/CoreApplication.java
+++ b/stack/core/src/test/java/org/apache/usergrid/CoreApplication.java
@@ -145,9 +145,14 @@ public class CoreApplication implements Application, TestRule {
}
- protected void before( Description description ) throws Exception {
- orgName = description.getClassName()+ UUIDGenerator.newTimeUUID();
- appName = description.getMethodName();
+ /**
+ * Create an application with the given app name and org name
+ * @param orgName
+ * @param appName
+ */
+ public void createApplication(final String orgName, final String appName) throws Exception {
+ this.orgName = orgName;
+ this.appName = appName;
id = setup.createApplication( orgName, appName );
assertNotNull( id );
@@ -156,7 +161,13 @@ public class CoreApplication implements Application, TestRule {
LOG.info( "Created new application {} in organization {}", appName, orgName );
+ }
+
+ protected void before( Description description ) throws Exception {
+ final String orgName = description.getClassName()+ UUIDGenerator.newTimeUUID();
+ final String appName = description.getMethodName();
+ createApplication( orgName, appName );
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/0857947f/stack/core/src/test/java/org/apache/usergrid/corepersistence/migration/EntityDataMigrationIT.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/corepersistence/migration/EntityDataMigrationIT.java b/stack/core/src/test/java/org/apache/usergrid/corepersistence/migration/EntityDataMigrationIT.java
index b8c0093..d5f2fe1 100644
--- a/stack/core/src/test/java/org/apache/usergrid/corepersistence/migration/EntityDataMigrationIT.java
+++ b/stack/core/src/test/java/org/apache/usergrid/corepersistence/migration/EntityDataMigrationIT.java
@@ -25,6 +25,7 @@ import java.util.Iterator;
import java.util.Set;
import org.junit.Before;
+import org.junit.Rule;
import org.junit.Test;
import org.apache.usergrid.AbstractCoreIT;
@@ -73,6 +74,13 @@ public class EntityDataMigrationIT extends AbstractCoreIT {
private EntityManagerFactory emf;
+
+ /**
+ * Rule to do the resets we need
+ */
+ @Rule
+ public MigrationTestRule migrationTestRule = new MigrationTestRule( app, CpSetup.getInjector() ,EntityDataMigration.class );
+
@Before
public void setup() {
emf = setup.getEmf();
@@ -90,13 +98,7 @@ public class EntityDataMigrationIT extends AbstractCoreIT {
public void testDataMigration() throws Throwable {
assertEquals( "version 3 expected", 3, entityDataMigration.getVersion() );
-
-
- /**
- * Reset to our version -1 and start the migration
- */
- dataMigrationManager.resetToVersion( entityDataMigration.getVersion() - 1 );
- dataMigrationManager.invalidate();
+ assertEquals( "Previous version expected", 2, dataMigrationManager.getCurrentVersion());
final EntityManager newAppEm = app.getEntityManager();
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/0857947f/stack/core/src/test/java/org/apache/usergrid/corepersistence/migration/EntityTypeMappingMigrationIT.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/corepersistence/migration/EntityTypeMappingMigrationIT.java b/stack/core/src/test/java/org/apache/usergrid/corepersistence/migration/EntityTypeMappingMigrationIT.java
index 1f0665a..3a52b96 100644
--- a/stack/core/src/test/java/org/apache/usergrid/corepersistence/migration/EntityTypeMappingMigrationIT.java
+++ b/stack/core/src/test/java/org/apache/usergrid/corepersistence/migration/EntityTypeMappingMigrationIT.java
@@ -24,6 +24,7 @@ import java.util.HashSet;
import java.util.Set;
import org.junit.Before;
+import org.junit.Rule;
import org.junit.Test;
import org.apache.usergrid.AbstractCoreIT;
@@ -35,8 +36,10 @@ import org.apache.usergrid.corepersistence.util.CpNamingUtils;
import org.apache.usergrid.persistence.Entity;
import org.apache.usergrid.persistence.EntityManager;
import org.apache.usergrid.persistence.EntityManagerFactory;
+import org.apache.usergrid.persistence.core.migration.data.DataMigrationManager;
import org.apache.usergrid.persistence.map.impl.MapSerializationImpl;
import org.apache.usergrid.persistence.model.entity.Id;
+import org.apache.usergrid.persistence.model.util.UUIDGenerator;
import com.google.inject.Injector;
import com.netflix.astyanax.Keyspace;
@@ -58,6 +61,15 @@ public class EntityTypeMappingMigrationIT extends AbstractCoreIT {
private Keyspace keyspace;
private EntityManagerFactory emf;
private ManagerCache managerCache;
+ private DataMigrationManager dataMigrationManager;
+
+
+ /**
+ * Rule to do the resets we need
+ */
+ @Rule
+ public MigrationTestRule migrationTestRule = new MigrationTestRule( app, CpSetup.getInjector() ,EntityTypeMappingMigration.class );
+
@Before
@@ -67,6 +79,7 @@ public class EntityTypeMappingMigrationIT extends AbstractCoreIT {
entityTypeMappingMigration = injector.getInstance( EntityTypeMappingMigration.class );
keyspace = injector.getInstance( Keyspace.class );
managerCache = injector.getInstance( ManagerCache.class );
+ dataMigrationManager = injector.getInstance( DataMigrationManager.class );
}
@@ -74,6 +87,7 @@ public class EntityTypeMappingMigrationIT extends AbstractCoreIT {
public void testIdMapping() throws Throwable {
assertEquals( "version 1 expected", 1, entityTypeMappingMigration.getVersion() );
+ assertEquals( "Previous version expected", 0, dataMigrationManager.getCurrentVersion());
final EntityManager newAppEm = app.getEntityManager();
@@ -97,6 +111,9 @@ public class EntityTypeMappingMigrationIT extends AbstractCoreIT {
keyspace.truncateColumnFamily( MapSerializationImpl.MAP_ENTRIES );
keyspace.truncateColumnFamily( MapSerializationImpl.MAP_KEYS );
+ app.createApplication( GraphShardVersionMigrationIT.class.getSimpleName()+ UUIDGenerator.newTimeUUID(), "migrationTest" );
+
+
final TestProgressObserver progressObserver = new TestProgressObserver();
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/0857947f/stack/core/src/test/java/org/apache/usergrid/corepersistence/migration/GraphShardVersionMigrationIT.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/corepersistence/migration/GraphShardVersionMigrationIT.java b/stack/core/src/test/java/org/apache/usergrid/corepersistence/migration/GraphShardVersionMigrationIT.java
index e119788..3ab9f63 100644
--- a/stack/core/src/test/java/org/apache/usergrid/corepersistence/migration/GraphShardVersionMigrationIT.java
+++ b/stack/core/src/test/java/org/apache/usergrid/corepersistence/migration/GraphShardVersionMigrationIT.java
@@ -24,9 +24,11 @@ import java.util.HashSet;
import java.util.Set;
import org.junit.Before;
+import org.junit.Rule;
import org.junit.Test;
import org.apache.usergrid.AbstractCoreIT;
+import org.apache.usergrid.CoreApplication;
import org.apache.usergrid.corepersistence.CpSetup;
import org.apache.usergrid.corepersistence.EntityWriteHelper;
import org.apache.usergrid.corepersistence.ManagerCache;
@@ -35,9 +37,11 @@ import org.apache.usergrid.persistence.EntityManager;
import org.apache.usergrid.persistence.core.migration.data.DataMigrationManager;
import org.apache.usergrid.persistence.core.migration.data.DataMigrationManagerImpl;
import org.apache.usergrid.persistence.core.migration.data.MigrationInfoSerialization;
+import org.apache.usergrid.persistence.core.migration.schema.MigrationException;
import org.apache.usergrid.persistence.graph.GraphManager;
import org.apache.usergrid.persistence.graph.impl.SimpleSearchEdgeType;
import org.apache.usergrid.persistence.model.entity.Id;
+import org.apache.usergrid.persistence.model.util.UUIDGenerator;
import com.google.common.collect.HashMultimap;
import com.google.common.collect.Multimap;
@@ -59,6 +63,14 @@ public class GraphShardVersionMigrationIT extends AbstractCoreIT {
private MigrationInfoSerialization migrationInfoSerialization;
+ /**
+ * Rule to do the resets we need
+ */
+ @Rule
+ public MigrationTestRule migrationTestRule = new MigrationTestRule( app, CpSetup.getInjector() ,GraphShardVersionMigration.class );
+
+
+
@Before
public void setup() {
injector = CpSetup.getInjector();
@@ -66,6 +78,7 @@ public class GraphShardVersionMigrationIT extends AbstractCoreIT {
managerCache = injector.getInstance( ManagerCache.class );
dataMigrationManager = injector.getInstance( DataMigrationManager.class );
migrationInfoSerialization = injector.getInstance( MigrationInfoSerialization.class );
+
}
@@ -73,12 +86,7 @@ public class GraphShardVersionMigrationIT extends AbstractCoreIT {
public void testIdMapping() throws Throwable {
assertEquals( "version 2 expected", 2, graphShardVersionMigration.getVersion() );
-
- /**
- * Reset to our version -1 and start the migration
- */
- dataMigrationManager.resetToVersion( graphShardVersionMigration.getVersion() - 1 );
- dataMigrationManager.invalidate();
+ assertEquals( "Previous version expected", 1, dataMigrationManager.getCurrentVersion());
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/0857947f/stack/core/src/test/java/org/apache/usergrid/corepersistence/migration/MigrationTestRule.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/corepersistence/migration/MigrationTestRule.java b/stack/core/src/test/java/org/apache/usergrid/corepersistence/migration/MigrationTestRule.java
new file mode 100644
index 0000000..13d06ee
--- /dev/null
+++ b/stack/core/src/test/java/org/apache/usergrid/corepersistence/migration/MigrationTestRule.java
@@ -0,0 +1,101 @@
+/*
+ * 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.corepersistence.migration;
+
+
+import org.junit.rules.TestRule;
+import org.junit.runner.Description;
+import org.junit.runners.model.Statement;
+
+import org.apache.usergrid.CoreApplication;
+import org.apache.usergrid.persistence.core.migration.data.DataMigration;
+import org.apache.usergrid.persistence.core.migration.data.DataMigrationManager;
+import org.apache.usergrid.persistence.model.util.UUIDGenerator;
+
+import com.google.inject.Injector;
+
+
+/**
+ * This class is required because we cannot create the system's framework on a higher version (the default behavior is
+ * the latest) then roll back to a previous version
+ *
+ * This rule performs the following operations.
+ *
+ * <ol> <li>Sets up the system's version to be the DataMigration impl's version -1</li> <li>Creates an application using
+ * that version of the schema.</li> <li>Sets the new org and app in the CoreApplication to the app created</li> </ol>
+ */
+public class MigrationTestRule implements TestRule {
+
+ protected final CoreApplication core;
+ protected final DataMigrationManager dataMigrationManager;
+ protected final DataMigration dataMigration;
+
+ protected int currentVersion;
+
+
+ /**
+ * Create a new migration test rule.
+ *
+ * @param core the CoreApplication rule used in this test
+ * @param injector The injector used in this test
+ * @param dataMigrationClass The data migration class that is under test
+ */
+ public MigrationTestRule( final CoreApplication core, final Injector injector,
+ final Class<? extends DataMigration> dataMigrationClass ) {
+ this.core = core;
+ this.dataMigrationManager = injector.getInstance( DataMigrationManager.class );
+ this.dataMigration = injector.getInstance( dataMigrationClass );
+ }
+
+
+ public void resetAndCreateApp( final String className, final String methodName ) throws Exception {
+ dataMigrationManager.invalidate();
+ currentVersion = dataMigrationManager.getCurrentVersion();
+
+ dataMigrationManager.resetToVersion( dataMigration.getVersion() - 1 );
+ dataMigrationManager.invalidate();
+
+ core.createApplication( className + UUIDGenerator.newTimeUUID(), methodName );
+ }
+
+
+ public void resetVersion(){
+ dataMigrationManager.resetToVersion( currentVersion );
+ dataMigrationManager.invalidate();
+ }
+
+ @Override
+ public Statement apply( final Statement base, final Description description ) {
+
+ return new Statement() {
+ @Override
+ public void evaluate() throws Throwable {
+ try {
+ resetAndCreateApp( description.getClassName(), description.getMethodName() );
+
+
+ base.evaluate();
+ }finally {
+ resetVersion();
+ }
+ }
+ };
+ }
+}
[24/50] [abbrv] incubator-usergrid git commit: Merge branch
'two-dot-o' into two-dot-o-events
Posted by sn...@apache.org.
Merge branch 'two-dot-o' into two-dot-o-events
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/88d49cb8
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/88d49cb8
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/88d49cb8
Branch: refs/heads/two-dot-o-events
Commit: 88d49cb8d7123276db0a4dabb78061f4465b0ccf
Parents: 5f0dc34 ce20abe
Author: Dave Johnson <dm...@apigee.com>
Authored: Tue Nov 25 11:24:00 2014 -0500
Committer: Dave Johnson <dm...@apigee.com>
Committed: Tue Nov 25 11:24:00 2014 -0500
----------------------------------------------------------------------
.../org/apache/usergrid/CoreApplication.java | 17 +-
.../migration/EntityDataMigrationIT.java | 16 +-
.../migration/EntityTypeMappingMigrationIT.java | 17 +
.../migration/GraphShardVersionMigrationIT.java | 20 +-
.../migration/MigrationTestRule.java | 101 ++++
.../org/apache/usergrid/persistence/GeoIT.java | 579 ++++++++++---------
.../applications/queries/BasicGeoTests.java | 268 +++++++++
.../applications/queries/basicGeoTests.java | 184 ------
8 files changed, 728 insertions(+), 474 deletions(-)
----------------------------------------------------------------------
[13/50] [abbrv] incubator-usergrid git commit: Anther merge fix.
Posted by sn...@apache.org.
Anther merge fix.
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/1884cce1
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/1884cce1
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/1884cce1
Branch: refs/heads/two-dot-o-events
Commit: 1884cce15e299f31c72caa1ae15cc07bf9545dc0
Parents: 2ee0eff
Author: Dave Johnson <dm...@apigee.com>
Authored: Mon Nov 24 10:42:55 2014 -0500
Committer: Dave Johnson <dm...@apigee.com>
Committed: Mon Nov 24 10:42:55 2014 -0500
----------------------------------------------------------------------
.../apache/usergrid/corepersistence/GuiceModule.java | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/1884cce1/stack/core/src/main/java/org/apache/usergrid/corepersistence/GuiceModule.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/GuiceModule.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/GuiceModule.java
index 98f473a..a57158f 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/GuiceModule.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/GuiceModule.java
@@ -65,6 +65,13 @@ public class GuiceModule extends AbstractModule {
install(new MapModule());
install(new QueueModule());
+ bind(ManagerCache.class).to( CpManagerCache.class );
+
+ Multibinder<DataMigration> dataMigrationMultibinder = Multibinder.newSetBinder( binder(), DataMigration.class );
+ dataMigrationMultibinder.addBinding().to( EntityTypeMappingMigration.class );
+ dataMigrationMultibinder.addBinding().to( GraphShardVersionMigration.class );
+ //dataMigrationMultibinder.addBinding().to( EntityDataMigration.class );
+
Multibinder<EntityDeleted> entityBinder =
Multibinder.newSetBinder(binder(), EntityDeleted.class);
entityBinder.addBinding().to(EntityDeletedHandler.class);
@@ -77,10 +84,7 @@ public class GuiceModule extends AbstractModule {
Multibinder.newSetBinder( binder(), EntityVersionCreated.class );
versionCreatedMultibinder.addBinding().to(EntityVersionCreatedHandler.class);
- Multibinder<DataMigration> dataMigrationMultibinder =
- Multibinder.newSetBinder( binder(), DataMigration.class );
- dataMigrationMultibinder.addBinding().to( EntityTypeMappingMigration.class );
- dataMigrationMultibinder.addBinding().to( GraphShardVersionMigration.class );
+
}
}
[19/50] [abbrv] incubator-usergrid git commit: fixed file name
Posted by sn...@apache.org.
fixed file name
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/39aaca6d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/39aaca6d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/39aaca6d
Branch: refs/heads/two-dot-o-events
Commit: 39aaca6d471663cd6debe21bf640cbbcb04d8fc7
Parents: c451178
Author: Rod Simpson <ro...@apigee.com>
Authored: Mon Nov 24 18:33:28 2014 -0700
Committer: Rod Simpson <ro...@apigee.com>
Committed: Mon Nov 24 18:33:28 2014 -0700
----------------------------------------------------------------------
.../applications/queries/BasicGeoTests.java | 268 +++++++++++++++++++
.../applications/queries/StandardGeoTests.java | 268 -------------------
2 files changed, 268 insertions(+), 268 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/39aaca6d/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/BasicGeoTests.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/BasicGeoTests.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/BasicGeoTests.java
new file mode 100644
index 0000000..3e9bd85
--- /dev/null
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/BasicGeoTests.java
@@ -0,0 +1,268 @@
+/*
+ * 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.rest.applications.queries;
+
+
+import java.util.*;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.sun.jersey.api.client.UniformInterfaceException;
+
+import java.io.IOException;
+
+import org.apache.usergrid.persistence.Entity;
+import org.apache.usergrid.persistence.EntityManager;
+import org.apache.usergrid.persistence.Results;
+
+import org.jclouds.json.Json;
+import org.junit.Rule;
+import org.junit.Test;
+
+import org.apache.usergrid.persistence.geo.model.Point;
+import org.apache.usergrid.persistence.index.query.Query;
+import org.apache.usergrid.persistence.index.utils.UUIDUtils;
+import org.apache.usergrid.rest.AbstractRestIT;
+import org.apache.usergrid.rest.TestContextSetup;
+import org.apache.usergrid.rest.test.resource.CustomCollection;
+
+import static org.junit.Assert.assertEquals;
+import static org.apache.usergrid.utils.MapUtils.hashMap;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
+
+
+/**
+ * Basic Geo Tests - CRUD entities with geo points, exceptions for malformed calls
+ *
+ * @author rockerston
+ */
+public class BasicGeoTests extends AbstractRestIT {
+
+ @Rule
+ public TestContextSetup context = new TestContextSetup( this );
+
+ public final String latitude = "latitude";
+
+ /**
+ * Create a entity with a geo location point in it
+ * 1. Create entity
+ * 2. Verify that the entity was created
+ */
+ @Test
+ public void createEntityWithGeoLocationPoint() throws IOException {
+
+ String collectionType = "stores";
+ JsonNode node = null;
+ Double lat = 37.776753;
+ Double lon = -122.407846;
+ //1. Create entity
+ Map<String, Double> latLon = hashMap("latitude", lat);
+ latLon.put( "longitude", lon );
+ Map<String, Object> entityData = new HashMap<String, Object>();
+ entityData.put( "location", latLon );
+
+ try {
+ node = context.collection( collectionType ).post( entityData );
+ }
+ catch ( UniformInterfaceException e ) {
+ JsonNode nodeError = mapper.readTree( e.getResponse().getEntity( String.class ) );
+ fail( nodeError.get( "error" ).textValue() );
+ }
+
+ //2. Verify that the entity was created
+ assertNotNull( node );
+ assertEquals( lat.toString(), node.get("location").get("latitude").asText() );
+ assertEquals( lon.toString(), node.get( "location" ).get("longitude").asText() );
+
+ }
+
+ /**
+ * Update an entity with a geo location point in it
+ * 1. create an entity with a geo point
+ * 2. read back that entity make sure it is accurate
+ * 3. update the geo point to a new value
+ * 4. read back the updated entity, make sure it is accurate
+ */
+ @Test
+ public void updateEntityWithGeoLocationPoint() throws IOException {
+
+ String collectionType = "stores";
+ String entityName = "cornerStore";
+ JsonNode entity = null;
+ Double lat = 37.776753;
+ Double lon = -122.407846;
+
+ //1. create an entity with a geo point
+ Map<String, Double> latLon = hashMap("latitude", lat);
+ latLon.put( "longitude", lon );
+ Map<String, Object> entityData = new HashMap<String, Object>();
+ entityData.put( "location", latLon );
+ entityData.put( "name", entityName );
+
+ try {
+ entity = context.collection( collectionType ).post( entityData );
+ }
+ catch ( UniformInterfaceException e ) {
+ JsonNode nodeError = mapper.readTree( e.getResponse().getEntity( String.class ) );
+ fail( nodeError.get( "error" ).textValue() );
+ }
+
+ assertNotNull(entity);
+ assertEquals( lat.toString(), entity.get("location").get("latitude").asText() );
+ assertEquals( lon.toString(), entity.get( "location" ).get("longitude").asText() );
+
+ context.refreshIndex();
+
+ //2. read back that entity make sure it is accurate
+ /*
+ try {
+ node = context.collection( collectionType ).get(entityName);
+ }
+ catch ( UniformInterfaceException e ) {
+ JsonNode nodeError = mapper.readTree( e.getResponse().getEntity( String.class ) );
+ fail( nodeError.get( "error" ).textValue() );
+ }
+
+ //3. update the geo point to a new value
+ Double newLat = 35.776753;
+ Double newLon = -119.407846;
+ latLon.put( "latitude", newLat );
+ latLon.put( "longitude", newLon );
+ entityData.put( "location", latLon );
+
+ //TODO PUT should take name property and append it to URL - e.g. PUT /cats/fluffy not PUT /cats {"name":"fluffy"}
+ try {
+ //node = context.collection( collectionType ).put(entityData);
+ //entity.put(entityData);
+
+ }
+ catch ( UniformInterfaceException e ) {
+ JsonNode nodeError = mapper.readTree( e.getResponse().getEntity( String.class ) );
+ fail( nodeError.get( "error" ).textValue() );
+ }
+
+ assertNotNull(entity);
+ assertEquals( newLat.toString(), entity.get("location").get("latitude").asText() );
+ assertEquals( newLon.toString(), entity.get( "location" ).get("longitude").asText() );
+ */
+
+ context.refreshIndex();
+
+ //4. read back the updated entity, make sure it is accurate
+
+
+
+
+
+ }
+
+ /**
+ * Test exceptions for entities with poorly created geo points
+ * 1. misspell latitude
+ * 2. misspell longitude
+ */
+ @Test
+ public void createEntitiesWithBadSpelling() throws IOException {
+
+ String collectionType = "stores";
+ JsonNode node = null;
+ Double lat = 37.776753;
+ Double lon = -122.407846;
+
+ // 1. misspell latitude
+ Map<String, Double> misspelledLatitude = hashMap("latitudee", lat);
+ misspelledLatitude.put( "longitude", lon );
+ Map<String, Object> misspelledLatitudeEntityData = new HashMap<String, Object>();
+ misspelledLatitudeEntityData.put( "location", misspelledLatitude );
+
+ try {
+ node = context.collection( collectionType ).post( misspelledLatitudeEntityData );
+ fail("System allowed misspelled location property - latitudee, which it should not");
+ }
+ catch ( UniformInterfaceException e ) {
+ //verify the correct error was returned
+ JsonNode nodeError = mapper.readTree( e.getResponse().getEntity( String.class ));
+ assertEquals( "illegal_argument", nodeError.get( "error" ).textValue() );
+ }
+
+ // 2. misspell longitude
+ Map<String, Double> misspelledLongitude = hashMap("latitude", lat);
+ misspelledLongitude.put( "longitudee", lon );
+ Map<String, Object> misspelledLongitudeEntityData = new HashMap<String, Object>();
+ misspelledLongitudeEntityData.put( "location", misspelledLongitude );
+
+ try {
+ node = context.collection( collectionType ).post( misspelledLongitudeEntityData );
+ fail("System allowed misspelled location property - longitudee, which it should not");
+ }
+ catch ( UniformInterfaceException e ) {
+ //verify the correct error was returned
+ JsonNode nodeError = mapper.readTree( e.getResponse().getEntity( String.class ));
+ assertEquals( "illegal_argument", nodeError.get( "error" ).textValue() );
+ }
+
+ }
+
+
+ /**
+ * Test exceptions for entities with poorly created geo points
+ * 1. pass only one point instead of two
+ * 2. pass a values that are not doubles
+ */
+ @Test
+ public void createEntitiesWithBadPoints() throws IOException {
+
+ String collectionType = "stores";
+ JsonNode node = null;
+ Double lat = 37.776753;
+ Double lon = -122.407846;
+
+ // 1. pass only one point instead of two
+ Map<String, Double> latitudeOnly = hashMap("latitude", lat);
+ Map<String, Object> latitudeOnlyEntityData = new HashMap<String, Object>();
+ latitudeOnlyEntityData.put( "location", latitudeOnly );
+
+ try {
+ node = context.collection( collectionType ).post( latitudeOnlyEntityData );
+ fail("System allowed location with only one point, latitude, which it should not");
+ }
+ catch ( UniformInterfaceException e ) {
+ //verify the correct error was returned
+ JsonNode nodeError = mapper.readTree( e.getResponse().getEntity( String.class ));
+ assertEquals( "illegal_argument", nodeError.get( "error" ).textValue() );
+ }
+
+ // 2. pass a values that are not doubles
+ Map<String, String> notDoubleLatLon = hashMap("latitude", "fred");
+ notDoubleLatLon.put( "longitude", "barney" );
+ Map<String, Object> notDoubleLatLonEntityData = new HashMap<String, Object>();
+ notDoubleLatLonEntityData.put( "location", notDoubleLatLon );
+
+ try {
+ node = context.collection( collectionType ).post( notDoubleLatLonEntityData );
+ fail("System allowed misspelled location values that are not doubles for latitude and longitude, which it should not");
+ }
+ catch ( UniformInterfaceException e ) {
+ //verify the correct error was returned
+ JsonNode nodeError = mapper.readTree( e.getResponse().getEntity( String.class ));
+ assertEquals( "illegal_argument", nodeError.get( "error" ).textValue() );
+ }
+
+
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/39aaca6d/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/StandardGeoTests.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/StandardGeoTests.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/StandardGeoTests.java
deleted file mode 100644
index 1879c55..0000000
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/StandardGeoTests.java
+++ /dev/null
@@ -1,268 +0,0 @@
-/*
- * 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.rest.applications.queries;
-
-
-import java.util.*;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.sun.jersey.api.client.UniformInterfaceException;
-
-import java.io.IOException;
-
-import org.apache.usergrid.persistence.Entity;
-import org.apache.usergrid.persistence.EntityManager;
-import org.apache.usergrid.persistence.Results;
-
-import org.jclouds.json.Json;
-import org.junit.Rule;
-import org.junit.Test;
-
-import org.apache.usergrid.persistence.geo.model.Point;
-import org.apache.usergrid.persistence.index.query.Query;
-import org.apache.usergrid.persistence.index.utils.UUIDUtils;
-import org.apache.usergrid.rest.AbstractRestIT;
-import org.apache.usergrid.rest.TestContextSetup;
-import org.apache.usergrid.rest.test.resource.CustomCollection;
-
-import static org.junit.Assert.assertEquals;
-import static org.apache.usergrid.utils.MapUtils.hashMap;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.fail;
-
-
-/**
- * Basic Geo Tests - CRUD entities with geo points, exceptions for malformed calls
- *
- * @author rockerston
- */
-public class StandardGeoTests extends AbstractRestIT {
-
- @Rule
- public TestContextSetup context = new TestContextSetup( this );
-
- public final String latitude = "latitude";
-
- /**
- * Create a entity with a geo location point in it
- * 1. Create entity
- * 2. Verify that the entity was created
- */
- @Test
- public void createEntityWithGeoLocationPoint() throws IOException {
-
- String collectionType = "stores";
- JsonNode node = null;
- Double lat = 37.776753;
- Double lon = -122.407846;
- //1. Create entity
- Map<String, Double> latLon = hashMap("latitude", lat);
- latLon.put( "longitude", lon );
- Map<String, Object> entityData = new HashMap<String, Object>();
- entityData.put( "location", latLon );
-
- try {
- node = context.collection( collectionType ).post( entityData );
- }
- catch ( UniformInterfaceException e ) {
- JsonNode nodeError = mapper.readTree( e.getResponse().getEntity( String.class ) );
- fail( nodeError.get( "error" ).textValue() );
- }
-
- //2. Verify that the entity was created
- assertNotNull( node );
- assertEquals( lat.toString(), node.get("location").get("latitude").asText() );
- assertEquals( lon.toString(), node.get( "location" ).get("longitude").asText() );
-
- }
-
- /**
- * Update an entity with a geo location point in it
- * 1. create an entity with a geo point
- * 2. read back that entity make sure it is accurate
- * 3. update the geo point to a new value
- * 4. read back the updated entity, make sure it is accurate
- */
- @Test
- public void updateEntityWithGeoLocationPoint() throws IOException {
-
- String collectionType = "stores";
- String entityName = "cornerStore";
- JsonNode entity = null;
- Double lat = 37.776753;
- Double lon = -122.407846;
-
- //1. create an entity with a geo point
- Map<String, Double> latLon = hashMap("latitude", lat);
- latLon.put( "longitude", lon );
- Map<String, Object> entityData = new HashMap<String, Object>();
- entityData.put( "location", latLon );
- entityData.put( "name", entityName );
-
- try {
- entity = context.collection( collectionType ).post( entityData );
- }
- catch ( UniformInterfaceException e ) {
- JsonNode nodeError = mapper.readTree( e.getResponse().getEntity( String.class ) );
- fail( nodeError.get( "error" ).textValue() );
- }
-
- assertNotNull(entity);
- assertEquals( lat.toString(), entity.get("location").get("latitude").asText() );
- assertEquals( lon.toString(), entity.get( "location" ).get("longitude").asText() );
-
- context.refreshIndex();
-
- //2. read back that entity make sure it is accurate
- /*
- try {
- node = context.collection( collectionType ).get(entityName);
- }
- catch ( UniformInterfaceException e ) {
- JsonNode nodeError = mapper.readTree( e.getResponse().getEntity( String.class ) );
- fail( nodeError.get( "error" ).textValue() );
- }
-
- //3. update the geo point to a new value
- Double newLat = 35.776753;
- Double newLon = -119.407846;
- latLon.put( "latitude", newLat );
- latLon.put( "longitude", newLon );
- entityData.put( "location", latLon );
-
- //TODO PUT should take name property and append it to URL - e.g. PUT /cats/fluffy not PUT /cats {"name":"fluffy"}
- try {
- //node = context.collection( collectionType ).put(entityData);
- //entity.put(entityData);
-
- }
- catch ( UniformInterfaceException e ) {
- JsonNode nodeError = mapper.readTree( e.getResponse().getEntity( String.class ) );
- fail( nodeError.get( "error" ).textValue() );
- }
-
- assertNotNull(entity);
- assertEquals( newLat.toString(), entity.get("location").get("latitude").asText() );
- assertEquals( newLon.toString(), entity.get( "location" ).get("longitude").asText() );
- */
-
- context.refreshIndex();
-
- //4. read back the updated entity, make sure it is accurate
-
-
-
-
-
- }
-
- /**
- * Test exceptions for entities with poorly created geo points
- * 1. misspell latitude
- * 2. misspell longitude
- */
- @Test
- public void createEntitiesWithBadSpelling() throws IOException {
-
- String collectionType = "stores";
- JsonNode node = null;
- Double lat = 37.776753;
- Double lon = -122.407846;
-
- // 1. misspell latitude
- Map<String, Double> misspelledLatitude = hashMap("latitudee", lat);
- misspelledLatitude.put( "longitude", lon );
- Map<String, Object> misspelledLatitudeEntityData = new HashMap<String, Object>();
- misspelledLatitudeEntityData.put( "location", misspelledLatitude );
-
- try {
- node = context.collection( collectionType ).post( misspelledLatitudeEntityData );
- fail("System allowed misspelled location property - latitudee, which it should not");
- }
- catch ( UniformInterfaceException e ) {
- //verify the correct error was returned
- JsonNode nodeError = mapper.readTree( e.getResponse().getEntity( String.class ));
- assertEquals( "illegal_argument", nodeError.get( "error" ).textValue() );
- }
-
- // 2. misspell longitude
- Map<String, Double> misspelledLongitude = hashMap("latitude", lat);
- misspelledLongitude.put( "longitudee", lon );
- Map<String, Object> misspelledLongitudeEntityData = new HashMap<String, Object>();
- misspelledLongitudeEntityData.put( "location", misspelledLongitude );
-
- try {
- node = context.collection( collectionType ).post( misspelledLongitudeEntityData );
- fail("System allowed misspelled location property - longitudee, which it should not");
- }
- catch ( UniformInterfaceException e ) {
- //verify the correct error was returned
- JsonNode nodeError = mapper.readTree( e.getResponse().getEntity( String.class ));
- assertEquals( "illegal_argument", nodeError.get( "error" ).textValue() );
- }
-
- }
-
-
- /**
- * Test exceptions for entities with poorly created geo points
- * 1. pass only one point instead of two
- * 2. pass a values that are not doubles
- */
- @Test
- public void createEntitiesWithBadPoints() throws IOException {
-
- String collectionType = "stores";
- JsonNode node = null;
- Double lat = 37.776753;
- Double lon = -122.407846;
-
- // 1. pass only one point instead of two
- Map<String, Double> latitudeOnly = hashMap("latitude", lat);
- Map<String, Object> latitudeOnlyEntityData = new HashMap<String, Object>();
- latitudeOnlyEntityData.put( "location", latitudeOnly );
-
- try {
- node = context.collection( collectionType ).post( latitudeOnlyEntityData );
- fail("System allowed location with only one point, latitude, which it should not");
- }
- catch ( UniformInterfaceException e ) {
- //verify the correct error was returned
- JsonNode nodeError = mapper.readTree( e.getResponse().getEntity( String.class ));
- assertEquals( "illegal_argument", nodeError.get( "error" ).textValue() );
- }
-
- // 2. pass a values that are not doubles
- Map<String, String> notDoubleLatLon = hashMap("latitude", "fred");
- notDoubleLatLon.put( "longitude", "barney" );
- Map<String, Object> notDoubleLatLonEntityData = new HashMap<String, Object>();
- notDoubleLatLonEntityData.put( "location", notDoubleLatLon );
-
- try {
- node = context.collection( collectionType ).post( notDoubleLatLonEntityData );
- fail("System allowed misspelled location values that are not doubles for latitude and longitude, which it should not");
- }
- catch ( UniformInterfaceException e ) {
- //verify the correct error was returned
- JsonNode nodeError = mapper.readTree( e.getResponse().getEntity( String.class ));
- assertEquals( "illegal_argument", nodeError.get( "error" ).textValue() );
- }
-
-
- }
-
-}
[16/50] [abbrv] incubator-usergrid git commit: Updated gatling
cluster launcher to tag instances
Posted by sn...@apache.org.
Updated gatling cluster launcher to tag instances
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/1f75549e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/1f75549e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/1f75549e
Branch: refs/heads/two-dot-o-events
Commit: 1f75549e9971f80ff56cc60774318e6f08a4cb38
Parents: 6d4a823
Author: Todd Nine <tn...@apigee.com>
Authored: Mon Nov 24 17:47:47 2014 -0700
Committer: Todd Nine <tn...@apigee.com>
Committed: Mon Nov 24 17:47:47 2014 -0700
----------------------------------------------------------------------
stack/awscluster/gatling-cluster-cf.json | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/1f75549e/stack/awscluster/gatling-cluster-cf.json
----------------------------------------------------------------------
diff --git a/stack/awscluster/gatling-cluster-cf.json b/stack/awscluster/gatling-cluster-cf.json
index 16b8d5b..ff41f14 100644
--- a/stack/awscluster/gatling-cluster-cf.json
+++ b/stack/awscluster/gatling-cluster-cf.json
@@ -216,20 +216,22 @@
"apt-get install zip unzip wget -y\n",
"wget https://bootstrap.pypa.io/ez_setup.py -O - | python\n",
"easy_install https://s3.amazonaws.com/cloudformation-examples/aws-cfn-bootstrap-latest.tar.gz\n",
- "/usr/local/bin/cfn-init -v ",
+ "## These don't seem to work correctly and cause script to bail. Temporarily removing \n",
+ "#/usr/local/bin/cfn-init -v ",
" --stack ", { "Ref" : "AWS::StackName" },
" --resource LaunchConfig ",
" --region ", { "Ref" : "AWS::Region" }, "\n",
- "/usr/local/bin/cfn-signal -e $? ",
+ "#/usr/local/bin/cfn-signal -e $? ",
" --stack ", { "Ref" : "AWS::StackName" },
" --resource GatlingServerGroup ",
" --region ", { "Ref" : "AWS::Region" }, "\n",
- "add-apt-repository ppa:webupd8team/java\n",
+ "add-apt-repository ppa:webupd8team/java --yes\n",
+ "apt-add-repository ppa:awstools-dev/awstools --yes\n",
"apt-get update\n",
"echo oracle-java7-installer shared/accepted-oracle-license-v1-1 select true | /usr/bin/debconf-set-selections\n",
- "apt-get install oracle-java7-installer oracle-java7-set-default expect expect-dev git -y --force-yes\n",
+ "apt-get install oracle-java7-installer oracle-java7-set-default expect expect-dev git ec2-api-tools -y --force-yes\n",
"update-java-alternatives -s java-7-oracle\n",
"mkdir -p /usr/local/apache-maven\n",
@@ -238,7 +240,8 @@
"tar -xzvf apache-maven-3.1.1-bin.tar.gz\n",
"cd ~ubuntu\n",
"git clone https://github.com/apache/incubator-usergrid.git usergrid\n",
- "chown -R ubuntu:ubuntu usergrid\n"
+ "chown -R ubuntu:ubuntu usergrid\n",
+ "ec2-create-tags $(curl -k http://169.254.169.254/latest/meta-data/instance-id) --aws-access-key ",{ "Ref":"GatlingKey" }, " --aws-secret-key ", { "Fn::GetAtt":[ "GatlingKey", "SecretAccessKey" ] } ," --tag Name=", { "Ref":"AWS::StackName" }, "-Gatling\n"
]]}}
}
},
@@ -356,4 +359,4 @@
"Value" : { "Fn::Join" : [ "", [ "http://", { "Fn::GetAtt" : [ "ElasticLoadBalancer", "DNSName" ]}]]}
}
}
-}
\ No newline at end of file
+}
[30/50] [abbrv] incubator-usergrid git commit: Merge branch
'two-dot-o' of https://git-wip-us.apache.org/repos/asf/incubator-usergrid
into two-dot-o
Posted by sn...@apache.org.
Merge branch 'two-dot-o' of https://git-wip-us.apache.org/repos/asf/incubator-usergrid into two-dot-o
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/277eb730
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/277eb730
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/277eb730
Branch: refs/heads/two-dot-o
Commit: 277eb730e114454f063802854ad2392365d996ad
Parents: ce20abe de455c3
Author: Dave Johnson <dm...@apigee.com>
Authored: Thu Nov 27 09:03:54 2014 -0500
Committer: Dave Johnson <dm...@apigee.com>
Committed: Thu Nov 27 09:03:54 2014 -0500
----------------------------------------------------------------------
.../rest/management/users/UsersResource.java | 38 ++++++++++++--------
1 file changed, 24 insertions(+), 14 deletions(-)
----------------------------------------------------------------------
[21/50] [abbrv] incubator-usergrid git commit: Fix bug observed at
test-time, caused by new way of injecting EMF.
Posted by sn...@apache.org.
Fix bug observed at test-time, caused by new way of injecting EMF.
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/5f0dc347
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/5f0dc347
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/5f0dc347
Branch: refs/heads/two-dot-o-events
Commit: 5f0dc347711c0d7921669e20ec03723acfcf0c7c
Parents: c326179
Author: Dave Johnson <dm...@apigee.com>
Authored: Tue Nov 25 10:23:11 2014 -0500
Committer: Dave Johnson <dm...@apigee.com>
Committed: Tue Nov 25 10:23:11 2014 -0500
----------------------------------------------------------------------
.../corepersistence/events/EntityDeletedHandler.java | 4 +---
.../corepersistence/events/EntityVersionCreatedHandler.java | 8 ++++----
.../corepersistence/events/EntityVersionDeletedHandler.java | 5 +----
3 files changed, 6 insertions(+), 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/5f0dc347/stack/core/src/main/java/org/apache/usergrid/corepersistence/events/EntityDeletedHandler.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/events/EntityDeletedHandler.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/events/EntityDeletedHandler.java
index d34b51c..865e284 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/events/EntityDeletedHandler.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/events/EntityDeletedHandler.java
@@ -24,7 +24,6 @@ import org.apache.usergrid.persistence.model.entity.Id;
import java.util.UUID;
import org.apache.usergrid.corepersistence.CpEntityManagerFactory;
-import org.apache.usergrid.corepersistence.HybridEntityManagerFactory;
import org.apache.usergrid.persistence.EntityManagerFactory;
import org.apache.usergrid.persistence.index.EntityIndex;
import org.slf4j.Logger;
@@ -52,8 +51,7 @@ public class EntityDeletedHandler implements EntityDeleted {
new Object[] { entityId.getType(), entityId.getUuid(), version,
scope.getName(), scope.getOwner(), scope.getApplication()});
- HybridEntityManagerFactory hemf = (HybridEntityManagerFactory)emf;
- CpEntityManagerFactory cpemf = (CpEntityManagerFactory)hemf.getImplementation();
+ CpEntityManagerFactory cpemf = (CpEntityManagerFactory)emf;
final EntityIndex ei = cpemf.getManagerCache().getEntityIndex(scope);
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/5f0dc347/stack/core/src/main/java/org/apache/usergrid/corepersistence/events/EntityVersionCreatedHandler.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/events/EntityVersionCreatedHandler.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/events/EntityVersionCreatedHandler.java
index 3462ecb..68c5547 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/events/EntityVersionCreatedHandler.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/events/EntityVersionCreatedHandler.java
@@ -22,7 +22,6 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.usergrid.corepersistence.CpEntityManagerFactory;
-import org.apache.usergrid.corepersistence.HybridEntityManagerFactory;
import org.apache.usergrid.persistence.EntityManagerFactory;
import org.apache.usergrid.persistence.collection.CollectionScope;
import org.apache.usergrid.persistence.collection.event.EntityVersionCreated;
@@ -54,13 +53,14 @@ public class EntityVersionCreatedHandler implements EntityVersionCreated {
new Object[] { entity.getId().getType(), entity.getId().getUuid(), entity.getVersion(),
scope.getName(), scope.getOwner(), scope.getApplication()});
- HybridEntityManagerFactory hemf = (HybridEntityManagerFactory)emf;
- CpEntityManagerFactory cpemf = (CpEntityManagerFactory)hemf.getImplementation();
+ CpEntityManagerFactory cpemf = (CpEntityManagerFactory)emf;
final EntityIndex ei = cpemf.getManagerCache().getEntityIndex(scope);
- //TODO why aren't we using a collection fig here? This seems kludgy
+ // This check is for testing purposes and for a test that to be able to dynamically turn
+ // off and on delete previous versions so that it can test clean-up on read.
if ( System.getProperty( "allow.stale.entities", "false" ).equals( "false" )) {
+
ei.deletePreviousVersions( entity.getId(), entity.getVersion() );
}
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/5f0dc347/stack/core/src/main/java/org/apache/usergrid/corepersistence/events/EntityVersionDeletedHandler.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/events/EntityVersionDeletedHandler.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/events/EntityVersionDeletedHandler.java
index d63edb7..a6e971a 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/events/EntityVersionDeletedHandler.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/events/EntityVersionDeletedHandler.java
@@ -18,7 +18,6 @@
package org.apache.usergrid.corepersistence.events;
import org.apache.usergrid.corepersistence.CpEntityManagerFactory;
-import org.apache.usergrid.corepersistence.CpSetup;
import org.apache.usergrid.persistence.collection.CollectionScope;
import org.apache.usergrid.persistence.collection.MvccEntity;
import org.apache.usergrid.persistence.collection.event.EntityVersionDeleted;
@@ -35,7 +34,6 @@ import rx.schedulers.Schedulers;
import java.util.List;
import com.google.inject.Inject;
-import org.apache.usergrid.corepersistence.HybridEntityManagerFactory;
import org.apache.usergrid.persistence.EntityManagerFactory;
@@ -59,8 +57,7 @@ public class EntityVersionDeletedHandler implements EntityVersionDeleted {
public void versionDeleted(
final CollectionScope scope, final Id entityId, final List<MvccEntity> entityVersions) {
- HybridEntityManagerFactory hemf = (HybridEntityManagerFactory)emf;
- CpEntityManagerFactory cpemf = (CpEntityManagerFactory)hemf.getImplementation();
+ CpEntityManagerFactory cpemf = (CpEntityManagerFactory)emf;
final EntityIndex ei = cpemf.getManagerCache().getEntityIndex(scope);
[23/50] [abbrv] incubator-usergrid git commit: Fix incorrect
formatting.
Posted by sn...@apache.org.
Fix incorrect formatting.
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/ce20abec
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/ce20abec
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/ce20abec
Branch: refs/heads/two-dot-o
Commit: ce20abecdd65ab97c19e2a3c9a8929e3fd9cf1ee
Parents: 39aaca6
Author: Dave Johnson <dm...@apigee.com>
Authored: Tue Nov 25 10:55:56 2014 -0500
Committer: Dave Johnson <dm...@apigee.com>
Committed: Tue Nov 25 10:55:56 2014 -0500
----------------------------------------------------------------------
.../org/apache/usergrid/persistence/GeoIT.java | 579 ++++++++++---------
1 file changed, 305 insertions(+), 274 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/ce20abec/stack/core/src/test/java/org/apache/usergrid/persistence/GeoIT.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/GeoIT.java b/stack/core/src/test/java/org/apache/usergrid/persistence/GeoIT.java
index 9556852..ad30064 100644
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/GeoIT.java
+++ b/stack/core/src/test/java/org/apache/usergrid/persistence/GeoIT.java
@@ -17,8 +17,13 @@
package org.apache.usergrid.persistence;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -44,339 +49,365 @@ public class GeoIT extends AbstractCoreIT {
}
- @Test
- public void testGeo() throws Exception {
- LOG.info( "GeoIT.testGeo" );
+ @Test
+ public void testGeo() throws Exception {
+ LOG.info("GeoIT.testGeo");
+ EntityManager em = app.getEntityManager();
+ assertNotNull(em);
+
+ // create user at a location
+ Map<String, Object> properties = new LinkedHashMap<String, Object>() {{
+ put("username", "edanuff");
+ put("email", "ed@anuff.com");
+ put("location", new LinkedHashMap<String, Object>() {
+ {
+ put("latitude", 37.776753);
+ put("longitude", -122.407846);
+ }
+ });
+ }
+ };
+ Entity user = em.create("user", properties);
+ assertNotNull(user);
+ em.refreshIndex();
- EntityManager em = app.getEntityManager();
- assertNotNull( em );
+ // define center point about 300m from that location
+ Point center = new Point(37.774277, -122.404744);
- // create user at a location
- Map<String, Object> properties = new LinkedHashMap<String, Object>() {{
- put( "username", "edanuff" );
- put( "email", "ed@anuff.com" );
- put( "location", new LinkedHashMap<String, Object>() {{
- put("latitude", 37.776753 );
- put("longitude", -122.407846 );
- }} );
- }};
+ Query query = Query.fromQL("select * where location within 200 of "
+ + center.getLat() + "," + center.getLon());
+ Results listResults = em.searchCollection(em.getApplicationRef(), "users", query);
- Entity user = em.create( "user", properties );
- assertNotNull( user );
+ assertEquals("No results less than 200m away from center", 0, listResults.size());
- em.refreshIndex();
+ query = Query.fromQL("select * where location within 400 of "
+ + center.getLat() + "," + center.getLon());
+ listResults = em.searchCollection(em.getApplicationRef(), "users", query);
- // define center point about 300m from that location
- Point center = new Point( 37.774277, -122.404744 );
+ this.dump(listResults);
- Query query = Query.fromQL( "select * where location within 200 of "
- + center.getLat() + "," + center.getLon());
- Results listResults = em.searchCollection( em.getApplicationRef(), "users", query );
+ assertEquals("1 result less than 400m away from center", 1, listResults.size());
- assertEquals("No results less than 200m away from center", 0, listResults.size() );
+ // remove location from user
+ properties.remove("location");
+ em.updateProperties(user, properties);
+ em.refreshIndex();
- query = Query.fromQL( "select * where location within 400 of "
- + center.getLat() + "," + center.getLon());
- listResults = em.searchCollection( em.getApplicationRef(), "users", query );
+ query = Query.fromQL("select * where location within 400 of "
+ + center.getLat() + "," + center.getLon());
+ listResults = em.searchCollection(em.getApplicationRef(), "users", query);
- this.dump( listResults );
+ this.dump(listResults);
- assertEquals("1 result less than 400m away from center", 1, listResults.size() );
+ // user no longer found with 400m search
+ assertEquals(0, listResults.size());
- // remove location from user
- properties.remove("location");
- em.updateProperties(user, properties);
- em.refreshIndex();
+ // move user and center to new locations
+ updatePos(em, user, 37.426373, -122.14108);
- query = Query.fromQL( "select * where location within 400 of "
- + center.getLat() + "," + center.getLon());
- listResults = em.searchCollection( em.getApplicationRef(), "users", query );
+ center = new Point(37.774277, -122.404744);
- this.dump( listResults );
+ query = Query.fromQL("select * where location within 200 of "
+ + center.getLat() + "," + center.getLon());
+ listResults = em.searchCollection(em.getApplicationRef(), "users", query);
- // user no longer found with 400m search
- assertEquals( 0, listResults.size() );
+ assertEquals(0, listResults.size());
- // move user and center to new locations
- updatePos( em, user, 37.426373, -122.14108 );
+ updatePos(em, user, 37.774277, -122.404744);
- center = new Point( 37.774277, -122.404744 );
+ center = new Point(37.776753, -122.407846);
- query = Query.fromQL( "select * where location within 200 of "
- + center.getLat() + "," + center.getLon());
- listResults = em.searchCollection( em.getApplicationRef(), "users", query );
+ query = Query.fromQL("select * where location within 1000 of "
+ + center.getLat() + "," + center.getLon());
+ listResults = em.searchCollection(em.getApplicationRef(), "users", query);
- assertEquals( 0, listResults.size() );
+ assertEquals(1, listResults.size());
- updatePos( em, user, 37.774277, -122.404744 );
+ // check at globally large distance
+ query = Query.fromQL("select * where location within " + Integer.MAX_VALUE + " of "
+ + center.getLat() + "," + center.getLon());
+ listResults = em.searchCollection(em.getApplicationRef(), "users", query);
+
+ assertEquals(1, listResults.size());
+
+ // create a new entity so we have 2
+ LinkedHashMap<String, Object> properties2 = new LinkedHashMap<String, Object>() {{
+ put("username", "sganyo");
+ put("email", "sganyo@anuff.com");
+ put("location", new LinkedHashMap<String, Object>() {
+ {
+ put("latitude", 31.1);
+ put("longitude", 121.2);
+ }
+ });
+ }
+ };
+ Entity user2 = em.create("user", properties2);
+ em.refreshIndex();
+ assertNotNull(user2);
- center = new Point( 37.776753, -122.407846 );
+ query = Query.fromQL("select * where location within 10000 of "
+ + center.getLat() + "," + center.getLon());
+ listResults = em.searchCollection(em.getApplicationRef(), "users", query);
- query = Query.fromQL( "select * where location within 1000 of "
- + center.getLat() + "," + center.getLon());
- listResults = em.searchCollection( em.getApplicationRef(), "users", query );
+ assertEquals(1, listResults.size());
- assertEquals( 1, listResults.size() );
+ // check at globally large distance
+ query = Query.fromQL("select * where location within " + Integer.MAX_VALUE + " of "
+ + center.getLat() + "," + center.getLon());
+ listResults = em.searchCollection(em.getApplicationRef(), "users", query);
- // check at globally large distance
+ assertEquals(2, listResults.size());
- query = Query.fromQL( "select * where location within " + Integer.MAX_VALUE + " of "
- + center.getLat() + "," + center.getLon());
- listResults = em.searchCollection( em.getApplicationRef(), "users", query );
+ // check at globally large distance (center point close to other entity)
+ center = new Point(31.14, 121.27);
- assertEquals( 1, listResults.size() );
+ query = Query.fromQL("select * where location within " + Integer.MAX_VALUE + " of "
+ + center.getLat() + "," + center.getLon());
+ listResults = em.searchCollection(em.getApplicationRef(), "users", query);
- // create a new entity so we have 2
- LinkedHashMap<String, Object> properties2 = new LinkedHashMap<String, Object>() {{
- put( "username", "sganyo" );
- put( "email", "sganyo@anuff.com" );
- put( "location", new LinkedHashMap<String, Object>() {{
- put("latitude", 31.1 );
- put("longitude", 121.2 );
- }} );
- }};
- Entity user2 = em.create( "user", properties2 );
- em.refreshIndex();
- assertNotNull( user2 );
+ assertEquals(2, listResults.size());
- query = Query.fromQL( "select * where location within 10000 of "
- + center.getLat() + "," + center.getLon());
- listResults = em.searchCollection( em.getApplicationRef(), "users", query );
+ Results emSearchResults = em.searchCollection(em.getApplicationRef(), "users",
+ Query.fromQL("location within 1000 of 37.776753, -122.407846"));
+ assertEquals(1, emSearchResults.size());
- assertEquals( 1, listResults.size() );
+ updatePos(em, user, 37.776753, -122.407846);
- // check at globally large distance
- query = Query.fromQL( "select * where location within " + Integer.MAX_VALUE + " of "
- + center.getLat() + "," + center.getLon());
- listResults = em.searchCollection( em.getApplicationRef(), "users", query );
+ center = new Point(37.428526, -122.140916);
- assertEquals( 2, listResults.size() );
+ query = Query.fromQL("select * where location within 1000 of "
+ + center.getLat() + "," + center.getLon());
+ listResults = em.searchCollection(em.getApplicationRef(), "users", query);
- // check at globally large distance (center point close to other entity)
- center = new Point( 31.14, 121.27 );
+ assertEquals(0, listResults.size());
- query = Query.fromQL( "select * where location within " + Integer.MAX_VALUE + " of "
- + center.getLat() + "," + center.getLon());
- listResults = em.searchCollection( em.getApplicationRef(), "users", query );
+ emSearchResults = em.searchCollection(em.getApplicationRef(), "users",
+ Query.fromQL("location within 1000 of 37.428526, -122.140916"));
+ assertEquals(0, emSearchResults.size());
- assertEquals( 2, listResults.size() );
+ properties = new LinkedHashMap<String, Object>();
+ properties.put("name", "Brickhouse");
+ properties.put("address", "426 Brannan Street");
+ properties.put("location", getLocation(37.779632, -122.395131));
- Results emSearchResults = em.searchCollection( em.getApplicationRef(), "users",
- Query.fromQL( "location within 1000 of 37.776753, -122.407846" ) );
- assertEquals( 1, emSearchResults.size() );
+ Entity restaurant = em.create("restaurant", properties);
+ assertNotNull(restaurant);
- updatePos( em, user, 37.776753, -122.407846 );
+ em.createConnection(user, "likes", restaurant);
- center = new Point( 37.428526, -122.140916 );
+ em.refreshIndex();
- query = Query.fromQL( "select * where location within 1000 of "
- + center.getLat() + "," + center.getLon());
- listResults = em.searchCollection( em.getApplicationRef(), "users", query );
+ emSearchResults = em.searchConnectedEntities(user,
+ Query.fromQL("location within 2000 of 37.776753, -122.407846").setConnectionType("likes"));
+ assertEquals(1, emSearchResults.size());
+ emSearchResults = em.searchConnectedEntities(user,
+ Query.fromQL("location within 1000 of 37.776753, -122.407846").setConnectionType("likes"));
+ assertEquals(0, emSearchResults.size());
+ }
- assertEquals( 0, listResults.size() );
- emSearchResults = em.searchCollection( em.getApplicationRef(), "users",
- Query.fromQL( "location within 1000 of 37.428526, -122.140916" ) );
- assertEquals( 0, emSearchResults.size() );
+ @Test
+ public void testGeo2() throws Exception {
+ LOG.info("GeoIT.testGeo2");
+ EntityManager em = app.getEntityManager();
+ assertNotNull(em);
+
+ // create user at a location
+ Map<String, Object> properties = new LinkedHashMap<String, Object>() {{
+ put("type", "store");
+ put("name", "norwest");
+ put("location", new LinkedHashMap<String, Object>() {
+ {
+ put("latitude", -33.746369);
+ put("longitude", 150.952183);
+ }
+ });
+ }
+ };
+ Entity entity = em.create("store", properties);
+ assertNotNull(entity);
+ properties = new LinkedHashMap<String, Object>() {{
+ put("type", "store");
+ put("name", "ashfield");
+ put("location", new LinkedHashMap<String, Object>() {
+ {
+ put("latitude", -33.889058);
+ put("longitude", 151.124024);
+ }
+ });
+ }
+ };
+ entity = em.create("store", properties);
+ assertNotNull(entity);
- properties = new LinkedHashMap<String, Object>();
- properties.put( "name", "Brickhouse" );
- properties.put( "address", "426 Brannan Street" );
- properties.put( "location", getLocation( 37.779632, -122.395131 ) );
+ em.refreshIndex();
- Entity restaurant = em.create( "restaurant", properties );
- assertNotNull( restaurant );
+ Point center = new Point(37.776753, -122.407846);
- em.createConnection( user, "likes", restaurant );
+ Query query = Query.fromQL("select * where location within 10000 of "
+ + center.getLat() + "," + center.getLon());
+ Results listResults = em.searchCollection(em.getApplicationRef(), "stores", query);
- em.refreshIndex();
+ this.dump(listResults);
- emSearchResults = em.searchConnectedEntities( user,
- Query.fromQL( "location within 2000 of 37.776753, -122.407846" ).setConnectionType( "likes" ) );
- assertEquals( 1, emSearchResults.size() );
+ assertEquals("Results less than 10000m away from center", 0, listResults.size());
+
+ Query query2 = Query.fromQL("select * where location within 40000000 of "
+ + center.getLat() + "," + center.getLon());
+ listResults = em.searchCollection(em.getApplicationRef(), "stores", query2);
+
+ assertEquals("Results from center point to ridiculously far", 2, listResults.size());
- emSearchResults = em.searchConnectedEntities( user,
- Query.fromQL( "location within 1000 of 37.776753, -122.407846" ).setConnectionType( "likes" ) );
- assertEquals( 0, emSearchResults.size() );
- }
- @Test
- public void testGeo2() throws Exception {
- LOG.info( "GeoIT.testGeo2" );
- EntityManager em = app.getEntityManager();
- assertNotNull( em );
-
- // create user at a location
- Map<String, Object> properties = new LinkedHashMap<String, Object>() {{
- put( "type", "store" );
- put( "name", "norwest" );
- put( "location", new LinkedHashMap<String, Object>() {{
- put("latitude", -33.746369 );
- put("longitude", 150.952183 );
- }} );
- }};
- Entity entity = em.create( "store", properties );
- assertNotNull( entity );
- properties = new LinkedHashMap<String, Object>() {{
- put( "type", "store" );
- put( "name", "ashfield" );
- put( "location", new LinkedHashMap<String, Object>() {{
- put("latitude", -33.889058 );
- put("longitude", 151.124024 );
- }} );
- }};
- entity = em.create( "store", properties );
- assertNotNull( entity );
-
- em.refreshIndex();
-
- Point center = new Point( 37.776753, -122.407846 );
-
- Query query = Query.fromQL( "select * where location within 10000 of "
- + center.getLat() + "," + center.getLon());
- Results listResults = em.searchCollection( em.getApplicationRef(), "stores", query );
-
- this.dump( listResults );
-
- assertEquals("Results less than 10000m away from center", 0, listResults.size() );
-
- Query query2 = Query.fromQL( "select * where location within 40000000 of "
- + center.getLat() + "," + center.getLon());
- listResults = em.searchCollection( em.getApplicationRef(), "stores", query2 );
-
- assertEquals("Results from center point to ridiculously far", 2, listResults.size() );
-
- }
- @Test
- public void testGeo3() throws Exception {
- LOG.info( "GeoIT.testGeo3" );
- EntityManager em = app.getEntityManager();
- assertNotNull( em );
-
- // create user at a location
- Map<String, Object> properties = new LinkedHashMap<String, Object>() {{
- put( "name", "norwest" );
- put( "location", new LinkedHashMap<String, Object>() {{
- put("latitude", -33.746369 );
- put("longitude", 150.952183 );
- }} );
- }};
- Entity entity = em.create( "store", properties );
- assertNotNull( entity );
- properties = new LinkedHashMap<String, Object>() {{
- put( "name", "ashfield" );
- put( "location", new LinkedHashMap<String, Object>() {{
- put("latitude", -33.889058 );
- put("longitude", 151.124024 );
- }} );
- }};
- entity = em.create( "store", properties );
- assertNotNull( entity );
-
- em.refreshIndex();
-
- Point center = new Point( -33.746369, 150.952183 );
-
- Query query = Query.fromQL( "select * where location within 10000 of "
- + center.getLat() + "," + center.getLon());
- Results listResults = em.searchCollection( em.getApplicationRef(), "stores", query );
-
- this.dump( listResults );
-
- assertEquals("Results less than 10000m away from center", 1, listResults.size() );
-
- Query query2 = Query.fromQL( "select * where location within 40000000 of "
- + center.getLat() + "," + center.getLon());
- listResults = em.searchCollection( em.getApplicationRef(), "stores", query2 );
-
- assertEquals("Results from center point to ridiculously far", 2, listResults.size() );
-
- }
- @Test
- public void testGeo4() throws Exception {
- LOG.info( "GeoIT.testGeo4" );
- EntityManager em = app.getEntityManager();
- assertNotNull( em );
-
- // create user at a location
- Map<String, Object> properties = new LinkedHashMap<String, Object>() {{
- put( "name", "norwest" );
- put( "location", new LinkedHashMap<String, Object>() {{
- put("latitude", -33.746369 );
- put("longitude", 150.952183 );
- }} );
- }};
- Entity entity = em.create( "store", properties );
- assertNotNull( entity );
- properties = new LinkedHashMap<String, Object>() {{
- put( "name", "ashfield" );
- put( "location", new LinkedHashMap<String, Object>() {{
- put("latitude", -33.889058 );
- put("longitude", 151.124024 );
- }} );
- }};
- entity = em.create( "store", properties );
- assertNotNull( entity );
-
- em.refreshIndex();
-
- List<Point> points = new ArrayList<Point>();
- points.add(new Point( 33.746369,-89 ));//Woodland, MS
- points.add(new Point( 33.746369,-91 ));//Beulah, MS
- points.add(new Point( -1.000000, 102.000000 ));//Somewhere in Indonesia
- points.add(new Point( -90.000000, 90.000000 ));//Antarctica
- points.add(new Point( 90, 90 ));//Santa's house
- //and the cartesian product...
- for(int i= -90;i<=90;i++){
- for(int j= -180;j<=180;j++){
- points.add(new Point( i, j ));
- }
}
- Iterator<Point> pointIterator = points.iterator();
- for(Point p=pointIterator.next();pointIterator.hasNext();p=pointIterator.next()){
- Query query = Query.fromQL( "select * where location within 10000 of "
- + p.getLat() + "," + p.getLon());
- Results listResults = em.searchCollection( em.getApplicationRef(), "stores", query );
- this.dump( listResults );
- assertEquals("Results less than 10000m away from center", 0, listResults.size() );
- query = Query.fromQL( "select * where location within 40000000 of "
- + p.getLat() + "," + p.getLon());
- listResults = em.searchCollection( em.getApplicationRef(), "stores", query );
+ @Test
+ public void testGeo3() throws Exception {
+ LOG.info("GeoIT.testGeo3");
+ EntityManager em = app.getEntityManager();
+ assertNotNull(em);
+
+ // create user at a location
+ Map<String, Object> properties = new LinkedHashMap<String, Object>() {
+ {
+ put("name", "norwest");
+ put("location", new LinkedHashMap<String, Object>() {
+ {
+ put("latitude", -33.746369);
+ put("longitude", 150.952183);
+ }
+ });
+ }
+ };
+ Entity entity = em.create("store", properties);
+ assertNotNull(entity);
+ properties = new LinkedHashMap<String, Object>() {
+ {
+ put("name", "ashfield");
+ put("location", new LinkedHashMap<String, Object>() {
+ {
+ put("latitude", -33.889058);
+ put("longitude", 151.124024);
+ }
+ });
+ }
+ };
+ entity = em.create("store", properties);
+ assertNotNull(entity);
+
+ em.refreshIndex();
+
+ Point center = new Point(-33.746369, 150.952183);
- assertEquals("Results from center point to ridiculously far", 2, listResults.size() );
+ Query query = Query.fromQL("select * where location within 10000 of "
+ + center.getLat() + "," + center.getLon());
+ Results listResults = em.searchCollection(em.getApplicationRef(), "stores", query);
- }
+ this.dump(listResults);
+ assertEquals("Results less than 10000m away from center", 1, listResults.size());
- }
- @Test
- public void testGeoBadPoints() throws Exception {
- LOG.info( "GeoIT.testGeoBadPoints" );
- double[][] vertices= {
- {-91.000000, 90.000000},
- {91.000000, 90.000000},
- {90.000000, 400},
- {90.000000, -270.000000},
- {-91.000000, -91.000000}
- };
- for (int i=0;i<vertices.length;i++){
- //bad coordinate. bad! you're supposed to have lat between -90 and 90
- try {
- Point p = new Point(vertices[i][0], vertices[i][1]);
- assertTrue("Bad points should throw an exception ["+vertices[i][0]+","+vertices[i][1]+"]", false);
- }catch(java.lang.IllegalArgumentException e){
- assertTrue("Bad points should throw an exception ["+vertices[i][0]+","+vertices[i][1]+"]" , true);
- }
+ Query query2 = Query.fromQL("select * where location within 40000000 of "
+ + center.getLat() + "," + center.getLon());
+ listResults = em.searchCollection(em.getApplicationRef(), "stores", query2);
+
+ assertEquals("Results from center point to ridiculously far", 2, listResults.size());
}
+ @Test
+ public void testGeo4() throws Exception {
+ LOG.info("GeoIT.testGeo4");
+ EntityManager em = app.getEntityManager();
+ assertNotNull(em);
+
+ // create user at a location
+ Map<String, Object> properties = new LinkedHashMap<String, Object>() {{
+ put("name", "norwest");
+ put("location", new LinkedHashMap<String, Object>() {
+ {
+ put("latitude", -33.746369);
+ put("longitude", 150.952183);
+ }
+ });
+ }
+ };
+ Entity entity = em.create("store", properties);
+ assertNotNull(entity);
+ properties = new LinkedHashMap<String, Object>() {{
+ put("name", "ashfield");
+ put("location", new LinkedHashMap<String, Object>() {
+ {
+ put("latitude", -33.889058);
+ put("longitude", 151.124024);
+ }
+ });
+ }
+ };
+ entity = em.create("store", properties);
+ assertNotNull(entity);
+
+ em.refreshIndex();
- }
+ List<Point> points = new ArrayList<Point>();
+ points.add(new Point(33.746369, -89));//Woodland, MS
+ points.add(new Point(33.746369, -91));//Beulah, MS
+ points.add(new Point(-1.000000, 102.000000));//Somewhere in Indonesia
+ points.add(new Point(-90.000000, 90.000000));//Antarctica
+ points.add(new Point(90, 90));//Santa's house
+ //and the cartesian product...
+ for (int i = -90; i <= 90; i++) {
+ for (int j = -180; j <= 180; j++) {
+ points.add(new Point(i, j));
+ }
+ }
+ Iterator<Point> pointIterator = points.iterator();
+ for (Point p = pointIterator.next(); pointIterator.hasNext(); p = pointIterator.next()) {
+ Query query = Query.fromQL("select * where location within 10000 of "
+ + p.getLat() + "," + p.getLon());
+ Results listResults = em.searchCollection(em.getApplicationRef(), "stores", query);
+
+ this.dump(listResults);
+ assertEquals("Results less than 10000m away from center", 0, listResults.size());
+
+ query = Query.fromQL("select * where location within 40000000 of "
+ + p.getLat() + "," + p.getLon());
+ listResults = em.searchCollection(em.getApplicationRef(), "stores", query);
+
+ assertEquals("Results from center point to ridiculously far", 2, listResults.size());
+
+ }
+
+ }
+
+
+ @Test
+ public void testGeoBadPoints() throws Exception {
+ LOG.info("GeoIT.testGeoBadPoints");
+ double[][] vertices = {
+ {-91.000000, 90.000000},
+ {91.000000, 90.000000},
+ {90.000000, 400},
+ {90.000000, -270.000000},
+ {-91.000000, -91.000000}
+ };
+ for (int i = 0; i < vertices.length; i++) {
+ //bad coordinate. bad! you're supposed to have lat between -90 and 90
+ try {
+ Point p = new Point(vertices[i][0], vertices[i][1]);
+ assertTrue("Bad points should throw an exception ["
+ + vertices[i][0] + "," + vertices[i][1] + "]", false);
+ } catch (java.lang.IllegalArgumentException e) {
+ assertTrue("Bad points should throw an exception ["
+ + vertices[i][0] + "," + vertices[i][1] + "]", true);
+ }
+ }
+ }
@Test
[09/50] [abbrv] incubator-usergrid git commit: Fixes tests by
invalidating version cache after hard resetting
Posted by sn...@apache.org.
Fixes tests by invalidating version cache after hard resetting
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/3e210116
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/3e210116
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/3e210116
Branch: refs/heads/two-dot-o-events
Commit: 3e2101165a81084abcb925910a52662cbc5c0d05
Parents: 0a92bee
Author: Todd Nine <tn...@apigee.com>
Authored: Fri Nov 21 14:37:14 2014 -0700
Committer: Todd Nine <tn...@apigee.com>
Committed: Fri Nov 21 14:37:14 2014 -0700
----------------------------------------------------------------------
.../usergrid/corepersistence/migration/EntityDataMigrationIT.java | 1 +
.../corepersistence/migration/GraphShardVersionMigrationIT.java | 2 ++
2 files changed, 3 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/3e210116/stack/core/src/test/java/org/apache/usergrid/corepersistence/migration/EntityDataMigrationIT.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/corepersistence/migration/EntityDataMigrationIT.java b/stack/core/src/test/java/org/apache/usergrid/corepersistence/migration/EntityDataMigrationIT.java
index 5c9e14c..b8c0093 100644
--- a/stack/core/src/test/java/org/apache/usergrid/corepersistence/migration/EntityDataMigrationIT.java
+++ b/stack/core/src/test/java/org/apache/usergrid/corepersistence/migration/EntityDataMigrationIT.java
@@ -96,6 +96,7 @@ public class EntityDataMigrationIT extends AbstractCoreIT {
* Reset to our version -1 and start the migration
*/
dataMigrationManager.resetToVersion( entityDataMigration.getVersion() - 1 );
+ dataMigrationManager.invalidate();
final EntityManager newAppEm = app.getEntityManager();
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/3e210116/stack/core/src/test/java/org/apache/usergrid/corepersistence/migration/GraphShardVersionMigrationIT.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/corepersistence/migration/GraphShardVersionMigrationIT.java b/stack/core/src/test/java/org/apache/usergrid/corepersistence/migration/GraphShardVersionMigrationIT.java
index 51ea052..e119788 100644
--- a/stack/core/src/test/java/org/apache/usergrid/corepersistence/migration/GraphShardVersionMigrationIT.java
+++ b/stack/core/src/test/java/org/apache/usergrid/corepersistence/migration/GraphShardVersionMigrationIT.java
@@ -78,6 +78,8 @@ public class GraphShardVersionMigrationIT extends AbstractCoreIT {
* Reset to our version -1 and start the migration
*/
dataMigrationManager.resetToVersion( graphShardVersionMigration.getVersion() - 1 );
+ dataMigrationManager.invalidate();
+
final EntityManager newAppEm = app.getEntityManager();
[03/50] [abbrv] incubator-usergrid git commit: Finished migration
testing. All core tests pass.
Posted by sn...@apache.org.
Finished migration testing. All core tests pass.
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/e32d5212
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/e32d5212
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/e32d5212
Branch: refs/heads/two-dot-o-events
Commit: e32d5212af3c53cc84c9a505cb9bb6824e6a16f2
Parents: 364a6ea
Author: Todd Nine <tn...@apigee.com>
Authored: Thu Nov 20 15:48:19 2014 -0700
Committer: Todd Nine <tn...@apigee.com>
Committed: Thu Nov 20 15:48:19 2014 -0700
----------------------------------------------------------------------
.../migration/EntityDataMigration.java | 90 ++++---
.../rx/ApplicationObservable.java | 65 +++--
.../migration/EntityDataMigrationIT.java | 251 +++++++++++++++++++
.../migration/GraphShardVersionMigrationIT.java | 131 +++++-----
4 files changed, 394 insertions(+), 143 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e32d5212/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/EntityDataMigration.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/EntityDataMigration.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/EntityDataMigration.java
index 79d31a8..767574d 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/EntityDataMigration.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/EntityDataMigration.java
@@ -22,9 +22,7 @@ package org.apache.usergrid.corepersistence.migration;
import java.util.Iterator;
import java.util.UUID;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import java.util.concurrent.atomic.AtomicLong;
import org.apache.usergrid.corepersistence.ManagerCache;
import org.apache.usergrid.corepersistence.rx.AllEntitiesInSystemObservable;
@@ -53,9 +51,6 @@ import rx.functions.Action1;
public class EntityDataMigration implements DataMigration {
- private static final Logger logger = LoggerFactory.getLogger( EntityDataMigration.class );
-
-
private final MvccEntitySerializationStrategy v1Serialization;
private final MvccEntitySerializationStrategy v2Serialization;
@@ -77,58 +72,71 @@ public class EntityDataMigration implements DataMigration {
@Override
public void migrate( final ProgressObserver observer ) throws Throwable {
+ final AtomicLong atomicLong = new AtomicLong();
+
+ AllEntitiesInSystemObservable.getAllEntitiesInSystem( managerCache, 1000 )
+ .doOnNext( new Action1<AllEntitiesInSystemObservable.ApplicationEntityGroup>() {
- AllEntitiesInSystemObservable.getAllEntitiesInSystem( managerCache, 1000 ).doOnNext(
- new Action1<AllEntitiesInSystemObservable.ApplicationEntityGroup>() {
+ @Override
+ public void call(
+ final AllEntitiesInSystemObservable.ApplicationEntityGroup
+ applicationEntityGroup ) {
- @Override
- public void call(
- final AllEntitiesInSystemObservable.ApplicationEntityGroup applicationEntityGroup ) {
+ final UUID now = UUIDGenerator.newTimeUUID();
- final UUID now = UUIDGenerator.newTimeUUID();
+ final Id appScopeId =
+ applicationEntityGroup.applicationScope.getApplication();
- final Id appScopeId = applicationEntityGroup.applicationScope.getApplication();
+ final MutationBatch totalBatch = keyspace.prepareMutationBatch();
- final MutationBatch totalBatch = keyspace.prepareMutationBatch();
+ //go through each entity in the system, and load it's entire
+ // history
+ for ( Id entityId : applicationEntityGroup.entityIds ) {
- for ( Id entityId : applicationEntityGroup.entityIds ) {
+ CollectionScope currentScope = CpNamingUtils
+ .getCollectionScopeNameFromEntityType( appScopeId,
+ entityId.getType() );
- CollectionScope currentScope = CpNamingUtils.getCollectionScopeNameFromEntityType(
- appScopeId, entityId.getType() );
+ //for each element in the history in the previous version,
+ // copy it to the CF in v2
+ Iterator<MvccEntity> allVersions = v1Serialization
+ .loadDescendingHistory( currentScope, entityId, now,
+ 1000 );
- Iterator<MvccEntity> allVersions =
- v1Serialization.loadDescendingHistory( currentScope, entityId, now, 1000 );
+ while ( allVersions.hasNext() ) {
+ final MvccEntity version = allVersions.next();
- while ( allVersions.hasNext() ) {
- final MvccEntity version = allVersions.next();
+ final MutationBatch versionBatch =
+ v2Serialization.write( currentScope, version );
- final MutationBatch versionBatch = v2Serialization.write( currentScope, version );
+ totalBatch.mergeShallow( versionBatch );
+
+ if ( atomicLong.incrementAndGet() % 50 == 0 ) {
+ executeBatch( totalBatch, observer, atomicLong );
+ }
+ }
+ }
+
+ executeBatch( totalBatch, observer, atomicLong );
+ }
+ } ).toBlocking().last();
+ }
- totalBatch.mergeShallow( versionBatch );
- if ( totalBatch.getRowCount() >= 50 ) {
- try {
- totalBatch.execute();
- }
- catch ( ConnectionException e ) {
- throw new DataMigrationException( "Unable to migrate batches ", e );
- }
- }
- }
- }
+ private void executeBatch( final MutationBatch batch, final ProgressObserver po, final AtomicLong count ) {
+ try {
+ batch.execute();
- try {
- totalBatch.execute();
- }
- catch ( ConnectionException e ) {
- throw new DataMigrationException( "Unable to migrate batches ", e );
- }
- }
- } ).toBlocking().last();
+ po.update( getVersion(), "Finished copying " + count + " entities to the new format" );
+ }
+ catch ( ConnectionException e ) {
+ po.failed( getVersion(), "Failed to execute mutation in cassandra" );
+ throw new DataMigrationException( "Unable to migrate batches ", e );
+ }
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e32d5212/stack/core/src/main/java/org/apache/usergrid/corepersistence/rx/ApplicationObservable.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/rx/ApplicationObservable.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/rx/ApplicationObservable.java
index 898812b..6019bca 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/rx/ApplicationObservable.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/rx/ApplicationObservable.java
@@ -23,18 +23,20 @@ package org.apache.usergrid.corepersistence.rx;
import java.util.Arrays;
import java.util.UUID;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
import org.apache.usergrid.corepersistence.ManagerCache;
import org.apache.usergrid.corepersistence.util.CpNamingUtils;
import org.apache.usergrid.persistence.collection.CollectionScope;
import org.apache.usergrid.persistence.collection.EntityCollectionManager;
-import org.apache.usergrid.persistence.collection.EntityCollectionManagerFactory;
import org.apache.usergrid.persistence.collection.impl.CollectionScopeImpl;
import org.apache.usergrid.persistence.core.scope.ApplicationScope;
import org.apache.usergrid.persistence.graph.Edge;
import org.apache.usergrid.persistence.graph.GraphManager;
-import org.apache.usergrid.persistence.graph.GraphManagerFactory;
import org.apache.usergrid.persistence.graph.SearchByEdgeType;
import org.apache.usergrid.persistence.graph.impl.SimpleSearchByEdgeType;
+import org.apache.usergrid.persistence.model.entity.Entity;
import org.apache.usergrid.persistence.model.entity.Id;
import rx.Observable;
@@ -47,14 +49,12 @@ import static org.apache.usergrid.corepersistence.util.CpNamingUtils.getApplicat
/**
* An observable that will emit all application stored in the system.
*/
-public class ApplicationObservable {
-
+public class ApplicationObservable {
+ private static final Logger logger = LoggerFactory.getLogger( ApplicationObservable.class );
/**
* Get all applicationIds as an observable
- * @param managerCache
- * @return
*/
public static Observable<Id> getAllApplicationIds( final ManagerCache managerCache ) {
@@ -62,22 +62,20 @@ public class ApplicationObservable {
//this way consumers can perform whatever work they need to on the root system first
- final Observable<Id> systemIds = Observable.from( Arrays.asList( generateApplicationId( CpNamingUtils.DEFAULT_APPLICATION_ID ),
- generateApplicationId( CpNamingUtils.MANAGEMENT_APPLICATION_ID ),
- generateApplicationId( CpNamingUtils.SYSTEM_APP_ID ) ) );
-
-
+ final Observable<Id> systemIds = Observable.from( Arrays
+ .asList( generateApplicationId( CpNamingUtils.DEFAULT_APPLICATION_ID ),
+ generateApplicationId( CpNamingUtils.MANAGEMENT_APPLICATION_ID ),
+ generateApplicationId( CpNamingUtils.SYSTEM_APP_ID ) ) );
final ApplicationScope appScope = getApplicationScope( CpNamingUtils.SYSTEM_APP_ID );
- final CollectionScope appInfoCollectionScope = new CollectionScopeImpl(
- appScope.getApplication(),
- appScope.getApplication(),
- CpNamingUtils.getCollectionScopeNameFromCollectionName( CpNamingUtils.APPINFOS ));
+ final CollectionScope appInfoCollectionScope =
+ new CollectionScopeImpl( appScope.getApplication(), appScope.getApplication(),
+ CpNamingUtils.getCollectionScopeNameFromCollectionName( CpNamingUtils.APPINFOS ) );
- final EntityCollectionManager
- collectionManager = managerCache.getEntityCollectionManager( appInfoCollectionScope );
+ final EntityCollectionManager collectionManager =
+ managerCache.getEntityCollectionManager( appInfoCollectionScope );
final GraphManager gm = managerCache.getGraphManager( appScope );
@@ -97,21 +95,34 @@ public class ApplicationObservable {
//get the app info and load it
final Id appInfo = edge.getTargetNode();
- return collectionManager.load( appInfo ).map( new Func1<org.apache.usergrid.persistence.model.entity.Entity, Id>() {
+ return collectionManager.load( appInfo )
+ //filter out null entities
+ .filter( new Func1<Entity, Boolean>() {
+ @Override
+ public Boolean call( final Entity entity ) {
+ if ( entity == null ) {
+ logger.warn( "Encountered a null application info for id {}", appInfo );
+ return false;
+ }
+ return true;
+ }
+ } )
+ //get the id from the entity
+ .map( new Func1<org.apache.usergrid.persistence.model.entity.Entity, Id>() {
- @Override
- public Id call( final org.apache.usergrid.persistence.model.entity.Entity entity ) {
- final UUID uuid = (UUID )entity.getField( "applicationUuid" ).getValue();
- return CpNamingUtils.generateApplicationId(uuid);
- }
- } );
+ @Override
+ public Id call( final org.apache.usergrid.persistence.model.entity.Entity entity ) {
+
+ final UUID uuid = ( UUID ) entity.getField( "applicationUuid" ).getValue();
+
+ return CpNamingUtils.generateApplicationId( uuid );
+ }
+ } );
}
} );
- return Observable.merge( systemIds, appIds);
+ return Observable.merge( systemIds, appIds );
}
-
-
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e32d5212/stack/core/src/test/java/org/apache/usergrid/corepersistence/migration/EntityDataMigrationIT.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/corepersistence/migration/EntityDataMigrationIT.java b/stack/core/src/test/java/org/apache/usergrid/corepersistence/migration/EntityDataMigrationIT.java
new file mode 100644
index 0000000..5c9e14c
--- /dev/null
+++ b/stack/core/src/test/java/org/apache/usergrid/corepersistence/migration/EntityDataMigrationIT.java
@@ -0,0 +1,251 @@
+/*
+ * 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.corepersistence.migration;
+
+
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import org.apache.usergrid.AbstractCoreIT;
+import org.apache.usergrid.corepersistence.CpSetup;
+import org.apache.usergrid.corepersistence.EntityWriteHelper;
+import org.apache.usergrid.corepersistence.ManagerCache;
+import org.apache.usergrid.corepersistence.rx.AllEntitiesInSystemObservable;
+import org.apache.usergrid.corepersistence.util.CpNamingUtils;
+import org.apache.usergrid.persistence.Entity;
+import org.apache.usergrid.persistence.EntityManager;
+import org.apache.usergrid.persistence.EntityManagerFactory;
+import org.apache.usergrid.persistence.SimpleEntityRef;
+import org.apache.usergrid.persistence.collection.CollectionScope;
+import org.apache.usergrid.persistence.collection.MvccEntity;
+import org.apache.usergrid.persistence.collection.mvcc.MvccEntitySerializationStrategy;
+import org.apache.usergrid.persistence.core.guice.CurrentImpl;
+import org.apache.usergrid.persistence.core.guice.PreviousImpl;
+import org.apache.usergrid.persistence.core.migration.data.DataMigrationManager;
+import org.apache.usergrid.persistence.core.migration.data.DataMigrationManagerImpl;
+import org.apache.usergrid.persistence.core.migration.data.MigrationInfoSerialization;
+import org.apache.usergrid.persistence.model.entity.Id;
+import org.apache.usergrid.persistence.model.util.UUIDGenerator;
+
+import com.google.inject.Injector;
+import com.google.inject.Key;
+
+import rx.functions.Action1;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+
+public class EntityDataMigrationIT extends AbstractCoreIT {
+
+
+ private Injector injector;
+
+
+ private EntityDataMigration entityDataMigration;
+ private ManagerCache managerCache;
+ private DataMigrationManager dataMigrationManager;
+ private MigrationInfoSerialization migrationInfoSerialization;
+ private MvccEntitySerializationStrategy v1Strategy;
+ private MvccEntitySerializationStrategy v2Strategy;
+ private EntityManagerFactory emf;
+
+
+ @Before
+ public void setup() {
+ emf = setup.getEmf();
+ injector = CpSetup.getInjector();
+ entityDataMigration = injector.getInstance( EntityDataMigration.class );
+ managerCache = injector.getInstance( ManagerCache.class );
+ dataMigrationManager = injector.getInstance( DataMigrationManager.class );
+ migrationInfoSerialization = injector.getInstance( MigrationInfoSerialization.class );
+ v1Strategy = injector.getInstance( Key.get(MvccEntitySerializationStrategy.class, PreviousImpl.class) );
+ v2Strategy = injector.getInstance( Key.get(MvccEntitySerializationStrategy.class, CurrentImpl.class) );
+ }
+
+
+ @Test
+ public void testDataMigration() throws Throwable {
+
+ assertEquals( "version 3 expected", 3, entityDataMigration.getVersion() );
+
+
+ /**
+ * Reset to our version -1 and start the migration
+ */
+ dataMigrationManager.resetToVersion( entityDataMigration.getVersion() - 1 );
+
+
+ final EntityManager newAppEm = app.getEntityManager();
+
+ final String type1 = "type1thing";
+ final String type2 = "type2thing";
+ final int size = 10;
+
+ final Set<Id> type1Identities = EntityWriteHelper.createTypes( newAppEm, type1, size );
+ final Set<Id> type2Identities = EntityWriteHelper.createTypes( newAppEm, type2, size );
+
+
+ final Set<Id> createdEntityIds = new HashSet<>();
+ createdEntityIds.addAll( type1Identities );
+ createdEntityIds.addAll( type2Identities );
+
+
+ final TestProgressObserver progressObserver = new TestProgressObserver();
+
+
+ //load everything that appears in v1, migrate and ensure it appears in v2
+ final Set<MvccEntity> savedEntities = new HashSet<>( 10000 );
+ //set that holds all entityIds for later assertion
+ final Set<Id> entityIds = new HashSet<>(10000);
+
+
+ //read everything in previous version format and put it into our types. Assumes we're
+ //using a test system, and it's not a huge amount of data, otherwise we'll overflow.
+
+ AllEntitiesInSystemObservable.getAllEntitiesInSystem( managerCache, 1000 )
+ .doOnNext( new Action1<AllEntitiesInSystemObservable.ApplicationEntityGroup>() {
+ @Override
+ public void call(
+ final AllEntitiesInSystemObservable.ApplicationEntityGroup entity ) {
+
+ //add all versions from history to our comparison
+ for ( final Id id : entity.entityIds ) {
+
+ CollectionScope scope = CpNamingUtils
+ .getCollectionScopeNameFromEntityType(
+ entity.applicationScope.getApplication(),
+ id.getType() );
+
+ final Iterator<MvccEntity> versions = v1Strategy
+ .loadDescendingHistory( scope, id, UUIDGenerator.newTimeUUID(),
+ 100 );
+
+ while ( versions.hasNext() ) {
+
+ final MvccEntity mvccEntity = versions.next();
+
+ savedEntities.add( mvccEntity );
+
+ createdEntityIds.remove( mvccEntity.getId() );
+
+ entityIds.add( id );
+ }
+ }
+ }
+ } ).toBlocking().lastOrDefault( null );
+
+ assertEquals( "Newly saved entities encountered", 0, createdEntityIds.size() );
+ assertTrue( "Saved new entities", savedEntities.size() > 0 );
+
+ //perform the migration
+ entityDataMigration.migrate( progressObserver );
+
+ assertFalse( "Progress observer should not have failed", progressObserver.getFailed() );
+ assertTrue( "Progress observer should have update messages", progressObserver.getUpdates().size() > 0 );
+
+
+ //write the status and version, then invalidate the cache so it appears
+ migrationInfoSerialization.setStatusCode( DataMigrationManagerImpl.StatusCode.COMPLETE.status );
+ migrationInfoSerialization.setVersion( entityDataMigration.getVersion() );
+ dataMigrationManager.invalidate();
+
+ assertEquals( "New version saved, and we should get new implementation", entityDataMigration.getVersion(),
+ dataMigrationManager.getCurrentVersion() );
+
+
+ //now visit all entities in the system again, load them from v2, and ensure they're the same
+ AllEntitiesInSystemObservable.getAllEntitiesInSystem( managerCache, 1000 )
+ .doOnNext( new Action1<AllEntitiesInSystemObservable.ApplicationEntityGroup>() {
+ @Override
+ public void call(
+ final AllEntitiesInSystemObservable
+ .ApplicationEntityGroup entity ) {
+ //add all versions from history to our comparison
+ for ( final Id id : entity.entityIds ) {
+
+ CollectionScope scope = CpNamingUtils
+ .getCollectionScopeNameFromEntityType(
+ entity.applicationScope.getApplication(),
+ id.getType() );
+
+ final Iterator<MvccEntity> versions = v2Strategy
+ .loadDescendingHistory( scope, id,
+ UUIDGenerator.newTimeUUID(), 100 );
+
+ while ( versions.hasNext() ) {
+
+ final MvccEntity mvccEntity = versions.next();
+
+ savedEntities.remove( mvccEntity );
+ }
+ }
+ }
+ }
+
+
+ ).toBlocking().lastOrDefault( null );
+
+
+ assertEquals( "All entities migrated", 0, savedEntities.size() );
+
+
+ //now visit all entities in the system again, and load them from the EM, ensure we see everything we did in the v1 traversal
+ AllEntitiesInSystemObservable.getAllEntitiesInSystem( managerCache, 1000 )
+ .doOnNext( new Action1<AllEntitiesInSystemObservable.ApplicationEntityGroup>() {
+ @Override
+ public void call(
+ final AllEntitiesInSystemObservable
+ .ApplicationEntityGroup entity ) {
+
+ final EntityManager em = emf.getEntityManager( entity.applicationScope.getApplication().getUuid() );
+
+ //add all versions from history to our comparison
+ for ( final Id id : entity.entityIds ) {
+
+
+ try {
+ final Entity emEntity = em.get( SimpleEntityRef.fromId( id ) );
+
+ if(emEntity != null){
+ entityIds.remove( id );
+ }
+ }
+ catch ( Exception e ) {
+ throw new RuntimeException("Error loading entity", e);
+ }
+ }
+ }
+ }
+
+
+ ).toBlocking().lastOrDefault( null );
+
+
+ assertEquals("All entities could be loaded by the entity manager", 0, entityIds.size());
+
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e32d5212/stack/core/src/test/java/org/apache/usergrid/corepersistence/migration/GraphShardVersionMigrationIT.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/corepersistence/migration/GraphShardVersionMigrationIT.java b/stack/core/src/test/java/org/apache/usergrid/corepersistence/migration/GraphShardVersionMigrationIT.java
index 88c02cd..51ea052 100644
--- a/stack/core/src/test/java/org/apache/usergrid/corepersistence/migration/GraphShardVersionMigrationIT.java
+++ b/stack/core/src/test/java/org/apache/usergrid/corepersistence/migration/GraphShardVersionMigrationIT.java
@@ -42,7 +42,6 @@ import org.apache.usergrid.persistence.model.entity.Id;
import com.google.common.collect.HashMultimap;
import com.google.common.collect.Multimap;
import com.google.inject.Injector;
-import com.netflix.astyanax.Keyspace;
import rx.functions.Action1;
@@ -55,7 +54,6 @@ public class GraphShardVersionMigrationIT extends AbstractCoreIT {
private Injector injector;
private GraphShardVersionMigration graphShardVersionMigration;
- private Keyspace keyspace;
private ManagerCache managerCache;
private DataMigrationManager dataMigrationManager;
private MigrationInfoSerialization migrationInfoSerialization;
@@ -65,7 +63,6 @@ public class GraphShardVersionMigrationIT extends AbstractCoreIT {
public void setup() {
injector = CpSetup.getInjector();
graphShardVersionMigration = injector.getInstance( GraphShardVersionMigration.class );
- keyspace = injector.getInstance( Keyspace.class );
managerCache = injector.getInstance( ManagerCache.class );
dataMigrationManager = injector.getInstance( DataMigrationManager.class );
migrationInfoSerialization = injector.getInstance( MigrationInfoSerialization.class );
@@ -75,15 +72,12 @@ public class GraphShardVersionMigrationIT extends AbstractCoreIT {
@Test
public void testIdMapping() throws Throwable {
- assertEquals("version 2 expected", 2, graphShardVersionMigration.getVersion());
+ assertEquals( "version 2 expected", 2, graphShardVersionMigration.getVersion() );
/**
* Reset to our version -1 and start the migration
*/
- dataMigrationManager.resetToVersion( graphShardVersionMigration.getVersion()-1 );
-
-
-
+ dataMigrationManager.resetToVersion( graphShardVersionMigration.getVersion() - 1 );
final EntityManager newAppEm = app.getEntityManager();
@@ -111,15 +105,16 @@ public class GraphShardVersionMigrationIT extends AbstractCoreIT {
//read everything in previous version format and put it into our types.
- AllEntitiesInSystemObservable.getAllEntitiesInSystem( managerCache, 1000)
+ AllEntitiesInSystemObservable.getAllEntitiesInSystem( managerCache, 1000 )
.doOnNext( new Action1<AllEntitiesInSystemObservable.ApplicationEntityGroup>() {
@Override
- public void call( final AllEntitiesInSystemObservable.ApplicationEntityGroup entity ) {
+ public void call(
+ final AllEntitiesInSystemObservable.ApplicationEntityGroup entity ) {
final GraphManager gm =
managerCache.getGraphManager( entity.applicationScope );
- for(final Id id: entity.entityIds) {
+ for ( final Id id : entity.entityIds ) {
/**
* Get our edge types from the source
*/
@@ -135,8 +130,7 @@ public class GraphShardVersionMigrationIT extends AbstractCoreIT {
/**
* Get the edge types to the target
*/
- gm.getEdgeTypesToTarget( new SimpleSearchEdgeType( id,
- null, null ) )
+ gm.getEdgeTypesToTarget( new SimpleSearchEdgeType( id, null, null ) )
.doOnNext( new Action1<String>() {
@Override
public void call( final String s ) {
@@ -153,7 +147,7 @@ public class GraphShardVersionMigrationIT extends AbstractCoreIT {
//perform the migration
graphShardVersionMigration.migrate( progressObserver );
- assertEquals("Newly saved entities encounterd", 0, allEntities.size());
+ assertEquals( "Newly saved entities encounterd", 0, allEntities.size() );
assertFalse( "Progress observer should not have failed", progressObserver.getFailed() );
assertTrue( "Progress observer should have update messages", progressObserver.getUpdates().size() > 0 );
@@ -163,70 +157,57 @@ public class GraphShardVersionMigrationIT extends AbstractCoreIT {
migrationInfoSerialization.setVersion( graphShardVersionMigration.getVersion() );
dataMigrationManager.invalidate();
- assertEquals("New version saved, and we should get new implementation", graphShardVersionMigration.getVersion(), dataMigrationManager.getCurrentVersion());
+ assertEquals( "New version saved, and we should get new implementation",
+ graphShardVersionMigration.getVersion(), dataMigrationManager.getCurrentVersion() );
//now visit all nodes in the system and remove their types from the multi maps, it should be empty at the end
AllEntitiesInSystemObservable.getAllEntitiesInSystem( managerCache, 1000 )
.doOnNext( new Action1<AllEntitiesInSystemObservable.ApplicationEntityGroup>() {
- @Override
- public void call(
- final AllEntitiesInSystemObservable.ApplicationEntityGroup entity ) {
-
- final GraphManager gm =
- managerCache.getGraphManager( entity.applicationScope );
-
- for ( final Id id : entity.entityIds ) {
- /**
- * Get our edge types from the source
- */
- gm.getEdgeTypesFromSource(
- new SimpleSearchEdgeType( id, null, null ) )
- .doOnNext( new Action1<String>() {
- @Override
- public void call( final String s ) {
- sourceTypes.remove( id, s );
- }
- } ).toBlocking().lastOrDefault( null );
-
-
- /**
- * Get the edge types to the target
- */
- gm.getEdgeTypesToTarget(
- new SimpleSearchEdgeType( id, null, null ) )
- .doOnNext( new Action1<String>() {
- @Override
- public void call( final String s ) {
- targetTypes.remove( id, s );
- }
- } ).toBlocking().lastOrDefault( null );
- }
- }
- }
-
-
- ).
-
-
- toBlocking()
-
-
- .
-
-
- lastOrDefault( null );
-
-
- assertEquals( "All source types migrated",0,sourceTypes.size( )
-
-
- );
-
-
- assertEquals( "All target types migrated",0,targetTypes.size( )
-
-
- );
- }
+ @Override
+ public void call(
+ final AllEntitiesInSystemObservable
+ .ApplicationEntityGroup entity ) {
+
+ final GraphManager gm =
+ managerCache.getGraphManager( entity.applicationScope );
+
+ for ( final Id id : entity.entityIds ) {
+ /**
+ * Get our edge types from the source
+ */
+ gm.getEdgeTypesFromSource(
+ new SimpleSearchEdgeType( id, null, null ) )
+ .doOnNext( new Action1<String>() {
+ @Override
+ public void call( final String s ) {
+ sourceTypes.remove( id, s );
+ }
+ } ).toBlocking().lastOrDefault( null );
+
+
+ /**
+ * Get the edge types to the target
+ */
+ gm.getEdgeTypesToTarget(
+ new SimpleSearchEdgeType( id, null, null ) )
+ .doOnNext( new Action1<String>() {
+ @Override
+ public void call( final String s ) {
+ targetTypes.remove( id, s );
+ }
+ } ).toBlocking().lastOrDefault( null );
+ }
+ }
+ }
+
+
+ ).toBlocking().lastOrDefault( null );
+
+
+ assertEquals( "All source types migrated", 0, sourceTypes.size() );
+
+
+ assertEquals( "All target types migrated", 0, targetTypes.size() );
}
+}
[20/50] [abbrv] incubator-usergrid git commit: Merge branch
'two-dot-o' into two-dot-o-events
Posted by sn...@apache.org.
Merge branch 'two-dot-o' into two-dot-o-events
Conflicts:
stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityDeleteListener.java
stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
stack/core/src/main/java/org/apache/usergrid/corepersistence/GuiceModule.java
stack/core/src/test/java/org/apache/usergrid/corepersistence/CpEntityDeleteListenerTest.java
stack/core/src/test/java/org/apache/usergrid/corepersistence/StaleIndexCleanupTest.java
stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/impl/EntityCollectionManagerImpl.java
stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/delete/MarkCommit.java
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/c3261795
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/c3261795
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/c3261795
Branch: refs/heads/two-dot-o-events
Commit: c3261795af2e0992ae9aecd8332e733dac42e0a8
Parents: 1884cce bd0a1e9
Author: Dave Johnson <dm...@apigee.com>
Authored: Tue Nov 25 07:31:05 2014 -0500
Committer: Dave Johnson <dm...@apigee.com>
Committed: Tue Nov 25 07:31:05 2014 -0500
----------------------------------------------------------------------
stack/core/pom.xml | 32 +-
.../corepersistence/CpEntityManager.java | 134 +-
.../corepersistence/CpEntityManagerFactory.java | 2 +-
.../corepersistence/CpRelationManager.java | 35 +-
.../usergrid/corepersistence/GuiceModule.java | 1 +
.../migration/EntityDataMigration.java | 147 ++
.../migration/EntityTypeMappingMigration.java | 28 +-
.../migration/GraphShardVersionMigration.java | 104 +-
.../corepersistence/migration/Versions.java | 3 +
.../rx/AllEntitiesInSystemObservable.java | 27 +-
.../rx/ApplicationObservable.java | 65 +-
.../corepersistence/util/CpEntityMapUtils.java | 62 +-
.../corepersistence/util/CpNamingUtils.java | 17 +
.../org/apache/usergrid/CoreITSetupImpl.java | 13 +
.../corepersistence/StaleIndexCleanupTest.java | 6 +-
.../migration/EntityDataMigrationIT.java | 252 ++++
.../migration/EntityTypeMappingMigrationIT.java | 74 +-
.../migration/GraphShardVersionMigrationIT.java | 153 +-
.../rx/AllEntitiesInSystemObservableIT.java | 23 +-
.../usergrid/persistence/LargeEntityIT.java | 112 ++
stack/core/src/test/resources/largeentity.json | 1329 ++++++++++++++++++
.../collection/EntityCollectionManager.java | 2 +-
.../exception/EntityTooLargeException.java | 67 +
.../collection/guice/CollectionModule.java | 2 -
.../impl/EntityCollectionManagerImpl.java | 294 ++--
.../collection/impl/EntityDeletedTask.java | 11 +-
.../impl/EntityVersionCleanupTask.java | 13 +-
.../mvcc/MvccEntitySerializationStrategy.java | 23 +-
.../mvcc/MvccLogEntrySerializationStrategy.java | 3 +-
.../mvcc/stage/delete/MarkCommit.java | 19 +-
.../mvcc/stage/write/WriteCommit.java | 3 +-
.../serialization/SerializationFig.java | 15 +-
.../UniqueValueSerializationStrategy.java | 3 +-
.../serialization/impl/EntityRepairImpl.java | 2 +-
.../MvccEntitySerializationStrategyImpl.java | 343 ++---
...vccEntitySerializationStrategyProxyImpl.java | 162 +++
.../MvccEntitySerializationStrategyV1Impl.java | 219 +++
.../MvccEntitySerializationStrategyV2Impl.java | 238 ++++
.../MvccLogEntrySerializationStrategyImpl.java | 2 +-
.../serialization/impl/SerializationModule.java | 25 +-
.../serialization/impl/SettingsValidation.java | 58 +
.../UniqueValueSerializationStrategyImpl.java | 2 +-
.../EntityCollectionManagerFactoryTest.java | 2 +-
.../collection/EntityCollectionManagerIT.java | 64 +-
.../EntityCollectionManagerStressTest.java | 2 +-
.../EntityCollectionManagerSyncIT.java | 2 +-
.../collection/guice/MigrationManagerRule.java | 38 -
.../collection/guice/TestCollectionModule.java | 10 +
.../impl/EntityVersionCleanupTaskTest.java | 11 +-
...niqueValueSerializationStrategyImplTest.java | 2 +-
.../mvcc/stage/write/WriteUniqueVerifyIT.java | 2 +-
.../mvcc/stage/write/WriteUniqueVerifyTest.java | 2 +-
.../serialization/EntityRepairImplTest.java | 2 +-
...MvccEntitySerializationStrategyImplTest.java | 87 +-
...cEntitySerializationStrategyProxyV1Test.java | 85 ++
...cEntitySerializationStrategyProxyV2Test.java | 83 ++
...ccEntitySerializationStrategyV1ImplTest.java | 55 +
...ccEntitySerializationStrategyV2ImplTest.java | 55 +
.../MvccEntitySerializationStrategyV2Test.java | 229 +++
.../impl/MvccLESSTransientTest.java | 55 +-
...ccLogEntrySerializationStrategyImplTest.java | 2 +-
.../impl/SettingsValidationTest.java | 131 ++
.../collection/util/EntityHelper.java | 105 ++
.../src/test/resources/log4j.properties | 21 +-
.../persistence/core/astyanax/CassandraFig.java | 12 +
.../persistence/core/astyanax/FieldBuffer.java | 70 +
.../core/astyanax/FieldBufferBuilder.java | 87 ++
.../core/astyanax/FieldBufferParser.java | 81 ++
.../core/astyanax/FieldBufferSerializer.java | 134 ++
.../core/guicyfig/SetConfigTestBypass.java | 108 ++
.../astyanax/FieldBufferSerializerTest.java | 126 ++
.../core/guice/MaxMigrationModule.java | 39 +
.../core/guice/MaxMigrationVersion.java | 40 +
.../core/guice/MigrationManagerRule.java | 19 +-
.../persistence/graph/GraphManagerIT.java | 2 +-
.../persistence/graph/GraphManagerLoadTest.java | 2 +-
.../graph/GraphManagerShardingIT.java | 2 +-
.../graph/GraphManagerStressTest.java | 2 +-
.../usergrid/persistence/graph/SimpleTest.java | 2 +-
.../graph/guice/TestGraphModule.java | 11 +
.../graph/impl/EdgeDeleteListenerTest.java | 2 +-
.../graph/impl/NodeDeleteListenerTest.java | 2 +-
.../graph/impl/stage/EdgeDeleteRepairTest.java | 2 +-
.../graph/impl/stage/EdgeMetaRepairTest.java | 2 +-
.../EdgeMetadataSerializationTest.java | 2 +-
.../EdgeSerializationChopTest.java | 2 +-
.../serialization/EdgeSerializationTest.java | 2 +-
.../serialization/NodeSerializationTest.java | 2 +-
.../impl/shard/EdgeShardSerializationTest.java | 2 +-
.../NodeShardCounterSerializationTest.java | 2 +-
.../persistence/map/MapManagerTest.java | 2 +-
.../persistence/model/field/LocationField.java | 3 -
.../index/impl/EntityIndexMapUtils.java | 4 +-
.../persistence/queue/QueueManagerTest.java | 26 +-
.../collection/groups/GroupResourceIT.java | 182 +--
.../applications/queries/GeoPagingTest.java | 41 +-
.../applications/queries/basicGeoTests.java | 184 +++
97 files changed, 5219 insertions(+), 1150 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c3261795/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
----------------------------------------------------------------------
diff --cc stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
index 5a193e5,b2d854b..c3e5bbe
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
@@@ -69,7 -69,7 +69,6 @@@ import org.apache.usergrid.persistence.
import org.apache.usergrid.persistence.collection.EntityCollectionManager;
import org.apache.usergrid.persistence.collection.exception.WriteOptimisticVerifyException;
import org.apache.usergrid.persistence.collection.exception.WriteUniqueVerifyException;
--import org.apache.usergrid.persistence.collection.impl.CollectionScopeImpl;
import org.apache.usergrid.persistence.core.scope.ApplicationScope;
import org.apache.usergrid.persistence.core.util.Health;
import org.apache.usergrid.persistence.entities.Application;
@@@ -214,23 -215,23 +214,22 @@@ public class CpEntityManager implement
// set to false for now
this.skipAggregateCounters = false;
-- int entityCacheSize =
-- Integer.parseInt( cass.getProperties().getProperty( "usergrid.entity_cache_size", "100" ) );
++ int entityCacheSize = Integer.parseInt(
++ cass.getProperties().getProperty( "usergrid.entity_cache_size", "100" ) );
-- int entityCacheTimeout =
-- Integer.parseInt( cass.getProperties().getProperty( "usergrid.entity_cache_timeout_ms", "500" ) );
++ int entityCacheTimeout = Integer.parseInt(
++ cass.getProperties().getProperty( "usergrid.entity_cache_timeout_ms", "500" ) );
this.entityCache = CacheBuilder.newBuilder().maximumSize( entityCacheSize )
-- .expireAfterWrite( entityCacheTimeout, TimeUnit.MILLISECONDS )
-- .build( new CacheLoader<EntityScope, org.apache.usergrid.persistence.model
-- .entity.Entity>() {
-- public org.apache.usergrid.persistence.model.entity.Entity load(
-- EntityScope es ) {
-- return managerCache.getEntityCollectionManager( es.scope )
-- .load( es.entityId ).toBlocking()
-- .lastOrDefault( null );
-- }
-- } );
++ .expireAfterWrite(entityCacheTimeout, TimeUnit.MILLISECONDS)
++ .build(new CacheLoader<EntityScope, org.apache.usergrid.persistence.model.entity.Entity>() {
++ public org.apache.usergrid.persistence.model.entity.Entity load(
++ EntityScope es) {
++ return managerCache.getEntityCollectionManager(es.scope)
++ .load(es.entityId).toBlocking()
++ .lastOrDefault(null);
++ }
++ });
}
@@@ -347,8 -348,8 +346,8 @@@
*/
@Metered( group = "core", name = "EntityManager_create" )
@TraceParticipant
-- public <A extends Entity> A create( String entityType, Class<A> entityClass, Map<String, Object> properties,
-- UUID importId ) throws Exception {
++ public <A extends Entity> A create( String entityType, Class<A> entityClass,
++ Map<String, Object> properties, UUID importId ) throws Exception {
UUID timestampUuid = importId != null ? importId : UUIDUtils.newTimeUUID();
@@@ -372,13 -373,9 +371,10 @@@
}
Id id = new SimpleId( entityRef.getUuid(), entityRef.getType() );
- String collectionName = CpNamingUtils.getCollectionScopeNameFromEntityType( entityRef.getType() );
- CollectionScope collectionScope =
- new CollectionScopeImpl( getApplicationScope().getApplication(), getApplicationScope().getApplication(),
- collectionName );
- CollectionScope collectionScope = getCollectionScopeNameFromEntityType(applicationScope.getApplication(), entityRef.getType());
++ CollectionScope collectionScope = getCollectionScopeNameFromEntityType(
++ applicationScope.getApplication(), entityRef.getType());
- EntityCollectionManager ecm = managerCache.getEntityCollectionManager( collectionScope );
// if ( !UUIDUtils.isTimeBased( id.getUuid() ) ) {
// throw new IllegalArgumentException(
@@@ -390,10 -387,10 +386,10 @@@
if ( cpEntity == null ) {
if ( logger.isDebugEnabled() ) {
logger.debug( "FAILED to load entity {}:{} from scope\n app {}\n owner {}\n name {}",
-- new Object[] {
-- id.getType(), id.getUuid(), collectionScope.getApplication(),
-- collectionScope.getOwner(), collectionScope.getName()
-- } );
++ new Object[] {
++ id.getType(), id.getUuid(), collectionScope.getApplication(),
++ collectionScope.getOwner(), collectionScope.getName()
++ } );
}
return null;
}
@@@ -457,13 -454,10 +453,11 @@@
String type = Schema.getDefaultSchema().getEntityType( entityClass );
Id id = new SimpleId( entityId, type );
- String collectionName = CpNamingUtils.getCollectionScopeNameFromEntityType( type );
- CollectionScope collectionScope =
- new CollectionScopeImpl( getApplicationScope().getApplication(), getApplicationScope().getApplication(),
- collectionName );
- EntityCollectionManager ecm = managerCache.getEntityCollectionManager( collectionScope );
- CollectionScope collectionScope = getCollectionScopeNameFromEntityType(applicationScope.getApplication(), type);
++ CollectionScope collectionScope = getCollectionScopeNameFromEntityType(
++ applicationScope.getApplication(), type);
+
// if ( !UUIDUtils.isTimeBased( id.getUuid() ) ) {
// throw new IllegalArgumentException(
@@@ -522,18 -516,17 +516,22 @@@
public void update( Entity entity ) throws Exception {
// first, update entity index in its own collection scope
- CollectionScope collectionScope =
- new CollectionScopeImpl( getApplicationScope().getApplication(), getApplicationScope().getApplication(),
- CpNamingUtils.getCollectionScopeNameFromEntityType( entity.getType() ) );
+
- CollectionScope collectionScope = getCollectionScopeNameFromEntityType(applicationScope.getApplication(), entity.getType());
++ CollectionScope collectionScope = getCollectionScopeNameFromEntityType(
++ applicationScope.getApplication(), entity.getType());
EntityCollectionManager ecm = managerCache.getEntityCollectionManager( collectionScope );
Id entityId = new SimpleId( entity.getUuid(), entity.getType() );
if ( logger.isDebugEnabled() ) {
-- logger.debug( "Updating entity {}:{} from scope\n app {}\n owner {}\n name {}", new Object[] {
-- entityId.getType(), entityId.getUuid(), collectionScope.getApplication(),
-- collectionScope.getOwner(), collectionScope.getName()
-- } );
++ logger.debug( "Updating entity {}:{} from scope\n app {}\n owner {}\n name {}",
++ new Object[] {
++ entityId.getType(),
++ entityId.getUuid(),
++ collectionScope.getApplication(),
++ collectionScope.getOwner(),
++ collectionScope.getName()
++ } );
}
// if ( !UUIDUtils.isTimeBased( entityId.getUuid() ) ) {
@@@ -590,9 -583,7 +588,8 @@@
private Observable deleteAsync( EntityRef entityRef ) throws Exception {
- CollectionScope collectionScope =
- new CollectionScopeImpl( getApplicationScope().getApplication(), getApplicationScope().getApplication(),
- CpNamingUtils.getCollectionScopeNameFromEntityType( entityRef.getType() ) );
- CollectionScope collectionScope = getCollectionScopeNameFromEntityType(applicationScope.getApplication(), entityRef.getType() );
++ CollectionScope collectionScope = getCollectionScopeNameFromEntityType(
++ applicationScope.getApplication(), entityRef.getType() );
EntityCollectionManager ecm = managerCache.getEntityCollectionManager( collectionScope );
@@@ -866,9 -857,9 +863,8 @@@
}
-- private Iterable<EntityRef> getEntityRefsForUniqueProperty( String collName, String propName, String alias )
-- throws Exception {
--
++ private Iterable<EntityRef> getEntityRefsForUniqueProperty(
++ String collName, String propName, String alias ) throws Exception {
final Id id = getIdForUniqueEntityField( collName, propName, alias );
@@@ -900,15 -891,15 +896,17 @@@
get( entityRef ).getType();
}
catch ( Exception e ) {
-- logger.error( "Unable to load entity " + entityRef.getType() + ":" + entityRef.getUuid(), e );
++ logger.error( "Unable to load entity " + entityRef.getType()
++ + ":" + entityRef.getUuid(), e );
}
if ( entityRef == null ) {
-- throw new EntityNotFoundException( "Entity " + entityId.toString() + " cannot be verified" );
++ throw new EntityNotFoundException(
++ "Entity " + entityId.toString() + " cannot be verified" );
}
if ( ( entityType != null ) && !entityType.equalsIgnoreCase( entityRef.getType() ) ) {
throw new UnexpectedEntityTypeException(
-- "Entity " + entityId + " is not the expected type, expected " + entityType + ", found "
-- + entityRef.getType() );
++ "Entity " + entityId + " is not the expected type, expected "
++ + entityType + ", found " + entityRef.getType() );
}
}
return entityRef;
@@@ -924,7 -915,7 +922,8 @@@
@Override
-- public List<Entity> getPartialEntities( Collection<UUID> ids, Collection<String> properties ) throws Exception {
++ public List<Entity> getPartialEntities(
++ Collection<UUID> ids, Collection<String> properties ) throws Exception {
throw new UnsupportedOperationException( "Not supported yet." );
}
@@@ -938,15 -929,15 +937,16 @@@
@Override
-- public void setProperty( EntityRef entityRef, String propertyName, Object propertyValue ) throws Exception {
++ public void setProperty(
++ EntityRef entityRef, String propertyName, Object propertyValue ) throws Exception {
setProperty( entityRef, propertyName, propertyValue, false );
}
@Override
-- public void setProperty( EntityRef entityRef, String propertyName, Object propertyValue, boolean override )
-- throws Exception {
++ public void setProperty( EntityRef entityRef, String propertyName, Object propertyValue,
++ boolean override ) throws Exception {
if ( ( propertyValue instanceof String ) && ( ( String ) propertyValue ).equals( "" ) ) {
propertyValue = null;
@@@ -954,8 -945,8 +954,8 @@@
Entity entity = get( entityRef );
-- propertyValue =
-- Schema.getDefaultSchema().validateEntityPropertyValue( entity.getType(), propertyName, propertyValue );
++ propertyValue = Schema.getDefaultSchema().validateEntityPropertyValue(
++ entity.getType(), propertyName, propertyValue );
entity.setProperty( propertyName, propertyValue );
entity.setProperty( PROPERTY_MODIFIED, UUIDUtils.getTimestampInMillis( UUIDUtils.newTimeUUID() ) );
@@@ -1010,15 -1001,10 +1010,12 @@@
@Override
public void deleteProperty( EntityRef entityRef, String propertyName ) throws Exception {
- CollectionScope collectionScope = getCollectionScopeNameFromEntityType(getApplicationScope().getApplication(), entityRef.getType());
+
- String collectionName = CpNamingUtils.getCollectionScopeNameFromEntityType( entityRef.getType() );
-
- CollectionScope collectionScope =
- new CollectionScopeImpl( getApplicationScope().getApplication(), getApplicationScope().getApplication(),
- collectionName );
++ CollectionScope collectionScope = getCollectionScopeNameFromEntityType(
++ getApplicationScope().getApplication(), entityRef.getType());
IndexScope defaultIndexScope = new IndexScopeImpl( getApplicationScope().getApplication(),
- CpNamingUtils.getCollectionScopeNameFromEntityType( entityRef.getType() ) );
+ getCollectionScopeNameFromEntityType( entityRef.getType() ) );
EntityCollectionManager ecm = managerCache.getEntityCollectionManager( collectionScope );
EntityIndex ei = managerCache.getEntityIndex( getApplicationScope() );
@@@ -1062,15 -1048,15 +1059,16 @@@
@Override
-- public void addToDictionary( EntityRef entityRef, String dictionaryName, Object elementValue ) throws Exception {
++ public void addToDictionary( EntityRef entityRef, String dictionaryName,
++ Object elementValue ) throws Exception {
addToDictionary( entityRef, dictionaryName, elementValue, null );
}
@Override
-- public void addToDictionary( EntityRef entityRef, String dictionaryName, Object elementName, Object elementValue )
-- throws Exception {
++ public void addToDictionary( EntityRef entityRef, String dictionaryName, Object elementName,
++ Object elementValue ) throws Exception {
if ( elementName == null ) {
return;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c3261795/stack/core/src/main/java/org/apache/usergrid/corepersistence/GuiceModule.java
----------------------------------------------------------------------
diff --cc stack/core/src/main/java/org/apache/usergrid/corepersistence/GuiceModule.java
index a57158f,018a9b7..2ff6c4f
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/GuiceModule.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/GuiceModule.java
@@@ -18,15 -19,10 +18,16 @@@ package org.apache.usergrid.corepersist
import com.google.inject.AbstractModule;
import com.google.inject.multibindings.Multibinder;
+ import org.apache.usergrid.corepersistence.migration.EntityDataMigration;
import org.apache.usergrid.corepersistence.migration.EntityTypeMappingMigration;
import org.apache.usergrid.corepersistence.migration.GraphShardVersionMigration;
+import org.apache.usergrid.corepersistence.events.EntityDeletedHandler;
+import org.apache.usergrid.corepersistence.events.EntityVersionCreatedHandler;
+import org.apache.usergrid.corepersistence.events.EntityVersionDeletedHandler;
+import org.apache.usergrid.persistence.EntityManagerFactory;
+import org.apache.usergrid.persistence.collection.event.EntityDeleted;
+import org.apache.usergrid.persistence.collection.event.EntityVersionCreated;
+import org.apache.usergrid.persistence.collection.event.EntityVersionDeleted;
import org.apache.usergrid.persistence.collection.guice.CollectionModule;
import org.apache.usergrid.persistence.core.guice.CommonModule;
import org.apache.usergrid.persistence.core.migration.data.DataMigration;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c3261795/stack/core/src/test/java/org/apache/usergrid/corepersistence/StaleIndexCleanupTest.java
----------------------------------------------------------------------
diff --cc stack/core/src/test/java/org/apache/usergrid/corepersistence/StaleIndexCleanupTest.java
index e1c0214,9d0c9e6..f159146
--- a/stack/core/src/test/java/org/apache/usergrid/corepersistence/StaleIndexCleanupTest.java
+++ b/stack/core/src/test/java/org/apache/usergrid/corepersistence/StaleIndexCleanupTest.java
@@@ -51,17 -51,13 +51,18 @@@ import org.apache.usergrid.persistence.
import org.apache.usergrid.persistence.model.entity.SimpleId;
import com.fasterxml.uuid.UUIDComparator;
+import java.util.concurrent.locks.Lock;
+import java.util.concurrent.locks.ReentrantLock;
+ import static org.apache.usergrid.corepersistence.util.CpNamingUtils.getCollectionScopeNameFromEntityType;
import static org.apache.usergrid.persistence.Schema.TYPE_APPLICATION;
+import org.junit.After;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
+import org.junit.Before;
+//need to create system properties in test that can get applied
/**
* Test on read style clean-up of stale ElasticSearch indexes.
*/
@@@ -382,13 -221,9 +383,10 @@@ public class StaleIndexCleanupTest exte
EntityManager em = app.getEntityManager();
- CollectionScope cs = new CollectionScopeImpl(
- new SimpleId( em.getApplicationId(), TYPE_APPLICATION ),
- new SimpleId( em.getApplicationId(), TYPE_APPLICATION ),
- CpNamingUtils.getCollectionScopeNameFromEntityType( eref.getType() ) );
+ CollectionScope cs = getCollectionScopeNameFromEntityType( new SimpleId( em.getApplicationId(), TYPE_APPLICATION ), eref.getType() );
- EntityCollectionManagerFactory ecmf = CpSetup.getInjector().getInstance( EntityCollectionManagerFactory.class );
+ EntityCollectionManagerFactory ecmf =
+ CpSetup.getInjector().getInstance( EntityCollectionManagerFactory.class );
EntityCollectionManager ecm = ecmf.createCollectionManager( cs );
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c3261795/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/EntityCollectionManager.java
----------------------------------------------------------------------
diff --cc stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/EntityCollectionManager.java
index e47d460,534d7a6..4de18fe
--- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/EntityCollectionManager.java
+++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/EntityCollectionManager.java
@@@ -43,7 -45,7 +43,7 @@@ public interface EntityCollectionManage
/**
* MarkCommit the entity and remove it's indexes with the given entity id
*/
-- public Observable<Void> delete( Id entityId );
++ public Observable<Id> delete( Id entityId );
/**
* Load the entity with the given entity Id
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c3261795/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/guice/CollectionModule.java
----------------------------------------------------------------------
diff --cc stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/guice/CollectionModule.java
index 4c96303,8015ca9..1c3e258
--- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/guice/CollectionModule.java
+++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/guice/CollectionModule.java
@@@ -18,8 -18,6 +18,7 @@@
package org.apache.usergrid.persistence.collection.guice;
- import java.util.Collections;
+
import org.safehaus.guicyfig.GuicyFigModule;
import org.apache.usergrid.persistence.collection.EntityCollectionManager;
@@@ -50,9 -43,7 +49,8 @@@ import com.google.inject.Inject
import com.google.inject.Provides;
import com.google.inject.Singleton;
import com.google.inject.assistedinject.FactoryModuleBuilder;
-
+import com.google.inject.multibindings.Multibinder;
- import java.util.List;
+import org.apache.usergrid.persistence.collection.event.EntityVersionCreated;
/**
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c3261795/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/impl/EntityCollectionManagerImpl.java
----------------------------------------------------------------------
diff --cc stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/impl/EntityCollectionManagerImpl.java
index 437c0d3,d54c5f7..a89924a
--- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/impl/EntityCollectionManagerImpl.java
+++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/impl/EntityCollectionManagerImpl.java
@@@ -60,10 -65,6 +65,12 @@@ import com.netflix.astyanax.connectionp
import com.netflix.astyanax.model.ColumnFamily;
import com.netflix.astyanax.model.CqlResult;
import com.netflix.astyanax.serializers.StringSerializer;
++import org.apache.usergrid.persistence.collection.EntityDeletedFactory;
++import org.apache.usergrid.persistence.collection.EntityVersionCleanupFactory;
++import org.apache.usergrid.persistence.collection.EntityVersionCreatedFactory;
+import org.apache.usergrid.persistence.collection.guice.CollectionTaskExecutor;
- import org.apache.usergrid.persistence.collection.serialization.SerializationFig;
++import org.apache.usergrid.persistence.core.task.Task;
+import org.apache.usergrid.persistence.core.task.TaskExecutor;
- import org.apache.usergrid.persistence.core.util.Health;
import rx.Observable;
import rx.Subscriber;
@@@ -109,24 -106,16 +117,26 @@@ public class EntityCollectionManagerImp
@Inject
- public EntityCollectionManagerImpl(
- @Write final WriteStart writeStart,
- @WriteUpdate final WriteStart writeUpdate,
- final WriteUniqueVerify writeVerifyUnique,
- final WriteOptimisticVerify writeOptimisticVerify,
- final WriteCommit writeCommit, final RollbackAction rollback,
- final MarkStart markStart, final MarkCommit markCommit,
- final MvccEntitySerializationStrategy entitySerializationStrategy,
- final UniqueValueSerializationStrategy uniqueValueSerializationStrategy,
- final MvccLogEntrySerializationStrategy mvccLogEntrySerializationStrategy,
- final Keyspace keyspace,
- final SerializationFig config,
- final EntityVersionCleanupFactory entityVersionCleanupFactory,
- final EntityVersionCreatedFactory entityVersionCreatedFactory,
- final EntityDeletedFactory entityDeletedFactory,
- public EntityCollectionManagerImpl( @Write final WriteStart writeStart, @WriteUpdate final WriteStart writeUpdate,
- final WriteUniqueVerify writeVerifyUnique,
- final WriteOptimisticVerify writeOptimisticVerify,
- final WriteCommit writeCommit, final RollbackAction rollback,
- final MarkStart markStart, final MarkCommit markCommit,
- @ProxyImpl final MvccEntitySerializationStrategy entitySerializationStrategy,
- final UniqueValueSerializationStrategy uniqueValueSerializationStrategy,
- final MvccLogEntrySerializationStrategy mvccLogEntrySerializationStrategy,
- final Keyspace keyspace, final SerializationFig config,
- @Assisted final CollectionScope collectionScope ) {
++ public EntityCollectionManagerImpl(
++ @Write final WriteStart writeStart,
++ @WriteUpdate final WriteStart writeUpdate,
++ final WriteUniqueVerify writeVerifyUnique,
++ final WriteOptimisticVerify writeOptimisticVerify,
++ final WriteCommit writeCommit,
++ final RollbackAction rollback,
++ final MarkStart markStart,
++ final MarkCommit markCommit,
++ @ProxyImpl final MvccEntitySerializationStrategy entitySerializationStrategy,
++ final UniqueValueSerializationStrategy uniqueValueSerializationStrategy,
++ final MvccLogEntrySerializationStrategy mvccLogEntrySerializationStrategy,
++ final Keyspace keyspace,
++ final SerializationFig config,
++ final EntityVersionCleanupFactory entityVersionCleanupFactory,
++ final EntityVersionCreatedFactory entityVersionCreatedFactory,
++ final EntityDeletedFactory entityDeletedFactory,
+ @CollectionTaskExecutor final TaskExecutor taskExecutor,
- @Assisted final CollectionScope collectionScope
++ @Assisted final CollectionScope collectionScope
+ ) {
this.uniqueValueSerializationStrategy = uniqueValueSerializationStrategy;
this.entitySerializationStrategy = entitySerializationStrategy;
@@@ -176,42 -161,25 +187,42 @@@
// observable = Concurrent.concurrent( observable, Schedulers.io(), new WaitZip(),
// writeVerifyUnique, writeOptimisticVerify );
- observable.map(writeCommit).doOnNext(new Action1<Entity>() {
- // return the commit result.
- return observable.map( writeCommit ).doOnError( rollback );
++ return observable.map(writeCommit).doOnNext(new Action1<Entity>() {
+ @Override
+ public void call(final Entity entity) {
+ //TODO fire the created task first then the entityVersioncleanup
+ taskExecutor.submit(entityVersionCreatedFactory.getTask(collectionScope,entity));
+ taskExecutor.submit(entityVersionCleanupFactory.getTask(collectionScope, entityId,entity.getVersion()));
+ //post-processing to come later. leave it empty for now.
+ }
+ }).doOnError(rollback);
-
-
- // return the commit result.
- return observable.map(writeCommit).doOnError(rollback);
}
@Override
- public Observable<Void> delete(final Id entityId) {
-
- Preconditions.checkNotNull(entityId, "Entity id is required in this stage");
- Preconditions.checkNotNull(entityId.getUuid(), "Entity id is required in this stage");
- Preconditions.checkNotNull(entityId.getType(), "Entity type is required in this stage");
-
- public Observable<Void> delete( final Id entityId ) {
++ public Observable<Id> delete( final Id entityId ) {
+
+ Preconditions.checkNotNull( entityId, "Entity id is required in this stage" );
+ Preconditions.checkNotNull( entityId.getUuid(), "Entity id is required in this stage" );
+ Preconditions.checkNotNull( entityId.getType(), "Entity type is required in this stage" );
+
- return Observable.from( new CollectionIoEvent<Id>( collectionScope, entityId ) ).map( markStart )
- .doOnNext( markCommit ).map( new Func1<CollectionIoEvent<MvccEntity>, Void>() {
- @Override
- public Void call( final CollectionIoEvent<MvccEntity> mvccEntityCollectionIoEvent ) {
- return null;
- }
- } );
++ Observable<Id> o = Observable.from(new CollectionIoEvent<Id>(collectionScope, entityId))
++ .map( markStart)
++ .doOnNext( markCommit)
++ .map( new Func1<CollectionIoEvent<MvccEntity>, Id>() {
++
++ @Override
++ public Id call(final CollectionIoEvent<MvccEntity> mvccEntityCollectionIoEvent) {
++ MvccEntity entity = mvccEntityCollectionIoEvent.getEvent();
++ Task<Void> task = entityDeletedFactory
++ .getTask( collectionScope, entity.getId(), entity.getVersion());
++ taskExecutor.submit(task);
++ return entity.getId();
++ }
++ }
++ );
+
- Observable<Void> o = Observable.from(new CollectionIoEvent<Id>(collectionScope, entityId)).map(markStart)
- .doOnNext(markCommit).map(new Func1<CollectionIoEvent<MvccEntity>, Void>() {
- @Override
- public Void call(final CollectionIoEvent<MvccEntity> mvccEntityCollectionIoEvent) {
- MvccEntity entity = mvccEntityCollectionIoEvent.getEvent();
- Task<Void> task = entityDeletedFactory.getTask(
- collectionScope,entity.getId(),entity.getVersion());
- taskExecutor.submit(task);
- return null;
- }
- });
+ return o;
}
@@@ -289,23 -261,30 +304,31 @@@
final Id entityId = entity.getId();
- ValidationUtils.verifyIdentity(entityId);
+
+ ValidationUtils.verifyIdentity( entityId );
// create our observable and start the write
- CollectionIoEvent<Entity> writeData = new CollectionIoEvent<Entity>(collectionScope, entity);
+ CollectionIoEvent<Entity> writeData = new CollectionIoEvent<Entity>( collectionScope, entity );
- Observable<CollectionIoEvent<MvccEntity>> observable = stageRunner(writeData, writeUpdate);
- return observable.map(writeCommit).doOnNext(new Action1<Entity>() {
+ Observable<CollectionIoEvent<MvccEntity>> observable = stageRunner( writeData, writeUpdate );
+
+
+ return observable.map( writeCommit ).doOnNext( new Action1<Entity>() {
@Override
- public void call(final Entity entity) {
- logger.debug("sending entity to the queue");
+ public void call( final Entity entity ) {
+ logger.debug( "sending entity to the queue" );
//we an update, signal the fix
+ taskExecutor.submit(entityVersionCreatedFactory.getTask(collectionScope,entity));
+ //TODO T.N Change this to fire a task
+ // Observable.from( new CollectionIoEvent<Id>(collectionScope,
+ // entityId ) ).map( load ).subscribeOn( Schedulers.io() ).subscribe();
+
+
}
- }).doOnError(rollback);
+ } ).doOnError( rollback );
}
@@@ -381,5 -358,4 +402,4 @@@
return Health.RED;
}
-
--}
++}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c3261795/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/impl/EntityDeletedTask.java
----------------------------------------------------------------------
diff --cc stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/impl/EntityDeletedTask.java
index 284cf5b,0000000..9ff4f56
mode 100644,000000..100644
--- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/impl/EntityDeletedTask.java
+++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/impl/EntityDeletedTask.java
@@@ -1,147 -1,0 +1,148 @@@
+/*
+ * 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.collection.impl;
+
+import com.google.inject.Inject;
+import com.google.inject.assistedinject.Assisted;
+import com.netflix.astyanax.MutationBatch;
+import org.apache.usergrid.persistence.collection.CollectionScope;
+import org.apache.usergrid.persistence.collection.EntityVersionCleanupFactory;
+import org.apache.usergrid.persistence.collection.event.EntityDeleted;
+import org.apache.usergrid.persistence.collection.mvcc.MvccEntitySerializationStrategy;
+import org.apache.usergrid.persistence.collection.mvcc.MvccLogEntrySerializationStrategy;
+import org.apache.usergrid.persistence.core.task.Task;
+import org.apache.usergrid.persistence.model.entity.Id;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import rx.Observable;
+import rx.functions.Action1;
+import rx.functions.Func1;
+import rx.schedulers.Schedulers;
+
+import java.util.Set;
+import java.util.UUID;
++import org.apache.usergrid.persistence.core.guice.ProxyImpl;
+
+
+/**
+ * Fires Cleanup Task
+ */
+public class EntityDeletedTask implements Task<Void> {
+ private static final Logger LOG = LoggerFactory.getLogger(EntityDeletedTask.class);
+
- private EntityVersionCleanupFactory entityVersionCleanupFactory;
- private MvccLogEntrySerializationStrategy logEntrySerializationStrategy;
- private MvccEntitySerializationStrategy entitySerializationStrategy;
- private Set<EntityDeleted> listeners;
++ private final EntityVersionCleanupFactory entityVersionCleanupFactory;
++ private final MvccLogEntrySerializationStrategy logEntrySerializationStrategy;
++ private final MvccEntitySerializationStrategy entitySerializationStrategy;
++ private final Set<EntityDeleted> listeners;
+ private final CollectionScope collectionScope;
+ private final Id entityId;
+ private final UUID version;
+
+
+ @Inject
+ public EntityDeletedTask(
+ EntityVersionCleanupFactory entityVersionCleanupFactory,
+ final MvccLogEntrySerializationStrategy logEntrySerializationStrategy,
- final MvccEntitySerializationStrategy entitySerializationStrategy,
++ @ProxyImpl final MvccEntitySerializationStrategy entitySerializationStrategy,
+ final Set<EntityDeleted> listeners, // MUST be a set or Guice will not inject
+ @Assisted final CollectionScope collectionScope,
+ @Assisted final Id entityId,
+ @Assisted final UUID version) {
+
+ this.entityVersionCleanupFactory = entityVersionCleanupFactory;
+ this.logEntrySerializationStrategy = logEntrySerializationStrategy;
+ this.entitySerializationStrategy = entitySerializationStrategy;
+ this.listeners = listeners;
+ this.collectionScope = collectionScope;
+ this.entityId = entityId;
+ this.version = version;
+ }
+
+
+ @Override
+ public void exceptionThrown(Throwable throwable) {
+ LOG.error( "Unable to run update task for collection {} with entity {} and version {}",
+ new Object[] { collectionScope, entityId, version }, throwable );
+ }
+
+
+ @Override
+ public Void rejected() {
+ try {
+ call();
+ }
+ catch ( Exception e ) {
+ throw new RuntimeException( "Exception thrown in call task", e );
+ }
+
+ return null;
+ }
+
+
+ @Override
+ public Void call() throws Exception {
+
+ entityVersionCleanupFactory.getTask( collectionScope, entityId, version ).call();
+
+ fireEvents();
+ final MutationBatch entityDelete = entitySerializationStrategy.delete(collectionScope, entityId, version);
+ final MutationBatch logDelete = logEntrySerializationStrategy.delete(collectionScope, entityId, version);
+ entityDelete.execute();
+ logDelete.execute();
+
+ return null;
+ }
+
+
+ private void fireEvents() {
+ final int listenerSize = listeners.size();
+
+ if ( listenerSize == 0 ) {
+ return;
+ }
+
+ if ( listenerSize == 1 ) {
+ listeners.iterator().next().deleted( collectionScope, entityId,version );
+ return;
+ }
+
+ LOG.debug( "Started firing {} listeners", listenerSize );
+
+ //if we have more than 1, run them on the rx scheduler for a max of 8 operations at a time
+ Observable.from(listeners)
+ .parallel( new Func1<Observable<EntityDeleted>, Observable<EntityDeleted>>() {
+
+ @Override
+ public Observable<EntityDeleted> call(
+ final Observable<EntityDeleted> entityVersionDeletedObservable ) {
+
+ return entityVersionDeletedObservable.doOnNext( new Action1<EntityDeleted>() {
+ @Override
+ public void call( final EntityDeleted listener ) {
+ listener.deleted(collectionScope, entityId, version);
+ }
+ } );
+ }
+ }, Schedulers.io() ).toBlocking().last();
+
+ LOG.debug( "Finished firing {} listeners", listenerSize );
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c3261795/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/impl/EntityVersionCleanupTask.java
----------------------------------------------------------------------
diff --cc stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/impl/EntityVersionCleanupTask.java
index d4bf6e6,422a155..efecdeb
--- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/impl/EntityVersionCleanupTask.java
+++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/impl/EntityVersionCleanupTask.java
@@@ -45,7 -22,6 +45,8 @@@ import org.apache.usergrid.persistence.
import com.netflix.astyanax.Keyspace;
import com.netflix.astyanax.MutationBatch;
import com.netflix.astyanax.connectionpool.exceptions.ConnectionException;
+import java.util.Set;
++import org.apache.usergrid.persistence.core.guice.ProxyImpl;
import rx.Observable;
import rx.functions.Action1;
@@@ -75,17 -51,11 +76,17 @@@ public class EntityVersionCleanupTask i
private final UUID version;
- public EntityVersionCleanupTask( final SerializationFig serializationFig,
- final MvccLogEntrySerializationStrategy logEntrySerializationStrategy,
- final MvccEntitySerializationStrategy entitySerializationStrategy,
- final Keyspace keyspace, final List<EntityVersionDeleted> listeners,
- final CollectionScope scope, final Id entityId, final UUID version ) {
+ @Inject
+ public EntityVersionCleanupTask(
+ final SerializationFig serializationFig,
+ final MvccLogEntrySerializationStrategy logEntrySerializationStrategy,
- final MvccEntitySerializationStrategy entitySerializationStrategy,
++ @ProxyImpl final MvccEntitySerializationStrategy entitySerializationStrategy,
+ final UniqueValueSerializationStrategy uniqueValueSerializationStrategy,
+ final Keyspace keyspace,
+ final Set<EntityVersionDeleted> listeners, // MUST be a set or Guice will not inject
+ @Assisted final CollectionScope scope,
+ @Assisted final Id entityId,
+ @Assisted final UUID version ) {
this.serializationFig = serializationFig;
this.logEntrySerializationStrategy = logEntrySerializationStrategy;
@@@ -123,79 -93,66 +124,81 @@@
@Override
public Void call() throws Exception {
-
-
- final UUID maxVersion = version;
-
-
- Observable<MvccLogEntry> versions = Observable.create( new ObservableIterator( "versionIterators" ) {
- @Override
- protected Iterator getIterator() {
- return new LogEntryIterator( logEntrySerializationStrategy, scope, entityId, maxVersion,
- serializationFig.getBufferSize() );
- }
- } );
-
-
- //get the uuid from the version
- versions.map( new Func1<MvccLogEntry, UUID>() {
- @Override
- public UUID call( final MvccLogEntry mvccLogEntry ) {
- return mvccLogEntry.getVersion();
- }
- } )
- //buffer our versions
- .buffer( serializationFig.getBufferSize() )
- //for each buffer set, delete all of them
- .doOnNext( new Action1<List<UUID>>() {
- @Override
- public void call( final List<UUID> versions ) {
-
- //Fire all the listeners
- fireEvents( versions );
-
- MutationBatch entityBatch = keyspace.prepareMutationBatch();
- MutationBatch logBatch = keyspace.prepareMutationBatch();
-
- for ( UUID version : versions ) {
- final MutationBatch entityDelete = entitySerializationStrategy.delete( scope, entityId, version );
-
- entityBatch.mergeShallow( entityDelete );
-
- final MutationBatch logDelete = logEntrySerializationStrategy.delete( scope, entityId, version );
-
- logBatch.mergeShallow( logDelete );
+ //TODO Refactor this logic into a a class that can be invoked from anywhere
+ //load every entity we have history of
+ Observable<List<MvccEntity>> deleteFieldsObservable =
+ Observable.create(new ObservableIterator<MvccEntity>("deleteColumns") {
+ @Override
+ protected Iterator<MvccEntity> getIterator() {
- Iterator<MvccEntity> entities = entitySerializationStrategy
- .load(scope, entityId, version, serializationFig.getBufferSize());
++ Iterator<MvccEntity> entities = entitySerializationStrategy.loadDescendingHistory(
++ scope, entityId, version, 1000); // TODO: what fetchsize should we use here?
+ return entities;
}
- }) //buffer them for efficiency
++ })
++ //buffer them for efficiency
+ .skip(1)
+ .buffer(serializationFig.getBufferSize()).doOnNext(
+ new Action1<List<MvccEntity>>() {
+ @Override
+ public void call(final List<MvccEntity> mvccEntities) {
+ final MutationBatch batch = keyspace.prepareMutationBatch();
+ final MutationBatch entityBatch = keyspace.prepareMutationBatch();
+ final MutationBatch logBatch = keyspace.prepareMutationBatch();
+
+ for (MvccEntity mvccEntity : mvccEntities) {
+ if (!mvccEntity.getEntity().isPresent()) {
+ continue;
+ }
+
+ final UUID entityVersion = mvccEntity.getVersion();
+ final Entity entity = mvccEntity.getEntity().get();
+
+ //remove all unique fields from the index
+ for (final Field field : entity.getFields()) {
+ if (!field.isUnique()) {
+ continue;
+ }
+ final UniqueValue unique = new UniqueValueImpl( field, entityId, entityVersion);
- final MutationBatch deleteMutation = uniqueValueSerializationStrategy.delete(scope,unique);
++ final MutationBatch deleteMutation =
++ uniqueValueSerializationStrategy.delete(scope,unique);
+ batch.mergeShallow(deleteMutation);
+ }
+
+ final MutationBatch entityDelete = entitySerializationStrategy
+ .delete(scope, entityId, mvccEntity.getVersion());
+ entityBatch.mergeShallow(entityDelete);
+ final MutationBatch logDelete = logEntrySerializationStrategy
+ .delete(scope, entityId, version);
+ logBatch.mergeShallow(logDelete);
+ }
+
+ try {
+ batch.execute();
+ } catch (ConnectionException e1) {
+ throw new RuntimeException("Unable to execute " +
+ "unique value " +
+ "delete", e1);
+ }
+ fireEvents(mvccEntities);
+ try {
+ entityBatch.execute();
+ } catch (ConnectionException e) {
+ throw new RuntimeException("Unable to delete entities in cleanup", e);
+ }
+
+ try {
+ logBatch.execute();
+ } catch (ConnectionException e) {
+ throw new RuntimeException("Unable to delete entities from the log", e);
+ }
-
- try {
- entityBatch.execute();
- }
- catch ( ConnectionException e ) {
- throw new RuntimeException( "Unable to delete entities in cleanup", e );
- }
-
- try {
- logBatch.execute();
- }
- catch ( ConnectionException e ) {
- throw new RuntimeException( "Unable to delete entities from the log", e );
}
}
- } ).count().toBlocking().last();
+ );
+
+ final int removedCount = deleteFieldsObservable.count().toBlocking().last();
+
+ logger.debug("Removed unique values for {} entities of entity {}",removedCount,entityId);
return null;
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c3261795/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/delete/MarkCommit.java
----------------------------------------------------------------------
diff --cc stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/delete/MarkCommit.java
index 994465d,e31aba5..baf2ac3
--- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/delete/MarkCommit.java
+++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/delete/MarkCommit.java
@@@ -19,8 -19,8 +19,6 @@@
package org.apache.usergrid.persistence.collection.mvcc.stage.delete;
--import java.util.Iterator;
--import java.util.List;
import java.util.UUID;
import org.slf4j.Logger;
@@@ -36,13 -36,14 +34,9 @@@ import org.apache.usergrid.persistence.
import org.apache.usergrid.persistence.collection.mvcc.entity.impl.MvccLogEntryImpl;
import org.apache.usergrid.persistence.collection.mvcc.stage.CollectionIoEvent;
import org.apache.usergrid.persistence.collection.serialization.SerializationFig;
--import org.apache.usergrid.persistence.collection.serialization.UniqueValue;
import org.apache.usergrid.persistence.collection.serialization.UniqueValueSerializationStrategy;
--import org.apache.usergrid.persistence.collection.serialization.impl.UniqueValueImpl;
- import org.apache.usergrid.persistence.core.rx.ObservableIterator;
- import org.apache.usergrid.persistence.model.entity.Entity;
+ import org.apache.usergrid.persistence.core.guice.ProxyImpl;
-import org.apache.usergrid.persistence.core.rx.ObservableIterator;
-import org.apache.usergrid.persistence.model.entity.Entity;
import org.apache.usergrid.persistence.model.entity.Id;
--import org.apache.usergrid.persistence.model.field.Field;
import com.google.common.base.Preconditions;
import com.google.inject.Inject;
@@@ -51,7 -52,7 +45,6 @@@ import com.netflix.astyanax.Keyspace
import com.netflix.astyanax.MutationBatch;
import com.netflix.astyanax.connectionpool.exceptions.ConnectionException;
--import rx.Observable;
import rx.functions.Action1;
@@@ -119,72 -120,69 +112,70 @@@ public class MarkCommit implements Acti
catch ( ConnectionException e ) {
throw new RuntimeException( "Unable to mark entry as deleted" );
}
- //<<<<<<< HEAD
- //=======
-
-
- //TODO Refactor this logic into a a class that can be invoked from anywhere
- //load every entity we have history of
- Observable<List<MvccEntity>> deleteFieldsObservable =
- Observable.create( new ObservableIterator<MvccEntity>( "deleteColumns" ) {
- @Override
- protected Iterator<MvccEntity> getIterator() {
- Iterator<MvccEntity> entities =
- entityStrat.loadDescendingHistory( collectionScope, entityId, entity.getVersion(), 100 );
-
- return entities;
- }
- } ) //buffer them for efficiency
- .buffer( serializationFig.getBufferSize() ).doOnNext(
-
- new Action1<List<MvccEntity>>() {
- @Override
- public void call( final List<MvccEntity> mvccEntities ) {
-
-
- final MutationBatch batch = keyspace.prepareMutationBatch();
-
- for ( MvccEntity mvccEntity : mvccEntities ) {
- if ( !mvccEntity.getEntity().isPresent() ) {
- continue;
- }
-
- final UUID entityVersion = mvccEntity.getVersion();
-
- final Entity entity = mvccEntity.getEntity().get();
-
- //remove all unique fields from the index
- for ( final Field field : entity.getFields() ) {
-
- if(!field.isUnique()){
- continue;
- }
-
- final UniqueValue unique = new UniqueValueImpl( field, entityId, entityVersion );
-
- final MutationBatch deleteMutation = uniqueValueStrat.delete(collectionScope, unique );
-
- batch.mergeShallow( deleteMutation );
- }
- }
-
- try {
- batch.execute();
- }
- catch ( ConnectionException e1 ) {
- throw new RuntimeException( "Unable to execute " +
- "unique value " +
- "delete", e1 );
- }
- }
- }
-
-
- );
-
- final int removedCount = deleteFieldsObservable.count().toBlocking().last();
-
- LOG.debug("Removed unique values for {} entities of entity {}", removedCount, entityId );
+ }
+ }
++
+//
+//
+// //TODO Refactor this logic into a a class that can be invoked from anywhere
+// //load every entity we have history of
+// Observable<List<MvccEntity>> deleteFieldsObservable =
+// Observable.create( new ObservableIterator<MvccEntity>( "deleteColumns" ) {
+// @Override
+// protected Iterator<MvccEntity> getIterator() {
+// Iterator<MvccEntity> entities =
+// entityStrat.load( collectionScope, entityId, entity.getVersion(), 100 );
+//
+// return entities;
+// }
+// } ) //buffer them for efficiency
+// .buffer( serializationFig.getBufferSize() ).doOnNext(
+//
+// new Action1<List<MvccEntity>>() {
+// @Override
+// public void call( final List<MvccEntity> mvccEntities ) {
+//
+//
+// final MutationBatch batch = keyspace.prepareMutationBatch();
+//
+// for ( MvccEntity mvccEntity : mvccEntities ) {
+// if ( !mvccEntity.getEntity().isPresent() ) {
+// continue;
+// }
+//
+// final UUID entityVersion = mvccEntity.getVersion();
+//
+// final Entity entity = mvccEntity.getEntity().get();
+//
+// //remove all unique fields from the index
+// for ( final Field field : entity.getFields() ) {
+//
+// if(!field.isUnique()){
+// continue;
+// }
+//
+// final UniqueValue unique = new UniqueValueImpl( field, entityId, entityVersion );
+//
+// final MutationBatch deleteMutation = uniqueValueStrat.delete(collectionScope, unique );
+//
+// batch.mergeShallow( deleteMutation );
+// }
+// }
+//
+// try {
+// batch.execute();
+// }
+// catch ( ConnectionException e1 ) {
+// throw new RuntimeException( "Unable to execute " +
+// "unique value " +
+// "delete", e1 );
+// }
+// }
+// }
+//
+//
+// );
+//
+// final int removedCount = deleteFieldsObservable.count().toBlocking().last();
+//
+// LOG.debug("Removed unique values for {} entities of entity {}", removedCount, entityId );
- //>>>>>>> befcdcab6f7f1c83dbcb2a24eddb055c9297d59f
- }
- }
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c3261795/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/guice/TestCollectionModule.java
----------------------------------------------------------------------
diff --cc stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/guice/TestCollectionModule.java
index 73f1b6d,e2e6876..dd3c013
--- a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/guice/TestCollectionModule.java
+++ b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/guice/TestCollectionModule.java
@@@ -21,7 -21,12 +21,8 @@@ package org.apache.usergrid.persistence
import org.apache.usergrid.persistence.core.guice.CommonModule;
+ import org.apache.usergrid.persistence.core.guice.MaxMigrationModule;
-import org.apache.usergrid.persistence.core.guice.MaxMigrationVersion;
import org.apache.usergrid.persistence.core.guice.TestModule;
-import org.apache.usergrid.persistence.core.migration.data.DataMigration;
-
-import com.google.inject.multibindings.Multibinder;
public class TestCollectionModule extends TestModule {
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c3261795/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/impl/EntityVersionCleanupTaskTest.java
----------------------------------------------------------------------
diff --cc stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/impl/EntityVersionCleanupTaskTest.java
index eae1c54,1fce6e2..d0a87c3
--- a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/impl/EntityVersionCleanupTaskTest.java
+++ b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/impl/EntityVersionCleanupTaskTest.java
@@@ -139,31 -119,22 +139,32 @@@ public class EntityVersionCleanupTaskTe
final MutationBatch newBatch = mock( MutationBatch.class );
- //set up returning a mutator
- when( mvccEntitySerializationStrategy.delete( same( appScope ), same( entityId ), any( UUID.class ) ) )
+ // set up returning a mutator
+ when(ess.delete( same( appScope ), same( entityId ), any( UUID.class ) ) )
.thenReturn( newBatch );
-
- when( mvccLogEntrySerializationStrategy.delete( same( appScope ), same( entityId ), any( UUID.class ) ) )
+ when(less.delete( same( appScope ), same( entityId ), any( UUID.class ) ) )
.thenReturn( newBatch );
+ final List<MvccEntity> mel = new ArrayList<MvccEntity>();
- //start the task
- ListenableFuture<Void> future = taskExecutor.submit( cleanupTask );
+ mel.add( new MvccEntityImpl( entityId, UUIDGenerator.newTimeUUID(),
+ MvccEntity.Status.DELETED, Optional.fromNullable((Entity)null)) );
- //wait for the task
- future.get();
+ mel.add( new MvccEntityImpl( entityId, UUIDGenerator.newTimeUUID(),
+ MvccEntity.Status.DELETED, Optional.fromNullable((Entity)null)) );
- when( ess.load( same( appScope ), same( entityId ), any(UUID.class), any(Integer.class) ) )
- //verify it was run
++ when( ess.loadDescendingHistory(
++ same( appScope ), same( entityId ), any(UUID.class), any(Integer.class) ) )
+ .thenReturn(mel.iterator() );
+
+ try {
+ cleanupTask.call();
+ }catch(Exception e){
+ Assert.fail( e.getMessage() );
+ }
+
+ // verify it was run
verify( entityBatch ).execute();
verify( logBatch ).execute();
@@@ -239,38 -195,24 +240,38 @@@
//set up returning a mutator
- when( mvccEntitySerializationStrategy.delete( same( appScope ), same( entityId ), any( UUID.class ) ) )
+ when(ess.delete( same( appScope ), same( entityId ), any( UUID.class ) ) )
.thenReturn( batch );
-
- when( mvccLogEntrySerializationStrategy.delete( same( appScope ), same( entityId ), any( UUID.class ) ) )
+ when( mvccLogEntrySerializationStrategy
+ .delete( same( appScope ), same( entityId ), any( UUID.class ) ) )
.thenReturn( batch );
+ final List<MvccEntity> mel = new ArrayList<MvccEntity>();
- //start the task
- ListenableFuture<Void> future = taskExecutor.submit( cleanupTask );
+ mel.add( new MvccEntityImpl( entityId, UUIDGenerator.newTimeUUID(),
+ MvccEntity.Status.DELETED, Optional.fromNullable((Entity)null)) );
- //wait for the task
- future.get();
+ mel.add( new MvccEntityImpl( entityId, UUIDGenerator.newTimeUUID(),
+ MvccEntity.Status.DELETED, Optional.fromNullable((Entity)null)) );
- when( ess.load( same( appScope ), same( entityId ), any(UUID.class), any(Integer.class) ) )
- //verify it was run
- verify( entityBatch, never() ).execute();
++ when( ess.loadDescendingHistory( same( appScope ), same( entityId ), any(UUID.class), any(Integer.class) ) )
+ .thenReturn(mel.iterator() );
- verify( logBatch, never() ).execute();
+ //start the task
+ try {
+ cleanupTask.call();
+ }catch(Exception e){
+ Assert.fail( e.getMessage() );
+ }
+
+
+ // These last two verify statements do not make sense. We cannot assert that the entity
+ // and log batches are never called. Even if there are no listeners the entity delete
+ // cleanup task will still run to do the normal cleanup.
+ //
+ // verify( entityBatch, never() ).execute();
+ // verify( logBatch, never() ).execute();
}
@@@ -358,23 -283,11 +359,23 @@@
.thenReturn( batch );
- //start the task
- ListenableFuture<Void> future = taskExecutor.submit( cleanupTask );
+ final List<MvccEntity> mel = new ArrayList<MvccEntity>();
- //wait for the task
- future.get();
+ mel.add( new MvccEntityImpl( entityId, UUIDGenerator.newTimeUUID(),
+ MvccEntity.Status.DELETED, Optional.fromNullable((Entity)null)) );
+
+ mel.add( new MvccEntityImpl( entityId, UUIDGenerator.newTimeUUID(),
+ MvccEntity.Status.DELETED, Optional.fromNullable((Entity)null)) );
+
- when( ess.load( same( appScope ), same( entityId ), any(UUID.class), any(Integer.class) ) )
++ when( ess.loadDescendingHistory( same( appScope ), same( entityId ), any(UUID.class), any(Integer.class) ) )
+ .thenReturn(mel.iterator() );
+
+
+ try {
+ cleanupTask.call();
+ }catch(Exception e){
+ Assert.fail( e.getMessage() );
+ }
//we deleted the version
//verify it was run
@@@ -462,36 -366,27 +463,36 @@@
//set up returning a mutator
- when( mvccEntitySerializationStrategy.delete( same( appScope ), same( entityId ), any( UUID.class ) ) )
+ when( ess.delete( same( appScope ), same( entityId ), any( UUID.class ) ) )
.thenReturn( batch );
-
- when( mvccLogEntrySerializationStrategy.delete( same( appScope ), same( entityId ), any( UUID.class ) ) )
+ when( mvccLogEntrySerializationStrategy
+ .delete( same( appScope ), same( entityId ), any( UUID.class ) ) )
.thenReturn( batch );
+ final List<MvccEntity> mel = new ArrayList<MvccEntity>();
- //start the task
- ListenableFuture<Void> future = taskExecutor.submit( cleanupTask );
+ Entity entity = new Entity( entityId );
- //wait for the task
- future.get();
+ mel.add( new MvccEntityImpl( entityId, UUIDGenerator.newTimeUUID(),
+ MvccEntity.Status.DELETED, Optional.of(entity)) );
- //we deleted the version
- //verify we deleted everything
- verify( entityBatch, times( sizeToReturn ) ).mergeShallow( any( MutationBatch.class ) );
+ mel.add( new MvccEntityImpl( entityId, UUIDGenerator.newTimeUUID(),
+ MvccEntity.Status.DELETED, Optional.of(entity)) );
- when( ess.load( same( appScope ), same( entityId ), any(UUID.class), any(Integer.class) ) )
- verify( logBatch, times( sizeToReturn ) ).mergeShallow( any( MutationBatch.class ) );
++ when( ess.loadDescendingHistory( same( appScope ), same( entityId ), any(UUID.class), any(Integer.class) ) )
+ .thenReturn(mel.iterator() );
+ try {
+ cleanupTask.call();
+ }catch(Exception e){
+ Assert.fail( e.getMessage() );
+ }
+ //we deleted the version
+ //verify we deleted everything
+ verify( entityBatch, times( 1 ) ).mergeShallow( any( MutationBatch.class ) );
+ verify( logBatch, times( 1 ) ).mergeShallow( any( MutationBatch.class ) );
verify( logBatch ).execute();
@@@ -729,29 -608,41 +730,29 @@@
.thenReturn( batch );
- //start the task
- ListenableFuture<Void> future1 = taskExecutor.submit( firstTask );
-
- //now start another task while the slow running task is running
- ListenableFuture<Void> future2 = taskExecutor.submit( secondTask );
+ final List<MvccEntity> mel = new ArrayList<MvccEntity>();
- //get the second task, we shouldn't have been able to queue it, therefore it should just run in process
- future2.get();
+ mel.add( new MvccEntityImpl( entityId, UUIDGenerator.newTimeUUID(),
+ MvccEntity.Status.DELETED, Optional.fromNullable((Entity)null)) );
- /**
- * While we're not done, release latches every 200 ms
- */
- while ( !future1.isDone() ) {
- Thread.sleep( 200 );
- waitSemaphore.release( listenerCount );
- }
+ mel.add( new MvccEntityImpl( entityId, UUIDGenerator.newTimeUUID(),
+ MvccEntity.Status.DELETED, Optional.fromNullable((Entity)null)) );
- when( ess.load( same( appScope ), same( entityId ), any(UUID.class), any(Integer.class) ) )
- //wait for the task
- future1.get();
++ when( ess.loadDescendingHistory( same( appScope ), same( entityId ), any(UUID.class), any(Integer.class) ) )
+ .thenReturn(mel.iterator() );
- //we deleted the version
- //verify we deleted everything
+ try {
+ cleanupTask.rejected();
+ }catch(Exception e){
+ Assert.fail(e.getMessage());
+ }
//we deleted the version
- //verify we deleted everything
- verify( logBatch, times( sizeToReturn* 2 ) ).mergeShallow( any( MutationBatch.class ) );
-
- verify( entityBatch, times( sizeToReturn * 2) ).mergeShallow( any( MutationBatch.class ) );
-
-
- verify( logBatch, times(2) ).execute();
-
- verify( entityBatch, times(2) ).execute();
+ //verify it was run
+ verify( entityBatch ).execute();
+ verify( logBatch ).execute();
//the latch was executed
latch.await();
[50/50] [abbrv] incubator-usergrid git commit: Merge branch
'two-dot-o' into no-source-in-es
Posted by sn...@apache.org.
Merge branch 'two-dot-o' into no-source-in-es
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/c3fc1515
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/c3fc1515
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/c3fc1515
Branch: refs/heads/no-source-in-es
Commit: c3fc1515b603367950cac1f9f36fa2262caf395e
Parents: 79f19f8 6210092
Author: Dave Johnson <dm...@apigee.com>
Authored: Wed Dec 3 14:58:01 2014 -0500
Committer: Dave Johnson <dm...@apigee.com>
Committed: Wed Dec 3 14:58:01 2014 -0500
----------------------------------------------------------------------
stack/awscluster/gatling-cluster-cf.json | 387 +++++++++++++++++++
stack/awscluster/pom.xml | 2 +-
.../main/dist/init_instance/install_yourkit.sh | 6 +-
.../src/main/groovy/NodeRegistry.groovy | 197 +++++++---
.../main/groovy/configure_elasticsearch.groovy | 31 +-
.../src/main/groovy/registry_list.groovy | 36 --
stack/awscluster/ugcluster-cf.json | 7 +-
.../MvccEntitySerializationStrategyImpl.java | 2 +-
.../core/astyanax/BucketScopedRowKey.java | 3 +-
.../core/astyanax/CassandraConfig.java | 18 +
.../core/astyanax/ColumnNameIterator.java | 1 -
.../persistence/core/astyanax/ColumnSearch.java | 30 +-
.../persistence/core/astyanax/ColumnTypes.java | 19 +-
.../core/astyanax/FieldBufferBuilder.java | 1 -
.../astyanax/MultiKeyColumnNameIterator.java | 2 -
.../core/astyanax/MultiRowColumnIterator.java | 4 -
.../core/astyanax/MultiTennantColumnFamily.java | 1 -
.../persistence/core/astyanax/ScopedRowKey.java | 1 -
.../astyanax/StringRowCompositeSerializer.java | 35 +-
.../core/hystrix/HystrixCassandra.java | 3 -
.../core/migration/data/DataMigration.java | 31 +-
.../migration/data/DataMigrationException.java | 30 +-
.../migration/data/DataMigrationManager.java | 30 +-
.../data/DataMigrationManagerImpl.java | 3 -
.../data/MigrationInfoSerialization.java | 31 +-
.../data/MigrationInfoSerializationImpl.java | 31 +-
.../migration/schema/MigrationManagerFig.java | 18 +
.../migration/schema/MigrationManagerImpl.java | 18 +
.../core/shard/ExpandingShardLocator.java | 23 +-
.../persistence/core/shard/StringHashUtils.java | 22 +-
.../usergrid/persistence/core/task/Task.java | 19 +-
.../persistence/core/task/TaskExecutor.java | 18 +
.../persistence/model/field/LocationField.java | 8 +
stack/loadtests/README.md | 19 +
stack/loadtests/pom.xml | 4 +-
.../usergrid/scenarios/DeviceScenarios.scala | 2 +-
.../usergrid/scenarios/UserScenarios.scala | 54 ++-
.../org/apache/usergrid/settings/Settings.scala | 2 +-
.../simulations/PostUsersSimulation.scala | 49 +--
.../usergrid/simulations/SetupSimulation.scala | 4 +-
stack/loadtests/src/test/scala/Engine.scala | 4 +-
stack/pom.xml | 1 +
42 files changed, 865 insertions(+), 342 deletions(-)
----------------------------------------------------------------------
[43/50] [abbrv] incubator-usergrid git commit: Added build option for
additional debug information to make profiling easier
Posted by sn...@apache.org.
Added build option for additional debug information to make profiling easier
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/c2bc921d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/c2bc921d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/c2bc921d
Branch: refs/heads/two-dot-o-events
Commit: c2bc921db5e210285a35f569e7d003f404e7baae
Parents: 5429420
Author: Todd Nine <tn...@apigee.com>
Authored: Tue Dec 2 16:50:12 2014 -0700
Committer: Todd Nine <tn...@apigee.com>
Committed: Tue Dec 2 16:50:12 2014 -0700
----------------------------------------------------------------------
stack/pom.xml | 1 +
1 file changed, 1 insertion(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c2bc921d/stack/pom.xml
----------------------------------------------------------------------
diff --git a/stack/pom.xml b/stack/pom.xml
index 5a7bdd3..e02a08e 100644
--- a/stack/pom.xml
+++ b/stack/pom.xml
@@ -1518,6 +1518,7 @@
<optimize>true</optimize>
<showDeprecation>true</showDeprecation>
<debug>true</debug>
+ <!-- uncomment when building for more detailed profiling information <debuglevel>lines,vars,source</debuglevel> -->
<encoding>UTF-8</encoding>
<showWarnings>true</showWarnings>
</configuration>
[06/50] [abbrv] incubator-usergrid git commit: Added tests for when
we have to make multiple trips to Cassandra.
Posted by sn...@apache.org.
Added tests for when we have to make multiple trips to Cassandra.
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/56ce7ce6
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/56ce7ce6
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/56ce7ce6
Branch: refs/heads/two-dot-o-events
Commit: 56ce7ce6df21b08282aa484ead6c3a19397f0d14
Parents: 3e625b1
Author: Todd Nine <tn...@apigee.com>
Authored: Fri Nov 21 13:32:52 2014 -0700
Committer: Todd Nine <tn...@apigee.com>
Committed: Fri Nov 21 13:32:52 2014 -0700
----------------------------------------------------------------------
.../MvccEntitySerializationStrategyImpl.java | 132 ++++++++++++++-----
.../MvccEntitySerializationStrategyV1Impl.java | 6 +-
.../MvccEntitySerializationStrategyV2Impl.java | 5 +-
.../MvccEntitySerializationStrategyV2Test.java | 101 +++++++++++---
4 files changed, 188 insertions(+), 56 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/56ce7ce6/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyImpl.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyImpl.java
index f3f4c13..c9ec9a8 100644
--- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyImpl.java
+++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyImpl.java
@@ -42,9 +42,9 @@ import org.apache.usergrid.persistence.collection.mvcc.entity.impl.MvccEntityImp
import org.apache.usergrid.persistence.collection.serialization.EntityRepair;
import org.apache.usergrid.persistence.collection.serialization.SerializationFig;
import org.apache.usergrid.persistence.collection.util.EntityUtils;
+import org.apache.usergrid.persistence.core.astyanax.CassandraFig;
import org.apache.usergrid.persistence.core.astyanax.ColumnNameIterator;
import org.apache.usergrid.persistence.core.astyanax.ColumnParser;
-import org.apache.usergrid.persistence.core.astyanax.IdRowCompositeSerializer;
import org.apache.usergrid.persistence.core.astyanax.MultiTennantColumnFamily;
import org.apache.usergrid.persistence.core.astyanax.MultiTennantColumnFamilyDefinition;
import org.apache.usergrid.persistence.core.astyanax.ScopedRowKey;
@@ -61,9 +61,15 @@ import com.netflix.astyanax.connectionpool.exceptions.ConnectionException;
import com.netflix.astyanax.model.Column;
import com.netflix.astyanax.model.ColumnList;
import com.netflix.astyanax.model.Row;
+import com.netflix.astyanax.model.Rows;
import com.netflix.astyanax.query.RowQuery;
import com.netflix.astyanax.serializers.AbstractSerializer;
-import com.netflix.astyanax.serializers.UUIDSerializer;
+
+import rx.Observable;
+import rx.Scheduler;
+import rx.functions.Func1;
+import rx.functions.Func2;
+import rx.schedulers.Schedulers;
/**
@@ -76,14 +82,17 @@ public abstract class MvccEntitySerializationStrategyImpl implements MvccEntityS
protected final Keyspace keyspace;
protected final SerializationFig serializationFig;
+ protected final CassandraFig cassandraFig;
protected final EntityRepair repair;
private final MultiTennantColumnFamily<ScopedRowKey<CollectionPrefixedKey<Id>>, UUID> columnFamily;
@Inject
- public MvccEntitySerializationStrategyImpl( final Keyspace keyspace, final SerializationFig serializationFig ) {
+ public MvccEntitySerializationStrategyImpl( final Keyspace keyspace, final SerializationFig serializationFig,
+ final CassandraFig cassandraFig ) {
this.keyspace = keyspace;
this.serializationFig = serializationFig;
+ this.cassandraFig = cassandraFig;
this.repair = new EntityRepairImpl( this, serializationFig );
this.columnFamily = getColumnFamily();
}
@@ -100,17 +109,8 @@ public abstract class MvccEntitySerializationStrategyImpl implements MvccEntityS
return doWrite( collectionScope, entityId, new RowOp() {
@Override
public void doOp( final ColumnListMutation<UUID> colMutation ) {
-// try {
colMutation.putColumn( colName, getEntitySerializer()
.toByteBuffer( new EntityWrapper( entity.getStatus(), entity.getEntity() ) ) );
-// }
-// catch ( Exception e ) {
-// // throw better exception if we can
-// if ( entity != null || entity.getEntity().get() != null ) {
-// throw new CollectionRuntimeException( entity, collectionScope, e );
-// }
-// throw e;
-// }
}
} );
}
@@ -152,46 +152,110 @@ public abstract class MvccEntitySerializationStrategyImpl implements MvccEntityS
rowKeys.add( rowKey );
}
+ /**
+ * Our settings may mean we exceed our maximum thrift buffer size. If we do, we have to make multiple requests, not just one.
+ * Perform the calculations and the appropriate request patterns
+ *
+ */
+
+ final int maxEntityResultSizeInBytes = serializationFig.getMaxEntitySize() * entityIds.size();
- final Iterator<Row<ScopedRowKey<CollectionPrefixedKey<Id>>, UUID>> latestEntityColumns;
+ //if we're less than 1, set the number of requests to 1
+ final int numberRequests = Math.max(1, maxEntityResultSizeInBytes / cassandraFig.getThriftBufferSize());
+ final int entitiesPerRequest = entityIds.size() / numberRequests;
- try {
- latestEntityColumns = keyspace.prepareQuery( columnFamily ).getKeySlice( rowKeys )
- .withColumnRange( maxVersion, null, false, 1 ).execute().getResult()
- .iterator();
+
+ final Scheduler scheduler;
+
+ //if it's a single request, run it on the same thread
+ if(numberRequests == 1){
+ scheduler = Schedulers.immediate();
}
- catch ( ConnectionException e ) {
- throw new CollectionRuntimeException( null, collectionScope, "An error occurred connecting to cassandra",
- e );
+ //if it's more than 1 request, run them on the I/O scheduler
+ else{
+ scheduler = Schedulers.io();
}
- final EntitySetImpl entitySetResults = new EntitySetImpl( entityIds.size() );
+ final EntitySetImpl entitySetResults = Observable.from( rowKeys )
+ //buffer our entities per request, then for that buffer, execute the query in parallel (if neccessary)
+ .buffer(entitiesPerRequest )
+ .parallel( new Func1<Observable<List<ScopedRowKey
+ <CollectionPrefixedKey<Id>>>>, Observable<Rows<ScopedRowKey<CollectionPrefixedKey<Id>>, UUID>>>() {
+
+
+ @Override
+ public Observable<Rows<ScopedRowKey<CollectionPrefixedKey<Id>>, UUID>> call(
+ final Observable<List<ScopedRowKey<CollectionPrefixedKey<Id>>>> listObservable ) {
+
+
+ //here, we execute our query then emit the items either in parallel, or on the current thread if we have more than 1 request
+ return listObservable.map( new Func1<List<ScopedRowKey<CollectionPrefixedKey<Id>>>,
+ Rows<ScopedRowKey<CollectionPrefixedKey<Id>>, UUID>>() {
+
+
+ @Override
+ public Rows<ScopedRowKey<CollectionPrefixedKey<Id>>, UUID> call(
+ final List<ScopedRowKey<CollectionPrefixedKey<Id>>> scopedRowKeys ) {
+
+ try {
+ return keyspace.prepareQuery( columnFamily ).getKeySlice( rowKeys )
+ .withColumnRange( maxVersion, null, false,
+ 1 ).execute().getResult();
+ }
+ catch ( ConnectionException e ) {
+ throw new CollectionRuntimeException( null, collectionScope, "An error occurred connecting to cassandra",
+ e );
+ }
+ }
+ } );
- while ( latestEntityColumns.hasNext() ) {
- final Row<ScopedRowKey<CollectionPrefixedKey<Id>>, UUID> row = latestEntityColumns.next();
- final ColumnList<UUID> columns = row.getColumns();
- if ( columns.size() == 0 ) {
- continue;
}
+ }, scheduler )
- final Id entityId = row.getKey().getKey().getSubKey();
+ //reduce all the output into a single Entity set
+ .reduce( new EntitySetImpl( entityIds.size() ),
+ new Func2<EntitySetImpl, Rows<ScopedRowKey<CollectionPrefixedKey<Id>>, UUID>, EntitySetImpl>() {
+ @Override
+ public EntitySetImpl call( final EntitySetImpl entitySet,
+ final Rows<ScopedRowKey<CollectionPrefixedKey<Id>>, UUID> rows ) {
- final Column<UUID> column = columns.getColumnByIndex( 0 );
+ final Iterator<Row<ScopedRowKey<CollectionPrefixedKey<Id>>, UUID>> latestEntityColumns = rows.iterator();
- final MvccEntity parsedEntity =
- new MvccColumnParser( entityId, getEntitySerializer() ).parseColumn( column );
+ while ( latestEntityColumns.hasNext() ) {
+ final Row<ScopedRowKey<CollectionPrefixedKey<Id>>, UUID> row = latestEntityColumns.next();
- //we *might* need to repair, it's not clear so check before loading into result sets
- final MvccEntity maybeRepaired = repair.maybeRepair( collectionScope, parsedEntity );
+ final ColumnList<UUID> columns = row.getColumns();
- entitySetResults.addEntity( maybeRepaired );
- }
+ if ( columns.size() == 0 ) {
+ continue;
+ }
+
+ final Id entityId = row.getKey().getKey().getSubKey();
+
+ final Column<UUID> column = columns.getColumnByIndex( 0 );
+
+ final MvccEntity parsedEntity =
+ new MvccColumnParser( entityId, getEntitySerializer() ).parseColumn( column );
+
+ //we *might* need to repair, it's not clear so check before loading into result sets
+ final MvccEntity maybeRepaired = repair.maybeRepair( collectionScope, parsedEntity );
+
+ entitySet.addEntity( maybeRepaired );
+ }
+
+
+
+ return entitySet;
+ }
+ } ).toBlocking().last();
return entitySetResults;
+
+
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/56ce7ce6/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyV1Impl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyV1Impl.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyV1Impl.java
index b40243d..119fb6d 100644
--- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyV1Impl.java
+++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyV1Impl.java
@@ -26,6 +26,8 @@ import java.util.UUID;
import org.apache.usergrid.persistence.collection.MvccEntity;
import org.apache.usergrid.persistence.collection.exception.DataCorruptionException;
import org.apache.usergrid.persistence.collection.serialization.SerializationFig;
+import org.apache.usergrid.persistence.core.astyanax.CassandraConfig;
+import org.apache.usergrid.persistence.core.astyanax.CassandraFig;
import org.apache.usergrid.persistence.core.astyanax.IdRowCompositeSerializer;
import org.apache.usergrid.persistence.core.astyanax.MultiTennantColumnFamily;
import org.apache.usergrid.persistence.core.astyanax.ScopedRowKey;
@@ -69,8 +71,8 @@ public class MvccEntitySerializationStrategyV1Impl extends MvccEntitySerializati
@Inject
- public MvccEntitySerializationStrategyV1Impl( final Keyspace keyspace, final SerializationFig serializationFig ) {
- super( keyspace, serializationFig );
+ public MvccEntitySerializationStrategyV1Impl( final Keyspace keyspace, final SerializationFig serializationFig, final CassandraFig cassandraFig ) {
+ super( keyspace, serializationFig, cassandraFig );
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/56ce7ce6/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyV2Impl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyV2Impl.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyV2Impl.java
index 923c399..cd46c1e 100644
--- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyV2Impl.java
+++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyV2Impl.java
@@ -27,6 +27,7 @@ import org.apache.usergrid.persistence.collection.MvccEntity;
import org.apache.usergrid.persistence.collection.exception.DataCorruptionException;
import org.apache.usergrid.persistence.collection.exception.EntityTooLargeException;
import org.apache.usergrid.persistence.collection.serialization.SerializationFig;
+import org.apache.usergrid.persistence.core.astyanax.CassandraFig;
import org.apache.usergrid.persistence.core.astyanax.FieldBuffer;
import org.apache.usergrid.persistence.core.astyanax.FieldBufferBuilder;
import org.apache.usergrid.persistence.core.astyanax.FieldBufferParser;
@@ -72,8 +73,8 @@ public class MvccEntitySerializationStrategyV2Impl extends MvccEntitySerializati
@Inject
- public MvccEntitySerializationStrategyV2Impl( final Keyspace keyspace, final SerializationFig serializationFig ) {
- super( keyspace, serializationFig );
+ public MvccEntitySerializationStrategyV2Impl( final Keyspace keyspace, final SerializationFig serializationFig, final CassandraFig cassandraFig ) {
+ super( keyspace, serializationFig, cassandraFig );
entitySerializer = new EntitySerializer( serializationFig );
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/56ce7ce6/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyV2Test.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyV2Test.java b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyV2Test.java
index a496519..5f633a1 100644
--- a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyV2Test.java
+++ b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyV2Test.java
@@ -20,25 +20,25 @@
package org.apache.usergrid.persistence.collection.serialization.impl;
-import java.lang.annotation.Annotation;
import java.util.Collections;
+import java.util.HashMap;
import java.util.Iterator;
+import java.util.Map;
import java.util.UUID;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
-import org.safehaus.guicyfig.Bypass;
-import org.safehaus.guicyfig.Env;
-import org.safehaus.guicyfig.Option;
import org.apache.usergrid.persistence.collection.CollectionScope;
+import org.apache.usergrid.persistence.collection.EntitySet;
import org.apache.usergrid.persistence.collection.MvccEntity;
import org.apache.usergrid.persistence.collection.exception.EntityTooLargeException;
import org.apache.usergrid.persistence.collection.impl.CollectionScopeImpl;
import org.apache.usergrid.persistence.collection.mvcc.entity.impl.MvccEntityImpl;
import org.apache.usergrid.persistence.collection.serialization.SerializationFig;
import org.apache.usergrid.persistence.collection.util.EntityHelper;
+import org.apache.usergrid.persistence.core.astyanax.CassandraFig;
import org.apache.usergrid.persistence.core.guicyfig.SetConfigTestBypass;
import org.apache.usergrid.persistence.core.util.ValidationUtils;
import org.apache.usergrid.persistence.model.entity.Entity;
@@ -49,6 +49,7 @@ import org.apache.usergrid.persistence.model.util.UUIDGenerator;
import com.google.inject.Inject;
import com.netflix.astyanax.connectionpool.exceptions.ConnectionException;
+import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
@@ -58,21 +59,27 @@ public abstract class MvccEntitySerializationStrategyV2Test extends MvccEntitySe
@Inject
protected SerializationFig serializationFig;
+ @Inject
+ protected CassandraFig cassandraFig;
+
+
private int setMaxEntitySize;
@Before
- public void setUp(){
+ public void setUp() {
- setMaxEntitySize = serializationFig.getMaxEntitySize();
+ setMaxEntitySize = serializationFig.getMaxEntitySize();
}
+
@After
- public void tearDown(){
+ public void tearDown() {
SetConfigTestBypass.setValueByPass( serializationFig, "getMaxEntitySize", setMaxEntitySize + "" );
}
+
/**
* Tests an entity with more than 65535 bytes worth of data is successfully stored and retrieved
*/
@@ -83,7 +90,7 @@ public abstract class MvccEntitySerializationStrategyV2Test extends MvccEntitySe
//this is the size it works out to be when serialized, we want to allow this size
- SetConfigTestBypass.setValueByPass( serializationFig, "getMaxEntitySize", 65535*10+"");
+ SetConfigTestBypass.setValueByPass( serializationFig, "getMaxEntitySize", 65535 * 10 + "" );
final Entity entity = EntityHelper.generateEntity( setSize );
//now we have one massive, entity, save it and retrieve it.
@@ -106,7 +113,12 @@ public abstract class MvccEntitySerializationStrategyV2Test extends MvccEntitySe
getMvccEntitySerializationStrategy().loadDescendingHistory( context, id, version, 100 );
- assertLargeEntity( mvccEntity, loaded );
+ assertTrue( loaded.hasNext() );
+
+ final MvccEntity loadedEntity = loaded.next();
+
+ assertLargeEntity( mvccEntity, loadedEntity );
+
MvccEntity returned =
serializationStrategy.load( context, Collections.singleton( id ), version ).getEntity( id );
@@ -115,7 +127,6 @@ public abstract class MvccEntitySerializationStrategyV2Test extends MvccEntitySe
}
-
/**
* Tests an entity with more than 65535 bytes worth of data is successfully stored and retrieved
*/
@@ -142,23 +153,77 @@ public abstract class MvccEntitySerializationStrategyV2Test extends MvccEntitySe
}
- protected void assertLargeEntity( final MvccEntity expected, final Iterator<MvccEntity> returned ) {
- assertTrue( returned.hasNext() );
+ /**
+ * Tests an entity with more than 65535 bytes worth of data is successfully stored and retrieved
+ */
+ @Test
+ public void largeEntityReadWrite() throws ConnectionException {
+
+ //this is the size it works out to be when serialized, we want to allow this size
+
+ //extreme edge case, we can only get 2 entities per call
+ final int thriftBuffer = cassandraFig.getThriftBufferSize();
- final MvccEntity loadedEntity = returned.next();
- assertLargeEntity( expected, loadedEntity );
- }
+ //we use 20, using 2 causes cassandra to OOM. We don't have a large enough instance running locally
- protected void assertLargeEntity( final MvccEntity expected, final MvccEntity returned ) {
+ final int maxEntitySize = ( int ) ( ( thriftBuffer * .9 ) / 20 );
- org.junit.Assert.assertEquals( "The loaded entity should match the stored entity", expected, returned );
- EntityHelper.verifyDeepEquals( expected.getEntity().get(), returned.getEntity().get() );
+ SetConfigTestBypass.setValueByPass( serializationFig, "getMaxEntitySize", maxEntitySize + "" );
+
+
+ final int size = 100;
+
+ final HashMap<Id, MvccEntity> entities = new HashMap<>( size );
+
+ CollectionScope context =
+ new CollectionScopeImpl( new SimpleId( "organization" ), new SimpleId( "parent" ), "tests" );
+
+
+ for ( int i = 0; i < size; i++ ) {
+ final Entity entity = EntityHelper.generateEntity( ( int ) (maxEntitySize*.4) );
+
+ //now we have one massive, entity, save it and retrieve it.
+
+ final Id id = entity.getId();
+ ValidationUtils.verifyIdentity( id );
+ final UUID version = UUIDGenerator.newTimeUUID();
+ final MvccEntity.Status status = MvccEntity.Status.COMPLETE;
+
+ final MvccEntity mvccEntity = new MvccEntityImpl( id, version, status, entity );
+
+
+ getMvccEntitySerializationStrategy().write( context, mvccEntity ).execute();
+
+ entities.put( id, mvccEntity );
+ }
+
+
+ //now load it, we ask for 100 and we only are allowed 2 per trip due to our max size constraints. Should all
+ //still load (note that users should not be encouraged to use this strategy, it's a bad idea!)
+ final EntitySet loaded =
+ getMvccEntitySerializationStrategy().load( context, entities.keySet(), UUIDGenerator.newTimeUUID() );
+
+ assertNotNull( "Entity set was loaded", loaded );
+
+
+ for ( Map.Entry<Id, MvccEntity> entry : entities.entrySet() ) {
+
+ final MvccEntity returned = loaded.getEntity( entry.getKey() );
+
+ assertLargeEntity( entry.getValue(), returned );
+ }
}
+ protected void assertLargeEntity( final MvccEntity expected, final MvccEntity returned ) {
+
+ org.junit.Assert.assertEquals( "The loaded entity should match the stored entity", expected, returned );
+
+ EntityHelper.verifyDeepEquals( expected.getEntity().get(), returned.getEntity().get() );
+ }
}
[14/50] [abbrv] incubator-usergrid git commit: Merge remote-tracking
branch 'github/pr/105' into two-dot-o
Posted by sn...@apache.org.
Merge remote-tracking branch 'github/pr/105' into two-dot-o
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/2586e9fe
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/2586e9fe
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/2586e9fe
Branch: refs/heads/two-dot-o-events
Commit: 2586e9fe458b55ebe16b9e080c38a8809ba25f9b
Parents: bd0a1e9 0857947
Author: Shawn Feldman <sf...@apache.org>
Authored: Mon Nov 24 09:08:35 2014 -0700
Committer: Shawn Feldman <sf...@apache.org>
Committed: Mon Nov 24 09:08:35 2014 -0700
----------------------------------------------------------------------
.../org/apache/usergrid/CoreApplication.java | 17 +++-
.../migration/EntityDataMigrationIT.java | 16 +--
.../migration/EntityTypeMappingMigrationIT.java | 17 ++++
.../migration/GraphShardVersionMigrationIT.java | 20 ++--
.../migration/MigrationTestRule.java | 101 +++++++++++++++++++
5 files changed, 155 insertions(+), 16 deletions(-)
----------------------------------------------------------------------
[02/50] [abbrv] incubator-usergrid git commit: Refactored generation
of collection scope to be re-usable with CpNamingUtils for consistency across
modules
Posted by sn...@apache.org.
Refactored generation of collection scope to be re-usable with CpNamingUtils for consistency across modules
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/364a6ea6
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/364a6ea6
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/364a6ea6
Branch: refs/heads/two-dot-o-events
Commit: 364a6ea6737194a1dd266b6d0e89abb4a40ddf96
Parents: 9ed7964
Author: Todd Nine <tn...@apigee.com>
Authored: Thu Nov 20 14:24:03 2014 -0700
Committer: Todd Nine <tn...@apigee.com>
Committed: Thu Nov 20 14:24:03 2014 -0700
----------------------------------------------------------------------
.../corepersistence/CpEntityManager.java | 44 ++++++--------------
.../corepersistence/CpEntityManagerFactory.java | 2 +-
.../corepersistence/CpRelationManager.java | 35 ++++------------
.../corepersistence/util/CpNamingUtils.java | 19 +++++++++
4 files changed, 41 insertions(+), 59 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/364a6ea6/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
index e2f67e8..e6b8bce 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
@@ -131,6 +131,7 @@ import static me.prettyprint.hector.api.factory.HFactory.createCounterSliceQuery
import static me.prettyprint.hector.api.factory.HFactory.createMutator;
import static org.apache.commons.lang.StringUtils.capitalize;
import static org.apache.commons.lang.StringUtils.isBlank;
+import static org.apache.usergrid.corepersistence.util.CpNamingUtils.getCollectionScopeNameFromEntityType;
import static org.apache.usergrid.persistence.Schema.COLLECTION_ROLES;
import static org.apache.usergrid.persistence.Schema.COLLECTION_USERS;
import static org.apache.usergrid.persistence.Schema.DICTIONARY_PERMISSIONS;
@@ -372,13 +373,9 @@ public class CpEntityManager implements EntityManager {
}
Id id = new SimpleId( entityRef.getUuid(), entityRef.getType() );
- String collectionName = CpNamingUtils.getCollectionScopeNameFromEntityType( entityRef.getType() );
- CollectionScope collectionScope =
- new CollectionScopeImpl( getApplicationScope().getApplication(), getApplicationScope().getApplication(),
- collectionName );
+ CollectionScope collectionScope = getCollectionScopeNameFromEntityType(applicationScope.getApplication(), entityRef.getType());
- EntityCollectionManager ecm = managerCache.getEntityCollectionManager( collectionScope );
// if ( !UUIDUtils.isTimeBased( id.getUuid() ) ) {
// throw new IllegalArgumentException(
@@ -457,13 +454,10 @@ public class CpEntityManager implements EntityManager {
String type = Schema.getDefaultSchema().getEntityType( entityClass );
Id id = new SimpleId( entityId, type );
- String collectionName = CpNamingUtils.getCollectionScopeNameFromEntityType( type );
- CollectionScope collectionScope =
- new CollectionScopeImpl( getApplicationScope().getApplication(), getApplicationScope().getApplication(),
- collectionName );
- EntityCollectionManager ecm = managerCache.getEntityCollectionManager( collectionScope );
+ CollectionScope collectionScope = getCollectionScopeNameFromEntityType(applicationScope.getApplication(), type);
+
// if ( !UUIDUtils.isTimeBased( id.getUuid() ) ) {
// throw new IllegalArgumentException(
@@ -522,9 +516,8 @@ public class CpEntityManager implements EntityManager {
public void update( Entity entity ) throws Exception {
// first, update entity index in its own collection scope
- CollectionScope collectionScope =
- new CollectionScopeImpl( getApplicationScope().getApplication(), getApplicationScope().getApplication(),
- CpNamingUtils.getCollectionScopeNameFromEntityType( entity.getType() ) );
+
+ CollectionScope collectionScope = getCollectionScopeNameFromEntityType(applicationScope.getApplication(), entity.getType());
EntityCollectionManager ecm = managerCache.getEntityCollectionManager( collectionScope );
Id entityId = new SimpleId( entity.getUuid(), entity.getType() );
@@ -590,9 +583,7 @@ public class CpEntityManager implements EntityManager {
private Observable deleteAsync( EntityRef entityRef ) throws Exception {
- CollectionScope collectionScope =
- new CollectionScopeImpl( getApplicationScope().getApplication(), getApplicationScope().getApplication(),
- CpNamingUtils.getCollectionScopeNameFromEntityType( entityRef.getType() ) );
+ CollectionScope collectionScope =getCollectionScopeNameFromEntityType(applicationScope.getApplication(), entityRef.getType() );
EntityCollectionManager ecm = managerCache.getEntityCollectionManager( collectionScope );
@@ -639,7 +630,7 @@ public class CpEntityManager implements EntityManager {
// deindex from default index scope
IndexScope defaultIndexScope = new IndexScopeImpl( getApplicationScope().getApplication(),
- CpNamingUtils.getCollectionScopeNameFromEntityType( entityRef.getType() ) );
+ getCollectionScopeNameFromEntityType( entityRef.getType() ) );
batch.deindex( defaultIndexScope, entity );
@@ -1010,15 +1001,10 @@ public class CpEntityManager implements EntityManager {
@Override
public void deleteProperty( EntityRef entityRef, String propertyName ) throws Exception {
-
- String collectionName = CpNamingUtils.getCollectionScopeNameFromEntityType( entityRef.getType() );
-
- CollectionScope collectionScope =
- new CollectionScopeImpl( getApplicationScope().getApplication(), getApplicationScope().getApplication(),
- collectionName );
+ CollectionScope collectionScope = getCollectionScopeNameFromEntityType(getApplicationScope().getApplication(), entityRef.getType());
IndexScope defaultIndexScope = new IndexScopeImpl( getApplicationScope().getApplication(),
- CpNamingUtils.getCollectionScopeNameFromEntityType( entityRef.getType() ) );
+ getCollectionScopeNameFromEntityType( entityRef.getType() ) );
EntityCollectionManager ecm = managerCache.getEntityCollectionManager( collectionScope );
EntityIndex ei = managerCache.getEntityIndex( getApplicationScope() );
@@ -2187,10 +2173,7 @@ public class CpEntityManager implements EntityManager {
private Id getIdForUniqueEntityField( final String collectionName, final String propertyName,
final Object propertyValue ) {
- CollectionScope collectionScope =
- new CollectionScopeImpl( applicationScope.getApplication(), applicationScope.getApplication(),
- CpNamingUtils.getCollectionScopeNameFromEntityType( collectionName ) );
-
+ CollectionScope collectionScope = getCollectionScopeNameFromEntityType(applicationScope.getApplication(), collectionName);
final EntityCollectionManager ecm = managerCache.getEntityCollectionManager( collectionScope );
@@ -2514,9 +2497,8 @@ public class CpEntityManager implements EntityManager {
org.apache.usergrid.persistence.model.entity.Entity cpEntity = entityToCpEntity( entity, importId );
// prepare to write and index Core Persistence Entity into default scope
- CollectionScope collectionScope =
- new CollectionScopeImpl( applicationScope.getApplication(), applicationScope.getApplication(),
- CpNamingUtils.getCollectionScopeNameFromEntityType( eType ) );
+ CollectionScope collectionScope = getCollectionScopeNameFromEntityType(applicationScope.getApplication(), eType);
+
EntityCollectionManager ecm = managerCache.getEntityCollectionManager( collectionScope );
if ( logger.isDebugEnabled() ) {
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/364a6ea6/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManagerFactory.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManagerFactory.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManagerFactory.java
index e07bb00..82e80a5 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManagerFactory.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManagerFactory.java
@@ -541,7 +541,7 @@ public class CpEntityManagerFactory implements EntityManagerFactory, Application
public long performEntityCount() {
//TODO, this really needs to be a task that writes this data somewhere since this will get
//progressively slower as the system expands
- return AllEntitiesInSystemObservable.getAllEntitiesInSystem( managerCache ).longCount().toBlocking().last();
+ return AllEntitiesInSystemObservable.getAllEntitiesInSystem( managerCache, 1000 ).longCount().toBlocking().last();
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/364a6ea6/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java
index 8514504..dcb4ba1 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java
@@ -120,6 +120,7 @@ import rx.functions.Func1;
import static java.util.Arrays.asList;
import static me.prettyprint.hector.api.factory.HFactory.createMutator;
+import static org.apache.usergrid.corepersistence.util.CpNamingUtils.getCollectionScopeNameFromEntityType;
import static org.apache.usergrid.persistence.Schema.COLLECTION_ROLES;
import static org.apache.usergrid.persistence.Schema.DICTIONARY_CONNECTED_ENTITIES;
import static org.apache.usergrid.persistence.Schema.DICTIONARY_CONNECTED_TYPES;
@@ -219,10 +220,7 @@ public class CpRelationManager implements RelationManager {
this.indexBucketLocator = indexBucketLocator; // TODO: this also
// load the Core Persistence version of the head entity as well
- this.headEntityScope = new CollectionScopeImpl(
- this.applicationScope.getApplication(),
- this.applicationScope.getApplication(),
- CpNamingUtils.getCollectionScopeNameFromEntityType( headEntity.getType() ) );
+ this.headEntityScope = getCollectionScopeNameFromEntityType(applicationScope.getApplication(), headEntity.getType());
if ( logger.isDebugEnabled() ) {
logger.debug( "Loading head entity {}:{} from scope\n app {}\n owner {}\n name {}",
@@ -606,10 +604,7 @@ public class CpRelationManager implements RelationManager {
public Entity addToCollection( String collName, EntityRef itemRef, boolean connectBack )
throws Exception {
- CollectionScope memberScope = new CollectionScopeImpl(
- applicationScope.getApplication(),
- applicationScope.getApplication(),
- CpNamingUtils.getCollectionScopeNameFromEntityType( itemRef.getType() ) );
+ CollectionScope memberScope = getCollectionScopeNameFromEntityType(applicationScope.getApplication(), itemRef.getType());
Id entityId = new SimpleId( itemRef.getUuid(), itemRef.getType() );
org.apache.usergrid.persistence.model.entity.Entity memberEntity =
@@ -642,10 +637,7 @@ public class CpRelationManager implements RelationManager {
}
// load the new member entity to be added to the collection from its default scope
- CollectionScope memberScope = new CollectionScopeImpl(
- applicationScope.getApplication(),
- applicationScope.getApplication(),
- CpNamingUtils.getCollectionScopeNameFromEntityType( itemRef.getType() ) );
+ CollectionScope memberScope = getCollectionScopeNameFromEntityType(applicationScope.getApplication(), itemRef.getType());
//TODO, this double load should disappear once events are in
Id entityId = new SimpleId( itemRef.getUuid(), itemRef.getType() );
@@ -797,11 +789,7 @@ public class CpRelationManager implements RelationManager {
}
// load the entity to be removed to the collection
- CollectionScope memberScope = new CollectionScopeImpl(
- this.applicationScope.getApplication(),
- this.applicationScope.getApplication(),
- CpNamingUtils.getCollectionScopeNameFromEntityType( itemRef.getType() ) );
- EntityCollectionManager memberMgr = managerCache.getEntityCollectionManager( memberScope );
+ CollectionScope memberScope = getCollectionScopeNameFromEntityType(applicationScope.getApplication(), itemRef.getType());
if ( logger.isDebugEnabled() ) {
logger.debug( "Loading entity to remove from collection "
@@ -1017,10 +1005,7 @@ public class CpRelationManager implements RelationManager {
ConnectionRefImpl connection = new ConnectionRefImpl( headEntity, connectionType, connectedEntityRef );
- CollectionScope targetScope = new CollectionScopeImpl(
- applicationScope.getApplication(),
- applicationScope.getApplication(),
- CpNamingUtils.getCollectionScopeNameFromEntityType( connectedEntityRef.getType() ) );
+ CollectionScope targetScope = getCollectionScopeNameFromEntityType(applicationScope.getApplication(), connectedEntityRef.getType());
if ( logger.isDebugEnabled() ) {
logger.debug("createConnection(): "
@@ -1249,12 +1234,8 @@ public class CpRelationManager implements RelationManager {
String connectionType = connectionRef.getConnectedEntity().getConnectionType();
- CollectionScope targetScope = new CollectionScopeImpl(
- applicationScope.getApplication(),
- applicationScope.getApplication(),
- CpNamingUtils.getCollectionScopeNameFromEntityType( connectedEntityRef.getType()) );
-
- EntityCollectionManager targetEcm = managerCache.getEntityCollectionManager( targetScope );
+ CollectionScope targetScope = getCollectionScopeNameFromEntityType( applicationScope.getApplication(),
+ connectedEntityRef.getType() );
if ( logger.isDebugEnabled() ) {
logger.debug( "Deleting connection '{}' from source {}:{} \n to target {}:{}",
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/364a6ea6/stack/core/src/main/java/org/apache/usergrid/corepersistence/util/CpNamingUtils.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/util/CpNamingUtils.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/util/CpNamingUtils.java
index 6fb35a3..684b6e0 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/util/CpNamingUtils.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/util/CpNamingUtils.java
@@ -22,6 +22,8 @@ package org.apache.usergrid.corepersistence.util;
import java.util.UUID;
import org.apache.usergrid.persistence.Schema;
+import org.apache.usergrid.persistence.collection.CollectionScope;
+import org.apache.usergrid.persistence.collection.impl.CollectionScopeImpl;
import org.apache.usergrid.persistence.core.scope.ApplicationScope;
import org.apache.usergrid.persistence.core.scope.ApplicationScopeImpl;
import org.apache.usergrid.persistence.entities.Application;
@@ -70,6 +72,23 @@ public class CpNamingUtils {
public static String TYPES_BY_UUID_MAP = "zzz_typesbyuuid_zzz";
+ /**
+ * Generate a collection scope for a collection within the application's Id for the given type
+ * @param applicationId The applicationId that owns this entity
+ * @param type The type in the collection
+ * @return The collectionScope
+ */
+ public static CollectionScope getCollectionScopeNameFromEntityType(final Id applicationId, final String type){
+ return
+ new CollectionScopeImpl( applicationId, applicationId,
+ getCollectionScopeNameFromEntityType( type ) );
+ }
+
+ /**
+ * Get the collection name from the entity/id type
+ * @param type
+ * @return
+ */
public static String getCollectionScopeNameFromEntityType( String type ) {
String csn = EDGE_COLL_SUFFIX + Schema.defaultCollectionName( type );
return csn.toLowerCase();
[22/50] [abbrv] incubator-usergrid git commit: Fix incorrect
formatting.
Posted by sn...@apache.org.
Fix incorrect formatting.
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/ce20abec
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/ce20abec
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/ce20abec
Branch: refs/heads/two-dot-o-events
Commit: ce20abecdd65ab97c19e2a3c9a8929e3fd9cf1ee
Parents: 39aaca6
Author: Dave Johnson <dm...@apigee.com>
Authored: Tue Nov 25 10:55:56 2014 -0500
Committer: Dave Johnson <dm...@apigee.com>
Committed: Tue Nov 25 10:55:56 2014 -0500
----------------------------------------------------------------------
.../org/apache/usergrid/persistence/GeoIT.java | 579 ++++++++++---------
1 file changed, 305 insertions(+), 274 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/ce20abec/stack/core/src/test/java/org/apache/usergrid/persistence/GeoIT.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/GeoIT.java b/stack/core/src/test/java/org/apache/usergrid/persistence/GeoIT.java
index 9556852..ad30064 100644
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/GeoIT.java
+++ b/stack/core/src/test/java/org/apache/usergrid/persistence/GeoIT.java
@@ -17,8 +17,13 @@
package org.apache.usergrid.persistence;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -44,339 +49,365 @@ public class GeoIT extends AbstractCoreIT {
}
- @Test
- public void testGeo() throws Exception {
- LOG.info( "GeoIT.testGeo" );
+ @Test
+ public void testGeo() throws Exception {
+ LOG.info("GeoIT.testGeo");
+ EntityManager em = app.getEntityManager();
+ assertNotNull(em);
+
+ // create user at a location
+ Map<String, Object> properties = new LinkedHashMap<String, Object>() {{
+ put("username", "edanuff");
+ put("email", "ed@anuff.com");
+ put("location", new LinkedHashMap<String, Object>() {
+ {
+ put("latitude", 37.776753);
+ put("longitude", -122.407846);
+ }
+ });
+ }
+ };
+ Entity user = em.create("user", properties);
+ assertNotNull(user);
+ em.refreshIndex();
- EntityManager em = app.getEntityManager();
- assertNotNull( em );
+ // define center point about 300m from that location
+ Point center = new Point(37.774277, -122.404744);
- // create user at a location
- Map<String, Object> properties = new LinkedHashMap<String, Object>() {{
- put( "username", "edanuff" );
- put( "email", "ed@anuff.com" );
- put( "location", new LinkedHashMap<String, Object>() {{
- put("latitude", 37.776753 );
- put("longitude", -122.407846 );
- }} );
- }};
+ Query query = Query.fromQL("select * where location within 200 of "
+ + center.getLat() + "," + center.getLon());
+ Results listResults = em.searchCollection(em.getApplicationRef(), "users", query);
- Entity user = em.create( "user", properties );
- assertNotNull( user );
+ assertEquals("No results less than 200m away from center", 0, listResults.size());
- em.refreshIndex();
+ query = Query.fromQL("select * where location within 400 of "
+ + center.getLat() + "," + center.getLon());
+ listResults = em.searchCollection(em.getApplicationRef(), "users", query);
- // define center point about 300m from that location
- Point center = new Point( 37.774277, -122.404744 );
+ this.dump(listResults);
- Query query = Query.fromQL( "select * where location within 200 of "
- + center.getLat() + "," + center.getLon());
- Results listResults = em.searchCollection( em.getApplicationRef(), "users", query );
+ assertEquals("1 result less than 400m away from center", 1, listResults.size());
- assertEquals("No results less than 200m away from center", 0, listResults.size() );
+ // remove location from user
+ properties.remove("location");
+ em.updateProperties(user, properties);
+ em.refreshIndex();
- query = Query.fromQL( "select * where location within 400 of "
- + center.getLat() + "," + center.getLon());
- listResults = em.searchCollection( em.getApplicationRef(), "users", query );
+ query = Query.fromQL("select * where location within 400 of "
+ + center.getLat() + "," + center.getLon());
+ listResults = em.searchCollection(em.getApplicationRef(), "users", query);
- this.dump( listResults );
+ this.dump(listResults);
- assertEquals("1 result less than 400m away from center", 1, listResults.size() );
+ // user no longer found with 400m search
+ assertEquals(0, listResults.size());
- // remove location from user
- properties.remove("location");
- em.updateProperties(user, properties);
- em.refreshIndex();
+ // move user and center to new locations
+ updatePos(em, user, 37.426373, -122.14108);
- query = Query.fromQL( "select * where location within 400 of "
- + center.getLat() + "," + center.getLon());
- listResults = em.searchCollection( em.getApplicationRef(), "users", query );
+ center = new Point(37.774277, -122.404744);
- this.dump( listResults );
+ query = Query.fromQL("select * where location within 200 of "
+ + center.getLat() + "," + center.getLon());
+ listResults = em.searchCollection(em.getApplicationRef(), "users", query);
- // user no longer found with 400m search
- assertEquals( 0, listResults.size() );
+ assertEquals(0, listResults.size());
- // move user and center to new locations
- updatePos( em, user, 37.426373, -122.14108 );
+ updatePos(em, user, 37.774277, -122.404744);
- center = new Point( 37.774277, -122.404744 );
+ center = new Point(37.776753, -122.407846);
- query = Query.fromQL( "select * where location within 200 of "
- + center.getLat() + "," + center.getLon());
- listResults = em.searchCollection( em.getApplicationRef(), "users", query );
+ query = Query.fromQL("select * where location within 1000 of "
+ + center.getLat() + "," + center.getLon());
+ listResults = em.searchCollection(em.getApplicationRef(), "users", query);
- assertEquals( 0, listResults.size() );
+ assertEquals(1, listResults.size());
- updatePos( em, user, 37.774277, -122.404744 );
+ // check at globally large distance
+ query = Query.fromQL("select * where location within " + Integer.MAX_VALUE + " of "
+ + center.getLat() + "," + center.getLon());
+ listResults = em.searchCollection(em.getApplicationRef(), "users", query);
+
+ assertEquals(1, listResults.size());
+
+ // create a new entity so we have 2
+ LinkedHashMap<String, Object> properties2 = new LinkedHashMap<String, Object>() {{
+ put("username", "sganyo");
+ put("email", "sganyo@anuff.com");
+ put("location", new LinkedHashMap<String, Object>() {
+ {
+ put("latitude", 31.1);
+ put("longitude", 121.2);
+ }
+ });
+ }
+ };
+ Entity user2 = em.create("user", properties2);
+ em.refreshIndex();
+ assertNotNull(user2);
- center = new Point( 37.776753, -122.407846 );
+ query = Query.fromQL("select * where location within 10000 of "
+ + center.getLat() + "," + center.getLon());
+ listResults = em.searchCollection(em.getApplicationRef(), "users", query);
- query = Query.fromQL( "select * where location within 1000 of "
- + center.getLat() + "," + center.getLon());
- listResults = em.searchCollection( em.getApplicationRef(), "users", query );
+ assertEquals(1, listResults.size());
- assertEquals( 1, listResults.size() );
+ // check at globally large distance
+ query = Query.fromQL("select * where location within " + Integer.MAX_VALUE + " of "
+ + center.getLat() + "," + center.getLon());
+ listResults = em.searchCollection(em.getApplicationRef(), "users", query);
- // check at globally large distance
+ assertEquals(2, listResults.size());
- query = Query.fromQL( "select * where location within " + Integer.MAX_VALUE + " of "
- + center.getLat() + "," + center.getLon());
- listResults = em.searchCollection( em.getApplicationRef(), "users", query );
+ // check at globally large distance (center point close to other entity)
+ center = new Point(31.14, 121.27);
- assertEquals( 1, listResults.size() );
+ query = Query.fromQL("select * where location within " + Integer.MAX_VALUE + " of "
+ + center.getLat() + "," + center.getLon());
+ listResults = em.searchCollection(em.getApplicationRef(), "users", query);
- // create a new entity so we have 2
- LinkedHashMap<String, Object> properties2 = new LinkedHashMap<String, Object>() {{
- put( "username", "sganyo" );
- put( "email", "sganyo@anuff.com" );
- put( "location", new LinkedHashMap<String, Object>() {{
- put("latitude", 31.1 );
- put("longitude", 121.2 );
- }} );
- }};
- Entity user2 = em.create( "user", properties2 );
- em.refreshIndex();
- assertNotNull( user2 );
+ assertEquals(2, listResults.size());
- query = Query.fromQL( "select * where location within 10000 of "
- + center.getLat() + "," + center.getLon());
- listResults = em.searchCollection( em.getApplicationRef(), "users", query );
+ Results emSearchResults = em.searchCollection(em.getApplicationRef(), "users",
+ Query.fromQL("location within 1000 of 37.776753, -122.407846"));
+ assertEquals(1, emSearchResults.size());
- assertEquals( 1, listResults.size() );
+ updatePos(em, user, 37.776753, -122.407846);
- // check at globally large distance
- query = Query.fromQL( "select * where location within " + Integer.MAX_VALUE + " of "
- + center.getLat() + "," + center.getLon());
- listResults = em.searchCollection( em.getApplicationRef(), "users", query );
+ center = new Point(37.428526, -122.140916);
- assertEquals( 2, listResults.size() );
+ query = Query.fromQL("select * where location within 1000 of "
+ + center.getLat() + "," + center.getLon());
+ listResults = em.searchCollection(em.getApplicationRef(), "users", query);
- // check at globally large distance (center point close to other entity)
- center = new Point( 31.14, 121.27 );
+ assertEquals(0, listResults.size());
- query = Query.fromQL( "select * where location within " + Integer.MAX_VALUE + " of "
- + center.getLat() + "," + center.getLon());
- listResults = em.searchCollection( em.getApplicationRef(), "users", query );
+ emSearchResults = em.searchCollection(em.getApplicationRef(), "users",
+ Query.fromQL("location within 1000 of 37.428526, -122.140916"));
+ assertEquals(0, emSearchResults.size());
- assertEquals( 2, listResults.size() );
+ properties = new LinkedHashMap<String, Object>();
+ properties.put("name", "Brickhouse");
+ properties.put("address", "426 Brannan Street");
+ properties.put("location", getLocation(37.779632, -122.395131));
- Results emSearchResults = em.searchCollection( em.getApplicationRef(), "users",
- Query.fromQL( "location within 1000 of 37.776753, -122.407846" ) );
- assertEquals( 1, emSearchResults.size() );
+ Entity restaurant = em.create("restaurant", properties);
+ assertNotNull(restaurant);
- updatePos( em, user, 37.776753, -122.407846 );
+ em.createConnection(user, "likes", restaurant);
- center = new Point( 37.428526, -122.140916 );
+ em.refreshIndex();
- query = Query.fromQL( "select * where location within 1000 of "
- + center.getLat() + "," + center.getLon());
- listResults = em.searchCollection( em.getApplicationRef(), "users", query );
+ emSearchResults = em.searchConnectedEntities(user,
+ Query.fromQL("location within 2000 of 37.776753, -122.407846").setConnectionType("likes"));
+ assertEquals(1, emSearchResults.size());
+ emSearchResults = em.searchConnectedEntities(user,
+ Query.fromQL("location within 1000 of 37.776753, -122.407846").setConnectionType("likes"));
+ assertEquals(0, emSearchResults.size());
+ }
- assertEquals( 0, listResults.size() );
- emSearchResults = em.searchCollection( em.getApplicationRef(), "users",
- Query.fromQL( "location within 1000 of 37.428526, -122.140916" ) );
- assertEquals( 0, emSearchResults.size() );
+ @Test
+ public void testGeo2() throws Exception {
+ LOG.info("GeoIT.testGeo2");
+ EntityManager em = app.getEntityManager();
+ assertNotNull(em);
+
+ // create user at a location
+ Map<String, Object> properties = new LinkedHashMap<String, Object>() {{
+ put("type", "store");
+ put("name", "norwest");
+ put("location", new LinkedHashMap<String, Object>() {
+ {
+ put("latitude", -33.746369);
+ put("longitude", 150.952183);
+ }
+ });
+ }
+ };
+ Entity entity = em.create("store", properties);
+ assertNotNull(entity);
+ properties = new LinkedHashMap<String, Object>() {{
+ put("type", "store");
+ put("name", "ashfield");
+ put("location", new LinkedHashMap<String, Object>() {
+ {
+ put("latitude", -33.889058);
+ put("longitude", 151.124024);
+ }
+ });
+ }
+ };
+ entity = em.create("store", properties);
+ assertNotNull(entity);
- properties = new LinkedHashMap<String, Object>();
- properties.put( "name", "Brickhouse" );
- properties.put( "address", "426 Brannan Street" );
- properties.put( "location", getLocation( 37.779632, -122.395131 ) );
+ em.refreshIndex();
- Entity restaurant = em.create( "restaurant", properties );
- assertNotNull( restaurant );
+ Point center = new Point(37.776753, -122.407846);
- em.createConnection( user, "likes", restaurant );
+ Query query = Query.fromQL("select * where location within 10000 of "
+ + center.getLat() + "," + center.getLon());
+ Results listResults = em.searchCollection(em.getApplicationRef(), "stores", query);
- em.refreshIndex();
+ this.dump(listResults);
- emSearchResults = em.searchConnectedEntities( user,
- Query.fromQL( "location within 2000 of 37.776753, -122.407846" ).setConnectionType( "likes" ) );
- assertEquals( 1, emSearchResults.size() );
+ assertEquals("Results less than 10000m away from center", 0, listResults.size());
+
+ Query query2 = Query.fromQL("select * where location within 40000000 of "
+ + center.getLat() + "," + center.getLon());
+ listResults = em.searchCollection(em.getApplicationRef(), "stores", query2);
+
+ assertEquals("Results from center point to ridiculously far", 2, listResults.size());
- emSearchResults = em.searchConnectedEntities( user,
- Query.fromQL( "location within 1000 of 37.776753, -122.407846" ).setConnectionType( "likes" ) );
- assertEquals( 0, emSearchResults.size() );
- }
- @Test
- public void testGeo2() throws Exception {
- LOG.info( "GeoIT.testGeo2" );
- EntityManager em = app.getEntityManager();
- assertNotNull( em );
-
- // create user at a location
- Map<String, Object> properties = new LinkedHashMap<String, Object>() {{
- put( "type", "store" );
- put( "name", "norwest" );
- put( "location", new LinkedHashMap<String, Object>() {{
- put("latitude", -33.746369 );
- put("longitude", 150.952183 );
- }} );
- }};
- Entity entity = em.create( "store", properties );
- assertNotNull( entity );
- properties = new LinkedHashMap<String, Object>() {{
- put( "type", "store" );
- put( "name", "ashfield" );
- put( "location", new LinkedHashMap<String, Object>() {{
- put("latitude", -33.889058 );
- put("longitude", 151.124024 );
- }} );
- }};
- entity = em.create( "store", properties );
- assertNotNull( entity );
-
- em.refreshIndex();
-
- Point center = new Point( 37.776753, -122.407846 );
-
- Query query = Query.fromQL( "select * where location within 10000 of "
- + center.getLat() + "," + center.getLon());
- Results listResults = em.searchCollection( em.getApplicationRef(), "stores", query );
-
- this.dump( listResults );
-
- assertEquals("Results less than 10000m away from center", 0, listResults.size() );
-
- Query query2 = Query.fromQL( "select * where location within 40000000 of "
- + center.getLat() + "," + center.getLon());
- listResults = em.searchCollection( em.getApplicationRef(), "stores", query2 );
-
- assertEquals("Results from center point to ridiculously far", 2, listResults.size() );
-
- }
- @Test
- public void testGeo3() throws Exception {
- LOG.info( "GeoIT.testGeo3" );
- EntityManager em = app.getEntityManager();
- assertNotNull( em );
-
- // create user at a location
- Map<String, Object> properties = new LinkedHashMap<String, Object>() {{
- put( "name", "norwest" );
- put( "location", new LinkedHashMap<String, Object>() {{
- put("latitude", -33.746369 );
- put("longitude", 150.952183 );
- }} );
- }};
- Entity entity = em.create( "store", properties );
- assertNotNull( entity );
- properties = new LinkedHashMap<String, Object>() {{
- put( "name", "ashfield" );
- put( "location", new LinkedHashMap<String, Object>() {{
- put("latitude", -33.889058 );
- put("longitude", 151.124024 );
- }} );
- }};
- entity = em.create( "store", properties );
- assertNotNull( entity );
-
- em.refreshIndex();
-
- Point center = new Point( -33.746369, 150.952183 );
-
- Query query = Query.fromQL( "select * where location within 10000 of "
- + center.getLat() + "," + center.getLon());
- Results listResults = em.searchCollection( em.getApplicationRef(), "stores", query );
-
- this.dump( listResults );
-
- assertEquals("Results less than 10000m away from center", 1, listResults.size() );
-
- Query query2 = Query.fromQL( "select * where location within 40000000 of "
- + center.getLat() + "," + center.getLon());
- listResults = em.searchCollection( em.getApplicationRef(), "stores", query2 );
-
- assertEquals("Results from center point to ridiculously far", 2, listResults.size() );
-
- }
- @Test
- public void testGeo4() throws Exception {
- LOG.info( "GeoIT.testGeo4" );
- EntityManager em = app.getEntityManager();
- assertNotNull( em );
-
- // create user at a location
- Map<String, Object> properties = new LinkedHashMap<String, Object>() {{
- put( "name", "norwest" );
- put( "location", new LinkedHashMap<String, Object>() {{
- put("latitude", -33.746369 );
- put("longitude", 150.952183 );
- }} );
- }};
- Entity entity = em.create( "store", properties );
- assertNotNull( entity );
- properties = new LinkedHashMap<String, Object>() {{
- put( "name", "ashfield" );
- put( "location", new LinkedHashMap<String, Object>() {{
- put("latitude", -33.889058 );
- put("longitude", 151.124024 );
- }} );
- }};
- entity = em.create( "store", properties );
- assertNotNull( entity );
-
- em.refreshIndex();
-
- List<Point> points = new ArrayList<Point>();
- points.add(new Point( 33.746369,-89 ));//Woodland, MS
- points.add(new Point( 33.746369,-91 ));//Beulah, MS
- points.add(new Point( -1.000000, 102.000000 ));//Somewhere in Indonesia
- points.add(new Point( -90.000000, 90.000000 ));//Antarctica
- points.add(new Point( 90, 90 ));//Santa's house
- //and the cartesian product...
- for(int i= -90;i<=90;i++){
- for(int j= -180;j<=180;j++){
- points.add(new Point( i, j ));
- }
}
- Iterator<Point> pointIterator = points.iterator();
- for(Point p=pointIterator.next();pointIterator.hasNext();p=pointIterator.next()){
- Query query = Query.fromQL( "select * where location within 10000 of "
- + p.getLat() + "," + p.getLon());
- Results listResults = em.searchCollection( em.getApplicationRef(), "stores", query );
- this.dump( listResults );
- assertEquals("Results less than 10000m away from center", 0, listResults.size() );
- query = Query.fromQL( "select * where location within 40000000 of "
- + p.getLat() + "," + p.getLon());
- listResults = em.searchCollection( em.getApplicationRef(), "stores", query );
+ @Test
+ public void testGeo3() throws Exception {
+ LOG.info("GeoIT.testGeo3");
+ EntityManager em = app.getEntityManager();
+ assertNotNull(em);
+
+ // create user at a location
+ Map<String, Object> properties = new LinkedHashMap<String, Object>() {
+ {
+ put("name", "norwest");
+ put("location", new LinkedHashMap<String, Object>() {
+ {
+ put("latitude", -33.746369);
+ put("longitude", 150.952183);
+ }
+ });
+ }
+ };
+ Entity entity = em.create("store", properties);
+ assertNotNull(entity);
+ properties = new LinkedHashMap<String, Object>() {
+ {
+ put("name", "ashfield");
+ put("location", new LinkedHashMap<String, Object>() {
+ {
+ put("latitude", -33.889058);
+ put("longitude", 151.124024);
+ }
+ });
+ }
+ };
+ entity = em.create("store", properties);
+ assertNotNull(entity);
+
+ em.refreshIndex();
+
+ Point center = new Point(-33.746369, 150.952183);
- assertEquals("Results from center point to ridiculously far", 2, listResults.size() );
+ Query query = Query.fromQL("select * where location within 10000 of "
+ + center.getLat() + "," + center.getLon());
+ Results listResults = em.searchCollection(em.getApplicationRef(), "stores", query);
- }
+ this.dump(listResults);
+ assertEquals("Results less than 10000m away from center", 1, listResults.size());
- }
- @Test
- public void testGeoBadPoints() throws Exception {
- LOG.info( "GeoIT.testGeoBadPoints" );
- double[][] vertices= {
- {-91.000000, 90.000000},
- {91.000000, 90.000000},
- {90.000000, 400},
- {90.000000, -270.000000},
- {-91.000000, -91.000000}
- };
- for (int i=0;i<vertices.length;i++){
- //bad coordinate. bad! you're supposed to have lat between -90 and 90
- try {
- Point p = new Point(vertices[i][0], vertices[i][1]);
- assertTrue("Bad points should throw an exception ["+vertices[i][0]+","+vertices[i][1]+"]", false);
- }catch(java.lang.IllegalArgumentException e){
- assertTrue("Bad points should throw an exception ["+vertices[i][0]+","+vertices[i][1]+"]" , true);
- }
+ Query query2 = Query.fromQL("select * where location within 40000000 of "
+ + center.getLat() + "," + center.getLon());
+ listResults = em.searchCollection(em.getApplicationRef(), "stores", query2);
+
+ assertEquals("Results from center point to ridiculously far", 2, listResults.size());
}
+ @Test
+ public void testGeo4() throws Exception {
+ LOG.info("GeoIT.testGeo4");
+ EntityManager em = app.getEntityManager();
+ assertNotNull(em);
+
+ // create user at a location
+ Map<String, Object> properties = new LinkedHashMap<String, Object>() {{
+ put("name", "norwest");
+ put("location", new LinkedHashMap<String, Object>() {
+ {
+ put("latitude", -33.746369);
+ put("longitude", 150.952183);
+ }
+ });
+ }
+ };
+ Entity entity = em.create("store", properties);
+ assertNotNull(entity);
+ properties = new LinkedHashMap<String, Object>() {{
+ put("name", "ashfield");
+ put("location", new LinkedHashMap<String, Object>() {
+ {
+ put("latitude", -33.889058);
+ put("longitude", 151.124024);
+ }
+ });
+ }
+ };
+ entity = em.create("store", properties);
+ assertNotNull(entity);
+
+ em.refreshIndex();
- }
+ List<Point> points = new ArrayList<Point>();
+ points.add(new Point(33.746369, -89));//Woodland, MS
+ points.add(new Point(33.746369, -91));//Beulah, MS
+ points.add(new Point(-1.000000, 102.000000));//Somewhere in Indonesia
+ points.add(new Point(-90.000000, 90.000000));//Antarctica
+ points.add(new Point(90, 90));//Santa's house
+ //and the cartesian product...
+ for (int i = -90; i <= 90; i++) {
+ for (int j = -180; j <= 180; j++) {
+ points.add(new Point(i, j));
+ }
+ }
+ Iterator<Point> pointIterator = points.iterator();
+ for (Point p = pointIterator.next(); pointIterator.hasNext(); p = pointIterator.next()) {
+ Query query = Query.fromQL("select * where location within 10000 of "
+ + p.getLat() + "," + p.getLon());
+ Results listResults = em.searchCollection(em.getApplicationRef(), "stores", query);
+
+ this.dump(listResults);
+ assertEquals("Results less than 10000m away from center", 0, listResults.size());
+
+ query = Query.fromQL("select * where location within 40000000 of "
+ + p.getLat() + "," + p.getLon());
+ listResults = em.searchCollection(em.getApplicationRef(), "stores", query);
+
+ assertEquals("Results from center point to ridiculously far", 2, listResults.size());
+
+ }
+
+ }
+
+
+ @Test
+ public void testGeoBadPoints() throws Exception {
+ LOG.info("GeoIT.testGeoBadPoints");
+ double[][] vertices = {
+ {-91.000000, 90.000000},
+ {91.000000, 90.000000},
+ {90.000000, 400},
+ {90.000000, -270.000000},
+ {-91.000000, -91.000000}
+ };
+ for (int i = 0; i < vertices.length; i++) {
+ //bad coordinate. bad! you're supposed to have lat between -90 and 90
+ try {
+ Point p = new Point(vertices[i][0], vertices[i][1]);
+ assertTrue("Bad points should throw an exception ["
+ + vertices[i][0] + "," + vertices[i][1] + "]", false);
+ } catch (java.lang.IllegalArgumentException e) {
+ assertTrue("Bad points should throw an exception ["
+ + vertices[i][0] + "," + vertices[i][1] + "]", true);
+ }
+ }
+ }
@Test
[36/50] [abbrv] incubator-usergrid git commit: Added error message fix
Posted by sn...@apache.org.
Added error message fix
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/a18e5de9
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/a18e5de9
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/a18e5de9
Branch: refs/heads/two-dot-o-events
Commit: a18e5de939030f8fc4e65fa12773d6a56e66c815
Parents: e3a2595
Author: Todd Nine <tn...@apigee.com>
Authored: Mon Dec 1 15:28:02 2014 -0700
Committer: Todd Nine <tn...@apigee.com>
Committed: Mon Dec 1 15:28:02 2014 -0700
----------------------------------------------------------------------
.../serialization/impl/MvccEntitySerializationStrategyImpl.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/a18e5de9/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyImpl.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyImpl.java
index c9ec9a8..6badbc1 100644
--- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyImpl.java
+++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyImpl.java
@@ -446,7 +446,7 @@ public abstract class MvccEntitySerializationStrategyImpl implements MvccEntityS
catch ( DataCorruptionException e ) {
log.error(
"DATA CORRUPTION DETECTED when de-serializing entity with Id {} and version {}. This means the"
- + " write was truncated.", id, version );
+ + " write was truncated.", id, version, e );
//return an empty entity, we can never load this one, and we don't want it to bring the system
//to a grinding halt
return new MvccEntityImpl( id, version, MvccEntity.Status.DELETED, Optional.<Entity>absent() );
[38/50] [abbrv] incubator-usergrid git commit: Refactored post users
simulation and user scenarios
Posted by sn...@apache.org.
Refactored post users simulation and user scenarios
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/e7cd6f82
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/e7cd6f82
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/e7cd6f82
Branch: refs/heads/two-dot-o-events
Commit: e7cd6f82d5597c785be10f2ab7c230166ae9fdd8
Parents: 12a522a
Author: Todd Nine <tn...@apigee.com>
Authored: Mon Dec 1 18:15:33 2014 -0700
Committer: Todd Nine <tn...@apigee.com>
Committed: Mon Dec 1 18:15:33 2014 -0700
----------------------------------------------------------------------
.../usergrid/scenarios/UserScenarios.scala | 50 +++++++++++++++-----
.../org/apache/usergrid/settings/Settings.scala | 2 +-
.../simulations/PostUsersSimulation.scala | 35 +++++---------
3 files changed, 51 insertions(+), 36 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e7cd6f82/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/UserScenarios.scala
----------------------------------------------------------------------
diff --git a/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/UserScenarios.scala b/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/UserScenarios.scala
index 63466be..7d1c9b5 100755
--- a/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/UserScenarios.scala
+++ b/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/UserScenarios.scala
@@ -38,20 +38,33 @@ import io.gatling.core.Predef._
.check(status.saveAs("userStatus"), jsonPath("$..entities[0]").exists, jsonPath("$..entities[0].uuid").exists, jsonPath("$..entities[0].uuid").saveAs("userId"))
)
- val postUserIfNotExists =
- exec(getUserByUsername)
- .doIf ("${userStatus}", "404") {
+
+ /**
+ * Post a user
+ */
+ val postUser =
+
exec(
- http("POST geolocated Users")
- .post("/users")
- .body(new StringBody("""{"location":{"latitude":"${latitude}","longitude":"${longitude}"},"username":"${username}",
- "displayName":"${displayName}","age":"${age}","seen":"${seen}","weight":"${weight}",
- "height":"${height}","aboutMe":"${aboutMe}","profileId":"${profileId}","headline":"${headline}",
- "showAge":"${showAge}","relationshipStatus":"${relationshipStatus}","ethnicity":"${ethnicity}","password":"password"}"""))
- .check(status.saveAs("userStatus"))
- .check(status.is(200),jsonPath("$..entities[0].uuid").saveAs("userId"))
- )
- }
+ http("POST geolocated Users")
+ .post("/users")
+ .body(new StringBody("""{"location":{"latitude":"${latitude}","longitude":"${longitude}"},"username":"${username}",
+ "displayName":"${displayName}","age":"${age}","seen":"${seen}","weight":"${weight}",
+ "height":"${height}","aboutMe":"${aboutMe}","profileId":"${profileId}","headline":"${headline}",
+ "showAge":"${showAge}","relationshipStatus":"${relationshipStatus}","ethnicity":"${ethnicity}","password":"password"}"""))
+ .check(status.saveAs("userStatus"))
+ .check(status.is(200),jsonPath("$..entities[0].uuid").saveAs("userId"))
+ )
+
+
+ /**
+ * Try to get a user, if it returns a 404, create the user
+ */
+ val postUserIfNotExists =
+ exec(getUserByUsername)
+ .doIf ("${userStatus}", "404") {
+ exec(postUser)
+ }
+
val putUser =
exec(getUserByUsername)
@@ -75,6 +88,10 @@ import io.gatling.core.Predef._
.check(status.is(200), jsonPath("$..entities[0].uuid").saveAs("userId"))
)
+ /**
+ * Logs in as the admin user. Checks if a user exists, if not, creates the user
+ * Logs in as the user, then creates 2 devices if they do not exist
+ */
val createUsersWithDevicesScenario = scenario("Create Users")
.feed(Settings.getInfiniteUserFeeder())
.exec(TokenScenarios.getManagementToken)
@@ -85,4 +102,11 @@ import io.gatling.core.Predef._
feed(FeederGenerator.generateEntityNameFeeder("device", Settings.numDevices))
.exec( DeviceScenarios.maybeCreateDevices)
}
+
+ /**
+ * Posts a new user every time
+ */
+ val postUsersInfinitely = scenario("Post Users")
+ .feed(Settings.getInfiniteUserFeeder())
+ .exec(UserScenarios.postUser)
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e7cd6f82/stack/loadtests/src/main/scala/org/apache/usergrid/settings/Settings.scala
----------------------------------------------------------------------
diff --git a/stack/loadtests/src/main/scala/org/apache/usergrid/settings/Settings.scala b/stack/loadtests/src/main/scala/org/apache/usergrid/settings/Settings.scala
index 570b404..4ef28c1 100755
--- a/stack/loadtests/src/main/scala/org/apache/usergrid/settings/Settings.scala
+++ b/stack/loadtests/src/main/scala/org/apache/usergrid/settings/Settings.scala
@@ -58,7 +58,7 @@ object Settings {
val pushNotifier = if (System.getProperty("pushNotifier") != null) System.getProperty("pushNotifier") else "loadNotifier"
val pushProvider = if (System.getProperty("pushProvider") != null) System.getProperty("pushProvider") else "noop"
- println(s"Will inject $maxPossibleUsers users per sec")
+ println(s"Will inject up to $maxPossibleUsers users per sec")
def getUserFeeder():Array[Map[String, String]]= {
val userFeeder = FeederGenerator.generateUserWithGeolocationFeeder(numUsers, userLocationRadius, centerLatitude, centerLongitude)
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e7cd6f82/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/PostUsersSimulation.scala
----------------------------------------------------------------------
diff --git a/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/PostUsersSimulation.scala b/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/PostUsersSimulation.scala
index 1c998cc..6992958 100755
--- a/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/PostUsersSimulation.scala
+++ b/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/PostUsersSimulation.scala
@@ -14,37 +14,28 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
- package org.apache.usergrid.simulations
+package org.apache.usergrid.simulations
import io.gatling.core.Predef._
- import org.apache.usergrid.datagenerators.FeederGenerator
- import org.apache.usergrid.scenarios.UserScenarios
- import org.apache.usergrid.settings.Settings
+import org.apache.usergrid.helpers.Setup
+import org.apache.usergrid.scenarios.UserScenarios
+import org.apache.usergrid.settings.Settings
- import scala.concurrent.duration._
+import scala.concurrent.duration._
class PostUsersSimulation extends Simulation {
- // Target settings
- val httpConf = Settings.httpConf
+ println("Begin setup")
+ Setup.setupOrg()
+ Setup.setupApplication()
+ println("End Setup")
- // Simulation settings
- val numUsers:Int = Settings.numUsers
- val rampTime:Int = Settings.rampTime
- val throttle:Int = Settings.throttle
- // Geolocation settings
- val centerLatitude:Double = Settings.centerLatitude
- val centerLongitude:Double = Settings.centerLongitude
- val userLocationRadius:Double = Settings.userLocationRadius
- val geosearchRadius:Int = Settings.geosearchRadius
+ setUp(
+ UserScenarios.postUsersInfinitely
+ .inject(constantUsersPerSec(Settings.maxPossibleUsers) during (Settings.duration)) // wait for 15 seconds so create org can finish, need to figure out coordination
- val feeder = FeederGenerator.generateUserWithGeolocationFeeder(numUsers, userLocationRadius, centerLatitude, centerLongitude).queue
- val scnToRun = scenario("POST geolocated users")
- .feed(feeder)
- .exec(UserScenarios.postUserIfNotExists)
-
- setUp(scnToRun.inject(atOnceUsers(numUsers)).throttle(reachRps(throttle) in (rampTime.seconds)).protocols(httpConf))
+ ) .throttle(reachRps(Settings.maxPossibleUsers) in (Settings.rampTime.seconds)).protocols(Settings.httpConf.acceptHeader("application/json"))
}
[26/50] [abbrv] incubator-usergrid git commit: Removed unused params
in gatling cluster. Moved signal of success to last step
Posted by sn...@apache.org.
Removed unused params in gatling cluster. Moved signal of success to last step
Updated key selection to be a drop down of valid ssh keys
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/65a018f8
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/65a018f8
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/65a018f8
Branch: refs/heads/two-dot-o-events
Commit: 65a018f8c06090d043d6016cc713941c1f30a91d
Parents: b12130f
Author: Todd Nine <tn...@apigee.com>
Authored: Wed Nov 26 10:50:18 2014 -0700
Committer: Todd Nine <tn...@apigee.com>
Committed: Wed Nov 26 10:50:18 2014 -0700
----------------------------------------------------------------------
stack/awscluster/gatling-cluster-cf.json | 19 +++++++------------
stack/awscluster/ugcluster-cf.json | 7 ++++---
2 files changed, 11 insertions(+), 15 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/65a018f8/stack/awscluster/gatling-cluster-cf.json
----------------------------------------------------------------------
diff --git a/stack/awscluster/gatling-cluster-cf.json b/stack/awscluster/gatling-cluster-cf.json
index b9f9752..59090de 100644
--- a/stack/awscluster/gatling-cluster-cf.json
+++ b/stack/awscluster/gatling-cluster-cf.json
@@ -11,13 +11,13 @@
"KeyName": {
"Description": "Name of an existing EC2 KeyPair to enable SSH access to the instance",
"Type": "AWS::EC2::KeyPair::KeyName",
- "Default": "jenkins-east",
+ "Default": "ug-cloudformation",
"ConstraintDescription": "must be the name of an existing EC2 KeyPair."
},
"InstanceType": {
"Description": "WebServer EC2 instance type",
"Type": "String",
- "Default": "m1.xlarge",
+ "Default": "c3.xlarge",
"AllowedValues": [
"t1.micro",
"t2.micro",
@@ -66,11 +66,6 @@
"ConstraintDescription": "must be a valid email address.",
"Default": "rbridges@apigee.com"
},
- "ReleaseBucket": {
- "Description": "S3 Bucket where Usergrid assembly is to be found.",
- "Type": "String",
- "Default": "usergrid-jenkins-builds"
- },
"SSHLocation": {
"Description": "The IP address range that can be used to SSH to the EC2 instances",
"Type": "String",
@@ -253,15 +248,11 @@
"wget https://bootstrap.pypa.io/ez_setup.py -O - | python\n",
"easy_install https://s3.amazonaws.com/cloudformation-examples/aws-cfn-bootstrap-latest.tar.gz\n",
"## These don't seem to work correctly and cause script to bail. Temporarily removing \n",
- "#/usr/local/bin/cfn-init -v ",
+ "/usr/local/bin/cfn-init -v ",
" --stack ", { "Ref" : "AWS::StackName" },
" --resource LaunchConfig ",
" --region ", { "Ref" : "AWS::Region" }, "\n",
- "#/usr/local/bin/cfn-signal -e $? ",
- " --stack ", { "Ref" : "AWS::StackName" },
- " --resource GatlingServerGroup ",
- " --region ", { "Ref" : "AWS::Region" }, "\n",
"add-apt-repository ppa:webupd8team/java --yes\n",
"apt-add-repository ppa:awstools-dev/awstools --yes\n",
@@ -273,6 +264,10 @@
"cd ~ubuntu\n",
"git clone -b ",{ "Ref":"Branch" } , " https://github.com/apache/incubator-usergrid.git usergrid\n",
"chown -R ubuntu:ubuntu usergrid\n",
+
+
+ "/usr/local/bin/cfn-signal --success true --stack ", { "Ref" : "AWS::StackName" }, " --resource GatlingServerGroup --region ", { "Ref" : "AWS::Region" }, "\n",
+
"ec2-create-tags $(curl -k http://169.254.169.254/latest/meta-data/instance-id) --aws-access-key ",{ "Ref":"GatlingKey" }, " --aws-secret-key ", { "Fn::GetAtt":[ "GatlingKey", "SecretAccessKey" ] } ," --tag Name=", { "Ref":"AWS::StackName" }, "-Gatling\n"
]]}}
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/65a018f8/stack/awscluster/ugcluster-cf.json
----------------------------------------------------------------------
diff --git a/stack/awscluster/ugcluster-cf.json b/stack/awscluster/ugcluster-cf.json
index 5b599ec..02058e5 100644
--- a/stack/awscluster/ugcluster-cf.json
+++ b/stack/awscluster/ugcluster-cf.json
@@ -47,9 +47,10 @@
"ConstraintDescription": "must be valid instance type."
},
"KeyPair": {
- "Description": "EC2 key pair to be use for SSH access",
- "Type": "String",
- "Default": "ug-cloudformation"
+ "Description": "Name of an existing EC2 KeyPair to enable SSH access to the instance",
+ "Type": "AWS::EC2::KeyPair::KeyName",
+ "Default": "ug-cloudformation",
+ "ConstraintDescription": "must be the name of an existing EC2 KeyPair."
},
"CassClusterName": {
"Description": "Name to be used for Cassandra cluster.",
[34/50] [abbrv] incubator-usergrid git commit: Updated registry to
use public dns name
Posted by sn...@apache.org.
Updated registry to use public dns name
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/2e1d8bd9
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/2e1d8bd9
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/2e1d8bd9
Branch: refs/heads/two-dot-o-events
Commit: 2e1d8bd96c01df4b7214f7b4e7165257d30fe76d
Parents: 91e25b5
Author: Todd Nine <tn...@apigee.com>
Authored: Mon Dec 1 10:01:07 2014 -0700
Committer: Todd Nine <tn...@apigee.com>
Committed: Mon Dec 1 10:01:07 2014 -0700
----------------------------------------------------------------------
stack/awscluster/src/main/groovy/NodeRegistry.groovy | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/2e1d8bd9/stack/awscluster/src/main/groovy/NodeRegistry.groovy
----------------------------------------------------------------------
diff --git a/stack/awscluster/src/main/groovy/NodeRegistry.groovy b/stack/awscluster/src/main/groovy/NodeRegistry.groovy
index 51aa8af..0288ae4 100644
--- a/stack/awscluster/src/main/groovy/NodeRegistry.groovy
+++ b/stack/awscluster/src/main/groovy/NodeRegistry.groovy
@@ -111,7 +111,7 @@ class NodeRegistry {
//TODO, add these to a list then sort them by date, then name
for (instance in reservation.getInstances()) {
- servers.add(new ServerEntry(instance.launchTime, instance.publicIpAddress));
+ servers.add(new ServerEntry(instance.launchTime, instance.publicDnsName));
}
}
[42/50] [abbrv] incubator-usergrid git commit: Updated ES
configuration to temporarily remove additional threads
Posted by sn...@apache.org.
Updated ES configuration to temporarily remove additional threads
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/54294207
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/54294207
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/54294207
Branch: refs/heads/two-dot-o-events
Commit: 54294207a321d2a964433c8498425043b2208ae4
Parents: ed58740
Author: Todd Nine <tn...@apigee.com>
Authored: Tue Dec 2 16:46:27 2014 -0700
Committer: Todd Nine <tn...@apigee.com>
Committed: Tue Dec 2 16:46:27 2014 -0700
----------------------------------------------------------------------
.../main/groovy/configure_elasticsearch.groovy | 31 +++++++++++---------
1 file changed, 17 insertions(+), 14 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/54294207/stack/awscluster/src/main/groovy/configure_elasticsearch.groovy
----------------------------------------------------------------------
diff --git a/stack/awscluster/src/main/groovy/configure_elasticsearch.groovy b/stack/awscluster/src/main/groovy/configure_elasticsearch.groovy
index 79d5c35..7bee82c 100644
--- a/stack/awscluster/src/main/groovy/configure_elasticsearch.groovy
+++ b/stack/awscluster/src/main/groovy/configure_elasticsearch.groovy
@@ -61,22 +61,25 @@ es.logger.level: INFO
#Set our threadpool size. Our bulk pool and search pools are quite large. We may want to turn these down if we
#overload the system
-
-threadpool:
- index:
- type: fixed
- size: 160
- queue_size: 0
- bulk:
- type: fixed
- size: 5000
+#
+# Temporarily removing. We don't know better :)
+# http://www.elasticsearch.org/guide/en/elasticsearch/guide/current/_don_8217_t_touch_these_settings.html#_threadpools
+#
+#threadpool:
+# index:
+# type: fixed
+# size: 160
+# queue_size: 0
+# bulk:
+# type: fixed
+# size: 5000
# size: 16
- queue_size: 100
- search:
- size: 10000
+# queue_size: 100
+# search:
+# size: 10000
# size: 48
- type: fixed
- queue_size: 100
+# type: fixed
+# queue_size: 100
action.auto_create_index: false
[32/50] [abbrv] incubator-usergrid git commit: Merge branch
'two-dot-o' into two-dot-o-events
Posted by sn...@apache.org.
Merge branch 'two-dot-o' into two-dot-o-events
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/21c93f1e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/21c93f1e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/21c93f1e
Branch: refs/heads/two-dot-o-events
Commit: 21c93f1e30c23cc6f24dd50bf49271098ae680fa
Parents: 88d49cb 277eb73
Author: Dave Johnson <dm...@apigee.com>
Authored: Mon Dec 1 09:38:37 2014 -0500
Committer: Dave Johnson <dm...@apigee.com>
Committed: Mon Dec 1 09:38:37 2014 -0500
----------------------------------------------------------------------
.../rest/management/users/UsersResource.java | 38 ++++++++++++--------
1 file changed, 24 insertions(+), 14 deletions(-)
----------------------------------------------------------------------
[47/50] [abbrv] incubator-usergrid git commit: Merge branch
'two-dot-o' of https://git-wip-us.apache.org/repos/asf/incubator-usergrid
into two-dot-o
Posted by sn...@apache.org.
Merge branch 'two-dot-o' of https://git-wip-us.apache.org/repos/asf/incubator-usergrid into two-dot-o
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/6210092f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/6210092f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/6210092f
Branch: refs/heads/two-dot-o-events
Commit: 6210092f073062bd5a147ddf2e42a00830e66c9d
Parents: 5d86227 c2bc921
Author: Dave Johnson <dm...@apigee.com>
Authored: Wed Dec 3 14:54:29 2014 -0500
Committer: Dave Johnson <dm...@apigee.com>
Committed: Wed Dec 3 14:54:29 2014 -0500
----------------------------------------------------------------------
stack/awscluster/gatling-cluster-cf.json | 387 +++++++++++++++++++
stack/awscluster/pom.xml | 2 +-
.../main/dist/init_instance/install_yourkit.sh | 6 +-
.../src/main/groovy/NodeRegistry.groovy | 197 +++++++---
.../main/groovy/configure_elasticsearch.groovy | 31 +-
.../src/main/groovy/registry_list.groovy | 36 --
stack/awscluster/ugcluster-cf.json | 7 +-
.../MvccEntitySerializationStrategyImpl.java | 2 +-
.../persistence/model/field/LocationField.java | 8 +
stack/loadtests/README.md | 19 +
stack/loadtests/pom.xml | 4 +-
.../usergrid/scenarios/DeviceScenarios.scala | 2 +-
.../usergrid/scenarios/UserScenarios.scala | 54 ++-
.../org/apache/usergrid/settings/Settings.scala | 2 +-
.../simulations/PostUsersSimulation.scala | 49 +--
.../usergrid/simulations/SetupSimulation.scala | 4 +-
stack/loadtests/src/test/scala/Engine.scala | 4 +-
stack/pom.xml | 1 +
18 files changed, 654 insertions(+), 161 deletions(-)
----------------------------------------------------------------------
[31/50] [abbrv] incubator-usergrid git commit: Merge branch
'two-dot-o' of https://git-wip-us.apache.org/repos/asf/incubator-usergrid
into two-dot-o
Posted by sn...@apache.org.
Merge branch 'two-dot-o' of https://git-wip-us.apache.org/repos/asf/incubator-usergrid into two-dot-o
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/277eb730
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/277eb730
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/277eb730
Branch: refs/heads/two-dot-o-events
Commit: 277eb730e114454f063802854ad2392365d996ad
Parents: ce20abe de455c3
Author: Dave Johnson <dm...@apigee.com>
Authored: Thu Nov 27 09:03:54 2014 -0500
Committer: Dave Johnson <dm...@apigee.com>
Committed: Thu Nov 27 09:03:54 2014 -0500
----------------------------------------------------------------------
.../rest/management/users/UsersResource.java | 38 ++++++++++++--------
1 file changed, 24 insertions(+), 14 deletions(-)
----------------------------------------------------------------------
[27/50] [abbrv] incubator-usergrid git commit: Change ES mappings to
omit both the storage of document source and document fields in the index for
USERGRID-255.
Posted by sn...@apache.org.
Change ES mappings to omit both the storage of document source and document fields in the index for USERGRID-255.
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/5ba1e7e3
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/5ba1e7e3
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/5ba1e7e3
Branch: refs/heads/no-source-in-es
Commit: 5ba1e7e3a252104981f2e5cf4f5fc4b91205823c
Parents: ce20abe
Author: Dave Johnson <dm...@apigee.com>
Authored: Wed Nov 26 16:49:00 2014 -0500
Committer: Dave Johnson <dm...@apigee.com>
Committed: Wed Nov 26 16:49:00 2014 -0500
----------------------------------------------------------------------
.../persistence/index/impl/IndexingUtils.java | 112 ++++++++++++-------
1 file changed, 71 insertions(+), 41 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/5ba1e7e3/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexingUtils.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexingUtils.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexingUtils.java
index 6d34b15..6272dcf 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexingUtils.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexingUtils.java
@@ -151,69 +151,99 @@ public class IndexingUtils {
.startObject( type )
+ // don't store source object in ES
+ .field("_source")
+ .startObject()
+ .field("_source").startObject().field("enabled", false).endObject()
+ .endObject()
+
.startArray( "dynamic_templates" )
// we need most specific mappings first since it's a stop on match algorithm
- .startObject()
- .startObject( "context_template" )
- .field( "match", IndexingUtils.ENTITYID_ID_FIELDNAME )
- .field( "match_mapping_type", "string" )
- .startObject( "mapping" ).field( "type", "string" )
- .field( "index", "not_analyzed" )
- .endObject()
- .endObject()
- .endObject()
+ .startObject() // array item
+ .startObject( "context_template" )
+ .field( "match", IndexingUtils.ENTITYID_ID_FIELDNAME )
+ .field( "match_mapping_type", "string" )
+ .startObject( "mapping" )
+ .field( "type", "string" )
+ .field( "index", "not_analyzed" )
+ .endObject()
+ // dont't store field in ES
+ .field("store", false)
+ .endObject()
+ .endObject()
- .startObject()
- .startObject( "context_template" )
- .field( "match", IndexingUtils.ENTITY_CONTEXT_FIELDNAME )
- .field( "match_mapping_type", "string" )
+ .startObject() // array item
+
+ .startObject( "context_template" )
+ .field( "match", IndexingUtils.ENTITY_CONTEXT_FIELDNAME )
+ .field( "match_mapping_type", "string" )
.startObject( "mapping" )
.field( "type", "string" )
- .field( "index", "not_analyzed" ).endObject()
+ .field( "index", "not_analyzed" )
.endObject()
- .endObject()
+ // dont't store field in ES
+ .field("store", false)
+ .endObject()
+
+ .endObject()
// any string with field name that starts with sa_ gets analyzed
- .startObject()
+
+ .startObject() // array item
+
.startObject( "template_1" )
.field( "match", ANALYZED_STRING_PREFIX + "*" )
- .field( "match_mapping_type", "string" ).startObject( "mapping" )
- .field( "type", "string" )
- .field( "index", "analyzed" )
+ .field( "match_mapping_type", "string" )
+ .startObject( "mapping")
+ .field( "type", "string" )
+ .field( "index", "analyzed" )
+ .endObject()
+ // dont't store field in ES
+ .field("store", false)
.endObject()
+
.endObject()
- .endObject()
-
- // all other strings are not analyzed
- .startObject()
- .startObject( "template_2" )
- //todo, should be string prefix, remove 2 field mapping
- .field( "match", "*" )
- .field( "match_mapping_type", "string" )
- .startObject( "mapping" )
- .field( "type", "string" )
+
+ // all other strings are not analyzed
+
+ .startObject() // array item
+
+ .startObject( "template_2" )
+ // TODO, should be string prefix, remove 2 field mapping
+ .field( "match", "*" )
+ .field( "match_mapping_type", "string" )
+ .startObject( "mapping" )
+ .field( "type", "string" )
.field( "index", "not_analyzed" )
+ .endObject()
+ // dont't store field in ES
+ .field("store", false)
.endObject()
+
.endObject()
- .endObject()
- // fields names starting with go_ get geo-indexed
- .startObject()
- .startObject( "template_3" )
- .field( "match", GEO_PREFIX + "location" )
- .startObject( "mapping" )
- .field( "type", "geo_point" )
- .endObject()
+ // fields names starting with go_ get geo-indexed
+
+ .startObject() // array item
+
+ .startObject( "template_3" )
+ .field( "match", GEO_PREFIX + "location" )
+ .startObject( "mapping" )
+ .field( "type", "geo_point" )
+ .endObject()
+ // dont't store field in ES
+ .field("store", false)
+ .endObject()
+
.endObject()
- .endObject()
- .endArray()
+ .endArray()
- .endObject()
+ .endObject()
- .endObject();
+ .endObject();
return builder;
}
[07/50] [abbrv] incubator-usergrid git commit: Merge remote-tracking
branch 'origin/two-dot-o' into USERGRID-250-buffer-size-fix
Posted by sn...@apache.org.
Merge remote-tracking branch 'origin/two-dot-o' into USERGRID-250-buffer-size-fix
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/b240c6f7
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/b240c6f7
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/b240c6f7
Branch: refs/heads/two-dot-o-events
Commit: b240c6f708796144dd9d85027d7a1db8a9a7f5f5
Parents: 56ce7ce 74866a5
Author: Todd Nine <tn...@apigee.com>
Authored: Fri Nov 21 13:34:56 2014 -0700
Committer: Todd Nine <tn...@apigee.com>
Committed: Fri Nov 21 13:34:56 2014 -0700
----------------------------------------------------------------------
.../org/apache/usergrid/persistence/GeoIT.java | 404 +++++++++++++------
.../index/impl/EsEntityIndexBatchImpl.java | 66 +--
.../index/impl/EsEntityIndexImpl.java | 105 +++--
.../persistence/index/impl/EsProvider.java | 55 +--
.../persistence/index/impl/EsQueryVistor.java | 3 +-
.../index/impl/FailureMonitorImpl.java | 4 +-
.../persistence/index/impl/IndexingUtils.java | 51 +--
.../index/query/CandidateResults.java | 3 -
.../persistence/index/query/EntityResults.java | 4 +-
.../persistence/index/query/Identifier.java | 3 +-
.../usergrid/persistence/index/query/Query.java | 26 +-
.../apache/usergrid/rest/AbstractRestIT.java | 5 +-
.../collection/BrowserCompatibilityTest.java | 2 +-
.../collection/DuplicateNameIT.java | 2 +-
.../collection/activities/PutTest.java | 2 +-
.../collection/groups/GroupResourceIT.java | 240 +++++++++--
.../collection/paging/PagingEntitiesTest.java | 4 +-
.../collection/paging/PagingResourceIT.java | 14 +-
.../users/ConnectionResourceTest.java | 16 +-
.../collection/users/OwnershipResourceIT.java | 18 +-
.../collection/users/RetrieveUsersTest.java | 4 +-
.../applications/queries/AndOrQueryTest.java | 13 +-
.../queries/BadGrammarQueryTest.java | 2 +-
.../applications/queries/GeoPagingTest.java | 222 +++++++++-
.../applications/queries/MatrixQueryTests.java | 2 +-
.../rest/applications/queries/OrderByTest.java | 6 +-
.../usergrid/rest/test/resource/Connection.java | 9 +
.../rest/test/resource/TestContext.java | 66 ++-
.../rest/test/resource/ValueResource.java | 2 +
.../rest/test/resource/app/Application.java | 16 +-
.../rest/test/resource/app/Collection.java | 81 ++++
.../usergrid/rest/test/resource/app/Group.java | 56 +++
.../test/resource/app/GroupsCollection.java | 66 +++
.../usergrid/rest/test/resource/app/Role.java | 56 +++
.../rest/test/resource/app/RolesCollection.java | 64 +++
.../rest/test/resource/app/UsersCollection.java | 26 +-
36 files changed, 1336 insertions(+), 382 deletions(-)
----------------------------------------------------------------------
[15/50] [abbrv] incubator-usergrid git commit: Merge branch
'APIBAAS-1391' of github.com:r3b/usergrid-1 into USERGRID-252
Posted by sn...@apache.org.
Merge branch 'APIBAAS-1391' of github.com:r3b/usergrid-1 into USERGRID-252
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/6d4a8231
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/6d4a8231
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/6d4a8231
Branch: refs/heads/two-dot-o-events
Commit: 6d4a8231ba0a268fd70bf548dbde52d8130d57df
Parents: 2586e9f 3bc7a89
Author: Todd Nine <tn...@apigee.com>
Authored: Mon Nov 24 16:09:14 2014 -0700
Committer: Todd Nine <tn...@apigee.com>
Committed: Mon Nov 24 16:09:14 2014 -0700
----------------------------------------------------------------------
stack/awscluster/gatling-cluster-cf.json | 359 ++++++++++++++++++++++++++
1 file changed, 359 insertions(+)
----------------------------------------------------------------------
[05/50] [abbrv] incubator-usergrid git commit: Added value validation
tests
Posted by sn...@apache.org.
Added value validation tests
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/3e625b1e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/3e625b1e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/3e625b1e
Branch: refs/heads/two-dot-o-events
Commit: 3e625b1e9160c384111d39bb3a740c6bf978a4a9
Parents: fb90ae7
Author: Todd Nine <tn...@apigee.com>
Authored: Fri Nov 21 13:00:36 2014 -0700
Committer: Todd Nine <tn...@apigee.com>
Committed: Fri Nov 21 13:00:36 2014 -0700
----------------------------------------------------------------------
.../corepersistence/CpEntityManager.java | 2 +-
.../corepersistence/util/CpNamingUtils.java | 4 +-
.../serialization/SerializationFig.java | 6 +-
.../serialization/impl/SerializationModule.java | 4 +
.../serialization/impl/SettingsValidation.java | 58 ++++++++
.../impl/SettingsValidationTest.java | 131 +++++++++++++++++++
6 files changed, 199 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/3e625b1e/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
index e6b8bce..b2d854b 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
@@ -583,7 +583,7 @@ public class CpEntityManager implements EntityManager {
private Observable deleteAsync( EntityRef entityRef ) throws Exception {
- CollectionScope collectionScope =getCollectionScopeNameFromEntityType(applicationScope.getApplication(), entityRef.getType() );
+ CollectionScope collectionScope = getCollectionScopeNameFromEntityType(applicationScope.getApplication(), entityRef.getType() );
EntityCollectionManager ecm = managerCache.getEntityCollectionManager( collectionScope );
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/3e625b1e/stack/core/src/main/java/org/apache/usergrid/corepersistence/util/CpNamingUtils.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/util/CpNamingUtils.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/util/CpNamingUtils.java
index 684b6e0..0d7b6ff 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/util/CpNamingUtils.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/util/CpNamingUtils.java
@@ -79,9 +79,7 @@ public class CpNamingUtils {
* @return The collectionScope
*/
public static CollectionScope getCollectionScopeNameFromEntityType(final Id applicationId, final String type){
- return
- new CollectionScopeImpl( applicationId, applicationId,
- getCollectionScopeNameFromEntityType( type ) );
+ return new CollectionScopeImpl( applicationId, applicationId, getCollectionScopeNameFromEntityType( type ) );
}
/**
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/3e625b1e/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/SerializationFig.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/SerializationFig.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/SerializationFig.java
index 0687312..9fb04d1 100644
--- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/SerializationFig.java
+++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/SerializationFig.java
@@ -13,6 +13,8 @@ import org.safehaus.guicyfig.Key;
@FigSingleton
public interface SerializationFig extends GuicyFig {
+ String COLLECTION_MAX_ENTITY_SIZE = "collection.max.entity.size";
+
/**
* Time to live timeout in seconds.
*
@@ -58,7 +60,7 @@ public interface SerializationFig extends GuicyFig {
int getTaskPoolQueueSize();
/**
- * The maximum amount of entities we can load at any one time
+ * The maximum amount of entities we can load in a single request
*/
@Key( "collection.max.load.size" )
@Default( "100" )
@@ -71,7 +73,7 @@ public interface SerializationFig extends GuicyFig {
*
* (15mb thrift buffer * .9) / 100 (default max load size)
*/
- @Key( "collection.max.entity.size" )
+ @Key( COLLECTION_MAX_ENTITY_SIZE )
@Default( "141557" )
int getMaxEntitySize();
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/3e625b1e/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/SerializationModule.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/SerializationModule.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/SerializationModule.java
index eb9c374..33a092d 100644
--- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/SerializationModule.java
+++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/SerializationModule.java
@@ -59,5 +59,9 @@ public class SerializationModule extends AbstractModule {
uriBinder.addBinding().to( Key.get( MvccEntitySerializationStrategy.class, CurrentImpl.class ) );
uriBinder.addBinding().to( Key.get( MvccLogEntrySerializationStrategy.class ) );
uriBinder.addBinding().to( Key.get( UniqueValueSerializationStrategy.class ) );
+
+
+ //bind our settings as an eager singleton so it's checked on startup
+ bind(SettingsValidation.class).asEagerSingleton();
}
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/3e625b1e/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/SettingsValidation.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/SettingsValidation.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/SettingsValidation.java
new file mode 100644
index 0000000..6715cfb
--- /dev/null
+++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/SettingsValidation.java
@@ -0,0 +1,58 @@
+/*
+ * 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.collection.serialization.impl;
+
+
+import org.apache.usergrid.persistence.collection.serialization.SerializationFig;
+import org.apache.usergrid.persistence.core.astyanax.CassandraFig;
+
+import com.google.common.base.Preconditions;
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+
+
+/**
+ *
+ * This element validates our SerializationFig and CassandraFig are correct for transport values
+ * TODO, this feels like a hack (Even though it's legal in GUICE) When we have more time, we should look at using
+ * something like visitors and SPI to perform validation
+ */
+@Singleton
+public class SettingsValidation {
+
+
+ @Inject
+ public SettingsValidation( final CassandraFig cassandraFig, final SerializationFig serializationFig ) {
+ final int thriftBufferSize = cassandraFig.getThriftBufferSize();
+
+ Preconditions.checkArgument( thriftBufferSize > 0, CassandraFig.THRIFT_TRANSPORT_SIZE + " must be > than 0" );
+
+ final int usableThriftBufferSize = ( int ) (thriftBufferSize*.9);
+
+ final int maxEntitySize = serializationFig.getMaxEntitySize();
+
+ Preconditions.checkArgument( maxEntitySize > 0, CassandraFig.THRIFT_TRANSPORT_SIZE + " must be > than 0" );
+
+ Preconditions.checkArgument(usableThriftBufferSize >= maxEntitySize, "You cannot set the max entity size to more than the thrift buffer size * .9. Maximum usable thrift size is " + usableThriftBufferSize + " and max entity size is " + maxEntitySize);
+
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/3e625b1e/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/SettingsValidationTest.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/SettingsValidationTest.java b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/SettingsValidationTest.java
new file mode 100644
index 0000000..807bc4e
--- /dev/null
+++ b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/SettingsValidationTest.java
@@ -0,0 +1,131 @@
+/*
+ * 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.collection.serialization.impl;
+
+
+import org.junit.Test;
+
+import org.apache.usergrid.persistence.collection.serialization.SerializationFig;
+import org.apache.usergrid.persistence.core.astyanax.CassandraFig;
+
+import static org.junit.Assert.*;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+
+/**
+ * Performs basic unit tests on our settings validation
+ */
+public class SettingsValidationTest {
+
+ /**
+ * Tests that when we're within range, it passes
+ */
+ @Test
+ public void withinBounds(){
+ CassandraFig cassandraFig = mock(CassandraFig.class);
+
+ final int thriftSize = 15728640;
+
+ final int usableThriftSize = ( int ) (thriftSize * .9);
+
+ when(cassandraFig.getThriftBufferSize()).thenReturn( thriftSize );
+
+
+ SerializationFig serializationFig = mock(SerializationFig.class);
+
+ when(serializationFig.getMaxEntitySize()).thenReturn( usableThriftSize );
+
+ new SettingsValidation( cassandraFig, serializationFig);
+
+ when(serializationFig.getMaxEntitySize()).thenReturn( usableThriftSize -1 );
+
+ new SettingsValidation( cassandraFig, serializationFig);
+
+ }
+
+
+ /**
+ * Tests that when we're within range, it passes
+ */
+ @Test(expected = IllegalArgumentException.class)
+ public void outOfBounds(){
+ CassandraFig cassandraFig = mock(CassandraFig.class);
+
+ final int thriftSize = 15728640;
+
+ final int usableThriftSize = ( int ) (thriftSize * .9);
+
+ when(cassandraFig.getThriftBufferSize()).thenReturn( thriftSize );
+
+
+ SerializationFig serializationFig = mock(SerializationFig.class);
+
+ when(serializationFig.getMaxEntitySize()).thenReturn( usableThriftSize+1 );
+
+ new SettingsValidation( cassandraFig, serializationFig);
+
+
+
+ }
+
+
+
+ /**
+ * Tests that when we're within range, it passes
+ */
+ @Test(expected = IllegalArgumentException.class)
+ public void zeroBufferSize(){
+ CassandraFig cassandraFig = mock(CassandraFig.class);
+
+ final int thriftSize = 0;
+
+ when(cassandraFig.getThriftBufferSize()).thenReturn( thriftSize );
+
+ SerializationFig serializationFig = mock(SerializationFig.class);
+
+ new SettingsValidation( cassandraFig, serializationFig);
+
+
+
+ }
+
+ /**
+ * Tests that when we're within range, it passes
+ */
+ @Test(expected = IllegalArgumentException.class)
+ public void zeroEntitySize(){
+ CassandraFig cassandraFig = mock(CassandraFig.class);
+
+ final int thriftSize = 15728640;
+
+ when(cassandraFig.getThriftBufferSize()).thenReturn( thriftSize );
+
+
+ SerializationFig serializationFig = mock(SerializationFig.class);
+
+ when(serializationFig.getMaxEntitySize()).thenReturn( 0 );
+
+ new SettingsValidation( cassandraFig, serializationFig);
+
+
+
+ }
+}
[17/50] [abbrv] incubator-usergrid git commit: updated basic geo tests
Posted by sn...@apache.org.
updated basic geo tests
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/09333ac4
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/09333ac4
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/09333ac4
Branch: refs/heads/two-dot-o-events
Commit: 09333ac4bf88670f6ece72f7dd13f6f59bbff4ae
Parents: 2586e9f
Author: Rod Simpson <ro...@apigee.com>
Authored: Mon Nov 24 18:31:12 2014 -0700
Committer: Rod Simpson <ro...@apigee.com>
Committed: Mon Nov 24 18:31:12 2014 -0700
----------------------------------------------------------------------
.../applications/queries/basicGeoTests.java | 88 +++++++++++++++++++-
1 file changed, 86 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/09333ac4/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/basicGeoTests.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/basicGeoTests.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/basicGeoTests.java
index e921b37..abaf6dd 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/basicGeoTests.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/basicGeoTests.java
@@ -59,6 +59,8 @@ public class basicGeoTests extends AbstractRestIT {
/**
* Create a entity with a geo location point in it
+ * 1. Create entity
+ * 2. Verify that the entity was created
*/
@Test
public void createEntityWithGeoLocationPoint() throws IOException {
@@ -67,6 +69,7 @@ public class basicGeoTests extends AbstractRestIT {
JsonNode node = null;
Double lat = 37.776753;
Double lon = -122.407846;
+ //1. Create entity
Map<String, Double> latLon = hashMap("latitude", lat);
latLon.put( "longitude", lon );
Map<String, Object> entityData = new HashMap<String, Object>();
@@ -77,16 +80,97 @@ public class basicGeoTests extends AbstractRestIT {
}
catch ( UniformInterfaceException e ) {
JsonNode nodeError = mapper.readTree( e.getResponse().getEntity( String.class ) );
- fail( node.get( "error" ).textValue() );
+ fail( nodeError.get( "error" ).textValue() );
}
+ //2. Verify that the entity was created
assertNotNull( node );
- assertEquals(lat.toString(), node.get("location").get("latitude").asText() );
+ assertEquals( lat.toString(), node.get("location").get("latitude").asText() );
assertEquals( lon.toString(), node.get( "location" ).get("longitude").asText() );
}
/**
+ * Update an entity with a geo location point in it
+ * 1. create an entity with a geo point
+ * 2. read back that entity make sure it is accurate
+ * 3. update the geo point to a new value
+ * 4. read back the updated entity, make sure it is accurate
+ */
+ @Test
+ public void updateEntityWithGeoLocationPoint() throws IOException {
+
+ String collectionType = "stores";
+ String entityName = "cornerStore";
+ JsonNode entity = null;
+ Double lat = 37.776753;
+ Double lon = -122.407846;
+
+ //1. create an entity with a geo point
+ Map<String, Double> latLon = hashMap("latitude", lat);
+ latLon.put( "longitude", lon );
+ Map<String, Object> entityData = new HashMap<String, Object>();
+ entityData.put( "location", latLon );
+ entityData.put( "name", entityName );
+
+ try {
+ entity = context.collection( collectionType ).post( entityData );
+ }
+ catch ( UniformInterfaceException e ) {
+ JsonNode nodeError = mapper.readTree( e.getResponse().getEntity( String.class ) );
+ fail( nodeError.get( "error" ).textValue() );
+ }
+
+ assertNotNull(entity);
+ assertEquals( lat.toString(), entity.get("location").get("latitude").asText() );
+ assertEquals( lon.toString(), entity.get( "location" ).get("longitude").asText() );
+
+ context.refreshIndex();
+
+ //2. read back that entity make sure it is accurate
+ /*
+ try {
+ node = context.collection( collectionType ).get(entityName);
+ }
+ catch ( UniformInterfaceException e ) {
+ JsonNode nodeError = mapper.readTree( e.getResponse().getEntity( String.class ) );
+ fail( nodeError.get( "error" ).textValue() );
+ }
+
+ //3. update the geo point to a new value
+ Double newLat = 35.776753;
+ Double newLon = -119.407846;
+ latLon.put( "latitude", newLat );
+ latLon.put( "longitude", newLon );
+ entityData.put( "location", latLon );
+
+ //TODO PUT should take name property and append it to URL - e.g. PUT /cats/fluffy not PUT /cats {"name":"fluffy"}
+ try {
+ //node = context.collection( collectionType ).put(entityData);
+ //entity.put(entityData);
+
+ }
+ catch ( UniformInterfaceException e ) {
+ JsonNode nodeError = mapper.readTree( e.getResponse().getEntity( String.class ) );
+ fail( nodeError.get( "error" ).textValue() );
+ }
+
+ assertNotNull(entity);
+ assertEquals( newLat.toString(), entity.get("location").get("latitude").asText() );
+ assertEquals( newLon.toString(), entity.get( "location" ).get("longitude").asText() );
+ */
+
+ context.refreshIndex();
+
+ //4. read back the updated entity, make sure it is accurate
+
+
+
+
+
+ }
+
+ /**
* Test exceptions for entities with poorly created geo points
* 1. misspell latitude
* 2. misspell longitude
[37/50] [abbrv] incubator-usergrid git commit: Upgrades gatling
version
Posted by sn...@apache.org.
Upgrades gatling version
Fixes jsonPath assertions to first check for entities[0]
Renamed create to be clearer when reading code
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/12a522ad
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/12a522ad
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/12a522ad
Branch: refs/heads/two-dot-o-events
Commit: 12a522ad1093a6d3f4efff7a49bdca6190be49ca
Parents: a18e5de
Author: Todd Nine <tn...@apigee.com>
Authored: Mon Dec 1 16:34:30 2014 -0700
Committer: Todd Nine <tn...@apigee.com>
Committed: Mon Dec 1 16:34:30 2014 -0700
----------------------------------------------------------------------
stack/loadtests/README.md | 19 +++++++++++++++++++
stack/loadtests/pom.xml | 4 ++--
.../usergrid/scenarios/DeviceScenarios.scala | 2 +-
.../usergrid/scenarios/UserScenarios.scala | 6 +++---
.../simulations/PostUsersSimulation.scala | 2 +-
.../usergrid/simulations/SetupSimulation.scala | 4 ++--
stack/loadtests/src/test/scala/Engine.scala | 4 ++--
7 files changed, 30 insertions(+), 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/12a522ad/stack/loadtests/README.md
----------------------------------------------------------------------
diff --git a/stack/loadtests/README.md b/stack/loadtests/README.md
index 87f4a67..14514c6 100644
--- a/stack/loadtests/README.md
+++ b/stack/loadtests/README.md
@@ -26,3 +26,22 @@ Gatling will run through mvn
Also see http://gatling.io/docs/2.0.2/general/simulation_setup.html
Additional docs can be found here http://gatling.io/docs/2.0.2/
+
+##Running a Push Notification Simulation
+
+1. Set up all users in the system with 2 devices each.
+
+ >mvn compile gatling:execute -Dgatling.simulationClass=org.apache.usergrid.simulations.SetupSimulation -DadminUser=usergrid -DadminPassword=test -Dorg=usergrid -Dapp=load -Dthrottle=100 -Dbaseurl=http://loadtest.usergrid.com -DmaxPossibleUsers=1000
+
+
+ Note the following.
+
+
+ **throttle:** The max number of users + devices per second to create
+
+ **maxPossibleUsers:** The maximum number of users the simulation will create before exiting
+
+
+1. No
+
+
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/12a522ad/stack/loadtests/pom.xml
----------------------------------------------------------------------
diff --git a/stack/loadtests/pom.xml b/stack/loadtests/pom.xml
index b08e58b..0389eda 100644
--- a/stack/loadtests/pom.xml
+++ b/stack/loadtests/pom.xml
@@ -52,9 +52,9 @@
<scala.version>2.10.4</scala.version>
<encoding>UTF-8</encoding>
- <gatling.version>2.0.1</gatling.version>
+ <gatling.version>2.0.3</gatling.version>
<gatling.plugin.version>2.0.0</gatling.plugin.version>
- <gatling-highcharts.version>2.0.1</gatling-highcharts.version>
+ <gatling-highcharts.version>2.0.3</gatling-highcharts.version>
<scala-maven-plugin.version>3.1.6</scala-maven-plugin.version>
</properties>
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/12a522ad/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/DeviceScenarios.scala
----------------------------------------------------------------------
diff --git a/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/DeviceScenarios.scala b/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/DeviceScenarios.scala
index 9385123..4abd8cb 100755
--- a/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/DeviceScenarios.scala
+++ b/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/DeviceScenarios.scala
@@ -50,7 +50,7 @@ object DeviceScenarios {
.body(StringBody("""{"deviceModel":"Fake Device",
"deviceOSVerion":"Negative Version",
"""" + notifier + """.notifier.id":"${entityName}"}"""))
- .check(status.is(200), jsonPath("$..entities[0].uuid").exists , jsonPath("$..entities[0].uuid").saveAs("deviceId")))
+ .check(status.is(200), jsonPath("$..entities[0]").exists , jsonPath("$..entities[0].uuid").exists , jsonPath("$..entities[0].uuid").saveAs("deviceId")))
val postDeviceWithNotifier400ok = exec(http("Create device with notifier")
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/12a522ad/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/UserScenarios.scala
----------------------------------------------------------------------
diff --git a/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/UserScenarios.scala b/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/UserScenarios.scala
index 6fc5655..63466be 100755
--- a/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/UserScenarios.scala
+++ b/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/UserScenarios.scala
@@ -35,10 +35,10 @@ import io.gatling.core.Predef._
http("GET user")
.get("/users/${username}")
.headers(Headers.jsonAuthorized)
- .check(status.saveAs("userStatus"), jsonPath("$..entities[0].uuid").exists, jsonPath("$..entities[0].uuid").saveAs("userId"))
+ .check(status.saveAs("userStatus"), jsonPath("$..entities[0]").exists, jsonPath("$..entities[0].uuid").exists, jsonPath("$..entities[0].uuid").saveAs("userId"))
)
- val postUser =
+ val postUserIfNotExists =
exec(getUserByUsername)
.doIf ("${userStatus}", "404") {
exec(
@@ -78,7 +78,7 @@ import io.gatling.core.Predef._
val createUsersWithDevicesScenario = scenario("Create Users")
.feed(Settings.getInfiniteUserFeeder())
.exec(TokenScenarios.getManagementToken)
- .exec(UserScenarios.postUser)
+ .exec(UserScenarios.postUserIfNotExists)
.exec(TokenScenarios.getUserToken)
.exec(UserScenarios.getUserByUsername)
.repeat(2){
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/12a522ad/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/PostUsersSimulation.scala
----------------------------------------------------------------------
diff --git a/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/PostUsersSimulation.scala b/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/PostUsersSimulation.scala
index cbac041..1c998cc 100755
--- a/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/PostUsersSimulation.scala
+++ b/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/PostUsersSimulation.scala
@@ -43,7 +43,7 @@ class PostUsersSimulation extends Simulation {
val scnToRun = scenario("POST geolocated users")
.feed(feeder)
- .exec(UserScenarios.postUser)
+ .exec(UserScenarios.postUserIfNotExists)
setUp(scnToRun.inject(atOnceUsers(numUsers)).throttle(reachRps(throttle) in (rampTime.seconds)).protocols(httpConf))
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/12a522ad/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/SetupSimulation.scala
----------------------------------------------------------------------
diff --git a/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/SetupSimulation.scala b/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/SetupSimulation.scala
index ab68d98..567a510 100644
--- a/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/SetupSimulation.scala
+++ b/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/SetupSimulation.scala
@@ -39,7 +39,7 @@ class SetupSimulation extends Simulation{
setUp(
UserScenarios.createUsersWithDevicesScenario
- .inject(constantUsersPerSec(Settings.maxPossibleUsers) during (Settings.duration))
+ .inject(splitUsers(Settings.maxPossibleUsers) into( rampUsers(10) over (10 seconds)) separatedBy (10 seconds))
.protocols(Settings.httpConf.acceptHeader("application/json"))
- ).throttle(reachRps(Settings.throttle) in (Settings.rampTime seconds), holdFor(Settings.duration))
+ )
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/12a522ad/stack/loadtests/src/test/scala/Engine.scala
----------------------------------------------------------------------
diff --git a/stack/loadtests/src/test/scala/Engine.scala b/stack/loadtests/src/test/scala/Engine.scala
index 48c93f8..0914589 100644
--- a/stack/loadtests/src/test/scala/Engine.scala
+++ b/stack/loadtests/src/test/scala/Engine.scala
@@ -25,8 +25,8 @@ object Engine extends App {
props.resultsDirectory(IDEPathHelper.resultsDirectory.toString)
props.requestBodiesDirectory(IDEPathHelper.requestBodiesDirectory.toString)
props.binariesDirectory(IDEPathHelper.mavenBinariesDirectory.toString)
- val simName = if(System.getProperty("simulationClass")!=null) System.getProperty("simulationClass") else "AppSimulation";
- props.simulationClass("org.apache.usergrid.simulations."+simName)
+ val simName = if(System.getProperty("gatling.simulationClass")!=null) System.getProperty("gatling.simulationClass") else "org.apache.usergrid.simulations.AppSimulation";
+ props.simulationClass(simName)
Gatling.fromMap(props.build)
}
[08/50] [abbrv] incubator-usergrid git commit: Setting to current
default of 1k. We need to refactor this setting to be common between all
modules and enforced in all modules.
Posted by sn...@apache.org.
Setting to current default of 1k. We need to refactor this setting to be common between all modules and enforced in all modules.
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/0a92bee7
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/0a92bee7
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/0a92bee7
Branch: refs/heads/two-dot-o-events
Commit: 0a92bee7988cb2a5207aef1c5dff5cd4c23c2f8a
Parents: b240c6f
Author: Todd Nine <tn...@apigee.com>
Authored: Fri Nov 21 14:18:21 2014 -0700
Committer: Todd Nine <tn...@apigee.com>
Committed: Fri Nov 21 14:18:21 2014 -0700
----------------------------------------------------------------------
.../persistence/collection/serialization/SerializationFig.java | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/0a92bee7/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/SerializationFig.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/SerializationFig.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/SerializationFig.java
index 9fb04d1..381a24e 100644
--- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/SerializationFig.java
+++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/SerializationFig.java
@@ -61,9 +61,10 @@ public interface SerializationFig extends GuicyFig {
/**
* The maximum amount of entities we can load in a single request
+ * TODO, change this and move it into a common setting that both query and collection share
*/
@Key( "collection.max.load.size" )
- @Default( "100" )
+ @Default( "1000" )
int getMaxLoadSize();
[39/50] [abbrv] incubator-usergrid git commit: Fixes missing
constructor in location
Posted by sn...@apache.org.
Fixes missing constructor in location
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/b9a2694d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/b9a2694d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/b9a2694d
Branch: refs/heads/two-dot-o-events
Commit: b9a2694daf124f3b19500aaa5479dcbbcdd1e40f
Parents: e7cd6f8
Author: Todd Nine <tn...@apigee.com>
Authored: Mon Dec 1 18:16:10 2014 -0700
Committer: Todd Nine <tn...@apigee.com>
Committed: Mon Dec 1 18:16:10 2014 -0700
----------------------------------------------------------------------
.../usergrid/persistence/model/field/LocationField.java | 8 ++++++++
1 file changed, 8 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/b9a2694d/stack/corepersistence/model/src/main/java/org/apache/usergrid/persistence/model/field/LocationField.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/model/src/main/java/org/apache/usergrid/persistence/model/field/LocationField.java b/stack/corepersistence/model/src/main/java/org/apache/usergrid/persistence/model/field/LocationField.java
index 407fd44..4605e1b 100644
--- a/stack/corepersistence/model/src/main/java/org/apache/usergrid/persistence/model/field/LocationField.java
+++ b/stack/corepersistence/model/src/main/java/org/apache/usergrid/persistence/model/field/LocationField.java
@@ -33,6 +33,14 @@ public class LocationField extends AbstractField<Location> {
}
+ /**
+ * Required for Jackson, DO NOT DELETE
+ */
+ public LocationField() {
+ //required do not delete
+ super();
+ }
+
@Override
public FieldTypeName getTypeName() {
[33/50] [abbrv] incubator-usergrid git commit: Updated NodeRegistry
to only select running instances in describe
Posted by sn...@apache.org.
Updated NodeRegistry to only select running instances in describe
Updated yourkit to the latest version
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/91e25b5e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/91e25b5e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/91e25b5e
Branch: refs/heads/two-dot-o-events
Commit: 91e25b5ecbccc205e97694851cf825994153e4f7
Parents: fd5be56
Author: Todd Nine <tn...@apigee.com>
Authored: Mon Dec 1 09:49:51 2014 -0700
Committer: Todd Nine <tn...@apigee.com>
Committed: Mon Dec 1 09:49:51 2014 -0700
----------------------------------------------------------------------
.../main/dist/init_instance/install_yourkit.sh | 6 +--
.../src/main/groovy/NodeRegistry.groovy | 45 ++++++++------------
2 files changed, 21 insertions(+), 30 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/91e25b5e/stack/awscluster/src/main/dist/init_instance/install_yourkit.sh
----------------------------------------------------------------------
diff --git a/stack/awscluster/src/main/dist/init_instance/install_yourkit.sh b/stack/awscluster/src/main/dist/init_instance/install_yourkit.sh
index ec1ac10..2bcfcd3 100644
--- a/stack/awscluster/src/main/dist/init_instance/install_yourkit.sh
+++ b/stack/awscluster/src/main/dist/init_instance/install_yourkit.sh
@@ -25,15 +25,15 @@ if [[ $YOURKIT = "true" ]]; then
mkdir -p /mnt/yourkit
cd /mnt/yourkit
-s3cmd --config=/etc/s3cfg get s3://${RELEASE_BUCKET}/yjp-2014-build-14110.zip
-unzip /mnt/yourkit/yjp-2014-build-14110.zip
+s3cmd --config=/etc/s3cfg get s3://${RELEASE_BUCKET}/yjp-2014-build-14114.zip
+unzip /mnt/yourkit/yjp-2014-build-14114.zip
mkdir -p /mnt/yourkitreports
chown -R tomcat7.tomcat7 /mnt/yourkitreports
cat >> /etc/default/tomcat7 << EOF
-JAVA_OPTS="\${JAVA_OPTS} -agentpath:/mnt/yourkit/yjp-2014-build-14110/bin/linux-x86-64/libyjpagent.so=port=10001,logdir=/mnt/yourkitreports,dir=/mnt/yourkitreports,onexit=snapshot"
+JAVA_OPTS="\${JAVA_OPTS} -agentpath:/mnt/yourkit/yjp-2014-build-14114/bin/linux-x86-64/libyjpagent.so=port=10001,logdir=/mnt/yourkitreports,dir=/mnt/yourkitreports,onexit=snapshot"
EOF
fi
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/91e25b5e/stack/awscluster/src/main/groovy/NodeRegistry.groovy
----------------------------------------------------------------------
diff --git a/stack/awscluster/src/main/groovy/NodeRegistry.groovy b/stack/awscluster/src/main/groovy/NodeRegistry.groovy
index 80a20eb..51aa8af 100644
--- a/stack/awscluster/src/main/groovy/NodeRegistry.groovy
+++ b/stack/awscluster/src/main/groovy/NodeRegistry.groovy
@@ -32,6 +32,9 @@ class NodeRegistry {
//taken from aws
public static final String STACK_NAME = "usergrid:stack-name";
public static final String NODE_TYPE = "usergrid:node_type";
+ public static final String SEARCH_INSTANCE_STATE = "instance-state-name";
+ public static final String SEARCH_STACK_NAME = TAG_PREFIX + STACK_NAME
+ public static final String SEARCH_NODE_TYPE = TAG_PREFIX + NODE_TYPE
private String accessKey = (String) System.getenv().get("AWS_ACCESS_KEY")
private String secretKey = (String) System.getenv().get("AWS_SECRET_KEY")
@@ -80,12 +83,12 @@ class NodeRegistry {
*/
def searchNode(def nodeType) {
- def stackNameFilter = new Filter(TAG_PREFIX+STACK_NAME).withValues(stackName)
- def nodeTypeFilter = new Filter(TAG_PREFIX+NODE_TYPE).withValues(nodeType)
+ def stackNameFilter = new Filter(SEARCH_STACK_NAME).withValues(stackName)
+ def nodeTypeFilter = new Filter(SEARCH_NODE_TYPE).withValues(nodeType)
+ def instanceState = new Filter(SEARCH_INSTANCE_STATE).withValues(InstanceStateName.Running.toString());
-
- //sort by created date
+ //sort by created date
def servers = new TreeSet<ServerEntry>();
@@ -93,11 +96,11 @@ class NodeRegistry {
- while(true){
+ while (true) {
- def describeRequest = new DescribeInstancesRequest().withFilters(stackNameFilter, nodeTypeFilter)
+ def describeRequest = new DescribeInstancesRequest().withFilters(stackNameFilter, nodeTypeFilter, instanceState)
- if(token != null){
+ if (token != null) {
describeRequest.withNextToken(token);
}
@@ -108,27 +111,17 @@ class NodeRegistry {
//TODO, add these to a list then sort them by date, then name
for (instance in reservation.getInstances()) {
-
- //ignore instances that aren't running
- if (instance.state.getName() == InstanceStateName.Running.toString()) {
- servers.add(new ServerEntry(instance.launchTime, instance.publicDnsName));
- }
-
-
+ servers.add(new ServerEntry(instance.launchTime, instance.publicIpAddress));
}
}
//nothing to do, exit the loop
- if(nodes.nextToken != null){
- token = nodes.nextToken;
- }
- else{
+ if (nodes.nextToken == null) {
break;
}
-
-
+ token = nodes.nextToken;
}
@@ -138,19 +131,17 @@ class NodeRegistry {
return createResults(servers);
}
- def createResults(def servers){
+ def createResults(def servers) {
def results = [];
- for(server in servers){
+ for (server in servers) {
results.add(server.publicIp)
}
return results;
}
-
-
/**
* Add the node to the database if it doesn't exist
*/
@@ -167,7 +158,7 @@ class NodeRegistry {
}
- class ServerEntry implements Comparable<ServerEntry>{
+ class ServerEntry implements Comparable<ServerEntry> {
private final Date launchDate;
private final String publicIp;
@@ -178,9 +169,9 @@ class NodeRegistry {
@Override
int compareTo(final ServerEntry o) {
- if(launchDate.before(o.launchDate)){
+ if (launchDate.before(o.launchDate)) {
-1;
- }else if (launchDate.after(o.launchDate)){
+ } else if (launchDate.after(o.launchDate)) {
return 1;
}
[41/50] [abbrv] incubator-usergrid git commit: Updates PostUsers
simulation to take into account only concurrent users.
Posted by sn...@apache.org.
Updates PostUsers simulation to take into account only concurrent users.
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/ed587408
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/ed587408
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/ed587408
Branch: refs/heads/two-dot-o-events
Commit: ed587408e258ca34a21bfb2a32e2792b3ef352be
Parents: b9a2694
Author: Todd Nine <tn...@apigee.com>
Authored: Tue Dec 2 14:51:13 2014 -0700
Committer: Todd Nine <tn...@apigee.com>
Committed: Tue Dec 2 14:51:13 2014 -0700
----------------------------------------------------------------------
.../simulations/PostUsersSimulation.scala | 22 ++++++++++++++------
1 file changed, 16 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/ed587408/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/PostUsersSimulation.scala
----------------------------------------------------------------------
diff --git a/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/PostUsersSimulation.scala b/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/PostUsersSimulation.scala
index 6992958..45a4437 100755
--- a/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/PostUsersSimulation.scala
+++ b/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/PostUsersSimulation.scala
@@ -21,8 +21,13 @@ import org.apache.usergrid.helpers.Setup
import org.apache.usergrid.scenarios.UserScenarios
import org.apache.usergrid.settings.Settings
-import scala.concurrent.duration._
-
+/**
+ * Posts application users continually to an application. Expects the following parameters
+ *
+ * -DmaxPossibleUsers : The maximum number of users to be making requests as fast as possible. Think of this as conccurrent users in the system
+ * -DrampTime: The amount of time (in seconds) to allow for maxPossibleUsers to be reached. This will add new users linearlly
+ * -Dduration: The amount of time (in seconds) to continue to perform requests up with the maxPossibleUsers
+ */
class PostUsersSimulation extends Simulation {
println("Begin setup")
@@ -33,9 +38,14 @@ class PostUsersSimulation extends Simulation {
setUp(
UserScenarios.postUsersInfinitely
- .inject(constantUsersPerSec(Settings.maxPossibleUsers) during (Settings.duration)) // wait for 15 seconds so create org can finish, need to figure out coordination
-
-
- ) .throttle(reachRps(Settings.maxPossibleUsers) in (Settings.rampTime.seconds)).protocols(Settings.httpConf.acceptHeader("application/json"))
+ .inject(
+ /**
+ * injection steps take from this forum post
+ * https://groups.google.com/forum/#!topic/gatling/JfYHaWCbA-w
+ */
+ rampUsersPerSec(1) to (Settings.maxPossibleUsers) during Settings.rampTime,
+ constantUsersPerSec(Settings.maxPossibleUsers) during Settings.duration
+
+ )).protocols(Settings.httpConf.acceptHeader("application/json"))
}
[48/50] [abbrv] incubator-usergrid git commit: Merge branch
'two-dot-o' of https://git-wip-us.apache.org/repos/asf/incubator-usergrid
into two-dot-o
Posted by sn...@apache.org.
Merge branch 'two-dot-o' of https://git-wip-us.apache.org/repos/asf/incubator-usergrid into two-dot-o
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/6210092f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/6210092f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/6210092f
Branch: refs/heads/two-dot-o
Commit: 6210092f073062bd5a147ddf2e42a00830e66c9d
Parents: 5d86227 c2bc921
Author: Dave Johnson <dm...@apigee.com>
Authored: Wed Dec 3 14:54:29 2014 -0500
Committer: Dave Johnson <dm...@apigee.com>
Committed: Wed Dec 3 14:54:29 2014 -0500
----------------------------------------------------------------------
stack/awscluster/gatling-cluster-cf.json | 387 +++++++++++++++++++
stack/awscluster/pom.xml | 2 +-
.../main/dist/init_instance/install_yourkit.sh | 6 +-
.../src/main/groovy/NodeRegistry.groovy | 197 +++++++---
.../main/groovy/configure_elasticsearch.groovy | 31 +-
.../src/main/groovy/registry_list.groovy | 36 --
stack/awscluster/ugcluster-cf.json | 7 +-
.../MvccEntitySerializationStrategyImpl.java | 2 +-
.../persistence/model/field/LocationField.java | 8 +
stack/loadtests/README.md | 19 +
stack/loadtests/pom.xml | 4 +-
.../usergrid/scenarios/DeviceScenarios.scala | 2 +-
.../usergrid/scenarios/UserScenarios.scala | 54 ++-
.../org/apache/usergrid/settings/Settings.scala | 2 +-
.../simulations/PostUsersSimulation.scala | 49 +--
.../usergrid/simulations/SetupSimulation.scala | 4 +-
stack/loadtests/src/test/scala/Engine.scala | 4 +-
stack/pom.xml | 1 +
18 files changed, 654 insertions(+), 161 deletions(-)
----------------------------------------------------------------------
[28/50] [abbrv] incubator-usergrid git commit: fixed recaptcha -
USERGRID-257
Posted by sn...@apache.org.
fixed recaptcha - USERGRID-257
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/de455c3c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/de455c3c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/de455c3c
Branch: refs/heads/two-dot-o-events
Commit: de455c3c41c11e1ae97f9c444dc612f1051b6b26
Parents: 39aaca6
Author: Rod Simpson <ro...@apigee.com>
Authored: Wed Nov 26 10:27:20 2014 -0700
Committer: grey <gr...@apigee.com>
Committed: Wed Nov 26 14:44:49 2014 -0800
----------------------------------------------------------------------
.../rest/management/users/UsersResource.java | 38 ++++++++++++--------
1 file changed, 24 insertions(+), 14 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/de455c3c/stack/rest/src/main/java/org/apache/usergrid/rest/management/users/UsersResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/management/users/UsersResource.java b/stack/rest/src/main/java/org/apache/usergrid/rest/management/users/UsersResource.java
index a849ae9..eee2807 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/management/users/UsersResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/management/users/UsersResource.java
@@ -173,27 +173,37 @@ public class UsersResource extends AbstractContextResource {
return handleViewable( "resetpw_email_form", this );
}
- ReCaptchaImpl reCaptcha = new ReCaptchaImpl();
- reCaptcha.setPrivateKey( properties.getRecaptchaPrivate() );
+ //we don't require recaptcha - only use it if it is present in the props file
+ boolean reCaptchaPassed = false;
+ if ( useReCaptcha() ) {
- ReCaptchaResponse reCaptchaResponse =
- reCaptcha.checkAnswer( httpServletRequest.getRemoteAddr(), challenge, uresponse );
+ ReCaptchaImpl reCaptcha = new ReCaptchaImpl();
+ reCaptcha.setPrivateKey(properties.getRecaptchaPrivate());
- if ( !useReCaptcha() || reCaptchaResponse.isValid() ) {
- user = management.findAdminUser( email );
- if ( user != null ) {
- management.startAdminUserPasswordResetFlow( user );
- return handleViewable( "resetpw_email_success", this );
+ ReCaptchaResponse reCaptchaResponse =
+ reCaptcha.checkAnswer(httpServletRequest.getRemoteAddr(), challenge, uresponse);
+
+ if (reCaptchaResponse.isValid()) {
+ reCaptchaPassed = true;
}
- else {
+ } else {
+ reCaptchaPassed = true;
+ }
+
+ if (reCaptchaPassed) {
+ user = management.findAdminUser(email);
+ if (user != null) {
+ management.startAdminUserPasswordResetFlow(user);
+ return handleViewable("resetpw_email_success", this);
+ } else {
errorMsg = "We don't recognize that email, try again...";
- return handleViewable( "resetpw_email_form", this );
+ return handleViewable("resetpw_email_form", this);
}
- }
- else {
+ } else {
errorMsg = "Incorrect Captcha, try again...";
- return handleViewable( "resetpw_email_form", this );
+ return handleViewable("resetpw_email_form", this);
}
+
}
catch ( RedirectionException e ) {
throw e;