Skip to content

Commit

Permalink
HSEARCH-3460 Refer to purge,refresh, etc. as index-*scale* works rath…
Browse files Browse the repository at this point in the history
…er than index-*scope* works

The wording is still clumsy, but at least there's no confusion with the
"search scope" which means "a list of selected indexes".
  • Loading branch information
yrodiere committed Feb 17, 2020
1 parent ebe841c commit e7e19ed
Show file tree
Hide file tree
Showing 20 changed files with 129 additions and 129 deletions.
2 changes: 1 addition & 1 deletion documentation/src/main/asciidoc/internals.asciidoc
Expand Up @@ -153,7 +153,7 @@ The mapper should create an indexing plan whenever it needs to add, update or de
including the tenant identifier when using multi-tenancy, in particular.
Thus the mapper should instantiate a new indexing plan whenever this context changes.

NOTE: Index-scoped operations such as flush, merge-segments, etc. are unavailable from indexing plans.
NOTE: Index-scale operations such as flush, merge-segments, etc. are unavailable from indexing plans.
They are accessed through a separate class, `IndexWorkspace`.

=== Searching
Expand Down
Expand Up @@ -153,7 +153,7 @@ public void massIndexing() {

SearchScope<Map> scope = searchSession.scope( Map.class, entityTypeName );

backendMock.expectIndexScopeWorks( INDEX1_NAME )
backendMock.expectIndexScaleWorks( INDEX1_NAME )
.purge()
.mergeSegments();

Expand Down
Expand Up @@ -30,7 +30,7 @@
import org.hibernate.search.util.common.SearchException;
import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock;
import org.hibernate.search.util.impl.integrationtest.common.rule.ThreadSpy;
import org.hibernate.search.util.impl.integrationtest.common.stub.backend.index.StubIndexScopeWork;
import org.hibernate.search.util.impl.integrationtest.common.stub.backend.index.StubIndexScaleWork;
import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper;
import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmUtils;
import org.hibernate.search.util.impl.test.SubTest;
Expand Down Expand Up @@ -84,11 +84,11 @@ public void indexing() {
exceptionMessage
)
.hasCauseInstanceOf( SimulatedFailure.class ),
expectIndexScopeWork( StubIndexScopeWork.Type.PURGE, ExecutionExpectation.SUCCEED ),
expectIndexScopeWork( StubIndexScopeWork.Type.MERGE_SEGMENTS, ExecutionExpectation.SUCCEED ),
expectIndexScaleWork( StubIndexScaleWork.Type.PURGE, ExecutionExpectation.SUCCEED ),
expectIndexScaleWork( StubIndexScaleWork.Type.MERGE_SEGMENTS, ExecutionExpectation.SUCCEED ),
expectIndexingWorks( ExecutionExpectation.FAIL ),
expectIndexScopeWork( StubIndexScopeWork.Type.FLUSH, ExecutionExpectation.SUCCEED ),
expectIndexScopeWork( StubIndexScopeWork.Type.REFRESH, ExecutionExpectation.SUCCEED )
expectIndexScaleWork( StubIndexScaleWork.Type.FLUSH, ExecutionExpectation.SUCCEED ),
expectIndexScaleWork( StubIndexScaleWork.Type.REFRESH, ExecutionExpectation.SUCCEED )
);

