-
Notifications
You must be signed in to change notification settings - Fork 141
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Add vacuum operation and IT * Add index state doc delete and more IT * Refactor IT * Fix bytebuddy version conflict * Fix broken IT * Fix broken IT * Fix jacoco failure with new IT * Fix code format * Fix jacoco test coverage --------- (cherry picked from commit 8374cb6) Signed-off-by: Chen Dai <[email protected]> Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
- Loading branch information
1 parent
8e25dd9
commit 68622f8
Showing
16 changed files
with
435 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,5 +12,6 @@ public enum IndexQueryActionType { | |
DESCRIBE, | ||
SHOW, | ||
DROP, | ||
VACUUM, | ||
ALTER | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
spark/src/main/java/org/opensearch/sql/spark/flint/operation/FlintIndexOpVacuum.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.opensearch.sql.spark.flint.operation; | ||
|
||
import org.apache.logging.log4j.LogManager; | ||
import org.apache.logging.log4j.Logger; | ||
import org.opensearch.action.admin.indices.delete.DeleteIndexRequest; | ||
import org.opensearch.action.support.master.AcknowledgedResponse; | ||
import org.opensearch.client.Client; | ||
import org.opensearch.sql.spark.execution.statestore.StateStore; | ||
import org.opensearch.sql.spark.flint.FlintIndexMetadata; | ||
import org.opensearch.sql.spark.flint.FlintIndexState; | ||
import org.opensearch.sql.spark.flint.FlintIndexStateModel; | ||
|
||
/** Flint index vacuum operation. */ | ||
public class FlintIndexOpVacuum extends FlintIndexOp { | ||
|
||
private static final Logger LOG = LogManager.getLogger(); | ||
|
||
/** OpenSearch client. */ | ||
private final Client client; | ||
|
||
public FlintIndexOpVacuum(StateStore stateStore, String datasourceName, Client client) { | ||
super(stateStore, datasourceName); | ||
this.client = client; | ||
} | ||
|
||
@Override | ||
boolean validate(FlintIndexState state) { | ||
return state == FlintIndexState.DELETED; | ||
} | ||
|
||
@Override | ||
FlintIndexState transitioningState() { | ||
return FlintIndexState.VACUUMING; | ||
} | ||
|
||
@Override | ||
public void runOp(FlintIndexMetadata flintIndexMetadata, FlintIndexStateModel flintIndex) { | ||
LOG.info("Vacuuming Flint index {}", flintIndexMetadata.getOpensearchIndexName()); | ||
DeleteIndexRequest request = | ||
new DeleteIndexRequest().indices(flintIndexMetadata.getOpensearchIndexName()); | ||
AcknowledgedResponse response = client.admin().indices().delete(request).actionGet(); | ||
LOG.info("OpenSearch index delete result: {}", response.isAcknowledged()); | ||
} | ||
|
||
@Override | ||
FlintIndexState stableState() { | ||
// Instruct StateStore to purge the index state doc | ||
return FlintIndexState.NONE; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.