Skip to content

Commit

Permalink
More
Browse files Browse the repository at this point in the history
  • Loading branch information
n1v0lg committed Sep 12, 2024
1 parent 42e439a commit 6aa6fce
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ private void innerGetPrivileges(
if (frozenSecurityIndex.indexExists() == false) {
listener.onResponse(Collections.emptyList());
} else if (frozenSecurityIndex.isAvailable(SEARCH_SHARDS) == false) {
if (false == waitOnUnavailable || false == frozenSecurityIndex.isCreating()) {
if (false == waitOnUnavailable || false == frozenSecurityIndex.indexIsCreating()) {
listener.onFailure(frozenSecurityIndex.getUnavailableReason(SEARCH_SHARDS));
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,9 @@ public boolean isAvailable(Availability availability) {
throw new IllegalStateException("Unexpected availability enumeration. This is bug, please contact support.");
}

public boolean isCreating() {
public boolean indexIsCreating() {
// TODO this is not accurate
return this.state.indexAvailableForWrite && this.state.indexAvailableForSearch == false;
return this.state.indexCreating;
}

public boolean isMappingUpToDate() {
Expand Down Expand Up @@ -375,21 +375,21 @@ public void onIndexAvailableAfterCreation(ActionListener<Void> listener) {
}
return;
}
final BiConsumer<SecurityIndexManager.State, SecurityIndexManager.State> indexAvailableForSearchListener = new BiConsumer<>() {
final BiConsumer<SecurityIndexManager.State, SecurityIndexManager.State> indexAvailableListener = new BiConsumer<>() {
@Override
public void accept(SecurityIndexManager.State previousState, SecurityIndexManager.State nextState) {
if (nextState.indexAvailableForSearch) {
if (nextState.indexAvailableForWrite && nextState.indexAvailableForSearch) {
if (removeStateListener(this)) {
listener.onResponse(null);
}
}
}
};
addStateListener(indexAvailableForSearchListener);
addStateListener(indexAvailableListener);
// TODO cleaner cancellation handling -- also, if we complete without cancelling, we should cancel the cancellation...
final ThreadPool threadPool = client.threadPool();
threadPool.schedule(() -> {
if (removeStateListener(indexAvailableForSearchListener)) {
if (removeStateListener(indexAvailableListener)) {
listener.onFailure(new IllegalStateException("timed out waiting for index"));
}
}, TimeValue.timeValueSeconds(5), threadPool.generic());
Expand Down

0 comments on commit 6aa6fce

Please sign in to comment.