assertEntityIndexingFailureHandling(
Expand Down Expand Up @@ -125,11 +125,11 @@ public void getId() {
.isInstanceOf( SearchException.class )
.hasMessageContaining( "Exception while invoking" ),
ExecutionExpectation.FAIL, ExecutionExpectation.SKIP,
expectIndexScopeWork( StubIndexScopeWork.Type.PURGE, ExecutionExpectation.SUCCEED ),
expectIndexScopeWork( StubIndexScopeWork.Type.MERGE_SEGMENTS, ExecutionExpectation.SUCCEED ),
expectIndexScaleWork( StubIndexScaleWork.Type.PURGE, ExecutionExpectation.SUCCEED ),
expectIndexScaleWork( StubIndexScaleWork.Type.MERGE_SEGMENTS, ExecutionExpectation.SUCCEED ),
expectIndexingWorks( ExecutionExpectation.SKIP ),
expectIndexScopeWork( StubIndexScopeWork.Type.FLUSH, ExecutionExpectation.SUCCEED ),
expectIndexScopeWork( StubIndexScopeWork.Type.REFRESH, ExecutionExpectation.SUCCEED )
expectIndexScaleWork( StubIndexScaleWork.Type.FLUSH, ExecutionExpectation.SUCCEED ),
expectIndexScaleWork( StubIndexScaleWork.Type.REFRESH, ExecutionExpectation.SUCCEED )
);

assertEntityGetterFailureHandling(
Expand Down Expand Up @@ -166,11 +166,11 @@ public void getTitle() {
.isInstanceOf( SearchException.class )
.hasMessageContaining( "Exception while invoking" ),
ExecutionExpectation.SUCCEED, ExecutionExpectation.FAIL,
expectIndexScopeWork( StubIndexScopeWork.Type.PURGE, ExecutionExpectation.SUCCEED ),
expectIndexScopeWork( StubIndexScopeWork.Type.MERGE_SEGMENTS, ExecutionExpectation.SUCCEED ),
expectIndexScaleWork( StubIndexScaleWork.Type.PURGE, ExecutionExpectation.SUCCEED ),
expectIndexScaleWork( StubIndexScaleWork.Type.MERGE_SEGMENTS, ExecutionExpectation.SUCCEED ),
expectIndexingWorks( ExecutionExpectation.SKIP ),
expectIndexScopeWork( StubIndexScopeWork.Type.FLUSH, ExecutionExpectation.SUCCEED ),
expectIndexScopeWork( StubIndexScopeWork.Type.REFRESH, ExecutionExpectation.SUCCEED )
expectIndexScaleWork( StubIndexScaleWork.Type.FLUSH, ExecutionExpectation.SUCCEED ),
expectIndexScaleWork( StubIndexScaleWork.Type.REFRESH, ExecutionExpectation.SUCCEED )
);

assertEntityGetterFailureHandling(
Expand All @@ -193,7 +193,7 @@ public void purge() {
ThreadExpectation.NOT_CREATED,
throwable -> assertThat( throwable ).isInstanceOf( SimulatedFailure.class )
.hasMessageContaining( exceptionMessage ),
expectIndexScopeWork( StubIndexScopeWork.Type.PURGE, ExecutionExpectation.FAIL )
expectIndexScaleWork( StubIndexScaleWork.Type.PURGE, ExecutionExpectation.FAIL )
);

assertMassIndexerOperationFailureHandling( exceptionMessage, failingOperationAsString );
Expand All @@ -213,8 +213,8 @@ public void mergeSegmentsBefore() {
ThreadExpectation.NOT_CREATED,
throwable -> assertThat( throwable ).isInstanceOf( SimulatedFailure.class )
.hasMessageContaining( exceptionMessage ),
expectIndexScopeWork( StubIndexScopeWork.Type.PURGE, ExecutionExpectation.SUCCEED ),
expectIndexScopeWork( StubIndexScopeWork.Type.MERGE_SEGMENTS, ExecutionExpectation.FAIL )
expectIndexScaleWork( StubIndexScaleWork.Type.PURGE, ExecutionExpectation.SUCCEED ),
expectIndexScaleWork( StubIndexScaleWork.Type.MERGE_SEGMENTS, ExecutionExpectation.FAIL )
);

assertMassIndexerOperationFailureHandling( exceptionMessage, failingOperationAsString );
Expand All @@ -235,10 +235,10 @@ public void mergeSegmentsAfter() {
ThreadExpectation.CREATED_AND_TERMINATED,
throwable -> assertThat( throwable ).isInstanceOf( SimulatedFailure.class )
.hasMessageContaining( exceptionMessage ),
expectIndexScopeWork( StubIndexScopeWork.Type.PURGE, ExecutionExpectation.SUCCEED ),
expectIndexScopeWork( StubIndexScopeWork.Type.MERGE_SEGMENTS, ExecutionExpectation.SUCCEED ),
expectIndexScaleWork( StubIndexScaleWork.Type.PURGE, ExecutionExpectation.SUCCEED ),
expectIndexScaleWork( StubIndexScaleWork.Type.MERGE_SEGMENTS, ExecutionExpectation.SUCCEED ),
expectIndexingWorks( ExecutionExpectation.SUCCEED ),
expectIndexScopeWork( StubIndexScopeWork.Type.MERGE_SEGMENTS, ExecutionExpectation.FAIL )
expectIndexScaleWork( StubIndexScaleWork.Type.MERGE_SEGMENTS, ExecutionExpectation.FAIL )
);

assertMassIndexerOperationFailureHandling( exceptionMessage, failingOperationAsString );
Expand All @@ -258,10 +258,10 @@ public void flush() {
ThreadExpectation.CREATED_AND_TERMINATED,
throwable -> assertThat( throwable ).isInstanceOf( SimulatedFailure.class )
.hasMessageContaining( exceptionMessage ),
expectIndexScopeWork( StubIndexScopeWork.Type.PURGE, ExecutionExpectation.SUCCEED ),
expectIndexScopeWork( StubIndexScopeWork.Type.MERGE_SEGMENTS, ExecutionExpectation.SUCCEED ),
expectIndexScaleWork( StubIndexScaleWork.Type.PURGE, ExecutionExpectation.SUCCEED ),
expectIndexScaleWork( StubIndexScaleWork.Type.MERGE_SEGMENTS, ExecutionExpectation.SUCCEED ),
expectIndexingWorks( ExecutionExpectation.SUCCEED ),
expectIndexScopeWork( StubIndexScopeWork.Type.FLUSH, ExecutionExpectation.FAIL )
expectIndexScaleWork( StubIndexScaleWork.Type.FLUSH, ExecutionExpectation.FAIL )
);

assertMassIndexerOperationFailureHandling( exceptionMessage, failingOperationAsString );
Expand All @@ -281,11 +281,11 @@ public void refresh() {
ThreadExpectation.CREATED_AND_TERMINATED,
throwable -> assertThat( throwable ).isInstanceOf( SimulatedFailure.class )
.hasMessageContaining( exceptionMessage ),
expectIndexScopeWork( StubIndexScopeWork.Type.PURGE, ExecutionExpectation.SUCCEED ),
expectIndexScopeWork( StubIndexScopeWork.Type.MERGE_SEGMENTS, ExecutionExpectation.SUCCEED ),
expectIndexScaleWork( StubIndexScaleWork.Type.PURGE, ExecutionExpectation.SUCCEED ),
expectIndexScaleWork( StubIndexScaleWork.Type.MERGE_SEGMENTS, ExecutionExpectation.SUCCEED ),
expectIndexingWorks( ExecutionExpectation.SUCCEED ),
expectIndexScopeWork( StubIndexScopeWork.Type.FLUSH, ExecutionExpectation.SUCCEED ),
expectIndexScopeWork( StubIndexScopeWork.Type.REFRESH, ExecutionExpectation.FAIL )
expectIndexScaleWork( StubIndexScaleWork.Type.FLUSH, ExecutionExpectation.SUCCEED ),
expectIndexScaleWork( StubIndexScaleWork.Type.REFRESH, ExecutionExpectation.FAIL )
);

assertMassIndexerOperationFailureHandling( exceptionMessage, failingOperationAsString );
Expand Down Expand Up @@ -325,10 +325,10 @@ public void indexingAndFlush() {
)
.hasCauseInstanceOf( SimulatedFailure.class )
),
expectIndexScopeWork( StubIndexScopeWork.Type.PURGE, ExecutionExpectation.SUCCEED ),
expectIndexScopeWork( StubIndexScopeWork.Type.MERGE_SEGMENTS, ExecutionExpectation.SUCCEED ),
expectIndexScaleWork( StubIndexScaleWork.Type.PURGE, ExecutionExpectation.SUCCEED ),
expectIndexScaleWork( StubIndexScaleWork.Type.MERGE_SEGMENTS, ExecutionExpectation.SUCCEED ),
expectIndexingWorks( ExecutionExpectation.FAIL ),
expectIndexScopeWork( StubIndexScopeWork.Type.FLUSH, ExecutionExpectation.FAIL )
expectIndexScaleWork( StubIndexScaleWork.Type.FLUSH, ExecutionExpectation.FAIL )
);

assertEntityIndexingAndMassIndexerOperationFailureHandling(
Expand Down Expand Up @@ -372,11 +372,11 @@ public void indexingAndRefresh() {
)
.hasCauseInstanceOf( SimulatedFailure.class )
),
expectIndexScopeWork( StubIndexScopeWork.Type.PURGE, ExecutionExpectation.SUCCEED ),
expectIndexScopeWork( StubIndexScopeWork.Type.MERGE_SEGMENTS, ExecutionExpectation.SUCCEED ),
expectIndexScaleWork( StubIndexScaleWork.Type.PURGE, ExecutionExpectation.SUCCEED ),
expectIndexScaleWork( StubIndexScaleWork.Type.MERGE_SEGMENTS, ExecutionExpectation.SUCCEED ),
expectIndexingWorks( ExecutionExpectation.FAIL ),
expectIndexScopeWork( StubIndexScopeWork.Type.FLUSH, ExecutionExpectation.SUCCEED ),
expectIndexScopeWork( StubIndexScopeWork.Type.REFRESH, ExecutionExpectation.FAIL )
expectIndexScaleWork( StubIndexScaleWork.Type.FLUSH, ExecutionExpectation.SUCCEED ),
expectIndexScaleWork( StubIndexScaleWork.Type.REFRESH, ExecutionExpectation.FAIL )
);

