Skip to content
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

[Backport 2.x] Monitor model changed to add an optional fanoutEnabled field #762

Merged
merged 1 commit into from
Dec 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,16 @@ import java.io.IOException
data class DocLevelMonitorInput(
val description: String = NO_DESCRIPTION,
val indices: List<String>,
val queries: List<DocLevelQuery>
val queries: List<DocLevelQuery>,
val fanoutEnabled: Boolean? = true
) : Input {

@Throws(IOException::class)
constructor(sin: StreamInput) : this(
sin.readString(), // description
sin.readStringList(), // indices
sin.readList(::DocLevelQuery) // docLevelQueries
sin.readList(::DocLevelQuery), // docLevelQueries
sin.readOptionalBoolean() // fanoutEnabled
)

override fun asTemplateArg(): Map<String, Any> {
Expand All @@ -41,6 +43,7 @@ data class DocLevelMonitorInput(
out.writeString(description)
out.writeStringCollection(indices)
out.writeCollection(queries)
out.writeOptionalBoolean(fanoutEnabled)
}

override fun toXContent(builder: XContentBuilder, params: ToXContent.Params): XContentBuilder {
Expand All @@ -49,6 +52,7 @@ data class DocLevelMonitorInput(
.field(DESCRIPTION_FIELD, description)
.field(INDICES_FIELD, indices.toTypedArray())
.field(QUERIES_FIELD, queries.toTypedArray())
.field(FANOUT_FIELD, fanoutEnabled)
.endObject()
.endObject()
return builder
Expand All @@ -59,7 +63,7 @@ data class DocLevelMonitorInput(
const val INDICES_FIELD = "indices"
const val DOC_LEVEL_INPUT_FIELD = "doc_level_input"
const val QUERIES_FIELD = "queries"

const val FANOUT_FIELD = "fan_out_enabled"
const val NO_DESCRIPTION = ""

val XCONTENT_REGISTRY = NamedXContentRegistry.Entry(
Expand All @@ -74,6 +78,7 @@ data class DocLevelMonitorInput(
var description: String = NO_DESCRIPTION
val indices: MutableList<String> = mutableListOf()
val docLevelQueries: MutableList<DocLevelQuery> = mutableListOf()
var fanoutEnabled: Boolean? = true

XContentParserUtils.ensureExpectedToken(XContentParser.Token.START_OBJECT, xcp.currentToken(), xcp)
while (xcp.nextToken() != XContentParser.Token.END_OBJECT) {
Expand Down Expand Up @@ -102,10 +107,15 @@ data class DocLevelMonitorInput(
docLevelQueries.add(DocLevelQuery.parse(xcp))
}
}
FANOUT_FIELD -> fanoutEnabled = if (xcp.currentToken() == XContentParser.Token.VALUE_NULL) {
fanoutEnabled
} else {
xcp.booleanValue()
}
}
}

return DocLevelMonitorInput(description = description, indices = indices, queries = docLevelQueries)
return DocLevelMonitorInput(description = description, indices = indices, queries = docLevelQueries, fanoutEnabled = fanoutEnabled)
}

@JvmStatic
Expand Down
Loading