Skip to content
Open
Show file tree
Hide file tree
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 @@ -193,7 +193,7 @@ class DocumentLevelMonitorRunner : MonitorRunner() {
indexLastRunContext.toMutableMap(),
concreteIndexName,
shardCount
) as MutableMap<String, Any>
)
if (IndexUtils.isAlias(indexName, monitorCtx.clusterService!!.state()) ||
IndexUtils.isDataStream(indexName, monitorCtx.clusterService!!.state())
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ fun initializeNewLastRunContext(
lastRunContext: Map<String, Any>,
index: String,
shardCount: Int,
): Map<String, Any> {
): MutableMap<String, Any> {
val updatedLastRunContext = lastRunContext.toMutableMap()

// Only initialize shards that don't already have a sequence number
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,9 +206,12 @@ object MonitorMetadataService :
else if (monitor.monitorType.endsWith(Monitor.MonitorType.DOC_LEVEL_MONITOR.value))
(monitor.inputs[0] as RemoteDocLevelMonitorInput).docLevelMonitorInput.indices[0]
else null
val runContext = if (monitor.monitorType.endsWith(Monitor.MonitorType.DOC_LEVEL_MONITOR.value))
createFullRunContext(monitorIndex, metadata.lastRunContext as MutableMap<String, MutableMap<String, Any>>)
else null
val runContext = if (monitor.monitorType.endsWith(Monitor.MonitorType.DOC_LEVEL_MONITOR.value)) {
@Suppress("UNCHECKED_CAST")
val lastRunCtx = if (metadata.lastRunContext.isEmpty()) null
else (metadata.lastRunContext as MutableMap<String, MutableMap<String, Any>>)
createFullRunContext(monitorIndex, lastRunCtx)
} else null
return if (runContext != null) {
metadata.copy(
lastRunContext = runContext
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ class RemoteDocumentLevelMonitorRunner : MonitorRunner() {
indexLastRunContext.toMutableMap(),
concreteIndexName,
shardCount
) as MutableMap<String, Any>
)
if (IndexUtils.isAlias(indexName, monitorCtx.clusterService!!.state()) ||
IndexUtils.isDataStream(indexName, monitorCtx.clusterService!!.state())
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,18 +228,18 @@ class DocLevelMonitorQueries(private val client: Client, private val clusterServ
// Compute full path relative to root
val fullPath = if (currentPath.isEmpty()) it.key
else "$currentPath.${it.key}"
val nodeProps = it.value as MutableMap<String, Any>
val nodeProps = (it.value as Map<String, Any>).toMutableMap()
// If it has type property and type is not "nested" then this is a leaf
if (nodeProps.containsKey(TYPE) && nodeProps[TYPE] != NESTED) {
// At this point we know full path of node, so we add it to output array
flattenPaths.put(fullPath, nodeProps)
// Calls processLeafFn and gets old node name, new node name and new properties of node.
// This is all information we need to update this node
val (oldName, newName, props) = processLeafFn(it.key, fullPath, it.value as MutableMap<String, Any>)
val (oldName, newName, props) = processLeafFn(it.key, fullPath, (it.value as Map<String, Any>).toMutableMap())
newNodes.add(Triple(oldName, newName, props))
} else if (nodeProps.containsKey(PROPERTIES) && nodeProps[PROPERTIES] != null) {
// Internal(non-leaf) node - visit children
traverseMappingsAndUpdate(nodeProps[PROPERTIES] as MutableMap<String, Any>, fullPath, processLeafFn, flattenPaths)
traverseMappingsAndUpdate((nodeProps[PROPERTIES] as Map<String, Any>).toMutableMap(), fullPath, processLeafFn, flattenPaths)
}
}
// Here we can update all processed leaves in tree
Expand Down