Revert "Make limit for versions to search for configurable." This reverts commit 8c186a91ae44fe104ddfd16338cfa7f5bb36bf74.
Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/90217b52 Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/90217b52 Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/90217b52 Branch: refs/heads/master Commit: 90217b527f23c12c9314b90661d19813c2fbe0dd Parents: a976cff Author: Michael Russo <mru...@apigee.com> Authored: Tue Apr 5 13:47:34 2016 -0700 Committer: Michael Russo <mru...@apigee.com> Committed: Tue Apr 5 13:47:34 2016 -0700 ---------------------------------------------------------------------- .../corepersistence/asyncevents/EventBuilderImpl.java | 4 ++-- .../usergrid/corepersistence/index/IndexService.java | 5 +++-- .../corepersistence/index/IndexServiceImpl.java | 13 ++++--------- .../apache/usergrid/persistence/index/EntityIndex.java | 4 ++-- .../persistence/index/impl/EsEntityIndexImpl.java | 5 +++-- .../persistence/index/impl/EntityIndexTest.java | 4 ++-- 6 files changed, 16 insertions(+), 19 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/usergrid/blob/90217b52/stack/core/src/main/java/org/apache/usergrid/corepersistence/asyncevents/EventBuilderImpl.java ---------------------------------------------------------------------- diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/asyncevents/EventBuilderImpl.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/asyncevents/EventBuilderImpl.java index c43b3d5..9851936 100644 --- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/asyncevents/EventBuilderImpl.java +++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/asyncevents/EventBuilderImpl.java @@ -128,7 +128,7 @@ public class EventBuilderImpl implements EventBuilder { if(mostRecentlyMarked != null){ deIndexObservable = - indexService.deleteEntityIndexes( applicationScope, entityId, mostRecentlyMarked.getVersion(), false ); + indexService.deleteEntityIndexes( applicationScope, entityId, mostRecentlyMarked.getVersion() ); ecmDeleteObservable = ecm.getVersions( entityId ) @@ -194,7 +194,7 @@ public class EventBuilderImpl implements EventBuilder { UUID latestVersion = latestVersions.getMaxVersion(entityId).getVersion(); deIndexObservable = - indexService.deleteEntityIndexes( applicationScope, entityId, latestVersion, true ); + indexService.deleteEntityIndexes( applicationScope, entityId, latestVersion); } http://git-wip-us.apache.org/repos/asf/usergrid/blob/90217b52/stack/core/src/main/java/org/apache/usergrid/corepersistence/index/IndexService.java ---------------------------------------------------------------------- diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/index/IndexService.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/index/IndexService.java index b48062a..54eb464 100644 --- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/index/IndexService.java +++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/index/IndexService.java @@ -24,11 +24,13 @@ import java.util.UUID; import org.apache.usergrid.persistence.core.scope.ApplicationScope; import org.apache.usergrid.persistence.graph.Edge; +import org.apache.usergrid.persistence.index.IndexEdge; import org.apache.usergrid.persistence.index.impl.IndexOperationMessage; import org.apache.usergrid.persistence.model.entity.Entity; import org.apache.usergrid.persistence.model.entity.Id; import rx.Observable; +import rx.observables.ConnectableObservable; /** @@ -76,11 +78,10 @@ public interface IndexService { * * @param applicationScope * @param entityId - * @param forEntityUpdates * @return */ Observable<IndexOperationMessage> deleteEntityIndexes(final ApplicationScope applicationScope, final Id entityId, - final UUID markedVersion, boolean forEntityUpdates); + final UUID markedVersion); http://git-wip-us.apache.org/repos/asf/usergrid/blob/90217b52/stack/core/src/main/java/org/apache/usergrid/corepersistence/index/IndexServiceImpl.java ---------------------------------------------------------------------- diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/index/IndexServiceImpl.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/index/IndexServiceImpl.java index 38e7122..6c07212 100644 --- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/index/IndexServiceImpl.java +++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/index/IndexServiceImpl.java @@ -52,6 +52,7 @@ import rx.Observable; import static org.apache.usergrid.corepersistence.util.CpNamingUtils.createSearchEdgeFromSource; import static org.apache.usergrid.corepersistence.util.CpNamingUtils.generateScopeFromSource; import static org.apache.usergrid.corepersistence.util.CpNamingUtils.generateScopeFromTarget; +import static org.apache.usergrid.persistence.Schema.getDefaultSchema; /** @@ -199,19 +200,13 @@ public class IndexServiceImpl implements IndexService { //This should look up the entityId and delete any documents with a timestamp that comes before //The edges that are connected will be compacted away from the graph. @Override - public Observable<IndexOperationMessage> deleteEntityIndexes(final ApplicationScope applicationScope, - final Id entityId, final UUID markedVersion, boolean forEntityUpdates) { + public Observable<IndexOperationMessage> deleteEntityIndexes( final ApplicationScope applicationScope, + final Id entityId, final UUID markedVersion ) { //bootstrap the lower modules from their caches final EntityIndex ei = entityIndexFactory.createEntityIndex(indexLocationStrategyFactory.getIndexLocationStrategy(applicationScope) ); - CandidateResults crs; - if(forEntityUpdates){ - crs = ei.getAllEntityVersionsBeforeMarkedVersion( entityId, markedVersion, indexFig.getOldVersionQueryLimit() ); - - }else{ - crs = ei.getAllEntityVersionsBeforeMarkedVersion( entityId, markedVersion, indexFig.getVersionQueryLimit() ); - } + CandidateResults crs = ei.getAllEntityVersionsBeforeMarkedVersion( entityId, markedVersion ); //If we get no search results, its possible that something was already deleted or //that it wasn't indexed yet. In either case we can't delete anything and return an empty observable.. http://git-wip-us.apache.org/repos/asf/usergrid/blob/90217b52/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 4f7ee72..81f900c 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 @@ -20,6 +20,7 @@ package org.apache.usergrid.persistence.index; +import com.google.common.base.Optional; import org.apache.usergrid.persistence.core.CPManager; import org.apache.usergrid.persistence.core.util.Health; import org.apache.usergrid.persistence.model.entity.Id; @@ -116,10 +117,9 @@ public interface EntityIndex extends CPManager { * * @param entityId The entityId to match when searching * @param markedVersion The version that has been marked for deletion. All version before this one must be deleted. - * @param limitToDelete * @return */ - CandidateResults getAllEntityVersionsBeforeMarkedVersion(final Id entityId, final UUID markedVersion, int limitToDelete); + CandidateResults getAllEntityVersionsBeforeMarkedVersion(final Id entityId, final UUID markedVersion); /** * delete all application records http://git-wip-us.apache.org/repos/asf/usergrid/blob/90217b52/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 98c0738..f754cc2 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 @@ -56,6 +56,7 @@ import org.elasticsearch.action.deletebyquery.DeleteByQueryResponse; import org.elasticsearch.action.deletebyquery.IndexDeleteByQueryResponse; 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.common.settings.ImmutableSettings; import org.elasticsearch.common.settings.Settings; @@ -532,7 +533,7 @@ public class EsEntityIndexImpl implements EntityIndex,VersionedData { @Override - public CandidateResults getAllEntityVersionsBeforeMarkedVersion(final Id entityId, final UUID markedVersion, int limitToDelete) { + public CandidateResults getAllEntityVersionsBeforeMarkedVersion( final Id entityId, final UUID markedVersion ) { Preconditions.checkNotNull( entityId, "entityId cannot be null" ); Preconditions.checkNotNull(markedVersion, "markedVersion cannot be null"); @@ -544,7 +545,7 @@ public class EsEntityIndexImpl implements EntityIndex,VersionedData { final long markedTimestamp = markedVersion.timestamp(); // never let the limit be less than 2 as there are potential indefinite paging issues - final int searchLimit = Math.max(2, limitToDelete); + final int searchLimit = Math.max(2, indexFig.getOldVersionQueryLimit()); // this query will find the document for the entity itself final QueryBuilder entityQuery = QueryBuilders http://git-wip-us.apache.org/repos/asf/usergrid/blob/90217b52/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 0896229..3978956 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 @@ -387,7 +387,7 @@ public class EntityIndexTest extends BaseIT { * Tests that we aggregate results only before the halfway version point. */ @Test - public void testScrollingDeindex() { + public void testScollingDeindex() { int numberOfEntities = 1000; int versionToSearchFor = numberOfEntities / 2; @@ -419,7 +419,7 @@ public class EntityIndexTest extends BaseIT { CandidateResults candidateResults = entityIndex .getAllEntityVersionsBeforeMarkedVersion( entity[versionToSearchFor].getId(), - entity[versionToSearchFor].getVersion(), numberOfEntities ); + entity[versionToSearchFor].getVersion() ); assertEquals( 501, candidateResults.size() ); }