Skip to content
This repository was archived by the owner on Aug 2, 2022. It is now read-only.

Commit d4d5afc

Browse files
Use common-utils from maven, use withContext instead runBlocking (#273)
1 parent 509a748 commit d4d5afc

File tree

3 files changed

+3
-7
lines changed

3 files changed

+3
-7
lines changed

alerting/src/main/kotlin/com/amazon/opendistroforelasticsearch/alerting/MonitorRunner.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,13 @@ import com.amazon.opendistroforelasticsearch.alerting.settings.DestinationSettin
5555
import com.amazon.opendistroforelasticsearch.alerting.settings.DestinationSettings.Companion.loadDestinationSettings
5656
import com.amazon.opendistroforelasticsearch.alerting.util.IndexUtils
5757
import com.amazon.opendistroforelasticsearch.alerting.util.isAllowed
58-
import org.apache.logging.log4j.LogManager
5958
import kotlinx.coroutines.CoroutineScope
6059
import kotlinx.coroutines.Dispatchers
6160
import kotlinx.coroutines.Job
6261
import kotlinx.coroutines.SupervisorJob
6362
import kotlinx.coroutines.launch
64-
import kotlinx.coroutines.runBlocking
6563
import kotlinx.coroutines.withContext
64+
import org.apache.logging.log4j.LogManager
6665
import org.elasticsearch.ExceptionsHelper
6766
import org.elasticsearch.action.DocWriteRequest
6867
import org.elasticsearch.action.bulk.BackoffPolicy
@@ -224,7 +223,7 @@ class MonitorRunner(
224223
logger.error("Error loading alerts for monitor: $id", e)
225224
return monitorResult.copy(error = e)
226225
}
227-
runBlocking(InjectorContextElement(monitor.id, settings, threadPool.threadContext, roles)) {
226+
withContext(InjectorContextElement(monitor.id, settings, threadPool.threadContext, roles)) {
228227
monitorResult = monitorResult.copy(inputResults = collectInputResults(monitor, periodStart, periodEnd))
229228
}
230229
val updatedAlerts = mutableListOf<Alert>()

core/build.gradle

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,9 @@ dependencies {
2525
compile "com.cronutils:cron-utils:7.0.5"
2626
compile "org.elasticsearch.client:elasticsearch-rest-client:${es_version}"
2727
compile 'com.google.googlejavaformat:google-java-format:1.3'
28+
compile "com.amazon.opendistroforelasticsearch:common-utils:${opendistroVersion}.0"
2829

2930
testImplementation "org.elasticsearch.test:framework:${es_version}"
3031
testImplementation "org.jetbrains.kotlin:kotlin-test:${kotlin_version}"
3132
testImplementation "org.jetbrains.kotlin:kotlin-test-junit:${kotlin_version}"
32-
33-
34-
//fixme: pick it from maven, pending on https://github.com/opendistro-for-elasticsearch/common-utils/pull/3
35-
compile files('libs/common-utils-1.10.1.0.jar')
3633
}

core/libs/common-utils-1.10.1.0.jar

-16.5 KB
Binary file not shown.

0 commit comments

Comments
 (0)