Skip to content

Commit

Permalink
HSEARCH-3460 Introduce SPIs for explicit index refresh
Browse files Browse the repository at this point in the history
  • Loading branch information
yrodiere committed Feb 17, 2020
1 parent 4da3ea8 commit 86f465b
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 2 deletions.
Expand Up @@ -58,4 +58,10 @@ public CompletableFuture<?> purge() {
public CompletableFuture<?> flush() {
return orchestrator.submit( builderFactory.flush().index( indexName ).build() );
}

@Override
public CompletableFuture<?> refresh() {
// TODO HSEARCH-3460
throw new UnsupportedOperationException( "Not implemented yet" );
}
}
Expand Up @@ -46,6 +46,12 @@ public CompletableFuture<?> flush() {
return doSubmit( factory.flush() );
}

@Override
public CompletableFuture<?> refresh() {
// TODO HSEARCH-3460
throw new UnsupportedOperationException( "Not implemented yet" );
}

private CompletableFuture<?> doSubmit(LuceneWriteWork<?> work) {
Collection<LuceneWriteWorkOrchestrator> orchestrators = indexManagerContext.getAllWriteOrchestrators();
CompletableFuture<?>[] futures = new CompletableFuture[orchestrators.size()];
Expand All @@ -59,6 +65,5 @@ private CompletableFuture<?> doSubmit(LuceneWriteWork<?> work) {
++i;
}
return CompletableFuture.allOf( futures );

}
}
Expand Up @@ -19,4 +19,6 @@ public interface IndexWorkspace {

CompletableFuture<?> flush();

CompletableFuture<?> refresh();

}
Expand Up @@ -42,6 +42,11 @@ public CompletableFuture<?> flush() {
return doOperationOnTypes( IndexWorkspace::flush );
}

@Override
public CompletableFuture<?> refresh() {
return doOperationOnTypes( IndexWorkspace::refresh );
}

private CompletableFuture<?> doOperationOnTypes(Function<IndexWorkspace, CompletableFuture<?>> operation) {
CompletableFuture<?>[] futures = new CompletableFuture<?>[delegates.size()];
int typeCounter = 0;
Expand Down
Expand Up @@ -16,4 +16,6 @@ public interface PojoScopeWorkspace {

CompletableFuture<?> flush();

CompletableFuture<?> refresh();

}
Expand Up @@ -363,6 +363,14 @@ public IndexScopeWorkCallListContext flush(CompletableFuture<?> future) {
return indexScopeWork( StubIndexScopeWork.Type.FLUSH, future );
}

public IndexScopeWorkCallListContext refresh() {
return indexScopeWork( StubIndexScopeWork.Type.REFRESH );
}

public IndexScopeWorkCallListContext refresh(CompletableFuture<?> future) {
return indexScopeWork( StubIndexScopeWork.Type.REFRESH, future );
}

public IndexScopeWorkCallListContext indexScopeWork(StubIndexScopeWork.Type type) {
return indexScopeWork( type, CompletableFuture.completedFuture( null ) );
}
Expand Down
Expand Up @@ -9,7 +9,7 @@
public final class StubIndexScopeWork {

public enum Type {
MERGE_SEGMENTS, PURGE, FLUSH
MERGE_SEGMENTS, PURGE, FLUSH, REFRESH
}

public static Builder builder(Type type) {
Expand Down
Expand Up @@ -46,4 +46,10 @@ public CompletableFuture<?> flush() {
StubIndexScopeWork work = StubIndexScopeWork.builder( StubIndexScopeWork.Type.FLUSH ).build();
return behavior.executeIndexScopeWork( Collections.singleton( indexName ), work );
}

@Override
public CompletableFuture<?> refresh() {
StubIndexScopeWork work = StubIndexScopeWork.builder( StubIndexScopeWork.Type.REFRESH ).build();
return behavior.executeIndexScopeWork( Collections.singleton( indexName ), work );
}
}

0 comments on commit 86f465b

Please sign in to comment.