assertEntityIndexingAndMassIndexerOperationFailureHandling(
Expand Down Expand Up @@ -505,18 +505,18 @@ private void doMassIndexingWithFailure(MassIndexer massIndexer,
}
}

private Runnable expectIndexScopeWork(StubIndexScopeWork.Type type, ExecutionExpectation executionExpectation) {
private Runnable expectIndexScaleWork(StubIndexScaleWork.Type type, ExecutionExpectation executionExpectation) {
return () -> {
switch ( executionExpectation ) {
case SUCCEED:
backendMock.expectIndexScopeWorks( Book.NAME )
.indexScopeWork( type );
backendMock.expectIndexScaleWorks( Book.NAME )
.indexScaleWork( type );
break;
case FAIL:
CompletableFuture<?> failingFuture = new CompletableFuture<>();
failingFuture.completeExceptionally( new SimulatedFailure( type.name() + " failure" ) );
backendMock.expectIndexScopeWorks( Book.NAME )
.indexScopeWork( type, failingFuture );
backendMock.expectIndexScaleWorks( Book.NAME )
.indexScaleWork( type, failingFuture );
break;
case SKIP:
break;
Expand Down
Expand Up @@ -94,7 +94,7 @@ public void defaultMassIndexerStartAndWait() throws Exception {

// purgeAtStart and mergeSegmentsAfterPurge are enabled by default,
// so we expect 1 purge, 1 mergeSegments and 1 flush calls in this order:
backendMock.expectIndexScopeWorks( Book.INDEX, session.getTenantIdentifier() )
backendMock.expectIndexScaleWorks( Book.INDEX, session.getTenantIdentifier() )
.purge()
.mergeSegments()
.flush()
Expand Down Expand Up @@ -140,7 +140,7 @@ public void mergeSegmentsOnFinish() {
// purgeAtStart and mergeSegmentsAfterPurge are enabled by default,
// and optimizeOnFinish is enabled explicitly,
// so we expect 1 purge, 2 optimize and 1 flush calls in this order:
backendMock.expectIndexScopeWorks( Book.INDEX, session.getTenantIdentifier() )
backendMock.expectIndexScaleWorks( Book.INDEX, session.getTenantIdentifier() )
.purge()
.mergeSegments()
.mergeSegments()
Expand Down Expand Up @@ -185,7 +185,7 @@ public void fromMappingWithoutSession() throws Exception {

// purgeAtStart and mergeSegmentsAfterPurge are enabled by default,
// so we expect 1 purge, 1 mergeSegments and 1 flush calls in this order:
backendMock.expectIndexScopeWorks( Book.INDEX )
backendMock.expectIndexScaleWorks( Book.INDEX )
.purge()
.mergeSegments()
.flush()
Expand Down
Expand Up @@ -101,7 +101,7 @@ public void defaultMassIndexerStartAndWait() {

// purgeAtStart and mergeSegmentsAfterPurge are enabled by default,
// so we expect 1 purge, 1 mergeSegments and 1 flush calls in this order:
backendMock.expectIndexScopeWorks( Book.INDEX, session.getTenantIdentifier() )
backendMock.expectIndexScaleWorks( Book.INDEX, session.getTenantIdentifier() )
.purge()
.mergeSegments()
.flush()
Expand Down
Expand Up @@ -128,7 +128,7 @@ private MassIndexer prepareMassIndexingThatWillNotTerminate() {
.typesToIndexInParallel( 1 )
.threadsToLoadObjects( 1 );

backendMock.expectIndexScopeWorks( Book.INDEX )
backendMock.expectIndexScaleWorks( Book.INDEX )
.purge()
.mergeSegments();

Expand All @@ -142,7 +142,7 @@ private MassIndexer prepareMassIndexingThatWillNotTerminate() {
// Return a CompletableFuture that will never complete
.processedThenExecuted( new CompletableFuture<>() );

backendMock.expectIndexScopeWorks( Book.INDEX )
backendMock.expectIndexScaleWorks( Book.INDEX )
.flush()
.refresh()
.mergeSegments();
Expand Down
Expand Up @@ -89,7 +89,7 @@ public void simple() {

// purgeAtStart and mergeSegmentsAfterPurge are enabled by default,
// so we expect 1 purge, 1 mergeSegments and 1 flush calls in this order:
backendMock.expectIndexScopeWorks( Book.INDEX, session.getTenantIdentifier() )
backendMock.expectIndexScaleWorks( Book.INDEX, session.getTenantIdentifier() )
.purge()
.mergeSegments()
.flush()
Expand Down
Expand Up @@ -93,7 +93,7 @@ public void defaultMassIndexerStartAndWait() {

// purgeAtStart and mergeSegmentsAfterPurge are enabled by default,
// so we expect 1 purge, 1 mergeSegments and 1 flush calls in this order:
backendMock.expectIndexScopeWorks( Book.INDEX, session.getTenantIdentifier() )
backendMock.expectIndexScaleWorks( Book.INDEX, session.getTenantIdentifier() )
.purge()
.mergeSegments()
.flush()
Expand Down
Expand Up @@ -72,7 +72,7 @@ public void entityWithPrimitiveId() {

// purgeAtStart and mergeSegmentsAfterPurge are enabled by default,
// so we expect 1 purge, 1 mergeSegments and 1 flush calls in this order:
backendMock.expectIndexScopeWorks( EntityWithPrimitiveId.INDEX, session.getTenantIdentifier() )
backendMock.expectIndexScaleWorks( EntityWithPrimitiveId.INDEX, session.getTenantIdentifier() )
.purge()
.mergeSegments()
.flush()
Expand Down
Expand Up @@ -16,7 +16,7 @@
public class SearchWorkspaceFlushIT extends AbstractSearchWorkspaceSimpleOperationIT {
@Override
protected void expectWork(BackendMock backendMock, String indexName, CompletableFuture<?> future) {
backendMock.expectIndexScopeWorks( indexName )
backendMock.expectIndexScaleWorks( indexName )
.flush( future );
}

Expand Down
Expand Up @@ -16,7 +16,7 @@
public class SearchWorkspaceMergeSegmentsIT extends AbstractSearchWorkspaceSimpleOperationIT {
@Override
protected void expectWork(BackendMock backendMock, String indexName, CompletableFuture<?> future) {
backendMock.expectIndexScopeWorks( indexName )
backendMock.expectIndexScaleWorks( indexName )
.mergeSegments( future );
}

Expand Down
Expand Up @@ -16,7 +16,7 @@
public class SearchWorkspacePurgeIT extends AbstractSearchWorkspaceSimpleOperationIT {
@Override
protected void expectWork(BackendMock backendMock, String indexName, CompletableFuture<?> future) {
backendMock.expectIndexScopeWorks( indexName )
backendMock.expectIndexScaleWorks( indexName )
.purge( future );
}

Expand Down
Expand Up @@ -16,7 +16,7 @@
public class SearchWorkspaceRefreshIT extends AbstractSearchWorkspaceSimpleOperationIT {
@Override
protected void expectWork(BackendMock backendMock, String indexName, CompletableFuture<?> future) {
backendMock.expectIndexScopeWorks( indexName )
backendMock.expectIndexScaleWorks( indexName )
.refresh( future );
}

Expand Down
Expand Up @@ -10,30 +10,30 @@

import org.hibernate.search.util.common.impl.ToStringStyle;
import org.hibernate.search.util.common.impl.ToStringTreeBuilder;
import org.hibernate.search.util.impl.integrationtest.common.stub.backend.index.StubIndexScopeWork;
import org.hibernate.search.util.impl.integrationtest.common.stub.backend.index.StubIndexScaleWork;

import org.junit.Assert;

public class StubIndexScopeWorkAssert {
public class StubIndexScaleWorkAssert {

public static StubIndexScopeWorkAssert assertThat(StubIndexScopeWork work) {
return new StubIndexScopeWorkAssert( work );
public static StubIndexScaleWorkAssert assertThat(StubIndexScaleWork work) {
return new StubIndexScaleWorkAssert( work );
}

private final StubIndexScopeWork actual;
private final StubIndexScaleWork actual;

private String messageBase = "Index-scope work did not match: ";
private String messageBase = "Index-scale work did not match: ";

private StubIndexScopeWorkAssert(StubIndexScopeWork actual) {
private StubIndexScaleWorkAssert(StubIndexScaleWork actual) {
this.actual = actual;
}

public StubIndexScopeWorkAssert as(String messageBase) {
public StubIndexScaleWorkAssert as(String messageBase) {
this.messageBase = messageBase;
return this;
}

public StubIndexScopeWorkAssert matches(StubIndexScopeWork expected) {
public StubIndexScaleWorkAssert matches(StubIndexScaleWork expected) {
ToStringTreeBuilder builder = new ToStringTreeBuilder( ToStringStyle.multilineDelimiterStructure() );

builder.startObject();
Expand Down

0 comments on commit e7e19ed

Please sign in to comment.