├── .codecov.yml ├── .editorconfig ├── .github ├── ISSUE_TEMPLATE │ ├── bug_report.md │ └── feature_request.md ├── PULL_REQUEST_TEMPLATE.md ├── draft-release-notes-config.yml └── workflows │ ├── draft-release-notes-workflow.yml │ ├── multi-node-test-workflow.yml │ ├── release-workflow.yml │ └── test-and-build-workflow.yml ├── .gitignore ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE ├── NOTICE ├── README.md ├── build-tools ├── esplugin-coverage.gradle └── pkgbuild.gradle ├── build.gradle ├── detekt.yml ├── docs ├── rfc.md ├── rollup-rfc.md └── transform-rfc.md ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── release-notes ├── create_release_notes.py ├── opendistro-for-elasticsearch-index-management.release-notes-1.10.0.0.md ├── opendistro-for-elasticsearch-index-management.release-notes-1.10.1.0.md ├── opendistro-for-elasticsearch-index-management.release-notes-1.10.1.1.md ├── opendistro-for-elasticsearch-index-management.release-notes-1.11.0.0.md ├── opendistro-for-elasticsearch-index-management.release-notes-1.12.0.0.md ├── opendistro-for-elasticsearch-index-management.release-notes-1.12.0.1.md ├── opendistro-for-elasticsearch-index-management.release-notes-1.13.0.0.md ├── opendistro-for-elasticsearch-index-management.release-notes-1.13.1.0.md ├── opendistro-for-elasticsearch-index-management.release-notes-1.13.2.0.md ├── opendistro-for-elasticsearch-index-management.release-notes-1.3.0.0.md ├── opendistro-for-elasticsearch-index-management.release-notes-1.4.0.0.md ├── opendistro-for-elasticsearch-index-management.release-notes-1.6.0.0.md ├── opendistro-for-elasticsearch-index-management.release-notes-1.7.0.0.md ├── opendistro-for-elasticsearch-index-management.release-notes-1.8.0.0.md ├── opendistro-for-elasticsearch-index-management.release-notes-1.9.0.0.md └── opendistro-for-elasticsearch-index-management.release-notes-1.9.0.1.md ├── settings.gradle ├── src ├── main │ ├── kotlin │ │ └── com │ │ │ └── amazon │ │ │ └── opendistroforelasticsearch │ │ │ └── indexmanagement │ │ │ ├── IndexManagementIndices.kt │ │ │ ├── IndexManagementPlugin.kt │ │ │ ├── IndexManagementRunner.kt │ │ │ ├── elasticapi │ │ │ └── ElasticExtensions.kt │ │ │ ├── indexstatemanagement │ │ │ ├── ISMTemplateService.kt │ │ │ ├── IndexStateManagementHistory.kt │ │ │ ├── ManagedIndexCoordinator.kt │ │ │ ├── ManagedIndexRunner.kt │ │ │ ├── MetadataService.kt │ │ │ ├── SkipExecution.kt │ │ │ ├── action │ │ │ │ ├── Action.kt │ │ │ │ ├── AllocationAction.kt │ │ │ │ ├── CloseAction.kt │ │ │ │ ├── DeleteAction.kt │ │ │ │ ├── ForceMergeAction.kt │ │ │ │ ├── IndexPriorityAction.kt │ │ │ │ ├── NotificationAction.kt │ │ │ │ ├── OpenAction.kt │ │ │ │ ├── ReadOnlyAction.kt │ │ │ │ ├── ReadWriteAction.kt │ │ │ │ ├── ReplicaCountAction.kt │ │ │ │ ├── RolloverAction.kt │ │ │ │ ├── RollupAction.kt │ │ │ │ ├── SnapshotAction.kt │ │ │ │ └── TransitionsAction.kt │ │ │ ├── elasticapi │ │ │ │ └── ElasticExtensions.kt │ │ │ ├── model │ │ │ │ ├── ChangePolicy.kt │ │ │ │ ├── ErrorNotification.kt │ │ │ │ ├── ISMTemplate.kt │ │ │ │ ├── ManagedIndexConfig.kt │ │ │ │ ├── ManagedIndexMetaData.kt │ │ │ │ ├── Policy.kt │ │ │ │ ├── SearchParams.kt │ │ │ │ ├── State.kt │ │ │ │ ├── StateFilter.kt │ │ │ │ ├── Transition.kt │ │ │ │ ├── action │ │ │ │ │ ├── ActionConfig.kt │ │ │ │ │ ├── ActionRetry.kt │ │ │ │ │ ├── ActionTimeout.kt │ │ │ │ │ ├── AllocationActionConfig.kt │ │ │ │ │ ├── CloseActionConfig.kt │ │ │ │ │ ├── DeleteActionConfig.kt │ │ │ │ │ ├── ForceMergeActionConfig.kt │ │ │ │ │ ├── IndexPriorityActionConfig.kt │ │ │ │ │ ├── NotificationActionConfig.kt │ │ │ │ │ ├── OpenActionConfig.kt │ │ │ │ │ ├── ReadOnlyActionConfig.kt │ │ │ │ │ ├── ReadWriteActionConfig.kt │ │ │ │ │ ├── ReplicaCountActionConfig.kt │ │ │ │ │ ├── RolloverActionConfig.kt │ │ │ │ │ ├── RollupActionConfig.kt │ │ │ │ │ ├── SnapshotActionConfig.kt │ │ │ │ │ └── TransitionsActionConfig.kt │ │ │ │ ├── coordinator │ │ │ │ │ ├── ClusterStateManagedIndexConfig.kt │ │ │ │ │ └── SweptManagedIndexConfig.kt │ │ │ │ ├── destination │ │ │ │ │ ├── Chime.kt │ │ │ │ │ ├── CustomWebhook.kt │ │ │ │ │ ├── Destination.kt │ │ │ │ │ └── Slack.kt │ │ │ │ └── managedindexmetadata │ │ │ │ │ ├── ActionMetaData.kt │ │ │ │ │ ├── ActionProperties.kt │ │ │ │ │ ├── PolicyRetryInfoMetaData.kt │ │ │ │ │ ├── StateMetaData.kt │ │ │ │ │ └── StepMetaData.kt │ │ │ ├── resthandler │ │ │ │ ├── RestAddPolicyAction.kt │ │ │ │ ├── RestChangePolicyAction.kt │ │ │ │ ├── RestDeletePolicyAction.kt │ │ │ │ ├── RestExplainAction.kt │ │ │ │ ├── RestGetPolicyAction.kt │ │ │ │ ├── RestIndexPolicyAction.kt │ │ │ │ ├── RestRemovePolicyAction.kt │ │ │ │ └── RestRetryFailedManagedIndexAction.kt │ │ │ ├── settings │ │ │ │ └── ManagedIndexSettings.kt │ │ │ ├── step │ │ │ │ ├── Step.kt │ │ │ │ ├── allocation │ │ │ │ │ └── AttemptAllocationStep.kt │ │ │ │ ├── close │ │ │ │ │ └── AttemptCloseStep.kt │ │ │ │ ├── delete │ │ │ │ │ └── AttemptDeleteStep.kt │ │ │ │ ├── forcemerge │ │ │ │ │ ├── AttemptCallForceMergeStep.kt │ │ │ │ │ ├── AttemptSetReadOnlyStep.kt │ │ │ │ │ └── WaitForForceMergeStep.kt │ │ │ │ ├── indexpriority │ │ │ │ │ └── AttemptSetIndexPriorityStep.kt │ │ │ │ ├── notification │ │ │ │ │ └── AttemptNotificationStep.kt │ │ │ │ ├── open │ │ │ │ │ └── AttemptOpenStep.kt │ │ │ │ ├── readonly │ │ │ │ │ └── SetReadOnlyStep.kt │ │ │ │ ├── readwrite │ │ │ │ │ └── SetReadWriteStep.kt │ │ │ │ ├── replicacount │ │ │ │ │ └── AttemptSetReplicaCountStep.kt │ │ │ │ ├── rollover │ │ │ │ │ └── AttemptRolloverStep.kt │ │ │ │ ├── rollup │ │ │ │ │ ├── AttemptCreateRollupJobStep.kt │ │ │ │ │ └── WaitForRollupCompletionStep.kt │ │ │ │ ├── snapshot │ │ │ │ │ ├── AttemptSnapshotStep.kt │ │ │ │ │ └── WaitForSnapshotStep.kt │ │ │ │ └── transition │ │ │ │ │ └── AttemptTransitionStep.kt │ │ │ ├── transport │ │ │ │ └── action │ │ │ │ │ ├── ISMStatusResponse.kt │ │ │ │ │ ├── addpolicy │ │ │ │ │ ├── AddPolicyAction.kt │ │ │ │ │ ├── AddPolicyRequest.kt │ │ │ │ │ └── TransportAddPolicyAction.kt │ │ │ │ │ ├── changepolicy │ │ │ │ │ ├── ChangePolicyAction.kt │ │ │ │ │ ├── ChangePolicyRequest.kt │ │ │ │ │ └── TransportChangePolicyAction.kt │ │ │ │ │ ├── deletepolicy │ │ │ │ │ ├── DeletePolicyAction.kt │ │ │ │ │ ├── DeletePolicyRequest.kt │ │ │ │ │ └── TransportDeletePolicyAction.kt │ │ │ │ │ ├── explain │ │ │ │ │ ├── ExplainAction.kt │ │ │ │ │ ├── ExplainAllResponse.kt │ │ │ │ │ ├── ExplainRequest.kt │ │ │ │ │ ├── ExplainResponse.kt │ │ │ │ │ └── TransportExplainAction.kt │ │ │ │ │ ├── getpolicy │ │ │ │ │ ├── GetPoliciesAction.kt │ │ │ │ │ ├── GetPoliciesRequest.kt │ │ │ │ │ ├── GetPoliciesResponse.kt │ │ │ │ │ ├── GetPolicyAction.kt │ │ │ │ │ ├── GetPolicyRequest.kt │ │ │ │ │ ├── GetPolicyResponse.kt │ │ │ │ │ ├── TransportGetPoliciesAction.kt │ │ │ │ │ └── TransportGetPolicyAction.kt │ │ │ │ │ ├── indexpolicy │ │ │ │ │ ├── IndexPolicyAction.kt │ │ │ │ │ ├── IndexPolicyRequest.kt │ │ │ │ │ ├── IndexPolicyResponse.kt │ │ │ │ │ └── TransportIndexPolicyAction.kt │ │ │ │ │ ├── removepolicy │ │ │ │ │ ├── RemovePolicyAction.kt │ │ │ │ │ ├── RemovePolicyRequest.kt │ │ │ │ │ └── TransportRemovePolicyAction.kt │ │ │ │ │ ├── retryfailedmanagedindex │ │ │ │ │ ├── RetryFailedManagedIndexAction.kt │ │ │ │ │ ├── RetryFailedManagedIndexRequest.kt │ │ │ │ │ └── TransportRetryFailedManagedIndexAction.kt │ │ │ │ │ └── updateindexmetadata │ │ │ │ │ ├── TransportUpdateManagedIndexMetaDataAction.kt │ │ │ │ │ ├── UpdateManagedIndexMetaDataAction.kt │ │ │ │ │ └── UpdateManagedIndexMetaDataRequest.kt │ │ │ └── util │ │ │ │ ├── DestinationType.kt │ │ │ │ ├── ManagedIndexUtils.kt │ │ │ │ └── RestHandlerUtils.kt │ │ │ ├── refreshanalyzer │ │ │ ├── RefreshSearchAnalyzerAction.kt │ │ │ ├── RefreshSearchAnalyzerRequest.kt │ │ │ ├── RefreshSearchAnalyzerResponse.kt │ │ │ ├── RefreshSearchAnalyzerShardResponse.kt │ │ │ ├── RestRefreshSearchAnalyzerAction.kt │ │ │ └── TransportRefreshSearchAnalyzerAction.kt │ │ │ ├── rollup │ │ │ ├── RollupIndexer.kt │ │ │ ├── RollupMapperService.kt │ │ │ ├── RollupMetadataService.kt │ │ │ ├── RollupRunner.kt │ │ │ ├── RollupSearchService.kt │ │ │ ├── action │ │ │ │ ├── delete │ │ │ │ │ ├── DeleteRollupAction.kt │ │ │ │ │ ├── DeleteRollupRequest.kt │ │ │ │ │ └── TransportDeleteRollupAction.kt │ │ │ │ ├── explain │ │ │ │ │ ├── ExplainRollupAction.kt │ │ │ │ │ ├── ExplainRollupRequest.kt │ │ │ │ │ ├── ExplainRollupResponse.kt │ │ │ │ │ └── TransportExplainRollupAction.kt │ │ │ │ ├── get │ │ │ │ │ ├── GetRollupAction.kt │ │ │ │ │ ├── GetRollupRequest.kt │ │ │ │ │ ├── GetRollupResponse.kt │ │ │ │ │ ├── GetRollupsAction.kt │ │ │ │ │ ├── GetRollupsRequest.kt │ │ │ │ │ ├── GetRollupsResponse.kt │ │ │ │ │ ├── TransportGetRollupAction.kt │ │ │ │ │ └── TransportGetRollupsAction.kt │ │ │ │ ├── index │ │ │ │ │ ├── IndexRollupAction.kt │ │ │ │ │ ├── IndexRollupRequest.kt │ │ │ │ │ ├── IndexRollupResponse.kt │ │ │ │ │ └── TransportIndexRollupAction.kt │ │ │ │ ├── mapping │ │ │ │ │ ├── TransportUpdateRollupMappingAction.kt │ │ │ │ │ ├── UpdateRollupMappingAction.kt │ │ │ │ │ └── UpdateRollupMappingRequest.kt │ │ │ │ ├── start │ │ │ │ │ ├── StartRollupAction.kt │ │ │ │ │ ├── StartRollupRequest.kt │ │ │ │ │ └── TransportStartRollupAction.kt │ │ │ │ └── stop │ │ │ │ │ ├── StopRollupAction.kt │ │ │ │ │ ├── StopRollupRequest.kt │ │ │ │ │ └── TransportStopRollupAction.kt │ │ │ ├── actionfilter │ │ │ │ ├── FieldCapsFilter.kt │ │ │ │ └── SerDeHelper.kt │ │ │ ├── interceptor │ │ │ │ └── RollupInterceptor.kt │ │ │ ├── model │ │ │ │ ├── ExplainRollup.kt │ │ │ │ ├── ISMRollup.kt │ │ │ │ ├── Rollup.kt │ │ │ │ ├── RollupFieldMapping.kt │ │ │ │ ├── RollupMetadata.kt │ │ │ │ ├── RollupMetrics.kt │ │ │ │ ├── dimension │ │ │ │ │ ├── DateHistogram.kt │ │ │ │ │ ├── Dimension.kt │ │ │ │ │ ├── Histogram.kt │ │ │ │ │ └── Terms.kt │ │ │ │ └── metric │ │ │ │ │ ├── Average.kt │ │ │ │ │ ├── Max.kt │ │ │ │ │ ├── Metric.kt │ │ │ │ │ ├── Min.kt │ │ │ │ │ ├── Sum.kt │ │ │ │ │ └── ValueCount.kt │ │ │ ├── resthandler │ │ │ │ ├── RestDeleteRollupAction.kt │ │ │ │ ├── RestExplainRollupAction.kt │ │ │ │ ├── RestGetRollupAction.kt │ │ │ │ ├── RestIndexRollupAction.kt │ │ │ │ ├── RestStartRollupAction.kt │ │ │ │ └── RestStopRollupAction.kt │ │ │ ├── settings │ │ │ │ └── RollupSettings.kt │ │ │ └── util │ │ │ │ └── RollupUtils.kt │ │ │ └── util │ │ │ ├── IndexManagementException.kt │ │ │ ├── IndexUtils.kt │ │ │ ├── OpenForTesting.kt │ │ │ └── RestHandlerUtils.kt │ ├── plugin-metadata │ │ └── plugin-security.policy │ └── resources │ │ ├── META-INF │ │ └── services │ │ │ └── com.amazon.opendistroforelasticsearch.jobscheduler.spi.JobSchedulerExtension │ │ └── mappings │ │ ├── opendistro-ism-config.json │ │ ├── opendistro-ism-history.json │ │ └── opendistro-rollup-target.json └── test │ ├── kotlin │ └── com │ │ └── amazon │ │ └── opendistroforelasticsearch │ │ └── indexmanagement │ │ ├── IndexManagementIndicesIT.kt │ │ ├── IndexManagementRestTestCase.kt │ │ ├── ODFERestTestCase.kt │ │ ├── TestHelpers.kt │ │ ├── indexstatemanagement │ │ ├── ISMTemplateMigrationIT.kt │ │ ├── IndexStateManagementIntegTestCase.kt │ │ ├── IndexStateManagementRestTestCase.kt │ │ ├── ManagedIndexConfigTests.kt │ │ ├── MetadataRegressionIT.kt │ │ ├── TestHelpers.kt │ │ ├── action │ │ │ ├── ActionRetryIT.kt │ │ │ ├── ActionTimeoutIT.kt │ │ │ ├── AllocationActionIT.kt │ │ │ ├── CloseActionIT.kt │ │ │ ├── ForceMergeActionIT.kt │ │ │ ├── IndexPriorityActionIT.kt │ │ │ ├── IndexStateManagementHistoryIT.kt │ │ │ ├── NotificationActionIT.kt │ │ │ ├── OpenActionIT.kt │ │ │ ├── ReadOnlyActionIT.kt │ │ │ ├── ReadWriteActionIT.kt │ │ │ ├── ReplicaCountActionIT.kt │ │ │ ├── RolloverActionIT.kt │ │ │ ├── RollupActionIT.kt │ │ │ ├── SnapshotActionIT.kt │ │ │ └── TransitionActionIT.kt │ │ ├── coordinator │ │ │ ├── ManagedIndexCoordinatorIT.kt │ │ │ ├── ManagedIndexCoordinatorTests.kt │ │ │ └── SkipExecutionTests.kt │ │ ├── model │ │ │ ├── ActionConfigTests.kt │ │ │ ├── ActionPropertiesTests.kt │ │ │ ├── ConditionsTests.kt │ │ │ ├── DestinationTests.kt │ │ │ ├── ISMTemplateTests.kt │ │ │ ├── ManagedIndexMetaDataTests.kt │ │ │ ├── PolicyTests.kt │ │ │ ├── StateTests.kt │ │ │ └── XContentTests.kt │ │ ├── resthandler │ │ │ ├── ISMTemplateRestAPIIT.kt │ │ │ ├── IndexStateManagementRestApiIT.kt │ │ │ ├── RestAddPolicyActionIT.kt │ │ │ ├── RestChangePolicyActionIT.kt │ │ │ ├── RestExplainActionIT.kt │ │ │ ├── RestRemovePolicyActionIT.kt │ │ │ └── RestRetryFailedManagedIndexActionIT.kt │ │ ├── runner │ │ │ ├── ManagedIndexRunnerIT.kt │ │ │ └── ManagedIndexRunnerTests.kt │ │ ├── step │ │ │ ├── AttemptCloseStepTests.kt │ │ │ ├── AttemptCreateRollupJobStepTests.kt │ │ │ ├── AttemptDeleteStepTests.kt │ │ │ ├── AttemptOpenStepTests.kt │ │ │ ├── AttemptSetIndexPriorityStepTests.kt │ │ │ ├── AttemptSetReplicaCountStepTests.kt │ │ │ ├── AttemptSnapshotStepTests.kt │ │ │ ├── AttemptTransitionStepTests.kt │ │ │ ├── SetReadOnlyStepTests.kt │ │ │ ├── SetReadWriteStepTests.kt │ │ │ ├── WaitForRollupCompletionStepTests.kt │ │ │ └── WaitForSnapshotStepTests.kt │ │ ├── transport │ │ │ └── action │ │ │ │ ├── ActionTests.kt │ │ │ │ ├── ISMStatusResponseTests.kt │ │ │ │ ├── addpolicy │ │ │ │ └── AddPolicyRequestTests.kt │ │ │ │ ├── changepolicy │ │ │ │ └── ChangePolicyRequestTests.kt │ │ │ │ ├── deletepolicy │ │ │ │ └── DeletePolicyRequestTests.kt │ │ │ │ ├── explain │ │ │ │ ├── ExplainRequestTests.kt │ │ │ │ └── ExplainResponseTests.kt │ │ │ │ ├── getpolicy │ │ │ │ ├── GetPoliciesRequestTests.kt │ │ │ │ ├── GetPoliciesResponseTests.kt │ │ │ │ ├── GetPolicyRequestTests.kt │ │ │ │ └── GetPolicyResponseTests.kt │ │ │ │ ├── indexpolicy │ │ │ │ ├── IndexPolicyRequestTests.kt │ │ │ │ └── IndexPolicyResponseTests.kt │ │ │ │ ├── removepolicy │ │ │ │ └── RemovePolicyRequestTests.kt │ │ │ │ └── retryfailedmanagedindex │ │ │ │ └── RetryFailedManagedIndexRequestTests.kt │ │ └── util │ │ │ └── ManagedIndexUtilsTests.kt │ │ ├── refreshanalyzer │ │ ├── RefreshSearchAnalyzerActionIT.kt │ │ ├── RefreshSearchAnalyzerResponseTests.kt │ │ ├── RefreshSearchAnalyzerShardResponseTests.kt │ │ └── RestRefreshSearchAnalyzerActionIT.kt │ │ ├── rollup │ │ ├── RollupMapperServiceTests.kt │ │ ├── RollupMetadataServiceTests.kt │ │ ├── RollupRestTestCase.kt │ │ ├── TestHelpers.kt │ │ ├── action │ │ │ ├── ActionTests.kt │ │ │ ├── RequestTests.kt │ │ │ └── ResponseTests.kt │ │ ├── actionfilter │ │ │ ├── FieldCapsFilterIT.kt │ │ │ ├── FieldCapsFilterTests.kt │ │ │ └── SerDeTests.kt │ │ ├── interceptor │ │ │ └── RollupInterceptorIT.kt │ │ ├── model │ │ │ ├── DimensionTests.kt │ │ │ ├── ISMRollupTests.kt │ │ │ ├── RollupFieldMappingTests.kt │ │ │ ├── RollupMetricsTests.kt │ │ │ ├── RollupTests.kt │ │ │ ├── WriteableTests.kt │ │ │ └── XContentTests.kt │ │ ├── resthandler │ │ │ ├── RestDeleteRollupActionIT.kt │ │ │ ├── RestExplainRollupActionIT.kt │ │ │ ├── RestGetRollupActionIT.kt │ │ │ ├── RestIndexRollupActionIT.kt │ │ │ ├── RestStartRollupActionIT.kt │ │ │ └── RestStopRollupActionIT.kt │ │ ├── runner │ │ │ └── RollupRunnerIT.kt │ │ └── util │ │ │ └── RollupUtilsTests.kt │ │ └── util │ │ └── IndexUtilsTests.kt │ └── resources │ ├── data │ └── nyc_5000.ndjson │ ├── index-management │ └── opendistro-index-management-1.13.2.0.zip │ ├── job-scheduler │ └── opendistro-job-scheduler-1.13.0.0.zip │ ├── mappings │ ├── cached-opendistro-ism-config.json │ ├── cached-opendistro-ism-history.json │ └── kibana-sample-data.json │ └── security │ ├── esnode-key.pem │ ├── esnode.pem │ ├── kirk-key.pem │ ├── kirk.pem │ ├── root-ca.pem │ ├── sample.pem │ └── test-kirk.jks └── worksheets ├── ism └── create.http └── rollups ├── comparisons.http ├── create.http ├── kibana_sample_data.http ├── search_test.http ├── secured ├── nyc.http ├── security_calls.http └── security_setup.http └── unsecured └── nyc.http /.codecov.yml: -------------------------------------------------------------------------------- 1 | codecov: 2 | require_ci_to_pass: yes 3 | 4 | coverage: 5 | precision: 2 6 | round: down 7 | range: "70...100" 8 | status: 9 | project: 10 | default: 11 | target: 70% # the required coverage value 12 | threshold: 1% # the leniency in hitting the target -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # config for Pinterest ktlint. https://github.com/pinterest/ktlint 2 | 3 | root = true 4 | 5 | [*.{kt,kts}] 6 | # we have detekt also checking for max line length. Disable the linter and use only one tool to check for max line length. 7 | 8 | # See https://github.com/arturbosch/detekt 9 | max_line_length=off 10 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: "[BUG]" 5 | labels: bug 6 | 7 | --- 8 | 9 | **Describe the bug** 10 | A clear and concise description of what the bug is. 11 | 12 | **Other plugins installed** 13 | Please mention if you are using this plugin along side any other plugin. Security for example. 14 | 15 | **To Reproduce** 16 | Steps to reproduce the behavior: 17 | 1. Go to '...' 18 | 2. Click on '....' 19 | 3. Scroll down to '....' 20 | 4. See error 21 | 22 | **Expected behavior** 23 | A clear and concise description of what you expected to happen. 24 | 25 | **Screenshots** 26 | If applicable, add screenshots to help explain your problem. 27 | 28 | **Desktop (please complete the following information):** 29 | - OS: [e.g. iOS] 30 | - Browser [e.g. chrome, safari] 31 | - Version [e.g. 22] 32 | 33 | **Additional context** 34 | Add any other context about the problem here. 35 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: enhancement 6 | 7 | --- 8 | 9 | **Is your feature request related to a problem? Please describe.** 10 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 11 | 12 | **Describe the solution you'd like** 13 | A clear and concise description of what you want to happen. 14 | 15 | **Describe alternatives you've considered** 16 | A clear and concise description of any alternative solutions or features you've considered. 17 | 18 | **Additional context** 19 | Add any other context or screenshots about the feature request here. 20 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | *Issue #, if available:* 2 | 3 | *Description of changes:* 4 | 5 | 6 | By making a contribution to this project, I certify that: 7 | 8 | (a) The contribution was created in whole or in part by me and I 9 | have the right to submit it under the open source license 10 | indicated in the file; or 11 | 12 | (b) The contribution is based upon previous work that, to the best 13 | of my knowledge, is covered under an appropriate open source 14 | license and I have the right under that license to submit that 15 | work with modifications, whether created in whole or in part 16 | by me, under the same open source license (unless I am 17 | permitted to submit under a different license), as indicated 18 | in the file; or 19 | 20 | (c) The contribution was provided directly to me by some other 21 | person who certified (a), (b) or (c) and I have not modified 22 | it. 23 | 24 | (d) I understand and agree that this project and the contribution 25 | are public and that a record of the contribution (including all 26 | personal information I submit with it, including my sign-off) is 27 | maintained indefinitely and may be redistributed consistent with 28 | this project or the open source license(s) involved. 29 | -------------------------------------------------------------------------------- /.github/draft-release-notes-config.yml: -------------------------------------------------------------------------------- 1 | # https://github.com/marketplace/actions/release-drafter 2 | # As pull requests are merged, a draft release is kept up-to-date listing the changes, ready to publish when you’re ready 3 | 4 | template: | 5 | Compatible with Elasticsearch (**set version here**). 6 | $CHANGES 7 | 8 | # Setting the formatting and sorting for the release notes body 9 | name-template: Version (set version here) 10 | change-template: '* $TITLE (#$NUMBER)' 11 | sort-by: merged_at 12 | sort-direction: ascending 13 | replacers: 14 | - search: '##' 15 | replace: '###' 16 | 17 | # Organizing the tagged PRs into unified ODFE categories 18 | categories: 19 | - title: 'Breaking changes' 20 | labels: 21 | - 'breaking change' 22 | - title: 'Features' 23 | labels: 24 | - 'feature' 25 | - title: 'Enhancements' 26 | labels: 27 | - 'enhancement' 28 | - 'action' 29 | - 'API' 30 | - title: 'Bug Fixes' 31 | labels: 32 | - 'bug' 33 | - title: 'Infrastructure' 34 | labels: 35 | - 'infra' 36 | - 'testing' 37 | - 'CI/CD' 38 | - 'dependencies' 39 | - title: 'Documentation' 40 | labels: 41 | - 'documentation' 42 | - title: 'Maintenance' 43 | labels: 44 | - 'version support' 45 | - title: 'Refactoring' 46 | labels: 47 | - 'Refactor' 48 | -------------------------------------------------------------------------------- /.github/workflows/draft-release-notes-workflow.yml: -------------------------------------------------------------------------------- 1 | name: Release Drafter 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | 8 | jobs: 9 | update_release_draft: 10 | name: Update draft release notes 11 | runs-on: ubuntu-latest 12 | steps: 13 | - name: Update draft release notes 14 | uses: release-drafter/release-drafter@v5 15 | with: 16 | config-name: draft-release-notes-config.yml 17 | name: Version (set here) 18 | tag: (None) 19 | env: 20 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} -------------------------------------------------------------------------------- /.github/workflows/multi-node-test-workflow.yml: -------------------------------------------------------------------------------- 1 | name: Multi node test workflow 2 | # This workflow is triggered on pull requests to main 3 | on: 4 | pull_request: 5 | branches: 6 | - main 7 | - development-* 8 | push: 9 | branches: 10 | - main 11 | - development-* 12 | 13 | jobs: 14 | build: 15 | # Job name 16 | name: Build Index Management 17 | # This job runs on Linux 18 | runs-on: ubuntu-latest 19 | steps: 20 | # This step uses the checkout Github action: https://github.com/actions/checkout 21 | - name: Checkout Branch 22 | uses: actions/checkout@v2 23 | # This step uses the setup-java Github action: https://github.com/actions/setup-java 24 | - name: Set Up JDK 14 25 | uses: actions/setup-java@v1 26 | with: 27 | java-version: 14 28 | - name: Run integration tests with multi node config 29 | run: ./gradlew integTest -PnumNodes=3 30 | - name: Upload failed logs 31 | uses: actions/upload-artifact@v2 32 | if: failure() 33 | with: 34 | name: logs 35 | path: build/testclusters/integTest-*/logs/* 36 | -------------------------------------------------------------------------------- /.github/workflows/test-and-build-workflow.yml: -------------------------------------------------------------------------------- 1 | name: Test and Build Workflow 2 | # This workflow is triggered on pull requests to main or a opendistro release branch 3 | on: 4 | pull_request: 5 | branches: 6 | - main 7 | - opendistro-* 8 | - development-* 9 | push: 10 | branches: 11 | - main 12 | - opendistro-* 13 | - development-* 14 | 15 | jobs: 16 | build: 17 | # Job name 18 | name: Build Index Management 19 | # This job runs on Linux 20 | runs-on: ubuntu-latest 21 | steps: 22 | # This step uses the checkout Github action: https://github.com/actions/checkout 23 | - name: Checkout Branch 24 | uses: actions/checkout@v2 25 | # This step uses the setup-java Github action: https://github.com/actions/setup-java 26 | - name: Set Up JDK 14 27 | uses: actions/setup-java@v1 28 | with: 29 | java-version: 14 30 | - name: Build with Gradle 31 | run: ./gradlew build 32 | - name: Upload failed logs 33 | uses: actions/upload-artifact@v2 34 | if: failure() 35 | with: 36 | name: logs 37 | path: build/testclusters/integTest-*/logs/* 38 | - name: Create Artifact Path 39 | run: | 40 | mkdir -p index-management-artifacts 41 | cp ./build/distributions/*.zip index-management-artifacts 42 | - name: Uploads coverage 43 | uses: codecov/codecov-action@v1 44 | with: 45 | token: ${{ secrets.CODECOV_TOKEN }} 46 | # This step uses the upload-artifact Github action: https://github.com/actions/upload-artifact 47 | - name: Upload Artifacts 48 | uses: actions/upload-artifact@v1 49 | with: 50 | name: index-management-plugin 51 | path: index-management-artifacts 52 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .gradle/ 2 | build/ 3 | out/ 4 | .idea/ 5 | *.ipr 6 | *.iws 7 | .DS_Store 8 | *.log 9 | http -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | ## Code of Conduct 2 | This project has adopted an [Open Source Code of Conduct](https://opendistro.github.io/for-elasticsearch/codeofconduct.html). 3 | -------------------------------------------------------------------------------- /NOTICE: -------------------------------------------------------------------------------- 1 | Index Management 2 | Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | -------------------------------------------------------------------------------- /detekt.yml: -------------------------------------------------------------------------------- 1 | failFast: false 2 | 3 | # TODO: Remove this before initial release, only for developmental purposes 4 | exceptions: 5 | TooGenericExceptionCaught: 6 | active: false 7 | 8 | style: 9 | ForbiddenComment: 10 | active: false 11 | MaxLineLength: 12 | maxLineLength: 150 13 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"). 5 | # You may not use this file except in compliance with the License. 6 | # A copy of the License is located at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # or in the "license" file accompanying this file. This file is distributed 11 | # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | # express or implied. See the License for the specific language governing 13 | # permissions and limitations under the License. 14 | # 15 | 16 | version = 1.13.2 17 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opendistro-for-elasticsearch/index-management/cda0eda35fc5da3816c407ad7a929d746edaf179/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /release-notes/create_release_notes.py: -------------------------------------------------------------------------------- 1 | # raw note means the draft release content copied down which is generated by Github workflow 2 | # this script helps add the URLs to all PR and have the right release note filename 3 | 4 | import os 5 | import sys 6 | import fileinput 7 | import re 8 | 9 | link_prefix = "https://github.com/opendistro-for-elasticsearch/index-management/pull/" 10 | searchExp = re.compile("([\(\[]).*?([\)\]])") 11 | 12 | current_date = raw_input("what day is today (e.g. 2020-06-29): ") 13 | file_path = raw_input("Path to raw note file (e.g., note.md): ") 14 | plugin_name = "index-management" 15 | plugin_version = raw_input('Plugin version (x.x.x.x): ') 16 | 17 | app_num = int( 18 | raw_input('Elasticsearch plugin (enter 1) or Kibana plugin (enter 2)? ')) 19 | app = 'Elasticsearch' 20 | if app_num is 2: 21 | app = 'Kibana' 22 | 23 | app_version = raw_input(app + ' compatibility version (x.x.x): ') 24 | 25 | for line in fileinput.input(file_path, inplace=True): 26 | # Add title and ES/Kibana compatibility 27 | if fileinput.isfirstline(): 28 | line = "## Version " + plugin_version + " " + current_date + "\n\n" \ 29 | "Compatible with " + app + " " + app_version + "\n" 30 | 31 | # Add link to PRs 32 | if '*' in line: 33 | start = line.find('#') + 1 34 | end = line.find(')', start) 35 | pr_num = line[start:end] 36 | line = re.sub(searchExp, "([#" + pr_num + 37 | "](" + link_prefix + pr_num + "))", line) 38 | sys.stdout.write(line) 39 | 40 | # Rename file to be consistent with ODFE standards 41 | new_file_path = "opendistro-for-elasticsearch-" + plugin_name + ".release-notes-" + \ 42 | plugin_version + ".md" 43 | os.rename(file_path, new_file_path) 44 | 45 | print('\n\nDone!\n') 46 | -------------------------------------------------------------------------------- /release-notes/opendistro-for-elasticsearch-index-management.release-notes-1.10.0.0.md: -------------------------------------------------------------------------------- 1 | ## Version 1.10.0.0 (2020-8-18) 2 | 3 | Compatible with Elasticsearch 7.9. 4 | 5 | ### Features 6 | * Implemented allocation action which can be used in index state management ([#106](https://github.com/opendistro-for-elasticsearch/index-management/pull/106)) 7 | 8 | ### Enhancements 9 | * Changes implementation of ChangePolicy REST API to use MultiGet inste… ([#253](https://github.com/opendistro-for-elasticsearch/index-management/pull/253)) 10 | 11 | ### Bug Fixes 12 | * Fixes snapshot issues, adds history mapping update workflow, adds tests ([#255](https://github.com/opendistro-for-elasticsearch/index-management/pull/255)) 13 | * Fixes force merge failing on long executions, changes some action mes… ([#267](https://github.com/opendistro-for-elasticsearch/index-management/pull/267)) 14 | 15 | ### Infrastructure 16 | * Adds codecov yml file to reduce flakiness in coverage check ([#251](https://github.com/opendistro-for-elasticsearch/index-management/pull/251)) 17 | * Adds support for multi-node run/testing and updates tests ([#254](https://github.com/opendistro-for-elasticsearch/index-management/pull/254)) 18 | * Adds multi node test workflow ([#256](https://github.com/opendistro-for-elasticsearch/index-management/pull/256)) 19 | * release notes automation ([#258](https://github.com/opendistro-for-elasticsearch/index-management/pull/258)) 20 | 21 | ### Documentation 22 | * Adds rollup-rfc to docs ([#248](https://github.com/opendistro-for-elasticsearch/index-management/pull/248)) 23 | 24 | ### Maintenance 25 | * Adds support for Elasticsearch 7.9 ([#283](https://github.com/opendistro-for-elasticsearch/index-management/pull/283)) 26 | -------------------------------------------------------------------------------- /release-notes/opendistro-for-elasticsearch-index-management.release-notes-1.10.1.0.md: -------------------------------------------------------------------------------- 1 | ## Version 1.10.1.0 (2020-9-8) 2 | 3 | Compatible with Elasticsearch 7.9.1. 4 | 5 | ### Infrastructure 6 | * Fixes download and doc links in gradle package ([#287](https://github.com/opendistro-for-elasticsearch/index-management/pull/287)) 7 | 8 | ### Maintenance 9 | * Adds support for Elasticsearch 7.9.1 ([#288](https://github.com/opendistro-for-elasticsearch/index-management/pull/288)) 10 | * Refactors internal architecture/files to prepare for support of transforms/rollups ([#285](https://github.com/opendistro-for-elasticsearch/index-management/pull/285)) 11 | -------------------------------------------------------------------------------- /release-notes/opendistro-for-elasticsearch-index-management.release-notes-1.10.1.1.md: -------------------------------------------------------------------------------- 1 | ## Version 1.10.1.1 (2020-9-14) 2 | 3 | Compatible with Elasticsearch 7.9.1. 4 | 5 | ### Features 6 | * Adds `_refresh_search_analyzers` API to allow updating synonym list for dynamically updatable synonym analyzers ([#290](https://github.com/opendistro-for-elasticsearch/index-management/pull/290)) 7 | 8 | ### Infrastructure 9 | * Fixes download and doc links in gradle package ([#287](https://github.com/opendistro-for-elasticsearch/index-management/pull/287)) 10 | 11 | ### Maintenance 12 | * Adds support for Elasticsearch 7.9.1 ([#288](https://github.com/opendistro-for-elasticsearch/index-management/pull/288)) 13 | * Refactors internal architecture/files to prepare for support of transforms/rollups ([#285](https://github.com/opendistro-for-elasticsearch/index-management/pull/285)) 14 | -------------------------------------------------------------------------------- /release-notes/opendistro-for-elasticsearch-index-management.release-notes-1.11.0.0.md: -------------------------------------------------------------------------------- 1 | ## Version 1.11.0.0 2020-10-19 2 | 3 | Compatible with Elasticsearch 7.9.1 4 | 5 | ### Enhancements 6 | 7 | * actionify remove policy API ([#293](https://github.com/opendistro-for-elasticsearch/index-management/pull/293)) 8 | * actionify add policy API ([#298](https://github.com/opendistro-for-elasticsearch/index-management/pull/298)) 9 | * actionify retry API ([#302](https://github.com/opendistro-for-elasticsearch/index-management/pull/302)) 10 | * actionify change policy API ([#303](https://github.com/opendistro-for-elasticsearch/index-management/pull/303)) 11 | * actionify explain API ([#304](https://github.com/opendistro-for-elasticsearch/index-management/pull/304)) 12 | * actionify index policy action ([#305](https://github.com/opendistro-for-elasticsearch/index-management/pull/305)) 13 | * actionify get policy API ([#307](https://github.com/opendistro-for-elasticsearch/index-management/pull/307)) 14 | * actionify delete policy API ([#308](https://github.com/opendistro-for-elasticsearch/index-management/pull/308)) 15 | 16 | -------------------------------------------------------------------------------- /release-notes/opendistro-for-elasticsearch-index-management.release-notes-1.12.0.1.md: -------------------------------------------------------------------------------- 1 | ## Version 1.12.0.1 2020-12-09 2 | 3 | Compatible with Elasticsearch 7.10.0 4 | 5 | ### Bug fixes 6 | 7 | * Accept request parameters in RestGetRollupAction and fix flakey tests ([#353](https://github.com/opendistro-for-elasticsearch/index-management/pull/353)) 8 | -------------------------------------------------------------------------------- /release-notes/opendistro-for-elasticsearch-index-management.release-notes-1.13.1.0.md: -------------------------------------------------------------------------------- 1 | ## Version 1.13.1.0 2021-02-26 2 | 3 | Compatible with Elasticsearch 7.10.2 4 | 5 | ### Enhancements 6 | * Support host deny list for error notification and notification action ([#410](https://github.com/opendistro-for-elasticsearch/index-management/pull/410)) 7 | -------------------------------------------------------------------------------- /release-notes/opendistro-for-elasticsearch-index-management.release-notes-1.13.2.0.md: -------------------------------------------------------------------------------- 1 | ## Version 1.13.2.0 2021-03-30 2 | 3 | Compatible with Elasticsearch 7.10.2 4 | 5 | ### Bug fixes 6 | * Correcting rollup rewriting logic in field caps filter for cross cluster search and introducing a setting to prevent the rewrite if not desired ([#422](https://github.com/opendistro-for-elasticsearch/index-management/pull/422)) 7 | 8 | -------------------------------------------------------------------------------- /release-notes/opendistro-for-elasticsearch-index-management.release-notes-1.3.0.0.md: -------------------------------------------------------------------------------- 1 | 2 | ## Version 1.3.0.0 (2019-12-17) 3 | 4 | ### Features 5 | 6 | This is the first official release of Open Distro Index Management plugin. 7 | 8 | With Index State Management you will be able to define custom policies, to optimize and manage indices and apply them to index patterns. 9 | Each policy contains a default state and a list of states that you define for the index to transition between. 10 | Within each state you can define a list of actions to perform and transitions to enter a new state based off certain conditions. 11 | 12 | Adds backend REST API used for basic CRUD operations, explain, and management of policies and managed indices. 13 | -------------------------------------------------------------------------------- /release-notes/opendistro-for-elasticsearch-index-management.release-notes-1.4.0.0.md: -------------------------------------------------------------------------------- 1 | 2 | ## Version 1.4.0.0 3 | 4 | ### Features 5 | * Adds support for Elasticsearch 7.4.2 [PR #132](https://github.com/opendistro-for-elasticsearch/index-management/pull/132) 6 | 7 | ### Bug Fixes 8 | * Fixes issue where action timeout was using start_time from previous action [PR #133](https://github.com/opendistro-for-elasticsearch/index-management/pull/133) 9 | 10 | -------------------------------------------------------------------------------- /release-notes/opendistro-for-elasticsearch-index-management.release-notes-1.6.0.0.md: -------------------------------------------------------------------------------- 1 | 2 | ## Version 1.6.0.0 (2020-3-26) 3 | 4 | ### Features 5 | * Adds support for Elasticsearch 7.6.1 [PR #164](https://github.com/opendistro-for-elasticsearch/index-management/pull/164) 6 | * Due to Changes in ES test framework since 7.5 7 | * Update Jacoco (code coverage) 8 | * Update gradle tasks `integTest` and `testClusters` 9 | * Update debug method and new debug option `cluster.debug` 10 | -------------------------------------------------------------------------------- /release-notes/opendistro-for-elasticsearch-index-management.release-notes-1.7.0.0.md: -------------------------------------------------------------------------------- 1 | 2 | ## Version 1.7.0.0 (2020-5-4) 3 | 4 | Compatible with Elasticsearch 7.6.1, Adds support for ODFE 1.7.0 5 | 6 | ### Features 7 | * Adds rollover conditions into info object [PR #208](https://github.com/opendistro-for-elasticsearch/index-management/pull/208) 8 | 9 | ### Enhancements 10 | * Adds isIdempotent method to each step and updates ManagedIndexRunner to use it [PR #165](https://github.com/opendistro-for-elasticsearch/index-management/pull/165) 11 | 12 | * Adds logs, fix for index creation date -1L, nullable checks [PR #170](https://github.com/opendistro-for-elasticsearch/index-management/pull/170) 13 | 14 | * Update schema version for IndexManagementConfig mapping if available [PR #198](https://github.com/opendistro-for-elasticsearch/index-management/pull/198) 15 | 16 | * Switches UpdateManagedIndexMetaData to batch tasks using custom executor [PR #209](https://github.com/opendistro-for-elasticsearch/index-management/pull/209) 17 | 18 | ### Bug Fixes 19 | * Delete and close failing during snapshot in progress [PR #172](https://github.com/opendistro-for-elasticsearch/index-management/pull/172) -------------------------------------------------------------------------------- /release-notes/opendistro-for-elasticsearch-index-management.release-notes-1.8.0.0.md: -------------------------------------------------------------------------------- 1 | 2 | ## Version 1.8.0.0 (2020-5-20) 3 | 4 | Compatible with Elasticsearch 7.7.0, Adds support for ODFE 1.8.0 5 | 6 | ### Features 7 | * Snapshot implementation [PR #135](https://github.com/opendistro-for-elasticsearch/index-management/pull/135) 8 | 9 | -------------------------------------------------------------------------------- /release-notes/opendistro-for-elasticsearch-index-management.release-notes-1.9.0.0.md: -------------------------------------------------------------------------------- 1 | 2 | ## Version 1.9.0.0 (2020-6-25) 3 | 4 | Compatible with Elasticsearch 7.8.0, Adds support for ODFE 1.9.0 5 | 6 | ### Features 7 | * Adds support for Elasticsearch 7.8.0 [PR #246](https://github.com/opendistro-for-elasticsearch/index-management/pull/246) 8 | 9 | ### Enhancements 10 | * Implement set index priority action [PR #241](https://github.com/opendistro-for-elasticsearch/index-management/pull/241) 11 | 12 | 13 | -------------------------------------------------------------------------------- /release-notes/opendistro-for-elasticsearch-index-management.release-notes-1.9.0.1.md: -------------------------------------------------------------------------------- 1 | 2 | ## Version 1.9.0.1 3 | 4 | Compatible with Elasticsearch 7.8.0, Adds support for ODFE 1.9.0 5 | 6 | ### Bug Fixes 7 | * Fixes snapshot bugs [PR #244](https://github.com/opendistro-for-elasticsearch/index-management/pull/244) 8 | 9 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | rootProject.name = 'opendistro-index-management' 17 | -------------------------------------------------------------------------------- /src/main/kotlin/com/amazon/opendistroforelasticsearch/indexmanagement/IndexManagementRunner.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | package com.amazon.opendistroforelasticsearch.indexmanagement 17 | 18 | import com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.ManagedIndexRunner 19 | import com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.model.ManagedIndexConfig 20 | import com.amazon.opendistroforelasticsearch.indexmanagement.rollup.RollupRunner 21 | import com.amazon.opendistroforelasticsearch.indexmanagement.rollup.model.Rollup 22 | import com.amazon.opendistroforelasticsearch.jobscheduler.spi.JobExecutionContext 23 | import com.amazon.opendistroforelasticsearch.jobscheduler.spi.ScheduledJobParameter 24 | import com.amazon.opendistroforelasticsearch.jobscheduler.spi.ScheduledJobRunner 25 | import org.apache.logging.log4j.LogManager 26 | 27 | object IndexManagementRunner : ScheduledJobRunner { 28 | 29 | private val logger = LogManager.getLogger(javaClass) 30 | 31 | override fun runJob(job: ScheduledJobParameter, context: JobExecutionContext) { 32 | when (job) { 33 | is ManagedIndexConfig -> ManagedIndexRunner.runJob(job, context) 34 | is Rollup -> RollupRunner.runJob(job, context) 35 | else -> { 36 | val errorMessage = "Invalid job type, found ${job.javaClass.simpleName} with id: ${context.jobId}" 37 | logger.error(errorMessage) 38 | throw IllegalArgumentException(errorMessage) 39 | } 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/kotlin/com/amazon/opendistroforelasticsearch/indexmanagement/indexstatemanagement/action/Action.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | package com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.action 17 | 18 | import com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.model.ManagedIndexMetaData 19 | import com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.model.action.ActionConfig 20 | import com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.model.action.ActionConfig.ActionType 21 | import com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.step.Step 22 | 23 | abstract class Action(val type: ActionType, val config: ActionConfig, val managedIndexMetaData: ManagedIndexMetaData) { 24 | 25 | abstract fun getSteps(): List 26 | 27 | abstract fun getStepToExecute(): Step 28 | 29 | fun isLastStep(stepName: String): Boolean = getSteps().last().name == stepName 30 | 31 | fun isFirstStep(stepName: String?): Boolean = getSteps().first().name == stepName 32 | } 33 | -------------------------------------------------------------------------------- /src/main/kotlin/com/amazon/opendistroforelasticsearch/indexmanagement/indexstatemanagement/action/AllocationAction.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | package com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.action 17 | 18 | import com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.model.ManagedIndexMetaData 19 | import com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.model.action.ActionConfig 20 | import com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.model.action.AllocationActionConfig 21 | import com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.step.Step 22 | import com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.step.allocation.AttemptAllocationStep 23 | import org.elasticsearch.client.Client 24 | import org.elasticsearch.cluster.service.ClusterService 25 | 26 | class AllocationAction( 27 | clusterService: ClusterService, 28 | client: Client, 29 | managedIndexMetaData: ManagedIndexMetaData, 30 | config: AllocationActionConfig 31 | ) : Action(ActionConfig.ActionType.ALLOCATION, config, managedIndexMetaData) { 32 | 33 | private val attemptAllocationStep = AttemptAllocationStep(clusterService, client, config, managedIndexMetaData) 34 | 35 | private val steps = listOf(attemptAllocationStep) 36 | 37 | override fun getSteps(): List = steps 38 | 39 | override fun getStepToExecute(): Step { 40 | return attemptAllocationStep 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/kotlin/com/amazon/opendistroforelasticsearch/indexmanagement/indexstatemanagement/action/CloseAction.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | package com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.action 17 | 18 | import com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.model.ManagedIndexMetaData 19 | import com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.model.action.ActionConfig.ActionType 20 | import com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.model.action.CloseActionConfig 21 | import com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.step.Step 22 | import com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.step.close.AttemptCloseStep 23 | import org.elasticsearch.client.Client 24 | import org.elasticsearch.cluster.service.ClusterService 25 | 26 | class CloseAction( 27 | clusterService: ClusterService, 28 | client: Client, 29 | managedIndexMetaData: ManagedIndexMetaData, 30 | config: CloseActionConfig 31 | ) : Action(ActionType.CLOSE, config, managedIndexMetaData) { 32 | 33 | private val attemptCloseStep = AttemptCloseStep(clusterService, client, config, managedIndexMetaData) 34 | 35 | private val steps = listOf(attemptCloseStep) 36 | 37 | override fun getSteps(): List = steps 38 | 39 | override fun getStepToExecute(): Step { 40 | return attemptCloseStep 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/kotlin/com/amazon/opendistroforelasticsearch/indexmanagement/indexstatemanagement/action/DeleteAction.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | package com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.action 17 | 18 | import com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.model.ManagedIndexMetaData 19 | import com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.model.action.ActionConfig.ActionType 20 | import com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.model.action.DeleteActionConfig 21 | import com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.step.delete.AttemptDeleteStep 22 | import com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.step.Step 23 | import org.elasticsearch.client.Client 24 | import org.elasticsearch.cluster.service.ClusterService 25 | 26 | class DeleteAction( 27 | clusterService: ClusterService, 28 | client: Client, 29 | managedIndexMetaData: ManagedIndexMetaData, 30 | config: DeleteActionConfig 31 | ) : Action(ActionType.DELETE, config, managedIndexMetaData) { 32 | 33 | private val attemptDeleteStep = AttemptDeleteStep(clusterService, client, config, managedIndexMetaData) 34 | private val steps = listOf(attemptDeleteStep) 35 | 36 | override fun getSteps(): List = steps 37 | 38 | override fun getStepToExecute(): Step { 39 | return attemptDeleteStep 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/kotlin/com/amazon/opendistroforelasticsearch/indexmanagement/indexstatemanagement/action/IndexPriorityAction.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | package com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.action 17 | 18 | import com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.model.ManagedIndexMetaData 19 | import com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.model.action.ActionConfig.ActionType 20 | import com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.model.action.IndexPriorityActionConfig 21 | import com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.step.Step 22 | import com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.step.indexpriority.AttemptSetIndexPriorityStep 23 | import org.elasticsearch.client.Client 24 | import org.elasticsearch.cluster.service.ClusterService 25 | 26 | class IndexPriorityAction( 27 | clusterService: ClusterService, 28 | client: Client, 29 | managedIndexMetaData: ManagedIndexMetaData, 30 | config: IndexPriorityActionConfig 31 | ) : Action(ActionType.INDEX_PRIORITY, config, managedIndexMetaData) { 32 | 33 | private val attemptSetIndexPriorityStep = AttemptSetIndexPriorityStep(clusterService, client, config, managedIndexMetaData) 34 | private val steps = listOf(attemptSetIndexPriorityStep) 35 | 36 | override fun getSteps(): List = steps 37 | 38 | override fun getStepToExecute(): Step = attemptSetIndexPriorityStep 39 | } 40 | -------------------------------------------------------------------------------- /src/main/kotlin/com/amazon/opendistroforelasticsearch/indexmanagement/indexstatemanagement/action/NotificationAction.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | package com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.action 17 | 18 | import com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.model.ManagedIndexMetaData 19 | import com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.model.action.ActionConfig 20 | import com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.model.action.NotificationActionConfig 21 | import com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.step.Step 22 | import com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.step.notification.AttemptNotificationStep 23 | import org.elasticsearch.client.Client 24 | import org.elasticsearch.cluster.service.ClusterService 25 | import org.elasticsearch.common.settings.Settings 26 | import org.elasticsearch.script.ScriptService 27 | 28 | class NotificationAction( 29 | clusterService: ClusterService, 30 | scriptService: ScriptService, 31 | client: Client, 32 | settings: Settings, 33 | managedIndexMetaData: ManagedIndexMetaData, 34 | config: NotificationActionConfig 35 | ) : Action(ActionConfig.ActionType.NOTIFICATION, config, managedIndexMetaData) { 36 | 37 | private val attemptNotificationStep = AttemptNotificationStep(clusterService, scriptService, client, settings, config, managedIndexMetaData) 38 | private val steps = listOf(attemptNotificationStep) 39 | 40 | override fun getSteps(): List = steps 41 | 42 | override fun getStepToExecute(): Step = attemptNotificationStep 43 | } 44 | -------------------------------------------------------------------------------- /src/main/kotlin/com/amazon/opendistroforelasticsearch/indexmanagement/indexstatemanagement/action/OpenAction.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | package com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.action 17 | 18 | import com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.model.ManagedIndexMetaData 19 | import com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.model.action.ActionConfig.ActionType 20 | import com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.model.action.OpenActionConfig 21 | import com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.step.Step 22 | import com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.step.open.AttemptOpenStep 23 | import org.elasticsearch.client.Client 24 | import org.elasticsearch.cluster.service.ClusterService 25 | 26 | class OpenAction( 27 | clusterService: ClusterService, 28 | client: Client, 29 | managedIndexMetaData: ManagedIndexMetaData, 30 | config: OpenActionConfig 31 | ) : Action(ActionType.OPEN, config, managedIndexMetaData) { 32 | 33 | private val attemptOpenStep = AttemptOpenStep(clusterService, client, config, managedIndexMetaData) 34 | 35 | private val steps = listOf(attemptOpenStep) 36 | 37 | override fun getSteps(): List = steps 38 | 39 | override fun getStepToExecute(): Step { 40 | return attemptOpenStep 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/kotlin/com/amazon/opendistroforelasticsearch/indexmanagement/indexstatemanagement/action/ReadOnlyAction.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | package com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.action 17 | 18 | import com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.model.ManagedIndexMetaData 19 | import com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.model.action.ActionConfig.ActionType 20 | import com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.model.action.ReadOnlyActionConfig 21 | import com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.step.Step 22 | import com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.step.readonly.SetReadOnlyStep 23 | import org.elasticsearch.client.Client 24 | import org.elasticsearch.cluster.service.ClusterService 25 | 26 | class ReadOnlyAction( 27 | clusterService: ClusterService, 28 | client: Client, 29 | managedIndexMetaData: ManagedIndexMetaData, 30 | config: ReadOnlyActionConfig 31 | ) : Action(ActionType.READ_ONLY, config, managedIndexMetaData) { 32 | 33 | private val setReadOnlyStep = SetReadOnlyStep(clusterService, client, config, managedIndexMetaData) 34 | private val steps = listOf(setReadOnlyStep) 35 | 36 | override fun getSteps(): List = steps 37 | 38 | override fun getStepToExecute(): Step { 39 | return setReadOnlyStep 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/kotlin/com/amazon/opendistroforelasticsearch/indexmanagement/indexstatemanagement/action/ReadWriteAction.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | package com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.action 17 | 18 | import com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.model.ManagedIndexMetaData 19 | import com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.model.action.ActionConfig.ActionType 20 | import com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.model.action.ReadWriteActionConfig 21 | import com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.step.Step 22 | import com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.step.readwrite.SetReadWriteStep 23 | import org.elasticsearch.client.Client 24 | import org.elasticsearch.cluster.service.ClusterService 25 | 26 | class ReadWriteAction( 27 | clusterService: ClusterService, 28 | client: Client, 29 | managedIndexMetaData: ManagedIndexMetaData, 30 | config: ReadWriteActionConfig 31 | ) : Action(ActionType.READ_WRITE, config, managedIndexMetaData) { 32 | 33 | private val setReadWriteStep = SetReadWriteStep(clusterService, client, config, managedIndexMetaData) 34 | private val steps = listOf(setReadWriteStep) 35 | 36 | override fun getSteps(): List = steps 37 | 38 | override fun getStepToExecute(): Step { 39 | return setReadWriteStep 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/kotlin/com/amazon/opendistroforelasticsearch/indexmanagement/indexstatemanagement/action/ReplicaCountAction.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | package com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.action 17 | 18 | import com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.model.ManagedIndexMetaData 19 | import com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.model.action.ActionConfig.ActionType 20 | import com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.model.action.ReplicaCountActionConfig 21 | import com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.step.Step 22 | import com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.step.replicacount.AttemptSetReplicaCountStep 23 | import org.elasticsearch.client.Client 24 | import org.elasticsearch.cluster.service.ClusterService 25 | 26 | class ReplicaCountAction( 27 | clusterService: ClusterService, 28 | client: Client, 29 | managedIndexMetaData: ManagedIndexMetaData, 30 | config: ReplicaCountActionConfig 31 | ) : Action(ActionType.REPLICA_COUNT, config, managedIndexMetaData) { 32 | 33 | private val attemptSetReplicaCountStep = AttemptSetReplicaCountStep(clusterService, client, config, managedIndexMetaData) 34 | private val steps = listOf(attemptSetReplicaCountStep) 35 | 36 | override fun getSteps(): List = steps 37 | 38 | override fun getStepToExecute(): Step = attemptSetReplicaCountStep 39 | } 40 | -------------------------------------------------------------------------------- /src/main/kotlin/com/amazon/opendistroforelasticsearch/indexmanagement/indexstatemanagement/action/RolloverAction.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | package com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.action 17 | 18 | import com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.model.ManagedIndexMetaData 19 | import com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.model.action.ActionConfig.ActionType 20 | import com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.model.action.RolloverActionConfig 21 | import com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.step.Step 22 | import com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.step.rollover.AttemptRolloverStep 23 | import org.elasticsearch.client.Client 24 | import org.elasticsearch.cluster.service.ClusterService 25 | 26 | class RolloverAction( 27 | clusterService: ClusterService, 28 | client: Client, 29 | managedIndexMetaData: ManagedIndexMetaData, 30 | config: RolloverActionConfig 31 | ) : Action(ActionType.ROLLOVER, config, managedIndexMetaData) { 32 | 33 | private val attemptRolloverStep = AttemptRolloverStep(clusterService, client, config, managedIndexMetaData) 34 | private val steps = listOf(attemptRolloverStep) 35 | 36 | override fun getSteps(): List = steps 37 | 38 | override fun getStepToExecute(): Step { 39 | return attemptRolloverStep 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/kotlin/com/amazon/opendistroforelasticsearch/indexmanagement/indexstatemanagement/action/TransitionsAction.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | package com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.action 17 | 18 | import com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.model.ManagedIndexMetaData 19 | import com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.model.action.ActionConfig.ActionType 20 | import com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.model.action.TransitionsActionConfig 21 | import com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.step.transition.AttemptTransitionStep 22 | import com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.step.Step 23 | import org.elasticsearch.client.Client 24 | import org.elasticsearch.cluster.service.ClusterService 25 | 26 | class TransitionsAction( 27 | clusterService: ClusterService, 28 | client: Client, 29 | managedIndexMetaData: ManagedIndexMetaData, 30 | config: TransitionsActionConfig 31 | ) : Action(ActionType.TRANSITION, config, managedIndexMetaData) { 32 | 33 | private val attemptTransitionStep = 34 | AttemptTransitionStep(clusterService, client, config, managedIndexMetaData) 35 | private val steps = listOf(attemptTransitionStep) 36 | 37 | override fun getSteps(): List = steps 38 | 39 | override fun getStepToExecute(): Step { 40 | return attemptTransitionStep 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/kotlin/com/amazon/opendistroforelasticsearch/indexmanagement/indexstatemanagement/model/SearchParams.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | package com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.model 17 | 18 | import org.elasticsearch.common.io.stream.StreamInput 19 | import org.elasticsearch.common.io.stream.StreamOutput 20 | import org.elasticsearch.common.io.stream.Writeable 21 | import java.io.IOException 22 | 23 | data class SearchParams( 24 | val size: Int, 25 | val from: Int, 26 | val sortField: String, 27 | val sortOrder: String, 28 | val queryString: String 29 | ) : Writeable { 30 | 31 | @Throws(IOException::class) 32 | constructor(sin: StreamInput) : this( 33 | size = sin.readInt(), 34 | from = sin.readInt(), 35 | sortField = sin.readString(), 36 | sortOrder = sin.readString(), 37 | queryString = sin.readString() 38 | ) 39 | 40 | @Throws(IOException::class) 41 | override fun writeTo(out: StreamOutput) { 42 | out.writeInt(size) 43 | out.writeInt(from) 44 | out.writeString(sortField) 45 | out.writeString(sortOrder) 46 | out.writeString(queryString) 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/main/kotlin/com/amazon/opendistroforelasticsearch/indexmanagement/indexstatemanagement/model/StateFilter.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | package com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.model 17 | 18 | import org.elasticsearch.common.io.stream.StreamInput 19 | import org.elasticsearch.common.io.stream.StreamOutput 20 | import org.elasticsearch.common.io.stream.Writeable 21 | import org.elasticsearch.common.xcontent.XContentParser 22 | import org.elasticsearch.common.xcontent.XContentParser.Token 23 | import org.elasticsearch.common.xcontent.XContentParserUtils.ensureExpectedToken 24 | import java.io.IOException 25 | 26 | data class StateFilter(val state: String) : Writeable { 27 | 28 | @Throws(IOException::class) 29 | constructor(sin: StreamInput) : this( 30 | state = sin.readString() 31 | ) 32 | 33 | @Throws(IOException::class) 34 | override fun writeTo(out: StreamOutput) { 35 | out.writeString(state) 36 | } 37 | 38 | companion object { 39 | const val STATE_FIELD = "state" 40 | 41 | @JvmStatic 42 | @Throws(IOException::class) 43 | fun parse(xcp: XContentParser): StateFilter { 44 | var state: String? = null 45 | 46 | ensureExpectedToken(Token.START_OBJECT, xcp.currentToken(), xcp) 47 | while (xcp.nextToken() != Token.END_OBJECT) { 48 | val fieldName = xcp.currentName() 49 | xcp.nextToken() 50 | 51 | when (fieldName) { 52 | STATE_FIELD -> state = xcp.text() 53 | } 54 | } 55 | 56 | return StateFilter(requireNotNull(state) { "Must include a state when using include filter" }) 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/main/kotlin/com/amazon/opendistroforelasticsearch/indexmanagement/indexstatemanagement/model/action/ActionTimeout.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | package com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.model.action 17 | 18 | import org.elasticsearch.common.io.stream.StreamInput 19 | import org.elasticsearch.common.io.stream.StreamOutput 20 | import org.elasticsearch.common.io.stream.Writeable 21 | import org.elasticsearch.common.unit.TimeValue 22 | import org.elasticsearch.common.xcontent.ToXContent 23 | import org.elasticsearch.common.xcontent.ToXContentFragment 24 | import org.elasticsearch.common.xcontent.XContentBuilder 25 | import org.elasticsearch.common.xcontent.XContentParser 26 | import org.elasticsearch.common.xcontent.XContentParser.Token 27 | import java.io.IOException 28 | 29 | data class ActionTimeout(val timeout: TimeValue) : ToXContentFragment, Writeable { 30 | 31 | override fun toXContent(builder: XContentBuilder, params: ToXContent.Params): XContentBuilder { 32 | return builder.field(TIMEOUT_FIELD, timeout.stringRep) 33 | } 34 | 35 | @Throws(IOException::class) 36 | constructor(sin: StreamInput) : this( 37 | timeout = sin.readTimeValue() 38 | ) 39 | 40 | @Throws(IOException::class) 41 | override fun writeTo(out: StreamOutput) { 42 | out.writeTimeValue(timeout) 43 | } 44 | 45 | companion object { 46 | const val TIMEOUT_FIELD = "timeout" 47 | 48 | @JvmStatic 49 | @Throws(IOException::class) 50 | fun parse(xcp: XContentParser): ActionTimeout { 51 | if (xcp.currentToken() == Token.VALUE_STRING) { 52 | return ActionTimeout(TimeValue.parseTimeValue(xcp.text(), TIMEOUT_FIELD)) 53 | } else { 54 | throw IllegalArgumentException("Invalid token: [${xcp.currentToken()}] for ActionTimeout") 55 | } 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/main/kotlin/com/amazon/opendistroforelasticsearch/indexmanagement/indexstatemanagement/model/action/TransitionsActionConfig.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | package com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.model.action 17 | 18 | import com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.action.Action 19 | import com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.action.TransitionsAction 20 | import com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.model.ManagedIndexMetaData 21 | import com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.model.Transition 22 | import org.elasticsearch.client.Client 23 | import org.elasticsearch.cluster.service.ClusterService 24 | import org.elasticsearch.common.settings.Settings 25 | import org.elasticsearch.script.ScriptService 26 | 27 | data class TransitionsActionConfig( 28 | val transitions: List 29 | ) : ActionConfig(ActionType.TRANSITION, -1) { 30 | 31 | override fun toAction( 32 | clusterService: ClusterService, 33 | scriptService: ScriptService, 34 | client: Client, 35 | settings: Settings, 36 | managedIndexMetaData: ManagedIndexMetaData 37 | ): Action = TransitionsAction(clusterService, client, managedIndexMetaData, this) 38 | } 39 | -------------------------------------------------------------------------------- /src/main/kotlin/com/amazon/opendistroforelasticsearch/indexmanagement/indexstatemanagement/model/coordinator/ClusterStateManagedIndexConfig.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | package com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.model.coordinator 17 | 18 | import com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.model.ManagedIndexConfig 19 | import org.elasticsearch.common.xcontent.ToXContentObject 20 | import org.elasticsearch.index.seqno.SequenceNumbers 21 | 22 | /** 23 | * Data class to hold index metadata from cluster state. 24 | * 25 | * This data class is used in the [com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.ManagedIndexCoordinator] 26 | * when reading in index metadata from cluster state and implements [ToXContentObject] for partial updates 27 | * of the [ManagedIndexConfig] job document. 28 | */ 29 | data class ClusterStateManagedIndexConfig( 30 | val index: String, 31 | val seqNo: Long = SequenceNumbers.UNASSIGNED_SEQ_NO, 32 | val primaryTerm: Long = SequenceNumbers.UNASSIGNED_PRIMARY_TERM, 33 | val uuid: String, 34 | val policyID: String 35 | ) 36 | -------------------------------------------------------------------------------- /src/main/kotlin/com/amazon/opendistroforelasticsearch/indexmanagement/indexstatemanagement/transport/action/ISMStatusResponse.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | package com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.transport.action 17 | 18 | import com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.util.FailedIndex 19 | import com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.util.UPDATED_INDICES 20 | import com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.util.buildInvalidIndexResponse 21 | import org.elasticsearch.action.ActionResponse 22 | import org.elasticsearch.common.io.stream.StreamInput 23 | import org.elasticsearch.common.io.stream.StreamOutput 24 | import org.elasticsearch.common.xcontent.ToXContent 25 | import org.elasticsearch.common.xcontent.ToXContentObject 26 | import org.elasticsearch.common.xcontent.XContentBuilder 27 | import java.io.IOException 28 | 29 | open class ISMStatusResponse : ActionResponse, ToXContentObject { 30 | 31 | val updated: Int 32 | val failedIndices: List 33 | 34 | constructor( 35 | updated: Int, 36 | failedIndices: List 37 | ) : super() { 38 | this.updated = updated 39 | this.failedIndices = failedIndices 40 | } 41 | 42 | @Throws(IOException::class) 43 | constructor(sin: StreamInput) : this( 44 | updated = sin.readInt(), 45 | failedIndices = sin.readList(::FailedIndex) 46 | ) 47 | 48 | override fun writeTo(out: StreamOutput) { 49 | out.writeInt(updated) 50 | out.writeCollection(failedIndices) 51 | } 52 | 53 | override fun toXContent(builder: XContentBuilder, params: ToXContent.Params): XContentBuilder { 54 | builder.startObject() 55 | builder.field(UPDATED_INDICES, updated) 56 | buildInvalidIndexResponse(builder, failedIndices) 57 | return builder.endObject() 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/main/kotlin/com/amazon/opendistroforelasticsearch/indexmanagement/indexstatemanagement/transport/action/addpolicy/AddPolicyAction.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | package com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.transport.action.addpolicy 17 | 18 | import com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.transport.action.ISMStatusResponse 19 | import org.elasticsearch.action.ActionType 20 | 21 | class AddPolicyAction private constructor() : ActionType(NAME, ::ISMStatusResponse) { 22 | companion object { 23 | val INSTANCE = AddPolicyAction() 24 | val NAME = "cluster:admin/opendistro/ism/managedindex/add" 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/kotlin/com/amazon/opendistroforelasticsearch/indexmanagement/indexstatemanagement/transport/action/addpolicy/AddPolicyRequest.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | package com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.transport.action.addpolicy 17 | 18 | import org.elasticsearch.action.ActionRequest 19 | import org.elasticsearch.action.ActionRequestValidationException 20 | import org.elasticsearch.action.ValidateActions 21 | import org.elasticsearch.common.io.stream.StreamInput 22 | import org.elasticsearch.common.io.stream.StreamOutput 23 | import java.io.IOException 24 | 25 | class AddPolicyRequest : ActionRequest { 26 | 27 | val indices: List 28 | val policyID: String 29 | 30 | constructor( 31 | indices: List, 32 | policyID: String 33 | ) : super() { 34 | this.indices = indices 35 | this.policyID = policyID 36 | } 37 | 38 | @Throws(IOException::class) 39 | constructor(sin: StreamInput) : this( 40 | indices = sin.readStringList(), 41 | policyID = sin.readString() 42 | ) 43 | 44 | override fun validate(): ActionRequestValidationException? { 45 | var validationException: ActionRequestValidationException? = null 46 | if (indices.isEmpty()) { 47 | validationException = ValidateActions.addValidationError("Missing indices", validationException) 48 | } 49 | return validationException 50 | } 51 | 52 | @Throws(IOException::class) 53 | override fun writeTo(out: StreamOutput) { 54 | out.writeStringCollection(indices) 55 | out.writeString(policyID) 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/main/kotlin/com/amazon/opendistroforelasticsearch/indexmanagement/indexstatemanagement/transport/action/changepolicy/ChangePolicyAction.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | package com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.transport.action.changepolicy 17 | 18 | import com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.transport.action.ISMStatusResponse 19 | import org.elasticsearch.action.ActionType 20 | 21 | class ChangePolicyAction private constructor() : ActionType(NAME, ::ISMStatusResponse) { 22 | companion object { 23 | val INSTANCE = ChangePolicyAction() 24 | val NAME = "cluster:admin/opendistro/ism/managedindex/change" 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/kotlin/com/amazon/opendistroforelasticsearch/indexmanagement/indexstatemanagement/transport/action/changepolicy/ChangePolicyRequest.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | package com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.transport.action.changepolicy 17 | 18 | import com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.model.ChangePolicy 19 | import org.elasticsearch.action.ActionRequest 20 | import org.elasticsearch.action.ActionRequestValidationException 21 | import org.elasticsearch.action.ValidateActions 22 | import org.elasticsearch.common.io.stream.StreamInput 23 | import org.elasticsearch.common.io.stream.StreamOutput 24 | import java.io.IOException 25 | 26 | class ChangePolicyRequest : ActionRequest { 27 | 28 | val indices: List 29 | val changePolicy: ChangePolicy 30 | 31 | constructor( 32 | indices: List, 33 | changePolicy: ChangePolicy 34 | ) : super() { 35 | this.indices = indices 36 | this.changePolicy = changePolicy 37 | } 38 | 39 | @Throws(IOException::class) 40 | constructor(sin: StreamInput) : this( 41 | indices = sin.readStringList(), 42 | changePolicy = ChangePolicy(sin) 43 | ) 44 | 45 | override fun validate(): ActionRequestValidationException? { 46 | var validationException: ActionRequestValidationException? = null 47 | if (indices.isEmpty()) { 48 | validationException = ValidateActions.addValidationError("Missing indices", validationException) 49 | } 50 | return validationException 51 | } 52 | 53 | @Throws(IOException::class) 54 | override fun writeTo(out: StreamOutput) { 55 | out.writeStringCollection(indices) 56 | changePolicy.writeTo(out) 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/main/kotlin/com/amazon/opendistroforelasticsearch/indexmanagement/indexstatemanagement/transport/action/deletepolicy/DeletePolicyAction.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | package com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.transport.action.deletepolicy 17 | 18 | import org.elasticsearch.action.ActionType 19 | import org.elasticsearch.action.delete.DeleteResponse 20 | 21 | class DeletePolicyAction private constructor() : ActionType(NAME, ::DeleteResponse) { 22 | companion object { 23 | val INSTANCE = DeletePolicyAction() 24 | val NAME = "cluster:admin/opendistro/ism/policy/delete" 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/kotlin/com/amazon/opendistroforelasticsearch/indexmanagement/indexstatemanagement/transport/action/deletepolicy/DeletePolicyRequest.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | package com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.transport.action.deletepolicy 17 | 18 | import org.elasticsearch.action.ActionRequest 19 | import org.elasticsearch.action.ActionRequestValidationException 20 | import org.elasticsearch.action.ValidateActions 21 | import org.elasticsearch.action.support.WriteRequest 22 | import org.elasticsearch.common.io.stream.StreamInput 23 | import org.elasticsearch.common.io.stream.StreamOutput 24 | import java.io.IOException 25 | 26 | class DeletePolicyRequest : ActionRequest { 27 | 28 | val policyID: String 29 | val refreshPolicy: WriteRequest.RefreshPolicy 30 | 31 | constructor( 32 | policyID: String, 33 | refreshPolicy: WriteRequest.RefreshPolicy 34 | ) : super() { 35 | this.policyID = policyID 36 | this.refreshPolicy = refreshPolicy 37 | } 38 | 39 | @Throws(IOException::class) 40 | constructor(sin: StreamInput) : this( 41 | policyID = sin.readString(), 42 | refreshPolicy = sin.readEnum(WriteRequest.RefreshPolicy::class.java) 43 | ) 44 | 45 | override fun validate(): ActionRequestValidationException? { 46 | var validationException: ActionRequestValidationException? = null 47 | if (policyID.isBlank()) { 48 | validationException = ValidateActions.addValidationError( 49 | "Missing policy ID", 50 | validationException 51 | ) 52 | } 53 | return validationException 54 | } 55 | 56 | @Throws(IOException::class) 57 | override fun writeTo(out: StreamOutput) { 58 | out.writeString(policyID) 59 | out.writeEnum(refreshPolicy) 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/main/kotlin/com/amazon/opendistroforelasticsearch/indexmanagement/indexstatemanagement/transport/action/deletepolicy/TransportDeletePolicyAction.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | package com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.transport.action.deletepolicy 17 | 18 | import com.amazon.opendistroforelasticsearch.indexmanagement.IndexManagementPlugin 19 | import org.elasticsearch.action.ActionListener 20 | import org.elasticsearch.action.delete.DeleteRequest 21 | import org.elasticsearch.action.delete.DeleteResponse 22 | import org.elasticsearch.action.support.ActionFilters 23 | import org.elasticsearch.action.support.HandledTransportAction 24 | import org.elasticsearch.client.node.NodeClient 25 | import org.elasticsearch.common.inject.Inject 26 | import org.elasticsearch.tasks.Task 27 | import org.elasticsearch.transport.TransportService 28 | 29 | class TransportDeletePolicyAction @Inject constructor( 30 | val client: NodeClient, 31 | transportService: TransportService, 32 | actionFilters: ActionFilters 33 | ) : HandledTransportAction( 34 | DeletePolicyAction.NAME, transportService, actionFilters, ::DeletePolicyRequest 35 | ) { 36 | override fun doExecute(task: Task, request: DeletePolicyRequest, listener: ActionListener) { 37 | val deleteRequest = DeleteRequest(IndexManagementPlugin.INDEX_MANAGEMENT_INDEX, request.policyID) 38 | .setRefreshPolicy(request.refreshPolicy) 39 | 40 | client.delete(deleteRequest, listener) 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/kotlin/com/amazon/opendistroforelasticsearch/indexmanagement/indexstatemanagement/transport/action/explain/ExplainAction.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | package com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.transport.action.explain 17 | 18 | import org.elasticsearch.action.ActionType 19 | 20 | class ExplainAction private constructor() : ActionType(NAME, ::ExplainResponse) { 21 | companion object { 22 | val INSTANCE = ExplainAction() 23 | val NAME = "cluster:admin/opendistro/ism/managedindex/explain" 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/kotlin/com/amazon/opendistroforelasticsearch/indexmanagement/indexstatemanagement/transport/action/explain/ExplainRequest.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | package com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.transport.action.explain 17 | 18 | import com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.model.SearchParams 19 | import org.elasticsearch.action.ActionRequest 20 | import org.elasticsearch.action.ActionRequestValidationException 21 | import org.elasticsearch.common.io.stream.StreamInput 22 | import org.elasticsearch.common.io.stream.StreamOutput 23 | import org.elasticsearch.common.unit.TimeValue 24 | import java.io.IOException 25 | 26 | class ExplainRequest : ActionRequest { 27 | 28 | val indices: List 29 | val local: Boolean 30 | val masterTimeout: TimeValue 31 | val searchParams: SearchParams 32 | 33 | constructor( 34 | indices: List, 35 | local: Boolean, 36 | masterTimeout: TimeValue, 37 | searchParams: SearchParams 38 | ) : super() { 39 | this.indices = indices 40 | this.local = local 41 | this.masterTimeout = masterTimeout 42 | this.searchParams = searchParams 43 | } 44 | 45 | @Throws(IOException::class) 46 | constructor(sin: StreamInput) : this( 47 | indices = sin.readStringList(), 48 | local = sin.readBoolean(), 49 | masterTimeout = sin.readTimeValue(), 50 | searchParams = SearchParams(sin) 51 | ) 52 | 53 | override fun validate(): ActionRequestValidationException? { 54 | return null 55 | } 56 | 57 | @Throws(IOException::class) 58 | override fun writeTo(out: StreamOutput) { 59 | out.writeStringCollection(indices) 60 | out.writeBoolean(local) 61 | out.writeTimeValue(masterTimeout) 62 | searchParams.writeTo(out) 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /src/main/kotlin/com/amazon/opendistroforelasticsearch/indexmanagement/indexstatemanagement/transport/action/getpolicy/GetPoliciesAction.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | package com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.transport.action.getpolicy 17 | 18 | import org.elasticsearch.action.ActionType 19 | 20 | class GetPoliciesAction private constructor() : ActionType(NAME, ::GetPoliciesResponse) { 21 | companion object { 22 | val INSTANCE = GetPoliciesAction() 23 | val NAME = "cluster:admin/opendistro/ism/policy/search" 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/kotlin/com/amazon/opendistroforelasticsearch/indexmanagement/indexstatemanagement/transport/action/getpolicy/GetPoliciesRequest.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | package com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.transport.action.getpolicy 17 | 18 | import com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.model.SearchParams 19 | import org.elasticsearch.action.ActionRequest 20 | import org.elasticsearch.action.ActionRequestValidationException 21 | import org.elasticsearch.common.io.stream.StreamInput 22 | import org.elasticsearch.common.io.stream.StreamOutput 23 | import java.io.IOException 24 | 25 | class GetPoliciesRequest : ActionRequest { 26 | 27 | val searchParams: SearchParams 28 | 29 | constructor( 30 | searchParams: SearchParams 31 | ) : super() { 32 | this.searchParams = searchParams 33 | } 34 | 35 | @Throws(IOException::class) 36 | constructor(sin: StreamInput) : this( 37 | searchParams = SearchParams(sin) 38 | ) 39 | 40 | override fun validate(): ActionRequestValidationException? { 41 | return null 42 | } 43 | 44 | @Throws(IOException::class) 45 | override fun writeTo(out: StreamOutput) { 46 | searchParams.writeTo(out) 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/main/kotlin/com/amazon/opendistroforelasticsearch/indexmanagement/indexstatemanagement/transport/action/getpolicy/GetPolicyAction.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | package com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.transport.action.getpolicy 17 | 18 | import org.elasticsearch.action.ActionType 19 | 20 | class GetPolicyAction private constructor() : ActionType(NAME, ::GetPolicyResponse) { 21 | companion object { 22 | val INSTANCE = GetPolicyAction() 23 | val NAME = "cluster:admin/opendistro/ism/policy/get" 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/kotlin/com/amazon/opendistroforelasticsearch/indexmanagement/indexstatemanagement/transport/action/getpolicy/GetPolicyRequest.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | package com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.transport.action.getpolicy 17 | 18 | import org.elasticsearch.action.ActionRequest 19 | import org.elasticsearch.action.ActionRequestValidationException 20 | import org.elasticsearch.action.ValidateActions 21 | import org.elasticsearch.common.io.stream.StreamInput 22 | import org.elasticsearch.common.io.stream.StreamOutput 23 | import org.elasticsearch.search.fetch.subphase.FetchSourceContext 24 | import java.io.IOException 25 | 26 | class GetPolicyRequest : ActionRequest { 27 | 28 | val policyID: String 29 | val version: Long 30 | val fetchSrcContext: FetchSourceContext 31 | 32 | constructor( 33 | policyID: String, 34 | version: Long, 35 | fetchSrcContext: FetchSourceContext 36 | ) : super() { 37 | this.policyID = policyID 38 | this.version = version 39 | this.fetchSrcContext = fetchSrcContext 40 | } 41 | 42 | @Throws(IOException::class) 43 | constructor(sin: StreamInput) : this( 44 | policyID = sin.readString(), 45 | version = sin.readLong(), 46 | fetchSrcContext = FetchSourceContext(sin) 47 | ) 48 | 49 | override fun validate(): ActionRequestValidationException? { 50 | var validationException: ActionRequestValidationException? = null 51 | if (policyID.isBlank()) { 52 | validationException = ValidateActions.addValidationError( 53 | "Missing policy ID", 54 | validationException 55 | ) 56 | } 57 | return validationException 58 | } 59 | 60 | @Throws(IOException::class) 61 | override fun writeTo(out: StreamOutput) { 62 | out.writeString(policyID) 63 | out.writeLong(version) 64 | fetchSrcContext.writeTo(out) 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/main/kotlin/com/amazon/opendistroforelasticsearch/indexmanagement/indexstatemanagement/transport/action/indexpolicy/IndexPolicyAction.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | package com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.transport.action.indexpolicy 17 | 18 | import org.elasticsearch.action.ActionType 19 | 20 | class IndexPolicyAction private constructor() : ActionType(NAME, ::IndexPolicyResponse) { 21 | companion object { 22 | val INSTANCE = IndexPolicyAction() 23 | val NAME = "cluster:admin/opendistro/ism/policy/write" 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/kotlin/com/amazon/opendistroforelasticsearch/indexmanagement/indexstatemanagement/transport/action/removepolicy/RemovePolicyAction.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | package com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.transport.action.removepolicy 17 | 18 | import com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.transport.action.ISMStatusResponse 19 | import org.elasticsearch.action.ActionType 20 | 21 | class RemovePolicyAction private constructor() : ActionType(NAME, ::ISMStatusResponse) { 22 | companion object { 23 | val INSTANCE = RemovePolicyAction() 24 | val NAME = "cluster:admin/opendistro/ism/managedindex/remove" 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/kotlin/com/amazon/opendistroforelasticsearch/indexmanagement/indexstatemanagement/transport/action/removepolicy/RemovePolicyRequest.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | package com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.transport.action.removepolicy 17 | 18 | import org.elasticsearch.action.ActionRequest 19 | import org.elasticsearch.action.ActionRequestValidationException 20 | import org.elasticsearch.action.ValidateActions 21 | import org.elasticsearch.common.io.stream.StreamInput 22 | import org.elasticsearch.common.io.stream.StreamOutput 23 | import java.io.IOException 24 | 25 | class RemovePolicyRequest : ActionRequest { 26 | 27 | val indices: List 28 | 29 | constructor( 30 | indices: List 31 | ) : super() { 32 | this.indices = indices 33 | } 34 | 35 | @Throws(IOException::class) 36 | constructor(sin: StreamInput) : this( 37 | indices = sin.readStringList() 38 | ) 39 | 40 | override fun validate(): ActionRequestValidationException? { 41 | var validationException: ActionRequestValidationException? = null 42 | if (indices.isEmpty()) { 43 | validationException = ValidateActions.addValidationError("Missing indices", validationException) 44 | } 45 | return validationException 46 | } 47 | 48 | @Throws(IOException::class) 49 | override fun writeTo(out: StreamOutput) { 50 | out.writeStringCollection(indices) 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/main/kotlin/com/amazon/opendistroforelasticsearch/indexmanagement/indexstatemanagement/transport/action/retryfailedmanagedindex/RetryFailedManagedIndexAction.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | package com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.transport.action.retryfailedmanagedindex 17 | 18 | import com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.transport.action.ISMStatusResponse 19 | import org.elasticsearch.action.ActionType 20 | 21 | class RetryFailedManagedIndexAction private constructor() : ActionType(NAME, ::ISMStatusResponse) { 22 | companion object { 23 | val INSTANCE = RetryFailedManagedIndexAction() 24 | val NAME = "cluster:admin/opendistro/ism/managedindex/retry" 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/kotlin/com/amazon/opendistroforelasticsearch/indexmanagement/indexstatemanagement/transport/action/retryfailedmanagedindex/RetryFailedManagedIndexRequest.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | package com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.transport.action.retryfailedmanagedindex 17 | 18 | import org.elasticsearch.action.ActionRequest 19 | import org.elasticsearch.action.ActionRequestValidationException 20 | import org.elasticsearch.action.ValidateActions 21 | import org.elasticsearch.common.io.stream.StreamInput 22 | import org.elasticsearch.common.io.stream.StreamOutput 23 | import org.elasticsearch.common.unit.TimeValue 24 | import java.io.IOException 25 | 26 | class RetryFailedManagedIndexRequest : ActionRequest { 27 | 28 | val indices: List 29 | val startState: String? 30 | val masterTimeout: TimeValue 31 | 32 | constructor( 33 | indices: List, 34 | startState: String?, 35 | masterTimeout: TimeValue 36 | ) : super() { 37 | this.indices = indices 38 | this.startState = startState 39 | this.masterTimeout = masterTimeout 40 | } 41 | 42 | @Throws(IOException::class) 43 | constructor(sin: StreamInput) : this( 44 | indices = sin.readStringList(), 45 | startState = sin.readOptionalString(), 46 | masterTimeout = sin.readTimeValue() 47 | ) 48 | 49 | override fun validate(): ActionRequestValidationException? { 50 | var validationException: ActionRequestValidationException? = null 51 | if (indices.isEmpty()) { 52 | validationException = ValidateActions.addValidationError("Missing indices", validationException) 53 | } 54 | return validationException 55 | } 56 | 57 | @Throws(IOException::class) 58 | override fun writeTo(out: StreamOutput) { 59 | out.writeStringCollection(indices) 60 | out.writeOptionalString(startState) 61 | out.writeTimeValue(masterTimeout) 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /src/main/kotlin/com/amazon/opendistroforelasticsearch/indexmanagement/indexstatemanagement/transport/action/updateindexmetadata/UpdateManagedIndexMetaDataAction.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | package com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.transport.action.updateindexmetadata 17 | 18 | import org.elasticsearch.action.ActionType 19 | import org.elasticsearch.action.support.master.AcknowledgedResponse 20 | import org.elasticsearch.common.io.stream.Writeable 21 | 22 | class UpdateManagedIndexMetaDataAction : ActionType(NAME, reader) { 23 | 24 | companion object { 25 | const val NAME = "cluster:admin/ism/update/managedindexmetadata" 26 | val INSTANCE = UpdateManagedIndexMetaDataAction() 27 | 28 | val reader = Writeable.Reader { AcknowledgedResponse(it) } 29 | } 30 | 31 | override fun getResponseReader(): Writeable.Reader = reader 32 | } 33 | -------------------------------------------------------------------------------- /src/main/kotlin/com/amazon/opendistroforelasticsearch/indexmanagement/indexstatemanagement/util/DestinationType.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | package com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.util 17 | 18 | /** 19 | * Temporary import from alerting, this will be removed once we pull notifications out of 20 | * alerting so all plugins can consume and use. 21 | */ 22 | enum class DestinationType(val value: String) { 23 | CHIME("chime"), 24 | SLACK("slack"), 25 | CUSTOM_WEBHOOK("custom_webhook"), 26 | TEST_ACTION("test_action") 27 | } 28 | -------------------------------------------------------------------------------- /src/main/kotlin/com/amazon/opendistroforelasticsearch/indexmanagement/refreshanalyzer/RefreshSearchAnalyzerAction.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | package com.amazon.opendistroforelasticsearch.indexmanagement.refreshanalyzer 17 | 18 | import org.elasticsearch.action.ActionType 19 | import org.elasticsearch.common.io.stream.Writeable 20 | 21 | class RefreshSearchAnalyzerAction : ActionType(NAME, reader) { 22 | companion object { 23 | const val NAME = "indices:admin/refresh_search_analyzers" 24 | val INSTANCE = RefreshSearchAnalyzerAction() 25 | val reader = Writeable.Reader { inp -> RefreshSearchAnalyzerResponse(inp) } 26 | } 27 | 28 | override fun getResponseReader(): Writeable.Reader = reader 29 | } 30 | -------------------------------------------------------------------------------- /src/main/kotlin/com/amazon/opendistroforelasticsearch/indexmanagement/refreshanalyzer/RefreshSearchAnalyzerRequest.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | package com.amazon.opendistroforelasticsearch.indexmanagement.refreshanalyzer 17 | 18 | import org.elasticsearch.action.support.broadcast.BroadcastRequest 19 | import org.elasticsearch.common.io.stream.StreamInput 20 | import java.io.IOException 21 | 22 | class RefreshSearchAnalyzerRequest : BroadcastRequest { 23 | @Suppress("SpreadOperator") 24 | constructor(vararg indices: String) : super(*indices) 25 | 26 | @Throws(IOException::class) 27 | constructor(inp: StreamInput) : super(inp) 28 | } 29 | -------------------------------------------------------------------------------- /src/main/kotlin/com/amazon/opendistroforelasticsearch/indexmanagement/refreshanalyzer/RefreshSearchAnalyzerShardResponse.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | package com.amazon.opendistroforelasticsearch.indexmanagement.refreshanalyzer 17 | 18 | import org.elasticsearch.action.support.broadcast.BroadcastShardResponse 19 | import org.elasticsearch.common.io.stream.StreamInput 20 | import org.elasticsearch.common.io.stream.StreamOutput 21 | import org.elasticsearch.index.shard.ShardId 22 | import java.io.IOException 23 | 24 | class RefreshSearchAnalyzerShardResponse : BroadcastShardResponse { 25 | var reloadedAnalyzers: List 26 | 27 | constructor(si: StreamInput) : super(si) { 28 | reloadedAnalyzers = si.readStringArray().toList() 29 | } 30 | 31 | constructor(shardId: ShardId, reloadedAnalyzers: List) : super(shardId) { 32 | this.reloadedAnalyzers = reloadedAnalyzers 33 | } 34 | 35 | @Throws(IOException::class) 36 | override fun writeTo(out: StreamOutput) { 37 | super.writeTo(out) 38 | out.writeStringArray(reloadedAnalyzers.toTypedArray()) 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/kotlin/com/amazon/opendistroforelasticsearch/indexmanagement/rollup/action/delete/DeleteRollupAction.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | package com.amazon.opendistroforelasticsearch.indexmanagement.rollup.action.delete 17 | 18 | import org.elasticsearch.action.ActionType 19 | import org.elasticsearch.action.delete.DeleteResponse 20 | 21 | class DeleteRollupAction private constructor() : ActionType(NAME, ::DeleteResponse) { 22 | companion object { 23 | val INSTANCE = DeleteRollupAction() 24 | val NAME = "cluster:admin/opendistro/rollup/delete" 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/kotlin/com/amazon/opendistroforelasticsearch/indexmanagement/rollup/action/delete/DeleteRollupRequest.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | package com.amazon.opendistroforelasticsearch.indexmanagement.rollup.action.delete 17 | 18 | import org.elasticsearch.action.ActionRequestValidationException 19 | import org.elasticsearch.action.ValidateActions.addValidationError 20 | import org.elasticsearch.action.delete.DeleteRequest 21 | import org.elasticsearch.common.io.stream.StreamInput 22 | import org.elasticsearch.common.io.stream.StreamOutput 23 | import java.io.IOException 24 | 25 | class DeleteRollupRequest : DeleteRequest { 26 | 27 | @Throws(IOException::class) 28 | constructor(sin: StreamInput) : super(sin) 29 | 30 | constructor(id: String) { 31 | super.id(id) 32 | } 33 | 34 | override fun validate(): ActionRequestValidationException? { 35 | var validationException: ActionRequestValidationException? = null 36 | if (super.id().isBlank()) { 37 | validationException = addValidationError("id is missing", validationException) 38 | } 39 | return validationException 40 | } 41 | 42 | @Throws(IOException::class) 43 | override fun writeTo(out: StreamOutput) { 44 | super.writeTo(out) 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/kotlin/com/amazon/opendistroforelasticsearch/indexmanagement/rollup/action/delete/TransportDeleteRollupAction.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | package com.amazon.opendistroforelasticsearch.indexmanagement.rollup.action.delete 17 | 18 | import com.amazon.opendistroforelasticsearch.indexmanagement.IndexManagementPlugin.Companion.INDEX_MANAGEMENT_INDEX 19 | import org.elasticsearch.action.ActionListener 20 | import org.elasticsearch.action.delete.DeleteRequest 21 | import org.elasticsearch.action.delete.DeleteResponse 22 | import org.elasticsearch.action.support.ActionFilters 23 | import org.elasticsearch.action.support.HandledTransportAction 24 | import org.elasticsearch.client.Client 25 | import org.elasticsearch.common.inject.Inject 26 | import org.elasticsearch.tasks.Task 27 | import org.elasticsearch.transport.TransportService 28 | 29 | class TransportDeleteRollupAction @Inject constructor( 30 | transportService: TransportService, 31 | val client: Client, 32 | actionFilters: ActionFilters 33 | ) : HandledTransportAction( 34 | DeleteRollupAction.NAME, transportService, actionFilters, ::DeleteRollupRequest 35 | ) { 36 | 37 | override fun doExecute(task: Task, request: DeleteRollupRequest, actionListener: ActionListener) { 38 | val deleteRequest = DeleteRequest(INDEX_MANAGEMENT_INDEX, request.id()) 39 | .setRefreshPolicy(request.refreshPolicy) 40 | client.delete(deleteRequest, actionListener) 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/kotlin/com/amazon/opendistroforelasticsearch/indexmanagement/rollup/action/explain/ExplainRollupAction.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | package com.amazon.opendistroforelasticsearch.indexmanagement.rollup.action.explain 17 | 18 | import org.elasticsearch.action.ActionType 19 | 20 | class ExplainRollupAction private constructor() : ActionType(NAME, ::ExplainRollupResponse) { 21 | companion object { 22 | val INSTANCE = ExplainRollupAction() 23 | val NAME = "cluster:admin/opendistro/rollup/explain" 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/kotlin/com/amazon/opendistroforelasticsearch/indexmanagement/rollup/action/explain/ExplainRollupRequest.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | package com.amazon.opendistroforelasticsearch.indexmanagement.rollup.action.explain 17 | 18 | import org.elasticsearch.action.ActionRequest 19 | import org.elasticsearch.action.ActionRequestValidationException 20 | import org.elasticsearch.action.ValidateActions.addValidationError 21 | import org.elasticsearch.common.io.stream.StreamInput 22 | import org.elasticsearch.common.io.stream.StreamOutput 23 | import java.io.IOException 24 | 25 | class ExplainRollupRequest : ActionRequest { 26 | 27 | val rollupIDs: List 28 | 29 | @Throws(IOException::class) 30 | constructor(sin: StreamInput) : this(rollupIDs = sin.readStringArray().toList()) 31 | 32 | constructor(rollupIDs: List) { 33 | this.rollupIDs = rollupIDs 34 | } 35 | 36 | override fun validate(): ActionRequestValidationException? { 37 | var validationException: ActionRequestValidationException? = null 38 | if (rollupIDs.isEmpty()) { 39 | validationException = addValidationError("Missing rollupID", validationException) 40 | } 41 | return validationException 42 | } 43 | 44 | @Throws(IOException::class) 45 | override fun writeTo(out: StreamOutput) { 46 | out.writeStringArray(rollupIDs.toTypedArray()) 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/main/kotlin/com/amazon/opendistroforelasticsearch/indexmanagement/rollup/action/get/GetRollupAction.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | package com.amazon.opendistroforelasticsearch.indexmanagement.rollup.action.get 17 | 18 | import org.elasticsearch.action.ActionType 19 | 20 | class GetRollupAction private constructor() : ActionType(NAME, ::GetRollupResponse) { 21 | companion object { 22 | val INSTANCE = GetRollupAction() 23 | val NAME = "cluster:admin/opendistro/rollup/get" 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/kotlin/com/amazon/opendistroforelasticsearch/indexmanagement/rollup/action/get/GetRollupsAction.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | package com.amazon.opendistroforelasticsearch.indexmanagement.rollup.action.get 17 | 18 | import org.elasticsearch.action.ActionType 19 | 20 | class GetRollupsAction private constructor() : ActionType(NAME, ::GetRollupsResponse) { 21 | companion object { 22 | val INSTANCE = GetRollupsAction() 23 | val NAME = "cluster:admin/opendistro/rollup/search" 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/kotlin/com/amazon/opendistroforelasticsearch/indexmanagement/rollup/action/index/IndexRollupAction.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | package com.amazon.opendistroforelasticsearch.indexmanagement.rollup.action.index 17 | 18 | import org.elasticsearch.action.ActionType 19 | 20 | class IndexRollupAction private constructor() : ActionType(NAME, ::IndexRollupResponse) { 21 | companion object { 22 | val INSTANCE = IndexRollupAction() 23 | val NAME = "cluster:admin/opendistro/rollup/index" 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/kotlin/com/amazon/opendistroforelasticsearch/indexmanagement/rollup/action/mapping/UpdateRollupMappingAction.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | package com.amazon.opendistroforelasticsearch.indexmanagement.rollup.action.mapping 17 | 18 | import org.elasticsearch.action.ActionType 19 | import org.elasticsearch.action.support.master.AcknowledgedResponse 20 | import org.elasticsearch.common.io.stream.Writeable 21 | 22 | class UpdateRollupMappingAction : ActionType(NAME, reader) { 23 | 24 | companion object { 25 | const val NAME = "cluster:admin/opendistro/rollup/mapping/update" 26 | val INSTANCE = UpdateRollupMappingAction() 27 | val reader = Writeable.Reader { AcknowledgedResponse(it) } 28 | } 29 | 30 | override fun getResponseReader(): Writeable.Reader = reader 31 | } 32 | -------------------------------------------------------------------------------- /src/main/kotlin/com/amazon/opendistroforelasticsearch/indexmanagement/rollup/action/mapping/UpdateRollupMappingRequest.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | package com.amazon.opendistroforelasticsearch.indexmanagement.rollup.action.mapping 17 | 18 | import com.amazon.opendistroforelasticsearch.indexmanagement.rollup.model.Rollup 19 | import org.elasticsearch.action.ActionRequestValidationException 20 | import org.elasticsearch.action.support.master.AcknowledgedRequest 21 | import org.elasticsearch.common.io.stream.StreamInput 22 | import org.elasticsearch.common.io.stream.StreamOutput 23 | 24 | class UpdateRollupMappingRequest : AcknowledgedRequest { 25 | val rollup: Rollup 26 | 27 | constructor(sin: StreamInput) : super(sin) { 28 | rollup = Rollup(sin) 29 | } 30 | 31 | constructor(rollup: Rollup) { 32 | this.rollup = rollup 33 | } 34 | 35 | override fun validate(): ActionRequestValidationException? { 36 | return null 37 | } 38 | 39 | override fun writeTo(out: StreamOutput) { 40 | super.writeTo(out) 41 | rollup.writeTo(out) 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/kotlin/com/amazon/opendistroforelasticsearch/indexmanagement/rollup/action/start/StartRollupAction.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | package com.amazon.opendistroforelasticsearch.indexmanagement.rollup.action.start 17 | 18 | import org.elasticsearch.action.ActionType 19 | import org.elasticsearch.action.support.master.AcknowledgedResponse 20 | 21 | class StartRollupAction private constructor() : ActionType(NAME, ::AcknowledgedResponse) { 22 | companion object { 23 | val INSTANCE = StartRollupAction() 24 | val NAME = "cluster:admin/opendistro/rollup/start" 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/kotlin/com/amazon/opendistroforelasticsearch/indexmanagement/rollup/action/start/StartRollupRequest.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | package com.amazon.opendistroforelasticsearch.indexmanagement.rollup.action.start 17 | 18 | import org.elasticsearch.action.ActionRequestValidationException 19 | import org.elasticsearch.action.ValidateActions.addValidationError 20 | import org.elasticsearch.action.update.UpdateRequest 21 | import org.elasticsearch.common.io.stream.StreamInput 22 | import org.elasticsearch.common.io.stream.StreamOutput 23 | import java.io.IOException 24 | 25 | class StartRollupRequest : UpdateRequest { 26 | 27 | @Throws(IOException::class) 28 | constructor(sin: StreamInput) : super(sin) 29 | 30 | constructor(id: String) { 31 | super.id(id) 32 | } 33 | 34 | override fun validate(): ActionRequestValidationException? { 35 | var validationException: ActionRequestValidationException? = null 36 | if (super.id().isEmpty()) { 37 | validationException = addValidationError("id is missing", validationException) 38 | } 39 | return validationException 40 | } 41 | 42 | @Throws(IOException::class) 43 | override fun writeTo(out: StreamOutput) { 44 | super.writeTo(out) 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/kotlin/com/amazon/opendistroforelasticsearch/indexmanagement/rollup/action/stop/StopRollupAction.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | package com.amazon.opendistroforelasticsearch.indexmanagement.rollup.action.stop 17 | 18 | import org.elasticsearch.action.ActionType 19 | import org.elasticsearch.action.support.master.AcknowledgedResponse 20 | 21 | class StopRollupAction private constructor() : ActionType(NAME, ::AcknowledgedResponse) { 22 | companion object { 23 | val INSTANCE = StopRollupAction() 24 | val NAME = "cluster:admin/opendistro/rollup/stop" 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/kotlin/com/amazon/opendistroforelasticsearch/indexmanagement/rollup/action/stop/StopRollupRequest.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | package com.amazon.opendistroforelasticsearch.indexmanagement.rollup.action.stop 17 | 18 | import org.elasticsearch.action.ActionRequestValidationException 19 | import org.elasticsearch.action.ValidateActions.addValidationError 20 | import org.elasticsearch.action.update.UpdateRequest 21 | import org.elasticsearch.common.io.stream.StreamInput 22 | import org.elasticsearch.common.io.stream.StreamOutput 23 | import java.io.IOException 24 | 25 | class StopRollupRequest : UpdateRequest { 26 | 27 | @Throws(IOException::class) 28 | constructor(sin: StreamInput) : super(sin) 29 | 30 | constructor(id: String) { 31 | super.id(id) 32 | } 33 | 34 | override fun validate(): ActionRequestValidationException? { 35 | var validationException: ActionRequestValidationException? = null 36 | if (super.id().isEmpty()) { 37 | validationException = addValidationError("id is missing", validationException) 38 | } 39 | return validationException 40 | } 41 | 42 | @Throws(IOException::class) 43 | override fun writeTo(out: StreamOutput) { 44 | super.writeTo(out) 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/kotlin/com/amazon/opendistroforelasticsearch/indexmanagement/rollup/model/ExplainRollup.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | package com.amazon.opendistroforelasticsearch.indexmanagement.rollup.model 17 | 18 | import org.elasticsearch.common.io.stream.StreamInput 19 | import org.elasticsearch.common.io.stream.StreamOutput 20 | import org.elasticsearch.common.io.stream.Writeable 21 | import org.elasticsearch.common.xcontent.ToXContent 22 | import org.elasticsearch.common.xcontent.ToXContentObject 23 | import org.elasticsearch.common.xcontent.XContentBuilder 24 | import java.io.IOException 25 | 26 | data class ExplainRollup( 27 | val metadataID: String? = null, 28 | val metadata: RollupMetadata? = null 29 | ) : ToXContentObject, Writeable { 30 | 31 | @Throws(IOException::class) 32 | constructor(sin: StreamInput) : this( 33 | metadataID = sin.readOptionalString(), 34 | metadata = if (sin.readBoolean()) RollupMetadata(sin) else null 35 | ) 36 | 37 | @Throws(IOException::class) 38 | override fun writeTo(out: StreamOutput) { 39 | out.writeOptionalString(metadataID) 40 | out.writeBoolean(metadata != null) 41 | metadata?.writeTo(out) 42 | } 43 | 44 | @Throws(IOException::class) 45 | override fun toXContent(builder: XContentBuilder, params: ToXContent.Params): XContentBuilder { 46 | return builder.startObject() 47 | .field(Rollup.METADATA_ID_FIELD, metadataID) 48 | .field(RollupMetadata.ROLLUP_METADATA_TYPE, metadata) 49 | .endObject() 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/main/kotlin/com/amazon/opendistroforelasticsearch/indexmanagement/rollup/model/RollupFieldMapping.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | package com.amazon.opendistroforelasticsearch.indexmanagement.rollup.model 17 | 18 | import com.amazon.opendistroforelasticsearch.indexmanagement.rollup.model.Rollup.Companion.DIMENSIONS_FIELD 19 | import com.amazon.opendistroforelasticsearch.indexmanagement.rollup.model.Rollup.Companion.METRICS_FIELD 20 | 21 | data class RollupFieldMapping(val fieldType: FieldType, val fieldName: String, val mappingType: String, var sourceType: String? = null) { 22 | 23 | fun sourceType(type: String?) { 24 | this.sourceType = type 25 | } 26 | 27 | override fun toString(): String { 28 | return "$fieldName.$mappingType" 29 | } 30 | 31 | fun toIssue(isFieldMissing: Boolean = false): String { 32 | return if (isFieldMissing || mappingType == UNKNOWN_MAPPING) return "missing field $fieldName" 33 | else when (fieldType) { 34 | FieldType.METRIC -> "missing $mappingType aggregation on $fieldName" 35 | else -> "missing $mappingType grouping on $fieldName" 36 | } 37 | } 38 | 39 | companion object { 40 | const val UNKNOWN_MAPPING = "unknown" 41 | enum class FieldType(val type: String) { 42 | DIMENSION(DIMENSIONS_FIELD), 43 | METRIC(METRICS_FIELD); 44 | 45 | override fun toString(): String { 46 | return type 47 | } 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/main/kotlin/com/amazon/opendistroforelasticsearch/indexmanagement/rollup/model/metric/Average.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | package com.amazon.opendistroforelasticsearch.indexmanagement.rollup.model.metric 17 | 18 | import org.elasticsearch.common.io.stream.StreamInput 19 | import org.elasticsearch.common.io.stream.StreamOutput 20 | import org.elasticsearch.common.xcontent.ToXContent 21 | import org.elasticsearch.common.xcontent.XContentBuilder 22 | import org.elasticsearch.common.xcontent.XContentParser 23 | import org.elasticsearch.common.xcontent.XContentParser.Token 24 | import org.elasticsearch.common.xcontent.XContentParserUtils.ensureExpectedToken 25 | 26 | class Average() : Metric(Type.AVERAGE) { 27 | constructor(sin: StreamInput) : this() 28 | 29 | override fun toXContent(builder: XContentBuilder, params: ToXContent.Params): XContentBuilder { 30 | return builder.startObject().startObject(Type.AVERAGE.type).endObject().endObject() 31 | } 32 | 33 | override fun writeTo(out: StreamOutput) {} // nothing to write 34 | 35 | override fun equals(other: Any?): Boolean { 36 | if (this === other) return true 37 | if (javaClass != other?.javaClass) return false 38 | return true 39 | } 40 | 41 | override fun hashCode(): Int = javaClass.hashCode() 42 | 43 | override fun toString(): String = "Average()" 44 | 45 | companion object { 46 | fun parse(xcp: XContentParser): Average { 47 | ensureExpectedToken(Token.START_OBJECT, xcp.currentToken(), xcp) 48 | ensureExpectedToken(Token.END_OBJECT, xcp.nextToken(), xcp) 49 | return Average() 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/main/kotlin/com/amazon/opendistroforelasticsearch/indexmanagement/rollup/model/metric/Max.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | package com.amazon.opendistroforelasticsearch.indexmanagement.rollup.model.metric 17 | 18 | import org.elasticsearch.common.io.stream.StreamInput 19 | import org.elasticsearch.common.io.stream.StreamOutput 20 | import org.elasticsearch.common.xcontent.ToXContent 21 | import org.elasticsearch.common.xcontent.XContentBuilder 22 | import org.elasticsearch.common.xcontent.XContentParser 23 | import org.elasticsearch.common.xcontent.XContentParser.Token 24 | import org.elasticsearch.common.xcontent.XContentParserUtils.ensureExpectedToken 25 | 26 | class Max() : Metric(Type.MAX) { 27 | constructor(sin: StreamInput) : this() 28 | 29 | override fun toXContent(builder: XContentBuilder, params: ToXContent.Params): XContentBuilder { 30 | return builder.startObject().startObject(Type.MAX.type).endObject().endObject() 31 | } 32 | 33 | override fun writeTo(out: StreamOutput) {} // nothing to write 34 | 35 | override fun equals(other: Any?): Boolean { 36 | if (this === other) return true 37 | if (javaClass != other?.javaClass) return false 38 | return true 39 | } 40 | 41 | override fun hashCode(): Int = javaClass.hashCode() 42 | 43 | override fun toString(): String = "Max()" 44 | 45 | companion object { 46 | fun parse(xcp: XContentParser): Max { 47 | ensureExpectedToken(Token.START_OBJECT, xcp.currentToken(), xcp) 48 | ensureExpectedToken(Token.END_OBJECT, xcp.nextToken(), xcp) 49 | return Max() 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/main/kotlin/com/amazon/opendistroforelasticsearch/indexmanagement/rollup/model/metric/Metric.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | package com.amazon.opendistroforelasticsearch.indexmanagement.rollup.model.metric 17 | 18 | import org.elasticsearch.common.io.stream.Writeable 19 | import org.elasticsearch.common.xcontent.ToXContentObject 20 | import org.elasticsearch.common.xcontent.XContentParser 21 | import org.elasticsearch.common.xcontent.XContentParser.Token 22 | import org.elasticsearch.common.xcontent.XContentParserUtils.ensureExpectedToken 23 | import java.io.IOException 24 | 25 | abstract class Metric(val type: Type) : ToXContentObject, Writeable { 26 | 27 | enum class Type(val type: String) { 28 | AVERAGE("avg"), 29 | SUM("sum"), 30 | MAX("max"), 31 | MIN("min"), 32 | VALUE_COUNT("value_count"); 33 | 34 | override fun toString(): String { 35 | return type 36 | } 37 | } 38 | 39 | companion object { 40 | @Suppress("ComplexMethod") 41 | @JvmStatic 42 | @Throws(IOException::class) 43 | fun parse(xcp: XContentParser): Metric { 44 | var metric: Metric? = null 45 | ensureExpectedToken(Token.START_OBJECT, xcp.currentToken(), xcp) 46 | while (xcp.nextToken() != Token.END_OBJECT) { 47 | val fieldName = xcp.currentName() 48 | xcp.nextToken() 49 | 50 | metric = when (fieldName) { 51 | Type.AVERAGE.type -> Average.parse(xcp) 52 | Type.MAX.type -> Max.parse(xcp) 53 | Type.MIN.type -> Min.parse(xcp) 54 | Type.SUM.type -> Sum.parse(xcp) 55 | Type.VALUE_COUNT.type -> ValueCount.parse(xcp) 56 | else -> throw IllegalArgumentException("Invalid metric type [$fieldName] found in metrics") 57 | } 58 | } 59 | 60 | return requireNotNull(metric) { "Metric is null" } 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /src/main/kotlin/com/amazon/opendistroforelasticsearch/indexmanagement/rollup/model/metric/Min.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | package com.amazon.opendistroforelasticsearch.indexmanagement.rollup.model.metric 17 | 18 | import org.elasticsearch.common.io.stream.StreamInput 19 | import org.elasticsearch.common.io.stream.StreamOutput 20 | import org.elasticsearch.common.xcontent.ToXContent 21 | import org.elasticsearch.common.xcontent.XContentBuilder 22 | import org.elasticsearch.common.xcontent.XContentParser 23 | import org.elasticsearch.common.xcontent.XContentParser.Token 24 | import org.elasticsearch.common.xcontent.XContentParserUtils.ensureExpectedToken 25 | 26 | class Min() : Metric(Type.MIN) { 27 | constructor(sin: StreamInput) : this() 28 | 29 | override fun toXContent(builder: XContentBuilder, params: ToXContent.Params): XContentBuilder { 30 | return builder.startObject().startObject(Type.MIN.type).endObject().endObject() 31 | } 32 | 33 | override fun writeTo(out: StreamOutput) {} // nothing to write 34 | 35 | override fun equals(other: Any?): Boolean { 36 | if (this === other) return true 37 | if (javaClass != other?.javaClass) return false 38 | return true 39 | } 40 | 41 | override fun hashCode(): Int = javaClass.hashCode() 42 | 43 | override fun toString(): String = "Min()" 44 | 45 | companion object { 46 | fun parse(xcp: XContentParser): Min { 47 | ensureExpectedToken(Token.START_OBJECT, xcp.currentToken(), xcp) 48 | ensureExpectedToken(Token.END_OBJECT, xcp.nextToken(), xcp) 49 | return Min() 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/main/kotlin/com/amazon/opendistroforelasticsearch/indexmanagement/rollup/model/metric/Sum.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | package com.amazon.opendistroforelasticsearch.indexmanagement.rollup.model.metric 17 | 18 | import org.elasticsearch.common.io.stream.StreamInput 19 | import org.elasticsearch.common.io.stream.StreamOutput 20 | import org.elasticsearch.common.xcontent.ToXContent 21 | import org.elasticsearch.common.xcontent.XContentBuilder 22 | import org.elasticsearch.common.xcontent.XContentParser 23 | import org.elasticsearch.common.xcontent.XContentParser.Token 24 | import org.elasticsearch.common.xcontent.XContentParserUtils.ensureExpectedToken 25 | 26 | class Sum() : Metric(Type.SUM) { 27 | constructor(sin: StreamInput) : this() 28 | 29 | override fun toXContent(builder: XContentBuilder, params: ToXContent.Params): XContentBuilder { 30 | return builder.startObject().startObject(Type.SUM.type).endObject().endObject() 31 | } 32 | 33 | override fun writeTo(out: StreamOutput) {} // nothing to write 34 | 35 | override fun equals(other: Any?): Boolean { 36 | if (this === other) return true 37 | if (javaClass != other?.javaClass) return false 38 | return true 39 | } 40 | 41 | override fun hashCode(): Int = javaClass.hashCode() 42 | 43 | override fun toString(): String = "Sum()" 44 | 45 | companion object { 46 | fun parse(xcp: XContentParser): Sum { 47 | ensureExpectedToken(Token.START_OBJECT, xcp.currentToken(), xcp) 48 | ensureExpectedToken(Token.END_OBJECT, xcp.nextToken(), xcp) 49 | return Sum() 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/main/kotlin/com/amazon/opendistroforelasticsearch/indexmanagement/rollup/model/metric/ValueCount.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | package com.amazon.opendistroforelasticsearch.indexmanagement.rollup.model.metric 17 | 18 | import org.elasticsearch.common.io.stream.StreamInput 19 | import org.elasticsearch.common.io.stream.StreamOutput 20 | import org.elasticsearch.common.xcontent.ToXContent 21 | import org.elasticsearch.common.xcontent.XContentBuilder 22 | import org.elasticsearch.common.xcontent.XContentParser 23 | import org.elasticsearch.common.xcontent.XContentParser.Token 24 | import org.elasticsearch.common.xcontent.XContentParserUtils.ensureExpectedToken 25 | 26 | class ValueCount() : Metric(Type.VALUE_COUNT) { 27 | constructor(sin: StreamInput) : this() 28 | 29 | override fun toXContent(builder: XContentBuilder, params: ToXContent.Params): XContentBuilder { 30 | return builder.startObject().startObject(Type.VALUE_COUNT.type).endObject().endObject() 31 | } 32 | 33 | override fun writeTo(out: StreamOutput) {} // nothing to write 34 | 35 | override fun equals(other: Any?): Boolean { 36 | if (this === other) return true 37 | if (javaClass != other?.javaClass) return false 38 | return true 39 | } 40 | 41 | override fun hashCode(): Int = javaClass.hashCode() 42 | 43 | override fun toString(): String = "ValueCount()" 44 | 45 | companion object { 46 | fun parse(xcp: XContentParser): ValueCount { 47 | ensureExpectedToken(Token.START_OBJECT, xcp.currentToken(), xcp) 48 | ensureExpectedToken(Token.END_OBJECT, xcp.nextToken(), xcp) 49 | return ValueCount() 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/main/kotlin/com/amazon/opendistroforelasticsearch/indexmanagement/rollup/resthandler/RestDeleteRollupAction.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | package com.amazon.opendistroforelasticsearch.indexmanagement.rollup.resthandler 17 | 18 | import com.amazon.opendistroforelasticsearch.indexmanagement.IndexManagementPlugin.Companion.ROLLUP_JOBS_BASE_URI 19 | import com.amazon.opendistroforelasticsearch.indexmanagement.rollup.action.delete.DeleteRollupAction 20 | import com.amazon.opendistroforelasticsearch.indexmanagement.rollup.action.delete.DeleteRollupRequest 21 | import com.amazon.opendistroforelasticsearch.indexmanagement.util.REFRESH 22 | import org.elasticsearch.action.support.WriteRequest.RefreshPolicy 23 | import org.elasticsearch.client.node.NodeClient 24 | import org.elasticsearch.rest.BaseRestHandler 25 | import org.elasticsearch.rest.RestHandler.Route 26 | import org.elasticsearch.rest.RestRequest 27 | import org.elasticsearch.rest.RestRequest.Method.DELETE 28 | import org.elasticsearch.rest.action.RestToXContentListener 29 | import java.io.IOException 30 | 31 | class RestDeleteRollupAction : BaseRestHandler() { 32 | 33 | override fun routes(): List { 34 | return listOf( 35 | Route(DELETE, "$ROLLUP_JOBS_BASE_URI/{rollupID}") 36 | ) 37 | } 38 | 39 | override fun getName(): String = "opendistro_delete_rollup_action" 40 | 41 | @Throws(IOException::class) 42 | override fun prepareRequest(request: RestRequest, client: NodeClient): RestChannelConsumer { 43 | val rollupID = request.param("rollupID") 44 | val refreshPolicy = RefreshPolicy.parse(request.param(REFRESH, RefreshPolicy.IMMEDIATE.value)) 45 | return RestChannelConsumer { channel -> 46 | channel.newBuilder() 47 | val deleteRollupRequest = DeleteRollupRequest(rollupID) 48 | .setRefreshPolicy(refreshPolicy) 49 | client.execute(DeleteRollupAction.INSTANCE, deleteRollupRequest, RestToXContentListener(channel)) 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/main/kotlin/com/amazon/opendistroforelasticsearch/indexmanagement/rollup/resthandler/RestExplainRollupAction.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | package com.amazon.opendistroforelasticsearch.indexmanagement.rollup.resthandler 17 | 18 | import com.amazon.opendistroforelasticsearch.indexmanagement.IndexManagementPlugin.Companion.ROLLUP_JOBS_BASE_URI 19 | import com.amazon.opendistroforelasticsearch.indexmanagement.rollup.action.explain.ExplainRollupAction 20 | import com.amazon.opendistroforelasticsearch.indexmanagement.rollup.action.explain.ExplainRollupRequest 21 | import org.elasticsearch.client.node.NodeClient 22 | import org.elasticsearch.common.Strings 23 | import org.elasticsearch.rest.BaseRestHandler 24 | import org.elasticsearch.rest.RestHandler.Route 25 | import org.elasticsearch.rest.RestRequest 26 | import org.elasticsearch.rest.RestRequest.Method.GET 27 | import org.elasticsearch.rest.action.RestToXContentListener 28 | 29 | class RestExplainRollupAction : BaseRestHandler() { 30 | 31 | override fun routes(): List { 32 | return listOf(Route(GET, "$ROLLUP_JOBS_BASE_URI/{rollupID}/_explain")) 33 | } 34 | 35 | override fun getName(): String = "opendistro_explain_rollup_action" 36 | 37 | override fun prepareRequest(request: RestRequest, client: NodeClient): RestChannelConsumer { 38 | val rollupIDs: List = Strings.splitStringByCommaToArray(request.param("rollupID")).toList() 39 | if (rollupIDs.isEmpty()) { 40 | throw IllegalArgumentException("Missing rollupID") 41 | } 42 | val explainRequest = ExplainRollupRequest(rollupIDs) 43 | return RestChannelConsumer { channel -> 44 | client.execute(ExplainRollupAction.INSTANCE, explainRequest, RestToXContentListener(channel)) 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/main/kotlin/com/amazon/opendistroforelasticsearch/indexmanagement/rollup/resthandler/RestStartRollupAction.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | package com.amazon.opendistroforelasticsearch.indexmanagement.rollup.resthandler 17 | 18 | import com.amazon.opendistroforelasticsearch.indexmanagement.IndexManagementPlugin.Companion.ROLLUP_JOBS_BASE_URI 19 | import com.amazon.opendistroforelasticsearch.indexmanagement.rollup.action.start.StartRollupAction 20 | import com.amazon.opendistroforelasticsearch.indexmanagement.rollup.action.start.StartRollupRequest 21 | import com.amazon.opendistroforelasticsearch.indexmanagement.rollup.model.Rollup 22 | import org.elasticsearch.client.node.NodeClient 23 | import org.elasticsearch.rest.BaseRestHandler 24 | import org.elasticsearch.rest.RestHandler.Route 25 | import org.elasticsearch.rest.BaseRestHandler.RestChannelConsumer 26 | import org.elasticsearch.rest.RestRequest 27 | import org.elasticsearch.rest.RestRequest.Method.POST 28 | import org.elasticsearch.rest.action.RestToXContentListener 29 | import java.io.IOException 30 | 31 | class RestStartRollupAction : BaseRestHandler() { 32 | 33 | override fun routes(): List { 34 | return listOf( 35 | Route(POST, "$ROLLUP_JOBS_BASE_URI/{rollupID}/_start") 36 | ) 37 | } 38 | 39 | override fun getName(): String { 40 | return "opendistro_start_rollup_action" 41 | } 42 | 43 | @Throws(IOException::class) 44 | override fun prepareRequest(request: RestRequest, client: NodeClient): RestChannelConsumer { 45 | val id = request.param("rollupID", Rollup.NO_ID) 46 | val startRequest = StartRollupRequest(id) 47 | return RestChannelConsumer { channel -> 48 | client.execute(StartRollupAction.INSTANCE, startRequest, RestToXContentListener(channel)) 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/main/kotlin/com/amazon/opendistroforelasticsearch/indexmanagement/rollup/resthandler/RestStopRollupAction.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | package com.amazon.opendistroforelasticsearch.indexmanagement.rollup.resthandler 17 | 18 | import com.amazon.opendistroforelasticsearch.indexmanagement.IndexManagementPlugin.Companion.ROLLUP_JOBS_BASE_URI 19 | import com.amazon.opendistroforelasticsearch.indexmanagement.rollup.action.stop.StopRollupAction 20 | import com.amazon.opendistroforelasticsearch.indexmanagement.rollup.action.stop.StopRollupRequest 21 | import com.amazon.opendistroforelasticsearch.indexmanagement.rollup.model.Rollup 22 | import org.elasticsearch.client.node.NodeClient 23 | import org.elasticsearch.rest.BaseRestHandler 24 | import org.elasticsearch.rest.RestHandler.Route 25 | import org.elasticsearch.rest.BaseRestHandler.RestChannelConsumer 26 | import org.elasticsearch.rest.RestRequest 27 | import org.elasticsearch.rest.RestRequest.Method.POST 28 | import org.elasticsearch.rest.action.RestToXContentListener 29 | import java.io.IOException 30 | 31 | class RestStopRollupAction : BaseRestHandler() { 32 | 33 | override fun routes(): List { 34 | return listOf( 35 | Route(POST, "$ROLLUP_JOBS_BASE_URI/{rollupID}/_stop") 36 | ) 37 | } 38 | 39 | override fun getName(): String { 40 | return "opendistro_stop_rollup_action" 41 | } 42 | 43 | @Throws(IOException::class) 44 | override fun prepareRequest(request: RestRequest, client: NodeClient): RestChannelConsumer { 45 | val id = request.param("rollupID", Rollup.NO_ID) 46 | if (Rollup.NO_ID == id) { 47 | throw IllegalArgumentException("Missing rollup ID") 48 | } 49 | 50 | val stopRequest = StopRollupRequest(id) 51 | return RestChannelConsumer { channel -> 52 | client.execute(StopRollupAction.INSTANCE, stopRequest, RestToXContentListener(channel)) 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/main/kotlin/com/amazon/opendistroforelasticsearch/indexmanagement/util/IndexManagementException.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | package com.amazon.opendistroforelasticsearch.indexmanagement.util 17 | 18 | import org.elasticsearch.ElasticsearchException 19 | import org.elasticsearch.common.Strings 20 | import org.elasticsearch.common.ValidationException 21 | import org.elasticsearch.index.IndexNotFoundException 22 | import org.elasticsearch.rest.RestStatus 23 | import java.lang.IllegalArgumentException 24 | 25 | class IndexManagementException(message: String, val status: RestStatus, ex: Exception) : ElasticsearchException(message, ex) { 26 | 27 | override fun status(): RestStatus { 28 | return status 29 | } 30 | 31 | companion object { 32 | @JvmStatic 33 | fun wrap(ex: Exception): ElasticsearchException { 34 | 35 | var friendlyMsg = ex.message as String 36 | var status = RestStatus.INTERNAL_SERVER_ERROR 37 | when (ex) { 38 | is IndexNotFoundException -> { 39 | status = ex.status() 40 | friendlyMsg = "Configuration index not found" 41 | } 42 | is IllegalArgumentException -> { 43 | status = RestStatus.BAD_REQUEST 44 | friendlyMsg = ex.message as String 45 | } 46 | is ValidationException -> { 47 | status = RestStatus.BAD_REQUEST 48 | friendlyMsg = ex.message as String 49 | } 50 | else -> { 51 | if (!Strings.isNullOrEmpty(ex.message)) { 52 | friendlyMsg = ex.message as String 53 | } 54 | } 55 | } 56 | 57 | return IndexManagementException(friendlyMsg, status, Exception("${ex.javaClass.name}: ${ex.message}")) 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/main/kotlin/com/amazon/opendistroforelasticsearch/indexmanagement/util/OpenForTesting.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | package com.amazon.opendistroforelasticsearch.indexmanagement.util 17 | 18 | annotation class OpenForTesting 19 | -------------------------------------------------------------------------------- /src/main/kotlin/com/amazon/opendistroforelasticsearch/indexmanagement/util/RestHandlerUtils.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | @file:Suppress("TopLevelPropertyNaming", "MatchingDeclarationName") 17 | package com.amazon.opendistroforelasticsearch.indexmanagement.util 18 | 19 | const val _DOC = "_doc" 20 | const val _ID = "_id" 21 | const val NO_ID = "" 22 | const val _VERSION = "_version" 23 | const val _SEQ_NO = "_seq_no" 24 | const val IF_SEQ_NO = "if_seq_no" 25 | const val _PRIMARY_TERM = "_primary_term" 26 | const val IF_PRIMARY_TERM = "if_primary_term" 27 | const val REFRESH = "refresh" 28 | -------------------------------------------------------------------------------- /src/main/plugin-metadata/plugin-security.policy: -------------------------------------------------------------------------------- 1 | grant { 2 | // needed to find the classloader to load whitelisted classes. 3 | permission java.lang.RuntimePermission "createClassLoader"; 4 | permission java.lang.RuntimePermission "getClassLoader"; 5 | 6 | permission java.net.SocketPermission "*", "connect,resolve"; 7 | permission java.net.NetPermission "getProxySelector"; 8 | }; 9 | -------------------------------------------------------------------------------- /src/main/resources/META-INF/services/com.amazon.opendistroforelasticsearch.jobscheduler.spi.JobSchedulerExtension: -------------------------------------------------------------------------------- 1 | com.amazon.opendistroforelasticsearch.indexmanagement.IndexManagementPlugin 2 | -------------------------------------------------------------------------------- /src/main/resources/mappings/opendistro-rollup-target.json: -------------------------------------------------------------------------------- 1 | { 2 | "_meta" : { 3 | "schema_version": 1 4 | }, 5 | "dynamic_templates" : [ 6 | { 7 | "strings" : { 8 | "match_mapping_type" : "string", 9 | "mapping" : { 10 | "type" : "keyword" 11 | } 12 | } 13 | }, 14 | { 15 | "date_histograms" : { 16 | "path_match" : "*.date_histogram", 17 | "mapping" : { 18 | "type" : "date" 19 | } 20 | } 21 | } 22 | ] 23 | } -------------------------------------------------------------------------------- /src/test/kotlin/com/amazon/opendistroforelasticsearch/indexmanagement/indexstatemanagement/coordinator/SkipExecutionTests.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | package com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.coordinator 17 | 18 | import com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.SkipExecution 19 | import org.elasticsearch.action.admin.cluster.node.info.NodesInfoAction 20 | import org.elasticsearch.client.Client 21 | import org.elasticsearch.cluster.ClusterChangedEvent 22 | import org.elasticsearch.cluster.ESAllocationTestCase 23 | import org.elasticsearch.cluster.service.ClusterService 24 | import org.junit.Before 25 | import org.mockito.Mockito 26 | 27 | class SkipExecutionTests : ESAllocationTestCase() { 28 | 29 | private lateinit var client: Client 30 | private lateinit var clusterService: ClusterService 31 | private lateinit var skip: SkipExecution 32 | 33 | @Before 34 | @Throws(Exception::class) 35 | fun setup() { 36 | client = Mockito.mock(Client::class.java) 37 | clusterService = Mockito.mock(ClusterService::class.java) 38 | skip = SkipExecution(client, clusterService) 39 | } 40 | 41 | fun `test cluster change event`() { 42 | val event = Mockito.mock(ClusterChangedEvent::class.java) 43 | Mockito.`when`(event.nodesChanged()).thenReturn(true) 44 | skip.clusterChanged(event) 45 | Mockito.verify(client).execute(Mockito.eq(NodesInfoAction.INSTANCE), Mockito.any(), Mockito.any()) 46 | } 47 | } -------------------------------------------------------------------------------- /src/test/kotlin/com/amazon/opendistroforelasticsearch/indexmanagement/indexstatemanagement/model/ActionPropertiesTests.kt: -------------------------------------------------------------------------------- 1 | package com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.model 2 | 3 | import com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.model.managedindexmetadata.ActionProperties 4 | import org.elasticsearch.common.xcontent.XContentType 5 | import org.elasticsearch.test.ESTestCase 6 | 7 | class ActionPropertiesTests : ESTestCase() { 8 | 9 | @Suppress("UNCHECKED_CAST") 10 | fun `test action properties exist in history index`() { 11 | // All properties inside the ActionProperties class need to be also added to the ism history mappings 12 | // This is to catch any commits/PRs that add to ActionProperties but forget to add to history mappings 13 | val expected = createParser( 14 | XContentType.JSON.xContent(), 15 | javaClass.classLoader.getResource("mappings/opendistro-ism-history.json")!!.readText()) 16 | val expectedMap = expected.map() as Map>>>>>>> 17 | val actionProperties = ActionProperties.Properties.values().map { it.key } 18 | val mappingActionProperties = expectedMap["properties"]!!["managed_index_meta_data"]!!["properties"]!!["action"]!!["properties"]!!["action_properties"]!!["properties"] 19 | assertNotNull("Could not get action properties from ism history mappings", mappingActionProperties) 20 | actionProperties.forEach { property -> 21 | assertTrue("The $property action property does not exist in the ism history mappings", mappingActionProperties!!.containsKey(property)) 22 | } 23 | } 24 | } -------------------------------------------------------------------------------- /src/test/kotlin/com/amazon/opendistroforelasticsearch/indexmanagement/indexstatemanagement/model/ConditionsTests.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | package com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.model 17 | 18 | import com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.randomByteSizeValue 19 | import com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.randomTimeValueObject 20 | import org.elasticsearch.common.unit.ByteSizeValue 21 | import org.elasticsearch.test.ESTestCase 22 | import kotlin.test.assertFailsWith 23 | 24 | class ConditionsTests : ESTestCase() { 25 | 26 | fun `test supplying more than one transition condition fails`() { 27 | assertFailsWith( 28 | IllegalArgumentException::class, 29 | "Expected IllegalArgumentException for supplying multiple transition conditions") { 30 | Conditions(indexAge = randomTimeValueObject(), size = randomByteSizeValue()) 31 | } 32 | } 33 | 34 | fun `test doc count condition of zero fails`() { 35 | assertFailsWith( 36 | IllegalArgumentException::class, 37 | "Expected IllegalArgumentException for doc count condition less than 1") { 38 | Conditions(docCount = 0) 39 | } 40 | } 41 | 42 | fun `test size condition of zero fails`() { 43 | assertFailsWith( 44 | IllegalArgumentException::class, 45 | "Expected IllegalArgumentException for size condition less than 1") { 46 | Conditions(size = ByteSizeValue.parseBytesSizeValue("0", "size_test")) 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/test/kotlin/com/amazon/opendistroforelasticsearch/indexmanagement/indexstatemanagement/model/ISMTemplateTests.kt: -------------------------------------------------------------------------------- 1 | package com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.model 2 | 3 | import com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.randomISMTemplate 4 | import org.elasticsearch.common.io.stream.InputStreamStreamInput 5 | import org.elasticsearch.common.io.stream.OutputStreamStreamOutput 6 | import org.elasticsearch.test.ESTestCase 7 | import java.io.ByteArrayInputStream 8 | import java.io.ByteArrayOutputStream 9 | 10 | class ISMTemplateTests : ESTestCase() { 11 | 12 | fun `test basic`() { 13 | val expectedISMTemplate = randomISMTemplate() 14 | 15 | roundTripISMTemplate(expectedISMTemplate) 16 | } 17 | 18 | private fun roundTripISMTemplate(expectedISMTemplate: ISMTemplate) { 19 | val baos = ByteArrayOutputStream() 20 | val osso = OutputStreamStreamOutput(baos) 21 | expectedISMTemplate.writeTo(osso) 22 | val input = InputStreamStreamInput(ByteArrayInputStream(baos.toByteArray())) 23 | 24 | val actualISMTemplate = ISMTemplate(input) 25 | assertEquals(expectedISMTemplate, actualISMTemplate) 26 | } 27 | } -------------------------------------------------------------------------------- /src/test/kotlin/com/amazon/opendistroforelasticsearch/indexmanagement/indexstatemanagement/model/PolicyTests.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | package com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.model 17 | 18 | import com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.randomPolicy 19 | import com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.randomState 20 | import com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.randomTransition 21 | import org.elasticsearch.test.ESTestCase 22 | import kotlin.test.assertFailsWith 23 | 24 | class PolicyTests : ESTestCase() { 25 | 26 | fun `test invalid default state`() { 27 | assertFailsWith(IllegalArgumentException::class, "Expected IllegalArgumentException for invalid default state") { 28 | randomPolicy().copy(defaultState = "definitely not this") 29 | } 30 | } 31 | 32 | fun `test empty states`() { 33 | assertFailsWith(IllegalArgumentException::class, "Expected IllegalArgumentException for empty states") { 34 | randomPolicy().copy(states = emptyList()) 35 | } 36 | } 37 | 38 | fun `test duplicate states`() { 39 | assertFailsWith(IllegalArgumentException::class, "Expected IllegalArgumentException for duplicate states") { 40 | val states = listOf(randomState(name = "duplicate"), randomState(), randomState(name = "duplicate")) 41 | randomPolicy(states = states) 42 | } 43 | } 44 | 45 | fun `test transition pointing to nonexistent state`() { 46 | assertFailsWith(IllegalArgumentException::class, "Expected IllegalArgumentException for nonexistent transition state") { 47 | val states = listOf(randomState(transitions = listOf(randomTransition(stateName = "doesnt exist"))), randomState(), randomState()) 48 | randomPolicy(states = states) 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/test/kotlin/com/amazon/opendistroforelasticsearch/indexmanagement/indexstatemanagement/model/StateTests.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | package com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.model 17 | 18 | import com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.randomDeleteActionConfig 19 | import com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.randomReplicaCountActionConfig 20 | import com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.randomState 21 | import com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.randomTransition 22 | import org.elasticsearch.test.ESTestCase 23 | import kotlin.test.assertFailsWith 24 | 25 | class StateTests : ESTestCase() { 26 | 27 | fun `test invalid state name`() { 28 | assertFailsWith(IllegalArgumentException::class, "Expected IllegalArgumentException for blank state name") { 29 | State(" ", emptyList(), emptyList()) 30 | } 31 | 32 | assertFailsWith(IllegalArgumentException::class, "Expected IllegalArgumentException for empty state name") { 33 | State("", emptyList(), emptyList()) 34 | } 35 | } 36 | 37 | fun `test transitions disallowed if using delete`() { 38 | assertFailsWith(IllegalArgumentException::class, "Expected IllegalArgumentException for transitions when using delete") { 39 | randomState(actions = listOf(randomDeleteActionConfig()), transitions = listOf(randomTransition())) 40 | } 41 | } 42 | 43 | fun `test action disallowed if used after delete`() { 44 | assertFailsWith(IllegalArgumentException::class, "Expected IllegalArgumentException for action if used after delete") { 45 | randomState(actions = listOf(randomDeleteActionConfig(), randomReplicaCountActionConfig())) 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/test/kotlin/com/amazon/opendistroforelasticsearch/indexmanagement/indexstatemanagement/step/AttemptCreateRollupJobStepTests.kt: -------------------------------------------------------------------------------- 1 | package com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.step 2 | 3 | import com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.model.ManagedIndexMetaData 4 | import com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.model.managedindexmetadata.ActionMetaData 5 | import com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.model.managedindexmetadata.ActionProperties 6 | import com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.randomRollupActionConfig 7 | import com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.step.rollup.AttemptCreateRollupJobStep 8 | import com.nhaarman.mockitokotlin2.mock 9 | import org.elasticsearch.client.Client 10 | import org.elasticsearch.cluster.service.ClusterService 11 | import org.elasticsearch.test.ESTestCase 12 | import java.lang.Exception 13 | 14 | class AttemptCreateRollupJobStepTests : ESTestCase() { 15 | 16 | private val rollupActionConfig = randomRollupActionConfig() 17 | private val indexName = "test" 18 | private val rollupId: String = rollupActionConfig.ismRollup.toRollup(indexName).id 19 | private val client: Client = mock() 20 | private val clusterService: ClusterService = mock() 21 | private val metadata = ManagedIndexMetaData(indexName, "indexUuid", "policy_id", null, null, null, null, null, null, 22 | ActionMetaData(AttemptCreateRollupJobStep.name, 1, 0, false, 0, null, ActionProperties(rollupId = rollupId)), null, null, null) 23 | private val step = AttemptCreateRollupJobStep(clusterService, client, rollupActionConfig.ismRollup, metadata) 24 | 25 | fun `test process failure`() { 26 | step.processFailure(rollupId, Exception("dummy-error")) 27 | val updatedManagedIndexMetaData = step.getUpdatedManagedIndexMetaData(metadata) 28 | assertEquals("Step status is not FAILED", Step.StepStatus.FAILED, updatedManagedIndexMetaData.stepMetaData?.stepStatus) 29 | assertEquals( 30 | "Error message is not expected", 31 | AttemptCreateRollupJobStep.getFailedMessage(rollupId, indexName), 32 | updatedManagedIndexMetaData.info?.get("message") 33 | ) 34 | } 35 | 36 | fun `test isIdempotent`() { 37 | assertTrue(step.isIdempotent()) 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/test/kotlin/com/amazon/opendistroforelasticsearch/indexmanagement/indexstatemanagement/transport/action/ISMStatusResponseTests.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | package com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.transport.action 17 | 18 | import com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.util.FailedIndex 19 | import org.elasticsearch.common.io.stream.BytesStreamOutput 20 | import org.elasticsearch.common.io.stream.StreamInput 21 | import org.elasticsearch.test.ESTestCase 22 | 23 | class ISMStatusResponseTests : ESTestCase() { 24 | 25 | fun `test ISM status response`() { 26 | val updated = 1 27 | val failedIndex = FailedIndex("index", "uuid", "reason") 28 | val failedIndices = mutableListOf(failedIndex) 29 | 30 | val res = ISMStatusResponse(updated, failedIndices) 31 | 32 | val out = BytesStreamOutput() 33 | res.writeTo(out) 34 | val sin = StreamInput.wrap(out.bytes().toBytesRef().bytes) 35 | val newRes = ISMStatusResponse(sin) 36 | assertEquals(updated, newRes.updated) 37 | assertEquals(failedIndices, newRes.failedIndices) 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/test/kotlin/com/amazon/opendistroforelasticsearch/indexmanagement/indexstatemanagement/transport/action/addpolicy/AddPolicyRequestTests.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | package com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.transport.action.addpolicy 17 | 18 | import org.elasticsearch.common.io.stream.BytesStreamOutput 19 | import org.elasticsearch.common.io.stream.StreamInput 20 | import org.elasticsearch.test.ESTestCase 21 | 22 | class AddPolicyRequestTests : ESTestCase() { 23 | 24 | fun `test add policy request`() { 25 | val indices = listOf("index1", "index2") 26 | val policyID = "policyID" 27 | val req = AddPolicyRequest(indices, policyID) 28 | 29 | val out = BytesStreamOutput() 30 | req.writeTo(out) 31 | val sin = StreamInput.wrap(out.bytes().toBytesRef().bytes) 32 | val newReq = AddPolicyRequest(sin) 33 | assertEquals(indices, newReq.indices) 34 | assertEquals(policyID, newReq.policyID) 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/test/kotlin/com/amazon/opendistroforelasticsearch/indexmanagement/indexstatemanagement/transport/action/changepolicy/ChangePolicyRequestTests.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | package com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.transport.action.changepolicy 17 | 18 | import com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.model.ChangePolicy 19 | import com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.model.StateFilter 20 | import org.elasticsearch.common.io.stream.BytesStreamOutput 21 | import org.elasticsearch.common.io.stream.StreamInput 22 | import org.elasticsearch.test.ESTestCase 23 | 24 | class ChangePolicyRequestTests : ESTestCase() { 25 | 26 | fun `test change policy request`() { 27 | val indices = listOf("index1", "index2") 28 | val stateFilter = StateFilter("state1") 29 | val changePolicy = ChangePolicy("policyID", "state1", listOf(stateFilter), true) 30 | val req = ChangePolicyRequest(indices, changePolicy) 31 | 32 | val out = BytesStreamOutput() 33 | req.writeTo(out) 34 | val sin = StreamInput.wrap(out.bytes().toBytesRef().bytes) 35 | val newReq = ChangePolicyRequest(sin) 36 | assertEquals(indices, newReq.indices) 37 | assertEquals(changePolicy, newReq.changePolicy) 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/test/kotlin/com/amazon/opendistroforelasticsearch/indexmanagement/indexstatemanagement/transport/action/deletepolicy/DeletePolicyRequestTests.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | package com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.transport.action.deletepolicy 17 | 18 | import org.elasticsearch.action.support.WriteRequest 19 | import org.elasticsearch.common.io.stream.BytesStreamOutput 20 | import org.elasticsearch.common.io.stream.StreamInput 21 | import org.elasticsearch.test.ESTestCase 22 | 23 | class DeletePolicyRequestTests : ESTestCase() { 24 | 25 | fun `test delete policy request`() { 26 | val policyID = "policyID" 27 | val refreshPolicy = WriteRequest.RefreshPolicy.IMMEDIATE 28 | val req = DeletePolicyRequest(policyID, refreshPolicy) 29 | 30 | val out = BytesStreamOutput() 31 | req.writeTo(out) 32 | val sin = StreamInput.wrap(out.bytes().toBytesRef().bytes) 33 | val newReq = DeletePolicyRequest(sin) 34 | assertEquals(policyID, newReq.policyID) 35 | assertEquals(refreshPolicy, newReq.refreshPolicy) 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/test/kotlin/com/amazon/opendistroforelasticsearch/indexmanagement/indexstatemanagement/transport/action/explain/ExplainRequestTests.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | package com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.transport.action.explain 17 | 18 | import com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.model.SearchParams 19 | import org.elasticsearch.common.io.stream.BytesStreamOutput 20 | import org.elasticsearch.common.io.stream.StreamInput 21 | import org.elasticsearch.common.unit.TimeValue 22 | import org.elasticsearch.test.ESTestCase 23 | 24 | class ExplainRequestTests : ESTestCase() { 25 | 26 | fun `test explain request`() { 27 | val indices = listOf("index1", "index2") 28 | val local = true 29 | val masterTimeout = TimeValue.timeValueSeconds(30) 30 | val params = SearchParams(0, 20, "sort-field", "asc", "*") 31 | val req = ExplainRequest(indices, local, masterTimeout, params) 32 | 33 | val out = BytesStreamOutput() 34 | req.writeTo(out) 35 | val sin = StreamInput.wrap(out.bytes().toBytesRef().bytes) 36 | val newReq = ExplainRequest(sin) 37 | assertEquals(indices, newReq.indices) 38 | assertEquals(local, newReq.local) 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/test/kotlin/com/amazon/opendistroforelasticsearch/indexmanagement/indexstatemanagement/transport/action/getpolicy/GetPoliciesRequestTests.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | package com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.transport.action.getpolicy 17 | 18 | import com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.model.SearchParams 19 | import org.elasticsearch.common.io.stream.BytesStreamOutput 20 | import org.elasticsearch.common.io.stream.StreamInput 21 | import org.elasticsearch.test.ESTestCase 22 | 23 | class GetPoliciesRequestTests : ESTestCase() { 24 | 25 | fun `test get policies request`() { 26 | val table = SearchParams(20, 0, "policy.policy_id.keyword", "desc", "*") 27 | val req = GetPoliciesRequest(table) 28 | 29 | val out = BytesStreamOutput() 30 | req.writeTo(out) 31 | val sin = StreamInput.wrap(out.bytes().toBytesRef().bytes) 32 | val newReq = GetPoliciesRequest(sin) 33 | assertEquals(table, newReq.searchParams) 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/test/kotlin/com/amazon/opendistroforelasticsearch/indexmanagement/indexstatemanagement/transport/action/getpolicy/GetPoliciesResponseTests.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | package com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.transport.action.getpolicy 17 | 18 | import com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.randomPolicy 19 | import org.elasticsearch.common.io.stream.BytesStreamOutput 20 | import org.elasticsearch.common.io.stream.StreamInput 21 | import org.elasticsearch.test.ESTestCase 22 | 23 | class GetPoliciesResponseTests : ESTestCase() { 24 | 25 | fun `test get policies response`() { 26 | val policy = randomPolicy() 27 | val res = GetPoliciesResponse(listOf(policy), 1) 28 | 29 | val out = BytesStreamOutput() 30 | res.writeTo(out) 31 | val sin = StreamInput.wrap(out.bytes().toBytesRef().bytes) 32 | val newRes = GetPoliciesResponse(sin) 33 | assertEquals(1, newRes.totalPolicies) 34 | assertEquals(1, newRes.policies.size) 35 | assertEquals(policy, newRes.policies[0]) 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/test/kotlin/com/amazon/opendistroforelasticsearch/indexmanagement/indexstatemanagement/transport/action/getpolicy/GetPolicyRequestTests.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | package com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.transport.action.getpolicy 17 | 18 | import org.elasticsearch.common.io.stream.BytesStreamOutput 19 | import org.elasticsearch.common.io.stream.StreamInput 20 | import org.elasticsearch.search.fetch.subphase.FetchSourceContext 21 | import org.elasticsearch.test.ESTestCase 22 | 23 | class GetPolicyRequestTests : ESTestCase() { 24 | 25 | fun `test get policy request`() { 26 | val policyID = "policyID" 27 | val version: Long = 123 28 | val fetchSrcContext = FetchSourceContext.DO_NOT_FETCH_SOURCE 29 | val req = GetPolicyRequest(policyID, version, fetchSrcContext) 30 | 31 | val out = BytesStreamOutput() 32 | req.writeTo(out) 33 | val sin = StreamInput.wrap(out.bytes().toBytesRef().bytes) 34 | val newReq = GetPolicyRequest(sin) 35 | assertEquals(policyID, newReq.policyID) 36 | assertEquals(version, newReq.version) 37 | assertEquals(fetchSrcContext, newReq.fetchSrcContext) 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/test/kotlin/com/amazon/opendistroforelasticsearch/indexmanagement/indexstatemanagement/transport/action/removepolicy/RemovePolicyRequestTests.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | package com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.transport.action.removepolicy 17 | 18 | import org.elasticsearch.common.io.stream.BytesStreamOutput 19 | import org.elasticsearch.common.io.stream.StreamInput 20 | import org.elasticsearch.test.ESTestCase 21 | 22 | class RemovePolicyRequestTests : ESTestCase() { 23 | 24 | fun `test remove policy request`() { 25 | val indices = listOf("index1", "index2") 26 | val req = RemovePolicyRequest(indices) 27 | 28 | val out = BytesStreamOutput() 29 | req.writeTo(out) 30 | val sin = StreamInput.wrap(out.bytes().toBytesRef().bytes) 31 | val newReq = RemovePolicyRequest(sin) 32 | assertEquals(indices, newReq.indices) 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/test/kotlin/com/amazon/opendistroforelasticsearch/indexmanagement/indexstatemanagement/transport/action/retryfailedmanagedindex/RetryFailedManagedIndexRequestTests.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | package com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.transport.action.retryfailedmanagedindex 17 | 18 | import org.elasticsearch.common.io.stream.BytesStreamOutput 19 | import org.elasticsearch.common.io.stream.StreamInput 20 | import org.elasticsearch.common.unit.TimeValue 21 | import org.elasticsearch.test.ESTestCase 22 | 23 | class RetryFailedManagedIndexRequestTests : ESTestCase() { 24 | 25 | fun `test retry managed index request`() { 26 | val indices = listOf("index1", "index2") 27 | val startState = "state1" 28 | val masterTimeout = TimeValue.timeValueSeconds(30) 29 | val req = RetryFailedManagedIndexRequest(indices, startState, masterTimeout) 30 | 31 | val out = BytesStreamOutput() 32 | req.writeTo(out) 33 | val sin = StreamInput.wrap(out.bytes().toBytesRef().bytes) 34 | val newReq = RetryFailedManagedIndexRequest(sin) 35 | assertEquals(indices, newReq.indices) 36 | assertEquals(startState, newReq.startState) 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/test/kotlin/com/amazon/opendistroforelasticsearch/indexmanagement/refreshanalyzer/RefreshSearchAnalyzerShardResponseTests.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | package com.amazon.opendistroforelasticsearch.indexmanagement.refreshanalyzer 17 | 18 | import org.elasticsearch.common.io.stream.BytesStreamOutput 19 | import org.elasticsearch.index.Index 20 | import org.elasticsearch.index.shard.ShardId 21 | import org.elasticsearch.test.ESTestCase 22 | import org.junit.Assert 23 | 24 | class RefreshSearchAnalyzerShardResponseTests : ESTestCase() { 25 | 26 | fun `test shard refresh response parsing`() { 27 | val reloadedAnalyzers = listOf("analyzer1", "analyzer2") 28 | val refreshShardResponse = RefreshSearchAnalyzerShardResponse(ShardId(Index("testIndex", "qwerty"), 0), reloadedAnalyzers) 29 | 30 | val refreshShardResponse2 = roundTripRequest(refreshShardResponse) 31 | Assert.assertEquals(refreshShardResponse2.shardId, refreshShardResponse.shardId) 32 | } 33 | 34 | @Throws(Exception::class) 35 | private fun roundTripRequest(response: RefreshSearchAnalyzerShardResponse): RefreshSearchAnalyzerShardResponse { 36 | BytesStreamOutput().use { out -> 37 | response.writeTo(out) 38 | out.bytes().streamInput().use { si -> return RefreshSearchAnalyzerShardResponse(si) } 39 | } 40 | } 41 | } -------------------------------------------------------------------------------- /src/test/kotlin/com/amazon/opendistroforelasticsearch/indexmanagement/rollup/actionfilter/SerDeTests.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | package com.amazon.opendistroforelasticsearch.indexmanagement.rollup.actionfilter 17 | 18 | import com.amazon.opendistroforelasticsearch.indexmanagement.rollup.randomISMFieldCaps 19 | import org.elasticsearch.action.fieldcaps.FieldCapabilitiesResponse 20 | import org.elasticsearch.test.ESTestCase 21 | 22 | class SerDeTests : ESTestCase() { 23 | 24 | fun `test round trip empty`() { 25 | val fieldCaps = FieldCapabilitiesResponse(arrayOf(), mapOf()) 26 | val roundTripFromFieldCaps = ISMFieldCapabilitiesResponse.fromFieldCapabilitiesResponse(fieldCaps).toFieldCapabilitiesResponse() 27 | assertEquals("Round tripping didn't work", fieldCaps, roundTripFromFieldCaps) 28 | } 29 | 30 | fun `test round trip nonempty`() { 31 | val ismFieldCaps = randomISMFieldCaps() 32 | val fieldCaps = ismFieldCaps.toFieldCapabilitiesResponse() 33 | val roundTrippedFieldCaps = ISMFieldCapabilitiesResponse.fromFieldCapabilitiesResponse(fieldCaps).toFieldCapabilitiesResponse() 34 | assertEquals("Round tripping didn't work", fieldCaps, roundTrippedFieldCaps) 35 | assertEquals("Expected indices are different", ismFieldCaps.indices.size, roundTrippedFieldCaps.indices.size) 36 | assertEquals("Expected response map is different", ismFieldCaps.responseMap.size, roundTrippedFieldCaps.get().size) 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/test/kotlin/com/amazon/opendistroforelasticsearch/indexmanagement/rollup/model/RollupFieldMappingTests.kt: -------------------------------------------------------------------------------- 1 | package com.amazon.opendistroforelasticsearch.indexmanagement.rollup.model 2 | 3 | import com.amazon.opendistroforelasticsearch.indexmanagement.rollup.model.RollupFieldMapping.Companion.UNKNOWN_MAPPING 4 | import org.elasticsearch.test.ESTestCase 5 | 6 | class RollupFieldMappingTests : ESTestCase() { 7 | 8 | fun `test toIssue`() { 9 | var fieldMapping = RollupFieldMapping(RollupFieldMapping.Companion.FieldType.DIMENSION, "dummy-field", "terms") 10 | var actual = fieldMapping.toIssue() 11 | assertEquals("missing terms grouping on dummy-field", actual) 12 | 13 | actual = fieldMapping.toIssue(true) 14 | assertEquals("missing field dummy-field", actual) 15 | 16 | fieldMapping = RollupFieldMapping(RollupFieldMapping.Companion.FieldType.METRIC, "dummy-field", "sum") 17 | actual = fieldMapping.toIssue() 18 | assertEquals("missing sum aggregation on dummy-field", actual) 19 | 20 | actual = fieldMapping.toIssue(true) 21 | assertEquals("missing field dummy-field", actual) 22 | 23 | fieldMapping = RollupFieldMapping(RollupFieldMapping.Companion.FieldType.DIMENSION, "dummy-field", UNKNOWN_MAPPING) 24 | actual = fieldMapping.toIssue(false) 25 | assertEquals("missing field dummy-field", actual) 26 | 27 | actual = fieldMapping.toIssue(true) 28 | assertEquals("missing field dummy-field", actual) 29 | } 30 | } -------------------------------------------------------------------------------- /src/test/kotlin/com/amazon/opendistroforelasticsearch/indexmanagement/rollup/model/RollupMetricsTests.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | package com.amazon.opendistroforelasticsearch.indexmanagement.rollup.model 17 | 18 | import com.amazon.opendistroforelasticsearch.indexmanagement.rollup.randomAverage 19 | import com.amazon.opendistroforelasticsearch.indexmanagement.rollup.randomRollupMetrics 20 | import org.elasticsearch.test.ESTestCase 21 | import org.elasticsearch.test.rest.ESRestTestCase 22 | import kotlin.test.assertFailsWith 23 | 24 | class RollupMetricsTests : ESTestCase() { 25 | fun `test rollup metrics empty fields`() { 26 | assertFailsWith(IllegalArgumentException::class, "Source and target field must not be empty") { 27 | randomRollupMetrics().copy(sourceField = "", targetField = "") 28 | } 29 | 30 | assertFailsWith(IllegalArgumentException::class, "Source and target field must not be empty") { 31 | randomRollupMetrics().copy(sourceField = "source", targetField = "") 32 | } 33 | 34 | assertFailsWith(IllegalArgumentException::class, "Source and target field must not be empty") { 35 | randomRollupMetrics().copy(sourceField = "", targetField = "target") 36 | } 37 | } 38 | 39 | fun `test rollup metrics needs at least one metric`() { 40 | val field = ESRestTestCase.randomAlphaOfLength(10) 41 | assertFailsWith(IllegalArgumentException::class, "Must specify at least one metric to aggregate on for $field") { 42 | randomRollupMetrics().copy(sourceField = field, targetField = field, metrics = emptyList()) 43 | } 44 | } 45 | 46 | fun `test rollup metrics distinct metrics`() { 47 | assertFailsWith(IllegalArgumentException::class, "Cannot have multiple metrics of the same type in a single rollup metric") { 48 | randomRollupMetrics().copy(metrics = listOf(randomAverage(), randomAverage())) 49 | } 50 | } 51 | } -------------------------------------------------------------------------------- /src/test/resources/index-management/opendistro-index-management-1.13.2.0.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opendistro-for-elasticsearch/index-management/cda0eda35fc5da3816c407ad7a929d746edaf179/src/test/resources/index-management/opendistro-index-management-1.13.2.0.zip -------------------------------------------------------------------------------- /src/test/resources/job-scheduler/opendistro-job-scheduler-1.13.0.0.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opendistro-for-elasticsearch/index-management/cda0eda35fc5da3816c407ad7a929d746edaf179/src/test/resources/job-scheduler/opendistro-job-scheduler-1.13.0.0.zip -------------------------------------------------------------------------------- /src/test/resources/security/esnode-key.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN PRIVATE KEY----- 2 | MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCWvn+O+rywfgMC 3 | ud24mAclMDfuNA/IzCKLxl5usIE/PvUm7PPfXQ14LfQhNQXqOuaD9fiVM+HO1BzK 4 | wmN3j4g7eHInR1cxENoNGKFa0Fr9EXnUv8sfwyobPD8NTu9eaH7T+d6f9oow+Q4n 5 | xb9Xin5IRR/pcJ8v7zEjcXpZaZejcSU4iVZ0PR2Di4H9rfe9SEyR5wLrsVBePB3L 6 | jaL1uK4bZF3n/JGgDe3BNy1PgPU+O+FCzQipBBTyJWQCjd4iTRXVbMa01PglAR85 7 | O9w6NXApBLyWdGRY6dGd8vMC2P4KlhnxlcgPZdglKniGTX+eTzT7Rszq77zjYrou 8 | PLwSh9S7AgMBAAECggEABwiohxFoEIwws8XcdKqTWsbfNTw0qFfuHLuK2Htf7IWR 9 | htlzn66F3F+4jnwc5IsPCoVFriCXnsEC/usHHSMTZkL+gJqxlNaGdin6DXS/aiOQ 10 | nb69SaQfqNmsz4ApZyxVDqsQGkK0vAhDAtQVU45gyhp/nLLmmqP8lPzMirOEodmp 11 | U9bA8t/ttrzng7SVAER42f6IVpW0iTKTLyFii0WZbq+ObViyqib9hVFrI6NJuQS+ 12 | IelcZB0KsSi6rqIjXg1XXyMiIUcSlhq+GfEa18AYgmsbPwMbExate7/8Ci7ZtCbh 13 | lx9bves2+eeqq5EMm3sMHyhdcg61yzd5UYXeZhwJkQKBgQDS9YqrAtztvLY2gMgv 14 | d+wOjb9awWxYbQTBjx33kf66W+pJ+2j8bI/XX2CpZ98w/oq8VhMqbr9j5b8MfsrF 15 | EoQvedA4joUo8sXd4j1mR2qKF4/KLmkgy6YYusNP2UrVSw7sh77bzce+YaVVoO/e 16 | 0wIVTHuD/QZ6fG6MasOqcbl6hwKBgQC27cQruaHFEXR/16LrMVAX+HyEEv44KOCZ 17 | ij5OE4P7F0twb+okngG26+OJV3BtqXf0ULlXJ+YGwXCRf6zUZkld3NMy3bbKPgH6 18 | H/nf3BxqS2tudj7+DV52jKtisBghdvtlKs56oc9AAuwOs37DvhptBKUPdzDDqfys 19 | Qchv5JQdLQKBgERev+pcqy2Bk6xmYHrB6wdseS/4sByYeIoi0BuEfYH4eB4yFPx6 20 | UsQCbVl6CKPgWyZe3ydJbU37D8gE78KfFagtWoZ56j4zMF2RDUUwsB7BNCDamce/ 21 | OL2bCeG/Erm98cBG3lxufOX+z47I8fTNfkdY2k8UmhzoZwurLm73HJ3RAoGBAKsp 22 | 6yamuXF2FbYRhUXgjHsBbTD/vJO72/yO2CGiLRpi/5mjfkjo99269trp0C8sJSub 23 | 5PBiSuADXFsoRgUv+HI1UAEGaCTwxFTQWrRWdtgW3d0sE2EQDVWL5kmfT9TwSeat 24 | mSoyAYR5t3tCBNkPJhbgA7pm4mASzHQ50VyxWs25AoGBAKPFx9X2oKhYQa+mW541 25 | bbqRuGFMoXIIcr/aeM3LayfLETi48o5NDr2NDP11j4yYuz26YLH0Dj8aKpWuehuH 26 | uB27n6j6qu0SVhQi6mMJBe1JrKbzhqMKQjYOoy8VsC2gdj5pCUP/kLQPW7zm9diX 27 | CiKTtKgPIeYdigor7V3AHcVT 28 | -----END PRIVATE KEY----- 29 | -------------------------------------------------------------------------------- /src/test/resources/security/esnode.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIIEyTCCA7GgAwIBAgIGAWLrc1O2MA0GCSqGSIb3DQEBCwUAMIGPMRMwEQYKCZIm 3 | iZPyLGQBGRYDY29tMRcwFQYKCZImiZPyLGQBGRYHZXhhbXBsZTEZMBcGA1UECgwQ 4 | RXhhbXBsZSBDb20gSW5jLjEhMB8GA1UECwwYRXhhbXBsZSBDb20gSW5jLiBSb290 5 | IENBMSEwHwYDVQQDDBhFeGFtcGxlIENvbSBJbmMuIFJvb3QgQ0EwHhcNMTgwNDIy 6 | MDM0MzQ3WhcNMjgwNDE5MDM0MzQ3WjBeMRIwEAYKCZImiZPyLGQBGRYCZGUxDTAL 7 | BgNVBAcMBHRlc3QxDTALBgNVBAoMBG5vZGUxDTALBgNVBAsMBG5vZGUxGzAZBgNV 8 | BAMMEm5vZGUtMC5leGFtcGxlLmNvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCC 9 | AQoCggEBAJa+f476vLB+AwK53biYByUwN+40D8jMIovGXm6wgT8+9Sbs899dDXgt 10 | 9CE1Beo65oP1+JUz4c7UHMrCY3ePiDt4cidHVzEQ2g0YoVrQWv0RedS/yx/DKhs8 11 | Pw1O715oftP53p/2ijD5DifFv1eKfkhFH+lwny/vMSNxellpl6NxJTiJVnQ9HYOL 12 | gf2t971ITJHnAuuxUF48HcuNovW4rhtkXef8kaAN7cE3LU+A9T474ULNCKkEFPIl 13 | ZAKN3iJNFdVsxrTU+CUBHzk73Do1cCkEvJZ0ZFjp0Z3y8wLY/gqWGfGVyA9l2CUq 14 | eIZNf55PNPtGzOrvvONiui48vBKH1LsCAwEAAaOCAVkwggFVMIG8BgNVHSMEgbQw 15 | gbGAFJI1DOAPHitF9k0583tfouYSl0BzoYGVpIGSMIGPMRMwEQYKCZImiZPyLGQB 16 | GRYDY29tMRcwFQYKCZImiZPyLGQBGRYHZXhhbXBsZTEZMBcGA1UECgwQRXhhbXBs 17 | ZSBDb20gSW5jLjEhMB8GA1UECwwYRXhhbXBsZSBDb20gSW5jLiBSb290IENBMSEw 18 | HwYDVQQDDBhFeGFtcGxlIENvbSBJbmMuIFJvb3QgQ0GCAQEwHQYDVR0OBBYEFKyv 19 | 78ZmFjVKM9g7pMConYH7FVBHMAwGA1UdEwEB/wQCMAAwDgYDVR0PAQH/BAQDAgXg 20 | MCAGA1UdJQEB/wQWMBQGCCsGAQUFBwMBBggrBgEFBQcDAjA1BgNVHREELjAsiAUq 21 | AwQFBYISbm9kZS0wLmV4YW1wbGUuY29tgglsb2NhbGhvc3SHBH8AAAEwDQYJKoZI 22 | hvcNAQELBQADggEBAIOKuyXsFfGv1hI/Lkpd/73QNqjqJdxQclX57GOMWNbOM5H0 23 | 5/9AOIZ5JQsWULNKN77aHjLRr4owq2jGbpc/Z6kAd+eiatkcpnbtbGrhKpOtoEZy 24 | 8KuslwkeixpzLDNISSbkeLpXz4xJI1ETMN/VG8ZZP1bjzlHziHHDu0JNZ6TnNzKr 25 | XzCGMCohFfem8vnKNnKUneMQMvXd3rzUaAgvtf7Hc2LTBlf4fZzZF1EkwdSXhaMA 26 | 1lkfHiqOBxtgeDLxCHESZ2fqgVqsWX+t3qHQfivcPW6txtDyrFPRdJOGhiMGzT/t 27 | e/9kkAtQRgpTb3skYdIOOUOV0WGQ60kJlFhAzIs= 28 | -----END CERTIFICATE----- 29 | -------------------------------------------------------------------------------- /src/test/resources/security/kirk-key.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN PRIVATE KEY----- 2 | MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDCwgBOoO88uMM8 3 | dREJsk58Yt4Jn0zwQ2wUThbvy3ICDiEWhiAhUbg6dTggpS5vWWJto9bvaaqgMVoh 4 | ElfYHdTDncX3UQNBEP8tqzHON6BFEFSGgJRGLd6f5dri6rK32nCotYS61CFXBFxf 5 | WumXjSukjyrcTsdkR3C5QDo2oN7F883MOQqRENPzAtZi9s3jNX48u+/e3yvJzXsB 6 | GS9Qmsye6C71enbIujM4CVwDT/7a5jHuaUp6OuNCFbdRPnu/wLYwOS2/yOtzAqk7 7 | /PFnPCe7YOa10ShnV/jx2sAHhp7ZQBJgFkkgnIERz9Ws74Au+EbptWnsWuB+LqRL 8 | x5G02IzpAgMBAAECggEAEzwnMkeBbqqDgyRqFbO/PgMNvD7i0b/28V0dCtCPEVY6 9 | klzrg3RCERP5V9AN8VVkppYjPkCzZ2A4b0JpMUu7ncOmr7HCnoSCj2IfEyePSVg+ 10 | 4OHbbcBOAoDTHiI2myM/M9++8izNS34qGV4t6pfjaDyeQQ/5cBVWNBWnKjS34S5H 11 | rJWpAcDgxYk5/ah2Xs2aULZlXDMxbSikjrv+n4JIYTKFQo8ydzL8HQDBRmXAFLjC 12 | gNOSHf+5u1JdpY3uPIxK1ugVf8zPZ4/OEB23j56uu7c8+sZ+kZwfRWAQmMhFVG/y 13 | OXxoT5mOruBsAw29m2Ijtxg252/YzSTxiDqFziB/eQKBgQDjeVAdi55GW/bvhuqn 14 | xME/An8E3hI/FyaaITrMQJUBjiCUaStTEqUgQ6A7ZfY/VX6qafOX7sli1svihrXC 15 | uelmKrdve/CFEEqzX9JWWRiPiQ0VZD+EQRsJvX85Tw2UGvVUh6dO3UGPS0BhplMD 16 | jeVpyXgZ7Gy5we+DWjfwhYrCmwKBgQDbLmQhRy+IdVljObZmv3QtJ0cyxxZETWzU 17 | MKmgBFvcRw+KvNwO+Iy0CHEbDu06Uj63kzI2bK3QdINaSrjgr8iftXIQpBmcgMF+ 18 | a1l5HtHlCp6RWd55nWQOEvn36IGN3cAaQkXuh4UYM7QfEJaAbzJhyJ+wXA3jWqUd 19 | 8bDTIAZ0ywKBgFuZ44gyTAc7S2JDa0Up90O/ZpT4NFLRqMrSbNIJg7d/m2EIRNkM 20 | HhCzCthAg/wXGo3XYq+hCdnSc4ICCzmiEfoBY6LyPvXmjJ5VDOeWs0xBvVIK74T7 21 | jr7KX2wdiHNGs9pZUidw89CXVhK8nptEzcheyA1wZowbK68yamph7HHXAoGBAK3x 22 | 7D9Iyl1mnDEWPT7f1Gh9UpDm1TIRrDvd/tBihTCVKK13YsFy2d+LD5Bk0TpGyUVR 23 | STlOGMdloFUJFh4jA3pUOpkgUr8Uo/sbYN+x6Ov3+I3sH5aupRhSURVA7YhUIz/z 24 | tqIt5R+m8Nzygi6dkQNvf+Qruk3jw0S3ahizwsvvAoGAL7do6dTLp832wFVxkEf4 25 | gg1M6DswfkgML5V/7GQ3MkIX/Hrmiu+qSuHhDGrp9inZdCDDYg5+uy1+2+RBMRZ3 26 | vDUUacvc4Fep05zp7NcjgU5y+/HWpuKVvLIlZAO1MBY4Xinqqii6RdxukIhxw7eT 27 | C6TPL5KAcV1R/XAihDhI18Y= 28 | -----END PRIVATE KEY----- 29 | -------------------------------------------------------------------------------- /src/test/resources/security/kirk.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIIEdzCCA1+gAwIBAgIGAWLrc1O4MA0GCSqGSIb3DQEBCwUAMIGPMRMwEQYKCZIm 3 | iZPyLGQBGRYDY29tMRcwFQYKCZImiZPyLGQBGRYHZXhhbXBsZTEZMBcGA1UECgwQ 4 | RXhhbXBsZSBDb20gSW5jLjEhMB8GA1UECwwYRXhhbXBsZSBDb20gSW5jLiBSb290 5 | IENBMSEwHwYDVQQDDBhFeGFtcGxlIENvbSBJbmMuIFJvb3QgQ0EwHhcNMTgwNDIy 6 | MDM0MzQ3WhcNMjgwNDE5MDM0MzQ3WjBNMQswCQYDVQQGEwJkZTENMAsGA1UEBwwE 7 | dGVzdDEPMA0GA1UECgwGY2xpZW50MQ8wDQYDVQQLDAZjbGllbnQxDTALBgNVBAMM 8 | BGtpcmswggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDCwgBOoO88uMM8 9 | dREJsk58Yt4Jn0zwQ2wUThbvy3ICDiEWhiAhUbg6dTggpS5vWWJto9bvaaqgMVoh 10 | ElfYHdTDncX3UQNBEP8tqzHON6BFEFSGgJRGLd6f5dri6rK32nCotYS61CFXBFxf 11 | WumXjSukjyrcTsdkR3C5QDo2oN7F883MOQqRENPzAtZi9s3jNX48u+/e3yvJzXsB 12 | GS9Qmsye6C71enbIujM4CVwDT/7a5jHuaUp6OuNCFbdRPnu/wLYwOS2/yOtzAqk7 13 | /PFnPCe7YOa10ShnV/jx2sAHhp7ZQBJgFkkgnIERz9Ws74Au+EbptWnsWuB+LqRL 14 | x5G02IzpAgMBAAGjggEYMIIBFDCBvAYDVR0jBIG0MIGxgBSSNQzgDx4rRfZNOfN7 15 | X6LmEpdAc6GBlaSBkjCBjzETMBEGCgmSJomT8ixkARkWA2NvbTEXMBUGCgmSJomT 16 | 8ixkARkWB2V4YW1wbGUxGTAXBgNVBAoMEEV4YW1wbGUgQ29tIEluYy4xITAfBgNV 17 | BAsMGEV4YW1wbGUgQ29tIEluYy4gUm9vdCBDQTEhMB8GA1UEAwwYRXhhbXBsZSBD 18 | b20gSW5jLiBSb290IENBggEBMB0GA1UdDgQWBBRsdhuHn3MGDvZxOe22+1wliCJB 19 | mDAMBgNVHRMBAf8EAjAAMA4GA1UdDwEB/wQEAwIF4DAWBgNVHSUBAf8EDDAKBggr 20 | BgEFBQcDAjANBgkqhkiG9w0BAQsFAAOCAQEAkPrUTKKn+/6g0CjhTPBFeX8mKXhG 21 | zw5z9Oq+xnwefZwxV82E/tgFsPcwXcJIBg0f43BaVSygPiV7bXqWhxASwn73i24z 22 | lveIR4+z56bKIhP6c3twb8WWR9yDcLu2Iroin7dYEm3dfVUrhz/A90WHr6ddwmLL 23 | 3gcFF2kBu3S3xqM5OmN/tqRXFmo+EvwrdJRiTh4Fsf0tX1ZT07rrGvBFYktK7Kma 24 | lqDl4UDCF1UWkiiFubc0Xw+DR6vNAa99E0oaphzvCmITU1wITNnYZTKzVzQ7vUCq 25 | kLmXOFLTcxTQpptxSo5xDD3aTpzWGCvjExCKpXQtsITUOYtZc02AGjjPOQ== 26 | -----END CERTIFICATE----- 27 | -------------------------------------------------------------------------------- /src/test/resources/security/root-ca.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIID/jCCAuagAwIBAgIBATANBgkqhkiG9w0BAQsFADCBjzETMBEGCgmSJomT8ixk 3 | ARkWA2NvbTEXMBUGCgmSJomT8ixkARkWB2V4YW1wbGUxGTAXBgNVBAoMEEV4YW1w 4 | bGUgQ29tIEluYy4xITAfBgNVBAsMGEV4YW1wbGUgQ29tIEluYy4gUm9vdCBDQTEh 5 | MB8GA1UEAwwYRXhhbXBsZSBDb20gSW5jLiBSb290IENBMB4XDTE4MDQyMjAzNDM0 6 | NloXDTI4MDQxOTAzNDM0NlowgY8xEzARBgoJkiaJk/IsZAEZFgNjb20xFzAVBgoJ 7 | kiaJk/IsZAEZFgdleGFtcGxlMRkwFwYDVQQKDBBFeGFtcGxlIENvbSBJbmMuMSEw 8 | HwYDVQQLDBhFeGFtcGxlIENvbSBJbmMuIFJvb3QgQ0ExITAfBgNVBAMMGEV4YW1w 9 | bGUgQ29tIEluYy4gUm9vdCBDQTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC 10 | ggEBAK/u+GARP5innhpXK0c0q7s1Su1VTEaIgmZr8VWI6S8amf5cU3ktV7WT9SuV 11 | TsAm2i2A5P+Ctw7iZkfnHWlsC3HhPUcd6mvzGZ4moxnamM7r+a9otRp3owYoGStX 12 | ylVTQusAjbq9do8CMV4hcBTepCd+0w0v4h6UlXU8xjhj1xeUIz4DKbRgf36q0rv4 13 | VIX46X72rMJSETKOSxuwLkov1ZOVbfSlPaygXIxqsHVlj1iMkYRbQmaTib6XWHKf 14 | MibDaqDejOhukkCjzpptGZOPFQ8002UtTTNv1TiaKxkjMQJNwz6jfZ53ws3fh1I0 15 | RWT6WfM4oeFRFnyFRmc4uYTUgAkCAwEAAaNjMGEwDwYDVR0TAQH/BAUwAwEB/zAf 16 | BgNVHSMEGDAWgBSSNQzgDx4rRfZNOfN7X6LmEpdAczAdBgNVHQ4EFgQUkjUM4A8e 17 | K0X2TTnze1+i5hKXQHMwDgYDVR0PAQH/BAQDAgGGMA0GCSqGSIb3DQEBCwUAA4IB 18 | AQBoQHvwsR34hGO2m8qVR9nQ5Klo5HYPyd6ySKNcT36OZ4AQfaCGsk+SecTi35QF 19 | RHL3g2qffED4tKR0RBNGQSgiLavmHGCh3YpDupKq2xhhEeS9oBmQzxanFwWFod4T 20 | nnsG2cCejyR9WXoRzHisw0KJWeuNlwjUdJY0xnn16srm1zL/M/f0PvCyh9HU1mF1 21 | ivnOSqbDD2Z7JSGyckgKad1Omsg/rr5XYtCeyJeXUPcmpeX6erWJJNTUh6yWC/hY 22 | G/dFC4xrJhfXwz6Z0ytUygJO32bJG4Np2iGAwvvgI9EfxzEv/KP+FGrJOvQJAq4/ 23 | BU36ZAa80W/8TBnqZTkNnqZV 24 | -----END CERTIFICATE----- 25 | -------------------------------------------------------------------------------- /src/test/resources/security/sample.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIIEyTCCA7GgAwIBAgIGAWLrc1O2MA0GCSqGSIb3DQEBCwUAMIGPMRMwEQYKCZIm 3 | iZPyLGQBGRYDY29tMRcwFQYKCZImiZPyLGQBGRYHZXhhbXBsZTEZMBcGA1UECgwQ 4 | RXhhbXBsZSBDb20gSW5jLjEhMB8GA1UECwwYRXhhbXBsZSBDb20gSW5jLiBSb290 5 | IENBMSEwHwYDVQQDDBhFeGFtcGxlIENvbSBJbmMuIFJvb3QgQ0EwHhcNMTgwNDIy 6 | MDM0MzQ3WhcNMjgwNDE5MDM0MzQ3WjBeMRIwEAYKCZImiZPyLGQBGRYCZGUxDTAL 7 | BgNVBAcMBHRlc3QxDTALBgNVBAoMBG5vZGUxDTALBgNVBAsMBG5vZGUxGzAZBgNV 8 | BAMMEm5vZGUtMC5leGFtcGxlLmNvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCC 9 | AQoCggEBAJa+f476vLB+AwK53biYByUwN+40D8jMIovGXm6wgT8+9Sbs899dDXgt 10 | 9CE1Beo65oP1+JUz4c7UHMrCY3ePiDt4cidHVzEQ2g0YoVrQWv0RedS/yx/DKhs8 11 | Pw1O715oftP53p/2ijD5DifFv1eKfkhFH+lwny/vMSNxellpl6NxJTiJVnQ9HYOL 12 | gf2t971ITJHnAuuxUF48HcuNovW4rhtkXef8kaAN7cE3LU+A9T474ULNCKkEFPIl 13 | ZAKN3iJNFdVsxrTU+CUBHzk73Do1cCkEvJZ0ZFjp0Z3y8wLY/gqWGfGVyA9l2CUq 14 | eIZNf55PNPtGzOrvvONiui48vBKH1LsCAwEAAaOCAVkwggFVMIG8BgNVHSMEgbQw 15 | gbGAFJI1DOAPHitF9k0583tfouYSl0BzoYGVpIGSMIGPMRMwEQYKCZImiZPyLGQB 16 | GRYDY29tMRcwFQYKCZImiZPyLGQBGRYHZXhhbXBsZTEZMBcGA1UECgwQRXhhbXBs 17 | ZSBDb20gSW5jLjEhMB8GA1UECwwYRXhhbXBsZSBDb20gSW5jLiBSb290IENBMSEw 18 | HwYDVQQDDBhFeGFtcGxlIENvbSBJbmMuIFJvb3QgQ0GCAQEwHQYDVR0OBBYEFKyv 19 | 78ZmFjVKM9g7pMConYH7FVBHMAwGA1UdEwEB/wQCMAAwDgYDVR0PAQH/BAQDAgXg 20 | MCAGA1UdJQEB/wQWMBQGCCsGAQUFBwMBBggrBgEFBQcDAjA1BgNVHREELjAsiAUq 21 | AwQFBYISbm9kZS0wLmV4YW1wbGUuY29tgglsb2NhbGhvc3SHBH8AAAEwDQYJKoZI 22 | hvcNAQELBQADggEBAIOKuyXsFfGv1hI/Lkpd/73QNqjqJdxQclX57GOMWNbOM5H0 23 | 5/9AOIZ5JQsWULNKN77aHjLRr4owq2jGbpc/Z6kAd+eiatkcpnbtbGrhKpOtoEZy 24 | 8KuslwkeixpzLDNISSbkeLpXz4xJI1ETMN/VG8ZZP1bjzlHziHHDu0JNZ6TnNzKr 25 | XzCGMCohFfem8vnKNnKUneMQMvXd3rzUaAgvtf7Hc2LTBlf4fZzZF1EkwdSXhaMA 26 | 1lkfHiqOBxtgeDLxCHESZ2fqgVqsWX+t3qHQfivcPW6txtDyrFPRdJOGhiMGzT/t 27 | e/9kkAtQRgpTb3skYdIOOUOV0WGQ60kJlFhAzIs= 28 | -----END CERTIFICATE----- -------------------------------------------------------------------------------- /src/test/resources/security/test-kirk.jks: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opendistro-for-elasticsearch/index-management/cda0eda35fc5da3816c407ad7a929d746edaf179/src/test/resources/security/test-kirk.jks -------------------------------------------------------------------------------- /worksheets/ism/create.http: -------------------------------------------------------------------------------- 1 | 2 | PUT localhost:9200/_opendistro/_ism/policies/example 3 | Content-Type: application/json 4 | 5 | { 6 | "policy": { 7 | "description": "ingesting logs", 8 | "default_state": "ingest", 9 | "states": [ 10 | { 11 | "name": "ingest", 12 | "actions": [ 13 | { 14 | "rollover": { 15 | "min_doc_count": 5 16 | } 17 | } 18 | ], 19 | "transitions": [ 20 | { 21 | "state_name": "search" 22 | } 23 | ] 24 | }, 25 | { 26 | "name": "search", 27 | "actions": [], 28 | "transitions": [ 29 | { 30 | "state_name": "delete", 31 | "conditions": { 32 | "min_index_age": "5m" 33 | } 34 | } 35 | ] 36 | }, 37 | { 38 | "name": "delete", 39 | "actions": [ 40 | { 41 | "delete": {} 42 | } 43 | ], 44 | "transitions": [] 45 | } 46 | ] 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /worksheets/rollups/kibana_sample_data.http: -------------------------------------------------------------------------------- 1 | # This will ingest the kibana sample ecommerce data into the cluster iff kibana 2 | # is running on 5601. If using local dev kibana make sure to pass yarn start --no-base-path 3 | POST localhost:5601/api/sample_data/ecommerce 4 | Connection: keep-alive 5 | kbn-version: 7.9.1 6 | Accept: */* 7 | User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.102 Safari/537.36 8 | Content-Type: application/json 9 | ### 10 | 11 | -------------------------------------------------------------------------------- /worksheets/rollups/secured/nyc.http: -------------------------------------------------------------------------------- 1 | ### Create these mappings first if you want to have the date mapping correctly created for datetime fields 2 | PUT https://localhost:9200/nyc-taxi-data 3 | Authorization: Basic admin admin 4 | Content-Type: application/json 5 | 6 | { 7 | "mappings": { 8 | "properties":{"DOLocationID":{"type":"integer"},"RatecodeID":{"type":"integer"},"fare_amount":{"type":"float"},"tpep_dropoff_datetime":{"type":"date","format":"yyyy-MM-dd HH:mm:ss"},"congestion_surcharge":{"type":"float"},"VendorID":{"type":"integer"},"passenger_count":{"type":"integer"},"tolls_amount":{"type":"float"},"improvement_surcharge":{"type":"float"},"trip_distance":{"type":"float"},"store_and_fwd_flag":{"type":"keyword"},"payment_type":{"type":"integer"},"total_amount":{"type":"float"},"extra":{"type":"float"},"tip_amount":{"type":"float"},"mta_tax":{"type":"float"},"tpep_pickup_datetime":{"type":"date","format":"yyyy-MM-dd HH:mm:ss"},"PULocationID":{"type":"integer"}} 9 | } 10 | } 11 | 12 | ### 13 | POST https://localhost:9200/nyc-taxi-data/_bulk?pretty 14 | Authorization: Basic admin admin 15 | Content-Type: application/x-ndjson 16 | 17 | < ../../src/test/resources/data/nyc_5000.ndjson 18 | 19 | ### 20 | DELETE https://localhost:9200/nyc-taxi-data/ 21 | Authorization: Basic admin admin 22 | 23 | ### 24 | GET https://localhost:9200/nyc-taxi-data/_mapping 25 | Authorization: Basic admin admin -------------------------------------------------------------------------------- /worksheets/rollups/secured/security_calls.http: -------------------------------------------------------------------------------- 1 | ### 2 | PUT https://localhost:9200/_opendistro/_rollup/jobs/bob 3 | Authorization: Basic bob bob 4 | Content-Type: application/json 5 | 6 | { 7 | "rollup": { 8 | "enabled": true, 9 | "schedule": { 10 | "interval": { 11 | "period": 1, 12 | "unit": "Minutes", 13 | "start_time": {{$timestamp}} 14 | } 15 | }, 16 | "last_updated_time": {{$timestamp}}, 17 | "description": "An example policy that rolls up the sample ecommerce data", 18 | "source_index": "nyc-taxi-data", 19 | "target_index": "example-rollup-index", 20 | "page_size": 5, 21 | "delay": 0, 22 | "roles": ["rollup_all", "nyc_taxi_all", "example_rollup_index_all"], 23 | "continuous": false, 24 | "dimensions": [ 25 | { 26 | "date_histogram": { 27 | "source_field": "tpep_pickup_datetime", 28 | "fixed_interval": "30m", 29 | "timezone": "America/Los_Angeles" 30 | } 31 | }, 32 | { 33 | "terms": { 34 | "source_field": "PULocationID" 35 | } 36 | }, 37 | { 38 | "terms": { 39 | "source_field": "DOLocationID" 40 | } 41 | }, 42 | { 43 | "terms": { 44 | "source_field": "passenger_count" 45 | } 46 | }, 47 | { 48 | "terms": { 49 | "source_field": "VendorID" 50 | } 51 | } 52 | ], 53 | "metrics": [ 54 | { 55 | "source_field": "passenger_count", 56 | "metrics": [{ "avg": {} },{ "sum": {} }, { "max": {} }, { "min": {} }, { "value_count": {} }] 57 | }, 58 | { 59 | "source_field": "trip_distance", 60 | "metrics": [{ "avg": {} },{ "sum": {} }, { "max": {} }, { "min": {} }, { "value_count": {} }] 61 | }, 62 | { 63 | "source_field": "total_amount", 64 | "metrics": [{ "avg": {} },{ "sum": {} }, { "max": {} }, { "min": {} }, { "value_count": {} }] 65 | } 66 | ] 67 | } 68 | } 69 | 70 | ### 71 | POST https://localhost:9200/_opendistro/_rollup/jobs/bob/_start 72 | Authorization: Basic bob bob 73 | 74 | ### 75 | POST https://localhost:9200/_opendistro/_rollup/jobs/bob/_stop 76 | Authorization: Basic bob_startstop bob_startstop 77 | 78 | ### 79 | 80 | GET https://localhost:9200/_search 81 | Authorization: Basic admin admins 82 | Content-Type: application/json -------------------------------------------------------------------------------- /worksheets/rollups/unsecured/nyc.http: -------------------------------------------------------------------------------- 1 | ### 2 | PUT localhost:9200/nyc-taxi-data 3 | Content-Type: application/json 4 | 5 | { 6 | "mappings": { 7 | "properties":{"DOLocationID":{"type":"integer"},"RatecodeID":{"type":"integer"},"fare_amount":{"type":"float"},"tpep_dropoff_datetime":{"type":"date","format":"yyyy-MM-dd HH:mm:ss"},"congestion_surcharge":{"type":"float"},"VendorID":{"type":"integer"},"passenger_count":{"type":"integer"},"tolls_amount":{"type":"float"},"improvement_surcharge":{"type":"float"},"trip_distance":{"type":"float"},"store_and_fwd_flag":{"type":"keyword"},"payment_type":{"type":"integer"},"total_amount":{"type":"float"},"extra":{"type":"float"},"tip_amount":{"type":"float"},"mta_tax":{"type":"float"},"tpep_pickup_datetime":{"type":"date","format":"yyyy-MM-dd HH:mm:ss"},"PULocationID":{"type":"integer"}} 8 | } 9 | } 10 | 11 | ### 12 | POST localhost:9200/nyc-taxi-data/_bulk?pretty 13 | Content-Type: application/x-ndjson 14 | 15 | < ../../src/test/resources/data/nyc_5000.ndjson 16 | 17 | ### 18 | DELETE localhost:9200/nyc-taxi-data/ 19 | 20 | ### 21 | GET localhost:9200/nyc-taxi-data/_mapping --------------------------------------------------------------------------------