-
Notifications
You must be signed in to change notification settings - Fork 112
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Feature] Support Transform as an ISM action (#760)
* Initial impl Signed-off-by: Tanqiu Liu <[email protected]> * fix style Signed-off-by: Tanqiu Liu <[email protected]> * end to end functional Signed-off-by: Tanqiu Liu <[email protected]> * ISM transform unit tests & integ tests Signed-off-by: Tanqiu Liu <[email protected]> * Fix after core #8157 (#857) Signed-off-by: bowenlan-amzn <[email protected]> * Upgrade the backport workflow (#862) Signed-off-by: Ashish Agrawal <[email protected]> Signed-off-by: Tanqiu Liu <[email protected]> * Added 2.9 release notes. (#851) * Added 2.9 release notes. Signed-off-by: AWSHurneyt <[email protected]> * Added 2.9 release notes. Signed-off-by: AWSHurneyt <[email protected]> * Added 2.9 release notes. Signed-off-by: AWSHurneyt <[email protected]> --------- Signed-off-by: AWSHurneyt <[email protected]> Signed-off-by: Tanqiu Liu <[email protected]> * Handle NPE in isRollupIndex (#855) * Handle NPE in isRollupIndex `metadata.index()` can return `null`, so handle that case by returning `false`. Signed-off-by: Bryce Lampe <[email protected]> * unit test Signed-off-by: Bryce Lampe <[email protected]> --------- Signed-off-by: Bryce Lampe <[email protected]> Co-authored-by: bowenlan-amzn <[email protected]> Signed-off-by: Tanqiu Liu <[email protected]> * Fix core XcontentType refactor (#873) Signed-off-by: Hailong Cui <[email protected]> Signed-off-by: Tanqiu Liu <[email protected]> * fix for max & min aggregations when no metric property exist (#870) Signed-off-by: Subhobrata Dey <[email protected]> Signed-off-by: Tanqiu Liu <[email protected]> * core refactor change (#884) Signed-off-by: Hailong Cui <[email protected]> Signed-off-by: Tanqiu Liu <[email protected]> * update backport branch name (#885) Signed-off-by: Hailong Cui <[email protected]> Signed-off-by: Tanqiu Liu <[email protected]> * core refactor change (#887) Signed-off-by: Hailong Cui <[email protected]> Signed-off-by: Tanqiu Liu <[email protected]> * Fix breaking change by core refactor (#888) Signed-off-by: Hailong Cui <[email protected]> Signed-off-by: Tanqiu Liu <[email protected]> * fix core breaking (#906) Signed-off-by: bowenlan-amzn <[email protected]> Signed-off-by: Tanqiu Liu <[email protected]> * Support copy alias in rollover (#907) * Support copy alias in rollover Signed-off-by: bowenlan-amzn <[email protected]> * 2.10 Signed-off-by: bowenlan-amzn <[email protected]> --------- Signed-off-by: bowenlan-amzn <[email protected]> Signed-off-by: Tanqiu Liu <[email protected]> * Set preference to _primary when searching control-center index (#911) * Set preference to _primary when searching control-center index Signed-off-by: gaobinlong <[email protected]> * Use _primary_first instead Signed-off-by: gaobinlong <[email protected]> --------- Signed-off-by: gaobinlong <[email protected]> Signed-off-by: Tanqiu Liu <[email protected]> * Add primary first preference to all search requests (#912) Signed-off-by: Tanqiu Liu <[email protected]> * fix intelliJ IDEA gradle sync error (#916) Signed-off-by: Hailong Cui <[email protected]> Signed-off-by: Tanqiu Liu <[email protected]> * make control center index as system index (#919) Signed-off-by: Hailong Cui <[email protected]> Signed-off-by: Tanqiu Liu <[email protected]> * Updates demo certs used in integ tests (#921) Signed-off-by: Darshit Chanpura <[email protected]> Signed-off-by: Tanqiu Liu <[email protected]> * Added 2.10 release notes (#925) Signed-off-by: Ashish Agrawal <[email protected]> Signed-off-by: Tanqiu Liu <[email protected]> * Bump bwc version (#930) Signed-off-by: bowenlan-amzn <[email protected]> Signed-off-by: Tanqiu Liu <[email protected]> * fix integ tests; upgrade mappings versions Signed-off-by: Tanqiu Liu <[email protected]> * Fix DCO Signed-off-by: Tanqiu Liu <[email protected]> * Addressed pr comments; Add integ test case for re-execute the same transform action Signed-off-by: Tanqiu Liu <[email protected]> * Addressed detekt error Signed-off-by: Tanqiu Liu <[email protected]> * Added ISMTransform writeable test Signed-off-by: Tanqiu Liu <[email protected]> * Addressed comments; Moved updateTransformStartTime to IndexManagementRestTestCase Signed-off-by: Tanqiu Liu <[email protected]> --------- Signed-off-by: Tanqiu Liu <[email protected]> Signed-off-by: bowenlan-amzn <[email protected]> Signed-off-by: Ashish Agrawal <[email protected]> Signed-off-by: AWSHurneyt <[email protected]> Signed-off-by: Bryce Lampe <[email protected]> Signed-off-by: Hailong Cui <[email protected]> Signed-off-by: Subhobrata Dey <[email protected]> Signed-off-by: gaobinlong <[email protected]> Signed-off-by: Darshit Chanpura <[email protected]> Co-authored-by: bowenlan-amzn <[email protected]> Co-authored-by: Ashish Agrawal <[email protected]> Co-authored-by: AWSHurneyt <[email protected]> Co-authored-by: Bryce Lampe <[email protected]> Co-authored-by: Hailong Cui <[email protected]> Co-authored-by: Subhobrata Dey <[email protected]> Co-authored-by: gaobinlong <[email protected]> Co-authored-by: Darshit Chanpura <[email protected]>
- Loading branch information
1 parent
f543d93
commit 3ddd75a
Showing
28 changed files
with
1,626 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
...rg.opensearch.indexmanagement.spi/indexstatemanagement/model/TransformActionProperties.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.opensearch.indexmanagement.spi.indexstatemanagement.model | ||
|
||
import org.opensearch.core.common.io.stream.StreamInput | ||
import org.opensearch.core.common.io.stream.StreamOutput | ||
import org.opensearch.core.common.io.stream.Writeable | ||
import org.opensearch.core.xcontent.XContentParserUtils.ensureExpectedToken | ||
import org.opensearch.core.xcontent.ToXContent | ||
import org.opensearch.core.xcontent.ToXContentFragment | ||
import org.opensearch.core.xcontent.XContentBuilder | ||
import org.opensearch.core.xcontent.XContentParser | ||
|
||
data class TransformActionProperties( | ||
val transformId: String? | ||
) : Writeable, ToXContentFragment { | ||
|
||
override fun writeTo(out: StreamOutput) { | ||
out.writeOptionalString(transformId) | ||
} | ||
|
||
override fun toXContent(builder: XContentBuilder, params: ToXContent.Params?): XContentBuilder { | ||
if (transformId != null) builder.field(Properties.TRANSFORM_ID.key, transformId) | ||
return builder | ||
} | ||
|
||
companion object { | ||
const val TRANSFORM_ACTION_PROPERTIES = "transform_action_properties" | ||
|
||
fun fromStreamInput(sin: StreamInput): TransformActionProperties { | ||
val transformId: String? = sin.readOptionalString() | ||
return TransformActionProperties(transformId) | ||
} | ||
|
||
fun parse(xcp: XContentParser): TransformActionProperties { | ||
var transformId: String? = null | ||
|
||
ensureExpectedToken(XContentParser.Token.START_OBJECT, xcp.currentToken(), xcp) | ||
while (xcp.nextToken() != XContentParser.Token.END_OBJECT) { | ||
val fieldName = xcp.currentName() | ||
xcp.nextToken() | ||
|
||
when (fieldName) { | ||
Properties.TRANSFORM_ID.key -> transformId = xcp.text() | ||
} | ||
} | ||
|
||
return TransformActionProperties(transformId) | ||
} | ||
} | ||
|
||
enum class Properties(val key: String) { | ||
TRANSFORM_ID("transform_id") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
...main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/action/TransformAction.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.opensearch.indexmanagement.indexstatemanagement.action | ||
|
||
import org.opensearch.core.common.io.stream.StreamOutput | ||
import org.opensearch.core.xcontent.ToXContent | ||
import org.opensearch.core.xcontent.XContentBuilder | ||
import org.opensearch.indexmanagement.indexstatemanagement.step.transform.AttemptCreateTransformJobStep | ||
import org.opensearch.indexmanagement.indexstatemanagement.step.transform.WaitForTransformCompletionStep | ||
import org.opensearch.indexmanagement.spi.indexstatemanagement.Action | ||
import org.opensearch.indexmanagement.spi.indexstatemanagement.Step | ||
import org.opensearch.indexmanagement.spi.indexstatemanagement.model.StepContext | ||
import org.opensearch.indexmanagement.transform.model.ISMTransform | ||
|
||
class TransformAction( | ||
val ismTransform: ISMTransform, | ||
index: Int | ||
) : Action(name, index) { | ||
|
||
companion object { | ||
const val name = "transform" | ||
const val ISM_TRANSFORM_FIELD = "ism_transform" | ||
} | ||
|
||
private val attemptCreateTransformJobStep = AttemptCreateTransformJobStep(this) | ||
private val waitForTransformCompletionStep = WaitForTransformCompletionStep() | ||
private val steps = listOf(attemptCreateTransformJobStep, waitForTransformCompletionStep) | ||
|
||
@Suppress("ReturnCount") | ||
override fun getStepToExecute(context: StepContext): Step { | ||
// if stepMetaData is null, return first step | ||
val stepMetaData = context.metadata.stepMetaData ?: return attemptCreateTransformJobStep | ||
|
||
// if the current step has completed, return the next step | ||
if (stepMetaData.stepStatus == Step.StepStatus.COMPLETED) { | ||
return when (stepMetaData.name) { | ||
AttemptCreateTransformJobStep.name -> waitForTransformCompletionStep | ||
else -> attemptCreateTransformJobStep | ||
} | ||
} | ||
|
||
return when (stepMetaData.name) { | ||
AttemptCreateTransformJobStep.name -> attemptCreateTransformJobStep | ||
else -> waitForTransformCompletionStep | ||
} | ||
} | ||
|
||
override fun getSteps(): List<Step> = steps | ||
|
||
override fun populateAction(builder: XContentBuilder, params: ToXContent.Params) { | ||
builder.startObject(type) | ||
builder.field(ISM_TRANSFORM_FIELD, ismTransform) | ||
builder.endObject() | ||
} | ||
|
||
override fun populateAction(out: StreamOutput) { | ||
ismTransform.writeTo(out) | ||
out.writeInt(actionIndex) | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
...otlin/org/opensearch/indexmanagement/indexstatemanagement/action/TransformActionParser.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.opensearch.indexmanagement.indexstatemanagement.action | ||
|
||
import org.opensearch.core.common.io.stream.StreamInput | ||
import org.opensearch.core.xcontent.XContentParser | ||
import org.opensearch.core.xcontent.XContentParserUtils | ||
import org.opensearch.indexmanagement.spi.indexstatemanagement.Action | ||
import org.opensearch.indexmanagement.spi.indexstatemanagement.ActionParser | ||
import org.opensearch.indexmanagement.transform.model.ISMTransform | ||
|
||
class TransformActionParser : ActionParser() { | ||
override fun fromStreamInput(sin: StreamInput): Action { | ||
val ismTransform = ISMTransform(sin) | ||
val index = sin.readInt() | ||
return TransformAction(ismTransform, index) | ||
} | ||
|
||
override fun fromXContent(xcp: XContentParser, index: Int): Action { | ||
var ismTransform: ISMTransform? = null | ||
|
||
XContentParserUtils.ensureExpectedToken(XContentParser.Token.START_OBJECT, xcp.currentToken(), xcp) | ||
while (xcp.nextToken() != XContentParser.Token.END_OBJECT) { | ||
val fieldName = xcp.currentName() | ||
xcp.nextToken() | ||
|
||
when (fieldName) { | ||
TransformAction.ISM_TRANSFORM_FIELD -> ismTransform = ISMTransform.parse(xcp) | ||
else -> throw IllegalArgumentException("Invalid field: [$fieldName] found in TransformAction.") | ||
} | ||
} | ||
|
||
return TransformAction(ismTransform = requireNotNull(ismTransform) { "TransformAction transform is null." }, index) | ||
} | ||
|
||
override fun getActionType(): String { | ||
return TransformAction.name | ||
} | ||
} |
Oops, something went wrong.