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 2015/06/09 19:30:48 UTC
[2/4] incubator-usergrid git commit: new index strategy
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/ab7c8e21/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexIdentifierv2Impl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexIdentifierv2Impl.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexIdentifierv2Impl.java
index c438abe..b36eac5 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexIdentifierv2Impl.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexIdentifierv2Impl.java
@@ -20,68 +20,3 @@
package org.apache.usergrid.persistence.index.impl;
-import com.google.inject.Inject;
-
-import org.apache.usergrid.persistence.core.astyanax.CassandraFig;
-import org.apache.usergrid.persistence.core.util.StringUtils;
-import org.apache.usergrid.persistence.index.IndexFig;
-import org.apache.usergrid.persistence.index.IndexIdentifier;
-
-
-/**
- * Class is used to generate an index name and alias name
- */
-public class IndexIdentifierv2Impl implements IndexIdentifier {
- private final CassandraFig cassandraFig;
- private final IndexFig indexFig;
- private final String prefix;
-
- @Inject
- public IndexIdentifierv2Impl(final CassandraFig cassandraFig, final IndexFig config) {
- this.cassandraFig = cassandraFig;
- this.indexFig = config;
- this.prefix = getPrefix();
- }
-
- private String getPrefix() {
- //remove usergrid
- final String indexPrefixConfig = StringUtils.isNotEmpty(indexFig.getIndexPrefix())
- ? indexFig.getIndexPrefix().toLowerCase() ////use lowercase value
- : "usergrid"; // default to something so its not null
- final String keyspaceName = cassandraFig.getApplicationKeyspace().toLowerCase();
- //check for repetition
- final boolean removePrefix = indexPrefixConfig.contains("usergrid") && keyspaceName.contains("usergrid");
- return !removePrefix
- ? indexPrefixConfig + "_" + keyspaceName
- : keyspaceName;
- }
-
- /**
- * Get the alias name
- * @return
- */
- @Override
- public IndexAlias getAlias() {
- return new IndexAlias(indexFig,prefix);
- }
-
- /**
- * Get index name, send in additional parameter to add incremental indexes
- * @param suffix
- * @return
- */
- @Override
- public String getIndex(String suffix) {
- if (suffix != null) {
- return prefix + "_" + suffix;
- } else {
- return prefix;
- }
- }
-
-
- @Override
- public String toString() {
- return "index id: "+prefix;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/ab7c8e21/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexLocationStrategy.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexLocationStrategy.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexLocationStrategy.java
deleted file mode 100644
index 89ecdeb..0000000
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexLocationStrategy.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- *
- * * Licensed to the Apache Software Foundation (ASF) under one or more
- * * contributor license agreements. The ASF licenses this file to You
- * * under the Apache License, Version 2.0 (the "License"); you may not
- * * use this file except in compliance with the License.
- * * You may obtain a copy of the License at
- * *
- * * http://www.apache.org/licenses/LICENSE-2.0
- * *
- * * Unless required by applicable law or agreed to in writing, software
- * * distributed under the License is distributed on an "AS IS" BASIS,
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * * See the License for the specific language governing permissions and
- * * limitations under the License. For additional information regarding
- * * copyright in this work, please see the NOTICE file in the top level
- * * directory of this distribution.
- *
- */
-package org.apache.usergrid.persistence.index.impl;
-
-import org.apache.usergrid.persistence.core.scope.ApplicationScope;
-import org.apache.usergrid.persistence.index.IndexIdentifier;
-
-/**
- * Classy class class.
- */
-public interface IndexLocationStrategy {
- IndexIdentifier getIndexIdentifier();
- ApplicationScope getApplicationScope();
- void validateApplicationScope();// ValidationUtils.validateApplicationScope( appScope );
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/ab7c8e21/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexRefreshCommandImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexRefreshCommandImpl.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexRefreshCommandImpl.java
index 28bd73d..0515a64 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexRefreshCommandImpl.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexRefreshCommandImpl.java
@@ -55,7 +55,6 @@ import rx.Observable;
public class IndexRefreshCommandImpl implements IndexRefreshCommand {
private static final Logger logger = LoggerFactory.getLogger( IndexRefreshCommandImpl.class );
- private final IndexAlias alias;
private final IndexCache indexCache;
private final EsProvider esProvider;
private final IndexBufferConsumer producer;
@@ -64,13 +63,15 @@ public class IndexRefreshCommandImpl implements IndexRefreshCommand {
@Inject
- public IndexRefreshCommandImpl( IndexIdentifier indexIdentifier, EsProvider esProvider,
- IndexBufferConsumer producer, IndexFig indexFig, MetricsFactory metricsFactory,
+ public IndexRefreshCommandImpl(
+ final EsProvider esProvider,
+ final IndexBufferConsumer producer,
+ final IndexFig indexFig,
+ final MetricsFactory metricsFactory,
final IndexCache indexCache ) {
this.timer = metricsFactory.getTimer( IndexRefreshCommandImpl.class, "index.refresh.timer" );
- this.alias = indexIdentifier.getAlias();
this.esProvider = esProvider;
this.producer = producer;
this.indexFig = indexFig;
@@ -79,7 +80,7 @@ public class IndexRefreshCommandImpl implements IndexRefreshCommand {
@Override
- public Observable<IndexRefreshCommandInfo> execute( String[] indexes ) {
+ public Observable<IndexRefreshCommandInfo> execute(IndexAlias alias, String[] indexes ) {
final long start = System.currentTimeMillis();
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/ab7c8e21/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/SearchRequestBuilderStrategy.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/SearchRequestBuilderStrategy.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/SearchRequestBuilderStrategy.java
index 2ac6bcb..506ba2b 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/SearchRequestBuilderStrategy.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/SearchRequestBuilderStrategy.java
@@ -20,6 +20,7 @@
package org.apache.usergrid.persistence.index.impl;
+import org.apache.usergrid.persistence.index.IndexAlias;
import org.elasticsearch.action.search.SearchRequestBuilder;
import org.elasticsearch.action.search.SearchType;
import org.elasticsearch.index.query.BoolFilterBuilder;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/ab7c8e21/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/ElasticSearchRule.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/ElasticSearchRule.java b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/ElasticSearchRule.java
index 1223dac..7d0522a 100644
--- a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/ElasticSearchRule.java
+++ b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/ElasticSearchRule.java
@@ -41,18 +41,9 @@ public class ElasticSearchRule extends ExternalResource {
private static final Logger logger = LoggerFactory.getLogger( ElasticSearchRule.class );
- private EntityIndex entityIndex;
-
- @Inject
- public void setMigrationManager( final EntityIndex entityIndex ) {
- this.entityIndex = entityIndex;
- }
-
-
@Override
protected void before() throws MigrationException {
logger.info( "Initializing index" );
- entityIndex.initialize();
}
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/ab7c8e21/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 4ce2636..55b61ac 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
@@ -31,6 +31,7 @@ import java.util.concurrent.atomic.AtomicLong;
import com.google.common.base.Optional;
import org.apache.usergrid.persistence.core.astyanax.CassandraFig;
import org.apache.usergrid.persistence.index.*;
+import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -39,7 +40,6 @@ import org.slf4j.LoggerFactory;
import org.apache.commons.lang3.time.StopWatch;
-import org.apache.usergrid.persistence.core.scope.ApplicationScope;
import org.apache.usergrid.persistence.core.scope.ApplicationScopeImpl;
import org.apache.usergrid.persistence.core.test.UseModules;
import org.apache.usergrid.persistence.core.util.Health;
@@ -77,14 +77,6 @@ public class EntityIndexTest extends BaseIT {
@Inject
public EntityIndexFactory eif;
- @Inject
- public EntityIndex ei;
-
- @Inject
- public IndexIdentifierv1Impl identifierv1;
-
- @Inject
- public IndexIdentifierv2Impl identifierv2;
@Inject
public IndexFig fig;
@@ -95,24 +87,31 @@ public class EntityIndexTest extends BaseIT {
@Inject
@Rule
public ElasticSearchRule elasticSearchRule;
+ private AliasedEntityIndex entityIndex;
+ private SimpleId appId;
+
+ @Before
+ public void setup(){
+ appId = new SimpleId(UUID.randomUUID(), "application" );
+ IndexLocationStrategy strategy = new TestIndexIdentifier(cassandraFig,fig,new ApplicationScopeImpl(appId));
+
+ entityIndex = eif.createEntityIndex( strategy );
+ }
@Test
public void testIndex() throws IOException, InterruptedException {
- Id appId = new SimpleId( "application" );
- ApplicationScope applicationScope = new ApplicationScopeImpl( appId );
- ApplicationEntityIndex entityIndex = eif.createApplicationEntityIndex( applicationScope );
final String entityType = "thing";
IndexEdge searchEdge = new IndexEdgeImpl( appId, "things", SearchEdge.NodeType.SOURCE, 1 );
final SearchTypes searchTypes = SearchTypes.fromTypes( entityType );
- insertJsonBlob( entityIndex, entityType, searchEdge, "/sample-large.json", 101, 0 );
+ insertJsonBlob( entityType, searchEdge, "/sample-large.json", 101, 0 );
- testQueries( searchEdge, searchTypes, entityIndex );
+ testQueries( searchEdge, searchTypes );
}
@@ -122,11 +121,6 @@ public class EntityIndexTest extends BaseIT {
@Test
public void testIndexVariations() throws IOException {
Id appId = new SimpleId( "application" );
-
- ApplicationScope applicationScope = new ApplicationScopeImpl( appId );
-
- ApplicationEntityIndex entityIndex = eif.createApplicationEntityIndex( applicationScope );
-
final String entityType = "thing";
IndexEdge indexEdge = new IndexEdgeImpl( appId, "things", SearchEdge.NodeType.SOURCE, 1 );
final SearchTypes searchTypes = SearchTypes.fromTypes( entityType );
@@ -157,7 +151,7 @@ public class EntityIndexTest extends BaseIT {
batch.index( indexEdge, entity2 );
batch.execute().toBlocking().last();
- ei.refreshAsync().toBlocking().first();
+ entityIndex.refreshAsync().toBlocking().first();
StopWatch timer = new StopWatch();
@@ -187,14 +181,11 @@ public class EntityIndexTest extends BaseIT {
@Test
public void testIndexThreads() throws IOException {
- final Id appId = new SimpleId( "application" );
- final ApplicationScope applicationScope = new ApplicationScopeImpl( appId );
long now = System.currentTimeMillis();
final int threads = 20;
final int size = 30;
- final ApplicationEntityIndex entityIndex = eif.createApplicationEntityIndex( applicationScope );
final String entityType = "thing";
@@ -240,47 +231,29 @@ public class EntityIndexTest extends BaseIT {
}
- @Test
- public void testMultipleIndexInitializations() {
- Id appId = new SimpleId( "application" );
-
- ApplicationScope applicationScope = new ApplicationScopeImpl( appId );
-
- ApplicationEntityIndex entityIndex = eif.createApplicationEntityIndex( applicationScope );
-
- for ( int i = 0; i < 10; i++ ) {
-
- }
- }
@Test
public void testAddMultipleIndexes() throws IOException {
- Id appId = new SimpleId( "application" );
-
- ApplicationScope applicationScope = new ApplicationScopeImpl( appId );
-
- ApplicationEntityIndex entityIndex = eif.createApplicationEntityIndex( applicationScope );
-
final String entityType = "thing";
IndexEdge searchEdge = new IndexEdgeImpl( appId, "things", SearchEdge.NodeType.SOURCE, 10 );
final SearchTypes searchTypes = SearchTypes.fromTypes(entityType);
- insertJsonBlob(entityIndex, entityType, searchEdge, "/sample-large.json", 101, 0);
+ insertJsonBlob( entityType, searchEdge, "/sample-large.json", 101, 0);
- testQueries(searchEdge, searchTypes, entityIndex);
+ testQueries(searchEdge, searchTypes);
- ei.addIndex("v2", 1, 0, "one");
+ entityIndex.addIndex("v2", 1, 0, "one");
- insertJsonBlob(entityIndex, entityType, searchEdge, "/sample-large.json", 101, 100);
+ insertJsonBlob( entityType, searchEdge, "/sample-large.json", 101, 100);
//Hilda Youn
- testQuery( searchEdge, searchTypes, entityIndex, "name = 'Hilda Young'", 1 );
+ testQuery( searchEdge, searchTypes, "name = 'Hilda Young'", 1 );
- testQuery( searchEdge, searchTypes, entityIndex, "name = 'Lowe Kelley'", 1 );
+ testQuery( searchEdge, searchTypes, "name = 'Lowe Kelley'", 1 );
log.info("hi");
}
@@ -288,38 +261,33 @@ public class EntityIndexTest extends BaseIT {
@Test
public void testDeleteWithAlias() throws IOException {
- Id appId = new SimpleId(UUID.randomUUID(), "application" );
-
- ApplicationScope applicationScope = new ApplicationScopeImpl( appId );
-
- ApplicationEntityIndex entityIndex = eif.createApplicationEntityIndex( applicationScope );
final String entityType = "thing";
IndexEdge searchEdge = new IndexEdgeImpl( appId, "things", SearchEdge.NodeType.SOURCE, 1 );
final SearchTypes searchTypes = SearchTypes.fromTypes( entityType );
- insertJsonBlob( entityIndex, entityType, searchEdge, "/sample-large.json", 1, 0 );
+ insertJsonBlob( entityType, searchEdge, "/sample-large.json", 1, 0 );
- ei.addIndex( "v2", 1, 0, "one" );
- ei.refreshAsync().toBlocking().first();
+ entityIndex.addIndex( "v2", 1, 0, "one" );
+ entityIndex.refreshAsync().toBlocking().first();
- insertJsonBlob( entityIndex, entityType, searchEdge, "/sample-large.json", 1, 1 );
+ insertJsonBlob( entityType, searchEdge, "/sample-large.json", 1, 1 );
- CandidateResults crs = testQuery( searchEdge, searchTypes, entityIndex, "name = 'Bowers Oneil'", 1 );
+ CandidateResults crs = testQuery( searchEdge, searchTypes, "name = 'Bowers Oneil'", 1 );
EntityIndexBatch entityIndexBatch = entityIndex.createBatch();
entityIndexBatch.deindex( searchEdge, crs.get( 0 ) );
entityIndexBatch.execute().toBlocking().last();
- ei.refreshAsync().toBlocking().first();
+ entityIndex.refreshAsync().toBlocking().first();
//Hilda Youn
- testQuery( searchEdge, searchTypes, entityIndex, "name = 'Bowers Oneil'", 0 );
+ testQuery( searchEdge, searchTypes, "name = 'Bowers Oneil'", 0 );
}
- private void insertJsonBlob( ApplicationEntityIndex entityIndex, String entityType, IndexEdge indexEdge,
+ private void insertJsonBlob( String entityType, IndexEdge indexEdge,
String filePath, final int max, final int startIndex ) throws IOException {
InputStream is = this.getClass().getResourceAsStream( filePath );
ObjectMapper mapper = new ObjectMapper();
@@ -327,7 +295,7 @@ public class EntityIndexTest extends BaseIT {
EntityIndexBatch batch = entityIndex.createBatch();
insertJsonBlob( sampleJson, batch, entityType, indexEdge, max, startIndex );
batch.execute().toBlocking().last();
- IndexRefreshCommandImpl.IndexRefreshCommandInfo info = ei.refreshAsync().toBlocking().first();
+ IndexRefreshCommandImpl.IndexRefreshCommandInfo info = entityIndex.refreshAsync().toBlocking().first();
long time = info.getExecutionTime();
log.info( "refresh took ms:" + time );
}
@@ -370,14 +338,7 @@ public class EntityIndexTest extends BaseIT {
@Test
public void testDeindex() {
- Id appId = new SimpleId( "application" );
-
- ApplicationScope applicationScope = new ApplicationScopeImpl( appId );
-
- IndexEdge searchEdge = new IndexEdgeImpl( appId, "fastcars", SearchEdge.NodeType.SOURCE, 1 );
-
- ApplicationEntityIndex entityIndex = eif.createApplicationEntityIndex( applicationScope );
-
+ IndexEdge searchEdge = new IndexEdgeImpl( appId, "fastcars", SearchEdge.NodeType.SOURCE, 1 );
Map entityMap = new HashMap() {{
put( "name", "Ferrari 212 Inter" );
@@ -392,7 +353,7 @@ public class EntityIndexTest extends BaseIT {
entity.setField( new UUIDField( IndexingUtils.ENTITY_ID_FIELDNAME, UUID.randomUUID() ) );
entityIndex.createBatch().index( searchEdge, entity ).execute().toBlocking().last();
- ei.refreshAsync().toBlocking().first();
+ entityIndex.refreshAsync().toBlocking().first();
CandidateResults candidateResults = entityIndex
.search( searchEdge, SearchTypes.fromTypes( entity.getId().getType() ), "name contains 'Ferrari*'", 10, 0 );
@@ -401,7 +362,7 @@ public class EntityIndexTest extends BaseIT {
EntityIndexBatch batch = entityIndex.createBatch();
batch.deindex( searchEdge, entity );
batch.execute().toBlocking().last();
- ei.refreshAsync().toBlocking().first();
+ entityIndex.refreshAsync().toBlocking().first();
candidateResults = entityIndex
.search(searchEdge, SearchTypes.fromTypes( entity.getId().getType() ), "name contains 'Ferrari*'", 10, 0 );
@@ -418,14 +379,8 @@ public class EntityIndexTest extends BaseIT {
int numberOfEntities = 1000;
int versionToSearchFor = numberOfEntities / 2;
- Id appId = new SimpleId( "application" );
-
- ApplicationScope applicationScope = new ApplicationScopeImpl( appId );
-
IndexEdge searchEdge = new IndexEdgeImpl( appId, "mehCars", SearchEdge.NodeType.SOURCE, 1 );
- ApplicationEntityIndex entityIndex = eif.createApplicationEntityIndex( applicationScope );
-
UUID entityUUID = UUID.randomUUID();
Id entityId = new SimpleId( "mehCar" );
@@ -445,7 +400,7 @@ public class EntityIndexTest extends BaseIT {
//index the new entity. This is where the loop will be set to create like 100 entities.
entityIndex.createBatch().index( searchEdge, entity[i] ).execute().toBlocking().last();
}
- ei.refreshAsync().toBlocking().first();
+ entityIndex.refreshAsync().toBlocking().first();
CandidateResults candidateResults = entityIndex
.getAllEntityVersionsBeforeMarkedVersion( entity[versionToSearchFor].getId(),
@@ -456,7 +411,7 @@ public class EntityIndexTest extends BaseIT {
private CandidateResults testQuery( final SearchEdge scope, final SearchTypes searchTypes,
- final ApplicationEntityIndex entityIndex, final String queryString,
+ final String queryString,
final int num ) {
StopWatch timer = new StopWatch();
@@ -471,34 +426,33 @@ public class EntityIndexTest extends BaseIT {
}
- private void testQueries( final SearchEdge scope, SearchTypes searchTypes,
- final ApplicationEntityIndex entityIndex ) {
+ private void testQueries( final SearchEdge scope, SearchTypes searchTypes) {
- testQuery( scope, searchTypes, entityIndex, "name = 'Morgan Pierce'", 1 );
+ testQuery( scope, searchTypes, "name = 'Morgan Pierce'", 1 );
- testQuery( scope, searchTypes, entityIndex, "name = 'morgan pierce'", 1 );
+ testQuery( scope, searchTypes, "name = 'morgan pierce'", 1 );
- testQuery( scope, searchTypes, entityIndex, "name = 'Morgan'", 0 );
+ testQuery( scope, searchTypes, "name = 'Morgan'", 0 );
- testQuery( scope, searchTypes, entityIndex, "name contains 'Morgan'", 1 );
+ testQuery( scope, searchTypes, "name contains 'Morgan'", 1 );
- testQuery( scope, searchTypes, entityIndex, "company > 'GeoLogix'", 64 );
+ testQuery( scope, searchTypes, "company > 'GeoLogix'", 64 );
- testQuery( scope, searchTypes, entityIndex, "gender = 'female'", 45 );
+ testQuery( scope, searchTypes, "gender = 'female'", 45 );
- testQuery( scope, searchTypes, entityIndex, "name = 'Minerva Harrell' and age > 39", 1 );
+ testQuery( scope, searchTypes, "name = 'Minerva Harrell' and age > 39", 1 );
- testQuery( scope, searchTypes, entityIndex, "name = 'Minerva Harrell' and age > 39 and age < 41", 1 );
+ testQuery( scope, searchTypes, "name = 'Minerva Harrell' and age > 39 and age < 41", 1 );
- testQuery( scope, searchTypes, entityIndex, "name = 'Minerva Harrell' and age > 40", 0 );
+ testQuery( scope, searchTypes, "name = 'Minerva Harrell' and age > 40", 0 );
- testQuery( scope, searchTypes, entityIndex, "name = 'Minerva Harrell' and age >= 40", 1 );
+ testQuery( scope, searchTypes, "name = 'Minerva Harrell' and age >= 40", 1 );
- testQuery( scope, searchTypes, entityIndex, "name = 'Minerva Harrell' and age <= 40", 1 );
+ testQuery( scope, searchTypes, "name = 'Minerva Harrell' and age <= 40", 1 );
- testQuery( scope, searchTypes, entityIndex, "name = 'Morgan* '", 1 );
+ testQuery( scope, searchTypes, "name = 'Morgan* '", 1 );
- testQuery( scope, searchTypes, entityIndex, "name = 'Morgan*'", 1 );
+ testQuery( scope, searchTypes, "name = 'Morgan*'", 1 );
// test a couple of array sub-property queries
@@ -506,16 +460,16 @@ public class EntityIndexTest extends BaseIT {
int totalUsers = 102;
// nobody has a friend named Jack the Ripper
- testQuery( scope, searchTypes, entityIndex, "friends.name = 'Jack the Ripper'", 0 );
+ testQuery( scope, searchTypes, "friends.name = 'Jack the Ripper'", 0 );
// everybody doesn't have a friend named Jack the Ripper
- testQuery( scope, searchTypes, entityIndex, "not (friends.name = 'Jack the Ripper')", totalUsers );
+ testQuery( scope, searchTypes, "not (friends.name = 'Jack the Ripper')", totalUsers );
// one person has a friend named Shari Hahn
- testQuery( scope, searchTypes, entityIndex, "friends.name = 'Wendy Moody'", 1 );
+ testQuery( scope, searchTypes, "friends.name = 'Wendy Moody'", 1 );
// everybody but 1 doesn't have a friend named Shari Hahh
- testQuery( scope, searchTypes, entityIndex, "not (friends.name = 'Shari Hahn')", totalUsers - 1 );
+ testQuery( scope, searchTypes, "not (friends.name = 'Shari Hahn')", totalUsers - 1 );
}
@@ -549,14 +503,14 @@ public class EntityIndexTest extends BaseIT {
@Test
public void deleteVerification() throws Throwable {
- Id appId = new SimpleId( "application" );
+
Id ownerId = new SimpleId( "owner" );
- ApplicationScope applicationScope = new ApplicationScopeImpl( appId );
+
IndexEdge indexSCope = new IndexEdgeImpl( ownerId, "user", SearchEdge.NodeType.SOURCE, 10 );
- ApplicationEntityIndex entityIndex = eif.createApplicationEntityIndex( applicationScope );
+
final String middleName = "middleName" + UUIDUtils.newTimeUUID();
@@ -576,7 +530,7 @@ public class EntityIndexTest extends BaseIT {
batch.index( indexSCope, user );
batch.execute().toBlocking().last();
- ei.refreshAsync().toBlocking().first();
+ entityIndex.refreshAsync().toBlocking().first();
final String query = "where username = 'edanuff'";
@@ -585,7 +539,7 @@ public class EntityIndexTest extends BaseIT {
batch.deindex( indexSCope, user.getId(), user.getVersion() );
batch.execute().toBlocking().last();
- ei.refreshAsync().toBlocking().first();
+ entityIndex.refreshAsync().toBlocking().first();
// EntityRef
@@ -601,11 +555,11 @@ public class EntityIndexTest extends BaseIT {
Id appId = new SimpleId( "entityindextest" );
Id ownerId = new SimpleId( "multivaluedtype" );
- ApplicationScope applicationScope = new ApplicationScopeImpl( appId );
+
IndexEdge indexScope = new IndexEdgeImpl( ownerId, "user", SearchEdge.NodeType.SOURCE, 10 );
- ApplicationEntityIndex entityIndex = eif.createApplicationEntityIndex( applicationScope );
+
entityIndex.createBatch();
@@ -646,7 +600,7 @@ public class EntityIndexTest extends BaseIT {
batch.index( indexScope, fred);
batch.execute().toBlocking().last();
- ei.refreshAsync().toBlocking().first();
+ entityIndex.refreshAsync().toBlocking().first();
final SearchTypes searchTypes = SearchTypes.fromTypes( "user" );
@@ -668,11 +622,11 @@ public class EntityIndexTest extends BaseIT {
@Test
public void healthTest() {
Id appId = new SimpleId( "entityindextest" );
- assertNotEquals( "cluster should be ok", Health.RED, ei.getClusterHealth() );
- assertEquals( "index should be ready", Health.GREEN, ei.getIndexHealth() );
- ei.refreshAsync().toBlocking().first();
- assertNotEquals( "cluster should be fine", Health.RED, ei.getIndexHealth() );
- assertNotEquals( "cluster should be ready now", Health.RED, ei.getClusterHealth() );
+ assertNotEquals( "cluster should be ok", Health.RED, entityIndex.getClusterHealth() );
+ assertEquals( "index should be ready", Health.GREEN, entityIndex.getIndexHealth() );
+ entityIndex.refreshAsync().toBlocking().first();
+ assertNotEquals( "cluster should be fine", Health.RED, entityIndex.getIndexHealth() );
+ assertNotEquals( "cluster should be ready now", Health.RED, entityIndex.getClusterHealth() );
}
@@ -680,15 +634,11 @@ public class EntityIndexTest extends BaseIT {
public void testCursorFormat() throws Exception {
String myType = UUID.randomUUID().toString();
- Id appId = new SimpleId(UUID.randomUUID(), "application" );
Id ownerId = new SimpleId( UUID.randomUUID(),"owner" );
- ApplicationScope applicationScope = new ApplicationScopeImpl( appId );
-
- IndexEdge indexEdge = new IndexEdgeImpl( ownerId, "users", SearchEdge.NodeType.SOURCE, 10 );
- ApplicationEntityIndex entityIndex = eif.createApplicationEntityIndex( applicationScope );
+ IndexEdge indexEdge = new IndexEdgeImpl( ownerId, "users", SearchEdge.NodeType.SOURCE, 10 );
final EntityIndexBatch batch = entityIndex.createBatch();
@@ -728,7 +678,7 @@ public class EntityIndexTest extends BaseIT {
batch.execute().toBlocking().last();
- ei.refreshAsync().toBlocking().first();
+ entityIndex.refreshAsync().toBlocking().first();
final int limit = 5;
@@ -769,11 +719,11 @@ public class EntityIndexTest extends BaseIT {
Id appId = new SimpleId( "application" );
Id ownerId = new SimpleId( "owner" );
- ApplicationScope applicationScope = new ApplicationScopeImpl( appId );
+
IndexEdge indexSCope = new IndexEdgeImpl( ownerId, "user", SearchEdge.NodeType.SOURCE, 10 );
- ApplicationEntityIndex entityIndex = eif.createApplicationEntityIndex( applicationScope );
+
final UUID searchUUID = UUIDGenerator.newTimeUUID();
@@ -794,7 +744,7 @@ public class EntityIndexTest extends BaseIT {
batch.index( indexSCope, user );
batch.execute().toBlocking().last();
- ei.refreshAsync().toBlocking().first();
+ entityIndex.refreshAsync().toBlocking().first();
final String query = "where searchUUID = " + searchUUID;
@@ -810,11 +760,11 @@ public class EntityIndexTest extends BaseIT {
Id appId = new SimpleId( "application" );
Id ownerId = new SimpleId( "owner" );
- ApplicationScope applicationScope = new ApplicationScopeImpl( appId );
+
IndexEdge indexSCope = new IndexEdgeImpl( ownerId, "user", SearchEdge.NodeType.SOURCE, 10 );
- ApplicationEntityIndex entityIndex = eif.createApplicationEntityIndex( applicationScope );
+
Map entityMap = new HashMap() {{
@@ -833,7 +783,7 @@ public class EntityIndexTest extends BaseIT {
batch.index( indexSCope, user );
batch.execute().toBlocking().last();
- ei.refreshAsync().toBlocking().first();
+ entityIndex.refreshAsync().toBlocking().first();
final String query = "where string = 'I am*'";
@@ -858,11 +808,11 @@ public class EntityIndexTest extends BaseIT {
Id appId = new SimpleId( "application" );
Id ownerId = new SimpleId( "owner" );
- ApplicationScope applicationScope = new ApplicationScopeImpl( appId );
+
IndexEdge indexSCope = new IndexEdgeImpl( ownerId, "user", SearchEdge.NodeType.SOURCE, 10 );
- ApplicationEntityIndex entityIndex = eif.createApplicationEntityIndex( applicationScope );
+
/**
@@ -890,7 +840,7 @@ public class EntityIndexTest extends BaseIT {
batch.index( indexSCope, first );
batch.index( indexSCope, second );
batch.execute().toBlocking().last();
- ei.refreshAsync().toBlocking().first();
+ entityIndex.refreshAsync().toBlocking().first();
final String ascQuery = "order by string";
@@ -921,10 +871,10 @@ public class EntityIndexTest extends BaseIT {
Id appId = new SimpleId( "application" );
Id ownerId = new SimpleId( "owner" );
- ApplicationScope applicationScope = new ApplicationScopeImpl( appId );
- ApplicationEntityIndex entityIndex = eif.createApplicationEntityIndex( applicationScope );
+
+
final Entity first = new Entity( "search" );
@@ -955,7 +905,7 @@ public class EntityIndexTest extends BaseIT {
batch.execute().toBlocking().last();
- ei.refreshAsync().toBlocking().first();
+ entityIndex.refreshAsync().toBlocking().first();
final String singleMatchQuery = "string contains 'alpha' OR string contains 'foo'";
@@ -1001,10 +951,10 @@ public class EntityIndexTest extends BaseIT {
Id appId = new SimpleId( "application" );
Id ownerId = new SimpleId( "owner" );
- ApplicationScope applicationScope = new ApplicationScopeImpl( appId );
- ApplicationEntityIndex entityIndex = eif.createApplicationEntityIndex( applicationScope );
+
+
final Entity first = new Entity( "search" );
@@ -1036,7 +986,7 @@ public class EntityIndexTest extends BaseIT {
batch.execute().toBlocking().last();
- ei.refreshAsync().toBlocking().first();
+ entityIndex.refreshAsync().toBlocking().first();
final String notFirst = "NOT int = 1";
@@ -1111,10 +1061,10 @@ public class EntityIndexTest extends BaseIT {
Id appId = new SimpleId( "application" );
Id ownerId = new SimpleId( "owner" );
- ApplicationScope applicationScope = new ApplicationScopeImpl( appId );
- ApplicationEntityIndex entityIndex = eif.createApplicationEntityIndex( applicationScope );
+
+
final Entity first = new Entity( "search" );
@@ -1146,7 +1096,7 @@ public class EntityIndexTest extends BaseIT {
batch.execute().toBlocking().last();
- ei.refreshAsync().toBlocking().first();
+ entityIndex.refreshAsync().toBlocking().first();
final String notFirst = "NOT string = 'I ate a sammich'";
@@ -1263,17 +1213,7 @@ public class EntityIndexTest extends BaseIT {
assertEquals( 0, noMatchesContainsOrResults.size() );
}
- @Test
- public void testIndexIdentifier(){
- String indexv1Name = identifierv1.getIndex("somesuffixv1");
- String indexv2Name = identifierv2.getIndex("somesuffixv2");
- assertFalse(indexv1Name.equals(indexv2Name));
- assertFalse(indexv1Name.contains(cassandraFig.getApplicationKeyspace().toLowerCase()));
- assertTrue(indexv2Name.contains(cassandraFig.getApplicationKeyspace().toLowerCase()));
- assertTrue(indexv1Name.contains(fig.getIndexPrefix()));
- assertTrue(indexv2Name.contains(fig.getIndexPrefix()));
- }
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/ab7c8e21/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/GeoPagingTest.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/GeoPagingTest.java b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/GeoPagingTest.java
index 25961b8..19e143e 100644
--- a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/GeoPagingTest.java
+++ b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/GeoPagingTest.java
@@ -23,14 +23,11 @@
package org.apache.usergrid.persistence.index.impl;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.NoSuchElementException;
+import java.util.*;
+import org.apache.usergrid.persistence.core.astyanax.CassandraFig;
+import org.apache.usergrid.persistence.index.*;
+import org.apache.usergrid.persistence.model.entity.SimpleId;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
@@ -41,19 +38,8 @@ import org.slf4j.LoggerFactory;
import org.apache.usergrid.persistence.core.guice.MigrationManagerRule;
import org.apache.usergrid.persistence.core.scope.ApplicationScopeImpl;
import org.apache.usergrid.persistence.core.test.UseModules;
-import org.apache.usergrid.persistence.index.ApplicationEntityIndex;
-import org.apache.usergrid.persistence.index.CandidateResult;
-import org.apache.usergrid.persistence.index.CandidateResults;
-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.IndexEdge;
-import org.apache.usergrid.persistence.index.SearchEdge;
-import org.apache.usergrid.persistence.index.SearchTypes;
import org.apache.usergrid.persistence.index.guice.TestIndexModule;
-import org.apache.usergrid.persistence.index.utils.UUIDUtils;
import org.apache.usergrid.persistence.model.entity.Entity;
-import org.apache.usergrid.persistence.model.field.IntegerField;
import org.apache.usergrid.persistence.model.field.LocationField;
import org.apache.usergrid.persistence.model.field.StringField;
import org.apache.usergrid.persistence.model.field.value.Location;
@@ -84,22 +70,32 @@ public class GeoPagingTest extends BaseIT {
@Inject
public EntityIndexFactory eif;
- @Inject
- public EntityIndex ei;
@Inject
@Rule
public MigrationManagerRule migrationManagerRule;
+ @Inject
+ public IndexFig fig;
-
+ @Inject
+ public CassandraFig cassandraFig;
@Inject
@Rule
public ElasticSearchRule elasticSearchRule;
+ private AliasedEntityIndex entityIndex;
+ private SimpleId appId;
+
+ @Before
+ public void setup(){
+ appId = new SimpleId(UUID.randomUUID(), "application" );
+ IndexLocationStrategy strategy =new TestIndexIdentifier(cassandraFig,fig,new ApplicationScopeImpl(appId));
+ entityIndex = eif.createEntityIndex( strategy );
+ }
/**
@@ -111,10 +107,8 @@ public class GeoPagingTest extends BaseIT {
int maxRangeLimit = 9;
Entity[] cats = new Entity[maxRangeLimit + 1];
- final ApplicationEntityIndex
- applicationEntityIndex = eif.createApplicationEntityIndex( new ApplicationScopeImpl( createId( "application" ) ) );
- final EntityIndexBatch batch = applicationEntityIndex.createBatch();
+ final EntityIndexBatch batch = entityIndex.createBatch();
final IndexEdge edge = new IndexEdgeImpl(createId("root"), "testType", SearchEdge.NodeType.SOURCE, 1000 );
@@ -136,14 +130,14 @@ public class GeoPagingTest extends BaseIT {
batch.execute().toBlocking().last();
- ei.refreshAsync().toBlocking().last();
+ entityIndex.refreshAsync().toBlocking().last();
final String query = "select * where location within 1500000 of 37, -75" ;
final CandidateResults
- candidates = applicationEntityIndex.search( edge, SearchTypes.fromTypes( "cat" ), query, 100, 0 );
+ candidates = entityIndex.search( edge, SearchTypes.fromTypes( "cat" ), query, 100, 0 );
assertNotNull( candidates );
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/ab7c8e21/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/IndexLoadTestsIT.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/IndexLoadTestsIT.java b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/IndexLoadTestsIT.java
index 812e756..a59a49d 100644
--- a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/IndexLoadTestsIT.java
+++ b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/IndexLoadTestsIT.java
@@ -23,9 +23,10 @@ import java.util.UUID;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicLong;
+import org.apache.usergrid.persistence.core.astyanax.CassandraFig;
+import org.apache.usergrid.persistence.index.*;
import org.junit.After;
import org.junit.Before;
-import org.junit.ClassRule;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -37,13 +38,6 @@ import org.apache.usergrid.persistence.core.metrics.MetricsFactory;
import org.apache.usergrid.persistence.core.scope.ApplicationScope;
import org.apache.usergrid.persistence.core.scope.ApplicationScopeImpl;
import org.apache.usergrid.persistence.core.test.UseModules;
-import org.apache.usergrid.persistence.index.ApplicationEntityIndex;
-import org.apache.usergrid.persistence.index.CandidateResults;
-import org.apache.usergrid.persistence.index.EntityIndex;
-import org.apache.usergrid.persistence.index.EntityIndexFactory;
-import org.apache.usergrid.persistence.index.IndexEdge;
-import org.apache.usergrid.persistence.index.SearchEdge;
-import org.apache.usergrid.persistence.index.SearchTypes;
import org.apache.usergrid.persistence.index.guice.IndexTestFig;
import org.apache.usergrid.persistence.index.guice.TestIndexModule;
import org.apache.usergrid.persistence.model.entity.Entity;
@@ -111,12 +105,29 @@ public class IndexLoadTestsIT extends BaseIT {
private Slf4jReporter reporter;
+ @Inject
+ public IndexFig fig;
+
+ @Inject
+ public CassandraFig cassandraFig;
+ @Inject
+ public EntityIndexFactory eif;
@Inject
@Rule
public ElasticSearchRule elasticSearchRule;
+ private SimpleId appId;
+ private EntityIndex entityIndex;
+
+ public void before(){
+ appId = new SimpleId(UUID.randomUUID(), "application" );
+ IndexLocationStrategy strategy = new TestIndexIdentifier(cassandraFig,fig,new ApplicationScopeImpl(appId));
+
+
+ entityIndex = eif.createEntityIndex( strategy );
+ }
@Before
@@ -182,20 +193,19 @@ public class IndexLoadTestsIT extends BaseIT {
final SearchEdge searchEdge = new SearchEdgeImpl( applicationId, "test", SearchEdge.NodeType.SOURCE );
- final ApplicationEntityIndex appEntityIndex = entityIndexFactory.createApplicationEntityIndex( scope );
//create our index if it doesn't exist
//delay our verification for indexing to happen
final Observable<DataLoadResult> dataLoadResults =
- createStreamFromWorkers( appEntityIndex, searchEdge, uniqueIdentifier ).buffer( indexTestFig.getBufferSize() )
+ createStreamFromWorkers( searchEdge, uniqueIdentifier ).buffer( indexTestFig.getBufferSize() )
//perform a delay to let ES index from our batches
.delay( indexTestFig.getValidateWait(), TimeUnit.MILLISECONDS )
//do our search in parallel, otherwise this test will take far too long
.flatMap( entitiesToValidate -> {
- return Observable.from( entitiesToValidate ).map( entityObservable -> {
-
+ return Observable.from( entitiesToValidate ).map( thisentityObservable -> {
+ Entity entityObservable = (Entity) thisentityObservable;
final int workerIndex = ( int ) entityObservable.getField( FIELD_WORKER_INDEX ).getValue();
final int ordinal = ( int ) entityObservable.getField( FIELD_ORDINAL ).getValue();
@@ -205,7 +215,7 @@ public class IndexLoadTestsIT extends BaseIT {
//execute our search
- final CandidateResults results = appEntityIndex
+ final CandidateResults results = entityIndex
.search( searchEdge, SearchTypes.fromTypes( searchEdge.getEdgeName() ),
"select * where " + FIELD_WORKER_INDEX + " = " + workerIndex + " AND " + FIELD_ORDINAL
+ " = " + ordinal + " AND " + FIELD_UNIQUE_IDENTIFIER + " = '" + uniqueIdentifier
@@ -256,17 +266,17 @@ public class IndexLoadTestsIT extends BaseIT {
}
- public Observable<Entity> createStreamFromWorkers( final ApplicationEntityIndex entityIndex, final SearchEdge indexEdge,
+ public Observable<Entity> createStreamFromWorkers( final SearchEdge indexEdge,
final String uniqueIdentifier ) {
//create a sequence of observables. Each index will be it's own worker thread using the Schedulers.newthread()
return Observable.range( 0, indexTestFig.getNumberOfWorkers() ).flatMap(
- integer -> createWriteObservable( entityIndex, indexEdge, uniqueIdentifier, integer )
+ integer -> createWriteObservable( indexEdge, uniqueIdentifier, integer )
.subscribeOn( Schedulers.newThread() ) );
}
- private Observable<Entity> createWriteObservable( final ApplicationEntityIndex entityIndex, final SearchEdge indexEdge,
+ private Observable<Entity> createWriteObservable( final SearchEdge indexEdge,
final String uniqueIdentifier, final int workerIndex ) {
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/ab7c8e21/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/TestIndexIdentifier.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/TestIndexIdentifier.java b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/TestIndexIdentifier.java
new file mode 100644
index 0000000..adbdfbe
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/TestIndexIdentifier.java
@@ -0,0 +1,93 @@
+/*
+ *
+ * * 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 org.apache.usergrid.persistence.core.astyanax.CassandraFig;
+import org.apache.usergrid.persistence.core.scope.ApplicationScope;
+import org.apache.usergrid.persistence.core.util.StringUtils;
+import org.apache.usergrid.persistence.index.IndexAlias;
+import org.apache.usergrid.persistence.index.IndexFig;
+import org.apache.usergrid.persistence.index.IndexLocationStrategy;
+
+
+/**
+ * Class is used to generate an index name and alias name
+ */
+public class TestIndexIdentifier implements IndexLocationStrategy {
+ private final CassandraFig cassandraFig;
+ private final IndexFig indexFig;
+ private final ApplicationScope applicationScope;
+ private final String prefix;
+
+ public TestIndexIdentifier(final CassandraFig cassandraFig, final IndexFig config, final ApplicationScope applicationScope) {
+ this.cassandraFig = cassandraFig;
+ this.indexFig = config;
+ this.applicationScope = applicationScope;
+ this.prefix = getPrefix();
+ }
+
+ private String getPrefix() {
+ //remove usergrid
+ final String indexPrefixConfig = StringUtils.isNotEmpty(indexFig.getIndexPrefix())
+ ? indexFig.getIndexPrefix().toLowerCase() ////use lowercase value
+ : ""; // default to something so its not null
+ final String keyspaceName = cassandraFig.getApplicationKeyspace().toLowerCase();
+ //check for repetition
+ final boolean removePrefix = indexPrefixConfig.length()>0 && !keyspaceName.contains(indexPrefixConfig) ;
+ return !removePrefix
+ ? indexPrefixConfig + "_" + keyspaceName
+ : keyspaceName;
+ }
+
+ /**
+ * Get the alias name
+ * @return
+ */
+ @Override
+ public IndexAlias getAlias() {
+ return new IndexAlias(indexFig,prefix);
+ }
+
+ /**
+ * Get index name, send in additional parameter to add incremental indexes
+ * @param suffix
+ * @return
+ */
+ @Override
+ public String getIndex(String suffix) {
+ if (suffix != null) {
+ return prefix + "_" + suffix;
+ } else {
+ return prefix;
+ }
+ }
+
+
+ @Override
+ public String toString() {
+ return "index id: "+prefix;
+ }
+
+ @Override
+ public ApplicationScope getApplicationScope() {
+ return applicationScope;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/ab7c8e21/stack/corepersistence/queryindex/src/test/resources/log4j.properties
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/test/resources/log4j.properties b/stack/corepersistence/queryindex/src/test/resources/log4j.properties
index 5d5f7c2..43b833c 100644
--- a/stack/corepersistence/queryindex/src/test/resources/log4j.properties
+++ b/stack/corepersistence/queryindex/src/test/resources/log4j.properties
@@ -37,7 +37,7 @@ log4j.appender.stdout.layout.ConversionPattern=%d %p (%t) %c{1} - %m%n
#log4j.logger.org.apache.cassandra.service.StorageProxy=DEBUG, stdout
#Debug our queries
-log4j.logger.org.apache.usergrid.persistence.index.impl.EsApplicationEntityIndexImpl=DEBUG
+log4j.logger.org.apache.usergrid.persistence.index.impl.EsEntityIndexImpl=DEBUG
#Debug our writes
#log4j.logger.org.apache.usergrid.persistence.index.impl.EsIndexBufferConsumerImpl=DEBUG
#Batch debugging
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/ab7c8e21/stack/rest/src/main/java/org/apache/usergrid/rest/AbstractContextResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/AbstractContextResource.java b/stack/rest/src/main/java/org/apache/usergrid/rest/AbstractContextResource.java
index cd73991..1494814 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/AbstractContextResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/AbstractContextResource.java
@@ -62,8 +62,6 @@ public abstract class AbstractContextResource {
};
protected static final ObjectMapper mapper = new ObjectMapper();
- private EntityIndex entityIndex;
-
protected AbstractContextResource parent;
@@ -198,9 +196,8 @@ public abstract class AbstractContextResource {
return new ApiResponse(properties);
}
- protected EntityIndex getEntityIndex(){
- entityIndex = entityIndex == null ? injector.getInstance(EntityIndex.class) : entityIndex;
- return entityIndex;
+ protected EntityManagerFactory getEmf(){
+ return emf;
}
/**
* Next three new methods necessary to work around inexplicable problems with EntityHolder.
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/ab7c8e21/stack/rest/src/main/java/org/apache/usergrid/rest/IndexResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/IndexResource.java b/stack/rest/src/main/java/org/apache/usergrid/rest/IndexResource.java
index ffb9700..79a51eb 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/IndexResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/IndexResource.java
@@ -35,6 +35,8 @@ import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.UriInfo;
+import org.apache.usergrid.corepersistence.util.CpNamingUtils;
+import org.apache.usergrid.persistence.EntityManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Scope;
@@ -217,7 +219,10 @@ public class IndexResource extends AbstractContextResource {
@RequireSystemAccess
@POST
- public JSONWithPadding addIndex( @Context UriInfo ui, Map<String, Object> config,
+ @Path(RootResource.APPLICATION_ID_PATH)
+ public JSONWithPadding addIndex( @Context UriInfo ui,
+ @PathParam( "applicationId" ) final String applicationIdStr,
+ Map<String, Object> config,
@QueryParam( "callback" ) @DefaultValue( "callback" ) String callback )
throws Exception {
@@ -234,9 +239,14 @@ public class IndexResource extends AbstractContextResource {
if ( !config.containsKey( "indexSuffix" ) ) {
throw new IllegalArgumentException( "Please add an indexSuffix to your post" );
}
+ final UUID appId = UUIDUtils.tryExtractUUID( applicationIdStr );
+ if(appId == null){
+ throw new IllegalArgumentException("app id was not parsed");
+ }
- emf.addIndex( config.get( "indexSuffix" ).toString(), ( int ) config.get( "shards" ),
+ EntityManager em = emf.getEntityManager(appId);
+ em.addIndex( config.get( "indexSuffix" ).toString(), ( int ) config.get( "shards" ),
( int ) config.get( "replicas" ), ( String ) config.get( "writeConsistency" ) );
response.setAction( "Add index to alias" );
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/ab7c8e21/stack/rest/src/main/java/org/apache/usergrid/rest/RootResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/RootResource.java b/stack/rest/src/main/java/org/apache/usergrid/rest/RootResource.java
index c31ca9b..5b5e711 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/RootResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/RootResource.java
@@ -208,10 +208,6 @@ public class RootResource extends AbstractContextResource implements MetricProce
EntityManager em = emf.getEntityManager(emf.getManagementAppId());
node.put( "managementAppIndexStatus", emf.getIndexHealth().toString() );
- IndexRefreshCommand.IndexRefreshCommandInfo didRefresh = emf.refreshIndex();
- node.put("refreshIndexTime", didRefresh.getExecutionTime());
- node.put("refreshIndexSuccess", didRefresh.hasFinished());
-
dumpMetrics(node);
response.setProperty( "status", node );
return new JSONWithPadding( response, callback );
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/ab7c8e21/stack/rest/src/main/java/org/apache/usergrid/rest/test/RefreshIndexResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/test/RefreshIndexResource.java b/stack/rest/src/main/java/org/apache/usergrid/rest/test/RefreshIndexResource.java
index 555d00c..1fdcee0 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/test/RefreshIndexResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/test/RefreshIndexResource.java
@@ -31,6 +31,7 @@ import javax.ws.rs.core.Response;
import com.google.common.base.Optional;
import org.apache.usergrid.persistence.EntityManager;
+import org.apache.usergrid.persistence.index.utils.UUIDUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Scope;
@@ -65,8 +66,13 @@ public class RefreshIndexResource extends AbstractContextResource {
throw new UnsupportedOperationException();
}
+ UUID appid = UUIDUtils.tryExtractUUID(appIdString);
+ if(appid == null){
+ throw new IllegalArgumentException("app id is null");
+ }
// refresh the system apps or app lookup below may fail
- getEntityIndex().refreshAsync().toBlocking().first();
+ EntityManager em = this.getEmf().getEntityManager(appid);
+ em.refreshIndex();
} catch (Exception e) {
logger.error("Error in refresh", e);
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/ab7c8e21/stack/rest/src/test/java/org/apache/usergrid/rest/IndexResourceIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/IndexResourceIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/IndexResourceIT.java
index afb9610..6378096 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/IndexResourceIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/IndexResourceIT.java
@@ -20,8 +20,10 @@
package org.apache.usergrid.rest;
-import com.fasterxml.jackson.databind.JsonNode;
-import org.junit.Ignore;
+import com.sun.jersey.api.client.WebResource;
+import com.sun.jersey.api.client.filter.HTTPBasicAuthFilter;
+import jdk.nashorn.internal.ir.annotations.Ignore;
+import org.apache.usergrid.rest.test.resource2point0.model.*;
import org.junit.Rule;
import org.junit.Test;
import org.slf4j.Logger;
@@ -32,17 +34,16 @@ import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
-import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.fail;
/**
* test index creation
*/
-public class IndexResourceIT extends AbstractRestIT {
+public class IndexResourceIT extends org.apache.usergrid.rest.test.resource2point0.AbstractRestIT {
+
- @Rule
- public TestContextSetup context = new TestContextSetup( this );
//Used for all MUUserResourceITTests
private Logger LOG = LoggerFactory.getLogger(IndexResourceIT.class);
@@ -50,33 +51,35 @@ public class IndexResourceIT extends AbstractRestIT {
}
- @Ignore( "will finish when tests are working from rest" )
@Test
+ @Ignore
public void TestAddIndex() throws Exception{
- String superToken = superAdminToken();
Map<String, Object> data = new HashMap<String, Object>();
data.put( "replicas", 0 );
data.put( "shards", 1 );
data.put( "writeConsistency", "one" );
- UUID appId = this.context.getAppUuid();
+ String appId = this.clientSetup.getAppUuid();
// change the password as admin. The old password isn't required
- JsonNode node = null;
+ org.apache.usergrid.rest.test.resource2point0.model.ApiResponse node = null;
try {
- node = mapper.readTree(resource().path("/system/index/" + appId)
- .queryParam("access_token", superToken)
- .accept(MediaType.APPLICATION_JSON).type(MediaType.APPLICATION_JSON_TYPE)
- .post(String.class, data));
+
+ WebResource resource = this.clientSetup.getRestClient().pathResource("/system/index/" + appId).getResource();
+
+ //added httpBasicauth filter to all setup calls because they all do verification this way.
+ HTTPBasicAuthFilter httpBasicAuthFilter = new HTTPBasicAuthFilter( clientSetup.getSuperuserName(),clientSetup.getSuperuserPassword() );
+ resource.addFilter( httpBasicAuthFilter );
+
+ node = resource.type( MediaType.APPLICATION_JSON_TYPE ).accept( MediaType.APPLICATION_JSON )
+ .get( org.apache.usergrid.rest.test.resource2point0.model.ApiResponse.class);
} catch (Exception e) {
LOG.error("failed", e);
fail(e.toString());
}
- assertNull( getError( node ) );
-
- refreshIndex("test-organization", "test-app");
+ assertNotNull( node );
}
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/ab7c8e21/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/ClientSetup.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/ClientSetup.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/ClientSetup.java
index 6a0a781..4cf28e5 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/ClientSetup.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/ClientSetup.java
@@ -165,7 +165,7 @@ public class ClientSetup implements TestRule {
}
public void refreshIndex() {
- this.restClient.refreshIndex(getOrganizationName(),getAppName());
+ this.restClient.refreshIndex(getOrganizationName(),getAppName(),getAppUuid());
}
public RestClient getRestClient(){
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/ab7c8e21/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/RestClient.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/RestClient.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/RestClient.java
index 152e546..0d8f981 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/RestClient.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/RestClient.java
@@ -28,6 +28,7 @@ import com.sun.jersey.api.client.config.DefaultClientConfig;
import com.sun.jersey.api.client.filter.HTTPBasicAuthFilter;
import javax.ws.rs.core.MediaType;
+import java.util.UUID;
/**
@@ -97,12 +98,13 @@ public class RestClient implements UrlResource {
public TokenResource token(){
return new TokenResource(context,this);
}
- public void refreshIndex(String orgname, String appName) {
+ public void refreshIndex(String orgname, String appName, String appid) {
//TODO: add error checking and logging
this.getResource().path( "/refreshindex" )
.queryParam( "org_name", orgname )
.queryParam( "app_name",appName )
- .accept( MediaType.APPLICATION_JSON ).post();
+ .queryParam("app_id", appid)
+ .accept( MediaType.APPLICATION_JSON ).post();
}
public NamedResource pathResource(String path){
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/ab7c8e21/stack/services/src/test/java/org/apache/usergrid/ServiceApplication.java
----------------------------------------------------------------------
diff --git a/stack/services/src/test/java/org/apache/usergrid/ServiceApplication.java b/stack/services/src/test/java/org/apache/usergrid/ServiceApplication.java
index 801a640..2c34deb 100644
--- a/stack/services/src/test/java/org/apache/usergrid/ServiceApplication.java
+++ b/stack/services/src/test/java/org/apache/usergrid/ServiceApplication.java
@@ -105,7 +105,7 @@ public class ServiceApplication extends CoreApplication {
dumpResults( results );
if ( !action.name().equals( ServiceAction.GET )) {
- setup.getEntityIndex().refresh();
+ setup.getEntityIndex().refresh(this.id);
}
return results;
@@ -131,14 +131,14 @@ public class ServiceApplication extends CoreApplication {
put( "name", name );
Entity entity = testRequest( ServiceAction.POST, 1, pluralize( entityType ) ).getEntity();
- setup.getEntityIndex().refresh();
+ setup.getEntityIndex().refresh(id);
return entity;
}
public void createConnection( Entity subject, String verb, Entity noun ) throws Exception {
sm.getEntityManager().createConnection( subject, verb, noun );
- setup.getEntityIndex().refresh();
+ setup.getEntityIndex().refresh(id);
}
@@ -153,7 +153,7 @@ public class ServiceApplication extends CoreApplication {
dumpResults( results );
if ( !action.name().equals( ServiceAction.GET )) {
- setup.getEntityIndex().refresh();
+ setup.getEntityIndex().refresh(id);
}
return results;
@@ -169,7 +169,7 @@ public class ServiceApplication extends CoreApplication {
assertNotNull( results.getData() );
if ( !action.name().equals( ServiceAction.GET )) {
- setup.getEntityIndex().refresh();
+ setup.getEntityIndex().refresh(id);
}
// dump( results.getData() );
@@ -179,20 +179,20 @@ public class ServiceApplication extends CoreApplication {
public Entity createRole( String name, String title, int inactivity ) throws Exception {
Entity createRole = sm.getEntityManager().createRole( name, title, inactivity );
- setup.getEntityIndex().refresh();
+ setup.getEntityIndex().refresh(id);
return createRole;
}
public void grantRolePermission( String role, String permission ) throws Exception {
sm.getEntityManager().grantRolePermission( role, permission );
- setup.getEntityIndex().refresh();
+ setup.getEntityIndex().refresh(id);
}
public void grantUserPermission( UUID uuid, String permission ) throws Exception {
sm.getEntityManager().grantUserPermission( uuid, permission );
- setup.getEntityIndex().refresh();
+ setup.getEntityIndex().refresh(id);
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/ab7c8e21/stack/services/src/test/java/org/apache/usergrid/ServiceITSetup.java
----------------------------------------------------------------------
diff --git a/stack/services/src/test/java/org/apache/usergrid/ServiceITSetup.java b/stack/services/src/test/java/org/apache/usergrid/ServiceITSetup.java
index 07a6fe5..e9bb248 100644
--- a/stack/services/src/test/java/org/apache/usergrid/ServiceITSetup.java
+++ b/stack/services/src/test/java/org/apache/usergrid/ServiceITSetup.java
@@ -27,6 +27,7 @@ import org.apache.usergrid.security.tokens.TokenService;
import org.apache.usergrid.services.ServiceManagerFactory;
import java.util.Properties;
+import java.util.UUID;
public interface ServiceITSetup extends CoreITSetup {
@@ -44,7 +45,7 @@ public interface ServiceITSetup extends CoreITSetup {
ImportService getImportService();
- void refreshIndex();
+ void refreshIndex(UUID appid);
/**
* Convenience method to set a property in the Properties object returned by getProps();
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/ab7c8e21/stack/services/src/test/java/org/apache/usergrid/ServiceITSetupImpl.java
----------------------------------------------------------------------
diff --git a/stack/services/src/test/java/org/apache/usergrid/ServiceITSetupImpl.java b/stack/services/src/test/java/org/apache/usergrid/ServiceITSetupImpl.java
index 8ae5322..c17ee92 100644
--- a/stack/services/src/test/java/org/apache/usergrid/ServiceITSetupImpl.java
+++ b/stack/services/src/test/java/org/apache/usergrid/ServiceITSetupImpl.java
@@ -43,6 +43,7 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.config.PropertiesFactoryBean;
import java.util.Properties;
+import java.util.UUID;
/** A {@link org.junit.rules.TestRule} that sets up services. */
@@ -180,8 +181,7 @@ public class ServiceITSetupImpl extends CoreITSetupImpl implements ServiceITSetu
return appInfoMigrationPlugin;
}
- @Override
- public void refreshIndex(){
- this.getEntityIndex().refresh();
+ public void refreshIndex(UUID appid){
+ this.getEntityIndex().refresh(appid);
}
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/ab7c8e21/stack/services/src/test/java/org/apache/usergrid/corepersistence/migration/AppInfoMigrationPluginTest.java
----------------------------------------------------------------------
diff --git a/stack/services/src/test/java/org/apache/usergrid/corepersistence/migration/AppInfoMigrationPluginTest.java b/stack/services/src/test/java/org/apache/usergrid/corepersistence/migration/AppInfoMigrationPluginTest.java
index 9c8f40f..0fd1e52 100644
--- a/stack/services/src/test/java/org/apache/usergrid/corepersistence/migration/AppInfoMigrationPluginTest.java
+++ b/stack/services/src/test/java/org/apache/usergrid/corepersistence/migration/AppInfoMigrationPluginTest.java
@@ -101,9 +101,9 @@ public class AppInfoMigrationPluginTest {
}
}
- setup.refreshIndex();
UUID mgmtAppId = setup.getEmf().getManagementAppId();
+ setup.refreshIndex(mgmtAppId);
EntityManager rootEm = setup.getEmf().getEntityManager( mgmtAppId );
checkApplicationsOk( orgName );
@@ -143,7 +143,7 @@ public class AppInfoMigrationPluginTest {
}
}
- setup.refreshIndex();
+ setup.refreshIndex(mgmtAppId);
setup.getEmf().flushEntityManagerCaches();
@@ -165,7 +165,7 @@ public class AppInfoMigrationPluginTest {
// test that expected calls were made the to progress observer (use mock library)
Mockito.verify( po, Mockito.times(10) ).update( Mockito.anyInt(), Mockito.anyString() );
- setup.refreshIndex();
+ setup.refreshIndex(mgmtAppId);
final Results appInfoResults = rootEm.searchCollection(
new SimpleEntityRef("application", mgmtAppId), "appinfos", Query.fromQL("select *"));
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/ab7c8e21/stack/services/src/test/java/org/apache/usergrid/management/EmailFlowIT.java
----------------------------------------------------------------------
diff --git a/stack/services/src/test/java/org/apache/usergrid/management/EmailFlowIT.java b/stack/services/src/test/java/org/apache/usergrid/management/EmailFlowIT.java
index b158568..d75638d 100644
--- a/stack/services/src/test/java/org/apache/usergrid/management/EmailFlowIT.java
+++ b/stack/services/src/test/java/org/apache/usergrid/management/EmailFlowIT.java
@@ -285,7 +285,7 @@ public class EmailFlowIT {
String activation_url = String.format( setup.get( PROPERTIES_USER_ACTIVATION_URL ), orgName, appName,
appUser.getUuid().toString() );
- setup.refreshIndex();
+ setup.refreshIndex(app.getId());
// Activation
setup.getMgmtSvc().startAppUserActivationFlow( app.getId(), appUser );
@@ -358,15 +358,15 @@ public class EmailFlowIT {
orgOwner = createOwnerAndOrganization( orgName, appName, userName, email, passwd, false, false );
assertNotNull( orgOwner );
- setup.getEntityIndex().refresh();
+ setup.getEntityIndex().refresh(app.getId());
ApplicationInfo app = setup.getMgmtSvc().createApplication( orgOwner.getOrganization().getUuid(), appName );
- setup.refreshIndex();
+ setup.refreshIndex(app.getId());
assertNotNull( app );
enableEmailConfirmation( app.getId() );
enableAdminApproval( app.getId() );
- setup.getEntityIndex().refresh();
+ setup.getEntityIndex().refresh(app.getId());
final String appUserEmail = uniqueEmail();
final String appUserUsername = uniqueUsername();
@@ -470,7 +470,7 @@ public class EmailFlowIT {
userProps.put( "activated", activated );
User user = em.create( User.ENTITY_TYPE, User.class, userProps );
- setup.getEntityIndex().refresh();
+ setup.getEntityIndex().refresh(app.getId());
return user;
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/ab7c8e21/stack/services/src/test/java/org/apache/usergrid/management/OrganizationIT.java
----------------------------------------------------------------------
diff --git a/stack/services/src/test/java/org/apache/usergrid/management/OrganizationIT.java b/stack/services/src/test/java/org/apache/usergrid/management/OrganizationIT.java
index 3c93fa3..e0561a2 100644
--- a/stack/services/src/test/java/org/apache/usergrid/management/OrganizationIT.java
+++ b/stack/services/src/test/java/org/apache/usergrid/management/OrganizationIT.java
@@ -22,6 +22,7 @@ import java.util.List;
import java.util.Map;
import java.util.UUID;
+import org.apache.usergrid.corepersistence.util.CpNamingUtils;
import org.junit.ClassRule;
import org.junit.Rule;
import org.junit.Test;
@@ -70,7 +71,7 @@ public class OrganizationIT {
//createOrganization( orgName, user, false );
assertNotNull( organization );
- setup.getEntityIndex().refresh();
+ setup.getEntityIndex().refresh(CpNamingUtils.MANAGEMENT_APPLICATION_ID);
Map<UUID, String> userOrganizations = setup.getMgmtSvc().getOrganizationsForAdminUser(
organization.getOwner().getUuid() );
assertEquals("wrong number of organizations", 1, userOrganizations.size());
@@ -83,7 +84,7 @@ public class OrganizationIT {
assertNotNull(applicationInfo.getId());
- setup.getEntityIndex().refresh();
+ setup.getEntityIndex().refresh(applicationInfo.getId());
Map<UUID, String> applications = setup.getMgmtSvc().getApplicationsForOrganization( organization.getOrganization().getUuid() );
assertEquals( "wrong number of applications", 1, applications.size() );
@@ -97,7 +98,7 @@ public class OrganizationIT {
setup.getMgmtSvc().activateOrganization( organization2 );
- setup.getEntityIndex().refresh();
+ setup.getEntityIndex().refresh(CpNamingUtils.MANAGEMENT_APPLICATION_ID);
UserInfo u = setup.getMgmtSvc().verifyAdminUserPasswordCredentials( organization.getOwner().getUuid().toString(), "test" );
assertNotNull( u );
@@ -215,7 +216,7 @@ public class OrganizationIT {
OrganizationInfo organization2 = setup.getMgmtSvc().createOrganization(uniqueOrg(), user, false );
assertNotNull( organization2 );
- setup.getEntityIndex().refresh();
+ setup.getEntityIndex().refresh(CpNamingUtils.MANAGEMENT_APPLICATION_ID);
Map<UUID, String> userOrganizations = setup.getMgmtSvc().getOrganizationsForAdminUser( user.getUuid() );
assertEquals( "wrong number of organizations", 2, userOrganizations.size() );
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/ab7c8e21/stack/services/src/test/java/org/apache/usergrid/management/RoleIT.java
----------------------------------------------------------------------
diff --git a/stack/services/src/test/java/org/apache/usergrid/management/RoleIT.java b/stack/services/src/test/java/org/apache/usergrid/management/RoleIT.java
index 64109b2..783e67c 100644
--- a/stack/services/src/test/java/org/apache/usergrid/management/RoleIT.java
+++ b/stack/services/src/test/java/org/apache/usergrid/management/RoleIT.java
@@ -66,7 +66,7 @@ public class RoleIT {
UUID applicationId = setup.getMgmtSvc().createApplication( organization.getUuid(), "test-app" ).getId();
EntityManager em = setup.getEmf().getEntityManager( applicationId );
- setup.getEntityIndex().refresh();
+ setup.getEntityIndex().refresh(em.getApplicationId());
Map<String, Object> properties = new LinkedHashMap<String, Object>();
properties.put( "username", "edanuff5" );
@@ -75,7 +75,7 @@ public class RoleIT {
User user = em.create( User.ENTITY_TYPE, User.class, properties );
em.createRole( "logged-in", "Logged In", 1000 );
- setup.getEntityIndex().refresh();
+ setup.getEntityIndex().refresh(em.getApplicationId());
em.addUserToRole( user.getUuid(), "logged-in" );
String accessToken = setup.getMgmtSvc().getAccessTokenForAppUser( applicationId, user.getUuid(), 0 );
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/ab7c8e21/stack/services/src/test/java/org/apache/usergrid/management/cassandra/ApplicationCreatorIT.java
----------------------------------------------------------------------
diff --git a/stack/services/src/test/java/org/apache/usergrid/management/cassandra/ApplicationCreatorIT.java b/stack/services/src/test/java/org/apache/usergrid/management/cassandra/ApplicationCreatorIT.java
index 0de8220..fd509c8 100644
--- a/stack/services/src/test/java/org/apache/usergrid/management/cassandra/ApplicationCreatorIT.java
+++ b/stack/services/src/test/java/org/apache/usergrid/management/cassandra/ApplicationCreatorIT.java
@@ -88,7 +88,7 @@ public class ApplicationCreatorIT {
customCreator.setSampleAppName(sampleAppName);
ApplicationInfo appInfo = customCreator.createSampleFor( orgOwner.getOrganization() );
if(appInfo == null){
- setup.refreshIndex();
+ setup.refreshIndex(setup.getEmf().getManagementAppId());
}
assertNotNull( appInfo );
assertEquals( expectedName, appInfo.getName() );
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/ab7c8e21/stack/services/src/test/java/org/apache/usergrid/management/cassandra/ManagementServiceIT.java
----------------------------------------------------------------------
diff --git a/stack/services/src/test/java/org/apache/usergrid/management/cassandra/ManagementServiceIT.java b/stack/services/src/test/java/org/apache/usergrid/management/cassandra/ManagementServiceIT.java
index 884bfec..196400f 100644
--- a/stack/services/src/test/java/org/apache/usergrid/management/cassandra/ManagementServiceIT.java
+++ b/stack/services/src/test/java/org/apache/usergrid/management/cassandra/ManagementServiceIT.java
@@ -98,7 +98,7 @@ public class ManagementServiceIT {
adminUser = orgAppAdminRule.getAdminInfo();
applicationId = orgAppAdminRule.getApplicationInfo().getId();
- setup.getEntityIndex().refresh();
+ setup.getEntityIndex().refresh(applicationId);
}
@@ -196,7 +196,7 @@ public class ManagementServiceIT {
setup.getMgmtSvc().activateAppUser( applicationId, user.getUuid() );
- setup.getEntityIndex().refresh();
+ setup.getEntityIndex().refresh(applicationId);
user = em.get( entity.getUuid(), User.class );
@@ -492,7 +492,7 @@ public class ManagementServiceIT {
false, false );
EntityManager em = setup.getEmf().getEntityManager( setup.getSmf().getManagementAppId() );
- setup.getEntityIndex().refresh();
+ setup.getEntityIndex().refresh(applicationId);
UserInfo authedUser = setup.getMgmtSvc().verifyAdminUserPasswordCredentials( username, password );
@@ -543,7 +543,7 @@ public class ManagementServiceIT {
em.addToDictionary( storedUser, DICTIONARY_CREDENTIALS, "password", info );
- setup.getEntityIndex().refresh();
+ setup.getEntityIndex().refresh(applicationId);
//verify authorization works
@@ -581,7 +581,7 @@ public class ManagementServiceIT {
EntityManager em = setup.getEmf().getEntityManager( setup.getEmf().getManagementAppId() );
User storedUser = em.create( user );
- setup.getEntityIndex().refresh();
+ setup.getEntityIndex().refresh(applicationId);
UUID userId = storedUser.getUuid();
@@ -650,7 +650,7 @@ public class ManagementServiceIT {
User storedUser = em.create( user );
- setup.getEntityIndex().refresh();
+ setup.getEntityIndex().refresh(applicationId);
UUID userId = storedUser.getUuid();
@@ -667,7 +667,7 @@ public class ManagementServiceIT {
setup.getMgmtSvc().setAppUserPassword( appId, userId, password, newPassword );
- setup.getEntityIndex().refresh();
+ setup.getEntityIndex().refresh(applicationId);
//verify authorization works
authedUser = setup.getMgmtSvc().verifyAppUserPasswordCredentials( appId, username, newPassword );
@@ -696,7 +696,7 @@ public class ManagementServiceIT {
User storedUser = em.create( user );
- setup.getEntityIndex().refresh();
+ setup.getEntityIndex().refresh(applicationId);
UUID userId = storedUser.getUuid();
@@ -726,7 +726,7 @@ public class ManagementServiceIT {
setup.getMgmtSvc().setAppUserPassword( appId, userId, password, newPassword );
- setup.getEntityIndex().refresh();
+ setup.getEntityIndex().refresh(applicationId);
//verify authorization works
authedUser = setup.getMgmtSvc().verifyAppUserPasswordCredentials( appId, username, newPassword );
@@ -757,7 +757,7 @@ public class ManagementServiceIT {
User storedUser = em.create( user );
- setup.getEntityIndex().refresh();
+ setup.getEntityIndex().refresh(applicationId);
UUID userId = storedUser.getUuid();
@@ -794,7 +794,7 @@ public class ManagementServiceIT {
setup.getMgmtSvc().setAppUserPassword( appId, userId, password, newPassword );
- setup.getEntityIndex().refresh();
+ setup.getEntityIndex().refresh(applicationId);
//verify authorization works
authedUser = setup.getMgmtSvc().verifyAppUserPasswordCredentials( appId, username, newPassword );
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/ab7c8e21/stack/services/src/test/java/org/apache/usergrid/management/export/ExportServiceIT.java
----------------------------------------------------------------------
diff --git a/stack/services/src/test/java/org/apache/usergrid/management/export/ExportServiceIT.java b/stack/services/src/test/java/org/apache/usergrid/management/export/ExportServiceIT.java
index 0e69d21..95e8c7d 100644
--- a/stack/services/src/test/java/org/apache/usergrid/management/export/ExportServiceIT.java
+++ b/stack/services/src/test/java/org/apache/usergrid/management/export/ExportServiceIT.java
@@ -118,7 +118,7 @@ public class ExportServiceIT {
organization = newOrgAppAdminRule.getOrganizationInfo();
applicationId = newOrgAppAdminRule.getApplicationInfo().getId();
- setup.getEntityIndex().refresh();
+ setup.getEntityIndex().refresh(applicationId);
}
@@ -272,7 +272,7 @@ public class ExportServiceIT {
entity[i] = em.create( "users", userProperties );
}
- setup.getEntityIndex().refresh();
+ setup.getEntityIndex().refresh(applicationId);
//creates connections
em.createConnection( em.get( new SimpleEntityRef( "user", entity[0].getUuid() ) ), "Vibrations",
em.get( new SimpleEntityRef( "user", entity[1].getUuid() ) ) );
@@ -506,7 +506,7 @@ public class ExportServiceIT {
JobExecution jobExecution = mock( JobExecution.class );
when( jobExecution.getJobData() ).thenReturn( jobData );
- setup.getEntityIndex().refresh();
+ setup.getEntityIndex().refresh(applicationId);
exportService.doExport( jobExecution );
@@ -577,7 +577,7 @@ public class ExportServiceIT {
JobExecution jobExecution = mock( JobExecution.class );
when( jobExecution.getJobData() ).thenReturn( jobData );
- setup.getEntityIndex().refresh();
+ setup.getEntityIndex().refresh(applicationId);
exportService.doExport( jobExecution );
@@ -612,7 +612,7 @@ public class ExportServiceIT {
EntityManager em = setup.getEmf().getEntityManager( applicationId );
em.createApplicationCollection( "baconators" );
- setup.getEntityIndex().refresh();
+ setup.getEntityIndex().refresh(applicationId);
//initialize user object to be posted
Map<String, Object> userProperties = null;
@@ -645,7 +645,7 @@ public class ExportServiceIT {
JobExecution jobExecution = mock( JobExecution.class );
when( jobExecution.getJobData() ).thenReturn( jobData );
- setup.getEntityIndex().refresh();
+ setup.getEntityIndex().refresh(applicationId);
exportService.doExport( jobExecution );
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/ab7c8e21/stack/services/src/test/java/org/apache/usergrid/management/importer/ImportCollectionIT.java
----------------------------------------------------------------------
diff --git a/stack/services/src/test/java/org/apache/usergrid/management/importer/ImportCollectionIT.java b/stack/services/src/test/java/org/apache/usergrid/management/importer/ImportCollectionIT.java
index 4c78a1e..10b6d28 100644
--- a/stack/services/src/test/java/org/apache/usergrid/management/importer/ImportCollectionIT.java
+++ b/stack/services/src/test/java/org/apache/usergrid/management/importer/ImportCollectionIT.java
@@ -239,7 +239,7 @@ public class ImportCollectionIT {
for ( Entity importedThing : importedThings ) {
emApp1.delete( importedThing );
}
- setup.getEntityIndex().refresh();
+ setup.getEntityIndex().refresh(appId2);
importedThings = emApp2.getCollection(
@@ -532,7 +532,7 @@ public class ImportCollectionIT {
if ( retries >= maxRetries ) {
throw new RuntimeException("Max retries reached");
}
- setup.getEntityIndex().refresh();
+ setup.getEntityIndex().refresh(em.getApplicationId());
return importEntity.getUuid();
@@ -547,7 +547,7 @@ public class ImportCollectionIT {
logger.debug("\n\nExporting {} collection from application {}\n",
collectionName, em.getApplication().getName() );
- setup.getEntityIndex().refresh();
+ setup.getEntityIndex().refresh(em.getApplicationId());
ExportService exportService = setup.getExportService();
@@ -591,7 +591,7 @@ public class ImportCollectionIT {
logger.debug("\n\nCreating new {} collection in application {}\n",
type, em.getApplication().getName());
- setup.getEntityIndex().refresh();
+ setup.getEntityIndex().refresh(em.getApplicationId());
List<Entity> created = new ArrayList<>();
@@ -613,7 +613,7 @@ public class ImportCollectionIT {
em.createConnection(new SimpleEntityRef(type, created.get(1).getUuid()),
"related", new SimpleEntityRef(type, created.get(0).getUuid()));
- setup.getEntityIndex().refresh();
+ setup.getEntityIndex().refresh(em.getApplicationId());
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/ab7c8e21/stack/services/src/test/java/org/apache/usergrid/services/ConnectionsServiceIT.java
----------------------------------------------------------------------
diff --git a/stack/services/src/test/java/org/apache/usergrid/services/ConnectionsServiceIT.java b/stack/services/src/test/java/org/apache/usergrid/services/ConnectionsServiceIT.java
index 57fadca..a1f19d4 100644
--- a/stack/services/src/test/java/org/apache/usergrid/services/ConnectionsServiceIT.java
+++ b/stack/services/src/test/java/org/apache/usergrid/services/ConnectionsServiceIT.java
@@ -99,13 +99,13 @@ public class ConnectionsServiceIT extends AbstractServiceIT {
Entity bar = app.testRequest( ServiceAction.POST, 1, "bars" ).getEntity();
assertNotNull( bar );
- setup.getEntityIndex().refresh();
+ setup.getEntityIndex().refresh(app.getId());
//POST users/conn-user1/user2/UUID
app.testRequest( ServiceAction.POST, 1, "foos", "foo", "bars", bar.getUuid() ); // should succeed
- setup.getEntityIndex().refresh();
+ setup.getEntityIndex().refresh(app.getId());
try {