-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move get metadata functions to new service
* Remove getIndexMetadata and getAllIndexMetadata from FlintClient * Implement the two for OpenSearch * TODO: sanitize index name * Add builder for FlintIndexMetadataService and options * Refactor caller of FlintClient.get(All)IndexMetadata with FlintIndexMetadataService * TODO: test suite for getIndexMetadata and getAllIndexMetadata (might overlap with FlintOpenSearchClientSuite) Signed-off-by: Sean Kao <[email protected]>
- Loading branch information
1 parent
addf507
commit 88ed8dd
Showing
14 changed files
with
163 additions
and
105 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
37 changes: 37 additions & 0 deletions
37
...e/src/main/scala/org/opensearch/flint/core/metadata/FlintIndexMetadataServiceBuilder.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,37 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.opensearch.flint.core.metadata; | ||
|
||
import java.lang.reflect.Constructor; | ||
import org.apache.spark.SparkConf; | ||
import org.opensearch.flint.common.metadata.FlintIndexMetadataService; | ||
import org.opensearch.flint.core.FlintOptions; | ||
import org.opensearch.flint.core.storage.FlintOpenSearchIndexMetadataService; | ||
|
||
/** | ||
* {@link FlintIndexMetadataService} builder. | ||
* <p> | ||
* Custom implementations of {@link FlintIndexMetadataService} are expected to provide a public | ||
* constructor with the signature {@code public MyCustomService(SparkConf sparkConf)} to be | ||
* instantiated by this builder. | ||
*/ | ||
public class FlintIndexMetadataServiceBuilder { | ||
public static FlintIndexMetadataService build(FlintOptions options, SparkConf sparkConf) { | ||
String className = options.getCustomFlintIndexMetadataServiceClass(); | ||
if (className.isEmpty()) { | ||
return new FlintOpenSearchIndexMetadataService(options); | ||
} | ||
|
||
// Attempts to instantiate Flint index metadata service with sparkConf using reflection | ||
try { | ||
Class<?> flintIndexMetadataServiceClass = Class.forName(className); | ||
Constructor<?> constructor = flintIndexMetadataServiceClass.getConstructor(SparkConf.class); | ||
return (FlintIndexMetadataService) constructor.newInstance(sparkConf); | ||
} catch (Exception e) { | ||
throw new RuntimeException("Failed to instantiate FlintIndexMetadataService: " + className, e); | ||
} | ||
} | ||
} |
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
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.