-
Notifications
You must be signed in to change notification settings - Fork 113
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 <liutanqiu@gmail.com> * fix style Signed-off-by: Tanqiu Liu <liutanqiu@gmail.com> * end to end functional Signed-off-by: Tanqiu Liu <liutanqiu@gmail.com> * ISM transform unit tests & integ tests Signed-off-by: Tanqiu Liu <liutanqiu@gmail.com> * Fix after core #8157 (#857) Signed-off-by: bowenlan-amzn <bowenlan23@gmail.com> * Upgrade the backport workflow (#862) Signed-off-by: Ashish Agrawal <ashisagr@amazon.com> Signed-off-by: Tanqiu Liu <liutanqiu@gmail.com> * Added 2.9 release notes. (#851) * Added 2.9 release notes. Signed-off-by: AWSHurneyt <hurneyt@amazon.com> * Added 2.9 release notes. Signed-off-by: AWSHurneyt <hurneyt@amazon.com> * Added 2.9 release notes. Signed-off-by: AWSHurneyt <hurneyt@amazon.com> --------- Signed-off-by: AWSHurneyt <hurneyt@amazon.com> Signed-off-by: Tanqiu Liu <liutanqiu@gmail.com> * 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 <brycelampe@gmail.com> * unit test Signed-off-by: Bryce Lampe <brycelampe@gmail.com> --------- Signed-off-by: Bryce Lampe <brycelampe@gmail.com> Co-authored-by: bowenlan-amzn <bowenlan23@gmail.com> Signed-off-by: Tanqiu Liu <liutanqiu@gmail.com> * Fix core XcontentType refactor (#873) Signed-off-by: Hailong Cui <ihailong@amazon.com> Signed-off-by: Tanqiu Liu <liutanqiu@gmail.com> * fix for max & min aggregations when no metric property exist (#870) Signed-off-by: Subhobrata Dey <sbcd90@gmail.com> Signed-off-by: Tanqiu Liu <liutanqiu@gmail.com> * core refactor change (#884) Signed-off-by: Hailong Cui <ihailong@amazon.com> Signed-off-by: Tanqiu Liu <liutanqiu@gmail.com> * update backport branch name (#885) Signed-off-by: Hailong Cui <ihailong@amazon.com> Signed-off-by: Tanqiu Liu <liutanqiu@gmail.com> * core refactor change (#887) Signed-off-by: Hailong Cui <ihailong@amazon.com> Signed-off-by: Tanqiu Liu <liutanqiu@gmail.com> * Fix breaking change by core refactor (#888) Signed-off-by: Hailong Cui <ihailong@amazon.com> Signed-off-by: Tanqiu Liu <liutanqiu@gmail.com> * fix core breaking (#906) Signed-off-by: bowenlan-amzn <bowenlan23@gmail.com> Signed-off-by: Tanqiu Liu <liutanqiu@gmail.com> * Support copy alias in rollover (#907) * Support copy alias in rollover Signed-off-by: bowenlan-amzn <bowenlan23@gmail.com> * 2.10 Signed-off-by: bowenlan-amzn <bowenlan23@gmail.com> --------- Signed-off-by: bowenlan-amzn <bowenlan23@gmail.com> Signed-off-by: Tanqiu Liu <liutanqiu@gmail.com> * Set preference to _primary when searching control-center index (#911) * Set preference to _primary when searching control-center index Signed-off-by: gaobinlong <gbinlong@amazon.com> * Use _primary_first instead Signed-off-by: gaobinlong <gbinlong@amazon.com> --------- Signed-off-by: gaobinlong <gbinlong@amazon.com> Signed-off-by: Tanqiu Liu <liutanqiu@gmail.com> * Add primary first preference to all search requests (#912) Signed-off-by: Tanqiu Liu <liutanqiu@gmail.com> * fix intelliJ IDEA gradle sync error (#916) Signed-off-by: Hailong Cui <ihailong@amazon.com> Signed-off-by: Tanqiu Liu <liutanqiu@gmail.com> * make control center index as system index (#919) Signed-off-by: Hailong Cui <ihailong@amazon.com> Signed-off-by: Tanqiu Liu <liutanqiu@gmail.com> * Updates demo certs used in integ tests (#921) Signed-off-by: Darshit Chanpura <dchanp@amazon.com> Signed-off-by: Tanqiu Liu <liutanqiu@gmail.com> * Added 2.10 release notes (#925) Signed-off-by: Ashish Agrawal <ashisagr@amazon.com> Signed-off-by: Tanqiu Liu <liutanqiu@gmail.com> * Bump bwc version (#930) Signed-off-by: bowenlan-amzn <bowenlan23@gmail.com> Signed-off-by: Tanqiu Liu <liutanqiu@gmail.com> * fix integ tests; upgrade mappings versions Signed-off-by: Tanqiu Liu <liutanqiu@gmail.com> * Fix DCO Signed-off-by: Tanqiu Liu <liutanqiu@gmail.com> * Addressed pr comments; Add integ test case for re-execute the same transform action Signed-off-by: Tanqiu Liu <liutanqiu@gmail.com> * Addressed detekt error Signed-off-by: Tanqiu Liu <liutanqiu@gmail.com> * Added ISMTransform writeable test Signed-off-by: Tanqiu Liu <liutanqiu@gmail.com> * Addressed comments; Moved updateTransformStartTime to IndexManagementRestTestCase Signed-off-by: Tanqiu Liu <liutanqiu@gmail.com> --------- Signed-off-by: Tanqiu Liu <liutanqiu@gmail.com> Signed-off-by: bowenlan-amzn <bowenlan23@gmail.com> Signed-off-by: Ashish Agrawal <ashisagr@amazon.com> Signed-off-by: AWSHurneyt <hurneyt@amazon.com> Signed-off-by: Bryce Lampe <brycelampe@gmail.com> Signed-off-by: Hailong Cui <ihailong@amazon.com> Signed-off-by: Subhobrata Dey <sbcd90@gmail.com> Signed-off-by: gaobinlong <gbinlong@amazon.com> Signed-off-by: Darshit Chanpura <dchanp@amazon.com> Co-authored-by: bowenlan-amzn <bowenlan23@gmail.com> Co-authored-by: Ashish Agrawal <ashisagr@amazon.com> Co-authored-by: AWSHurneyt <hurneyt@amazon.com> Co-authored-by: Bryce Lampe <brycelampe@gmail.com> Co-authored-by: Hailong Cui <ihailong@amazon.com> Co-authored-by: Subhobrata Dey <sbcd90@gmail.com> Co-authored-by: gaobinlong <gbl_long@163.com> Co-authored-by: Darshit Chanpura <35282393+DarshitChanpura@users.noreply.github.com>
- 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.