You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@usergrid.apache.org by sf...@apache.org on 2014/12/10 18:13:50 UTC
[01/41] incubator-usergrid git commit: WIP,
first copy of adding users simulation
Repository: incubator-usergrid
Updated Branches:
refs/heads/UG-rest-test-framework-overhaul 7dd658bf4 -> 7a0c37816
WIP, first copy of adding users simulation
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/bd79d37d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/bd79d37d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/bd79d37d
Branch: refs/heads/UG-rest-test-framework-overhaul
Commit: bd79d37d56c6f1458990c463833fcf7d39828728
Parents: 7645a79
Author: Todd Nine <tn...@apigee.com>
Authored: Wed Dec 3 15:32:34 2014 -0700
Committer: Todd Nine <tn...@apigee.com>
Committed: Wed Dec 3 15:32:34 2014 -0700
----------------------------------------------------------------------
.../usergrid/scenarios/UserScenarios.scala | 11 +++++
.../simulations/GetUsersSimulation.scala | 51 ++++++++++++++++++++
2 files changed, 62 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/bd79d37d/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 7d1c9b5..2ca6d21 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
@@ -56,6 +56,15 @@ import io.gatling.core.Predef._
)
+
+ val getUsersWithCursor = exec(
+ http("GET user")
+ .get("/users?cursor=${cursor}")
+ .headers(Headers.jsonAuthorized)
+ .check(status.saveAs("userStatus"), jsonPath("$..entities").saveAs("users"))
+ )
+
+
/**
* Try to get a user, if it returns a 404, create the user
*/
@@ -109,4 +118,6 @@ import io.gatling.core.Predef._
val postUsersInfinitely = scenario("Post Users")
.feed(Settings.getInfiniteUserFeeder())
.exec(UserScenarios.postUser)
+
+ val getUsersIndefinitely = scenario("Get Users").exec()
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/bd79d37d/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/GetUsersSimulation.scala
----------------------------------------------------------------------
diff --git a/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/GetUsersSimulation.scala b/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/GetUsersSimulation.scala
new file mode 100755
index 0000000..eefeff1
--- /dev/null
+++ b/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/GetUsersSimulation.scala
@@ -0,0 +1,51 @@
+/*
+ * 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.simulations
+
+import io.gatling.core.Predef._
+import org.apache.usergrid.helpers.Setup
+import org.apache.usergrid.scenarios.UserScenarios
+import org.apache.usergrid.settings.Settings
+
+/**
+ * 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 GetUsersSimulation extends Simulation {
+
+ println("Begin setup")
+ Setup.setupOrg()
+ Setup.setupApplication()
+ println("End Setup")
+
+
+ setUp(
+ UserScenarios.postUsersInfinitely
+ .inject(
+ /**
+ * injection steps take from this forum post
+ * https://groups.google.com/forum/#!topic/gatling/JfYHaWCbA-w
+ */
+ rampUsers(Settings.maxPossibleUsers) over Settings.rampTime,
+ constantUsersPerSec(Settings.maxPossibleUsers) during Settings.duration
+
+ )).protocols(Settings.httpConf.acceptHeader("application/json"))
+
+}
[12/41] incubator-usergrid git commit: Fix broken tests that could
not be run multiple times without deleting all data from C* and ES after each
run.
Posted by sf...@apache.org.
Fix broken tests that could not be run multiple times without deleting all data from C* and ES after each run.
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/26774448
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/26774448
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/26774448
Branch: refs/heads/UG-rest-test-framework-overhaul
Commit: 26774448a2ff824d2f3ea2f924ef0ee3e30a4875
Parents: c4973e9
Author: Dave Johnson <dm...@apigee.com>
Authored: Fri Dec 5 15:28:05 2014 -0500
Committer: Dave Johnson <dm...@apigee.com>
Committed: Fri Dec 5 15:28:05 2014 -0500
----------------------------------------------------------------------
.../corepersistence/CpEntityManager.java | 230 ++++++++++---------
.../corepersistence/util/CpEntityMapUtils.java | 32 ++-
.../batch/job/SchedulerRuntimeIntervalIT.java | 47 ++--
.../migration/EntityTypeMappingMigrationIT.java | 87 +++----
.../apache/usergrid/persistence/CounterIT.java | 62 +++--
.../usergrid/persistence/CountingMutatorIT.java | 4 +-
.../persistence/EntityDictionaryIT.java | 11 +-
.../usergrid/persistence/EntityManagerIT.java | 47 ++--
.../persistence/GeoQueryBooleanTest.java | 7 +-
.../apache/usergrid/persistence/IndexIT.java | 14 +-
.../usergrid/persistence/PathQueryIT.java | 5 +-
.../PerformanceEntityRebuildIndexTest.java | 6 +-
.../usergrid/persistence/PermissionsIT.java | 5 +-
.../cassandra/EntityManagerFactoryImplIT.java | 9 +-
.../query/AbstractIteratingQueryIT.java | 3 +-
stack/core/src/test/resources/log4j.properties | 5 +-
.../data/DataMigrationManagerImpl.java | 29 ++-
.../persistence/index/IndexIdentifier.java | 4 +
.../index/impl/EsEntityIndexImpl.java | 80 ++++---
19 files changed, 386 insertions(+), 301 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/26774448/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 b2d854b..4c5ff0a 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
@@ -69,7 +69,6 @@ import org.apache.usergrid.persistence.collection.CollectionScope;
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;
@@ -215,23 +214,24 @@ public class CpEntityManager implements EntityManager {
// 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 );
- }
- } );
+ 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);
+ }
+ }
+ );
}
@@ -374,7 +374,8 @@ public class CpEntityManager implements EntityManager {
Id id = new SimpleId( entityRef.getUuid(), entityRef.getType() );
- CollectionScope collectionScope = getCollectionScopeNameFromEntityType(applicationScope.getApplication(), entityRef.getType());
+ CollectionScope collectionScope = getCollectionScopeNameFromEntityType(
+ applicationScope.getApplication(), entityRef.getType());
// if ( !UUIDUtils.isTimeBased( id.getUuid() ) ) {
@@ -583,7 +584,8 @@ 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 );
@@ -1374,8 +1376,8 @@ public class CpEntityManager implements EntityManager {
@Override
- public Entity createItemInCollection( EntityRef entityRef, String collectionName, String itemType,
- Map<String, Object> props ) throws Exception {
+ public Entity createItemInCollection( EntityRef entityRef, String collectionName,
+ String itemType, Map<String, Object> props ) throws Exception {
return getRelationManager( entityRef ).createItemInCollection( collectionName, itemType, props );
}
@@ -1420,8 +1422,8 @@ public class CpEntityManager implements EntityManager {
@Override
- public ConnectionRef createConnection( EntityRef connectingEntity, String pairedConnectionType,
- EntityRef pairedEntity, String connectionType, EntityRef connectedEntityRef )
+ public ConnectionRef createConnection( EntityRef connectingEntity, String pairedConnectionType,
+ EntityRef pairedEntity, String connectionType, EntityRef connectedEntityRef )
throws Exception {
return getRelationManager( connectingEntity )
@@ -1447,8 +1449,8 @@ public class CpEntityManager implements EntityManager {
@Override
- public ConnectionRef connectionRef( EntityRef connectingEntity, String pairedConnectionType, EntityRef pairedEntity,
- String connectionType, EntityRef connectedEntityRef ) throws Exception {
+ public ConnectionRef connectionRef( EntityRef connectingEntity, String pairedConnectionType,
+ EntityRef pairedEntity, String connectionType, EntityRef connectedEntityRef ) throws Exception {
return getRelationManager( connectingEntity )
.connectionRef( pairedConnectionType, pairedEntity, connectionType, connectedEntityRef );
@@ -1479,8 +1481,8 @@ public class CpEntityManager implements EntityManager {
@Override
- public Results getConnectedEntities( EntityRef entityRef, String connectionType, String connectedEntityType,
- Level resultsLevel ) throws Exception {
+ public Results getConnectedEntities( EntityRef entityRef, String connectionType,
+ String connectedEntityType, Level resultsLevel ) throws Exception {
return getRelationManager( entityRef )
.getConnectedEntities( connectionType, connectedEntityType, resultsLevel );
@@ -1488,8 +1490,8 @@ public class CpEntityManager implements EntityManager {
@Override
- public Results getConnectingEntities( EntityRef entityRef, String connectionType, String connectedEntityType,
- Level resultsLevel ) throws Exception {
+ public Results getConnectingEntities( EntityRef entityRef, String connectionType,
+ String connectedEntityType, Level resultsLevel ) throws Exception {
return getRelationManager( entityRef )
.getConnectingEntities( connectionType, connectedEntityType, resultsLevel );
@@ -1497,8 +1499,8 @@ public class CpEntityManager implements EntityManager {
@Override
- public Results getConnectingEntities( EntityRef entityRef, String connectionType, String entityType, Level level,
- int count ) throws Exception {
+ public Results getConnectingEntities( EntityRef entityRef, String connectionType,
+ String entityType, Level level, int count ) throws Exception {
return getRelationManager( entityRef ).getConnectingEntities( connectionType, entityType, level, count );
}
@@ -1592,8 +1594,8 @@ public class CpEntityManager implements EntityManager {
}
- private Entity batchCreateRole( String roleName, String roleTitle, long inactivity, String propertyName,
- UUID ownerId, Map<String, Object> additionalProperties ) throws Exception {
+ private Entity batchCreateRole( String roleName, String roleTitle, long inactivity,
+ String propertyName, UUID ownerId, Map<String, Object> additionalProperties ) throws Exception {
UUID timestampUuid = UUIDUtils.newTimeUUID();
long timestamp = UUIDUtils.getUUIDLong( timestampUuid );
@@ -1615,9 +1617,11 @@ public class CpEntityManager implements EntityManager {
Mutator<ByteBuffer> batch = createMutator( cass.getApplicationKeyspace( applicationId ), be );
CassandraPersistenceUtils.addInsertToMutator( batch, ENTITY_DICTIONARIES,
- CassandraPersistenceUtils.key( ownerId, Schema.DICTIONARY_ROLENAMES ), roleName, roleTitle, timestamp );
+ CassandraPersistenceUtils.key( ownerId,
+ Schema.DICTIONARY_ROLENAMES ), roleName, roleTitle, timestamp );
CassandraPersistenceUtils.addInsertToMutator( batch, ENTITY_DICTIONARIES,
- CassandraPersistenceUtils.key( ownerId, Schema.DICTIONARY_ROLETIMES ), roleName, inactivity,
+ CassandraPersistenceUtils.key( ownerId,
+ Schema.DICTIONARY_ROLETIMES ), roleName, inactivity,
timestamp );
CassandraPersistenceUtils.addInsertToMutator( batch, ENTITY_DICTIONARIES,
CassandraPersistenceUtils.key( ownerId, DICTIONARY_SETS ), Schema.DICTIONARY_ROLENAMES, null,
@@ -1635,9 +1639,8 @@ public class CpEntityManager implements EntityManager {
permission = permission.toLowerCase();
long timestamp = cass.createTimestamp();
Mutator<ByteBuffer> batch = createMutator( cass.getApplicationKeyspace( applicationId ), be );
- CassandraPersistenceUtils
- .addInsertToMutator( batch, ApplicationCF.ENTITY_DICTIONARIES, getRolePermissionsKey( roleName ),
- permission, ByteBuffer.allocate( 0 ), timestamp );
+ CassandraPersistenceUtils.addInsertToMutator( batch, ApplicationCF.ENTITY_DICTIONARIES,
+ getRolePermissionsKey( roleName ), permission, ByteBuffer.allocate( 0 ), timestamp );
CassandraPersistenceUtils.batchExecute( batch, CassandraService.RETRY_COUNT );
}
@@ -1650,16 +1653,16 @@ public class CpEntityManager implements EntityManager {
Mutator<ByteBuffer> batch = createMutator( cass.getApplicationKeyspace( applicationId ), be );
for ( String permission : permissions ) {
permission = permission.toLowerCase();
- CassandraPersistenceUtils
- .addInsertToMutator( batch, ApplicationCF.ENTITY_DICTIONARIES, getRolePermissionsKey( roleName ),
- permission, ByteBuffer.allocate( 0 ), timestamp );
+ CassandraPersistenceUtils.addInsertToMutator( batch, ApplicationCF.ENTITY_DICTIONARIES,
+ getRolePermissionsKey( roleName ), permission, ByteBuffer.allocate( 0 ), timestamp);
}
CassandraPersistenceUtils.batchExecute( batch, CassandraService.RETRY_COUNT );
}
private Object getRolePermissionsKey( String roleName ) {
- return CassandraPersistenceUtils.key( SimpleRoleRef.getIdForRoleName( roleName ), DICTIONARY_PERMISSIONS );
+ return CassandraPersistenceUtils.key(
+ SimpleRoleRef.getIdForRoleName( roleName ), DICTIONARY_PERMISSIONS );
}
@@ -1680,10 +1683,9 @@ public class CpEntityManager implements EntityManager {
roleName = roleName.toLowerCase();
permission = permission.toLowerCase();
long timestamp = cass.createTimestamp();
- Mutator<ByteBuffer> batch = createMutator( cass.getApplicationKeyspace( applicationId ), be );
- CassandraPersistenceUtils
- .addDeleteToMutator( batch, ApplicationCF.ENTITY_DICTIONARIES, getRolePermissionsKey( roleName ),
- permission, timestamp );
+ Mutator<ByteBuffer> batch = createMutator( cass.getApplicationKeyspace( applicationId ), be);
+ CassandraPersistenceUtils.addDeleteToMutator( batch, ApplicationCF.ENTITY_DICTIONARIES,
+ getRolePermissionsKey( roleName ), permission, timestamp );
CassandraPersistenceUtils.batchExecute( batch, CassandraService.RETRY_COUNT );
}
@@ -1691,8 +1693,8 @@ public class CpEntityManager implements EntityManager {
@Override
public Set<String> getRolePermissions( String roleName ) throws Exception {
roleName = roleName.toLowerCase();
- return cass.getAllColumnNames( cass.getApplicationKeyspace( applicationId ), ApplicationCF.ENTITY_DICTIONARIES,
- getRolePermissionsKey( roleName ) );
+ return cass.getAllColumnNames( cass.getApplicationKeyspace( applicationId ),
+ ApplicationCF.ENTITY_DICTIONARIES, getRolePermissionsKey( roleName ) );
}
@@ -1747,7 +1749,7 @@ public class CpEntityManager implements EntityManager {
long timestamp = cass.createTimestamp();
Mutator<ByteBuffer> batch = createMutator( cass.getApplicationKeyspace( applicationId ), be );
CassandraPersistenceUtils.addInsertToMutator( batch, ApplicationCF.ENTITY_DICTIONARIES,
- getRolePermissionsKey( groupId, roleName ), permission, ByteBuffer.allocate( 0 ), timestamp );
+ getRolePermissionsKey( groupId, roleName ), permission, ByteBuffer.allocate( 0 ), timestamp );
CassandraPersistenceUtils.batchExecute( batch, CassandraService.RETRY_COUNT );
}
@@ -1767,8 +1769,8 @@ public class CpEntityManager implements EntityManager {
@Override
public Set<String> getGroupRolePermissions( UUID groupId, String roleName ) throws Exception {
roleName = roleName.toLowerCase();
- return cass.getAllColumnNames( cass.getApplicationKeyspace( applicationId ), ApplicationCF.ENTITY_DICTIONARIES,
- getRolePermissionsKey( groupId, roleName ) );
+ return cass.getAllColumnNames( cass.getApplicationKeyspace( applicationId ),
+ ApplicationCF.ENTITY_DICTIONARIES, getRolePermissionsKey( groupId, roleName ) );
}
@@ -1810,8 +1812,8 @@ public class CpEntityManager implements EntityManager {
@Override
public Set<String> getUserPermissions( UUID userId ) throws Exception {
- return cast(
- getDictionaryAsSet( new SimpleEntityRef( User.ENTITY_TYPE, userId ), Schema.DICTIONARY_PERMISSIONS ) );
+ return cast(getDictionaryAsSet(
+ new SimpleEntityRef( User.ENTITY_TYPE, userId ), Schema.DICTIONARY_PERMISSIONS ) );
}
@@ -1891,23 +1893,23 @@ public class CpEntityManager implements EntityManager {
@Override
- public void incrementAggregateCounters( UUID userId, UUID groupId, String category, String counterName,
- long value ) {
+ public void incrementAggregateCounters( UUID userId, UUID groupId, String category,
+ String counterName, long value ) {
long cassandraTimestamp = cass.createTimestamp();
incrementAggregateCounters( userId, groupId, category, counterName, value, cassandraTimestamp );
}
- private void incrementAggregateCounters( UUID userId, UUID groupId, String category, String counterName, long value,
- long cassandraTimestamp ) {
+ private void incrementAggregateCounters( UUID userId, UUID groupId, String category,
+ String counterName, long value, long cassandraTimestamp ) {
+
// TODO short circuit
if ( !skipAggregateCounters ) {
Mutator<ByteBuffer> m = createMutator( cass.getApplicationKeyspace( applicationId ), be );
- counterUtils
- .batchIncrementAggregateCounters( m, applicationId, userId, groupId, null, category, counterName,
- value, cassandraTimestamp / 1000, cassandraTimestamp );
+ counterUtils.batchIncrementAggregateCounters( m, applicationId, userId, groupId, null,
+ category, counterName, value, cassandraTimestamp / 1000, cassandraTimestamp );
CassandraPersistenceUtils.batchExecute( m, CassandraService.RETRY_COUNT );
}
@@ -1915,16 +1917,16 @@ public class CpEntityManager implements EntityManager {
@Override
- public Results getAggregateCounters( UUID userId, UUID groupId, String category, String counterName,
- CounterResolution resolution, long start, long finish, boolean pad ) {
- return this
- .getAggregateCounters( userId, groupId, null, category, counterName, resolution, start, finish, pad );
+ public Results getAggregateCounters( UUID userId, UUID groupId, String category,
+ String counterName, CounterResolution resolution, long start, long finish, boolean pad ) {
+ return this.getAggregateCounters(
+ userId, groupId, null, category, counterName, resolution, start, finish, pad );
}
@Override
- public Results getAggregateCounters( UUID userId, UUID groupId, UUID queueId, String category, String counterName,
- CounterResolution resolution, long start, long finish, boolean pad ) {
+ public Results getAggregateCounters( UUID userId, UUID groupId, UUID queueId, String category,
+ String counterName, CounterResolution resolution, long start, long finish, boolean pad ) {
start = resolution.round( start );
finish = resolution.round( finish );
@@ -2030,8 +2032,8 @@ public class CpEntityManager implements EntityManager {
}
}
CounterUtils.AggregateCounterSelection selection = selections.get( r.getKey() );
- countSets.add( new AggregateCounterSet( selection.getName(), selection.getUserId(), selection.getGroupId(),
- selection.getCategory(), counters ) );
+ countSets.add( new AggregateCounterSet( selection.getName(), selection.getUserId(),
+ selection.getGroupId(), selection.getCategory(), counters ) );
}
Collections.sort( countSets, new Comparator<AggregateCounterSet>() {
@@ -2059,8 +2061,8 @@ public class CpEntityManager implements EntityManager {
return new SimpleEntityRef( "user", identifier.getUUID() );
}
if ( identifier.isName() ) {
- return this.getAlias( new SimpleEntityRef( Application.ENTITY_TYPE, applicationId ), "user",
- identifier.getName() );
+ return this.getAlias( new SimpleEntityRef(
+ Application.ENTITY_TYPE, applicationId ), "user", identifier.getName() );
}
if ( identifier.isEmail() ) {
@@ -2150,8 +2152,8 @@ public class CpEntityManager implements EntityManager {
if ( !skipAggregateCounters ) {
long timestamp = cass.createTimestamp();
Mutator<ByteBuffer> m = createMutator( cass.getApplicationKeyspace( applicationId ), be );
- counterUtils.batchIncrementAggregateCounters( m, applicationId, userId, groupId, null, category, counters,
- timestamp );
+ counterUtils.batchIncrementAggregateCounters(
+ m, applicationId, userId, groupId, null, category, counters, timestamp );
CassandraPersistenceUtils.batchExecute( m, CassandraService.RETRY_COUNT );
}
@@ -2173,13 +2175,14 @@ public class CpEntityManager implements EntityManager {
private Id getIdForUniqueEntityField( final String collectionName, final String propertyName,
final Object propertyValue ) {
- CollectionScope collectionScope = getCollectionScopeNameFromEntityType(applicationScope.getApplication(), collectionName);
+ CollectionScope collectionScope = getCollectionScopeNameFromEntityType(
+ applicationScope.getApplication(), collectionName);
final EntityCollectionManager ecm = managerCache.getEntityCollectionManager( collectionScope );
//convert to a string, that's what we store
- final Id results = ecm.getIdField( new StringField( propertyName, propertyValue.toString() ) ).toBlocking()
- .lastOrDefault( null );
+ final Id results = ecm.getIdField( new StringField(
+ propertyName, propertyValue.toString() ) ).toBlocking() .lastOrDefault( null );
return results;
}
@@ -2370,8 +2373,8 @@ public class CpEntityManager implements EntityManager {
@Override
- public <A extends Entity> A batchCreate( Mutator<ByteBuffer> ignored, String entityType, Class<A> entityClass,
- Map<String, Object> properties, UUID importId, UUID timestampUuid )
+ public <A extends Entity> A batchCreate( Mutator<ByteBuffer> ignored, String entityType,
+ Class<A> entityClass, Map<String, Object> properties, UUID importId, UUID timestampUuid )
throws Exception {
String eType = Schema.normalizeEntityType( entityType );
@@ -2502,10 +2505,15 @@ public class CpEntityManager implements EntityManager {
EntityCollectionManager ecm = managerCache.getEntityCollectionManager( collectionScope );
if ( logger.isDebugEnabled() ) {
- logger.debug( "Writing entity {}:{} into scope\n app {}\n owner {}\n name {} data {}", new Object[] {
- entity.getType(), entity.getUuid(), collectionScope.getApplication(),
- collectionScope.getOwner(), collectionScope.getName(), CpEntityMapUtils.toMap( cpEntity )
- } );
+ logger.debug( "Writing entity {}:{} into scope\n app {}\n owner {}\n name {} data {}",
+ new Object[] {
+ entity.getType(),
+ entity.getUuid(),
+ collectionScope.getApplication(),
+ collectionScope.getOwner(),
+ collectionScope.getName(),
+ CpEntityMapUtils.toMap( cpEntity )
+ } );
//
// if ( entity.getType().equals("group")) {
// logger.debug("Writing Group");
@@ -2575,18 +2583,20 @@ public class CpEntityManager implements EntityManager {
private void incrementEntityCollection( String collection_name, long cassandraTimestamp ) {
try {
- incrementAggregateCounters( null, null, null, APPLICATION_COLLECTION + collection_name, ONE_COUNT,
- cassandraTimestamp );
+ incrementAggregateCounters( null, null, null,
+ APPLICATION_COLLECTION + collection_name, ONE_COUNT, cassandraTimestamp );
}
catch ( Exception e ) {
logger.error( "Unable to increment counter application.collection: {}.",
new Object[] { collection_name, e } );
}
try {
- incrementAggregateCounters( null, null, null, APPLICATION_ENTITIES, ONE_COUNT, cassandraTimestamp );
+ incrementAggregateCounters( null, null, null,
+ APPLICATION_ENTITIES, ONE_COUNT, cassandraTimestamp );
}
catch ( Exception e ) {
- logger.error( "Unable to increment counter application.entities for collection: " + "{} with timestamp: {}",
+ logger.error( "Unable to increment counter application.entities for collection: "
+ + "{} with timestamp: {}",
new Object[] { collection_name, cassandraTimestamp, e } );
}
}
@@ -2612,26 +2622,26 @@ public class CpEntityManager implements EntityManager {
@Override
- public Mutator<ByteBuffer> batchSetProperty( Mutator<ByteBuffer> batch, EntityRef entity, String propertyName,
- Object propertyValue, UUID timestampUuid ) throws Exception {
+ public Mutator<ByteBuffer> batchSetProperty( Mutator<ByteBuffer> batch, EntityRef entity,
+ String propertyName, Object propertyValue, UUID timestampUuid ) throws Exception {
throw new UnsupportedOperationException( "Not supported yet." );
}
@Override
- public Mutator<ByteBuffer> batchSetProperty( Mutator<ByteBuffer> batch, EntityRef entity, String propertyName,
- Object propertyValue, boolean force, boolean noRead,
- UUID timestampUuid ) throws Exception {
+ public Mutator<ByteBuffer> batchSetProperty( Mutator<ByteBuffer> batch, EntityRef entity,
+ String propertyName, Object propertyValue, boolean force, boolean noRead,
+ UUID timestampUuid ) throws Exception {
throw new UnsupportedOperationException( "Not supported yet." );
}
@Override
- public Mutator<ByteBuffer> batchUpdateDictionary( Mutator<ByteBuffer> batch, EntityRef entity,
- String dictionaryName, Object elementValue, Object elementCoValue,
- boolean removeFromDictionary, UUID timestampUuid )
+ public Mutator<ByteBuffer> batchUpdateDictionary( Mutator<ByteBuffer> batch, EntityRef entity,
+ String dictionaryName, Object elementValue, Object elementCoValue,
+ boolean removeFromDictionary, UUID timestampUuid )
throws Exception {
long timestamp = UUIDUtils.getUUIDLong( timestampUuid );
@@ -2641,31 +2651,34 @@ public class CpEntityManager implements EntityManager {
elementCoValue = ByteBuffer.allocate( 0 );
}
- boolean entityHasDictionary = Schema.getDefaultSchema().hasDictionary( entity.getType(), dictionaryName );
+ boolean entityHasDictionary = Schema.getDefaultSchema()
+ .hasDictionary( entity.getType(), dictionaryName );
// Don't index dynamic dictionaries not defined by the schema
if ( entityHasDictionary ) {
- getRelationManager( entity )
- .batchUpdateSetIndexes( batch, dictionaryName, elementValue, removeFromDictionary, timestampUuid );
+ getRelationManager( entity ).batchUpdateSetIndexes(
+ batch, dictionaryName, elementValue, removeFromDictionary, timestampUuid );
}
- ApplicationCF dictionary_cf = entityHasDictionary ? ENTITY_DICTIONARIES : ENTITY_COMPOSITE_DICTIONARIES;
+ ApplicationCF dictionary_cf = entityHasDictionary
+ ? ENTITY_DICTIONARIES : ENTITY_COMPOSITE_DICTIONARIES;
if ( elementValue != null ) {
if ( !removeFromDictionary ) {
// Set the new value
- elementCoValue =
- CassandraPersistenceUtils.toStorableBinaryValue( elementCoValue, !entityHasDictionary );
+ elementCoValue = CassandraPersistenceUtils.toStorableBinaryValue(
+ elementCoValue, !entityHasDictionary );
CassandraPersistenceUtils.addInsertToMutator( batch, dictionary_cf,
CassandraPersistenceUtils.key( entity.getUuid(), dictionaryName ),
- entityHasDictionary ? elementValue : asList( elementValue ), elementCoValue, timestamp );
+ entityHasDictionary ? elementValue : asList( elementValue ),
+ elementCoValue, timestamp );
if ( !entityHasDictionary ) {
CassandraPersistenceUtils.addInsertToMutator( batch, ENTITY_DICTIONARIES,
- CassandraPersistenceUtils.key( entity.getUuid(), DICTIONARY_SETS ), dictionaryName, null,
- timestamp );
+ CassandraPersistenceUtils.key( entity.getUuid(), DICTIONARY_SETS ),
+ dictionaryName, null, timestamp );
}
}
else {
@@ -2680,20 +2693,19 @@ public class CpEntityManager implements EntityManager {
@Override
- public Mutator<ByteBuffer> batchUpdateDictionary( Mutator<ByteBuffer> batch, EntityRef entity,
- String dictionaryName, Object elementValue,
- boolean removeFromDictionary, UUID timestampUuid )
+ public Mutator<ByteBuffer> batchUpdateDictionary( Mutator<ByteBuffer> batch, EntityRef entity,
+ String dictionaryName, Object elementValue, boolean removeFromDictionary,
+ UUID timestampUuid )
throws Exception {
- return batchUpdateDictionary( batch, entity, dictionaryName, elementValue, null, removeFromDictionary,
- timestampUuid );
+ return batchUpdateDictionary( batch, entity, dictionaryName, elementValue, null,
+ removeFromDictionary, timestampUuid );
}
@Override
- public Mutator<ByteBuffer> batchUpdateProperties( Mutator<ByteBuffer> batch, EntityRef entity,
- Map<String, Object> properties, UUID timestampUuid )
- throws Exception {
+ public Mutator<ByteBuffer> batchUpdateProperties( Mutator<ByteBuffer> batch, EntityRef entity,
+ Map<String, Object> properties, UUID timestampUuid ) throws Exception {
throw new UnsupportedOperationException( "Not supported yet." );
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/26774448/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 ba59154..344bcd3 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
@@ -139,38 +139,54 @@ public class CpEntityMapUtils {
// is the map really a location element?
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) {
+ Map<String, Object> origMap = (Map<String, Object>) value;
+ Map<String, Object> m = new HashMap<String, Object>();
+
+ // Tests expect us to treat "Longitude" the same as "longitude"
+ for ( String key : origMap.keySet() ) {
+ m.put( key.toLowerCase(), origMap.get(key) );
+ }
+
+ // Expect at least two fields in a Location object
+ 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).");
+ 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).");
+ 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");
+ throw new IllegalArgumentException("Location properties require two fields - "
+ + "latitude and longitude, or lat and 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.");
+ 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.");
+ throw new IllegalArgumentException("Location properties requires two fields - "
+ + "latitude and longitude, or lat and lon.");
}
} else {
// not a location element, process it as map
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/26774448/stack/core/src/test/java/org/apache/usergrid/batch/job/SchedulerRuntimeIntervalIT.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/batch/job/SchedulerRuntimeIntervalIT.java b/stack/core/src/test/java/org/apache/usergrid/batch/job/SchedulerRuntimeIntervalIT.java
index 351ca7b..b6544d7 100644
--- a/stack/core/src/test/java/org/apache/usergrid/batch/job/SchedulerRuntimeIntervalIT.java
+++ b/stack/core/src/test/java/org/apache/usergrid/batch/job/SchedulerRuntimeIntervalIT.java
@@ -32,75 +32,58 @@ import static org.junit.Assert.assertTrue;
/**
- * Class to test job that the run loop executes in the time expected when there's no jobs to run. Tests
- * saturation at each point of the runtime as well
+ * Class to test job that the run loop executes in the time expected when there's no jobs to run.
+ * Tests saturation at each point of the runtime as well
*/
@Concurrent
public class SchedulerRuntimeIntervalIT extends AbstractSchedulerRuntimeIT {
- private static final Logger logger = LoggerFactory.getLogger(SchedulerRuntimeIntervalIT.class.getName());
+ private static final Logger logger =
+ LoggerFactory.getLogger(SchedulerRuntimeIntervalIT.class.getName());
private static final long EXPECTED_RUNTIME = 60000;
-
-
// private static final long EXPECTED_RUNTIME = 3000000;
/**
- * This is a combination of ( count+1 ) * interval*2. If this test takes longer than this to run, we have a bug in how
- * often the run loop is executing
- * @throws InterruptedException
+ * This is a combination of ( count+1 ) * interval*2. If this test takes longer than this
+ * to run, we have a bug in how often the run loop is executing
*/
@Test(timeout = EXPECTED_RUNTIME)
public void runLoopTest() throws InterruptedException {
- /**
- * the number of iterations we should run
- *
- */
+ // the number of iterations we should run
final int pollCount = 5;
final int expectedInterval = 5000;
-
-
-
- JobSchedulerService schedulerService = cassandraResource.getBean( JobSchedulerService.class );
+ JobSchedulerService schedulerService = cassandraResource.getBean(JobSchedulerService.class);
final long interval = schedulerService.getInterval();
-
final int numberOfWorkers = schedulerService.getWorkerSize();
-
final int expectedExecutions = numberOfWorkers * pollCount;
-
- assertEquals("Interval must be set to "+ expectedInterval + " for test to work properly", expectedInterval, interval);
-
+ assertEquals("Interval must be set to "+ expectedInterval
+ + " for test to work properly", expectedInterval, interval);
CountdownLatchJob counterJob = cassandraResource.getBean( CountdownLatchJob.class );
// set the counter job latch size
counterJob.setLatch( expectedExecutions );
-
getJobListener().setExpected(expectedExecutions );
-
long fireTime = System.currentTimeMillis();
- /**
- * We want to space the jobs out so there will most likely be an empty poll phase. For each run where we do
- * get jobs, we want to saturate the worker pool to ensure the semaphore is release properly
- */
+ // We want to space the jobs out so there will most likely be an empty poll phase.
+ // For each run where we do get jobs, we want to saturate the worker pool to ensure the
+ // semaphore is release properly
for ( int i = 0; i < pollCount; i++ ) {
for(int j = 0; j < numberOfWorkers; j ++){
scheduler.createJob( "countdownLatch", fireTime, new JobData() );
}
-
-
fireTime += expectedInterval*2;
}
-
boolean waited = counterJob.waitForCount(EXPECTED_RUNTIME, TimeUnit.MILLISECONDS);
assertTrue( "Ran" + getCount() + " number of jobs", waited);
@@ -109,7 +92,7 @@ public class SchedulerRuntimeIntervalIT extends AbstractSchedulerRuntimeIT {
logger.warn("Jobs not yet finished after waited {}, block again" , waitTime);
}
- //If we get to here without timing out, the test ran correctly. The assertion is implicit in the timeout
-
+ // If we get to here without timing out, the test ran correctly.
+ // The assertion is implicit in the timeout
}
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/26774448/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 3a52b96..837997c 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
@@ -68,7 +68,8 @@ public class EntityTypeMappingMigrationIT extends AbstractCoreIT {
* Rule to do the resets we need
*/
@Rule
- public MigrationTestRule migrationTestRule = new MigrationTestRule( app, CpSetup.getInjector() ,EntityTypeMappingMigration.class );
+ public MigrationTestRule migrationTestRule = new MigrationTestRule(
+ app, CpSetup.getInjector() ,EntityTypeMappingMigration.class );
@@ -111,7 +112,9 @@ public class EntityTypeMappingMigrationIT extends AbstractCoreIT {
keyspace.truncateColumnFamily( MapSerializationImpl.MAP_ENTRIES );
keyspace.truncateColumnFamily( MapSerializationImpl.MAP_KEYS );
- app.createApplication( GraphShardVersionMigrationIT.class.getSimpleName()+ UUIDGenerator.newTimeUUID(), "migrationTest" );
+ app.createApplication(
+ GraphShardVersionMigrationIT.class.getSimpleName()+ UUIDGenerator.newTimeUUID(),
+ "migrationTest" );
@@ -121,46 +124,46 @@ public class EntityTypeMappingMigrationIT extends AbstractCoreIT {
AllEntitiesInSystemObservable.getAllEntitiesInSystem( managerCache, 1000 )
- .doOnNext( new Action1<AllEntitiesInSystemObservable.ApplicationEntityGroup>() {
- @Override
- public void call(
- final AllEntitiesInSystemObservable.ApplicationEntityGroup entity ) {
- //ensure that each one has a type
-
- 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 );
+ .doOnNext( new Action1<AllEntitiesInSystemObservable.ApplicationEntityGroup>() {
+ @Override
+ public void call(
+ final AllEntitiesInSystemObservable.ApplicationEntityGroup entity ) {
+ //ensure that each one has a type
+
+ 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 );
assertEquals( "Every element should have been encountered", 0, allEntities.size() );
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/26774448/stack/core/src/test/java/org/apache/usergrid/persistence/CounterIT.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/CounterIT.java b/stack/core/src/test/java/org/apache/usergrid/persistence/CounterIT.java
index 0aecfd9..470a6f2 100644
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/CounterIT.java
+++ b/stack/core/src/test/java/org/apache/usergrid/persistence/CounterIT.java
@@ -21,6 +21,7 @@ import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.UUID;
+import org.apache.commons.lang3.RandomStringUtils;
import org.junit.Before;
import org.junit.Test;
@@ -71,7 +72,8 @@ public class CounterIT extends AbstractCoreIT {
LOG.info( "CounterIT.testIncrementAndDecrement" );
- UUID applicationId = setup.createApplication( "testOrganization", "testCountersIandD" );
+ UUID applicationId = setup.createApplication(
+ "testOrganization", "testCountersIandD" + RandomStringUtils.randomAlphabetic(20) );
assertNotNull( applicationId );
EntityManager em = setup.getEmf().getEntityManager( applicationId );
@@ -102,7 +104,8 @@ public class CounterIT extends AbstractCoreIT {
public void testCounters() throws Exception {
LOG.info( "CounterIT.testCounters" );
- UUID applicationId = setup.createApplication( "testOrganization", "testCounters" );
+ UUID applicationId = setup.createApplication(
+ "testOrganization", "testCounters" + RandomStringUtils.randomAlphabetic(20) );
assertNotNull( applicationId );
EntityManager em = setup.getEmf().getEntityManager( applicationId );
@@ -141,7 +144,8 @@ public class CounterIT extends AbstractCoreIT {
System.currentTimeMillis(), true );
LOG.info( JsonUtils.mapToJsonString( r.getCounters() ) );
- r = em.getAggregateCounters( user1, null, null, "visits", CounterResolution.ALL, ts, System.currentTimeMillis(),
+ r = em.getAggregateCounters( user1, null, null, "visits", CounterResolution.ALL, ts,
+ System.currentTimeMillis(),
false );
LOG.info( JsonUtils.mapToJsonString( r.getCounters() ) );
@@ -180,25 +184,32 @@ public class CounterIT extends AbstractCoreIT {
@Test
public void testCommunityCounters() throws Exception {
+
EntityManager em = setup.getEmf().getEntityManager( setup.getEmf().getManagementAppId() );
+ Map<String, Long> counts = em.getApplicationCounters();
+ long originalAdminLoginsCount = counts.get( "admin.logins" ).longValue();
+
+ String randomSuffix = RandomStringUtils.randomAlphabetic(20);
+ String orgName = "testCounter" + randomSuffix;
+ String appName = "testEntityCounters" + randomSuffix;
+
Group organizationEntity = new Group();
- organizationEntity.setPath( "tst-counter" );
- organizationEntity.setProperty( "name", "testCounter" );
+ organizationEntity.setPath( "tst-counter" + randomSuffix );
+ organizationEntity.setProperty( "name", orgName );
organizationEntity = em.create( organizationEntity );
-
- UUID applicationId = setup.getEmf().createApplication( "testCounter", "testEntityCounters" );
+ UUID applicationId = setup.getEmf().createApplication( orgName, appName );
Map<String, Object> properties = new LinkedHashMap<String, Object>();
- properties.put( "name", "testCounter/testEntityCounters" );
+ properties.put( "name", orgName + "/" + appName );
Entity applicationEntity = em.create( applicationId, "application_info", properties );
+
//Creating connections like below doesn't work.
// em.createConnection( new SimpleEntityRef( "group", organizationEntity.getUuid() ), "owns",
// new SimpleEntityRef( "application_info", applicationId ) );
- em.createConnection( organizationEntity.toTypedEntity(),"owns",applicationEntity );
-
+ em.createConnection( organizationEntity.toTypedEntity(), "owns", applicationEntity );
Event event = new Event();
event.setTimestamp( System.currentTimeMillis() );
@@ -207,32 +218,37 @@ public class CounterIT extends AbstractCoreIT {
// TODO look at row syntax of event counters being sent
em.create( event );
- /*
- event = new Event();
- event.setTimestamp(System.currentTimeMillis());
- event.addCounter("admin.logins", 1);
- em.create(event);
- */
- Map<String, Long> counts = em.getApplicationCounters();
+
+ // event = new Event();
+ // event.setTimestamp(System.currentTimeMillis());
+ // event.addCounter("admin.logins", 1);
+ // em.create(event);
+
+ counts = em.getApplicationCounters();
LOG.info( JsonUtils.mapToJsonString( counts ) );
assertNotNull( counts.get( "admin.logins" ) );
- assertEquals( 1, counts.get( "admin.logins" ).longValue() );
+ assertEquals( 1, counts.get( "admin.logins" ).longValue() - originalAdminLoginsCount );
+
// Q's:
// how to "count" a login to a specific application?
// when org is provided, why is it returning 8? Is it 4 with one 'event'?
- Results r = em.getAggregateCounters( null, null, null, "admin.logins", CounterResolution.ALL, ts,
- System.currentTimeMillis(), false );
+ Results r = em.getAggregateCounters( null, null, null, "admin.logins",
+ CounterResolution.ALL, ts, System.currentTimeMillis(), false );
+
LOG.info( JsonUtils.mapToJsonString( r.getCounters() ) );
- assertEquals( 1, r.getCounters().get( 0 ).getValues().get( 0 ).getValue() );
- //counts = em.getEntityCounters(organizationEntity.getUuid());
- //LOG.info(JsonUtils.mapToJsonString(counts));
+ assertEquals( 1,
+ r.getCounters().get( 0 ).getValues().get( 0 ).getValue() - originalAdminLoginsCount );
+
+ // counts = em.getEntityCounters(organizationEntity.getUuid());
+ // LOG.info(JsonUtils.mapToJsonString(counts));
Query query = new Query();
query.addCounterFilter( "admin.logins:*:*:*" );
query.setStartTime( ts );
query.setFinishTime( System.currentTimeMillis() );
query.setResolution( CounterResolution.SIX_HOUR );
//query.setPad(true);
+
r = em.getAggregateCounters( query );
LOG.info( JsonUtils.mapToJsonString( r.getCounters() ) );
assertEquals( 1, r.getCounters().get( 0 ).getValues().get( 0 ).getValue() );
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/26774448/stack/core/src/test/java/org/apache/usergrid/persistence/CountingMutatorIT.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/CountingMutatorIT.java b/stack/core/src/test/java/org/apache/usergrid/persistence/CountingMutatorIT.java
index 83a00f3..0d029dd 100644
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/CountingMutatorIT.java
+++ b/stack/core/src/test/java/org/apache/usergrid/persistence/CountingMutatorIT.java
@@ -20,6 +20,7 @@ package org.apache.usergrid.persistence;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.UUID;
+import org.apache.commons.lang3.RandomStringUtils;
import org.junit.After;
import org.junit.Before;
@@ -65,7 +66,8 @@ public class CountingMutatorIT extends AbstractCoreIT {
//temporarily set our max size to 10 for testing
CountingMutator.MAX_SIZE = 10;
- UUID applicationId = setup.createApplication( "testOrganization", "testFlushingMutatorOnConnections" );
+ UUID applicationId = setup.createApplication(
+ "testOrganization", "testFlushingMutator-" + RandomStringUtils.randomAlphabetic(20) );
EntityManager em = setup.getEmf().getEntityManager( applicationId );
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/26774448/stack/core/src/test/java/org/apache/usergrid/persistence/EntityDictionaryIT.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/EntityDictionaryIT.java b/stack/core/src/test/java/org/apache/usergrid/persistence/EntityDictionaryIT.java
index 111b9fa..d38c50c 100644
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/EntityDictionaryIT.java
+++ b/stack/core/src/test/java/org/apache/usergrid/persistence/EntityDictionaryIT.java
@@ -22,6 +22,7 @@ import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
+import org.apache.commons.lang3.RandomStringUtils;
import org.junit.Test;
import org.slf4j.Logger;
@@ -61,7 +62,7 @@ public class EntityDictionaryIT extends AbstractCoreIT {
LOG.info( "EntityDictionaryIT.testApplicationDictionaries" );
- UUID applicationId = setup.createApplication( "testOrganization", "testApplicationDictionaries" );
+ UUID applicationId = setup.createApplication( "testOrganization", "testApplicationDictionaries" + RandomStringUtils.randomAlphabetic(20) );
assertNotNull( applicationId );
EntityManager em = setup.getEmf().getEntityManager( applicationId );
@@ -78,7 +79,7 @@ public class EntityDictionaryIT extends AbstractCoreIT {
public void testUserDictionaries() throws Exception {
LOG.info( "EntityDictionaryIT.testUserDictionaries" );
- UUID applicationId = setup.createApplication( "testOrganization", "testUserDictionaries" );
+ UUID applicationId = setup.createApplication( "testOrganization", "testUserDictionaries" + RandomStringUtils.randomAlphabetic(20) );
assertNotNull( applicationId );
EntityManager em = setup.getEmf().getEntityManager( applicationId );
@@ -151,7 +152,7 @@ public class EntityDictionaryIT extends AbstractCoreIT {
LOG.info( "EntityDictionaryIT.testApplicationDictionaries" );
- UUID applicationId = setup.createApplication( "testOrganization", "testRemoveFromDictionary" );
+ UUID applicationId = setup.createApplication( "testOrganization", "testRemoveFromDictionary" + RandomStringUtils.randomAlphabetic(20) );
assertNotNull( applicationId );
EntityManager em = setup.getEmf().getEntityManager( applicationId );
@@ -185,7 +186,7 @@ public class EntityDictionaryIT extends AbstractCoreIT {
provider.setAccessTokenEndpointUrl( "https://accounts.google.com/o/oauth2/token" );
provider.setVersion( "2.0" );
- UUID applicationId = setup.createApplication( "testOrganization", "testGetDictionaries" );
+ UUID applicationId = setup.createApplication( "testOrganization", "testGetDictionaries" + RandomStringUtils.randomAlphabetic(20) );
assertNotNull( applicationId );
EntityManager em = setup.getEmf().getEntityManager( applicationId );
@@ -206,7 +207,7 @@ public class EntityDictionaryIT extends AbstractCoreIT {
LOG.info( "EntityDictionaryIT.testAddMapToDictionaries" );
Map<String,Object> testMap = new HashMap<String,Object>();
- UUID applicationId = setup.createApplication( "testOrganization", "testAddMapToDictionaries" );
+ UUID applicationId = setup.createApplication( "testOrganization", "testAddMapToDictionaries" + RandomStringUtils.randomAlphabetic(20) );
assertNotNull( applicationId );
EntityManager em = setup.getEmf().getEntityManager( applicationId );
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/26774448/stack/core/src/test/java/org/apache/usergrid/persistence/EntityManagerIT.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/EntityManagerIT.java b/stack/core/src/test/java/org/apache/usergrid/persistence/EntityManagerIT.java
index cb65a2a..427c168 100644
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/EntityManagerIT.java
+++ b/stack/core/src/test/java/org/apache/usergrid/persistence/EntityManagerIT.java
@@ -26,6 +26,7 @@ import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.UUID;
+import org.apache.commons.lang3.RandomStringUtils;
import org.junit.Ignore;
import org.junit.Test;
@@ -59,7 +60,8 @@ public class EntityManagerIT extends AbstractCoreIT {
public void testEntityManager() throws Exception {
LOG.info( "EntityManagerIT.testEntityManagerTest" );
- UUID applicationId = setup.createApplication( "testOrganization", "testEntityManagerTest" );
+ UUID applicationId = setup.createApplication(
+ "testOrganization", "testEntityManagerTest" + RandomStringUtils.randomAlphabetic(20) );
assertNotNull( applicationId );
EntityManager em = setup.getEmf().getEntityManager( applicationId );
@@ -119,7 +121,8 @@ public class EntityManagerIT extends AbstractCoreIT {
public void testCreateAndGet() throws Exception {
LOG.info( "EntityDaoTest.testCreateAndGet" );
- UUID applicationId = setup.createApplication( "testOrganization", "testCreateAndGet" );
+ UUID applicationId = setup.createApplication(
+ "testOrganization", "testCreateAndGet" + RandomStringUtils.randomAlphabetic(20) );
EntityManager em = setup.getEmf().getEntityManager( applicationId );
@@ -189,7 +192,8 @@ public class EntityManagerIT extends AbstractCoreIT {
public void testDictionaries() throws Exception {
LOG.info( "EntityDaoTest.testDictionaries" );
- UUID applicationId = setup.createApplication( "testOrganization", "testDictionaries" );
+ UUID applicationId = setup.createApplication(
+ "testOrganization", "testDictionaries" + RandomStringUtils.randomAlphabetic(20) );
EntityManager em = setup.getEmf().getEntityManager( applicationId );
@@ -232,7 +236,8 @@ public class EntityManagerIT extends AbstractCoreIT {
public void testProperties() throws Exception {
LOG.info( "EntityDaoTest.testProperties" );
- UUID applicationId = setup.createApplication( "testOrganization", "testProperties" );
+ UUID applicationId = setup.createApplication(
+ "testOrganization", "testProperties" + RandomStringUtils.randomAlphabetic(20) );
EntityManager em = setup.getEmf().getEntityManager( applicationId );
@@ -270,7 +275,8 @@ public class EntityManagerIT extends AbstractCoreIT {
public void testCreateAndDelete() throws Exception {
LOG.info( "EntityDaoTest.testCreateAndDelete" );
- UUID applicationId = setup.createApplication( "testOrganization", "testCreateAndDelete" );
+ UUID applicationId = setup.createApplication(
+ "testOrganization", "testCreateAndDelete" + RandomStringUtils.randomAlphabetic(20) );
EntityManager em = setup.getEmf().getEntityManager( applicationId );
@@ -292,8 +298,8 @@ public class EntityManagerIT extends AbstractCoreIT {
// now search by username, no results should be returned
- Results r =
- em.searchCollection( em.getApplicationRef(), "thing", new Query().addEqualityFilter( "name", name ) );
+ Results r = em.searchCollection( em.getApplicationRef(), "thing",
+ new Query().addEqualityFilter( "name", name ) );
assertEquals( 0, r.size() );
}
@@ -303,7 +309,8 @@ public class EntityManagerIT extends AbstractCoreIT {
public void testCreateAndDeleteUser() throws Exception {
LOG.info( "EntityDaoTest.testCreateAndDeleteUser" );
- UUID applicationId = setup.createApplication( "testOrganization", "testCreateAndDeleteUser" );
+ UUID applicationId = setup.createApplication(
+ "testOrganization", "testCreateAndDeleteUser" + RandomStringUtils.randomAlphabetic(20) );
EntityManager em = setup.getEmf().getEntityManager( applicationId );
@@ -344,7 +351,8 @@ public class EntityManagerIT extends AbstractCoreIT {
em.refreshIndex();
- r = em.searchCollection( em.getApplicationRef(), "users", new Query().addEqualityFilter( "username", name ) );
+ r = em.searchCollection( em.getApplicationRef(), "users",
+ new Query().addEqualityFilter( "username", name ) );
assertEquals( 1, r.size() );
@@ -357,7 +365,8 @@ public class EntityManagerIT extends AbstractCoreIT {
public void testJson() throws Exception {
LOG.info( "EntityDaoTest.testProperties" );
- UUID applicationId = setup.createApplication( "testOrganization", "testJson" );
+ UUID applicationId = setup.createApplication(
+ "testOrganization", "testJson" + RandomStringUtils.randomAlphabetic(20) );
EntityManager em = setup.getEmf().getEntityManager( applicationId );
@@ -398,7 +407,8 @@ public class EntityManagerIT extends AbstractCoreIT {
organizationEntity.setProperty( "name", "testCounterOrg" );
organizationEntity = em.create( organizationEntity );
- UUID applicationId = setup.getEmf().createApplication( "testCounterOrg", "testEntityCounters" );
+ UUID applicationId = setup.getEmf().createApplication(
+ "testCounterOrg", "testEntityCounters" + RandomStringUtils.randomAlphabetic(20) );
Map<String, Object> properties = new LinkedHashMap<String, Object>();
properties.put( "name", "testEntityCounters" );
@@ -434,7 +444,8 @@ public class EntityManagerIT extends AbstractCoreIT {
public void testCreateAndList() throws Exception {
LOG.info( "EntityDaoTest.testCreateAndDelete" );
- UUID applicationId = setup.createApplication( "testOrganization", "testCreateAndList" );
+ UUID applicationId = setup.createApplication(
+ "testOrganization", "testCreateAndList" + RandomStringUtils.randomAlphabetic(20) );
EntityManager em = setup.getEmf().getEntityManager( applicationId );
@@ -476,7 +487,8 @@ public class EntityManagerIT extends AbstractCoreIT {
@Test
public void testCorrectType() throws Exception {
- UUID applicationId = setup.createApplication( "testOrganization", "testCorrectType" );
+ UUID applicationId = setup.createApplication(
+ "testOrganization", "testCorrectType" + RandomStringUtils.randomAlphabetic(20) );
EntityManager em = setup.getEmf().getEntityManager( applicationId );
@@ -502,7 +514,8 @@ public class EntityManagerIT extends AbstractCoreIT {
public void testImmutableForcedPropChange() throws Exception {
LOG.info( "EntityDaoTest.testProperties" );
- UUID applicationId = setup.createApplication( "testOrganization", "testNamePropChanges" );
+ UUID applicationId = setup.createApplication(
+ "testOrganization", "testNamePropChanges" + RandomStringUtils.randomAlphabetic(20) );
EntityManager em = setup.getEmf().getEntityManager( applicationId );
@@ -525,7 +538,8 @@ public class EntityManagerIT extends AbstractCoreIT {
@Test
public void ownershipScopeCorrect() throws Exception {
- UUID applicationId = setup.createApplication( "testOrganization", "ownershipScopeCorrect" );
+ UUID applicationId = setup.createApplication(
+ "testOrganization", "ownershipScopeCorrect" + RandomStringUtils.randomAlphabetic(20) );
EntityManager em = setup.getEmf().getEntityManager( applicationId );
@@ -583,7 +597,8 @@ public class EntityManagerIT extends AbstractCoreIT {
public void testDeprecatedGet() throws Exception {
LOG.info( "EntityManagerIT.testDeprecatedGet" );
- UUID applicationId = setup.createApplication( "testOrganization", "testDeprecatedGet" );
+ UUID applicationId = setup.createApplication(
+ "testOrganization", "testDeprecatedGet" + RandomStringUtils.randomAlphabetic(20) );
assertNotNull( applicationId );
EntityManager em = setup.getEmf().getEntityManager( applicationId );
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/26774448/stack/core/src/test/java/org/apache/usergrid/persistence/GeoQueryBooleanTest.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/GeoQueryBooleanTest.java b/stack/core/src/test/java/org/apache/usergrid/persistence/GeoQueryBooleanTest.java
index 3b11872..a13f242 100644
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/GeoQueryBooleanTest.java
+++ b/stack/core/src/test/java/org/apache/usergrid/persistence/GeoQueryBooleanTest.java
@@ -21,6 +21,7 @@ import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.UUID;
+import org.apache.commons.lang3.RandomStringUtils;
import org.junit.Test;
import org.slf4j.Logger;
@@ -50,7 +51,8 @@ public class GeoQueryBooleanTest extends AbstractCoreIT {
log.info( "GeoQueryBooleanTest.testGeoQueryWithOr" );
- UUID applicationId = setup.createApplication( "testOrganization", "testGeoQueryWithOr" );
+ UUID applicationId = setup.createApplication(
+ "testOrganization", "testGeoQueryWithOr-" + RandomStringUtils.randomAlphabetic(20));
assertNotNull( applicationId );
EntityManager em = setup.getEmf().getEntityManager( applicationId );
@@ -116,7 +118,8 @@ public class GeoQueryBooleanTest extends AbstractCoreIT {
log.info( "GeoQueryBooleanTest.testGeoQueryWithOr" );
- UUID applicationId = setup.createApplication( "testOrganization", "testGeoQueryWithNot" );
+ UUID applicationId = setup.createApplication(
+ "testOrganization", "testGeoQueryWithNot-" + RandomStringUtils.randomAlphabetic(20) );
assertNotNull( applicationId );
EntityManager em = setup.getEmf().getEntityManager( applicationId );
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/26774448/stack/core/src/test/java/org/apache/usergrid/persistence/IndexIT.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/IndexIT.java b/stack/core/src/test/java/org/apache/usergrid/persistence/IndexIT.java
index 2f571fb..e839fa1 100644
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/IndexIT.java
+++ b/stack/core/src/test/java/org/apache/usergrid/persistence/IndexIT.java
@@ -25,6 +25,7 @@ import me.prettyprint.cassandra.serializers.ByteBufferSerializer;
import me.prettyprint.hector.api.Keyspace;
import static me.prettyprint.hector.api.factory.HFactory.createMutator;
import me.prettyprint.hector.api.mutation.Mutator;
+import org.apache.commons.lang3.RandomStringUtils;
import org.apache.usergrid.AbstractCoreIT;
import org.apache.usergrid.CoreITSuite;
import org.apache.usergrid.cassandra.Concurrent;
@@ -32,15 +33,12 @@ import org.apache.usergrid.persistence.cassandra.CassandraService;
import org.apache.usergrid.persistence.cassandra.IndexUpdate;
import org.apache.usergrid.persistence.cassandra.IndexUpdate.IndexEntry;
import org.apache.usergrid.persistence.cassandra.RelationManagerImpl;
-import org.apache.usergrid.persistence.hector.CountingMutator;
import org.apache.usergrid.persistence.index.query.Query;
import org.apache.usergrid.utils.JsonUtils;
import org.apache.usergrid.utils.UUIDUtils;
-import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.fail;
import org.junit.Test;
import org.slf4j.Logger;
@@ -62,7 +60,7 @@ public class IndexIT extends AbstractCoreIT {
public void testCollectionOrdering() throws Exception {
LOG.info( "testCollectionOrdering" );
- UUID applicationId = setup.createApplication( "testOrganization", "testCollectionOrdering" );
+ UUID applicationId = setup.createApplication( "testOrganization", "testCollectionOrdering" + RandomStringUtils.randomAlphabetic(20) );
assertNotNull( applicationId );
EntityManager em = setup.getEmf().getEntityManager( applicationId );
@@ -135,7 +133,7 @@ public class IndexIT extends AbstractCoreIT {
public void testCollectionFilters() throws Exception {
LOG.info( "testCollectionFilters" );
- UUID applicationId = setup.createApplication( "testOrganization", "testCollectionFilters" );
+ UUID applicationId = setup.createApplication( "testOrganization", "testCollectionFilters" + RandomStringUtils.randomAlphabetic(20) );
assertNotNull( applicationId );
EntityManager em = setup.getEmf().getEntityManager( applicationId );
@@ -261,7 +259,7 @@ public class IndexIT extends AbstractCoreIT {
public void testSecondarySorts() throws Exception {
LOG.info( "testSecondarySorts" );
- UUID applicationId = setup.createApplication( "testOrganization", "testSecondarySorts" );
+ UUID applicationId = setup.createApplication( "testOrganization", "testSecondarySorts" + RandomStringUtils.randomAlphabetic(20) );
assertNotNull( applicationId );
EntityManager em = setup.getEmf().getEntityManager( applicationId );
@@ -295,7 +293,7 @@ public class IndexIT extends AbstractCoreIT {
@Test
public void testPropertyUpdateWithConnection() throws Exception {
- UUID applicationId = setup.createApplication( "testOrganization", "testPropertyUpdateWithConnection" );
+ UUID applicationId = setup.createApplication( "testOrganization", "testPropertyUpdateWithConnection" + RandomStringUtils.randomAlphabetic(20) );
EntityManager em = setup.getEmf().getEntityManager( applicationId );
@@ -370,7 +368,7 @@ public class IndexIT extends AbstractCoreIT {
public void testPropertyUpdateWithConnectionEntityIndexEntryAudit() throws Exception {
UUID applicationId =
- setup.createApplication( "testOrganization", "testPropertyUpdateWithConnectionEntityIndexEntryAudit" );
+ setup.createApplication( "testOrganization", "testPropertyUpdateWithConnectionEntityIndexEntryAudit" + RandomStringUtils.randomAlphabetic(20) );
EntityManager em = setup.getEmf().getEntityManager( applicationId );
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/26774448/stack/core/src/test/java/org/apache/usergrid/persistence/PathQueryIT.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/PathQueryIT.java b/stack/core/src/test/java/org/apache/usergrid/persistence/PathQueryIT.java
index 16fae85..e5256f3 100644
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/PathQueryIT.java
+++ b/stack/core/src/test/java/org/apache/usergrid/persistence/PathQueryIT.java
@@ -25,6 +25,7 @@ import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
+import org.apache.commons.lang3.RandomStringUtils;
import org.junit.Test;
import org.apache.usergrid.AbstractCoreIT;
@@ -37,7 +38,7 @@ public class PathQueryIT extends AbstractCoreIT {
@Test
public void testUserDevicePathQuery() throws Exception {
- UUID applicationId = setup.createApplication( "testOrganization", "testUserDevicePathQuery" );
+ UUID applicationId = setup.createApplication( "testOrganization", "testUserDevicePathQuery" + RandomStringUtils.randomAlphabetic(20) );
EntityManager em = setup.getEmf().getEntityManager( applicationId );
List<Entity> users = new ArrayList<Entity>();
@@ -106,7 +107,7 @@ public class PathQueryIT extends AbstractCoreIT {
@Test
public void testGroupUserDevicePathQuery() throws Exception {
- UUID applicationId = setup.createApplication( "testOrganization", "testGroupUserDevicePathQuery" );
+ UUID applicationId = setup.createApplication( "testOrganization", "testGroupUserDevicePathQuery" + RandomStringUtils.randomAlphabetic(20) );
EntityManager em = setup.getEmf().getEntityManager( applicationId );
List<Entity> groups = new ArrayList<Entity>();
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/26774448/stack/core/src/test/java/org/apache/usergrid/persistence/PerformanceEntityRebuildIndexTest.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/PerformanceEntityRebuildIndexTest.java b/stack/core/src/test/java/org/apache/usergrid/persistence/PerformanceEntityRebuildIndexTest.java
index 28974ac..574d366 100644
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/PerformanceEntityRebuildIndexTest.java
+++ b/stack/core/src/test/java/org/apache/usergrid/persistence/PerformanceEntityRebuildIndexTest.java
@@ -63,7 +63,7 @@ public class PerformanceEntityRebuildIndexTest extends AbstractCoreIT {
private static final MetricRegistry registry = new MetricRegistry();
private Slf4jReporter reporter;
- private static final long RUNTIME_MS = TimeUnit.SECONDS.toMillis( 5 );
+ private static final long RUNTIME_MS = TimeUnit.SECONDS.toMillis( 3 );
private static final long WRITE_DELAY_MS = 10;
@@ -207,8 +207,8 @@ public class PerformanceEntityRebuildIndexTest extends AbstractCoreIT {
};
try {
-// setup.getEmf().refreshIndex();
- setup.getEmf().rebuildAllIndexes( po );
+
+ setup.getEmf().rebuildApplicationIndexes( em.getApplicationId(), po );
reporter.report();
registry.remove( meterName );
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/26774448/stack/core/src/test/java/org/apache/usergrid/persistence/PermissionsIT.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/PermissionsIT.java b/stack/core/src/test/java/org/apache/usergrid/persistence/PermissionsIT.java
index 87aca64..bdd82ea 100644
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/PermissionsIT.java
+++ b/stack/core/src/test/java/org/apache/usergrid/persistence/PermissionsIT.java
@@ -22,6 +22,7 @@ import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
+import org.apache.commons.lang3.RandomStringUtils;
import org.junit.Test;
import org.slf4j.Logger;
@@ -49,7 +50,7 @@ public class PermissionsIT extends AbstractCoreIT {
@Test
public void testPermissionTimeout() throws Exception {
- UUID applicationId = setup.createApplication( "permissionsTest", "testPermissionTimeout" );
+ UUID applicationId = setup.createApplication( "permissionsTest", "testPermissionTimeout" + RandomStringUtils.randomAlphabetic(20) );
assertNotNull( applicationId );
@@ -99,7 +100,7 @@ public class PermissionsIT extends AbstractCoreIT {
public void testPermissions() throws Exception {
logger.info( "PermissionsIT.testPermissions" );
- UUID applicationId = setup.createApplication( "testOrganization", "testPermissions" );
+ UUID applicationId = setup.createApplication( "testOrganization", "testPermissions" + RandomStringUtils.randomAlphabetic(20) );
assertNotNull( applicationId );
EntityManager em = setup.getEmf().getEntityManager( applicationId );
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/26774448/stack/core/src/test/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImplIT.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImplIT.java b/stack/core/src/test/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImplIT.java
index dc7ab3c..4cc0dbd 100644
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImplIT.java
+++ b/stack/core/src/test/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImplIT.java
@@ -22,6 +22,7 @@ import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
+import org.apache.commons.lang3.RandomStringUtils;
import org.junit.AfterClass;
import org.junit.Before;
@@ -88,8 +89,10 @@ public class EntityManagerFactoryImplIT extends AbstractCoreIT {
@Before
public void initTracing() {
- traceTagManager = CoreITSuite.cassandraResource.getBean( "traceTagManager", TraceTagManager.class );
- traceTagReporter = CoreITSuite.cassandraResource.getBean( "traceTagReporter", TraceTagReporter.class );
+ traceTagManager = CoreITSuite.cassandraResource.getBean(
+ "traceTagManager", TraceTagManager.class );
+ traceTagReporter = CoreITSuite.cassandraResource.getBean(
+ "traceTagReporter", TraceTagReporter.class );
}
@@ -105,7 +108,7 @@ public class EntityManagerFactoryImplIT extends AbstractCoreIT {
traceTagManager.attach( traceTag );
logger.info( "EntityDaoTest.testCreateAndGet" );
- UUID applicationId = createApplication( "EntityManagerFactoryImplIT", "testCreateAndGet" );
+ UUID applicationId = createApplication( "EntityManagerFactoryImplIT", "testCreateAndGet" + RandomStringUtils.randomAlphabetic(20) );
logger.info( "Application id " + applicationId );
EntityManager em = emf.getEntityManager( applicationId );
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/26774448/stack/core/src/test/java/org/apache/usergrid/persistence/query/AbstractIteratingQueryIT.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/query/AbstractIteratingQueryIT.java b/stack/core/src/test/java/org/apache/usergrid/persistence/query/AbstractIteratingQueryIT.java
index 4d371fb..d8f31ff 100644
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/query/AbstractIteratingQueryIT.java
+++ b/stack/core/src/test/java/org/apache/usergrid/persistence/query/AbstractIteratingQueryIT.java
@@ -50,7 +50,8 @@ public abstract class AbstractIteratingQueryIT {
@ClassRule
public static CoreITSetup setup = new CoreITSetupImpl(
- ConcurrentCoreIteratorITSuite.cassandraResource, ConcurrentCoreIteratorITSuite.elasticSearchResource );
+ ConcurrentCoreIteratorITSuite.cassandraResource,
+ ConcurrentCoreIteratorITSuite.elasticSearchResource );
@Rule
public CoreApplication app = new CoreApplication( setup );
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/26774448/stack/core/src/test/resources/log4j.properties
----------------------------------------------------------------------
diff --git a/stack/core/src/test/resources/log4j.properties b/stack/core/src/test/resources/log4j.properties
index 2aa9983..2b156b3 100644
--- a/stack/core/src/test/resources/log4j.properties
+++ b/stack/core/src/test/resources/log4j.properties
@@ -43,8 +43,9 @@ log4j.logger.org.apache.usergrid.persistence.PerformanceEntityReadTest=DEBUG
log4j.logger.org.apache.usergrid.persistence.PerformanceEntityRebuildIndexTest=DEBUG
#log4j.logger.org.apache.usergrid.persistence=INFO
-log4j.logger.org.apache.usergrid.corepersistence=DEBUG
+log4j.logger.org.apache.usergrid.corepersistence.migration=WARN
#log4j.logger.org.apache.usergrid.corepersistence.CpSetup=INFO
+#log4j.logger.org.apache.usergrid.corepersistence=DEBUG
#log4j.logger.org.apache.usergrid.corepersistence.CpEntityManagerFactory=DEBUG
#log4j.logger.org.apache.usergrid.corepersistence.CpEntityManager=DEBUG
#log4j.logger.org.apache.usergrid.corepersistence.CpRelationManager=DEBUG
@@ -54,7 +55,7 @@ log4j.logger.org.apache.usergrid.corepersistence=DEBUG
#log4j.logger.org.apache.usergrid.persistence.CollectionIT=DEBUG
#log4j.logger.org.apache.usergrid.persistence.collection=DEBUG
-log4j.logger.org.apache.usergrid.persistence.index=DEBUG
+#log4j.logger.org.apache.usergrid.persistence.index=DEBUG
#log4j.logger.org.elasticsearch=DEBUG
#log4j.logger.org.apache.cassandra.service.StorageProxy=DEBUG, stdout
[27/41] incubator-usergrid git commit: fix apns
Posted by sf...@apache.org.
fix apns
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/62249154
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/62249154
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/62249154
Branch: refs/heads/UG-rest-test-framework-overhaul
Commit: 622491547fe0ea42a7c7bbd63611c804023caa7f
Parents: 461c192
Author: Shawn Feldman <sf...@apache.org>
Authored: Mon Dec 8 12:34:14 2014 -0700
Committer: Shawn Feldman <sf...@apache.org>
Committed: Mon Dec 8 12:34:14 2014 -0700
----------------------------------------------------------------------
.../services/notifications/apns/NotificationsServiceIT.java | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/62249154/stack/services/src/test/java/org/apache/usergrid/services/notifications/apns/NotificationsServiceIT.java
----------------------------------------------------------------------
diff --git a/stack/services/src/test/java/org/apache/usergrid/services/notifications/apns/NotificationsServiceIT.java b/stack/services/src/test/java/org/apache/usergrid/services/notifications/apns/NotificationsServiceIT.java
index 3f42777..3b9206e 100644
--- a/stack/services/src/test/java/org/apache/usergrid/services/notifications/apns/NotificationsServiceIT.java
+++ b/stack/services/src/test/java/org/apache/usergrid/services/notifications/apns/NotificationsServiceIT.java
@@ -191,8 +191,8 @@ public class NotificationsServiceIT extends AbstractServiceNotificationIT {
entity = results.getEntitiesMap().get(notification.getUuid());
assertNotNull(entity);
- checkReceipts(notification, 1);
- checkStatistics(notification, 1, 0);
+ checkReceipts(notification, 2);
+ checkStatistics(notification, 2, 0);
}
@Test
@@ -579,7 +579,7 @@ public class NotificationsServiceIT extends AbstractServiceNotificationIT {
app.getEntityManager().refreshIndex();
- checkReceipts(notification, 1);
+ checkReceipts(notification, 2);
}
@Ignore("todo: how can I mock this?")
[02/41] incubator-usergrid git commit: Mostly working. Need to finish
with setting cursor to empty on last request
Posted by sf...@apache.org.
Mostly working. Need to finish with setting cursor to empty on last request
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/23727010
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/23727010
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/23727010
Branch: refs/heads/UG-rest-test-framework-overhaul
Commit: 23727010cc0bd3ca5a2363b6de5577a6845ed599
Parents: bd79d37
Author: Todd Nine <tn...@apigee.com>
Authored: Wed Dec 3 17:53:34 2014 -0700
Committer: Todd Nine <tn...@apigee.com>
Committed: Wed Dec 3 17:53:34 2014 -0700
----------------------------------------------------------------------
.../usergrid/scenarios/UserScenarios.scala | 42 +++++++++++++++-----
.../simulations/GetUsersSimulation.scala | 2 +-
2 files changed, 34 insertions(+), 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/23727010/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 2ca6d21..2bbe9a3 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
@@ -57,14 +57,6 @@ import io.gatling.core.Predef._
- val getUsersWithCursor = exec(
- http("GET user")
- .get("/users?cursor=${cursor}")
- .headers(Headers.jsonAuthorized)
- .check(status.saveAs("userStatus"), jsonPath("$..entities").saveAs("users"))
- )
-
-
/**
* Try to get a user, if it returns a 404, create the user
*/
@@ -90,6 +82,27 @@ import io.gatling.core.Predef._
)
}
+ /**
+ * Get a collection of users without a cursor. Sets the cursor and entities array as "users"
+ */
+ val getUsersWithoutCursor = exec(
+ http("GET user")
+ .get("/users")
+ .headers(Headers.jsonAuthorized)
+ .check(status.is(200), jsonPath("$..entities").saveAs("users"), jsonPath("$..cursor").saveAs("cursor"))
+ )
+
+ /**
+ * Get the next page of users with the cursor, expects the value "cursor" to be present in teh session
+ */
+ val getUsersWithCursor = exec(
+ http("GET user")
+ .get("/users?cursor=${cursor}")
+ .headers(Headers.jsonAuthorized)
+ .check(status.is(200), jsonPath("$..entities").saveAs("users"), jsonPath("$..cursor").saveAs("cursor"))
+ )
+
+
val deleteUserByUsername = exec(
http("DELETE user")
.delete("/users/${username}")
@@ -119,5 +132,16 @@ import io.gatling.core.Predef._
.feed(Settings.getInfiniteUserFeeder())
.exec(UserScenarios.postUser)
- val getUsersIndefinitely = scenario("Get Users").exec()
+ /**
+ * Get the users a page at a time until exhausted
+ */
+ val getUsersToEnd = scenario("Get Users").exec(
+ //get the management token
+ TokenScenarios.getManagementToken,
+ //get users without a cursor
+ getUsersWithoutCursor
+ //as long as we have a cursor, keep getting results
+ ).asLongAs(session => session("cursor").as[String] != "") {
+ exec(getUsersWithCursor)
+ }
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/23727010/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/GetUsersSimulation.scala
----------------------------------------------------------------------
diff --git a/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/GetUsersSimulation.scala b/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/GetUsersSimulation.scala
index eefeff1..cceab3c 100755
--- a/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/GetUsersSimulation.scala
+++ b/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/GetUsersSimulation.scala
@@ -37,7 +37,7 @@ class GetUsersSimulation extends Simulation {
setUp(
- UserScenarios.postUsersInfinitely
+ UserScenarios.getUsersToEnd
.inject(
/**
* injection steps take from this forum post
[03/41] incubator-usergrid git commit: add delete and put methods
Posted by sf...@apache.org.
add delete and put methods
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/3079231c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/3079231c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/3079231c
Branch: refs/heads/UG-rest-test-framework-overhaul
Commit: 3079231c92fc100caf5b02aa6e3e98b11b522a1f
Parents: 2372701
Author: Shawn Feldman <sf...@apache.org>
Authored: Wed Dec 3 20:54:55 2014 -0700
Committer: Shawn Feldman <sf...@apache.org>
Committed: Wed Dec 3 20:54:55 2014 -0700
----------------------------------------------------------------------
.../usergrid/scenarios/UserScenarios.scala | 38 ++++++++++++++------
1 file changed, 27 insertions(+), 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/3079231c/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 2bbe9a3..eeecffa 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,7 +35,9 @@ import io.gatling.core.Predef._
http("GET user")
.get("/users/${username}")
.headers(Headers.jsonAuthorized)
- .check(status.saveAs("userStatus"), jsonPath("$..entities[0]").exists, 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"),
+ jsonPath("$..entities[0].username").exists, jsonPath("$..entities[0].uuid").saveAs("username"))
)
@@ -66,22 +68,36 @@ import io.gatling.core.Predef._
exec(postUser)
}
-
- val putUser =
- exec(getUserByUsername)
- .doIf("${userStatus}", "200") {
- exec(
- http("POST geolocated Users")
- .put("/users")
- .body(new StringBody( """{"location":{"latitude":"${latitude}","longitude":"${longitude}"},"username":"${username}",
+ val putUser = exec(
+ http("PUT geolocated Users")
+ .put("/users/${username}")
+ .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.is(200), jsonPath("$..entities[0].uuid").saveAs("userId"))
+ .check(status.is(200), jsonPath("$..entities[0].uuid").saveAs("userId"))
- )
+ )
+
+ val putUserIfExists =
+ exec(getUserByUsername)
+ .doIf("${userStatus}", "200") {
+ putUser
}
+ val deleteUser = exec(
+ http("PUT geolocated Users")
+ .delete("/users/${username}")
+ .check(status.is(200))
+
+ )
+
+ val deleteUserIfExists =
+ exec(getUserByUsername)
+ .doIf("${userStatus}", "200") {
+ deleteUser
+ }
+
/**
* Get a collection of users without a cursor. Sets the cursor and entities array as "users"
*/
[30/41] incubator-usergrid git commit: fixed abstract class name
Posted by sf...@apache.org.
fixed abstract class 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/4bf4d715
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/4bf4d715
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/4bf4d715
Branch: refs/heads/UG-rest-test-framework-overhaul
Commit: 4bf4d715fc11877d672541e0aa04714f7f0c2a9d
Parents: e9cecff
Author: Shawn Feldman <sf...@apache.org>
Authored: Mon Dec 8 15:15:00 2014 -0700
Committer: Shawn Feldman <sf...@apache.org>
Committed: Mon Dec 8 15:15:00 2014 -0700
----------------------------------------------------------------------
.../persistence/queue/DefaultQueueManager.java | 4 ++--
.../AbstractServiceNotificationIT.java | 16 +---------------
.../notifications/apns/NotificationsServiceIT.java | 2 --
.../notifications/gcm/NotificationsServiceIT.java | 9 +++++++--
4 files changed, 10 insertions(+), 21 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/4bf4d715/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/DefaultQueueManager.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/DefaultQueueManager.java b/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/DefaultQueueManager.java
index 354aa7b..d9fddd3 100644
--- a/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/DefaultQueueManager.java
+++ b/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/DefaultQueueManager.java
@@ -24,13 +24,13 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
-import java.util.concurrent.ConcurrentLinkedQueue;
+import java.util.concurrent.ArrayBlockingQueue;
/**
* Default queue manager implementation, uses in memory linked queue
*/
public class DefaultQueueManager implements QueueManager {
- public ConcurrentLinkedQueue<QueueMessage> queue = new ConcurrentLinkedQueue<>();
+ public ArrayBlockingQueue<QueueMessage> queue = new ArrayBlockingQueue<>(10000);
@Override
public synchronized List<QueueMessage> getMessages(int limit, int transactionTimeout, int waitTime, Class klass) {
List<QueueMessage> returnQueue = new ArrayList<>();
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/4bf4d715/stack/services/src/test/java/org/apache/usergrid/services/notifications/AbstractServiceNotificationIT.java
----------------------------------------------------------------------
diff --git a/stack/services/src/test/java/org/apache/usergrid/services/notifications/AbstractServiceNotificationIT.java b/stack/services/src/test/java/org/apache/usergrid/services/notifications/AbstractServiceNotificationIT.java
index 1fd6f3e..55bb91f 100644
--- a/stack/services/src/test/java/org/apache/usergrid/services/notifications/AbstractServiceNotificationIT.java
+++ b/stack/services/src/test/java/org/apache/usergrid/services/notifications/AbstractServiceNotificationIT.java
@@ -39,28 +39,14 @@ import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.fail;
-public class AbstractServiceNotificationIT extends AbstractServiceIT {
+public abstract class AbstractServiceNotificationIT extends AbstractServiceIT {
private NotificationsService ns;
- @Rule
- public TestName name = new TestName();
-
- @BeforeClass
- public static void beforeClass() {
- }
-
- @Before
- public void before() throws Exception {
-
- }
-
protected NotificationsService getNotificationService(){
ns = (NotificationsService) app.getSm().getService("notifications");
return ns;
}
-
-
protected Notification scheduleNotificationAndWait(Notification notification)
throws Exception {
long timeout = System.currentTimeMillis() + 60000;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/4bf4d715/stack/services/src/test/java/org/apache/usergrid/services/notifications/apns/NotificationsServiceIT.java
----------------------------------------------------------------------
diff --git a/stack/services/src/test/java/org/apache/usergrid/services/notifications/apns/NotificationsServiceIT.java b/stack/services/src/test/java/org/apache/usergrid/services/notifications/apns/NotificationsServiceIT.java
index 3b9206e..5fda74b 100644
--- a/stack/services/src/test/java/org/apache/usergrid/services/notifications/apns/NotificationsServiceIT.java
+++ b/stack/services/src/test/java/org/apache/usergrid/services/notifications/apns/NotificationsServiceIT.java
@@ -68,11 +68,9 @@ public class NotificationsServiceIT extends AbstractServiceNotificationIT {
}
- @Override
@Before
public void before() throws Exception {
- super.before();
// create apns notifier //
app.clear();
app.put("name", notifierName);
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/4bf4d715/stack/services/src/test/java/org/apache/usergrid/services/notifications/gcm/NotificationsServiceIT.java
----------------------------------------------------------------------
diff --git a/stack/services/src/test/java/org/apache/usergrid/services/notifications/gcm/NotificationsServiceIT.java b/stack/services/src/test/java/org/apache/usergrid/services/notifications/gcm/NotificationsServiceIT.java
index ce0dca7..8d6fb70 100644
--- a/stack/services/src/test/java/org/apache/usergrid/services/notifications/gcm/NotificationsServiceIT.java
+++ b/stack/services/src/test/java/org/apache/usergrid/services/notifications/gcm/NotificationsServiceIT.java
@@ -21,6 +21,7 @@ import org.apache.usergrid.persistence.entities.*;
import org.apache.usergrid.persistence.queue.DefaultQueueManager;
import org.apache.usergrid.services.notifications.*;
import org.junit.*;
+import org.junit.rules.TestName;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -34,6 +35,7 @@ import static org.apache.usergrid.services.notifications.ApplicationQueueManager
public class NotificationsServiceIT extends AbstractServiceNotificationIT {
+
private static final Logger logger = LoggerFactory
.getLogger(NotificationsServiceIT.class);
@@ -54,15 +56,18 @@ public class NotificationsServiceIT extends AbstractServiceNotificationIT {
private NotificationsService ns;
private QueueListener listener;
+
+
+
+
@BeforeClass
public static void setup(){
+
}
- @Override
@Before
public void before() throws Exception {
- super.before();
// create gcm notifier //
[28/41] incubator-usergrid git commit: fix gcm
Posted by sf...@apache.org.
fix gcm
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/e9cecff1
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/e9cecff1
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/e9cecff1
Branch: refs/heads/UG-rest-test-framework-overhaul
Commit: e9cecff1d0df14691c021fb682a9f84bdb3382ed
Parents: 6224915
Author: Shawn Feldman <sf...@apache.org>
Authored: Mon Dec 8 12:36:24 2014 -0700
Committer: Shawn Feldman <sf...@apache.org>
Committed: Mon Dec 8 12:36:24 2014 -0700
----------------------------------------------------------------------
.../services/notifications/gcm/NotificationsServiceIT.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e9cecff1/stack/services/src/test/java/org/apache/usergrid/services/notifications/gcm/NotificationsServiceIT.java
----------------------------------------------------------------------
diff --git a/stack/services/src/test/java/org/apache/usergrid/services/notifications/gcm/NotificationsServiceIT.java b/stack/services/src/test/java/org/apache/usergrid/services/notifications/gcm/NotificationsServiceIT.java
index 4b41d13..ce0dca7 100644
--- a/stack/services/src/test/java/org/apache/usergrid/services/notifications/gcm/NotificationsServiceIT.java
+++ b/stack/services/src/test/java/org/apache/usergrid/services/notifications/gcm/NotificationsServiceIT.java
@@ -163,7 +163,7 @@ public class NotificationsServiceIT extends AbstractServiceNotificationIT {
// perform push //
notification = scheduleNotificationAndWait(notification);
- checkReceipts(notification, 1);
+ checkReceipts(notification, 2);
}
@Test
[25/41] incubator-usergrid git commit: add comment
Posted by sf...@apache.org.
add comment
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/8cdfaf95
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/8cdfaf95
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/8cdfaf95
Branch: refs/heads/UG-rest-test-framework-overhaul
Commit: 8cdfaf9547da2a69a34b9b548167201c6a1a3068
Parents: 983b20b
Author: Shawn Feldman <sf...@apache.org>
Authored: Mon Dec 8 10:14:55 2014 -0700
Committer: Shawn Feldman <sf...@apache.org>
Committed: Mon Dec 8 10:14:55 2014 -0700
----------------------------------------------------------------------
.../usergrid/persistence/index/impl/EsEntityIndexBatchImpl.java | 1 +
1 file changed, 1 insertion(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/8cdfaf95/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexBatchImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexBatchImpl.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexBatchImpl.java
index 51fe63b..f2cbc6b 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexBatchImpl.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexBatchImpl.java
@@ -187,6 +187,7 @@ public class EsEntityIndexBatchImpl implements EntityIndexBatch {
log.debug( "De-indexing type {} with documentId '{}'" , entityType, indexId);
String[] indexes = entityIndex.getIndexes(EntityIndex.AliasType.Read);
+ //get the default index if no alias exists yet
if(indexes == null ||indexes.length == 0){
indexes = new String[]{indexIdentifier.getIndex(null)};
}
[09/41] incubator-usergrid git commit: Updated delete to include 404
responses as valid
Posted by sf...@apache.org.
Updated delete to include 404 responses as valid
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/38871cc1
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/38871cc1
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/38871cc1
Branch: refs/heads/UG-rest-test-framework-overhaul
Commit: 38871cc1bf1ed976feb69b499a8d89cc4693817b
Parents: 9ad779e
Author: Todd Nine <tn...@apigee.com>
Authored: Thu Dec 4 16:22:50 2014 -0700
Committer: Todd Nine <tn...@apigee.com>
Committed: Thu Dec 4 16:22:50 2014 -0700
----------------------------------------------------------------------
.../main/scala/org/apache/usergrid/scenarios/UserScenarios.scala | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/38871cc1/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 2cfdef2..c589365 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
@@ -103,7 +103,7 @@ object UserScenarios {
http("DELETE geolocated Users")
.delete("/users/${username}")
.headers(Headers.jsonAuthorized)
- .check(status.is(200))
+ .check(status.in(Seq(200,404)))
)
val deleteUserIfExists =
[15/41] incubator-usergrid git commit: Minor formatting changes only.
Posted by sf...@apache.org.
Minor formatting changes 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/e71a68fb
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/e71a68fb
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/e71a68fb
Branch: refs/heads/UG-rest-test-framework-overhaul
Commit: e71a68fbfa4c267930837551fce19196df822289
Parents: 2677444
Author: Dave Johnson <dm...@apigee.com>
Authored: Fri Dec 5 16:46:21 2014 -0500
Committer: Dave Johnson <dm...@apigee.com>
Committed: Fri Dec 5 16:46:21 2014 -0500
----------------------------------------------------------------------
.../migration/EntityDataMigrationIT.java | 137 ++++++++++---------
.../usergrid/persistence/PathQueryIT.java | 9 +-
2 files changed, 76 insertions(+), 70 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e71a68fb/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 d5f2fe1..b9b7d24 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
@@ -79,7 +79,8 @@ public class EntityDataMigrationIT extends AbstractCoreIT {
* Rule to do the resets we need
*/
@Rule
- public MigrationTestRule migrationTestRule = new MigrationTestRule( app, CpSetup.getInjector() ,EntityDataMigration.class );
+ public MigrationTestRule migrationTestRule =
+ new MigrationTestRule( app, CpSetup.getInjector() ,EntityDataMigration.class );
@Before
public void setup() {
@@ -129,36 +130,36 @@ public class EntityDataMigrationIT extends AbstractCoreIT {
//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 ) {
+ .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 ) {
+ //add all versions from history to our comparison
+ for ( final Id id : entity.entityIds ) {
- CollectionScope scope = CpNamingUtils
- .getCollectionScopeNameFromEntityType(
- entity.applicationScope.getApplication(),
- id.getType() );
+ CollectionScope scope = CpNamingUtils
+ .getCollectionScopeNameFromEntityType(
+ entity.applicationScope.getApplication(),
+ id.getType() );
- final Iterator<MvccEntity> versions = v1Strategy
- .loadDescendingHistory( scope, id, UUIDGenerator.newTimeUUID(),
- 100 );
+ final Iterator<MvccEntity> versions = v1Strategy
+ .loadDescendingHistory( scope, id, UUIDGenerator.newTimeUUID(),
+ 100 );
- while ( versions.hasNext() ) {
+ while ( versions.hasNext() ) {
- final MvccEntity mvccEntity = versions.next();
+ final MvccEntity mvccEntity = versions.next();
- savedEntities.add( mvccEntity );
+ savedEntities.add( mvccEntity );
- createdEntityIds.remove( mvccEntity.getId() );
+ createdEntityIds.remove( mvccEntity.getId() );
- entityIds.add( id );
- }
- }
- }
- } ).toBlocking().lastOrDefault( null );
+ entityIds.add( id );
+ }
+ }
+ }
+ } ).toBlocking().lastOrDefault( null );
assertEquals( "Newly saved entities encountered", 0, createdEntityIds.size() );
assertTrue( "Saved new entities", savedEntities.size() > 0 );
@@ -181,70 +182,72 @@ public class EntityDataMigrationIT extends AbstractCoreIT {
//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 ) {
+ .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() );
+ CollectionScope scope = CpNamingUtils
+ .getCollectionScopeNameFromEntityType(
+ entity.applicationScope.getApplication(),
+ id.getType() );
- final Iterator<MvccEntity> versions = v2Strategy
- .loadDescendingHistory( scope, id,
- UUIDGenerator.newTimeUUID(), 100 );
+ final Iterator<MvccEntity> versions = v2Strategy
+ .loadDescendingHistory( scope, id,
+ UUIDGenerator.newTimeUUID(), 100 );
- while ( versions.hasNext() ) {
+ while ( versions.hasNext() ) {
- final MvccEntity mvccEntity = versions.next();
+ final MvccEntity mvccEntity = versions.next();
- savedEntities.remove( mvccEntity );
- }
- }
- }
- }
+ savedEntities.remove( mvccEntity );
+ }
+ }
+ }
+ }
- ).toBlocking().lastOrDefault( null );
+ ).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
+ //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 ) {
+ .doOnNext( new Action1<AllEntitiesInSystemObservable.ApplicationEntityGroup>() {
+ @Override
+ public void call(
+ final AllEntitiesInSystemObservable
+ .ApplicationEntityGroup entity ) {
- final EntityManager em = emf.getEntityManager( entity.applicationScope.getApplication().getUuid() );
+ final EntityManager em = emf.getEntityManager(
+ entity.applicationScope.getApplication().getUuid() );
- //add all versions from history to our comparison
- for ( final Id id : entity.entityIds ) {
+ //add all versions from history to our comparison
+ for ( final Id id : entity.entityIds ) {
- try {
- final Entity emEntity = em.get( SimpleEntityRef.fromId( id ) );
+ 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);
- }
- }
- }
- }
+ if(emEntity != null){
+ entityIds.remove( id );
+ }
+ }
+ catch ( Exception e ) {
+ throw new RuntimeException("Error loading entity", e);
+ }
+ }
+ }
+ }
- ).toBlocking().lastOrDefault( null );
+ ).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/e71a68fb/stack/core/src/test/java/org/apache/usergrid/persistence/PathQueryIT.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/PathQueryIT.java b/stack/core/src/test/java/org/apache/usergrid/persistence/PathQueryIT.java
index e5256f3..61ac16f 100644
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/PathQueryIT.java
+++ b/stack/core/src/test/java/org/apache/usergrid/persistence/PathQueryIT.java
@@ -38,7 +38,8 @@ public class PathQueryIT extends AbstractCoreIT {
@Test
public void testUserDevicePathQuery() throws Exception {
- UUID applicationId = setup.createApplication( "testOrganization", "testUserDevicePathQuery" + RandomStringUtils.randomAlphabetic(20) );
+ UUID applicationId = setup.createApplication(
+ "testOrganization", "testUserDevicePathQuery" + RandomStringUtils.randomAlphabetic(20) );
EntityManager em = setup.getEmf().getEntityManager( applicationId );
List<Entity> users = new ArrayList<Entity>();
@@ -93,7 +94,8 @@ public class PathQueryIT extends AbstractCoreIT {
deviceQuery.addFilter( "index >= 2" );
int expectedDeviceQuerySize = 3;
- PathQuery<EntityRef> usersPQ = new PathQuery<EntityRef>( new SimpleEntityRef( em.getApplicationRef()), userQuery );
+ PathQuery<EntityRef> usersPQ = new PathQuery<EntityRef>(
+ new SimpleEntityRef( em.getApplicationRef()), userQuery );
PathQuery<Entity> devicesPQ = usersPQ.chain( deviceQuery );
HashSet set = new HashSet( expectedUserQuerySize * expectedDeviceQuerySize );
Iterator<Entity> i = devicesPQ.iterator( em );
@@ -107,7 +109,8 @@ public class PathQueryIT extends AbstractCoreIT {
@Test
public void testGroupUserDevicePathQuery() throws Exception {
- UUID applicationId = setup.createApplication( "testOrganization", "testGroupUserDevicePathQuery" + RandomStringUtils.randomAlphabetic(20) );
+ UUID applicationId = setup.createApplication(
+ "testOrganization", "testGroupUserDevicePathQuery" + RandomStringUtils.randomAlphabetic(20) );
EntityManager em = setup.getEmf().getEntityManager( applicationId );
List<Entity> groups = new ArrayList<Entity>();
[38/41] incubator-usergrid git commit: Merge remote-tracking branch
'origin/two-dot-o' into USERGRID-252
Posted by sf...@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/5d4ce726
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/5d4ce726
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/5d4ce726
Branch: refs/heads/UG-rest-test-framework-overhaul
Commit: 5d4ce726117ddb8ba67e3df86180751d201a3561
Parents: 692eff8 a63b856
Author: Todd Nine <tn...@apigee.com>
Authored: Tue Dec 9 16:08:50 2014 -0700
Committer: Todd Nine <tn...@apigee.com>
Committed: Tue Dec 9 16:08:50 2014 -0700
----------------------------------------------------------------------
.../corepersistence/CpEntityManager.java | 230 ++++++++++---------
.../corepersistence/util/CpEntityMapUtils.java | 32 ++-
.../batch/job/SchedulerRuntimeIntervalIT.java | 49 ++--
.../migration/EntityDataMigrationIT.java | 139 +++++------
.../migration/EntityTypeMappingMigrationIT.java | 89 +++----
.../apache/usergrid/persistence/CounterIT.java | 89 ++++---
.../usergrid/persistence/CountingMutatorIT.java | 4 +-
.../persistence/EntityDictionaryIT.java | 11 +-
.../usergrid/persistence/EntityManagerIT.java | 47 ++--
.../persistence/GeoQueryBooleanTest.java | 7 +-
.../apache/usergrid/persistence/IndexIT.java | 14 +-
.../usergrid/persistence/PathQueryIT.java | 10 +-
.../PerformanceEntityRebuildIndexTest.java | 6 +-
.../usergrid/persistence/PermissionsIT.java | 5 +-
.../cassandra/EntityManagerFactoryImplIT.java | 9 +-
.../query/AbstractIteratingQueryIT.java | 3 +-
stack/core/src/test/resources/log4j.properties | 5 +-
.../data/DataMigrationManagerImpl.java | 29 ++-
.../persistence/index/IndexIdentifier.java | 4 +
.../index/impl/EsEntityIndexImpl.java | 80 ++++---
.../persistence/queue/DefaultQueueManager.java | 68 ++++++
.../usergrid/services/TestQueueManager.java | 65 ------
.../AbstractServiceNotificationIT.java | 16 +-
.../apns/NotificationsServiceIT.java | 12 +-
.../gcm/NotificationsServiceIT.java | 15 +-
25 files changed, 570 insertions(+), 468 deletions(-)
----------------------------------------------------------------------
[37/41] incubator-usergrid git commit: move method back to entityindex
Posted by sf...@apache.org.
move method back to entityindex
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/18197e3d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/18197e3d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/18197e3d
Branch: refs/heads/UG-rest-test-framework-overhaul
Commit: 18197e3de65c29db764218534f846d825bcb4b0f
Parents: 574fe64
Author: Shawn Feldman <sf...@apache.org>
Authored: Tue Dec 9 16:02:14 2014 -0700
Committer: Shawn Feldman <sf...@apache.org>
Committed: Tue Dec 9 16:02:14 2014 -0700
----------------------------------------------------------------------
.../usergrid/corepersistence/CpEntityManagerFactory.java | 4 +---
.../apache/usergrid/persistence/index/AliasedEntityIndex.java | 7 -------
.../org/apache/usergrid/persistence/index/EntityIndex.java | 7 +++++++
3 files changed, 8 insertions(+), 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/18197e3d/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 56eb258..7016d3c 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
@@ -704,9 +704,7 @@ public class CpEntityManagerFactory implements EntityManagerFactory, Application
@Override
public void addIndex(final UUID applicationId,final String indexSuffix,final int shards,final int replicas){
EntityIndex entityIndex = getManagerCache().getEntityIndex(CpNamingUtils.getApplicationScope(applicationId));
- if(entityIndex instanceof AliasedEntityIndex) {
- ((AliasedEntityIndex)entityIndex).addIndex(indexSuffix, shards, replicas);
- }
+ entityIndex.addIndex(indexSuffix, shards, replicas);
}
@Override
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/18197e3d/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/AliasedEntityIndex.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/AliasedEntityIndex.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/AliasedEntityIndex.java
index 15a0d45..118b7ad 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/AliasedEntityIndex.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/AliasedEntityIndex.java
@@ -38,13 +38,6 @@ public interface AliasedEntityIndex extends EntityIndex{
*/
public void addAlias(final String indexSuffix);
- /**
- * Create an index and add to alias, will create alias and remove any old index from write alias if alias already exists
- * @param indexSuffix index name
- * @param shards
- * @param replicas
- */
- public void addIndex(final String indexSuffix, final int shards, final int replicas);
/**
* type of alias
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/18197e3d/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 549f87e..f1da568 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
@@ -38,6 +38,13 @@ public interface EntityIndex {
*/
public void initializeIndex();
+ /**
+ * Create an index and add to alias, will create alias and remove any old index from write alias if alias already exists
+ * @param indexSuffix index name
+ * @param shards
+ * @param replicas
+ */
+ public void addIndex(final String indexSuffix, final int shards, final int replicas);
/**
* Create the index batch.
[17/41] incubator-usergrid git commit: Fix to ensure tests passes
when run multiple times without clearing database.
Posted by sf...@apache.org.
Fix to ensure tests passes when run multiple times without clearing database.
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/8088c63f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/8088c63f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/8088c63f
Branch: refs/heads/UG-rest-test-framework-overhaul
Commit: 8088c63f392d30d6248a0c25a3d9fb552c915489
Parents: e71a68f
Author: Dave Johnson <dm...@apigee.com>
Authored: Mon Dec 8 09:55:38 2014 -0500
Committer: Dave Johnson <dm...@apigee.com>
Committed: Mon Dec 8 09:55:38 2014 -0500
----------------------------------------------------------------------
.../apache/usergrid/persistence/CounterIT.java | 21 ++++++++++----------
1 file changed, 11 insertions(+), 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/8088c63f/stack/core/src/test/java/org/apache/usergrid/persistence/CounterIT.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/CounterIT.java b/stack/core/src/test/java/org/apache/usergrid/persistence/CounterIT.java
index 470a6f2..ab7d41e 100644
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/CounterIT.java
+++ b/stack/core/src/test/java/org/apache/usergrid/persistence/CounterIT.java
@@ -187,6 +187,15 @@ public class CounterIT extends AbstractCoreIT {
EntityManager em = setup.getEmf().getEntityManager( setup.getEmf().getManagementAppId() );
+ // get counts at start of test
+ Query query = new Query();
+ query.addCounterFilter( "admin.logins:*:*:*" );
+ query.setStartTime( ts );
+ query.setFinishTime( System.currentTimeMillis() );
+ query.setResolution( CounterResolution.SIX_HOUR );
+ Results or = em.getAggregateCounters( query );
+ long originalCount = or.getCounters().get( 0 ).getValues().get( 0 ).getValue();
+
Map<String, Long> counts = em.getApplicationCounters();
long originalAdminLoginsCount = counts.get( "admin.logins" ).longValue();
@@ -240,17 +249,9 @@ public class CounterIT extends AbstractCoreIT {
assertEquals( 1,
r.getCounters().get( 0 ).getValues().get( 0 ).getValue() - originalAdminLoginsCount );
- // counts = em.getEntityCounters(organizationEntity.getUuid());
- // LOG.info(JsonUtils.mapToJsonString(counts));
- Query query = new Query();
- query.addCounterFilter( "admin.logins:*:*:*" );
- query.setStartTime( ts );
- query.setFinishTime( System.currentTimeMillis() );
- query.setResolution( CounterResolution.SIX_HOUR );
- //query.setPad(true);
-
r = em.getAggregateCounters( query );
LOG.info( JsonUtils.mapToJsonString( r.getCounters() ) );
- assertEquals( 1, r.getCounters().get( 0 ).getValues().get( 0 ).getValue() );
+ assertEquals( 1,
+ r.getCounters().get( 0 ).getValues().get( 0 ).getValue() - originalCount );
}
}
[13/41] incubator-usergrid git commit: Merge remote-tracking branch
'origin/two-dot-o' into USERGRID-252
Posted by sf...@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/1b239b7f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/1b239b7f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/1b239b7f
Branch: refs/heads/UG-rest-test-framework-overhaul
Commit: 1b239b7fa7da3e95175286e47422a955580ee6a7
Parents: d52a185 c4973e9
Author: Todd Nine <tn...@apigee.com>
Authored: Fri Dec 5 14:12:05 2014 -0700
Committer: Todd Nine <tn...@apigee.com>
Committed: Fri Dec 5 14:12:05 2014 -0700
----------------------------------------------------------------------
.../org/apache/usergrid/persistence/GeoIT.java | 771 +++++++++----------
1 file changed, 371 insertions(+), 400 deletions(-)
----------------------------------------------------------------------
[04/41] incubator-usergrid git commit: new scenario for put and delete
Posted by sf...@apache.org.
new scenario for put and delete
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/55428142
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/55428142
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/55428142
Branch: refs/heads/UG-rest-test-framework-overhaul
Commit: 554281425ddee0cc269639e89faa25312fbf9bc4
Parents: 3079231
Author: Shawn Feldman <sf...@apache.org>
Authored: Thu Dec 4 09:20:40 2014 -0700
Committer: Shawn Feldman <sf...@apache.org>
Committed: Thu Dec 4 09:20:40 2014 -0700
----------------------------------------------------------------------
.../apache/usergrid/scenarios/UserScenarios.scala | 17 ++++++++++++++++-
1 file changed, 16 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/55428142/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 eeecffa..090ffea 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
@@ -146,7 +146,22 @@ import io.gatling.core.Predef._
*/
val postUsersInfinitely = scenario("Post Users")
.feed(Settings.getInfiniteUserFeeder())
- .exec(UserScenarios.postUser)
+ .exec(postUser)
+
+
+ /**
+ * Puts a new user every time
+ */
+ val putUsersInfinitely = scenario("Post Users")
+ .feed(Settings.getInfiniteUserFeeder())
+ .exec(putUser)
+
+ /**
+ * Deletes user every time
+ */
+ val deleteUsersInfinitely = scenario("Post Users")
+ .feed(Settings.getInfiniteUserFeeder())
+ .exec(deleteUser)
/**
* Get the users a page at a time until exhausted
[19/41] incubator-usergrid git commit: fix deletes so we remove from
all
Posted by sf...@apache.org.
fix deletes so we remove from all
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/4b90e97e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/4b90e97e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/4b90e97e
Branch: refs/heads/UG-rest-test-framework-overhaul
Commit: 4b90e97e16253559d51479dd57a59aacf3f61466
Parents: c4973e9
Author: Shawn Feldman <sf...@apache.org>
Authored: Mon Dec 8 08:40:54 2014 -0700
Committer: Shawn Feldman <sf...@apache.org>
Committed: Mon Dec 8 08:40:54 2014 -0700
----------------------------------------------------------------------
.../usergrid/persistence/index/EntityIndex.java | 7 ++++
.../index/impl/EsEntityIndexBatchImpl.java | 24 ++++++++----
.../index/impl/EsEntityIndexImpl.java | 18 ++++++---
.../persistence/index/impl/EntityIndexTest.java | 41 +++++++++++++++++++-
4 files changed, 76 insertions(+), 14 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/4b90e97e/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 4a653b3..6e7779f 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
@@ -47,6 +47,13 @@ public interface EntityIndex {
public void addIndex(final String indexSuffix, final int shards, final int replicas);
/**
+ * Get the indexes for an alias
+ * @param aliasName name of alias
+ * @return list of index names
+ */
+ public String[] getIndexes(final String aliasName);
+
+ /**
* Create the index batch.
*/
public EntityIndexBatch createBatch();
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/4b90e97e/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexBatchImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexBatchImpl.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexBatchImpl.java
index a3ca8a5..35c89ae 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexBatchImpl.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexBatchImpl.java
@@ -26,7 +26,7 @@ import java.util.Map;
import java.util.Set;
import java.util.UUID;
-import org.apache.usergrid.persistence.index.IndexIdentifier;
+import org.apache.usergrid.persistence.index.*;
import org.elasticsearch.action.bulk.BulkItemResponse;
import org.elasticsearch.action.bulk.BulkRequestBuilder;
import org.elasticsearch.action.bulk.BulkResponse;
@@ -36,9 +36,6 @@ import org.slf4j.LoggerFactory;
import org.apache.usergrid.persistence.core.scope.ApplicationScope;
import org.apache.usergrid.persistence.core.util.ValidationUtils;
-import org.apache.usergrid.persistence.index.EntityIndexBatch;
-import org.apache.usergrid.persistence.index.IndexFig;
-import org.apache.usergrid.persistence.index.IndexScope;
import org.apache.usergrid.persistence.index.query.CandidateResult;
import org.apache.usergrid.persistence.index.utils.IndexValidationUtils;
import org.apache.usergrid.persistence.model.entity.Entity;
@@ -59,6 +56,9 @@ import org.apache.usergrid.persistence.model.field.UUIDField;
import org.apache.usergrid.persistence.model.field.value.EntityObject;
import com.google.common.base.Joiner;
+import rx.Observable;
+import rx.functions.Action1;
+import rx.schedulers.Schedulers;
import static org.apache.usergrid.persistence.index.impl.IndexingUtils.ANALYZED_STRING_PREFIX;
import static org.apache.usergrid.persistence.index.impl.IndexingUtils.BOOLEAN_PREFIX;
@@ -92,13 +92,16 @@ public class EsEntityIndexBatchImpl implements EntityIndexBatch {
private final FailureMonitor failureMonitor;
+ private final EntityIndex entityIndex;
+
public EsEntityIndexBatchImpl( final ApplicationScope applicationScope, final Client client,
- final IndexFig config, final int autoFlushSize, final FailureMonitor failureMonitor ) {
+ final IndexFig config, final int autoFlushSize, final FailureMonitor failureMonitor, final EntityIndex entityIndex ) {
this.applicationScope = applicationScope;
this.client = client;
this.failureMonitor = failureMonitor;
+ this.entityIndex = entityIndex;
this.indexIdentifier = IndexingUtils.createIndexIdentifier(config, applicationScope);
this.alias = indexIdentifier.getAlias();
this.refresh = config.isForcedRefresh();
@@ -162,7 +165,7 @@ public class EsEntityIndexBatchImpl implements EntityIndexBatch {
final String context = createContextName( indexScope );
final String entityType = id.getType();
- String indexId = createIndexDocId( id, version, context );
+ final String indexId = createIndexDocId( id, version, context );
if ( log.isDebugEnabled() ) {
@@ -181,8 +184,15 @@ public class EsEntityIndexBatchImpl implements EntityIndexBatch {
log.debug( "De-indexing type {} with documentId '{}'" , entityType, indexId);
+ final String[] indexes = entityIndex.getIndexes(alias.getReadAlias());
+ //get all indexes then flush everyone
+ Observable.from(indexes).subscribeOn(Schedulers.io()).forEach(new Action1<String>() {
+ @Override
+ public void call(String index) {
+ bulkRequest.add(client.prepareDelete(index, entityType, indexId).setRefresh(refresh));
- bulkRequest.add( client.prepareDelete(alias.getWriteAlias(), entityType, indexId ).setRefresh( refresh ) );
+ }
+ });
log.debug( "Deindexed Entity with index id " + indexId );
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/4b90e97e/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java
index d546092..13d07d6 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java
@@ -178,9 +178,9 @@ public class EsEntityIndexImpl implements EntityIndex {
Boolean isAck;
String indexName = indexIdentifier.getIndex(indexSuffix);
final AdminClient adminClient = esProvider.getClient().admin();
- //remove write alias, can only have one
- ImmutableOpenMap<String,List<AliasMetaData>> aliasMap = adminClient.indices().getAliases(new GetAliasesRequest(alias.getWriteAlias())).actionGet().getAliases();
- String[] indexNames = aliasMap.keys().toArray(String.class);
+ final String aliasName = alias.getWriteAlias();
+ String[] indexNames = getIndexes( aliasName);
+
for(String currentIndex : indexNames){
isAck = adminClient.indices().prepareAliases().removeAlias(currentIndex,alias.getWriteAlias()).execute().actionGet().isAcknowledged();
logger.info("Removed Index Name [{}] from Alias=[{}] ACK=[{}]",currentIndex, alias, isAck);
@@ -198,6 +198,14 @@ public class EsEntityIndexImpl implements EntityIndex {
}
}
+ @Override
+ public String[] getIndexes(String aliasName) {
+ final AdminClient adminClient = esProvider.getClient().admin();
+ //remove write alias, can only have one
+ ImmutableOpenMap<String,List<AliasMetaData>> aliasMap = adminClient.indices().getAliases(new GetAliasesRequest(aliasName)).actionGet().getAliases();
+ return aliasMap.keys().toArray(String.class);
+ }
+
/**
* Tests writing a document to a new index to ensure it's working correctly. See this post:
@@ -262,7 +270,7 @@ public class EsEntityIndexImpl implements EntityIndex {
@Override
public EntityIndexBatch createBatch() {
return new EsEntityIndexBatchImpl(
- applicationScope, esProvider.getClient(), config, 1000, failureMonitor );
+ applicationScope, esProvider.getClient(), config, 1000, failureMonitor, this );
}
@@ -424,7 +432,7 @@ public class EsEntityIndexImpl implements EntityIndex {
@Override
public boolean doOp() {
try {
- esProvider.getClient().admin().indices().prepareRefresh( alias.getWriteAlias() ).execute().actionGet();
+ esProvider.getClient().admin().indices().prepareRefresh( alias.getReadAlias() ).execute().actionGet();
logger.debug( "Refreshed index: " + alias);
return true;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/4b90e97e/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityIndexTest.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityIndexTest.java b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityIndexTest.java
index 13d1552..ced682b 100644
--- a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityIndexTest.java
+++ b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityIndexTest.java
@@ -25,6 +25,7 @@ import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
+import org.apache.usergrid.persistence.index.query.CandidateResult;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.slf4j.Logger;
@@ -139,6 +140,41 @@ public class EntityIndexTest extends BaseIT {
testQuery(indexScope, searchTypes, entityIndex, "name = 'Lowe Kelley'", 1 );
}
+ @Test
+ public void testDeleteByQueryWithAlias() throws IOException {
+ Id appId = new SimpleId( "application" );
+
+ ApplicationScope applicationScope = new ApplicationScopeImpl( appId );
+
+ EntityIndex entityIndex = eif.createEntityIndex(applicationScope);
+ entityIndex.initializeIndex();
+
+ final String entityType = "thing";
+ IndexScope indexScope = new IndexScopeImpl( appId, "things" );
+ final SearchTypes searchTypes = SearchTypes.fromTypes( entityType );
+
+ insertJsonBlob(entityIndex, entityType, indexScope, "/sample-large.json",1,0);
+
+ entityIndex.refresh();
+
+ entityIndex.addIndex("v2", 1,0);
+
+ insertJsonBlob(entityIndex, entityType, indexScope, "/sample-large.json",1,0);
+
+ entityIndex.refresh();
+ CandidateResults crs = testQuery(indexScope, searchTypes, entityIndex, "name = 'Bowers Oneil'", 2);
+
+ EntityIndexBatch entityIndexBatch = entityIndex.createBatch();
+ entityIndexBatch.deindex(indexScope, crs.get(0));
+ entityIndexBatch.deindex(indexScope,crs.get(1));
+ entityIndexBatch.executeAndRefresh();
+ entityIndex.refresh();
+
+ //Hilda Youn
+ testQuery(indexScope, searchTypes, entityIndex, "name = 'Bowers Oneil'", 0);
+
+ }
+
private void insertJsonBlob(EntityIndex entityIndex, String entityType, IndexScope indexScope, String filePath,final int max,final int startIndex) throws IOException {
InputStream is = this.getClass().getResourceAsStream( filePath );
ObjectMapper mapper = new ObjectMapper();
@@ -172,7 +208,7 @@ public class EntityIndexTest extends BaseIT {
- if ( count++ > max ) {
+ if ( ++count > max ) {
break;
}
}
@@ -221,7 +257,7 @@ public class EntityIndexTest extends BaseIT {
}
- private void testQuery(final IndexScope scope, final SearchTypes searchTypes, final EntityIndex entityIndex, final String queryString, final int num ) {
+ private CandidateResults testQuery(final IndexScope scope, final SearchTypes searchTypes, final EntityIndex entityIndex, final String queryString, final int num ) {
StopWatch timer = new StopWatch();
timer.start();
@@ -232,6 +268,7 @@ public class EntityIndexTest extends BaseIT {
assertEquals( num, candidateResults.size() );
log.debug( "Query time {}ms", timer.getTime() );
+ return candidateResults;
}
[08/41] incubator-usergrid git commit: Added session injection of a
singleton token for removing post from report
Posted by sf...@apache.org.
Added session injection of a singleton token for removing post from report
Created 2 distinct scenarios for users get by username and get by page.
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/9ad779eb
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/9ad779eb
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/9ad779eb
Branch: refs/heads/UG-rest-test-framework-overhaul
Commit: 9ad779ebf6e27f1e676207752afb53e8da9fdfae
Parents: c64fcba
Author: Todd Nine <tn...@apigee.com>
Authored: Thu Dec 4 16:12:56 2014 -0700
Committer: Todd Nine <tn...@apigee.com>
Committed: Thu Dec 4 16:12:56 2014 -0700
----------------------------------------------------------------------
.../apache/usergrid/helpers/Extractors.scala | 11 +++++
.../usergrid/scenarios/UserScenarios.scala | 26 ++++++----
.../org/apache/usergrid/settings/Headers.scala | 6 ++-
.../simulations/GetUserPagesSimulation.scala | 51 ++++++++++++++++++++
.../simulations/GetUsersSimulation.scala | 2 +-
5 files changed, 85 insertions(+), 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/9ad779eb/stack/loadtests/src/main/scala/org/apache/usergrid/helpers/Extractors.scala
----------------------------------------------------------------------
diff --git a/stack/loadtests/src/main/scala/org/apache/usergrid/helpers/Extractors.scala b/stack/loadtests/src/main/scala/org/apache/usergrid/helpers/Extractors.scala
index 055bf8d..3e85712 100644
--- a/stack/loadtests/src/main/scala/org/apache/usergrid/helpers/Extractors.scala
+++ b/stack/loadtests/src/main/scala/org/apache/usergrid/helpers/Extractors.scala
@@ -66,6 +66,17 @@ object Extractors {
}
+ val ManagementToken: String = Setup.getManagementToken()
+
+
+ /**
+ * Get the management token for the admin username and password in settings, then inject it into the session
+ * under the variable "authToken"
+ * @return
+ */
+ def injectStaticTokenToSession() : Expression[Session] = {
+ session => session.set("authToken", ManagementToken)
+ }
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/9ad779eb/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 e48b60c..2cfdef2 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
@@ -24,7 +24,6 @@ import org.apache.usergrid.datagenerators.FeederGenerator
import org.apache.usergrid.settings.{Headers, Settings, Utils}
import org.apache.usergrid.helpers.Extractors._
-import scala.util.parsing.json.JSONArray
object UserScenarios {
@@ -86,9 +85,11 @@ object UserScenarios {
exec(postUser)
}
+
val putUser = exec(
http("PUT geolocated Users")
.put("/users/${username}")
+ .headers(Headers.jsonAuthorized)
.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}",
@@ -99,10 +100,10 @@ object UserScenarios {
val deleteUser = exec(
- http("PUT geolocated Users")
+ http("DELETE geolocated Users")
.delete("/users/${username}")
+ .headers(Headers.jsonAuthorized)
.check(status.is(200))
-
)
val deleteUserIfExists =
@@ -175,27 +176,34 @@ object UserScenarios {
/**
* Puts a new user every time
*/
- val putUsersInfinitely = scenario("Put Users")
+ val putUsersInfinitely = scenario("Put Users").exec(injectStaticTokenToSession)
.feed(Settings.getInfiniteUserFeeder())
.exec(putUser)
/**
* Deletes user every time
*/
- val deleteUsersInfinitely = scenario("Delete Users")
+ val deleteUsersInfinitely = scenario("Delete Users").exec(injectStaticTokenToSession)
.feed(Settings.getInfiniteUserFeeder())
.exec(deleteUser)
/**
* Get the users a page at a time until exhausted
*/
- val getUsersToEnd = scenario("Get Users")
- //get the management token
- .exec(TokenScenarios.getManagementToken)
+ val getUserPagesToEnd = scenario("Get User Pages").exec(injectStaticTokenToSession)
//get users without a cursor
.exec(getUsersWithoutCursor)
//as long as we have a cursor, keep getting results
.asLongAs(stringParamExists(SessionVarCursor)) {
exec(getUsersWithCursor)
- }
+ }.exec(sessionFunction => {
+ sessionFunction
+ })
+
+ val getUsersByUsername = scenario("Get User By Username").exec(injectStaticTokenToSession)
+ .feed(Settings.getInfiniteUserFeeder())
+ //get users without a cursor
+ .exec(getUserByUsername)
+
+
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/9ad779eb/stack/loadtests/src/main/scala/org/apache/usergrid/settings/Headers.scala
----------------------------------------------------------------------
diff --git a/stack/loadtests/src/main/scala/org/apache/usergrid/settings/Headers.scala b/stack/loadtests/src/main/scala/org/apache/usergrid/settings/Headers.scala
index 9b735e5..6cd6f2e 100755
--- a/stack/loadtests/src/main/scala/org/apache/usergrid/settings/Headers.scala
+++ b/stack/loadtests/src/main/scala/org/apache/usergrid/settings/Headers.scala
@@ -16,7 +16,9 @@
*/
package org.apache.usergrid.settings
-/**
+ import org.apache.usergrid.helpers.Setup
+
+ /**
*
*/
object Headers {
@@ -40,4 +42,6 @@ object Headers {
+
+
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/9ad779eb/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/GetUserPagesSimulation.scala
----------------------------------------------------------------------
diff --git a/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/GetUserPagesSimulation.scala b/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/GetUserPagesSimulation.scala
new file mode 100755
index 0000000..5d76ca0
--- /dev/null
+++ b/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/GetUserPagesSimulation.scala
@@ -0,0 +1,51 @@
+/*
+ * 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.simulations
+
+import io.gatling.core.Predef._
+import org.apache.usergrid.helpers.Setup
+import org.apache.usergrid.scenarios.UserScenarios
+import org.apache.usergrid.settings.Settings
+
+/**
+ * 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 GetUserPagesSimulation extends Simulation {
+
+ println("Begin setup")
+ Setup.setupOrg()
+ Setup.setupApplication()
+ println("End Setup")
+
+
+ setUp(
+ UserScenarios.getUserPagesToEnd
+ .inject(
+ /**
+ * injection steps take from this forum post
+ * https://groups.google.com/forum/#!topic/gatling/JfYHaWCbA-w
+ */
+ rampUsers(Settings.maxPossibleUsers) over Settings.rampTime,
+ constantUsersPerSec(Settings.maxPossibleUsers) during Settings.duration
+
+ )).protocols(Settings.httpConf.acceptHeader("application/json"))
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/9ad779eb/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/GetUsersSimulation.scala
----------------------------------------------------------------------
diff --git a/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/GetUsersSimulation.scala b/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/GetUsersSimulation.scala
index cceab3c..a088e27 100755
--- a/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/GetUsersSimulation.scala
+++ b/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/GetUsersSimulation.scala
@@ -37,7 +37,7 @@ class GetUsersSimulation extends Simulation {
setUp(
- UserScenarios.getUsersToEnd
+ UserScenarios.getUsersByUsername
.inject(
/**
* injection steps take from this forum post
[18/41] incubator-usergrid git commit: Ignored awaiting fix for
USERGRID-267
Posted by sf...@apache.org.
Ignored awaiting fix for USERGRID-267
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/10a1d7d2
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/10a1d7d2
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/10a1d7d2
Branch: refs/heads/UG-rest-test-framework-overhaul
Commit: 10a1d7d2e1e5be633164fb78f4f9e6d9d7dad9a1
Parents: 8088c63
Author: Dave Johnson <dm...@apigee.com>
Authored: Mon Dec 8 10:02:24 2014 -0500
Committer: Dave Johnson <dm...@apigee.com>
Committed: Mon Dec 8 10:02:24 2014 -0500
----------------------------------------------------------------------
.../org/apache/usergrid/batch/job/SchedulerRuntimeIntervalIT.java | 2 ++
1 file changed, 2 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/10a1d7d2/stack/core/src/test/java/org/apache/usergrid/batch/job/SchedulerRuntimeIntervalIT.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/batch/job/SchedulerRuntimeIntervalIT.java b/stack/core/src/test/java/org/apache/usergrid/batch/job/SchedulerRuntimeIntervalIT.java
index b6544d7..523f41d 100644
--- a/stack/core/src/test/java/org/apache/usergrid/batch/job/SchedulerRuntimeIntervalIT.java
+++ b/stack/core/src/test/java/org/apache/usergrid/batch/job/SchedulerRuntimeIntervalIT.java
@@ -29,6 +29,7 @@ import org.apache.usergrid.persistence.entities.JobData;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
+import org.junit.Ignore;
/**
@@ -36,6 +37,7 @@ import static org.junit.Assert.assertTrue;
* Tests saturation at each point of the runtime as well
*/
@Concurrent
+@Ignore("Ignored awaiting fix for USERGRID-267")
public class SchedulerRuntimeIntervalIT extends AbstractSchedulerRuntimeIT {
private static final Logger logger =
[11/41] incubator-usergrid git commit: Fix broken tests that could
not be run multiple times without deleting all data from C* and ES after each
run.
Posted by sf...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/26774448/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 b9cc851..a9719b7 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
@@ -65,7 +65,9 @@ public class DataMigrationManagerImpl implements DataMigrationManager {
@Inject
public DataMigrationManagerImpl( final MigrationInfoSerialization migrationInfoSerialization,
final Set<DataMigration> migrations ) {
- Preconditions.checkNotNull( migrationInfoSerialization, "migrationInfoSerialization must not be null" );
+
+ Preconditions.checkNotNull( migrationInfoSerialization,
+ "migrationInfoSerialization must not be null" );
Preconditions.checkNotNull( migrations, "migrations must not be null" );
this.migrationInfoSerialization = migrationInfoSerialization;
@@ -87,9 +89,9 @@ public class DataMigrationManagerImpl implements DataMigrationManager {
final Class<? extends DataMigration> currentClass = migration.getClass();
- throw new DataMigrationException(
- String.format( "Data migrations must be unique. Both classes %s and %s have version %d",
- existingClass, currentClass, version ) );
+ throw new DataMigrationException( String.format(
+ "Data migrations must be unique. Both classes %s and %s have version %d",
+ existingClass, currentClass, version ) );
}
migrationTreeMap.put( version, migration );
@@ -112,7 +114,8 @@ public class DataMigrationManagerImpl implements DataMigrationManager {
migrationTreeMap.lastKey() );
//we have our migrations to run, execute them
- final NavigableMap<Integer, DataMigration> migrationsToRun = migrationTreeMap.tailMap( currentVersion, false );
+ final NavigableMap<Integer, DataMigration> migrationsToRun =
+ migrationTreeMap.tailMap( currentVersion, false );
CassandraProgressObserver observer = new CassandraProgressObserver();
@@ -185,7 +188,8 @@ public class DataMigrationManagerImpl implements DataMigrationManager {
public void resetToVersion( final int version ) {
final int highestAllowed = migrationTreeMap.lastKey();
- Preconditions.checkArgument( version <= highestAllowed, "You cannot set a version higher than the max of " + highestAllowed);
+ Preconditions.checkArgument( version <= highestAllowed,
+ "You cannot set a version higher than the max of " + highestAllowed);
Preconditions.checkArgument( version >= 0, "You must specify a version of 0 or greater" );
migrationInfoSerialization.setVersion( version );
@@ -221,7 +225,8 @@ public class DataMigrationManagerImpl implements DataMigrationManager {
@Override
public void failed( final int migrationVersion, final String reason ) {
- final String storedMessage = String.format( "Failed to migrate, reason is appended. Error '%s'", reason );
+ final String storedMessage = String.format(
+ "Failed to migrate, reason is appended. Error '%s'", reason );
update( migrationVersion, storedMessage );
@@ -240,13 +245,14 @@ public class DataMigrationManagerImpl implements DataMigrationManager {
throwable.printStackTrace( new PrintWriter( stackTrace ) );
- final String storedMessage = String.format( "Failed to migrate, reason is appended. Error '%s' %s", reason,
- stackTrace.toString() );
+ final String storedMessage = String.format(
+ "Failed to migrate, reason is appended. Error '%s' %s", reason, stackTrace.toString() );
update( migrationVersion, storedMessage );
- LOG.error( "Unable to migrate version {} due to reason {}.", migrationVersion, reason, throwable );
+ LOG.error( "Unable to migrate version {} due to reason {}.",
+ migrationVersion, reason, throwable );
failed = true;
@@ -256,7 +262,8 @@ public class DataMigrationManagerImpl implements DataMigrationManager {
@Override
public void update( final int migrationVersion, final String message ) {
- final String formattedOutput = String.format( "Migration version %d. %s", migrationVersion, message );
+ final String formattedOutput = String.format(
+ "Migration version %d. %s", migrationVersion, message );
//Print this to the info log
LOG.info( formattedOutput );
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/26774448/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/IndexIdentifier.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/IndexIdentifier.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/IndexIdentifier.java
index 86b5611..f23dc36 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/IndexIdentifier.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/IndexIdentifier.java
@@ -85,4 +85,8 @@ public class IndexIdentifier{
}
}
+ public String toString() {
+ return "application: " + applicationScope.getApplication().getUuid();
+ }
+
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/26774448/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java
index d546092..eb050d6 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java
@@ -21,7 +21,6 @@ package org.apache.usergrid.persistence.index.impl;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
-import java.util.Map;
import java.util.UUID;
import java.util.concurrent.atomic.AtomicBoolean;
@@ -120,7 +119,9 @@ public class EsEntityIndexImpl implements EntityIndex {
@Inject
- public EsEntityIndexImpl( @Assisted final ApplicationScope appScope, final IndexFig config, final EsProvider provider ) {
+ public EsEntityIndexImpl( @Assisted final ApplicationScope appScope, final IndexFig config,
+ final EsProvider provider ) {
+
ValidationUtils.validateApplicationScope( appScope );
this.applicationScope = appScope;
this.esProvider = provider;
@@ -153,9 +154,14 @@ public class EsEntityIndexImpl implements EntityIndex {
//Create index
try {
final AdminClient admin = esProvider.getClient().admin();
- Settings settings = ImmutableSettings.settingsBuilder().put("index.number_of_shards", numberOfShards)
- .put("index.number_of_replicas", numberOfReplicas).build();
- final CreateIndexResponse cir = admin.indices().prepareCreate(indexName).setSettings(settings).execute().actionGet();
+ Settings settings = ImmutableSettings.settingsBuilder()
+ .put("index.number_of_shards", numberOfShards)
+ .put("index.number_of_replicas", numberOfReplicas)
+ .build();
+ final CreateIndexResponse cir = admin.indices().prepareCreate(indexName)
+ .setSettings(settings)
+ .execute()
+ .actionGet();
logger.info("Created new Index Name [{}] ACK=[{}]", indexName, cir.isAcknowledged());
} catch (IndexAlreadyExistsException e) {
logger.info("Index Name [{}] already exists", indexName);
@@ -178,19 +184,27 @@ public class EsEntityIndexImpl implements EntityIndex {
Boolean isAck;
String indexName = indexIdentifier.getIndex(indexSuffix);
final AdminClient adminClient = esProvider.getClient().admin();
+
//remove write alias, can only have one
- ImmutableOpenMap<String,List<AliasMetaData>> aliasMap = adminClient.indices().getAliases(new GetAliasesRequest(alias.getWriteAlias())).actionGet().getAliases();
+ ImmutableOpenMap<String,List<AliasMetaData>> aliasMap = adminClient.indices()
+ .getAliases(new GetAliasesRequest(alias.getWriteAlias())).actionGet().getAliases();
String[] indexNames = aliasMap.keys().toArray(String.class);
+
for(String currentIndex : indexNames){
- isAck = adminClient.indices().prepareAliases().removeAlias(currentIndex,alias.getWriteAlias()).execute().actionGet().isAcknowledged();
- logger.info("Removed Index Name [{}] from Alias=[{}] ACK=[{}]",currentIndex, alias, isAck);
+ isAck = adminClient.indices().prepareAliases().removeAlias(currentIndex,
+ alias.getWriteAlias()).execute().actionGet().isAcknowledged();
+ logger.info("Removed Index Name [{}] from Alias=[{}] ACK=[{}]",currentIndex, alias, isAck);
}
+
//add read alias
- isAck = adminClient.indices().prepareAliases().addAlias(indexName, alias.getReadAlias()).execute().actionGet().isAcknowledged();
+ isAck = adminClient.indices().prepareAliases().addAlias(
+ indexName, alias.getReadAlias()).execute().actionGet().isAcknowledged();
logger.info("Created new read Alias Name [{}] ACK=[{}]", alias, isAck);
+
//add write alias
- isAck = adminClient.indices().prepareAliases().addAlias(indexName, alias.getWriteAlias()).execute().actionGet().isAcknowledged();
+ isAck = adminClient.indices().prepareAliases().addAlias(
+ indexName, alias.getWriteAlias()).execute().actionGet().isAcknowledged();
logger.info("Created new write Alias Name [{}] ACK=[{}]", alias, isAck);
} catch (Exception e) {
@@ -217,17 +231,19 @@ public class EsEntityIndexImpl implements EntityIndex {
public boolean doOp() {
final String tempId = UUIDGenerator.newTimeUUID().toString();
- esProvider.getClient().prepareIndex( alias.getWriteAlias(), VERIFY_TYPE, tempId ).setSource( DEFAULT_PAYLOAD )
- .get();
+ esProvider.getClient().prepareIndex( alias.getWriteAlias(), VERIFY_TYPE, tempId )
+ .setSource( DEFAULT_PAYLOAD ).get();
- logger.info( "Successfully created new document with docId {} in index {} and type {}", tempId,
- alias, VERIFY_TYPE );
+ logger.info( "Successfully created new document with docId {} "
+ + "in index {} and type {}", tempId, alias, VERIFY_TYPE );
// delete all types, this way if we miss one it will get cleaned up
- esProvider.getClient().prepareDeleteByQuery( alias.getWriteAlias() ).setTypes(VERIFY_TYPE)
- .setQuery( MATCH_ALL_QUERY_BUILDER ).get();
+ esProvider.getClient().prepareDeleteByQuery( alias.getWriteAlias() )
+ .setTypes(VERIFY_TYPE)
+ .setQuery( MATCH_ALL_QUERY_BUILDER ).get();
- logger.info( "Successfully deleted all documents in index {} and type {}", alias, VERIFY_TYPE );
+ logger.info( "Successfully deleted all documents in index {} and type {}",
+ alias, VERIFY_TYPE );
return true;
@@ -279,10 +295,10 @@ public class EsEntityIndexImpl implements EntityIndex {
SearchResponse searchResponse;
if ( query.getCursor() == null ) {
- SearchRequestBuilder srb = esProvider.getClient().prepareSearch( alias.getReadAlias() ).setTypes(entityTypes)
- .setScroll(cursorTimeout + "m").setQuery(qb);
-
-
+ SearchRequestBuilder srb = esProvider.getClient().prepareSearch( alias.getReadAlias() )
+ .setTypes(entityTypes)
+ .setScroll(cursorTimeout + "m")
+ .setQuery(qb);
final FilterBuilder fb = query.createFilterBuilder();
@@ -333,8 +349,8 @@ public class EsEntityIndexImpl implements EntityIndex {
if ( logger.isDebugEnabled() ) {
- logger.debug( "Searching index {}\n scope{} \n type {}\n query {} ", new Object[] {
- this.alias, context, entityTypes, srb
+ logger.debug( "Searching index {}\n scope{} \n type {}\n query {} ",
+ new Object[] { this.alias, context, entityTypes, srb
} );
}
@@ -424,7 +440,8 @@ public class EsEntityIndexImpl implements EntityIndex {
@Override
public boolean doOp() {
try {
- esProvider.getClient().admin().indices().prepareRefresh( alias.getWriteAlias() ).execute().actionGet();
+ esProvider.getClient().admin().indices().prepareRefresh( alias.getWriteAlias() )
+ .execute().actionGet();
logger.debug( "Refreshed index: " + alias);
return true;
@@ -460,12 +477,14 @@ public class EsEntityIndexImpl implements EntityIndex {
final String context = IndexingUtils.createContextName(scope);
final SearchTypes searchTypes = SearchTypes.fromTypes( id.getType() );
- final QueryBuilder queryBuilder = QueryBuilders.termQuery( IndexingUtils.ENTITY_CONTEXT_FIELDNAME, context );
+ final QueryBuilder queryBuilder =
+ QueryBuilders.termQuery( IndexingUtils.ENTITY_CONTEXT_FIELDNAME, context );
- final SearchRequestBuilder srb =
- esProvider.getClient().prepareSearch( alias.getReadAlias() ).setTypes(searchTypes.getTypeNames())
- .setScroll(cursorTimeout + "m").setQuery(queryBuilder);
+ final SearchRequestBuilder srb = esProvider.getClient().prepareSearch( alias.getReadAlias() )
+ .setTypes(searchTypes.getTypeNames())
+ .setScroll(cursorTimeout + "m")
+ .setQuery(queryBuilder);
@@ -554,9 +573,8 @@ public class EsEntityIndexImpl implements EntityIndex {
public Health getIndexHealth() {
try {
- ClusterHealthResponse chr = esProvider.getClient().admin().cluster()
- .health(new ClusterHealthRequest(new String[]{indexIdentifier.getIndex(null)}))
- .get();
+ ClusterHealthResponse chr = esProvider.getClient().admin().cluster().health(
+ new ClusterHealthRequest(new String[]{indexIdentifier.getIndex(null)})).get();
return Health.valueOf( chr.getStatus().name() );
}
catch ( Exception ex ) {
[22/41] incubator-usergrid git commit: Ignore two migration tests
awaiting fix for USERGRID-268
Posted by sf...@apache.org.
Ignore two migration tests awaiting fix for USERGRID-268
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/20164769
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/20164769
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/20164769
Branch: refs/heads/UG-rest-test-framework-overhaul
Commit: 20164769a0c03a40699e739f1c59ac9b40cd0d60
Parents: 10a1d7d
Author: Dave Johnson <dm...@apigee.com>
Authored: Mon Dec 8 11:23:16 2014 -0500
Committer: Dave Johnson <dm...@apigee.com>
Committed: Mon Dec 8 11:23:16 2014 -0500
----------------------------------------------------------------------
.../usergrid/corepersistence/migration/EntityDataMigrationIT.java | 2 ++
.../corepersistence/migration/EntityTypeMappingMigrationIT.java | 2 ++
2 files changed, 4 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/20164769/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 b9b7d24..af8bbed 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
@@ -57,6 +57,7 @@ import rx.functions.Action1;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
+import org.junit.Ignore;
public class EntityDataMigrationIT extends AbstractCoreIT {
@@ -96,6 +97,7 @@ public class EntityDataMigrationIT extends AbstractCoreIT {
@Test
+ @Ignore("Awaiting fix for USERGRID-268")
public void testDataMigration() throws Throwable {
assertEquals( "version 3 expected", 3, entityDataMigration.getVersion() );
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/20164769/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 837997c..266fb17 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
@@ -49,6 +49,7 @@ import rx.functions.Action1;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
+import org.junit.Ignore;
public class EntityTypeMappingMigrationIT extends AbstractCoreIT {
@@ -85,6 +86,7 @@ public class EntityTypeMappingMigrationIT extends AbstractCoreIT {
@Test
+ @Ignore("Ignored awaiting fix for USERGRID-268")
public void testIdMapping() throws Throwable {
assertEquals( "version 1 expected", 1, entityTypeMappingMigration.getVersion() );
[21/41] incubator-usergrid git commit: get indexes for alias
Posted by sf...@apache.org.
get indexes for alias
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/4d04da8e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/4d04da8e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/4d04da8e
Branch: refs/heads/UG-rest-test-framework-overhaul
Commit: 4d04da8e58eff556e2f1aab1dbdc9b6c7eb1f740
Parents: 7e34742
Author: Shawn Feldman <sf...@apache.org>
Authored: Mon Dec 8 08:51:47 2014 -0700
Committer: Shawn Feldman <sf...@apache.org>
Committed: Mon Dec 8 08:51:47 2014 -0700
----------------------------------------------------------------------
.../usergrid/persistence/index/impl/EsEntityIndexImpl.java | 5 +++++
1 file changed, 5 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/4d04da8e/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java
index 610fe6c..5824c38 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java
@@ -203,6 +203,11 @@ public class EsEntityIndexImpl implements EntityIndex {
return getIndexes(aliasName);
}
+ /**
+ * get indexes for alias
+ * @param aliasName
+ * @return
+ */
private String[] getIndexes(final String aliasName){
final AdminClient adminClient = esProvider.getClient().admin();
//remove write alias, can only have one
[06/41] incubator-usergrid git commit: Added extractor helpers
Posted by sf...@apache.org.
Added extractor helpers
Updated UsersScenario to use helpers and constants
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/6709158f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/6709158f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/6709158f
Branch: refs/heads/UG-rest-test-framework-overhaul
Commit: 6709158fc40a011807007717f432d1d324319e26
Parents: 2372701
Author: Todd Nine <tn...@apigee.com>
Authored: Thu Dec 4 15:14:33 2014 -0700
Committer: Todd Nine <tn...@apigee.com>
Committed: Thu Dec 4 15:14:33 2014 -0700
----------------------------------------------------------------------
.../apache/usergrid/helpers/Extractors.scala | 72 ++++++++++
.../usergrid/scenarios/UserScenarios.scala | 132 ++++++++++++-------
2 files changed, 153 insertions(+), 51 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6709158f/stack/loadtests/src/main/scala/org/apache/usergrid/helpers/Extractors.scala
----------------------------------------------------------------------
diff --git a/stack/loadtests/src/main/scala/org/apache/usergrid/helpers/Extractors.scala b/stack/loadtests/src/main/scala/org/apache/usergrid/helpers/Extractors.scala
new file mode 100644
index 0000000..055bf8d
--- /dev/null
+++ b/stack/loadtests/src/main/scala/org/apache/usergrid/helpers/Extractors.scala
@@ -0,0 +1,72 @@
+package org.apache.usergrid.helpers
+
+import io.gatling.core.Predef._
+import io.gatling.core.session._
+import io.gatling.http.Predef._
+
+import scala.util.parsing.json.JSONArray
+
+/**
+ * Helper object that will perform extractions
+ */
+object Extractors {
+
+// /**
+// * Will extract the cursor from the response. If the cursor is not present, an empty string will be set
+// */
+// val maybeExtractCursor = jsonPath("$..cursor").transformOption( extract => {
+// //it may or may not be present. If it is, save it, otherwise save it as an empty string
+// extract.orElse(Some(""))
+// }).saveAs("cursor")
+//
+// /**
+// * Will extract entities as a json array into the session. If they do not exist, it will set to an empty list
+// */
+// val maybeExtractEntities = jsonPath("..entities").transformOption(extract => {
+// extract.orElse(Some(JSONArray(List())));
+// }).saveAs("entities")
+
+ /**
+ * Will extract the cursor from the response. If the cursor is not present, an empty string will be set
+ */
+ def maybeExtractCursor(saveAsName : String) = {
+ jsonPath("$..cursor").transformOption(extract => {
+ //it may or may not be present. If it is, save it, otherwise save it as an empty string
+ extract.orElse(Some(""))
+ }).saveAs(saveAsName)
+ }
+
+
+ /**
+ * tries to extract the cursor from the session, if it exists, it returns true. if it's the default, returns false
+ * @param nameInSession The name of the variable in the session
+ * @return
+ */
+ def stringParamExists (nameInSession: String) : Expression[Boolean] = {
+ session => session(nameInSession) != null && session(nameInSession).as[String] != ""
+ }
+
+ /**
+ * Will extract entities as a json array into the session. If they do not exist, it will set to an empty list
+ * @param saveAsName The name to use when saving to the session
+ */
+ def maybeExtractEntities(saveAsName: String) = {
+ jsonPath("$..entities").ofType[Seq[Any]].transformOption(extract => {
+ extract.orElse(Some(Seq()));
+ }).saveAs(saveAsName)
+ }
+
+ /**
+ * Returns true if sequence is not null and has elements. Expects a seq object
+ * @param nameInSession The name ot use when saving to the session
+ * @return
+ */
+ def sequenceHasElements(nameInSession: String) : Expression[Boolean] = {
+ session => session(nameInSession) != null && session(nameInSession).as[Seq[Any]].length > 0
+ }
+
+
+
+
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6709158f/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 2bbe9a3..13fb96b 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
@@ -14,28 +14,49 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
- package org.apache.usergrid.scenarios
+
+package org.apache.usergrid.scenarios
import io.gatling.core.Predef._
- import io.gatling.http.Predef._
- import io.gatling.http.request.StringBody
- import org.apache.usergrid.datagenerators.FeederGenerator
- import org.apache.usergrid.settings.{Headers, Settings, Utils}
+import io.gatling.http.Predef._
+import io.gatling.http.request.StringBody
+import org.apache.usergrid.datagenerators.FeederGenerator
+import org.apache.usergrid.settings.{Headers, Settings, Utils}
+import org.apache.usergrid.helpers.Extractors._
+
+import scala.util.parsing.json.JSONArray
+
+object UserScenarios {
+
+ /**
+ * Naming constants used in the scenarios for saving values into the sessions
+ */
+
+ //The value for the cursor
+ val SessionVarCursor: String = "cursor"
- object UserScenarios {
+ //the value for the json array of users
+ val SessionVarUsers: String = "users"
+
+ //the value for the users uuid
+ val SessionVarUserId: String = "userId"
+
+ //the value for HTTP response code after requests
+ val SessionVarUserStatus: String = "userStatus"
+
+ val getRandomUser = exec(
+ http("GET user")
+ .get("/users/user" + Utils.generateRandomInt(1, Settings.numEntities))
+ .headers(Headers.jsonAuthorized)
+ .check(status.is(200))
+ )
- val getRandomUser = exec(
- http("GET user")
- .get("/users/user" + Utils.generateRandomInt(1, Settings.numEntities))
- .headers(Headers.jsonAuthorized)
- .check(status.is(200))
- )
val getUserByUsername = exec(
http("GET user")
.get("/users/${username}")
.headers(Headers.jsonAuthorized)
- .check(status.saveAs("userStatus"), jsonPath("$..entities[0]").exists, jsonPath("$..entities[0].uuid").exists, jsonPath("$..entities[0].uuid").saveAs("userId"))
+ .check(status.saveAs(SessionVarUserStatus), jsonPath("$..entities[0]").exists, jsonPath("$..entities[0].uuid").exists, jsonPath("$..entities[0].uuid").saveAs(SessionVarUserId))
)
@@ -45,31 +66,30 @@ import io.gatling.core.Predef._
val postUser =
exec(
- http("POST geolocated Users")
- .post("/users")
- .body(new StringBody("""{"location":{"latitude":"${latitude}","longitude":"${longitude}"},"username":"${username}",
+ 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"))
- )
-
+ .check(status.saveAs(SessionVarUserStatus))
+ .check(status.is(200), jsonPath("$..entities[0].uuid").saveAs(SessionVarUserId))
+ )
/**
- * Try to get a user, if it returns a 404, create the user
- */
+ * Try to get a user, if it returns a 404, create the user
+ */
val postUserIfNotExists =
exec(getUserByUsername)
- .doIf ("${userStatus}", "404") {
- exec(postUser)
+ .doIf("${userStatus}", "404") {
+ exec(postUser)
}
val putUser =
exec(getUserByUsername)
- .doIf("${userStatus}", "200") {
+ .doIf("${userStatus}", "200") {
exec(
http("POST geolocated Users")
.put("/users")
@@ -77,10 +97,10 @@ import io.gatling.core.Predef._
"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.is(200), jsonPath("$..entities[0].uuid").saveAs("userId"))
+ .check(status.is(200), jsonPath("$..entities[0].uuid").saveAs(SessionVarUserId))
)
- }
+ }
/**
* Get a collection of users without a cursor. Sets the cursor and entities array as "users"
@@ -89,59 +109,69 @@ import io.gatling.core.Predef._
http("GET user")
.get("/users")
.headers(Headers.jsonAuthorized)
- .check(status.is(200), jsonPath("$..entities").saveAs("users"), jsonPath("$..cursor").saveAs("cursor"))
+ .check(status.is(200), maybeExtractEntities(SessionVarUsers), maybeExtractCursor(SessionVarCursor))
)
/**
* Get the next page of users with the cursor, expects the value "cursor" to be present in teh session
*/
+ //maybe doif for detecting empty session?
val getUsersWithCursor = exec(
- http("GET user")
- .get("/users?cursor=${cursor}")
- .headers(Headers.jsonAuthorized)
- .check(status.is(200), jsonPath("$..entities").saveAs("users"), jsonPath("$..cursor").saveAs("cursor"))
- )
+ http("GET user")
+ .get("/users?cursor=${" + SessionVarCursor + "}")
+ .headers(Headers.jsonAuthorized)
+ .check(status.is(200), maybeExtractEntities(SessionVarUsers), maybeExtractCursor(SessionVarCursor))
+ ) /**
+ * Debugging block
+
+ .exec(session => {
+
+ val cursor = session.get(SessionVarCursor)
+ val users = session.get(SessionVarUsers)
+
+ session
+ }) */
val deleteUserByUsername = exec(
http("DELETE user")
.delete("/users/${username}")
.headers(Headers.jsonAuthorized)
- .check(status.is(200), jsonPath("$..entities[0].uuid").saveAs("userId"))
+ .check(status.is(200), jsonPath("$..entities[0].uuid").saveAs(SessionVarUserId))
)
/**
* 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")
+ val createUsersWithDevicesScenario = scenario("Create Users")
.feed(Settings.getInfiniteUserFeeder())
.exec(TokenScenarios.getManagementToken)
.exec(UserScenarios.postUserIfNotExists)
.exec(TokenScenarios.getUserToken)
.exec(UserScenarios.getUserByUsername)
- .repeat(2){
- feed(FeederGenerator.generateEntityNameFeeder("device", Settings.numDevices))
- .exec( DeviceScenarios.maybeCreateDevices)
- }
+ .repeat(2) {
+ 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)
+ val postUsersInfinitely = scenario("Post Users")
+ .feed(Settings.getInfiniteUserFeeder())
+ .exec(UserScenarios.postUser)
/**
* Get the users a page at a time until exhausted
*/
- val getUsersToEnd = scenario("Get Users").exec(
- //get the management token
- TokenScenarios.getManagementToken,
- //get users without a cursor
- getUsersWithoutCursor
- //as long as we have a cursor, keep getting results
- ).asLongAs(session => session("cursor").as[String] != "") {
- exec(getUsersWithCursor)
- }
+ val getUsersToEnd = scenario("Get Users")
+ //get the management token
+ .exec(TokenScenarios.getManagementToken)
+ //get users without a cursor
+ .exec(getUsersWithoutCursor)
+ //as long as we have a cursor, keep getting results
+ .asLongAs(stringParamExists(SessionVarCursor)) {
+ exec(getUsersWithCursor)
+ }
}
[16/41] incubator-usergrid git commit: Changed tomcat configuration
to be configured based on number of processors and threads per core
Posted by sf...@apache.org.
Changed tomcat configuration to be configured based on number of processors and threads per core
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/692eff82
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/692eff82
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/692eff82
Branch: refs/heads/UG-rest-test-framework-overhaul
Commit: 692eff82361af0eaa0824bf47cb70a20ec0bd184
Parents: ecce52d
Author: Todd Nine <tn...@apigee.com>
Authored: Fri Dec 5 15:46:07 2014 -0700
Committer: Todd Nine <tn...@apigee.com>
Committed: Fri Dec 5 15:46:07 2014 -0700
----------------------------------------------------------------------
.../main/dist/init_instance/init_rest_server.sh | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/692eff82/stack/awscluster/src/main/dist/init_instance/init_rest_server.sh
----------------------------------------------------------------------
diff --git a/stack/awscluster/src/main/dist/init_instance/init_rest_server.sh b/stack/awscluster/src/main/dist/init_instance/init_rest_server.sh
index 924fb49..3d5fdaf 100644
--- a/stack/awscluster/src/main/dist/init_instance/init_rest_server.sh
+++ b/stack/awscluster/src/main/dist/init_instance/init_rest_server.sh
@@ -68,51 +68,51 @@ export ACCEPT_COUNT=100
export NR_OPEN=1048576
export FILE_MAX=761773
+#Number of threads to allow per core
+export NUM_THREAD_PROC=25
+
+#Get the number of processors
+export NUM_PROC=$(nproc)
+
+#Configure the max amount of tomcat threads
+export TOMCAT_THREADS=$((${NUM_PROC} * ${NUM_THREAD_PROC}))
+
case `(curl http://169.254.169.254/latest/meta-data/instance-type)` in
'm1.small' )
# total of 1.7g
export TOMCAT_RAM=1190m
- export TOMCAT_THREADS=300
;;
'm1.medium' )
# total of 3.75g
export TOMCAT_RAM=2625m
- export TOMCAT_THREADS=500
;;
'm1.large' )
# total of 7.5g
export TOMCAT_RAM=5250m
- export TOMCAT_THREADS=1000
;;
'm1.xlarge' )
# total of 15g
export TOMCAT_RAM=10500m
- export TOMCAT_THREADS=2000
;;
'm3.large' )
# total of 7.5g
export TOMCAT_RAM=5250m
- export TOMCAT_THREADS=1600
;;
'm3.xlarge' )
# total of 15g
export TOMCAT_RAM=10500m
- export TOMCAT_THREADS=3300
;;
'c3.xlarge' )
# total of 7.5g
export TOMCAT_RAM=4096m
- export TOMCAT_THREADS=1000
;;
'c3.2xlarge' )
# total of 15g
export TOMCAT_RAM=10500m
- export TOMCAT_THREADS=2000
;;
'c3.4xlarge' )
# total of 30g
export TOMCAT_RAM=21000m
- export TOMCAT_THREADS=4000
esac
[36/41] incubator-usergrid git commit: add caching to indexes
Posted by sf...@apache.org.
add caching to indexes
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/574fe644
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/574fe644
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/574fe644
Branch: refs/heads/UG-rest-test-framework-overhaul
Commit: 574fe6449a96a7f8a8531cdb0c2f81ad7a2643e9
Parents: 1d2697f
Author: Shawn Feldman <sf...@apache.org>
Authored: Tue Dec 9 11:16:16 2014 -0700
Committer: Shawn Feldman <sf...@apache.org>
Committed: Tue Dec 9 11:16:16 2014 -0700
----------------------------------------------------------------------
.../usergrid/persistence/index/IndexFig.java | 3 +++
.../persistence/index/impl/EsIndexCache.java | 23 ++++++++++++++++----
2 files changed, 22 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/574fe644/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/IndexFig.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/IndexFig.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/IndexFig.java
index ea0a4f3..d78ed72 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/IndexFig.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/IndexFig.java
@@ -110,4 +110,7 @@ public interface IndexFig extends GuicyFig {
@Default( "20" )
@Key( ELASTICSEARCH_FAIL_REFRESH )
int getFailRefreshCount();
+
+ @Default("2")
+ int getIndexCacheMaxWorkers();
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/574fe644/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsIndexCache.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsIndexCache.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsIndexCache.java
index f418590..c607222 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsIndexCache.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsIndexCache.java
@@ -24,9 +24,13 @@ import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
import com.google.common.util.concurrent.ListenableFuture;
+import com.google.common.util.concurrent.ListenableFutureTask;
+import com.google.common.util.concurrent.ListeningScheduledExecutorService;
+import com.google.common.util.concurrent.MoreExecutors;
import com.google.inject.Inject;
import com.google.inject.Singleton;
import org.apache.usergrid.persistence.index.AliasedEntityIndex;
+import org.apache.usergrid.persistence.index.IndexFig;
import org.apache.usergrid.persistence.index.IndexIdentifier;
import org.elasticsearch.action.admin.indices.alias.get.GetAliasesRequest;
import org.elasticsearch.client.AdminClient;
@@ -36,7 +40,9 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.List;
+import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
+import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
/**
@@ -46,21 +52,30 @@ import java.util.concurrent.TimeUnit;
public class EsIndexCache {
private static final Logger logger = LoggerFactory.getLogger(EsEntityIndexImpl.class);
+ private final ListeningScheduledExecutorService refreshExecutors;
private LoadingCache<String, String[]> aliasIndexCache;
@Inject
- public EsIndexCache(final EsProvider provider) {
+ public EsIndexCache(final EsProvider provider, final IndexFig indexFig) {
+ this.refreshExecutors = MoreExecutors
+ .listeningDecorator(Executors.newScheduledThreadPool(indexFig.getIndexCacheMaxWorkers()));
aliasIndexCache = CacheBuilder.newBuilder().maximumSize(1000)
.refreshAfterWrite(5,TimeUnit.MINUTES)
.build(new CacheLoader<String, String[]>() {
@Override
- public ListenableFuture<String[]> reload(String key, String[] oldValue) throws Exception {
- return super.reload(key, oldValue);
+ public ListenableFuture<String[]> reload(final String key, String[] oldValue) throws Exception {
+ ListenableFutureTask<String[]> task = ListenableFutureTask.create( new Callable<String[]>() {
+ public String[] call() {
+ return load( key );
+ }
+ } );
+ refreshExecutors.execute(task);
+ return task;
}
@Override
- public String[] load(String aliasName) {
+ public String[] load(final String aliasName) {
final AdminClient adminClient = provider.getClient().admin();
//remove write alias, can only have one
ImmutableOpenMap<String, List<AliasMetaData>> aliasMap = adminClient.indices().getAliases(new GetAliasesRequest(aliasName)).actionGet().getAliases();
[35/41] incubator-usergrid git commit: add caching to indexes
Posted by sf...@apache.org.
add caching to indexes
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/1d2697fc
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/1d2697fc
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/1d2697fc
Branch: refs/heads/UG-rest-test-framework-overhaul
Commit: 1d2697fc967680aa092b42705ffdc688e3579dae
Parents: b545c0e
Author: Shawn Feldman <sf...@apache.org>
Authored: Tue Dec 9 09:50:45 2014 -0700
Committer: Shawn Feldman <sf...@apache.org>
Committed: Tue Dec 9 09:50:45 2014 -0700
----------------------------------------------------------------------
.../persistence/index/impl/EsIndexCache.java | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/1d2697fc/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsIndexCache.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsIndexCache.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsIndexCache.java
index 710cc60..f418590 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsIndexCache.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsIndexCache.java
@@ -40,7 +40,7 @@ import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
/**
- * Classy class class.
+ * Cache for Es index operations
*/
@Singleton
public class EsIndexCache {
@@ -66,11 +66,15 @@ public class EsIndexCache {
ImmutableOpenMap<String, List<AliasMetaData>> aliasMap = adminClient.indices().getAliases(new GetAliasesRequest(aliasName)).actionGet().getAliases();
return aliasMap.keys().toArray(String.class);
}
- })
-
- ;
+ }) ;
}
+ /**
+ * Get indexes for an alias
+ * @param alias
+ * @param aliasType
+ * @return
+ */
public String[] getIndexes(IndexIdentifier.IndexAlias alias, AliasedEntityIndex.AliasType aliasType) {
String[] indexes;
try {
@@ -82,6 +86,10 @@ public class EsIndexCache {
return indexes;
}
+ /**
+ * clean up cache
+ * @param alias
+ */
public void invalidate(IndexIdentifier.IndexAlias alias){
aliasIndexCache.invalidate(alias.getWriteAlias());
aliasIndexCache.invalidate(alias.getReadAlias());
[07/41] incubator-usergrid git commit: Merge branch 'USERGRID-252' of
https://git-wip-us.apache.org/repos/asf/incubator-usergrid into USERGRID-252
Posted by sf...@apache.org.
Merge branch 'USERGRID-252' of https://git-wip-us.apache.org/repos/asf/incubator-usergrid into USERGRID-252
Conflicts:
stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/UserScenarios.scala
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/c64fcba7
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/c64fcba7
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/c64fcba7
Branch: refs/heads/UG-rest-test-framework-overhaul
Commit: c64fcba728908a5f093e6a55b48af1b1fb50d496
Parents: 6709158 949daf8
Author: Todd Nine <tn...@apigee.com>
Authored: Thu Dec 4 15:16:38 2014 -0700
Committer: Todd Nine <tn...@apigee.com>
Committed: Thu Dec 4 15:16:38 2014 -0700
----------------------------------------------------------------------
.../usergrid/scenarios/UserScenarios.scala | 46 ++++++++++++----
.../simulations/DeleteUsersSimulation.scala | 56 ++++++++++++++++++++
.../simulations/PutUsersSimulation.scala | 56 ++++++++++++++++++++
3 files changed, 147 insertions(+), 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c64fcba7/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/UserScenarios.scala
----------------------------------------------------------------------
diff --cc stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/UserScenarios.scala
index 13fb96b,090ffea..e48b60c
--- a/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/UserScenarios.scala
+++ b/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/UserScenarios.scala
@@@ -78,28 -60,42 +78,37 @@@ object UserScenarios
/**
- * Try to get a user, if it returns a 404, create the user
- */
+ * Try to get a user, if it returns a 404, create the user
+ */
val postUserIfNotExists =
exec(getUserByUsername)
- .doIf ("${userStatus}", "404") {
- exec(postUser)
+ .doIf("${userStatus}", "404") {
+ exec(postUser)
}
-
- val putUser =
- exec(getUserByUsername)
- .doIf("${userStatus}", "200") {
- exec(
- http("POST geolocated Users")
- .put("/users")
- .body(new StringBody( """{"location":{"latitude":"${latitude}","longitude":"${longitude}"},"username":"${username}",
+ val putUser = exec(
+ http("PUT geolocated Users")
+ .put("/users/${username}")
+ .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.is(200), jsonPath("$..entities[0].uuid").saveAs(SessionVarUserId))
- .check(status.is(200), jsonPath("$..entities[0].uuid").saveAs("userId"))
-
- )
++ .check(status.is(200), jsonPath("$..entities[0].uuid").saveAs(SessionVarUserId))
- val putUserIfExists =
- exec(getUserByUsername)
- .doIf("${userStatus}", "200") {
- putUser
- }
+ )
++
+
+ val deleteUser = exec(
+ http("PUT geolocated Users")
+ .delete("/users/${username}")
+ .check(status.is(200))
+
+ )
+
+ val deleteUserIfExists =
+ exec(getUserByUsername)
+ .doIf("${userStatus}", "200") {
+ deleteUser
}
/**
@@@ -158,9 -144,24 +167,24 @@@
/**
* Posts a new user every time
*/
- val postUsersInfinitely = scenario("Post Users")
+ val postUsersInfinitely = scenario("Post Users")
+ .feed(Settings.getInfiniteUserFeeder())
+ .exec(postUser)
+
+
+ /**
+ * Puts a new user every time
+ */
- val putUsersInfinitely = scenario("Post Users")
++ val putUsersInfinitely = scenario("Put Users")
+ .feed(Settings.getInfiniteUserFeeder())
+ .exec(putUser)
+
+ /**
+ * Deletes user every time
+ */
- val deleteUsersInfinitely = scenario("Post Users")
++ val deleteUsersInfinitely = scenario("Delete Users")
.feed(Settings.getInfiniteUserFeeder())
- .exec(UserScenarios.postUser)
+ .exec(deleteUser)
/**
* Get the users a page at a time until exhausted
[24/41] incubator-usergrid git commit: if there is no alias then use
the index
Posted by sf...@apache.org.
if there is no alias then use the index
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/983b20b2
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/983b20b2
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/983b20b2
Branch: refs/heads/UG-rest-test-framework-overhaul
Commit: 983b20b2179f1363eebaf8cce5771d5d732b2409
Parents: 3d9137e
Author: Shawn Feldman <sf...@apache.org>
Authored: Mon Dec 8 10:11:11 2014 -0700
Committer: Shawn Feldman <sf...@apache.org>
Committed: Mon Dec 8 10:11:11 2014 -0700
----------------------------------------------------------------------
.../index/impl/EsEntityIndexBatchImpl.java | 33 ++++++++++++++------
.../persistence/index/impl/EntityIndexTest.java | 7 +++--
2 files changed, 28 insertions(+), 12 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/983b20b2/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexBatchImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexBatchImpl.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexBatchImpl.java
index ecc71e9..51fe63b 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexBatchImpl.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexBatchImpl.java
@@ -25,6 +25,7 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
+import java.util.concurrent.atomic.AtomicInteger;
import org.apache.usergrid.persistence.index.*;
import org.elasticsearch.action.bulk.BulkItemResponse;
@@ -58,6 +59,7 @@ import org.apache.usergrid.persistence.model.field.value.EntityObject;
import com.google.common.base.Joiner;
import rx.Observable;
import rx.functions.Action1;
+import rx.functions.Func1;
import rx.schedulers.Schedulers;
import static org.apache.usergrid.persistence.index.impl.IndexingUtils.ANALYZED_STRING_PREFIX;
@@ -184,16 +186,29 @@ public class EsEntityIndexBatchImpl implements EntityIndexBatch {
log.debug( "De-indexing type {} with documentId '{}'" , entityType, indexId);
- final String[] indexes = entityIndex.getIndexes(EntityIndex.AliasType.Read);
+ String[] indexes = entityIndex.getIndexes(EntityIndex.AliasType.Read);
+ if(indexes == null ||indexes.length == 0){
+ indexes = new String[]{indexIdentifier.getIndex(null)};
+ }
+ final AtomicInteger errorCount = new AtomicInteger();
//get all indexes then flush everyone
- Observable.from(indexes).subscribeOn(Schedulers.io()).forEach(new Action1<String>() {
- @Override
- public void call(String index) {
- bulkRequest.add(client.prepareDelete(index, entityType, indexId).setRefresh(refresh));
-
- }
- });
-
+ Observable.from(indexes).subscribeOn(Schedulers.io())
+ .map(new Func1<String, Object>() {
+ @Override
+ public Object call(String index) {
+ try {
+ bulkRequest.add(client.prepareDelete(index, entityType, indexId).setRefresh(refresh));
+ }catch (Exception e){
+ log.error("failed to deindex",e);
+ errorCount.incrementAndGet();
+ }
+ return index;
+ }
+ }).toBlocking().last();
+
+ if(errorCount.get()>0){
+ log.error("Failed to flush some indexes");
+ }
log.debug( "Deindexed Entity with index id " + indexId );
maybeFlush();
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/983b20b2/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityIndexTest.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityIndexTest.java b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityIndexTest.java
index d00796d..47c4dbd 100644
--- a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityIndexTest.java
+++ b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityIndexTest.java
@@ -166,7 +166,7 @@ public class EntityIndexTest extends BaseIT {
EntityIndexBatch entityIndexBatch = entityIndex.createBatch();
entityIndexBatch.deindex(indexScope, crs.get(0));
- entityIndexBatch.deindex(indexScope,crs.get(1));
+ entityIndexBatch.deindex(indexScope, crs.get(1));
entityIndexBatch.executeAndRefresh();
entityIndex.refresh();
@@ -248,8 +248,9 @@ public class EntityIndexTest extends BaseIT {
Query.fromQL( "name contains 'Ferrari*'" ) );
assertEquals( 1, candidateResults.size() );
- entityIndex.createBatch().deindex( indexScope, entity ).execute();
-
+ EntityIndexBatch batch = entityIndex.createBatch();
+ batch.deindex(indexScope, entity).execute();
+ batch.executeAndRefresh();
entityIndex.refresh();
candidateResults = entityIndex.search( indexScope, SearchTypes.fromTypes(entity.getId().getType()), Query.fromQL( "name contains 'Ferrari*'" ) );
[31/41] incubator-usergrid git commit: Merge remote-tracking branch
'origin/usergrid-269' into two-dot-o
Posted by sf...@apache.org.
Merge remote-tracking branch 'origin/usergrid-269' 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/a63b856e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/a63b856e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/a63b856e
Branch: refs/heads/UG-rest-test-framework-overhaul
Commit: a63b856e90e33e4b93f35bfcaeb02552a7acc4a0
Parents: e29a99e 4bf4d71
Author: Todd Nine <tn...@apigee.com>
Authored: Mon Dec 8 15:17:25 2014 -0700
Committer: Todd Nine <tn...@apigee.com>
Committed: Mon Dec 8 15:17:25 2014 -0700
----------------------------------------------------------------------
.../persistence/queue/DefaultQueueManager.java | 68 ++++++++++++++++++++
.../usergrid/services/TestQueueManager.java | 65 -------------------
.../AbstractServiceNotificationIT.java | 16 +----
.../apns/NotificationsServiceIT.java | 12 ++--
.../gcm/NotificationsServiceIT.java | 15 +++--
5 files changed, 84 insertions(+), 92 deletions(-)
----------------------------------------------------------------------
[34/41] incubator-usergrid git commit: add caching to indexes
Posted by sf...@apache.org.
add caching to indexes
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/b545c0e4
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/b545c0e4
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/b545c0e4
Branch: refs/heads/UG-rest-test-framework-overhaul
Commit: b545c0e4715d458f7e6b5c1cfa0e96a1f86068b2
Parents: 8d34426
Author: Shawn Feldman <sf...@apache.org>
Authored: Tue Dec 9 09:38:45 2014 -0700
Committer: Shawn Feldman <sf...@apache.org>
Committed: Tue Dec 9 09:38:45 2014 -0700
----------------------------------------------------------------------
.../index/impl/EsEntityIndexImpl.java | 30 ++-----
.../persistence/index/impl/EsIndexCache.java | 91 ++++++++++++++++++++
2 files changed, 99 insertions(+), 22 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/b545c0e4/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java
index 3f895b5..a6e9337 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java
@@ -30,7 +30,6 @@ import org.elasticsearch.action.admin.cluster.health.ClusterHealthRequest;
import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse;
import org.elasticsearch.action.admin.cluster.tasks.PendingClusterTasksRequest;
import org.elasticsearch.action.admin.cluster.tasks.PendingClusterTasksResponse;
-import org.elasticsearch.action.admin.indices.alias.get.GetAliasesRequest;
import org.elasticsearch.action.admin.indices.create.CreateIndexResponse;
import org.elasticsearch.action.admin.indices.delete.DeleteIndexResponse;
import org.elasticsearch.action.admin.indices.template.put.PutIndexTemplateResponse;
@@ -38,8 +37,6 @@ import org.elasticsearch.action.search.SearchRequestBuilder;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.action.search.SearchScrollRequestBuilder;
import org.elasticsearch.client.AdminClient;
-import org.elasticsearch.cluster.metadata.AliasMetaData;
-import org.elasticsearch.common.collect.ImmutableOpenMap;
import org.elasticsearch.common.settings.ImmutableSettings;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.XContentBuilder;
@@ -120,11 +117,11 @@ public class EsEntityIndexImpl implements AliasedEntityIndex {
private static final MatchAllQueryBuilder MATCH_ALL_QUERY_BUILDER = QueryBuilders.matchAllQuery();
+ private EsIndexCache aliasCache;
- @Inject
- public EsEntityIndexImpl( @Assisted final ApplicationScope appScope, final IndexFig config,
- final EsProvider provider ) {
+ @Inject
+ public EsEntityIndexImpl( @Assisted final ApplicationScope appScope, final IndexFig config, final EsProvider provider, final EsIndexCache indexCache) {
ValidationUtils.validateApplicationScope( appScope );
this.applicationScope = appScope;
this.esProvider = provider;
@@ -133,6 +130,7 @@ public class EsEntityIndexImpl implements AliasedEntityIndex {
this.indexIdentifier = IndexingUtils.createIndexIdentifier(config, appScope);
this.alias = indexIdentifier.getAlias();
this.failureMonitor = new FailureMonitorImpl( config, provider );
+ this.aliasCache = indexCache;
}
@Override
@@ -188,7 +186,7 @@ public class EsEntityIndexImpl implements AliasedEntityIndex {
String indexName = indexIdentifier.getIndex(indexSuffix);
final AdminClient adminClient = esProvider.getClient().admin();
- String[] indexNames = getIndexes(alias.getWriteAlias());
+ String[] indexNames = getIndexes(AliasType.Write);
for(String currentIndex : indexNames){
isAck = adminClient.indices().prepareAliases().removeAlias(currentIndex,
@@ -206,7 +204,7 @@ public class EsEntityIndexImpl implements AliasedEntityIndex {
isAck = adminClient.indices().prepareAliases().addAlias(
indexName, alias.getWriteAlias()).execute().actionGet().isAcknowledged();
logger.info("Created new write Alias Name [{}] ACK=[{}]", alias, isAck);
-
+ aliasCache.invalidate(alias);
} catch (Exception e) {
logger.warn("Failed to create alias ", e);
}
@@ -214,21 +212,9 @@ public class EsEntityIndexImpl implements AliasedEntityIndex {
@Override
public String[] getIndexes(final AliasType aliasType) {
- final String aliasName = aliasType == AliasType.Read ? alias.getReadAlias() : alias.getWriteAlias();
- return getIndexes(aliasName);
+ return aliasCache.getIndexes(alias,aliasType);
}
- /**
- * get indexes for alias
- * @param aliasName
- * @return
- */
- private String[] getIndexes(final String aliasName){
- final AdminClient adminClient = esProvider.getClient().admin();
- //remove write alias, can only have one
- ImmutableOpenMap<String,List<AliasMetaData>> aliasMap = adminClient.indices().getAliases(new GetAliasesRequest(aliasName)).actionGet().getAliases();
- return aliasMap.keys().toArray(String.class);
- }
/**
* Tests writing a document to a new index to ensure it's working correctly. See this post:
@@ -457,7 +443,7 @@ public class EsEntityIndexImpl implements AliasedEntityIndex {
@Override
public boolean doOp() {
try {
- String[] indexes = getIndexes(AliasType.Read);
+ String[] indexes = getIndexes(AliasType.Read);
Observable.from(indexes).subscribeOn(Schedulers.io()).map(new Func1<String, String>() {
@Override
public String call(String index) {
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/b545c0e4/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsIndexCache.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsIndexCache.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsIndexCache.java
new file mode 100644
index 0000000..710cc60
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsIndexCache.java
@@ -0,0 +1,91 @@
+/*
+ *
+ * * Licensed to the Apache Software Foundation (ASF) under one or more
+ * * contributor license agreements. The ASF licenses this file to You
+ * * under the Apache License, Version 2.0 (the "License"); you may not
+ * * use this file except in compliance with the License.
+ * * You may obtain a copy of the License at
+ * *
+ * * http://www.apache.org/licenses/LICENSE-2.0
+ * *
+ * * Unless required by applicable law or agreed to in writing, software
+ * * distributed under the License is distributed on an "AS IS" BASIS,
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * * See the License for the specific language governing permissions and
+ * * limitations under the License. For additional information regarding
+ * * copyright in this work, please see the NOTICE file in the top level
+ * * directory of this distribution.
+ *
+ */
+
+package org.apache.usergrid.persistence.index.impl;
+
+import com.google.common.cache.CacheBuilder;
+import com.google.common.cache.CacheLoader;
+import com.google.common.cache.LoadingCache;
+import com.google.common.util.concurrent.ListenableFuture;
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+import org.apache.usergrid.persistence.index.AliasedEntityIndex;
+import org.apache.usergrid.persistence.index.IndexIdentifier;
+import org.elasticsearch.action.admin.indices.alias.get.GetAliasesRequest;
+import org.elasticsearch.client.AdminClient;
+import org.elasticsearch.cluster.metadata.AliasMetaData;
+import org.elasticsearch.common.collect.ImmutableOpenMap;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.List;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * Classy class class.
+ */
+@Singleton
+public class EsIndexCache {
+
+ private static final Logger logger = LoggerFactory.getLogger(EsEntityIndexImpl.class);
+
+ private LoadingCache<String, String[]> aliasIndexCache;
+
+ @Inject
+ public EsIndexCache(final EsProvider provider) {
+ aliasIndexCache = CacheBuilder.newBuilder().maximumSize(1000)
+ .refreshAfterWrite(5,TimeUnit.MINUTES)
+ .build(new CacheLoader<String, String[]>() {
+ @Override
+ public ListenableFuture<String[]> reload(String key, String[] oldValue) throws Exception {
+ return super.reload(key, oldValue);
+ }
+
+ @Override
+ public String[] load(String aliasName) {
+ final AdminClient adminClient = provider.getClient().admin();
+ //remove write alias, can only have one
+ ImmutableOpenMap<String, List<AliasMetaData>> aliasMap = adminClient.indices().getAliases(new GetAliasesRequest(aliasName)).actionGet().getAliases();
+ return aliasMap.keys().toArray(String.class);
+ }
+ })
+
+ ;
+ }
+
+ public String[] getIndexes(IndexIdentifier.IndexAlias alias, AliasedEntityIndex.AliasType aliasType) {
+ String[] indexes;
+ try {
+ indexes = aliasIndexCache.get(aliasType == AliasedEntityIndex.AliasType.Read ? alias.getReadAlias() : alias.getWriteAlias());
+ } catch (ExecutionException ee) {
+ logger.error("Failed to retreive indexes", ee);
+ throw new RuntimeException(ee);
+ }
+ return indexes;
+ }
+
+ public void invalidate(IndexIdentifier.IndexAlias alias){
+ aliasIndexCache.invalidate(alias.getWriteAlias());
+ aliasIndexCache.invalidate(alias.getReadAlias());
+
+ }
+
+}
[33/41] incubator-usergrid git commit: add observable to refresh
Posted by sf...@apache.org.
add observable to refresh
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/8d344268
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/8d344268
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/8d344268
Branch: refs/heads/UG-rest-test-framework-overhaul
Commit: 8d344268ba435253497a7c92db895152c193a20a
Parents: 21630f4
Author: Shawn Feldman <sf...@apache.org>
Authored: Mon Dec 8 17:32:03 2014 -0700
Committer: Shawn Feldman <sf...@apache.org>
Committed: Mon Dec 8 17:32:03 2014 -0700
----------------------------------------------------------------------
.../persistence/index/impl/EsEntityIndexBatchImpl.java | 6 +-----
.../usergrid/persistence/index/impl/EsEntityIndexImpl.java | 2 +-
2 files changed, 2 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/8d344268/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexBatchImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexBatchImpl.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexBatchImpl.java
index 0d0e52b..cd5be7f 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexBatchImpl.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexBatchImpl.java
@@ -191,7 +191,6 @@ public class EsEntityIndexBatchImpl implements EntityIndexBatch {
if(indexes == null ||indexes.length == 0){
indexes = new String[]{indexIdentifier.getIndex(null)};
}
- final AtomicInteger errorCount = new AtomicInteger();
//get all indexes then flush everyone
Observable.from(indexes).subscribeOn(Schedulers.io())
.map(new Func1<String, Object>() {
@@ -201,15 +200,12 @@ public class EsEntityIndexBatchImpl implements EntityIndexBatch {
bulkRequest.add(client.prepareDelete(index, entityType, indexId).setRefresh(refresh));
}catch (Exception e){
log.error("failed to deindex",e);
- errorCount.incrementAndGet();
+ throw e;
}
return index;
}
}).toBlocking().last();
- if(errorCount.get()>0){
- log.error("Failed to flush some indexes");
- }
log.debug( "Deindexed Entity with index id " + indexId );
maybeFlush();
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/8d344268/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java
index 4bca8c2..3f895b5 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java
@@ -464,7 +464,7 @@ public class EsEntityIndexImpl implements AliasedEntityIndex {
esProvider.getClient().admin().indices().prepareRefresh( index ).execute().actionGet();
return index;
}
- });
+ }).toBlocking().last();
logger.debug( "Refreshed index: " + alias);
[20/41] incubator-usergrid git commit: Add enum to prevent mistakes
in naming
Posted by sf...@apache.org.
Add enum to prevent mistakes in naming
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/7e347422
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/7e347422
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/7e347422
Branch: refs/heads/UG-rest-test-framework-overhaul
Commit: 7e3474227a5f97faea141a9b6bdf2246327e2ac0
Parents: 4b90e97
Author: Shawn Feldman <sf...@apache.org>
Authored: Mon Dec 8 08:51:22 2014 -0700
Committer: Shawn Feldman <sf...@apache.org>
Committed: Mon Dec 8 08:51:22 2014 -0700
----------------------------------------------------------------------
.../apache/usergrid/persistence/index/EntityIndex.java | 9 ++++++++-
.../persistence/index/impl/EsEntityIndexBatchImpl.java | 2 +-
.../persistence/index/impl/EsEntityIndexImpl.java | 11 +++++++----
3 files changed, 16 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/7e347422/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 6e7779f..f38a390 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
@@ -51,7 +51,7 @@ public interface EntityIndex {
* @param aliasName name of alias
* @return list of index names
*/
- public String[] getIndexes(final String aliasName);
+ public String[] getIndexes(final AliasType aliasType);
/**
* Create the index batch.
@@ -95,6 +95,13 @@ public interface EntityIndex {
*/
public Health getIndexHealth();
+ /**
+ * type of alias
+ */
+ public enum AliasType {
+ Read, Write
+ }
+
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/7e347422/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexBatchImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexBatchImpl.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexBatchImpl.java
index 35c89ae..ecc71e9 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexBatchImpl.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexBatchImpl.java
@@ -184,7 +184,7 @@ public class EsEntityIndexBatchImpl implements EntityIndexBatch {
log.debug( "De-indexing type {} with documentId '{}'" , entityType, indexId);
- final String[] indexes = entityIndex.getIndexes(alias.getReadAlias());
+ final String[] indexes = entityIndex.getIndexes(EntityIndex.AliasType.Read);
//get all indexes then flush everyone
Observable.from(indexes).subscribeOn(Schedulers.io()).forEach(new Action1<String>() {
@Override
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/7e347422/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java
index 13d07d6..610fe6c 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java
@@ -178,8 +178,7 @@ public class EsEntityIndexImpl implements EntityIndex {
Boolean isAck;
String indexName = indexIdentifier.getIndex(indexSuffix);
final AdminClient adminClient = esProvider.getClient().admin();
- final String aliasName = alias.getWriteAlias();
- String[] indexNames = getIndexes( aliasName);
+ String[] indexNames = getIndexes(alias.getWriteAlias());
for(String currentIndex : indexNames){
isAck = adminClient.indices().prepareAliases().removeAlias(currentIndex,alias.getWriteAlias()).execute().actionGet().isAcknowledged();
@@ -199,14 +198,18 @@ public class EsEntityIndexImpl implements EntityIndex {
}
@Override
- public String[] getIndexes(String aliasName) {
+ public String[] getIndexes(final AliasType aliasType) {
+ final String aliasName = aliasType == AliasType.Read ? alias.getReadAlias() : alias.getWriteAlias();
+ return getIndexes(aliasName);
+ }
+
+ private String[] getIndexes(final String aliasName){
final AdminClient adminClient = esProvider.getClient().admin();
//remove write alias, can only have one
ImmutableOpenMap<String,List<AliasMetaData>> aliasMap = adminClient.indices().getAliases(new GetAliasesRequest(aliasName)).actionGet().getAliases();
return aliasMap.keys().toArray(String.class);
}
-
/**
* Tests writing a document to a new index to ensure it's working correctly. See this post:
* http://s.apache.org/index-missing-exception
[32/41] incubator-usergrid git commit: merge
Posted by sf...@apache.org.
merge
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/21630f49
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/21630f49
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/21630f49
Branch: refs/heads/UG-rest-test-framework-overhaul
Commit: 21630f498e7f59cd760e0fd2cd69c1f38de25f45
Parents: 8cdfaf9 a63b856
Author: Shawn Feldman <sf...@apache.org>
Authored: Mon Dec 8 17:23:52 2014 -0700
Committer: Shawn Feldman <sf...@apache.org>
Committed: Mon Dec 8 17:23:52 2014 -0700
----------------------------------------------------------------------
.../corepersistence/CpEntityManager.java | 230 ++++++++++---------
.../corepersistence/CpEntityManagerFactory.java | 6 +-
.../corepersistence/util/CpEntityMapUtils.java | 32 ++-
.../batch/job/SchedulerRuntimeIntervalIT.java | 49 ++--
.../migration/EntityDataMigrationIT.java | 139 +++++------
.../migration/EntityTypeMappingMigrationIT.java | 89 +++----
.../apache/usergrid/persistence/CounterIT.java | 89 ++++---
.../usergrid/persistence/CountingMutatorIT.java | 4 +-
.../persistence/EntityDictionaryIT.java | 11 +-
.../usergrid/persistence/EntityManagerIT.java | 47 ++--
.../persistence/GeoQueryBooleanTest.java | 7 +-
.../apache/usergrid/persistence/IndexIT.java | 14 +-
.../usergrid/persistence/PathQueryIT.java | 10 +-
.../PerformanceEntityRebuildIndexTest.java | 6 +-
.../usergrid/persistence/PermissionsIT.java | 5 +-
.../cassandra/EntityManagerFactoryImplIT.java | 9 +-
.../query/AbstractIteratingQueryIT.java | 3 +-
stack/core/src/test/resources/log4j.properties | 5 +-
.../data/DataMigrationManagerImpl.java | 29 ++-
.../persistence/index/AliasedEntityIndex.java | 55 +++++
.../usergrid/persistence/index/EntityIndex.java | 26 ---
.../persistence/index/IndexIdentifier.java | 4 +
.../index/impl/EsEntityIndexBatchImpl.java | 6 +-
.../index/impl/EsEntityIndexImpl.java | 88 ++++---
.../persistence/index/impl/EntityIndexTest.java | 15 +-
.../persistence/queue/DefaultQueueManager.java | 68 ++++++
.../usergrid/services/TestQueueManager.java | 65 ------
.../AbstractServiceNotificationIT.java | 16 +-
.../apns/NotificationsServiceIT.java | 12 +-
.../gcm/NotificationsServiceIT.java | 15 +-
30 files changed, 647 insertions(+), 507 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/21630f49/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManagerFactory.java
----------------------------------------------------------------------
diff --cc stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManagerFactory.java
index f6b0df8,f6b0df8..56eb258
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManagerFactory.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManagerFactory.java
@@@ -64,6 -64,6 +64,7 @@@ import org.apache.usergrid.persistence.
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.index.AliasedEntityIndex;
import org.apache.usergrid.persistence.index.EntityIndex;
import org.apache.usergrid.persistence.index.EntityIndexFactory;
import org.apache.usergrid.persistence.index.query.Query;
@@@ -702,7 -702,7 +703,10 @@@ public class CpEntityManagerFactory imp
@Override
public void addIndex(final UUID applicationId,final String indexSuffix,final int shards,final int replicas){
-- getManagerCache().getEntityIndex(CpNamingUtils.getApplicationScope( applicationId )).addIndex(indexSuffix,shards,replicas);
++ EntityIndex entityIndex = getManagerCache().getEntityIndex(CpNamingUtils.getApplicationScope(applicationId));
++ if(entityIndex instanceof AliasedEntityIndex) {
++ ((AliasedEntityIndex)entityIndex).addIndex(indexSuffix, shards, replicas);
++ }
}
@Override
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/21630f49/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/AliasedEntityIndex.java
----------------------------------------------------------------------
diff --cc stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/AliasedEntityIndex.java
index 0000000,0000000..15a0d45
new file mode 100644
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/AliasedEntityIndex.java
@@@ -1,0 -1,0 +1,55 @@@
++/*
++ *
++ * * Licensed to the Apache Software Foundation (ASF) under one or more
++ * * contributor license agreements. The ASF licenses this file to You
++ * * under the Apache License, Version 2.0 (the "License"); you may not
++ * * use this file except in compliance with the License.
++ * * You may obtain a copy of the License at
++ * *
++ * * http://www.apache.org/licenses/LICENSE-2.0
++ * *
++ * * Unless required by applicable law or agreed to in writing, software
++ * * distributed under the License is distributed on an "AS IS" BASIS,
++ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
++ * * See the License for the specific language governing permissions and
++ * * limitations under the License. For additional information regarding
++ * * copyright in this work, please see the NOTICE file in the top level
++ * * directory of this distribution.
++ *
++ */
++
++package org.apache.usergrid.persistence.index;
++
++/**
++ * EntityIndex with aliases for multiple indexes
++ */
++public interface AliasedEntityIndex extends EntityIndex{
++
++ /**
++ * Get the indexes for an alias
++ * @param aliasType name of alias
++ * @return list of index names
++ */
++ public String[] getIndexes(final AliasType aliasType);
++
++ /**
++ * Add alias to index, will remove old index from write alias
++ * @param indexSuffix must be different than current index
++ */
++ public void addAlias(final String indexSuffix);
++
++ /**
++ * Create an index and add to alias, will create alias and remove any old index from write alias if alias already exists
++ * @param indexSuffix index name
++ * @param shards
++ * @param replicas
++ */
++ public void addIndex(final String indexSuffix, final int shards, final int replicas);
++
++ /**
++ * type of alias
++ */
++ public enum AliasType {
++ Read, Write
++ }
++}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/21630f49/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/EntityIndex.java
----------------------------------------------------------------------
diff --cc stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/EntityIndex.java
index f38a390,4a653b3..549f87e
--- 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
@@@ -38,31 -38,24 +38,12 @@@ public interface EntityIndex
*/
public void initializeIndex();
-- /**
-- * Create an index and add to alias, will create alias and remove any old index from write alias if alias already exists
-- * @param indexSuffix index name
-- * @param shards
-- * @param replicas
-- */
-- public void addIndex(final String indexSuffix, final int shards, final int replicas);
-
- /**
- * Get the indexes for an alias
- * @param aliasName name of alias
- * @return list of index names
- */
- public String[] getIndexes(final AliasType aliasType);
/**
* Create the index batch.
*/
public EntityIndexBatch createBatch();
-- /**
-- * Add alias to index, will remove old index from write alias
-- * @param indexSuffix must be different than current index
-- */
-- public void addAlias(final String indexSuffix);
/**
* Execute query in Usergrid syntax.
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/21630f49/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexBatchImpl.java
----------------------------------------------------------------------
diff --cc stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexBatchImpl.java
index f2cbc6b,a3ca8a5..0d0e52b
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexBatchImpl.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexBatchImpl.java
@@@ -94,11 -92,9 +94,11 @@@ public class EsEntityIndexBatchImpl imp
private final FailureMonitor failureMonitor;
- private final EntityIndex entityIndex;
++ private final AliasedEntityIndex entityIndex;
+
public EsEntityIndexBatchImpl( final ApplicationScope applicationScope, final Client client,
- final IndexFig config, final int autoFlushSize, final FailureMonitor failureMonitor, final EntityIndex entityIndex ) {
- final IndexFig config, final int autoFlushSize, final FailureMonitor failureMonitor ) {
++ final IndexFig config, final int autoFlushSize, final FailureMonitor failureMonitor, final AliasedEntityIndex entityIndex ) {
this.applicationScope = applicationScope;
this.client = client;
@@@ -186,30 -181,9 +186,30 @@@
log.debug( "De-indexing type {} with documentId '{}'" , entityType, indexId);
- String[] indexes = entityIndex.getIndexes(EntityIndex.AliasType.Read);
-
- bulkRequest.add( client.prepareDelete(alias.getWriteAlias(), entityType, indexId ).setRefresh( refresh ) );
-
++ String[] indexes = entityIndex.getIndexes(AliasedEntityIndex.AliasType.Read);
+ //get the default index if no alias exists yet
+ if(indexes == null ||indexes.length == 0){
+ indexes = new String[]{indexIdentifier.getIndex(null)};
+ }
+ final AtomicInteger errorCount = new AtomicInteger();
+ //get all indexes then flush everyone
+ Observable.from(indexes).subscribeOn(Schedulers.io())
+ .map(new Func1<String, Object>() {
+ @Override
+ public Object call(String index) {
+ try {
+ bulkRequest.add(client.prepareDelete(index, entityType, indexId).setRefresh(refresh));
+ }catch (Exception e){
+ log.error("failed to deindex",e);
+ errorCount.incrementAndGet();
+ }
+ return index;
+ }
+ }).toBlocking().last();
+
+ if(errorCount.get()>0){
+ log.error("Failed to flush some indexes");
+ }
log.debug( "Deindexed Entity with index id " + indexId );
maybeFlush();
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/21630f49/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java
----------------------------------------------------------------------
diff --cc stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java
index 5824c38,eb050d6..4bca8c2
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java
@@@ -73,6 -72,6 +72,9 @@@ import org.apache.usergrid.persistence.
import com.google.common.collect.ImmutableMap;
import com.google.inject.Inject;
import com.google.inject.assistedinject.Assisted;
++import rx.Observable;
++import rx.functions.Func1;
++import rx.schedulers.Schedulers;
import static org.apache.usergrid.persistence.index.impl.IndexingUtils.BOOLEAN_PREFIX;
import static org.apache.usergrid.persistence.index.impl.IndexingUtils.NUMBER_PREFIX;
@@@ -83,7 -82,7 +85,7 @@@ import static org.apache.usergrid.persi
/**
* Implements index using ElasticSearch Java API.
*/
--public class EsEntityIndexImpl implements EntityIndex {
++public class EsEntityIndexImpl implements AliasedEntityIndex {
private static final Logger logger = LoggerFactory.getLogger( EsEntityIndexImpl.class );
@@@ -178,18 -184,27 +187,24 @@@
Boolean isAck;
String indexName = indexIdentifier.getIndex(indexSuffix);
final AdminClient adminClient = esProvider.getClient().admin();
+
- //remove write alias, can only have one
- ImmutableOpenMap<String,List<AliasMetaData>> aliasMap = adminClient.indices()
- .getAliases(new GetAliasesRequest(alias.getWriteAlias())).actionGet().getAliases();
- String[] indexNames = aliasMap.keys().toArray(String.class);
+ String[] indexNames = getIndexes(alias.getWriteAlias());
for(String currentIndex : indexNames){
- isAck = adminClient.indices().prepareAliases().removeAlias(currentIndex,alias.getWriteAlias()).execute().actionGet().isAcknowledged();
- logger.info("Removed Index Name [{}] from Alias=[{}] ACK=[{}]",currentIndex, alias, isAck);
+ isAck = adminClient.indices().prepareAliases().removeAlias(currentIndex,
+ alias.getWriteAlias()).execute().actionGet().isAcknowledged();
+ logger.info("Removed Index Name [{}] from Alias=[{}] ACK=[{}]",currentIndex, alias, isAck);
}
+
//add read alias
- isAck = adminClient.indices().prepareAliases().addAlias(indexName, alias.getReadAlias()).execute().actionGet().isAcknowledged();
+ isAck = adminClient.indices().prepareAliases().addAlias(
+ indexName, alias.getReadAlias()).execute().actionGet().isAcknowledged();
logger.info("Created new read Alias Name [{}] ACK=[{}]", alias, isAck);
+
//add write alias
- isAck = adminClient.indices().prepareAliases().addAlias(indexName, alias.getWriteAlias()).execute().actionGet().isAcknowledged();
+ isAck = adminClient.indices().prepareAliases().addAlias(
+ indexName, alias.getWriteAlias()).execute().actionGet().isAcknowledged();
logger.info("Created new write Alias Name [{}] ACK=[{}]", alias, isAck);
} catch (Exception e) {
@@@ -233,17 -231,19 +248,19 @@@
public boolean doOp() {
final String tempId = UUIDGenerator.newTimeUUID().toString();
- esProvider.getClient().prepareIndex( alias.getWriteAlias(), VERIFY_TYPE, tempId ).setSource( DEFAULT_PAYLOAD )
- .get();
+ esProvider.getClient().prepareIndex( alias.getWriteAlias(), VERIFY_TYPE, tempId )
- .setSource( DEFAULT_PAYLOAD ).get();
++ .setSource(DEFAULT_PAYLOAD).get();
- logger.info( "Successfully created new document with docId {} in index {} and type {}", tempId,
- alias, VERIFY_TYPE );
+ logger.info( "Successfully created new document with docId {} "
+ + "in index {} and type {}", tempId, alias, VERIFY_TYPE );
// delete all types, this way if we miss one it will get cleaned up
- esProvider.getClient().prepareDeleteByQuery( alias.getWriteAlias() ).setTypes(VERIFY_TYPE)
- .setQuery( MATCH_ALL_QUERY_BUILDER ).get();
+ esProvider.getClient().prepareDeleteByQuery( alias.getWriteAlias() )
+ .setTypes(VERIFY_TYPE)
- .setQuery( MATCH_ALL_QUERY_BUILDER ).get();
++ .setQuery(MATCH_ALL_QUERY_BUILDER).get();
- logger.info( "Successfully deleted all documents in index {} and type {}", alias, VERIFY_TYPE );
+ logger.info( "Successfully deleted all documents in index {} and type {}",
+ alias, VERIFY_TYPE );
return true;
@@@ -440,7 -440,8 +457,15 @@@
@Override
public boolean doOp() {
try {
- esProvider.getClient().admin().indices().prepareRefresh( alias.getReadAlias() ).execute().actionGet();
- esProvider.getClient().admin().indices().prepareRefresh( alias.getWriteAlias() )
- .execute().actionGet();
++ String[] indexes = getIndexes(AliasType.Read);
++ Observable.from(indexes).subscribeOn(Schedulers.io()).map(new Func1<String, String>() {
++ @Override
++ public String call(String index) {
++ esProvider.getClient().admin().indices().prepareRefresh( index ).execute().actionGet();
++ return index;
++ }
++ });
++
logger.debug( "Refreshed index: " + alias);
return true;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/21630f49/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityIndexTest.java
----------------------------------------------------------------------
diff --cc stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityIndexTest.java
index 47c4dbd,13d1552..fd94985
--- a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityIndexTest.java
+++ b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityIndexTest.java
@@@ -25,7 -25,6 +25,8 @@@ import java.util.LinkedHashMap
import java.util.List;
import java.util.Map;
++import org.apache.usergrid.persistence.index.*;
+import org.apache.usergrid.persistence.index.query.CandidateResult;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.slf4j.Logger;
@@@ -38,11 -37,11 +39,6 @@@ import org.apache.usergrid.persistence.
import org.apache.usergrid.persistence.core.scope.ApplicationScopeImpl;
import org.apache.usergrid.persistence.core.test.UseModules;
import org.apache.usergrid.persistence.core.util.Health;
--import org.apache.usergrid.persistence.index.EntityIndex;
--import org.apache.usergrid.persistence.index.EntityIndexBatch;
--import org.apache.usergrid.persistence.index.EntityIndexFactory;
--import org.apache.usergrid.persistence.index.IndexScope;
--import org.apache.usergrid.persistence.index.SearchTypes;
import org.apache.usergrid.persistence.index.guice.TestIndexModule;
import org.apache.usergrid.persistence.index.query.CandidateResults;
import org.apache.usergrid.persistence.index.query.Query;
@@@ -115,7 -114,7 +111,7 @@@ public class EntityIndexTest extends Ba
ApplicationScope applicationScope = new ApplicationScopeImpl( appId );
-- EntityIndex entityIndex = eif.createEntityIndex( applicationScope );
++ AliasedEntityIndex entityIndex =(AliasedEntityIndex) eif.createEntityIndex( applicationScope );
entityIndex.initializeIndex();
final String entityType = "thing";
@@@ -140,41 -139,6 +136,42 @@@
testQuery(indexScope, searchTypes, entityIndex, "name = 'Lowe Kelley'", 1 );
}
+ @Test
+ public void testDeleteByQueryWithAlias() throws IOException {
+ Id appId = new SimpleId( "application" );
+
+ ApplicationScope applicationScope = new ApplicationScopeImpl( appId );
+
- EntityIndex entityIndex = eif.createEntityIndex(applicationScope);
++ AliasedEntityIndex entityIndex =(AliasedEntityIndex) eif.createEntityIndex( applicationScope );
++
+ entityIndex.initializeIndex();
+
+ final String entityType = "thing";
+ IndexScope indexScope = new IndexScopeImpl( appId, "things" );
+ final SearchTypes searchTypes = SearchTypes.fromTypes( entityType );
+
+ insertJsonBlob(entityIndex, entityType, indexScope, "/sample-large.json",1,0);
+
+ entityIndex.refresh();
+
- entityIndex.addIndex("v2", 1,0);
++ entityIndex.addIndex("v2", 1, 0);
+
- insertJsonBlob(entityIndex, entityType, indexScope, "/sample-large.json",1,0);
++ insertJsonBlob(entityIndex, entityType, indexScope, "/sample-large.json", 1, 0);
+
+ entityIndex.refresh();
+ CandidateResults crs = testQuery(indexScope, searchTypes, entityIndex, "name = 'Bowers Oneil'", 2);
+
+ EntityIndexBatch entityIndexBatch = entityIndex.createBatch();
+ entityIndexBatch.deindex(indexScope, crs.get(0));
+ entityIndexBatch.deindex(indexScope, crs.get(1));
+ entityIndexBatch.executeAndRefresh();
+ entityIndex.refresh();
+
+ //Hilda Youn
+ testQuery(indexScope, searchTypes, entityIndex, "name = 'Bowers Oneil'", 0);
+
+ }
+
private void insertJsonBlob(EntityIndex entityIndex, String entityType, IndexScope indexScope, String filePath,final int max,final int startIndex) throws IOException {
InputStream is = this.getClass().getResourceAsStream( filePath );
ObjectMapper mapper = new ObjectMapper();
[05/41] incubator-usergrid git commit: new simulations for put and
delete
Posted by sf...@apache.org.
new simulations for put and delete
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/949daf8d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/949daf8d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/949daf8d
Branch: refs/heads/UG-rest-test-framework-overhaul
Commit: 949daf8dc67a995f7da42d2069a8ff1de793a6ec
Parents: 5542814
Author: Shawn Feldman <sf...@apache.org>
Authored: Thu Dec 4 09:30:01 2014 -0700
Committer: Shawn Feldman <sf...@apache.org>
Committed: Thu Dec 4 09:30:01 2014 -0700
----------------------------------------------------------------------
.../simulations/DeleteUsersSimulation.scala | 56 ++++++++++++++++++++
.../simulations/PutUsersSimulation.scala | 56 ++++++++++++++++++++
2 files changed, 112 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/949daf8d/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/DeleteUsersSimulation.scala
----------------------------------------------------------------------
diff --git a/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/DeleteUsersSimulation.scala b/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/DeleteUsersSimulation.scala
new file mode 100644
index 0000000..bcfbe2d
--- /dev/null
+++ b/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/DeleteUsersSimulation.scala
@@ -0,0 +1,56 @@
+/*
+ *
+ * * Licensed to the Apache Software Foundation (ASF) under one or more
+ * * contributor license agreements. The ASF licenses this file to You
+ * * under the Apache License, Version 2.0 (the "License"); you may not
+ * * use this file except in compliance with the License.
+ * * You may obtain a copy of the License at
+ * *
+ * * http://www.apache.org/licenses/LICENSE-2.0
+ * *
+ * * Unless required by applicable law or agreed to in writing, software
+ * * distributed under the License is distributed on an "AS IS" BASIS,
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * * See the License for the specific language governing permissions and
+ * * limitations under the License. For additional information regarding
+ * * copyright in this work, please see the NOTICE file in the top level
+ * * directory of this distribution.
+ *
+ */
+
+package org.apache.usergrid.simulations
+
+import io.gatling.core.Predef._
+import io.gatling.core.scenario.Simulation
+import org.apache.usergrid.helpers.Setup
+import org.apache.usergrid.scenarios.UserScenarios
+import org.apache.usergrid.settings.Settings
+
+/**
+ * Deletes 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 DeleteUsersSimulation extends Simulation {
+
+ println("Begin setup")
+ Setup.setupOrg()
+ Setup.setupApplication()
+ println("End Setup")
+
+
+ setUp(
+ UserScenarios.deleteUsersInfinitely
+ .inject(
+ /**
+ * injection steps take from this forum post
+ * https://groups.google.com/forum/#!topic/gatling/JfYHaWCbA-w
+ */
+ rampUsers(Settings.maxPossibleUsers) over Settings.rampTime,
+ constantUsersPerSec(Settings.maxPossibleUsers) during Settings.duration
+
+ )).protocols(Settings.httpConf.acceptHeader("application/json"))
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/949daf8d/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/PutUsersSimulation.scala
----------------------------------------------------------------------
diff --git a/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/PutUsersSimulation.scala b/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/PutUsersSimulation.scala
new file mode 100644
index 0000000..f89952c
--- /dev/null
+++ b/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/PutUsersSimulation.scala
@@ -0,0 +1,56 @@
+/*
+ *
+ * * Licensed to the Apache Software Foundation (ASF) under one or more
+ * * contributor license agreements. The ASF licenses this file to You
+ * * under the Apache License, Version 2.0 (the "License"); you may not
+ * * use this file except in compliance with the License.
+ * * You may obtain a copy of the License at
+ * *
+ * * http://www.apache.org/licenses/LICENSE-2.0
+ * *
+ * * Unless required by applicable law or agreed to in writing, software
+ * * distributed under the License is distributed on an "AS IS" BASIS,
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * * See the License for the specific language governing permissions and
+ * * limitations under the License. For additional information regarding
+ * * copyright in this work, please see the NOTICE file in the top level
+ * * directory of this distribution.
+ *
+ */
+
+package org.apache.usergrid.simulations
+
+import io.gatling.core.Predef._
+import io.gatling.core.scenario.Simulation
+import org.apache.usergrid.helpers.Setup
+import org.apache.usergrid.scenarios.UserScenarios
+import org.apache.usergrid.settings.Settings
+
+/**
+ * PUTS 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 PutUsersSimulation extends Simulation {
+
+ println("Begin setup")
+ Setup.setupOrg()
+ Setup.setupApplication()
+ println("End Setup")
+
+
+ setUp(
+ UserScenarios.putUsersInfinitely
+ .inject(
+ /**
+ * injection steps take from this forum post
+ * https://groups.google.com/forum/#!topic/gatling/JfYHaWCbA-w
+ */
+ rampUsers(Settings.maxPossibleUsers) over Settings.rampTime,
+ constantUsersPerSec(Settings.maxPossibleUsers) during Settings.duration
+
+ )).protocols(Settings.httpConf.acceptHeader("application/json"))
+
+}
[26/41] incubator-usergrid git commit: remove queue manager
Posted by sf...@apache.org.
remove queue manager
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/461c1928
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/461c1928
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/461c1928
Branch: refs/heads/UG-rest-test-framework-overhaul
Commit: 461c1928beae05c78646ac727f20e0afe7d6f3fb
Parents: c4973e9
Author: Shawn Feldman <sf...@apache.org>
Authored: Mon Dec 8 11:03:48 2014 -0700
Committer: Shawn Feldman <sf...@apache.org>
Committed: Mon Dec 8 11:03:48 2014 -0700
----------------------------------------------------------------------
.../persistence/queue/DefaultQueueManager.java | 68 ++++++++++++++++++++
.../usergrid/services/TestQueueManager.java | 65 -------------------
.../apns/NotificationsServiceIT.java | 4 +-
.../gcm/NotificationsServiceIT.java | 4 +-
4 files changed, 72 insertions(+), 69 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/461c1928/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/DefaultQueueManager.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/DefaultQueueManager.java b/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/DefaultQueueManager.java
new file mode 100644
index 0000000..354aa7b
--- /dev/null
+++ b/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/DefaultQueueManager.java
@@ -0,0 +1,68 @@
+/*
+ *
+ * * Licensed to the Apache Software Foundation (ASF) under one or more
+ * * contributor license agreements. The ASF licenses this file to You
+ * * under the Apache License, Version 2.0 (the "License"); you may not
+ * * use this file except in compliance with the License.
+ * * You may obtain a copy of the License at
+ * *
+ * * http://www.apache.org/licenses/LICENSE-2.0
+ * *
+ * * Unless required by applicable law or agreed to in writing, software
+ * * distributed under the License is distributed on an "AS IS" BASIS,
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * * See the License for the specific language governing permissions and
+ * * limitations under the License. For additional information regarding
+ * * copyright in this work, please see the NOTICE file in the top level
+ * * directory of this distribution.
+ *
+ */
+
+package org.apache.usergrid.persistence.queue;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.UUID;
+import java.util.concurrent.ConcurrentLinkedQueue;
+
+/**
+ * Default queue manager implementation, uses in memory linked queue
+ */
+public class DefaultQueueManager implements QueueManager {
+ public ConcurrentLinkedQueue<QueueMessage> queue = new ConcurrentLinkedQueue<>();
+ @Override
+ public synchronized List<QueueMessage> getMessages(int limit, int transactionTimeout, int waitTime, Class klass) {
+ List<QueueMessage> returnQueue = new ArrayList<>();
+ for(int i=0;i<limit;i++){
+ if(!queue.isEmpty()){
+ returnQueue.add( queue.remove());
+ }else{
+ break;
+ }
+ }
+ return returnQueue;
+ }
+
+ @Override
+ public void commitMessage(QueueMessage queueMessage) {
+ }
+
+ @Override
+ public void commitMessages(List<QueueMessage> queueMessages) {
+ }
+
+ @Override
+ public synchronized void sendMessages(List bodies) throws IOException {
+ for(Object body : bodies){
+ String uuid = UUID.randomUUID().toString();
+ queue.add(new QueueMessage(uuid,"handle_"+uuid,body));
+ }
+ }
+
+ @Override
+ public synchronized void sendMessage(Object body) throws IOException {
+ String uuid = UUID.randomUUID().toString();
+ queue.add(new QueueMessage(uuid,"handle_"+uuid,body));
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/461c1928/stack/services/src/test/java/org/apache/usergrid/services/TestQueueManager.java
----------------------------------------------------------------------
diff --git a/stack/services/src/test/java/org/apache/usergrid/services/TestQueueManager.java b/stack/services/src/test/java/org/apache/usergrid/services/TestQueueManager.java
deleted file mode 100644
index 37fef40..0000000
--- a/stack/services/src/test/java/org/apache/usergrid/services/TestQueueManager.java
+++ /dev/null
@@ -1,65 +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.services;
-
-import org.apache.usergrid.persistence.queue.QueueManager;
-import org.apache.usergrid.persistence.queue.QueueMessage;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.UUID;
-import java.util.concurrent.ConcurrentLinkedQueue;
-
-
-public class TestQueueManager implements QueueManager {
- public ConcurrentLinkedQueue<QueueMessage> queue = new ConcurrentLinkedQueue<>();
- @Override
- public synchronized List<QueueMessage> getMessages(int limit, int transactionTimeout, int waitTime, Class klass) {
- List<QueueMessage> returnQueue = new ArrayList<>();
- for(int i=0;i<limit;i++){
- if(!queue.isEmpty()){
- returnQueue.add( queue.remove());
- }else{
- break;
- }
- }
- return returnQueue;
- }
-
- @Override
- public void commitMessage(QueueMessage queueMessage) {
- }
-
- @Override
- public void commitMessages(List<QueueMessage> queueMessages) {
- }
-
- @Override
- public synchronized void sendMessages(List bodies) throws IOException {
- for(Object body : bodies){
- String uuid = UUID.randomUUID().toString();
- queue.add(new QueueMessage(uuid,"handle_"+uuid,body));
- }
- }
-
- @Override
- public synchronized void sendMessage(Object body) throws IOException {
- String uuid = UUID.randomUUID().toString();
- queue.add(new QueueMessage(uuid,"handle_"+uuid,body));
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/461c1928/stack/services/src/test/java/org/apache/usergrid/services/notifications/apns/NotificationsServiceIT.java
----------------------------------------------------------------------
diff --git a/stack/services/src/test/java/org/apache/usergrid/services/notifications/apns/NotificationsServiceIT.java b/stack/services/src/test/java/org/apache/usergrid/services/notifications/apns/NotificationsServiceIT.java
index 0a5375f..3f42777 100644
--- a/stack/services/src/test/java/org/apache/usergrid/services/notifications/apns/NotificationsServiceIT.java
+++ b/stack/services/src/test/java/org/apache/usergrid/services/notifications/apns/NotificationsServiceIT.java
@@ -21,7 +21,7 @@ import org.apache.commons.io.IOUtils;
import org.apache.usergrid.persistence.*;
import org.apache.usergrid.persistence.entities.*;
import org.apache.usergrid.persistence.index.query.Query;
-import org.apache.usergrid.services.TestQueueManager;
+import org.apache.usergrid.persistence.queue.DefaultQueueManager;
import org.apache.usergrid.services.notifications.*;
import org.junit.*;
import org.slf4j.Logger;
@@ -121,7 +121,7 @@ public class NotificationsServiceIT extends AbstractServiceNotificationIT {
ns = getNotificationService();
- TestQueueManager qm = new TestQueueManager();
+ DefaultQueueManager qm = new DefaultQueueManager();
ns.TEST_QUEUE_MANAGER = qm;
app.getEntityManager().refreshIndex();
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/461c1928/stack/services/src/test/java/org/apache/usergrid/services/notifications/gcm/NotificationsServiceIT.java
----------------------------------------------------------------------
diff --git a/stack/services/src/test/java/org/apache/usergrid/services/notifications/gcm/NotificationsServiceIT.java b/stack/services/src/test/java/org/apache/usergrid/services/notifications/gcm/NotificationsServiceIT.java
index 5228464..4b41d13 100644
--- a/stack/services/src/test/java/org/apache/usergrid/services/notifications/gcm/NotificationsServiceIT.java
+++ b/stack/services/src/test/java/org/apache/usergrid/services/notifications/gcm/NotificationsServiceIT.java
@@ -18,7 +18,7 @@ package org.apache.usergrid.services.notifications.gcm;
import org.apache.usergrid.persistence.*;
import org.apache.usergrid.persistence.entities.*;
-import org.apache.usergrid.services.TestQueueManager;
+import org.apache.usergrid.persistence.queue.DefaultQueueManager;
import org.apache.usergrid.services.notifications.*;
import org.junit.*;
import org.slf4j.Logger;
@@ -93,7 +93,7 @@ public class NotificationsServiceIT extends AbstractServiceNotificationIT {
device2 = app.getEntityManager().get(e.getUuid(), Device.class);
ns = getNotificationService();
- TestQueueManager qm = new TestQueueManager();
+ DefaultQueueManager qm = new DefaultQueueManager();
ns.TEST_QUEUE_MANAGER = qm;
listener = new QueueListener(ns.getServiceManagerFactory(), ns.getEntityManagerFactory(),ns.getMetricsFactory(), new Properties());
[40/41] incubator-usergrid git commit: Merge remote-tracking branch
'origin/two-dot-o' into USERGRID-252
Posted by sf...@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/43ed8464
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/43ed8464
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/43ed8464
Branch: refs/heads/UG-rest-test-framework-overhaul
Commit: 43ed8464f81316619f3985a43fb61d2a0aa1c78a
Parents: 5d4ce72 04679c8
Author: Todd Nine <tn...@apigee.com>
Authored: Tue Dec 9 17:31:33 2014 -0700
Committer: Todd Nine <tn...@apigee.com>
Committed: Tue Dec 9 17:31:33 2014 -0700
----------------------------------------------------------------------
.../corepersistence/CpEntityManagerFactory.java | 4 +-
.../persistence/index/AliasedEntityIndex.java | 48 ++++++++
.../usergrid/persistence/index/EntityIndex.java | 5 -
.../usergrid/persistence/index/IndexFig.java | 3 +
.../index/impl/EsEntityIndexBatchImpl.java | 38 +++++--
.../index/impl/EsEntityIndexImpl.java | 44 ++++---
.../persistence/index/impl/EsIndexCache.java | 114 +++++++++++++++++++
.../persistence/index/impl/EntityIndexTest.java | 61 +++++++---
8 files changed, 273 insertions(+), 44 deletions(-)
----------------------------------------------------------------------
[10/41] incubator-usergrid git commit: Added ability to run the tests
via shell script
Posted by sf...@apache.org.
Added ability to run the tests via shell 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/d52a185a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/d52a185a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/d52a185a
Branch: refs/heads/UG-rest-test-framework-overhaul
Commit: d52a185aed3df969cb85e11db1470144a32f9992
Parents: 38871cc
Author: Todd Nine <tn...@apigee.com>
Authored: Fri Dec 5 10:56:11 2014 -0700
Committer: Todd Nine <tn...@apigee.com>
Committed: Fri Dec 5 10:56:11 2014 -0700
----------------------------------------------------------------------
stack/loadtests/runtests.sh | 107 +++++++++++++++++++++++++++++++++++++++
1 file changed, 107 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/d52a185a/stack/loadtests/runtests.sh
----------------------------------------------------------------------
diff --git a/stack/loadtests/runtests.sh b/stack/loadtests/runtests.sh
new file mode 100755
index 0000000..171d561
--- /dev/null
+++ b/stack/loadtests/runtests.sh
@@ -0,0 +1,107 @@
+#!/bin/bash
+
+die() { echo "$@" 1>&2 ; exit 1; }
+
+####
+#This is a script to simplify running gatling tests. It will default several parameters, invoke the maven plugins
+#Then aggregate the results
+####
+[ "$#" -eq 4 ] || die "4 arguments required, $# provided. Example is $0 URL MAX_CONCURRENT_USERS RAMP_TIME(seconds) DURATION_TIME(seconds)"
+
+URL="$1"
+MAX_CONCURRENT_USERS="$2"
+RAMP_TIME="$3"
+DURATION_TIME="$4"
+
+shift 4
+
+#Compile everything
+mvn compile
+
+#Set the app id to be a date epoch for uniqueness
+APP1=$(date +%s)
+
+
+
+#Execute the post step
+mvn gatling:execute -Dorg=usergrid \
+-Dbaseurl=${URL} \
+-DmaxPossibleUsers=${MAX_CONCURRENT_USERS} \
+-DmaxPossibleUsers=${RAMP_TIME} \
+-DadminUser=usergrid \
+-DadminPassword=test \
+-Dduration=${DURATION_TIME} \
+-Dgatling.simulationClass=org.apache.usergrid.simulations.PostUsersSimulation \
+-Dapp=${APP1}
+
+
+#Execute the get users by username
+mvn gatling:execute -Dorg=usergrid \
+-Dbaseurl=${URL} \
+-DmaxPossibleUsers=${MAX_CONCURRENT_USERS} \
+-DmaxPossibleUsers=${RAMP_TIME} \
+-DadminUser=usergrid \
+-DadminPassword=test \
+-Dduration=${DURATION_TIME} \
+-Dgatling.simulationClass=org.apache.usergrid.simulations.GetUsersSimulation \
+-Dapp=${APP1}
+
+
+#Execute the get users by page
+mvn gatling:execute -Dorg=usergrid \
+-Dbaseurl=${URL} \
+-DmaxPossibleUsers=${MAX_CONCURRENT_USERS} \
+-DmaxPossibleUsers=${RAMP_TIME} \
+-DadminUser=usergrid \
+-DadminPassword=test \
+-Dduration=${DURATION_TIME} \
+-Dgatling.simulationClass=org.apache.usergrid.simulations.GetUserPagesSimulation \
+-Dapp=${APP1}
+
+
+APP2=$(date +%s)
+
+#Execute put users to create them
+mvn gatling:execute -Dorg=usergrid \
+-Dbaseurl=${URL} \
+-DmaxPossibleUsers=${MAX_CONCURRENT_USERS} \
+-DmaxPossibleUsers=${RAMP_TIME} \
+-DadminUser=usergrid \
+-DadminPassword=test \
+-Dduration=${DURATION_TIME} \
+-Dgatling.simulationClass=org.apache.usergrid.simulations.PutUsersSimulation \
+-Dapp=${APP2}
+
+#Execute the put users to update them
+mvn gatling:execute -Dorg=usergrid \
+-Dbaseurl=${URL} \
+-DmaxPossibleUsers=${MAX_CONCURRENT_USERS} \
+-DmaxPossibleUsers=${RAMP_TIME} \
+-DadminUser=usergrid \
+-DadminPassword=test \
+-Dduration=${DURATION_TIME} \
+-Dgatling.simulationClass=org.apache.usergrid.simulations.PutUsersSimulation \
+-Dapp=${APP2}
+
+
+#Execute the delete to remove them
+mvn gatling:execute -Dorg=usergrid \
+-Dbaseurl=${URL} \
+-DmaxPossibleUsers=${MAX_CONCURRENT_USERS} \
+-DmaxPossibleUsers=${RAMP_TIME} \
+-DadminUser=usergrid \
+-DadminPassword=test \
+-Dduration=${DURATION_TIME} \
+-Dgatling.simulationClass=org.apache.usergrid.simulations.DeleteUsersSimulation \
+-Dapp=${APP2}
+
+
+#Now move all the reports
+#AGGREGATE_DIR="target/aggregate-$(date +%s)"
+
+#mkdir -p ${AGGREGATE_DIR}
+
+
+#copy to the format of target/aggregate(date)/(simnulationame)-simulation.log
+#find target -name "simulation.log" -exec cp {} ${AGGREGATE_DIR}/$(basename $(dirname {} ))-simulation.log \;
+
[41/41] incubator-usergrid git commit: Merge branch 'two-dot-o' into
UG-rest-test-framework-overhaul
Posted by sf...@apache.org.
Merge branch 'two-dot-o' into UG-rest-test-framework-overhaul
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/7a0c3781
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/7a0c3781
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/7a0c3781
Branch: refs/heads/UG-rest-test-framework-overhaul
Commit: 7a0c378163488dd310e5c7141b1fb701dec9c6b5
Parents: 7dd658b 43ed846
Author: Shawn Feldman <sf...@apache.org>
Authored: Wed Dec 10 10:13:18 2014 -0700
Committer: Shawn Feldman <sf...@apache.org>
Committed: Wed Dec 10 10:13:18 2014 -0700
----------------------------------------------------------------------
.../main/dist/init_instance/init_rest_server.sh | 18 +-
.../corepersistence/CpEntityManager.java | 230 ++++++++++---------
.../corepersistence/CpEntityManagerFactory.java | 4 +-
.../corepersistence/util/CpEntityMapUtils.java | 32 ++-
.../batch/job/SchedulerRuntimeIntervalIT.java | 49 ++--
.../migration/EntityDataMigrationIT.java | 139 +++++------
.../migration/EntityTypeMappingMigrationIT.java | 89 +++----
.../apache/usergrid/persistence/CounterIT.java | 89 ++++---
.../usergrid/persistence/CountingMutatorIT.java | 4 +-
.../persistence/EntityDictionaryIT.java | 11 +-
.../usergrid/persistence/EntityManagerIT.java | 47 ++--
.../persistence/GeoQueryBooleanTest.java | 7 +-
.../apache/usergrid/persistence/IndexIT.java | 14 +-
.../usergrid/persistence/PathQueryIT.java | 10 +-
.../PerformanceEntityRebuildIndexTest.java | 6 +-
.../usergrid/persistence/PermissionsIT.java | 5 +-
.../cassandra/EntityManagerFactoryImplIT.java | 9 +-
.../query/AbstractIteratingQueryIT.java | 3 +-
stack/core/src/test/resources/log4j.properties | 5 +-
.../data/DataMigrationManagerImpl.java | 29 ++-
.../persistence/index/AliasedEntityIndex.java | 48 ++++
.../usergrid/persistence/index/EntityIndex.java | 5 -
.../usergrid/persistence/index/IndexFig.java | 3 +
.../persistence/index/IndexIdentifier.java | 4 +
.../index/impl/EsEntityIndexBatchImpl.java | 38 ++-
.../index/impl/EsEntityIndexImpl.java | 106 +++++----
.../persistence/index/impl/EsIndexCache.java | 114 +++++++++
.../persistence/index/impl/EntityIndexTest.java | 61 +++--
.../persistence/queue/DefaultQueueManager.java | 68 ++++++
stack/loadtests/runtests.sh | 120 ++++++++++
.../apache/usergrid/helpers/Extractors.scala | 84 +++++++
.../org/apache/usergrid/helpers/Setup.scala | 30 +--
.../usergrid/scenarios/UserScenarios.scala | 177 ++++++++++----
.../org/apache/usergrid/settings/Headers.scala | 6 +-
.../simulations/DeleteUsersSimulation.scala | 56 +++++
.../simulations/GetUserPagesSimulation.scala | 51 ++++
.../simulations/GetUsersSimulation.scala | 51 ++++
.../simulations/PutUsersSimulation.scala | 56 +++++
.../usergrid/services/TestQueueManager.java | 65 ------
.../AbstractServiceNotificationIT.java | 16 +-
.../apns/NotificationsServiceIT.java | 12 +-
.../gcm/NotificationsServiceIT.java | 15 +-
42 files changed, 1418 insertions(+), 568 deletions(-)
----------------------------------------------------------------------
[23/41] incubator-usergrid git commit: fix tests
Posted by sf...@apache.org.
fix 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/3d9137e3
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/3d9137e3
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/3d9137e3
Branch: refs/heads/UG-rest-test-framework-overhaul
Commit: 3d9137e34d9080b6ea15de301470bcb7ca704a8f
Parents: 4d04da8
Author: Shawn Feldman <sf...@apache.org>
Authored: Mon Dec 8 09:28:09 2014 -0700
Committer: Shawn Feldman <sf...@apache.org>
Committed: Mon Dec 8 09:28:09 2014 -0700
----------------------------------------------------------------------
.../usergrid/persistence/index/impl/EntityIndexTest.java | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/3d9137e3/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityIndexTest.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityIndexTest.java b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityIndexTest.java
index ced682b..d00796d 100644
--- a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityIndexTest.java
+++ b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityIndexTest.java
@@ -88,7 +88,7 @@ public class EntityIndexTest extends BaseIT {
IndexScope indexScope = new IndexScopeImpl( appId, "things" );
final SearchTypes searchTypes = SearchTypes.fromTypes( entityType );
- insertJsonBlob(entityIndex, entityType, indexScope, "/sample-large.json",100,0);
+ insertJsonBlob(entityIndex, entityType, indexScope, "/sample-large.json",101,0);
entityIndex.refresh();
@@ -122,7 +122,7 @@ public class EntityIndexTest extends BaseIT {
IndexScope indexScope = new IndexScopeImpl( appId, "things" );
final SearchTypes searchTypes = SearchTypes.fromTypes( entityType );
- insertJsonBlob(entityIndex, entityType, indexScope, "/sample-large.json",100,0);
+ insertJsonBlob(entityIndex, entityType, indexScope, "/sample-large.json",101,0);
entityIndex.refresh();
@@ -130,7 +130,7 @@ public class EntityIndexTest extends BaseIT {
entityIndex.addIndex("v2", 1,0);
- insertJsonBlob(entityIndex, entityType, indexScope, "/sample-large.json",100,100);
+ insertJsonBlob(entityIndex, entityType, indexScope, "/sample-large.json",101,100);
entityIndex.refresh();
[14/41] incubator-usergrid git commit: Added license headers to files
Posted by sf...@apache.org.
Added license headers to files
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/ecce52d4
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/ecce52d4
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/ecce52d4
Branch: refs/heads/UG-rest-test-framework-overhaul
Commit: ecce52d4fcda80cd063cccbb6ea4934c30c36777
Parents: 1b239b7
Author: Todd Nine <tn...@apigee.com>
Authored: Fri Dec 5 14:15:24 2014 -0700
Committer: Todd Nine <tn...@apigee.com>
Committed: Fri Dec 5 14:15:24 2014 -0700
----------------------------------------------------------------------
stack/loadtests/runtests.sh | 13 ++++++
.../apache/usergrid/helpers/Extractors.scala | 49 ++++++++++----------
.../org/apache/usergrid/helpers/Setup.scala | 30 ++++++------
3 files changed, 53 insertions(+), 39 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/ecce52d4/stack/loadtests/runtests.sh
----------------------------------------------------------------------
diff --git a/stack/loadtests/runtests.sh b/stack/loadtests/runtests.sh
index 171d561..0897d25 100755
--- a/stack/loadtests/runtests.sh
+++ b/stack/loadtests/runtests.sh
@@ -1,4 +1,17 @@
#!/bin/bash
+#
+# Licensed 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.
+#
die() { echo "$@" 1>&2 ; exit 1; }
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/ecce52d4/stack/loadtests/src/main/scala/org/apache/usergrid/helpers/Extractors.scala
----------------------------------------------------------------------
diff --git a/stack/loadtests/src/main/scala/org/apache/usergrid/helpers/Extractors.scala b/stack/loadtests/src/main/scala/org/apache/usergrid/helpers/Extractors.scala
index 3e85712..aa8c614 100644
--- a/stack/loadtests/src/main/scala/org/apache/usergrid/helpers/Extractors.scala
+++ b/stack/loadtests/src/main/scala/org/apache/usergrid/helpers/Extractors.scala
@@ -1,35 +1,37 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. The ASF licenses this file to You
+ * under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License. For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ *
+ */
package org.apache.usergrid.helpers
import io.gatling.core.Predef._
import io.gatling.core.session._
import io.gatling.http.Predef._
-import scala.util.parsing.json.JSONArray
-
/**
* Helper object that will perform extractions
*/
object Extractors {
-// /**
-// * Will extract the cursor from the response. If the cursor is not present, an empty string will be set
-// */
-// val maybeExtractCursor = jsonPath("$..cursor").transformOption( extract => {
-// //it may or may not be present. If it is, save it, otherwise save it as an empty string
-// extract.orElse(Some(""))
-// }).saveAs("cursor")
-//
-// /**
-// * Will extract entities as a json array into the session. If they do not exist, it will set to an empty list
-// */
-// val maybeExtractEntities = jsonPath("..entities").transformOption(extract => {
-// extract.orElse(Some(JSONArray(List())));
-// }).saveAs("entities")
-
/**
* Will extract the cursor from the response. If the cursor is not present, an empty string will be set
*/
- def maybeExtractCursor(saveAsName : String) = {
+ def maybeExtractCursor(saveAsName: String) = {
jsonPath("$..cursor").transformOption(extract => {
//it may or may not be present. If it is, save it, otherwise save it as an empty string
extract.orElse(Some(""))
@@ -42,7 +44,7 @@ object Extractors {
* @param nameInSession The name of the variable in the session
* @return
*/
- def stringParamExists (nameInSession: String) : Expression[Boolean] = {
+ def stringParamExists(nameInSession: String): Expression[Boolean] = {
session => session(nameInSession) != null && session(nameInSession).as[String] != ""
}
@@ -61,12 +63,12 @@ object Extractors {
* @param nameInSession The name ot use when saving to the session
* @return
*/
- def sequenceHasElements(nameInSession: String) : Expression[Boolean] = {
+ def sequenceHasElements(nameInSession: String): Expression[Boolean] = {
session => session(nameInSession) != null && session(nameInSession).as[Seq[Any]].length > 0
}
- val ManagementToken: String = Setup.getManagementToken()
+ val ManagementToken: String = Setup.getManagementToken()
/**
@@ -74,10 +76,9 @@ object Extractors {
* under the variable "authToken"
* @return
*/
- def injectStaticTokenToSession() : Expression[Session] = {
- session => session.set("authToken", ManagementToken)
+ def injectStaticTokenToSession(): Expression[Session] = {
+ session => session.set("authToken", ManagementToken)
}
-
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/ecce52d4/stack/loadtests/src/main/scala/org/apache/usergrid/helpers/Setup.scala
----------------------------------------------------------------------
diff --git a/stack/loadtests/src/main/scala/org/apache/usergrid/helpers/Setup.scala b/stack/loadtests/src/main/scala/org/apache/usergrid/helpers/Setup.scala
index 2dd0ed7..fb0bcde 100644
--- a/stack/loadtests/src/main/scala/org/apache/usergrid/helpers/Setup.scala
+++ b/stack/loadtests/src/main/scala/org/apache/usergrid/helpers/Setup.scala
@@ -1,20 +1,20 @@
/*
*
- * * Licensed to the Apache Software Foundation (ASF) under one or more
- * * contributor license agreements. The ASF licenses this file to You
- * * under the Apache License, Version 2.0 (the "License"); you may not
- * * use this file except in compliance with the License.
- * * You may obtain a copy of the License at
- * *
- * * http://www.apache.org/licenses/LICENSE-2.0
- * *
- * * Unless required by applicable law or agreed to in writing, software
- * * distributed under the License is distributed on an "AS IS" BASIS,
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * * See the License for the specific language governing permissions and
- * * limitations under the License. For additional information regarding
- * * copyright in this work, please see the NOTICE file in the top level
- * * directory of this distribution.
+ * 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.
*
*/
[39/41] incubator-usergrid git commit: Removed subscribeOnCalls
Posted by sf...@apache.org.
Removed subscribeOnCalls
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/04679c82
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/04679c82
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/04679c82
Branch: refs/heads/UG-rest-test-framework-overhaul
Commit: 04679c82a5a5cac1427c9775d40f3f3d76f30bff
Parents: 18197e3
Author: Todd Nine <tn...@apigee.com>
Authored: Tue Dec 9 17:17:12 2014 -0700
Committer: Todd Nine <tn...@apigee.com>
Committed: Tue Dec 9 17:17:12 2014 -0700
----------------------------------------------------------------------
.../usergrid/persistence/index/impl/EsEntityIndexBatchImpl.java | 2 +-
.../apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/04679c82/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexBatchImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexBatchImpl.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexBatchImpl.java
index cd5be7f..99a08da 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexBatchImpl.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexBatchImpl.java
@@ -192,7 +192,7 @@ public class EsEntityIndexBatchImpl implements EntityIndexBatch {
indexes = new String[]{indexIdentifier.getIndex(null)};
}
//get all indexes then flush everyone
- Observable.from(indexes).subscribeOn(Schedulers.io())
+ Observable.from(indexes)
.map(new Func1<String, Object>() {
@Override
public Object call(String index) {
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/04679c82/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java
index a6e9337..67e1680 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java
@@ -444,7 +444,7 @@ public class EsEntityIndexImpl implements AliasedEntityIndex {
public boolean doOp() {
try {
String[] indexes = getIndexes(AliasType.Read);
- Observable.from(indexes).subscribeOn(Schedulers.io()).map(new Func1<String, String>() {
+ Observable.from(indexes).map(new Func1<String, String>() {
@Override
public String call(String index) {
esProvider.getClient().admin().indices().prepareRefresh( index ).execute().actionGet();
[29/41] incubator-usergrid git commit: Fix in original value test
logic.
Posted by sf...@apache.org.
Fix in original value test logic.
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/e29a99e8
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/e29a99e8
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/e29a99e8
Branch: refs/heads/UG-rest-test-framework-overhaul
Commit: e29a99e8bce2610a9281fe89de23b5c5b4ec72ba
Parents: 2016476
Author: Dave Johnson <dm...@apigee.com>
Authored: Mon Dec 8 15:46:18 2014 -0500
Committer: Dave Johnson <dm...@apigee.com>
Committed: Mon Dec 8 15:46:18 2014 -0500
----------------------------------------------------------------------
.../org/apache/usergrid/persistence/CounterIT.java | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e29a99e8/stack/core/src/test/java/org/apache/usergrid/persistence/CounterIT.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/CounterIT.java b/stack/core/src/test/java/org/apache/usergrid/persistence/CounterIT.java
index ab7d41e..e360244 100644
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/CounterIT.java
+++ b/stack/core/src/test/java/org/apache/usergrid/persistence/CounterIT.java
@@ -1,4 +1,5 @@
/*
+
* 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.
@@ -193,11 +194,22 @@ public class CounterIT extends AbstractCoreIT {
query.setStartTime( ts );
query.setFinishTime( System.currentTimeMillis() );
query.setResolution( CounterResolution.SIX_HOUR );
+
Results or = em.getAggregateCounters( query );
- long originalCount = or.getCounters().get( 0 ).getValues().get( 0 ).getValue();
+ final long originalCount;
+ if ( or.getCounters().get( 0 ).getValues().isEmpty() ) {
+ originalCount = 0;
+ } else {
+ originalCount = or.getCounters().get( 0 ).getValues().get( 0 ).getValue();
+ }
Map<String, Long> counts = em.getApplicationCounters();
- long originalAdminLoginsCount = counts.get( "admin.logins" ).longValue();
+ final long originalAdminLoginsCount;
+ if ( counts.get( "admin.logins" ) == null ) {
+ originalAdminLoginsCount = 0;
+ } else {
+ originalAdminLoginsCount = counts.get( "admin.logins" );
+ }
String randomSuffix = RandomStringUtils.randomAlphabetic(20);
String orgName = "testCounter" + randomSuffix;