Skip to content

Commit

Permalink
add partial trigger result and partial input result in fanout response
Browse files Browse the repository at this point in the history
Signed-off-by: Surya Sashank Nistala <[email protected]>
  • Loading branch information
eirsep committed Feb 9, 2024
1 parent 27322c6 commit 093ab6f
Showing 1 changed file with 28 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -1,53 +1,70 @@
package org.opensearch.alerting.action

import org.opensearch.alerting.model.DocumentLevelTriggerRunResult
import org.opensearch.alerting.model.InputRunResults
import org.opensearch.alerting.model.MonitorRunResult
import org.opensearch.core.action.ActionResponse
import org.opensearch.core.common.io.stream.StreamInput
import org.opensearch.core.common.io.stream.StreamOutput
import org.opensearch.core.index.shard.ShardId
import org.opensearch.core.xcontent.ToXContent
import org.opensearch.core.xcontent.ToXContentObject
import org.opensearch.core.xcontent.XContentBuilder
import java.io.IOException

class DocLevelMonitorFanOutResponse : ActionResponse, ToXContentObject {

val nodeId: String
val executionId: String
val monitorId: String
val shardIdFailureMap: Map<ShardId, Exception>
val shardIdFailureMap: Map<String, Exception>
val findingIds: List<String>

// for shards not delegated to nodes sequence number would be -3 (new number shard was not queried),
val lastRunContexts: Map<String, Any>
val lastRunContexts: Map<String, Any> // partial
val inputResults: InputRunResults // partial
val triggerResults: Map<String, DocumentLevelTriggerRunResult> // partial

@Throws(IOException::class)
constructor(sin: StreamInput) : this(
sin.readString(),
sin.readString(),
sin.readString(),
sin.readMap() as Map<ShardId, Exception>,
sin.readStringList(),
sin.readMap()!! as Map<String, Any>,
nodeId = sin.readString(),
executionId = sin.readString(),
monitorId = sin.readString(),
shardIdFailureMap = sin.readMap() as Map<String, Exception>,
findingIds = sin.readStringList(),
lastRunContexts = sin.readMap()!! as Map<String, Any>,
inputResults = InputRunResults.readFrom(sin),
triggerResults = MonitorRunResult.suppressWarning(sin.readMap()) as Map<String, DocumentLevelTriggerRunResult> // triggerResults
)

constructor(
nodeId: String,
executionId: String,
monitorId: String,
shardIdFailureMap: Map<ShardId, Exception>,
shardIdFailureMap: Map<String, Exception>,
findingIds: List<String>,
lastRunContexts: Map<String, Any>,
inputResults: InputRunResults = InputRunResults(), // partial,
triggerResults: Map<String, DocumentLevelTriggerRunResult> = mapOf(),
) : super() {
this.nodeId = nodeId
this.executionId = executionId
this.monitorId = monitorId
this.shardIdFailureMap = shardIdFailureMap
this.findingIds = findingIds
this.lastRunContexts = lastRunContexts
this.inputResults = inputResults
this.triggerResults = triggerResults
}

@Throws(IOException::class)
override fun writeTo(out: StreamOutput) {
out.writeString(nodeId)
out.writeString(executionId)
out.writeString(monitorId)
out.writeMap(shardIdFailureMap)
out.writeStringCollection(findingIds)
out.writeMap(lastRunContexts)
inputResults.writeTo(out)
out.writeMap(triggerResults)
}

@Throws(IOException::class)
Expand Down

0 comments on commit 093ab6f

Please sign in to comment.