@@ -7,17 +7,25 @@ package org.opensearch.commons.alerting.action
7
7
8
8
import org.opensearch.action.ActionRequest
9
9
import org.opensearch.action.ActionRequestValidationException
10
+ import org.opensearch.commons.alerting.model.DataSources
10
11
import org.opensearch.commons.alerting.model.IndexExecutionContext
12
+ import org.opensearch.commons.alerting.model.IntervalSchedule
11
13
import org.opensearch.commons.alerting.model.Monitor
14
+ import org.opensearch.commons.alerting.model.Monitor.Companion.NO_VERSION
12
15
import org.opensearch.commons.alerting.model.MonitorMetadata
13
16
import org.opensearch.commons.alerting.model.WorkflowRunContext
17
+ import org.opensearch.commons.alerting.util.IndexUtils.Companion.NO_SCHEMA_VERSION
14
18
import org.opensearch.core.common.io.stream.StreamInput
15
19
import org.opensearch.core.common.io.stream.StreamOutput
16
20
import org.opensearch.core.index.shard.ShardId
17
21
import org.opensearch.core.xcontent.ToXContent
18
22
import org.opensearch.core.xcontent.ToXContentObject
19
23
import org.opensearch.core.xcontent.XContentBuilder
24
+ import org.opensearch.index.seqno.SequenceNumbers
20
25
import java.io.IOException
26
+ import java.time.Instant
27
+ import java.time.temporal.ChronoUnit
28
+ import java.util.UUID
21
29
22
30
class DocLevelMonitorFanOutRequest : ActionRequest , ToXContentObject {
23
31
val monitor: Monitor
@@ -37,7 +45,7 @@ class DocLevelMonitorFanOutRequest : ActionRequest, ToXContentObject {
37
45
indexExecutionContext: IndexExecutionContext ? ,
38
46
shardIds: List <ShardId >,
39
47
concreteIndicesSeenSoFar: List <String >,
40
- workflowRunContext: WorkflowRunContext ?
48
+ workflowRunContext: WorkflowRunContext ? ,
41
49
) : super () {
42
50
this .monitor = monitor
43
51
this .dryRun = dryRun
@@ -52,16 +60,75 @@ class DocLevelMonitorFanOutRequest : ActionRequest, ToXContentObject {
52
60
53
61
@Throws(IOException ::class )
54
62
constructor (sin: StreamInput ) : this (
55
- monitor = Monitor .readFrom(sin)!! ,
56
- dryRun = sin.readBoolean(),
57
- monitorMetadata = MonitorMetadata .readFrom(sin),
58
- executionId = sin.readString(),
59
- shardIds = sin.readList(::ShardId ),
60
- concreteIndicesSeenSoFar = sin.readStringList(),
61
- workflowRunContext = if (sin.readBoolean()) {
62
- WorkflowRunContext (sin)
63
- } else { null },
64
- indexExecutionContext = IndexExecutionContext (sin)
63
+ monitor = try {
64
+ Monitor .readFrom(sin)!!
65
+ } catch (e: Exception ) {
66
+ Monitor (
67
+ " failed_serde" ,
68
+ NO_VERSION ,
69
+ " failed_serde" ,
70
+ true ,
71
+ IntervalSchedule (1 , ChronoUnit .MINUTES ),
72
+ Instant .now(),
73
+ Instant .now(),
74
+ " " ,
75
+ null ,
76
+ NO_SCHEMA_VERSION ,
77
+ emptyList(),
78
+ emptyList(),
79
+ emptyMap(),
80
+ DataSources (),
81
+ false ,
82
+ false ,
83
+ " failed"
84
+ )
85
+ },
86
+ dryRun = try {
87
+ sin.readBoolean()
88
+ } catch (e: Exception ) {
89
+ false
90
+ },
91
+ monitorMetadata = try {
92
+ MonitorMetadata .readFrom(sin)
93
+ } catch (e: Exception ) {
94
+ MonitorMetadata (
95
+ " failed_serde" , SequenceNumbers .UNASSIGNED_SEQ_NO , SequenceNumbers .UNASSIGNED_PRIMARY_TERM ,
96
+ " failed_serde" , emptyList(), emptyMap(),
97
+ mutableMapOf ()
98
+ )
99
+ },
100
+ executionId = try {
101
+ sin.readString()
102
+ } catch (e: Exception ) {
103
+ " "
104
+ },
105
+ shardIds = try {
106
+ sin.readList(::ShardId )
107
+ } catch (e: Exception ) {
108
+ listOf (ShardId (" failed_serde" , " failed_serde" ,999999 ))// to circumvent an isEmpty() check in constructor
109
+ },
110
+ concreteIndicesSeenSoFar = try {
111
+ sin.readStringList()
112
+ } catch (e: Exception ) {
113
+ emptyList()
114
+ },
115
+ workflowRunContext = try {
116
+ if (sin.readBoolean()) {
117
+ WorkflowRunContext (sin)
118
+ } else {
119
+ null
120
+ }
121
+ } catch (e: Exception ) {
122
+ null
123
+ },
124
+ indexExecutionContext = try {
125
+ IndexExecutionContext (sin)
126
+ } catch (e: Exception ) {
127
+ IndexExecutionContext (
128
+ emptyList(), mutableMapOf (), mutableMapOf (), " failed_serde" , " failed_serde" , emptyList(), emptyList(), emptyList(),
129
+ emptyList(), emptyList()
130
+ )
131
+ }
65
132
)
66
133
67
134
@Throws(IOException ::class )
0 commit comments