Skip to content

Commit

Permalink
changes to cleanup the pr
Browse files Browse the repository at this point in the history
Signed-off-by: Subhobrata Dey <[email protected]>
  • Loading branch information
sbcd90 committed May 28, 2024
1 parent 0181b85 commit 70f165f
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,7 @@ package org.opensearch.alerting.remote.monitors

import org.opensearch.alerting.spi.RemoteMonitorRunner

/**
* Class to store monitorType to monitorRunner tuples.
*/
class RemoteMonitorRegistry(val monitorType: String, val monitorRunner: RemoteMonitorRunner)
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ import org.opensearch.core.xcontent.NamedXContentRegistry
import org.opensearch.tasks.Task
import org.opensearch.transport.TransportService
import java.time.Instant
import java.util.*
import java.util.Locale

private val log = LogManager.getLogger(TransportExecuteMonitorAction::class.java)
private val scope: CoroutineScope = CoroutineScope(Dispatchers.IO)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,34 @@ import org.opensearch.common.settings.Settings
import org.opensearch.common.xcontent.LoggingDeprecationHandler
import org.opensearch.common.xcontent.XContentHelper
import org.opensearch.common.xcontent.XContentType
import org.opensearch.commons.alerting.action.*
import org.opensearch.commons.alerting.action.AcknowledgeAlertRequest
import org.opensearch.commons.alerting.action.AcknowledgeAlertResponse
import org.opensearch.commons.alerting.action.AcknowledgeChainedAlertRequest
import org.opensearch.commons.alerting.action.AlertingActions
import org.opensearch.commons.alerting.action.DeleteMonitorRequest
import org.opensearch.commons.alerting.action.GetAlertsRequest
import org.opensearch.commons.alerting.action.GetAlertsResponse
import org.opensearch.commons.alerting.action.IndexMonitorResponse
import org.opensearch.commons.alerting.action.SearchMonitorRequest
import org.opensearch.commons.alerting.aggregation.bucketselectorext.BucketSelectorExtAggregationBuilder
import org.opensearch.commons.alerting.model.*
import org.opensearch.commons.alerting.model.Alert
import org.opensearch.commons.alerting.model.ChainedAlertTrigger
import org.opensearch.commons.alerting.model.ChainedMonitorFindings
import org.opensearch.commons.alerting.model.CompositeInput
import org.opensearch.commons.alerting.model.DataSources
import org.opensearch.commons.alerting.model.Delegate
import org.opensearch.commons.alerting.model.DocLevelMonitorInput
import org.opensearch.commons.alerting.model.DocLevelQuery
import org.opensearch.commons.alerting.model.DocumentLevelTriggerRunResult
import org.opensearch.commons.alerting.model.IntervalSchedule
import org.opensearch.commons.alerting.model.Monitor
import org.opensearch.commons.alerting.model.ScheduledJob
import org.opensearch.commons.alerting.model.ScheduledJob.Companion.DOC_LEVEL_QUERIES_INDEX
import org.opensearch.commons.alerting.model.ScheduledJob.Companion.SCHEDULED_JOBS_INDEX
import org.opensearch.commons.alerting.model.SearchInput
import org.opensearch.commons.alerting.model.Table
import org.opensearch.commons.alerting.model.Workflow
import org.opensearch.commons.alerting.model.WorkflowMetadata
import org.opensearch.commons.alerting.util.AlertingException
import org.opensearch.core.rest.RestStatus
import org.opensearch.core.xcontent.XContentParser
Expand All @@ -58,8 +81,9 @@ import java.time.ZonedDateTime
import java.time.format.DateTimeFormatter
import java.time.temporal.ChronoUnit
import java.time.temporal.ChronoUnit.MILLIS
import java.util.*
import java.util.Collections
import java.util.Map
import java.util.UUID
import java.util.concurrent.ExecutionException
import java.util.concurrent.TimeUnit
import java.util.stream.Collectors
Expand Down Expand Up @@ -1574,6 +1598,26 @@ class MonitorDataSourcesIT : AlertingSingleNodeTestCase() {
""".trimIndent()
val monitorId = "abc"
indexDoc(SCHEDULED_JOBS_INDEX, monitorId, monitorStringWithoutName)

val monitorMetadata = """
{
"metadata": {
"monitor_id": "$monitorId",
"last_action_execution_times": [],
"last_run_context": {
"$index": {
"0": -1,
"index": "$index",
"shards_count": 1
}
},
"source_to_query_index_mapping": {
"$index$monitorId": ".opensearch-alerting-queries-000001"
}
}
}
""".trimIndent()
indexDoc(SCHEDULED_JOBS_INDEX, "$monitorId-metadata", monitorMetadata)
val getMonitorResponse = getMonitorResponse(monitorId)
Assert.assertNotNull(getMonitorResponse)
Assert.assertNotNull(getMonitorResponse.monitor)
Expand Down Expand Up @@ -1690,6 +1734,26 @@ class MonitorDataSourcesIT : AlertingSingleNodeTestCase() {
""".trimIndent()
val monitorId = "abc"
indexDoc(SCHEDULED_JOBS_INDEX, monitorId, monitorStringWithoutName)

val monitorMetadata = """
{
"metadata": {
"monitor_id": "$monitorId",
"last_action_execution_times": [],
"last_run_context": {
"$index": {
"0": -1,
"index": "$index",
"shards_count": 1
}
},
"source_to_query_index_mapping": {
"$index$monitorId": ".opensearch-alerting-queries-000001"
}
}
}
""".trimIndent()
indexDoc(SCHEDULED_JOBS_INDEX, "$monitorId-metadata", monitorMetadata)
val getMonitorResponse = getMonitorResponse(monitorId)
Assert.assertNotNull(getMonitorResponse)
Assert.assertNotNull(getMonitorResponse.monitor)
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@ import org.opensearch.core.common.breaker.CircuitBreakingException
import org.opensearch.core.common.io.stream.Writeable
import org.opensearch.core.index.shard.ShardId
import org.opensearch.node.NodeClosedException
import org.opensearch.transport.*
import org.opensearch.transport.ActionNotFoundTransportException
import org.opensearch.transport.ConnectTransportException
import org.opensearch.transport.RemoteTransportException
import org.opensearch.transport.TransportException
import org.opensearch.transport.TransportRequestOptions
import org.opensearch.transport.TransportService
import java.time.Instant
import kotlin.coroutines.resume
import kotlin.coroutines.resumeWithException
Expand Down

0 comments on commit 70f165f

Please sign in to comment.