-
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.
Implement vacuum index operation (#2557)
* Add vacuum operation and IT Signed-off-by: Chen Dai <[email protected]> * Add index state doc delete and more IT Signed-off-by: Chen Dai <[email protected]> * Refactor IT Signed-off-by: Chen Dai <[email protected]> * Fix bytebuddy version conflict Signed-off-by: Chen Dai <[email protected]> * Fix broken IT Signed-off-by: Chen Dai <[email protected]> * Fix broken IT Signed-off-by: Chen Dai <[email protected]> * Fix jacoco failure with new IT Signed-off-by: Chen Dai <[email protected]> * Fix code format Signed-off-by: Chen Dai <[email protected]> * Fix jacoco test coverage Signed-off-by: Chen Dai <[email protected]> --------- Signed-off-by: Chen Dai <[email protected]>
- Loading branch information
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.