-
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
(cherry picked from commit b654e43) Signed-off-by: Vamsi Manohar <reddyvam@amazon.com> 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
a877ea8
commit 145b163
Showing
9 changed files
with
214 additions
and
74 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
24 changes: 10 additions & 14 deletions
24
spark/src/main/java/org/opensearch/sql/spark/config/SparkExecutionEngineConfig.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 |
---|---|---|
@@ -1,25 +1,21 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.opensearch.sql.spark.config; | ||
|
||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | ||
import com.google.gson.Gson; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
/** | ||
* POJO for spark Execution Engine Config. Interface between {@link | ||
* org.opensearch.sql.spark.asyncquery.AsyncQueryExecutorService} and {@link | ||
* SparkExecutionEngineConfigSupplier} | ||
*/ | ||
@Data | ||
@JsonIgnoreProperties(ignoreUnknown = true) | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class SparkExecutionEngineConfig { | ||
private String applicationId; | ||
private String region; | ||
private String executionRoleARN; | ||
|
||
/** Additional Spark submit parameters to append to request. */ | ||
private String sparkSubmitParameters; | ||
|
||
public static SparkExecutionEngineConfig toSparkExecutionEngineConfig(String jsonString) { | ||
return new Gson().fromJson(jsonString, SparkExecutionEngineConfig.class); | ||
} | ||
private String clusterName; | ||
} |
30 changes: 30 additions & 0 deletions
30
...c/main/java/org/opensearch/sql/spark/config/SparkExecutionEngineConfigClusterSetting.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,30 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.opensearch.sql.spark.config; | ||
|
||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | ||
import com.google.gson.Gson; | ||
import lombok.Data; | ||
|
||
/** | ||
* This POJO is just for reading stringified json in `plugins.query.executionengine.spark.config` | ||
* setting. | ||
*/ | ||
@Data | ||
@JsonIgnoreProperties(ignoreUnknown = true) | ||
public class SparkExecutionEngineConfigClusterSetting { | ||
private String applicationId; | ||
private String region; | ||
private String executionRoleARN; | ||
|
||
/** Additional Spark submit parameters to append to request. */ | ||
private String sparkSubmitParameters; | ||
|
||
public static SparkExecutionEngineConfigClusterSetting toSparkExecutionEngineConfig( | ||
String jsonString) { | ||
return new Gson().fromJson(jsonString, SparkExecutionEngineConfigClusterSetting.class); | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
spark/src/main/java/org/opensearch/sql/spark/config/SparkExecutionEngineConfigSupplier.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,12 @@ | ||
package org.opensearch.sql.spark.config; | ||
|
||
/** Interface for extracting and providing SparkExecutionEngineConfig */ | ||
public interface SparkExecutionEngineConfigSupplier { | ||
|
||
/** | ||
* Get SparkExecutionEngineConfig | ||
* | ||
* @return {@link SparkExecutionEngineConfig}. | ||
*/ | ||
SparkExecutionEngineConfig getSparkExecutionEngineConfig(); | ||
} |
42 changes: 42 additions & 0 deletions
42
...src/main/java/org/opensearch/sql/spark/config/SparkExecutionEngineConfigSupplierImpl.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,42 @@ | ||
package org.opensearch.sql.spark.config; | ||
|
||
import static org.opensearch.sql.common.setting.Settings.Key.CLUSTER_NAME; | ||
import static org.opensearch.sql.common.setting.Settings.Key.SPARK_EXECUTION_ENGINE_CONFIG; | ||
|
||
import java.security.AccessController; | ||
import java.security.PrivilegedAction; | ||
import lombok.AllArgsConstructor; | ||
import org.apache.commons.lang3.StringUtils; | ||
import org.opensearch.cluster.ClusterName; | ||
import org.opensearch.sql.common.setting.Settings; | ||
|
||
@AllArgsConstructor | ||
public class SparkExecutionEngineConfigSupplierImpl implements SparkExecutionEngineConfigSupplier { | ||
|
||
private Settings settings; | ||
|
||
@Override | ||
public SparkExecutionEngineConfig getSparkExecutionEngineConfig() { | ||
String sparkExecutionEngineConfigSettingString = | ||
this.settings.getSettingValue(SPARK_EXECUTION_ENGINE_CONFIG); | ||
SparkExecutionEngineConfig sparkExecutionEngineConfig = new SparkExecutionEngineConfig(); | ||
if (!StringUtils.isBlank(sparkExecutionEngineConfigSettingString)) { | ||
SparkExecutionEngineConfigClusterSetting sparkExecutionEngineConfigClusterSetting = | ||
AccessController.doPrivileged( | ||
(PrivilegedAction<SparkExecutionEngineConfigClusterSetting>) | ||
() -> | ||
SparkExecutionEngineConfigClusterSetting.toSparkExecutionEngineConfig( | ||
sparkExecutionEngineConfigSettingString)); | ||
sparkExecutionEngineConfig.setApplicationId( | ||
sparkExecutionEngineConfigClusterSetting.getApplicationId()); | ||
sparkExecutionEngineConfig.setExecutionRoleARN( | ||
sparkExecutionEngineConfigClusterSetting.getExecutionRoleARN()); | ||
sparkExecutionEngineConfig.setSparkSubmitParameters( | ||
sparkExecutionEngineConfigClusterSetting.getSparkSubmitParameters()); | ||
sparkExecutionEngineConfig.setRegion(sparkExecutionEngineConfigClusterSetting.getRegion()); | ||
} | ||
ClusterName clusterName = settings.getSettingValue(CLUSTER_NAME); | ||
sparkExecutionEngineConfig.setClusterName(clusterName.value()); | ||
return sparkExecutionEngineConfig; | ||
} | ||
} |
Oops, something went wrong.