Skip to content

Commit

Permalink
Optimize scheduler interval conf (#3049)
Browse files Browse the repository at this point in the history
* Optimize scheduler interval conf

Signed-off-by: Louis Chu <[email protected]>

* Update OpenSearchAsyncQuerySchedulerConfigComposer.java

Signed-off-by: Louis Chu <[email protected]>

* Update OpenSearchAsyncQuerySchedulerConfigComposer.java

Signed-off-by: Louis Chu <[email protected]>

---------

Signed-off-by: Louis Chu <[email protected]>
  • Loading branch information
noCharger authored Oct 18, 2024
1 parent 7666a44 commit a87061d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import static org.opensearch.sql.spark.data.constants.SparkConstants.FLINT_JOB_EXTERNAL_SCHEDULER_INTERVAL;

import lombok.RequiredArgsConstructor;
import org.opensearch.core.common.Strings;
import org.opensearch.sql.common.setting.Settings;
import org.opensearch.sql.spark.asyncquery.model.AsyncQueryRequestContext;
import org.opensearch.sql.spark.dispatcher.model.DispatchQueryRequest;
Expand All @@ -30,7 +31,11 @@ public void compose(
settings.getSettingValue(Settings.Key.ASYNC_QUERY_EXTERNAL_SCHEDULER_INTERVAL);
sparkSubmitParameters.setConfigItem(
FLINT_JOB_EXTERNAL_SCHEDULER_ENABLED, String.valueOf(externalSchedulerEnabled));
sparkSubmitParameters.setConfigItem(
FLINT_JOB_EXTERNAL_SCHEDULER_INTERVAL, externalSchedulerInterval);
if (!Strings.isNullOrEmpty(externalSchedulerInterval)) {
externalSchedulerInterval =
"\"" + externalSchedulerInterval + "\""; // Wrap the value with double quotes
sparkSubmitParameters.setConfigItem(
FLINT_JOB_EXTERNAL_SCHEDULER_INTERVAL, externalSchedulerInterval);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.opensearch.sql.spark.config;

import static org.junit.Assert.assertNull;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

Expand Down Expand Up @@ -40,7 +41,7 @@ public void testCompose() {
verify(sparkSubmitParameters)
.setConfigItem("spark.flint.job.externalScheduler.enabled", "true");
verify(sparkSubmitParameters)
.setConfigItem("spark.flint.job.externalScheduler.interval", "10 minutes");
.setConfigItem("spark.flint.job.externalScheduler.interval", "\"10 minutes\"");
}

@Test
Expand All @@ -63,6 +64,6 @@ public void testComposeWithMissingInterval() {

composer.compose(sparkSubmitParameters, dispatchQueryRequest, context);

verify(sparkSubmitParameters).setConfigItem("spark.flint.job.externalScheduler.interval", "");
assertNull(sparkSubmitParameters.getConfigItem("spark.flint.job.externalScheduler.interval"));
}
}

0 comments on commit a87061d

Please sign in to comment.