Skip to content

Commit

Permalink
Switched to basing off seconds
Browse files Browse the repository at this point in the history
Signed-off-by: Joshua Au <[email protected]>
  • Loading branch information
Joshua152 committed Dec 12, 2023
1 parent a79d754 commit d60bf2f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ import org.opensearch.indexmanagement.util.IndexUtils.Companion.LUCENE_MAX_CLAUS
import org.opensearch.indexmanagement.util.IndexUtils.Companion.ODFE_MAGIC_NULL
import org.opensearch.indexmanagement.util.IndexUtils.Companion.hashToFixedSize
import org.opensearch.core.rest.RestStatus
import org.opensearch.indexmanagement.transform.settings.TransformSettings.Companion.MINIMUM_CANCEL_AFTER_TIME_INTERVAL_MINUTES
import org.opensearch.indexmanagement.transform.settings.TransformSettings.Companion.MINIMUM_CANCEL_AFTER_TIME_INTERVAL_SECONDS
import org.opensearch.search.aggregations.Aggregation
import org.opensearch.search.aggregations.bucket.composite.CompositeAggregation
import org.opensearch.search.aggregations.bucket.composite.CompositeAggregationBuilder
Expand Down Expand Up @@ -201,8 +201,7 @@ class TransformSearchService(

var searchRequestTimeoutInSeconds = transformContext.getMaxRequestTimeoutInSeconds()
if (searchRequestTimeoutInSeconds == null) {
val timeIntervalMinutes = TimeValue.timeValueMinutes(getCancelAfterTimeInterval(cancelAfterTimeInterval.minutes))
searchRequestTimeoutInSeconds = timeIntervalMinutes.seconds
searchRequestTimeoutInSeconds = getCancelAfterTimeIntervalSeconds(cancelAfterTimeInterval.seconds)
}

client.suspendUntil { listener: ActionListener<SearchResponse> ->
Expand Down Expand Up @@ -240,14 +239,14 @@ class TransformSearchService(
}
}

private fun getCancelAfterTimeInterval(givenIntervalMinutes: Long): Long {
private fun getCancelAfterTimeIntervalSeconds(givenIntervalSeconds: Long): Long {
// The default value for the cancelAfterTimeInterval is -1 and so, in this case
// we should ignore processing on the value
if (givenIntervalMinutes == -1L) {
if (givenIntervalSeconds == -1L) {
return -1
}

return max(givenIntervalMinutes, MINIMUM_CANCEL_AFTER_TIME_INTERVAL_MINUTES)
return max(givenIntervalSeconds, MINIMUM_CANCEL_AFTER_TIME_INTERVAL_SECONDS)
}

companion object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class TransformSettings {
companion object {
const val DEFAULT_RENEW_LOCK_RETRY_COUNT = 3
const val DEFAULT_RENEW_LOCK_RETRY_DELAY = 1000L
const val MINIMUM_CANCEL_AFTER_TIME_INTERVAL_MINUTES = 10L
const val MINIMUM_CANCEL_AFTER_TIME_INTERVAL_SECONDS = 600L

val TRANSFORM_JOB_SEARCH_BACKOFF_COUNT: Setting<Int> = Setting.intSetting(
"plugins.transform.internal.search.backoff_count",
Expand Down

0 comments on commit d60bf2f

Please sign in to comment.