-
Notifications
You must be signed in to change notification settings - Fork 103
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
initial commit for remote monitor support #1547
Changes from 1 commit
197b7f8
0181b85
70f165f
8bd00b4
a840958
315d8ac
629a0c3
f48253c
77a83ff
4b88443
ae13a15
5564e3a
58a6f29
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,13 +41,15 @@ import org.opensearch.common.xcontent.XContentType | |
import org.opensearch.commons.alerting.model.DocLevelMonitorInput | ||
import org.opensearch.commons.alerting.model.Monitor | ||
import org.opensearch.commons.alerting.model.ScheduledJob | ||
import org.opensearch.commons.alerting.util.isMonitorOfStandardType | ||
import org.opensearch.core.rest.RestStatus | ||
import org.opensearch.core.xcontent.NamedXContentRegistry | ||
import org.opensearch.core.xcontent.ToXContent | ||
import org.opensearch.core.xcontent.XContentParser | ||
import org.opensearch.core.xcontent.XContentParserUtils | ||
import org.opensearch.index.seqno.SequenceNumbers | ||
import org.opensearch.transport.RemoteTransportException | ||
import java.util.* | ||
|
||
private val log = LogManager.getLogger(MonitorMetadataService::class.java) | ||
|
||
|
@@ -185,10 +187,16 @@ object MonitorMetadataService : | |
|
||
suspend fun recreateRunContext(metadata: MonitorMetadata, monitor: Monitor): MonitorMetadata { | ||
try { | ||
val monitorIndex = if (monitor.monitorType == Monitor.MonitorType.DOC_LEVEL_MONITOR) | ||
val monitorIndex = if ( | ||
monitor.isMonitorOfStandardType() && | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why not just check string value is doc level monitor? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. just want to use a single string constant, so just reusing the enum value. |
||
Monitor.MonitorType.valueOf(monitor.monitorType.uppercase(Locale.ROOT)) == Monitor.MonitorType.DOC_LEVEL_MONITOR | ||
) | ||
(monitor.inputs[0] as DocLevelMonitorInput).indices[0] | ||
else null | ||
val runContext = if (monitor.monitorType == Monitor.MonitorType.DOC_LEVEL_MONITOR) | ||
val runContext = if ( | ||
monitor.isMonitorOfStandardType() && | ||
Monitor.MonitorType.valueOf(monitor.monitorType.uppercase(Locale.ROOT)) == Monitor.MonitorType.DOC_LEVEL_MONITOR | ||
) | ||
createFullRunContext(monitorIndex, metadata.lastRunContext as MutableMap<String, MutableMap<String, Any>>) | ||
else null | ||
return if (runContext != null) { | ||
|
@@ -208,10 +216,16 @@ object MonitorMetadataService : | |
createWithRunContext: Boolean, | ||
workflowMetadataId: String? = null, | ||
): MonitorMetadata { | ||
val monitorIndex = if (monitor.monitorType == Monitor.MonitorType.DOC_LEVEL_MONITOR) | ||
val monitorIndex = if ( | ||
monitor.isMonitorOfStandardType() && | ||
Monitor.MonitorType.valueOf(monitor.monitorType.uppercase(Locale.ROOT)) == Monitor.MonitorType.DOC_LEVEL_MONITOR | ||
) | ||
(monitor.inputs[0] as DocLevelMonitorInput).indices[0] | ||
else null | ||
val runContext = if (monitor.monitorType == Monitor.MonitorType.DOC_LEVEL_MONITOR && createWithRunContext) | ||
val runContext = if ( | ||
monitor.isMonitorOfStandardType() && | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. extract into method - isDocLevelMonitor() There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
Monitor.MonitorType.valueOf(monitor.monitorType.uppercase(Locale.ROOT)) == Monitor.MonitorType.DOC_LEVEL_MONITOR && createWithRunContext | ||
) | ||
createFullRunContext(monitorIndex) | ||
else emptyMap() | ||
return MonitorMetadata( | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this the same dependency used by jobscheduler or notification for shadow plugin?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes.