diff --git a/build.gradle b/build.gradle index aa585356..ca0ccaca 100644 --- a/build.gradle +++ b/build.gradle @@ -16,48 +16,86 @@ import java.nio.charset.StandardCharsets import java.nio.file.Files import java.util.concurrent.Callable -import org.elasticsearch.gradle.testclusters.TestClusterConfiguration +import org.opensearch.gradle.testclusters.TestClusterConfiguration import java.util.function.Predicate import java.util.concurrent.TimeUnit import java.util.stream.Collectors -plugins { - id "elasticsearch.esplugin" version "7.10.2" - id 'org.jetbrains.kotlin.jvm' version "1.3.72" +buildscript { + ext { + opensearch_version = System.getProperty("opensearch_version", "1.0.0-beta1") + kotlin_version = System.getProperty("kotlin.version", "1.3.72") + } + + repositories { + mavenLocal() + mavenCentral() + maven { url "https://plugins.gradle.org/m2/" } + } + + dependencies { + classpath "org.opensearch.gradle:build-tools:${opensearch_version}" + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${kotlin_version}" + classpath "org.jetbrains.kotlin:kotlin-allopen:${kotlin_version}" + classpath "io.gitlab.arturbosch.detekt:detekt-gradle-plugin:1.0.0-RC15" + classpath "org.jacoco:org.jacoco.agent:0.8.5" + } } -group = "com.amazon.es" -version = "${version}.0" -ext.kotlin_version = '1.3.72' -repositories { - mavenCentral() +plugins { + id 'nebula.ospackage' version "8.3.0" + id "com.dorongold.task-tree" version "1.5" } -apply plugin: 'elasticsearch.testclusters' -apply plugin: 'elasticsearch.rest-test' +apply plugin: 'java' +apply plugin: 'jacoco' +apply plugin: 'idea' +apply plugin: 'opensearch.opensearchplugin' +apply plugin: 'opensearch.testclusters' +apply plugin: 'opensearch.rest-test' +apply plugin: 'org.jetbrains.kotlin.jvm' +apply plugin: 'org.jetbrains.kotlin.plugin.allopen' + +configurations.all { + if (it.state != Configuration.State.UNRESOLVED) return + resolutionStrategy { + force "org.jetbrains.kotlin:kotlin-stdlib:${kotlin_version}" + force "org.jetbrains.kotlin:kotlin-stdlib-common:${kotlin_version}" + force 'junit:junit:4.13.1' + force 'commons-beanutils:commons-beanutils:1.9.4' + force 'com.google.guava:guava:30.0-jre' + force 'com.puppycrawl.tools:checkstyle:8.29' + force 'commons-codec:commons-codec:1.13' + force 'org.apache.httpcomponents:httpclient:4.5.13' + force 'org.apache.httpcomponents:httpclient-osgi:4.5.13' + force 'org.apache.httpcomponents.client5:httpclient5:5.0.3' + force 'org.apache.httpcomponents.client5:httpclient5-osgi:5.0.3' + force 'com.fasterxml.jackson.core:jackson-databind:2.10.4' + force 'org.yaml:snakeyaml:1.26' + force 'org.codehaus.plexus:plexus-utils:3.0.24' + } +} dependencies { - // Elasticsearch nanny state marks all dependencies non-transitive forcing us to list them out. - compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8" - compile "org.jetbrains.kotlin:kotlin-stdlib-jdk7" - compile "org.jetbrains.kotlin:kotlin-stdlib" - compile "org.jetbrains.kotlin:kotlin-stdlib-common" + compileOnly "org.opensearch:opensearch:${opensearch_version}" + compile "org.jetbrains.kotlin:kotlin-stdlib:${kotlin_version}" + compile "org.jetbrains.kotlin:kotlin-stdlib-common:${kotlin_version}" compile "org.jetbrains:annotations:13.0" + compile "com.github.seancfoley:ipaddress:5.3.3" compile "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.5" + testCompile "org.opensearch.test:framework:${opensearch_version}" testImplementation "org.assertj:assertj-core:3.17.2" - testImplementation "org.elasticsearch.client:elasticsearch-rest-high-level-client:${versions.elasticsearch}" + testImplementation "org.opensearch.client:opensearch-rest-high-level-client:${opensearch_version}" testImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:1.3.5" + testCompile "org.jetbrains.kotlin:kotlin-test:${kotlin_version}" } -// Elasticsearch nanny state forces us to manually resolve all conflicts -configurations.all { - if (it.state != Configuration.State.UNRESOLVED) return - resolutionStrategy { - force "org.jetbrains.kotlin:kotlin-stdlib:${kotlin_version}" - force "org.jetbrains.kotlin:kotlin-stdlib-common:${kotlin_version}" - } +repositories { + mavenLocal() + mavenCentral() + maven { url "https://plugins.gradle.org/m2/" } } compileKotlin { @@ -75,21 +113,22 @@ compileTestKotlin { } } -esplugin { - name = project.name - description = "Open Distro Cross Cluster Replication Plugin" - classname = "com.amazon.elasticsearch.replication.ReplicationPlugin" -} - ext { licenseFile = rootProject.file('LICENSE') noticeFile = rootProject.file('NOTICE') } +opensearchplugin { + name = project.name + description = "Open Distro Cross Cluster Replication Plugin" + classname = "org.opensearch.replication.ReplicationPlugin" +} + + javadoc.enabled = false licenseHeaders.enabled = false dependencyLicenses.enabled = false -thirdPartyAudit.enabled = true +thirdPartyAudit.enabled = false validateNebulaPom.enabled = false loggerUsageCheck.enabled = false @@ -211,7 +250,7 @@ task initializeSecurityIndex { testingConventions { naming { IT { - baseClass 'com.amazon.elasticsearch.replication.MultiClusterRestTestCase' + baseClass 'org.opensearch.replication.MultiClusterRestTestCase' } } } diff --git a/gradle.properties b/gradle.properties index 3da8b52b..9e278901 100644 --- a/gradle.properties +++ b/gradle.properties @@ -11,4 +11,4 @@ # express or implied. See the License for the specific language governing # permissions and limitations under the License. -version = 1.13.0 +version = 1.0.0 diff --git a/settings.gradle b/settings.gradle index cb529b64..bbddfbf5 100644 --- a/settings.gradle +++ b/settings.gradle @@ -13,20 +13,4 @@ * permissions and limitations under the License. */ -pluginManagement { - repositories { - mavenCentral() - jcenter() - gradlePluginPortal() - } - resolutionStrategy { - eachPlugin { - // ES not available in gradle plugin portal so hand code here - if(requested.id.namespace == "elasticsearch") { - useModule "org.elasticsearch.gradle:build-tools:${requested.version}" - } - } - } -} - -rootProject.name = "opendistro-cross-cluster-replication" +rootProject.name = "opensearch-cross-cluster-replication" diff --git a/src/main/kotlin/com/amazon/elasticsearch/replication/ReplicationEngine.kt b/src/main/kotlin/org/opensearch/replication/ReplicationEngine.kt similarity index 89% rename from src/main/kotlin/com/amazon/elasticsearch/replication/ReplicationEngine.kt rename to src/main/kotlin/org/opensearch/replication/ReplicationEngine.kt index e0aaf9a5..e5f82325 100644 --- a/src/main/kotlin/com/amazon/elasticsearch/replication/ReplicationEngine.kt +++ b/src/main/kotlin/org/opensearch/replication/ReplicationEngine.kt @@ -13,11 +13,11 @@ * permissions and limitations under the License. */ -package com.amazon.elasticsearch.replication +package org.opensearch.replication -import org.elasticsearch.index.engine.EngineConfig -import org.elasticsearch.index.engine.InternalEngine -import org.elasticsearch.index.seqno.SequenceNumbers +import org.opensearch.index.engine.EngineConfig +import org.opensearch.index.engine.InternalEngine +import org.opensearch.index.seqno.SequenceNumbers class ReplicationEngine(config: EngineConfig) : InternalEngine(config) { diff --git a/src/main/kotlin/com/amazon/elasticsearch/replication/ReplicationException.kt b/src/main/kotlin/org/opensearch/replication/ReplicationException.kt similarity index 73% rename from src/main/kotlin/com/amazon/elasticsearch/replication/ReplicationException.kt rename to src/main/kotlin/org/opensearch/replication/ReplicationException.kt index 7275ecb5..10803b6b 100644 --- a/src/main/kotlin/com/amazon/elasticsearch/replication/ReplicationException.kt +++ b/src/main/kotlin/org/opensearch/replication/ReplicationException.kt @@ -13,19 +13,19 @@ * permissions and limitations under the License. */ -package com.amazon.elasticsearch.replication +package org.opensearch.replication -import org.elasticsearch.ElasticsearchException -import org.elasticsearch.action.ShardOperationFailedException -import org.elasticsearch.cluster.metadata.IndexMetadata.INDEX_UUID_NA_VALUE -import org.elasticsearch.index.shard.ShardId +import org.opensearch.OpenSearchException +import org.opensearch.action.ShardOperationFailedException +import org.opensearch.cluster.metadata.IndexMetadata.INDEX_UUID_NA_VALUE +import org.opensearch.index.shard.ShardId /** * Base class replication exceptions. Note: Replication process may throw exceptions that do not derive from this such as - * [org.elasticsearch.ResourceAlreadyExistsException], [org.elasticsearch.index.IndexNotFoundException] or - * [org.elasticsearch.index.shard.ShardNotFoundException]. + * [org.opensearch.ResourceAlreadyExistsException], [org.opensearch.index.IndexNotFoundException] or + * [org.opensearch.index.shard.ShardNotFoundException]. */ -class ReplicationException: ElasticsearchException { +class ReplicationException: OpenSearchException { constructor(message: String, vararg args: Any) : super(message, *args) diff --git a/src/main/kotlin/com/amazon/elasticsearch/replication/ReplicationPlugin.kt b/src/main/kotlin/org/opensearch/replication/ReplicationPlugin.kt similarity index 62% rename from src/main/kotlin/com/amazon/elasticsearch/replication/ReplicationPlugin.kt rename to src/main/kotlin/org/opensearch/replication/ReplicationPlugin.kt index a0b6c7f5..1b745700 100644 --- a/src/main/kotlin/com/amazon/elasticsearch/replication/ReplicationPlugin.kt +++ b/src/main/kotlin/org/opensearch/replication/ReplicationPlugin.kt @@ -13,95 +13,95 @@ * permissions and limitations under the License. */ -package com.amazon.elasticsearch.replication - -import com.amazon.elasticsearch.replication.action.autofollow.TransportUpdateAutoFollowPatternAction -import com.amazon.elasticsearch.replication.action.autofollow.UpdateAutoFollowPatternAction -import com.amazon.elasticsearch.replication.action.changes.GetChangesAction -import com.amazon.elasticsearch.replication.action.changes.TransportGetChangesAction -import com.amazon.elasticsearch.replication.action.index.ReplicateIndexAction -import com.amazon.elasticsearch.replication.action.index.ReplicateIndexMasterNodeAction -import com.amazon.elasticsearch.replication.action.index.TransportReplicateIndexAction -import com.amazon.elasticsearch.replication.action.index.TransportReplicateIndexMasterNodeAction -import com.amazon.elasticsearch.replication.action.replay.ReplayChangesAction -import com.amazon.elasticsearch.replication.action.replay.TransportReplayChangesAction -import com.amazon.elasticsearch.replication.action.repository.GetFileChunkAction -import com.amazon.elasticsearch.replication.action.repository.GetStoreMetadataAction -import com.amazon.elasticsearch.replication.action.repository.ReleaseLeaderResourcesAction -import com.amazon.elasticsearch.replication.action.repository.TransportGetFileChunkAction -import com.amazon.elasticsearch.replication.action.repository.TransportGetStoreMetadataAction -import com.amazon.elasticsearch.replication.action.stop.StopIndexReplicationAction -import com.amazon.elasticsearch.replication.action.stop.TransportStopIndexReplicationAction -import com.amazon.elasticsearch.replication.action.repository.TransportReleaseLeaderResourcesAction -import com.amazon.elasticsearch.replication.metadata.ReplicationMetadata -import com.amazon.elasticsearch.replication.repository.REMOTE_REPOSITORY_TYPE -import com.amazon.elasticsearch.replication.repository.RemoteClusterRepositoriesService -import com.amazon.elasticsearch.replication.repository.RemoteClusterRepository -import com.amazon.elasticsearch.replication.repository.RemoteClusterRestoreLeaderService -import com.amazon.elasticsearch.replication.rest.ReplicateIndexHandler -import com.amazon.elasticsearch.replication.rest.StopIndexReplicationHandler -import com.amazon.elasticsearch.replication.rest.UpdateAutoFollowPatternsHandler -import com.amazon.elasticsearch.replication.task.IndexCloseListener -import com.amazon.elasticsearch.replication.task.autofollow.AutoFollowExecutor -import com.amazon.elasticsearch.replication.task.autofollow.AutoFollowParams -import com.amazon.elasticsearch.replication.task.index.IndexReplicationExecutor -import com.amazon.elasticsearch.replication.task.index.IndexReplicationParams -import com.amazon.elasticsearch.replication.task.index.IndexReplicationState -import com.amazon.elasticsearch.replication.task.shard.ShardReplicationExecutor -import com.amazon.elasticsearch.replication.task.shard.ShardReplicationParams -import com.amazon.elasticsearch.replication.task.shard.ShardReplicationState -import com.amazon.elasticsearch.replication.util.Injectables -import org.elasticsearch.action.ActionRequest -import org.elasticsearch.action.ActionResponse -import org.elasticsearch.client.Client -import org.elasticsearch.cluster.NamedDiff -import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver -import org.elasticsearch.cluster.metadata.Metadata -import org.elasticsearch.cluster.metadata.RepositoryMetadata -import org.elasticsearch.cluster.node.DiscoveryNodes -import org.elasticsearch.cluster.service.ClusterService -import org.elasticsearch.common.CheckedFunction -import org.elasticsearch.common.ParseField -import org.elasticsearch.common.component.LifecycleComponent -import org.elasticsearch.common.io.stream.NamedWriteableRegistry -import org.elasticsearch.common.io.stream.Writeable -import org.elasticsearch.common.settings.ClusterSettings -import org.elasticsearch.common.settings.IndexScopedSettings -import org.elasticsearch.common.settings.Setting -import org.elasticsearch.common.settings.Settings -import org.elasticsearch.common.settings.SettingsFilter -import org.elasticsearch.common.settings.SettingsModule -import org.elasticsearch.common.unit.TimeValue -import org.elasticsearch.common.xcontent.NamedXContentRegistry -import org.elasticsearch.common.xcontent.XContentParser -import org.elasticsearch.env.Environment -import org.elasticsearch.env.NodeEnvironment -import org.elasticsearch.index.IndexModule -import org.elasticsearch.index.IndexSettings -import org.elasticsearch.index.engine.EngineFactory -import org.elasticsearch.indices.recovery.RecoverySettings -import org.elasticsearch.persistent.PersistentTaskParams -import org.elasticsearch.persistent.PersistentTaskState -import org.elasticsearch.persistent.PersistentTasksExecutor -import org.elasticsearch.plugins.ActionPlugin -import org.elasticsearch.plugins.ActionPlugin.ActionHandler -import org.elasticsearch.plugins.EnginePlugin -import org.elasticsearch.plugins.PersistentTaskPlugin -import org.elasticsearch.plugins.Plugin -import org.elasticsearch.plugins.RepositoryPlugin -import org.elasticsearch.repositories.RepositoriesService -import org.elasticsearch.repositories.Repository -import org.elasticsearch.rest.RestController -import org.elasticsearch.rest.RestHandler -import org.elasticsearch.script.ScriptService -import org.elasticsearch.threadpool.ExecutorBuilder -import org.elasticsearch.threadpool.ScalingExecutorBuilder -import org.elasticsearch.threadpool.ThreadPool -import org.elasticsearch.watcher.ResourceWatcherService +package org.opensearch.replication + +import org.opensearch.replication.action.autofollow.TransportUpdateAutoFollowPatternAction +import org.opensearch.replication.action.autofollow.UpdateAutoFollowPatternAction +import org.opensearch.replication.action.changes.GetChangesAction +import org.opensearch.replication.action.changes.TransportGetChangesAction +import org.opensearch.replication.action.index.ReplicateIndexAction +import org.opensearch.replication.action.index.ReplicateIndexMasterNodeAction +import org.opensearch.replication.action.index.TransportReplicateIndexAction +import org.opensearch.replication.action.index.TransportReplicateIndexMasterNodeAction +import org.opensearch.replication.action.replay.ReplayChangesAction +import org.opensearch.replication.action.replay.TransportReplayChangesAction +import org.opensearch.replication.action.repository.GetFileChunkAction +import org.opensearch.replication.action.repository.GetStoreMetadataAction +import org.opensearch.replication.action.repository.ReleaseLeaderResourcesAction +import org.opensearch.replication.action.repository.TransportGetFileChunkAction +import org.opensearch.replication.action.repository.TransportGetStoreMetadataAction +import org.opensearch.replication.action.stop.StopIndexReplicationAction +import org.opensearch.replication.action.stop.TransportStopIndexReplicationAction +import org.opensearch.replication.action.repository.TransportReleaseLeaderResourcesAction +import org.opensearch.replication.metadata.ReplicationMetadata +import org.opensearch.replication.repository.REMOTE_REPOSITORY_TYPE +import org.opensearch.replication.repository.RemoteClusterRepositoriesService +import org.opensearch.replication.repository.RemoteClusterRepository +import org.opensearch.replication.repository.RemoteClusterRestoreLeaderService +import org.opensearch.replication.rest.ReplicateIndexHandler +import org.opensearch.replication.rest.StopIndexReplicationHandler +import org.opensearch.replication.rest.UpdateAutoFollowPatternsHandler +import org.opensearch.replication.task.IndexCloseListener +import org.opensearch.replication.task.autofollow.AutoFollowExecutor +import org.opensearch.replication.task.autofollow.AutoFollowParams +import org.opensearch.replication.task.index.IndexReplicationExecutor +import org.opensearch.replication.task.index.IndexReplicationParams +import org.opensearch.replication.task.index.IndexReplicationState +import org.opensearch.replication.task.shard.ShardReplicationExecutor +import org.opensearch.replication.task.shard.ShardReplicationParams +import org.opensearch.replication.task.shard.ShardReplicationState +import org.opensearch.replication.util.Injectables +import org.opensearch.action.ActionRequest +import org.opensearch.action.ActionResponse +import org.opensearch.client.Client +import org.opensearch.cluster.NamedDiff +import org.opensearch.cluster.metadata.IndexNameExpressionResolver +import org.opensearch.cluster.metadata.Metadata +import org.opensearch.cluster.metadata.RepositoryMetadata +import org.opensearch.cluster.node.DiscoveryNodes +import org.opensearch.cluster.service.ClusterService +import org.opensearch.common.CheckedFunction +import org.opensearch.common.ParseField +import org.opensearch.common.component.LifecycleComponent +import org.opensearch.common.io.stream.NamedWriteableRegistry +import org.opensearch.common.io.stream.Writeable +import org.opensearch.common.settings.ClusterSettings +import org.opensearch.common.settings.IndexScopedSettings +import org.opensearch.common.settings.Setting +import org.opensearch.common.settings.Settings +import org.opensearch.common.settings.SettingsFilter +import org.opensearch.common.settings.SettingsModule +import org.opensearch.common.unit.TimeValue +import org.opensearch.common.xcontent.NamedXContentRegistry +import org.opensearch.common.xcontent.XContentParser +import org.opensearch.env.Environment +import org.opensearch.env.NodeEnvironment +import org.opensearch.index.IndexModule +import org.opensearch.index.IndexSettings +import org.opensearch.index.engine.EngineFactory +import org.opensearch.indices.recovery.RecoverySettings +import org.opensearch.persistent.PersistentTaskParams +import org.opensearch.persistent.PersistentTaskState +import org.opensearch.persistent.PersistentTasksExecutor +import org.opensearch.plugins.ActionPlugin +import org.opensearch.plugins.ActionPlugin.ActionHandler +import org.opensearch.plugins.EnginePlugin +import org.opensearch.plugins.PersistentTaskPlugin +import org.opensearch.plugins.Plugin +import org.opensearch.plugins.RepositoryPlugin +import org.opensearch.repositories.RepositoriesService +import org.opensearch.repositories.Repository +import org.opensearch.rest.RestController +import org.opensearch.rest.RestHandler +import org.opensearch.script.ScriptService +import org.opensearch.threadpool.ExecutorBuilder +import org.opensearch.threadpool.ScalingExecutorBuilder +import org.opensearch.threadpool.ThreadPool +import org.opensearch.watcher.ResourceWatcherService import java.util.Optional import java.util.function.Supplier -import com.amazon.elasticsearch.replication.action.index.block.UpdateIndexBlockAction -import com.amazon.elasticsearch.replication.action.index.block.TransportUpddateIndexBlockAction +import org.opensearch.replication.action.index.block.UpdateIndexBlockAction +import org.opensearch.replication.action.index.block.TransportUpddateIndexBlockAction internal class ReplicationPlugin : Plugin(), ActionPlugin, PersistentTaskPlugin, RepositoryPlugin, EnginePlugin { diff --git a/src/main/kotlin/com/amazon/elasticsearch/replication/action/autofollow/TransportUpdateAutoFollowPatternAction.kt b/src/main/kotlin/org/opensearch/replication/action/autofollow/TransportUpdateAutoFollowPatternAction.kt similarity index 73% rename from src/main/kotlin/com/amazon/elasticsearch/replication/action/autofollow/TransportUpdateAutoFollowPatternAction.kt rename to src/main/kotlin/org/opensearch/replication/action/autofollow/TransportUpdateAutoFollowPatternAction.kt index 6de8e4bb..c8d84219 100644 --- a/src/main/kotlin/com/amazon/elasticsearch/replication/action/autofollow/TransportUpdateAutoFollowPatternAction.kt +++ b/src/main/kotlin/org/opensearch/replication/action/autofollow/TransportUpdateAutoFollowPatternAction.kt @@ -13,40 +13,40 @@ * permissions and limitations under the License. */ -package com.amazon.elasticsearch.replication.action.autofollow +package org.opensearch.replication.action.autofollow -import com.amazon.elasticsearch.replication.metadata.ReplicationMetadata -import com.amazon.elasticsearch.replication.metadata.UpdateAutoFollowPattern -import com.amazon.elasticsearch.replication.task.autofollow.AutoFollowExecutor -import com.amazon.elasticsearch.replication.task.autofollow.AutoFollowParams -import com.amazon.elasticsearch.replication.util.SecurityContext -import com.amazon.elasticsearch.replication.util.completeWith -import com.amazon.elasticsearch.replication.util.coroutineContext -import com.amazon.elasticsearch.replication.util.persistentTasksService -import com.amazon.elasticsearch.replication.util.removeTask -import com.amazon.elasticsearch.replication.util.startTask -import com.amazon.elasticsearch.replication.util.waitForClusterStateUpdate +import org.opensearch.replication.metadata.ReplicationMetadata +import org.opensearch.replication.metadata.UpdateAutoFollowPattern +import org.opensearch.replication.task.autofollow.AutoFollowExecutor +import org.opensearch.replication.task.autofollow.AutoFollowParams +import org.opensearch.replication.util.SecurityContext +import org.opensearch.replication.util.persistentTasksService import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.launch import org.apache.logging.log4j.LogManager -import org.elasticsearch.ElasticsearchException -import org.elasticsearch.ResourceAlreadyExistsException -import org.elasticsearch.ResourceNotFoundException -import org.elasticsearch.action.ActionListener -import org.elasticsearch.action.support.ActionFilters -import org.elasticsearch.action.support.master.AcknowledgedResponse -import org.elasticsearch.action.support.master.TransportMasterNodeAction -import org.elasticsearch.client.node.NodeClient -import org.elasticsearch.cluster.ClusterState -import org.elasticsearch.cluster.block.ClusterBlockException -import org.elasticsearch.cluster.block.ClusterBlockLevel -import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver -import org.elasticsearch.cluster.service.ClusterService -import org.elasticsearch.common.inject.Inject -import org.elasticsearch.common.io.stream.StreamInput -import org.elasticsearch.threadpool.ThreadPool -import org.elasticsearch.transport.TransportService +import org.opensearch.OpenSearchException +import org.opensearch.ResourceAlreadyExistsException +import org.opensearch.ResourceNotFoundException +import org.opensearch.action.ActionListener +import org.opensearch.action.support.ActionFilters +import org.opensearch.action.support.master.AcknowledgedResponse +import org.opensearch.action.support.master.TransportMasterNodeAction +import org.opensearch.client.node.NodeClient +import org.opensearch.cluster.ClusterState +import org.opensearch.cluster.block.ClusterBlockException +import org.opensearch.cluster.block.ClusterBlockLevel +import org.opensearch.cluster.metadata.IndexNameExpressionResolver +import org.opensearch.cluster.service.ClusterService +import org.opensearch.common.inject.Inject +import org.opensearch.common.io.stream.StreamInput +import org.opensearch.replication.util.completeWith +import org.opensearch.replication.util.coroutineContext +import org.opensearch.replication.util.removeTask +import org.opensearch.replication.util.startTask +import org.opensearch.replication.util.waitForClusterStateUpdate +import org.opensearch.threadpool.ThreadPool +import org.opensearch.transport.TransportService class TransportUpdateAutoFollowPatternAction @Inject constructor( transportService: TransportService, clusterService: ClusterService, threadPool: ThreadPool, @@ -92,7 +92,7 @@ class TransportUpdateAutoFollowPatternAction @Inject constructor( } if(!response.isAcknowledged) { - throw ElasticsearchException(AUTOFOLLOW_EXCEPTION_GENERIC_STRING) + throw OpenSearchException(AUTOFOLLOW_EXCEPTION_GENERIC_STRING) } if (request.action == UpdateAutoFollowPatternRequest.Action.ADD) { @@ -123,7 +123,7 @@ class TransportUpdateAutoFollowPatternAction @Inject constructor( log.warn("Task already started for '$clusterAlias:$patternName'", e) } catch (e: Exception) { log.error("Failed to start auto follow task for cluster '$clusterAlias:$patternName'", e) - throw ElasticsearchException(AUTOFOLLOW_EXCEPTION_GENERIC_STRING) + throw OpenSearchException(AUTOFOLLOW_EXCEPTION_GENERIC_STRING) } } @@ -135,7 +135,7 @@ class TransportUpdateAutoFollowPatternAction @Inject constructor( log.warn("Task already stopped for '$clusterAlias:$patternName'", e) } catch (e: Exception) { log.error("Failed to stop auto follow task for cluster '$clusterAlias:$patternName'", e) - throw ElasticsearchException(AUTOFOLLOW_EXCEPTION_GENERIC_STRING) + throw OpenSearchException(AUTOFOLLOW_EXCEPTION_GENERIC_STRING) } } } diff --git a/src/main/kotlin/com/amazon/elasticsearch/replication/action/autofollow/UpdateAutoFollowPatternAction.kt b/src/main/kotlin/org/opensearch/replication/action/autofollow/UpdateAutoFollowPatternAction.kt similarity index 83% rename from src/main/kotlin/com/amazon/elasticsearch/replication/action/autofollow/UpdateAutoFollowPatternAction.kt rename to src/main/kotlin/org/opensearch/replication/action/autofollow/UpdateAutoFollowPatternAction.kt index df2bc527..ab0bd4e0 100644 --- a/src/main/kotlin/com/amazon/elasticsearch/replication/action/autofollow/UpdateAutoFollowPatternAction.kt +++ b/src/main/kotlin/org/opensearch/replication/action/autofollow/UpdateAutoFollowPatternAction.kt @@ -13,10 +13,10 @@ * permissions and limitations under the License. */ -package com.amazon.elasticsearch.replication.action.autofollow +package org.opensearch.replication.action.autofollow -import org.elasticsearch.action.ActionType -import org.elasticsearch.action.support.master.AcknowledgedResponse +import org.opensearch.action.ActionType +import org.opensearch.action.support.master.AcknowledgedResponse class UpdateAutoFollowPatternAction : ActionType(NAME, ::AcknowledgedResponse) { diff --git a/src/main/kotlin/com/amazon/elasticsearch/replication/action/autofollow/UpdateAutoFollowPatternRequest.kt b/src/main/kotlin/org/opensearch/replication/action/autofollow/UpdateAutoFollowPatternRequest.kt similarity index 84% rename from src/main/kotlin/com/amazon/elasticsearch/replication/action/autofollow/UpdateAutoFollowPatternRequest.kt rename to src/main/kotlin/org/opensearch/replication/action/autofollow/UpdateAutoFollowPatternRequest.kt index ba3f6f97..886771dc 100644 --- a/src/main/kotlin/com/amazon/elasticsearch/replication/action/autofollow/UpdateAutoFollowPatternRequest.kt +++ b/src/main/kotlin/org/opensearch/replication/action/autofollow/UpdateAutoFollowPatternRequest.kt @@ -13,15 +13,15 @@ * permissions and limitations under the License. */ -package com.amazon.elasticsearch.replication.action.autofollow +package org.opensearch.replication.action.autofollow -import org.elasticsearch.action.ActionRequestValidationException -import org.elasticsearch.action.support.master.AcknowledgedRequest -import org.elasticsearch.common.io.stream.StreamInput -import org.elasticsearch.common.io.stream.StreamOutput -import org.elasticsearch.common.xcontent.XContentParser -import org.elasticsearch.common.xcontent.XContentParser.Token -import org.elasticsearch.common.xcontent.XContentParserUtils.ensureExpectedToken +import org.opensearch.action.ActionRequestValidationException +import org.opensearch.action.support.master.AcknowledgedRequest +import org.opensearch.common.io.stream.StreamInput +import org.opensearch.common.io.stream.StreamOutput +import org.opensearch.common.xcontent.XContentParser +import org.opensearch.common.xcontent.XContentParser.Token +import org.opensearch.common.xcontent.XContentParserUtils.ensureExpectedToken class UpdateAutoFollowPatternRequest: AcknowledgedRequest { diff --git a/src/main/kotlin/com/amazon/elasticsearch/replication/action/changes/GetChangesAction.kt b/src/main/kotlin/org/opensearch/replication/action/changes/GetChangesAction.kt similarity index 89% rename from src/main/kotlin/com/amazon/elasticsearch/replication/action/changes/GetChangesAction.kt rename to src/main/kotlin/org/opensearch/replication/action/changes/GetChangesAction.kt index 1fbe202d..20e14f3c 100644 --- a/src/main/kotlin/com/amazon/elasticsearch/replication/action/changes/GetChangesAction.kt +++ b/src/main/kotlin/org/opensearch/replication/action/changes/GetChangesAction.kt @@ -13,9 +13,9 @@ * permissions and limitations under the License. */ -package com.amazon.elasticsearch.replication.action.changes +package org.opensearch.replication.action.changes -import org.elasticsearch.action.ActionType +import org.opensearch.action.ActionType class GetChangesAction private constructor() : ActionType(NAME, ::GetChangesResponse) { diff --git a/src/main/kotlin/com/amazon/elasticsearch/replication/action/changes/GetChangesRequest.kt b/src/main/kotlin/org/opensearch/replication/action/changes/GetChangesRequest.kt similarity index 78% rename from src/main/kotlin/com/amazon/elasticsearch/replication/action/changes/GetChangesRequest.kt rename to src/main/kotlin/org/opensearch/replication/action/changes/GetChangesRequest.kt index 23eb13d2..43b88b2b 100644 --- a/src/main/kotlin/com/amazon/elasticsearch/replication/action/changes/GetChangesRequest.kt +++ b/src/main/kotlin/org/opensearch/replication/action/changes/GetChangesRequest.kt @@ -13,15 +13,15 @@ * permissions and limitations under the License. */ -package com.amazon.elasticsearch.replication.action.changes - -import org.elasticsearch.action.ActionRequestValidationException -import org.elasticsearch.action.support.single.shard.SingleShardRequest -import org.elasticsearch.cluster.node.DiscoveryNode -import org.elasticsearch.common.io.stream.StreamInput -import org.elasticsearch.common.io.stream.StreamOutput -import org.elasticsearch.index.shard.ShardId -import org.elasticsearch.transport.RemoteClusterAwareRequest +package org.opensearch.replication.action.changes + +import org.opensearch.action.ActionRequestValidationException +import org.opensearch.action.support.single.shard.SingleShardRequest +import org.opensearch.cluster.node.DiscoveryNode +import org.opensearch.common.io.stream.StreamInput +import org.opensearch.common.io.stream.StreamOutput +import org.opensearch.index.shard.ShardId +import org.opensearch.transport.RemoteClusterAwareRequest class GetChangesRequest : SingleShardRequest, RemoteClusterAwareRequest { diff --git a/src/main/kotlin/com/amazon/elasticsearch/replication/action/changes/GetChangesResponse.kt b/src/main/kotlin/org/opensearch/replication/action/changes/GetChangesResponse.kt similarity index 81% rename from src/main/kotlin/com/amazon/elasticsearch/replication/action/changes/GetChangesResponse.kt rename to src/main/kotlin/org/opensearch/replication/action/changes/GetChangesResponse.kt index d7a6947f..387f4109 100644 --- a/src/main/kotlin/com/amazon/elasticsearch/replication/action/changes/GetChangesResponse.kt +++ b/src/main/kotlin/org/opensearch/replication/action/changes/GetChangesResponse.kt @@ -13,12 +13,12 @@ * permissions and limitations under the License. */ -package com.amazon.elasticsearch.replication.action.changes +package org.opensearch.replication.action.changes -import org.elasticsearch.action.ActionResponse -import org.elasticsearch.common.io.stream.StreamInput -import org.elasticsearch.common.io.stream.StreamOutput -import org.elasticsearch.index.translog.Translog +import org.opensearch.action.ActionResponse +import org.opensearch.common.io.stream.StreamInput +import org.opensearch.common.io.stream.StreamOutput +import org.opensearch.index.translog.Translog class GetChangesResponse(val changes: List, val fromSeqNo: Long, diff --git a/src/main/kotlin/com/amazon/elasticsearch/replication/action/changes/TransportGetChangesAction.kt b/src/main/kotlin/org/opensearch/replication/action/changes/TransportGetChangesAction.kt similarity index 76% rename from src/main/kotlin/com/amazon/elasticsearch/replication/action/changes/TransportGetChangesAction.kt rename to src/main/kotlin/org/opensearch/replication/action/changes/TransportGetChangesAction.kt index 56fecd41..e1e7c3c2 100644 --- a/src/main/kotlin/com/amazon/elasticsearch/replication/action/changes/TransportGetChangesAction.kt +++ b/src/main/kotlin/org/opensearch/replication/action/changes/TransportGetChangesAction.kt @@ -13,32 +13,31 @@ * permissions and limitations under the License. */ -package com.amazon.elasticsearch.replication.action.changes +package org.opensearch.replication.action.changes -import com.amazon.elasticsearch.replication.action.repository.GetFileChunkAction -import com.amazon.elasticsearch.replication.util.completeWith -import com.amazon.elasticsearch.replication.util.coroutineContext -import com.amazon.elasticsearch.replication.util.waitForGlobalCheckpoint import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.launch -import org.elasticsearch.ElasticsearchTimeoutException -import org.elasticsearch.action.ActionListener -import org.elasticsearch.action.support.ActionFilters -import org.elasticsearch.action.support.single.shard.TransportSingleShardAction -import org.elasticsearch.cluster.ClusterState -import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver -import org.elasticsearch.cluster.routing.ShardsIterator -import org.elasticsearch.cluster.service.ClusterService -import org.elasticsearch.common.inject.Inject -import org.elasticsearch.common.io.stream.StreamInput -import org.elasticsearch.common.io.stream.Writeable -import org.elasticsearch.common.unit.TimeValue -import org.elasticsearch.index.shard.ShardId -import org.elasticsearch.index.translog.Translog -import org.elasticsearch.indices.IndicesService -import org.elasticsearch.threadpool.ThreadPool -import org.elasticsearch.transport.TransportActionProxy -import org.elasticsearch.transport.TransportService +import org.opensearch.OpenSearchTimeoutException +import org.opensearch.action.ActionListener +import org.opensearch.action.support.ActionFilters +import org.opensearch.action.support.single.shard.TransportSingleShardAction +import org.opensearch.cluster.ClusterState +import org.opensearch.cluster.metadata.IndexNameExpressionResolver +import org.opensearch.cluster.routing.ShardsIterator +import org.opensearch.cluster.service.ClusterService +import org.opensearch.common.inject.Inject +import org.opensearch.common.io.stream.StreamInput +import org.opensearch.common.io.stream.Writeable +import org.opensearch.common.unit.TimeValue +import org.opensearch.index.shard.ShardId +import org.opensearch.index.translog.Translog +import org.opensearch.indices.IndicesService +import org.opensearch.replication.util.completeWith +import org.opensearch.replication.util.coroutineContext +import org.opensearch.replication.util.waitForGlobalCheckpoint +import org.opensearch.threadpool.ThreadPool +import org.opensearch.transport.TransportActionProxy +import org.opensearch.transport.TransportService import kotlin.math.min class TransportGetChangesAction @Inject constructor(threadPool: ThreadPool, clusterService: ClusterService, @@ -78,7 +77,7 @@ class TransportGetChangesAction @Inject constructor(threadPool: ThreadPool, clus // TODO: Figure out a better way to wait for the global checkpoint to be synced to the translog if (indexShard.lastSyncedGlobalCheckpoint < request.fromSeqNo) { assert(gcp > indexShard.lastSyncedGlobalCheckpoint) { "Checkpoint didn't advance at all" } - throw ElasticsearchTimeoutException("global checkpoint not synced. Retry after a few miliseconds...") + throw OpenSearchTimeoutException("global checkpoint not synced. Retry after a few miliseconds...") } } diff --git a/src/main/kotlin/com/amazon/elasticsearch/replication/action/index/ReplicateIndexAction.kt b/src/main/kotlin/org/opensearch/replication/action/index/ReplicateIndexAction.kt similarity index 90% rename from src/main/kotlin/com/amazon/elasticsearch/replication/action/index/ReplicateIndexAction.kt rename to src/main/kotlin/org/opensearch/replication/action/index/ReplicateIndexAction.kt index 5af59697..8af2d449 100644 --- a/src/main/kotlin/com/amazon/elasticsearch/replication/action/index/ReplicateIndexAction.kt +++ b/src/main/kotlin/org/opensearch/replication/action/index/ReplicateIndexAction.kt @@ -13,9 +13,9 @@ * permissions and limitations under the License. */ -package com.amazon.elasticsearch.replication.action.index +package org.opensearch.replication.action.index -import org.elasticsearch.action.ActionType +import org.opensearch.action.ActionType class ReplicateIndexAction private constructor(): ActionType(NAME, ::ReplicateIndexResponse) { companion object { diff --git a/src/main/kotlin/com/amazon/elasticsearch/replication/action/index/ReplicateIndexMasterNodeAction.kt b/src/main/kotlin/org/opensearch/replication/action/index/ReplicateIndexMasterNodeAction.kt similarity index 84% rename from src/main/kotlin/com/amazon/elasticsearch/replication/action/index/ReplicateIndexMasterNodeAction.kt rename to src/main/kotlin/org/opensearch/replication/action/index/ReplicateIndexMasterNodeAction.kt index 7d97722b..c507444b 100644 --- a/src/main/kotlin/com/amazon/elasticsearch/replication/action/index/ReplicateIndexMasterNodeAction.kt +++ b/src/main/kotlin/org/opensearch/replication/action/index/ReplicateIndexMasterNodeAction.kt @@ -13,10 +13,10 @@ * permissions and limitations under the License. */ -package com.amazon.elasticsearch.replication.action.index +package org.opensearch.replication.action.index -import org.elasticsearch.action.ActionType -import org.elasticsearch.action.support.master.AcknowledgedResponse +import org.opensearch.action.ActionType +import org.opensearch.action.support.master.AcknowledgedResponse class ReplicateIndexMasterNodeAction private constructor(): ActionType(NAME, ::AcknowledgedResponse) { companion object { diff --git a/src/main/kotlin/com/amazon/elasticsearch/replication/action/index/ReplicateIndexMasterNodeRequest.kt b/src/main/kotlin/org/opensearch/replication/action/index/ReplicateIndexMasterNodeRequest.kt similarity index 78% rename from src/main/kotlin/com/amazon/elasticsearch/replication/action/index/ReplicateIndexMasterNodeRequest.kt rename to src/main/kotlin/org/opensearch/replication/action/index/ReplicateIndexMasterNodeRequest.kt index b108b7d5..2bff2508 100644 --- a/src/main/kotlin/com/amazon/elasticsearch/replication/action/index/ReplicateIndexMasterNodeRequest.kt +++ b/src/main/kotlin/org/opensearch/replication/action/index/ReplicateIndexMasterNodeRequest.kt @@ -13,15 +13,15 @@ * permissions and limitations under the License. */ -package com.amazon.elasticsearch.replication.action.index - -import org.elasticsearch.action.ActionRequestValidationException -import org.elasticsearch.action.support.master.MasterNodeRequest -import org.elasticsearch.common.io.stream.StreamInput -import org.elasticsearch.common.io.stream.StreamOutput -import org.elasticsearch.common.xcontent.ToXContent -import org.elasticsearch.common.xcontent.ToXContentObject -import org.elasticsearch.common.xcontent.XContentBuilder +package org.opensearch.replication.action.index + +import org.opensearch.action.ActionRequestValidationException +import org.opensearch.action.support.master.MasterNodeRequest +import org.opensearch.common.io.stream.StreamInput +import org.opensearch.common.io.stream.StreamOutput +import org.opensearch.common.xcontent.ToXContent +import org.opensearch.common.xcontent.ToXContentObject +import org.opensearch.common.xcontent.XContentBuilder class ReplicateIndexMasterNodeRequest: MasterNodeRequest, ToXContentObject { diff --git a/src/main/kotlin/com/amazon/elasticsearch/replication/action/index/ReplicateIndexRequest.kt b/src/main/kotlin/org/opensearch/replication/action/index/ReplicateIndexRequest.kt similarity index 83% rename from src/main/kotlin/com/amazon/elasticsearch/replication/action/index/ReplicateIndexRequest.kt rename to src/main/kotlin/org/opensearch/replication/action/index/ReplicateIndexRequest.kt index e4af8ffa..696d5ccd 100644 --- a/src/main/kotlin/com/amazon/elasticsearch/replication/action/index/ReplicateIndexRequest.kt +++ b/src/main/kotlin/org/opensearch/replication/action/index/ReplicateIndexRequest.kt @@ -13,20 +13,20 @@ * permissions and limitations under the License. */ -package com.amazon.elasticsearch.replication.action.index - -import org.elasticsearch.action.ActionRequestValidationException -import org.elasticsearch.action.IndicesRequest -import org.elasticsearch.action.support.IndicesOptions -import org.elasticsearch.action.support.master.AcknowledgedRequest -import org.elasticsearch.common.ParseField -import org.elasticsearch.common.io.stream.StreamInput -import org.elasticsearch.common.io.stream.StreamOutput -import org.elasticsearch.common.xcontent.ObjectParser -import org.elasticsearch.common.xcontent.ToXContent.Params -import org.elasticsearch.common.xcontent.ToXContentObject -import org.elasticsearch.common.xcontent.XContentBuilder -import org.elasticsearch.common.xcontent.XContentParser +package org.opensearch.replication.action.index + +import org.opensearch.action.ActionRequestValidationException +import org.opensearch.action.IndicesRequest +import org.opensearch.action.support.IndicesOptions +import org.opensearch.action.support.master.AcknowledgedRequest +import org.opensearch.common.ParseField +import org.opensearch.common.io.stream.StreamInput +import org.opensearch.common.io.stream.StreamOutput +import org.opensearch.common.xcontent.ObjectParser +import org.opensearch.common.xcontent.ToXContent.Params +import org.opensearch.common.xcontent.ToXContentObject +import org.opensearch.common.xcontent.XContentBuilder +import org.opensearch.common.xcontent.XContentParser import java.io.IOException class ReplicateIndexRequest : AcknowledgedRequest, IndicesRequest.Replaceable, ToXContentObject { diff --git a/src/main/kotlin/com/amazon/elasticsearch/replication/action/index/ReplicateIndexResponse.kt b/src/main/kotlin/org/opensearch/replication/action/index/ReplicateIndexResponse.kt similarity index 78% rename from src/main/kotlin/com/amazon/elasticsearch/replication/action/index/ReplicateIndexResponse.kt rename to src/main/kotlin/org/opensearch/replication/action/index/ReplicateIndexResponse.kt index 6f4e83f8..3f48907b 100644 --- a/src/main/kotlin/com/amazon/elasticsearch/replication/action/index/ReplicateIndexResponse.kt +++ b/src/main/kotlin/org/opensearch/replication/action/index/ReplicateIndexResponse.kt @@ -13,11 +13,11 @@ * permissions and limitations under the License. */ -package com.amazon.elasticsearch.replication.action.index +package org.opensearch.replication.action.index -import org.elasticsearch.action.support.master.AcknowledgedResponse -import org.elasticsearch.common.io.stream.StreamInput -import org.elasticsearch.common.io.stream.StreamOutput +import org.opensearch.action.support.master.AcknowledgedResponse +import org.opensearch.common.io.stream.StreamInput +import org.opensearch.common.io.stream.StreamOutput class ReplicateIndexResponse(acknowledged: Boolean) : AcknowledgedResponse(acknowledged) { constructor(inp: StreamInput) : this(inp.readBoolean()) diff --git a/src/main/kotlin/com/amazon/elasticsearch/replication/action/index/TransportReplicateIndexAction.kt b/src/main/kotlin/org/opensearch/replication/action/index/TransportReplicateIndexAction.kt similarity index 77% rename from src/main/kotlin/com/amazon/elasticsearch/replication/action/index/TransportReplicateIndexAction.kt rename to src/main/kotlin/org/opensearch/replication/action/index/TransportReplicateIndexAction.kt index f27a76e9..e703fd5e 100644 --- a/src/main/kotlin/com/amazon/elasticsearch/replication/action/index/TransportReplicateIndexAction.kt +++ b/src/main/kotlin/org/opensearch/replication/action/index/TransportReplicateIndexAction.kt @@ -13,25 +13,21 @@ * permissions and limitations under the License. */ -package com.amazon.elasticsearch.replication.action.index +package org.opensearch.replication.action.index -import com.amazon.elasticsearch.replication.util.SecurityContext -import com.amazon.elasticsearch.replication.util.coroutineContext -import com.amazon.elasticsearch.replication.util.suspendExecute +import org.opensearch.replication.util.SecurityContext import kotlinx.coroutines.CoroutineScope -import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch import org.apache.logging.log4j.LogManager -import org.elasticsearch.action.ActionListener -import org.elasticsearch.action.support.ActionFilters -import org.elasticsearch.action.support.HandledTransportAction -import org.elasticsearch.action.support.master.AcknowledgedResponse -import org.elasticsearch.client.Client -import org.elasticsearch.common.inject.Inject -import org.elasticsearch.tasks.Task -import org.elasticsearch.threadpool.ThreadPool -import org.elasticsearch.transport.TransportService +import org.opensearch.action.ActionListener +import org.opensearch.action.support.ActionFilters +import org.opensearch.action.support.HandledTransportAction +import org.opensearch.action.support.master.AcknowledgedResponse +import org.opensearch.client.Client +import org.opensearch.common.inject.Inject +import org.opensearch.tasks.Task +import org.opensearch.threadpool.ThreadPool +import org.opensearch.transport.TransportService class TransportReplicateIndexAction @Inject constructor(transportService: TransportService, val threadPool: ThreadPool, diff --git a/src/main/kotlin/com/amazon/elasticsearch/replication/action/index/TransportReplicateIndexMasterNodeAction.kt b/src/main/kotlin/org/opensearch/replication/action/index/TransportReplicateIndexMasterNodeAction.kt similarity index 73% rename from src/main/kotlin/com/amazon/elasticsearch/replication/action/index/TransportReplicateIndexMasterNodeAction.kt rename to src/main/kotlin/org/opensearch/replication/action/index/TransportReplicateIndexMasterNodeAction.kt index 7d694265..6941d816 100644 --- a/src/main/kotlin/com/amazon/elasticsearch/replication/action/index/TransportReplicateIndexMasterNodeAction.kt +++ b/src/main/kotlin/org/opensearch/replication/action/index/TransportReplicateIndexMasterNodeAction.kt @@ -13,49 +13,49 @@ * permissions and limitations under the License. */ -package com.amazon.elasticsearch.replication.action.index - -import com.amazon.elasticsearch.replication.action.replicationstatedetails.UpdateReplicationStateDetailsRequest -import com.amazon.elasticsearch.replication.metadata.REPLICATION_OVERALL_STATE_KEY -import com.amazon.elasticsearch.replication.metadata.REPLICATION_OVERALL_STATE_RUNNING_VALUE -import com.amazon.elasticsearch.replication.metadata.UpdateReplicatedIndices -import com.amazon.elasticsearch.replication.metadata.UpdateReplicationStateDetailsTaskExecutor -import com.amazon.elasticsearch.replication.task.ReplicationState -import com.amazon.elasticsearch.replication.task.index.IndexReplicationExecutor -import com.amazon.elasticsearch.replication.task.index.IndexReplicationParams -import com.amazon.elasticsearch.replication.task.index.IndexReplicationState -import com.amazon.elasticsearch.replication.util.coroutineContext -import com.amazon.elasticsearch.replication.util.startTask -import com.amazon.elasticsearch.replication.util.submitClusterStateUpdateTask -import com.amazon.elasticsearch.replication.util.suspending -import com.amazon.elasticsearch.replication.util.waitForClusterStateUpdate -import com.amazon.elasticsearch.replication.util.waitForTaskCondition +package org.opensearch.replication.action.index + +import org.opensearch.replication.action.replicationstatedetails.UpdateReplicationStateDetailsRequest +import org.opensearch.replication.metadata.REPLICATION_OVERALL_STATE_KEY +import org.opensearch.replication.metadata.REPLICATION_OVERALL_STATE_RUNNING_VALUE +import org.opensearch.replication.metadata.UpdateReplicatedIndices +import org.opensearch.replication.metadata.UpdateReplicationStateDetailsTaskExecutor +import org.opensearch.replication.task.ReplicationState +import org.opensearch.replication.task.index.IndexReplicationExecutor +import org.opensearch.replication.task.index.IndexReplicationParams +import org.opensearch.replication.task.index.IndexReplicationState +import org.opensearch.replication.util.submitClusterStateUpdateTask +import org.opensearch.replication.util.suspending import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.launch import org.apache.logging.log4j.LogManager -import org.elasticsearch.action.ActionListener -import org.elasticsearch.action.support.ActionFilters -import org.elasticsearch.action.support.IndicesOptions -import org.elasticsearch.action.support.master.AcknowledgedRequest -import org.elasticsearch.action.support.master.AcknowledgedResponse -import org.elasticsearch.action.support.master.TransportMasterNodeAction -import org.elasticsearch.client.node.NodeClient -import org.elasticsearch.cluster.ClusterState -import org.elasticsearch.cluster.ClusterStateTaskExecutor -import org.elasticsearch.cluster.block.ClusterBlockException -import org.elasticsearch.cluster.block.ClusterBlockLevel -import org.elasticsearch.cluster.metadata.IndexMetadata -import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver -import org.elasticsearch.cluster.service.ClusterService -import org.elasticsearch.common.inject.Inject -import org.elasticsearch.common.io.stream.StreamInput -import org.elasticsearch.index.IndexNotFoundException -import org.elasticsearch.persistent.PersistentTasksService -import org.elasticsearch.repositories.RepositoriesService -import org.elasticsearch.threadpool.ThreadPool -import org.elasticsearch.transport.TransportService +import org.opensearch.action.ActionListener +import org.opensearch.action.support.ActionFilters +import org.opensearch.action.support.IndicesOptions +import org.opensearch.action.support.master.AcknowledgedRequest +import org.opensearch.action.support.master.AcknowledgedResponse +import org.opensearch.action.support.master.TransportMasterNodeAction +import org.opensearch.client.node.NodeClient +import org.opensearch.cluster.ClusterState +import org.opensearch.cluster.ClusterStateTaskExecutor +import org.opensearch.cluster.block.ClusterBlockException +import org.opensearch.cluster.block.ClusterBlockLevel +import org.opensearch.cluster.metadata.IndexMetadata +import org.opensearch.cluster.metadata.IndexNameExpressionResolver +import org.opensearch.cluster.service.ClusterService +import org.opensearch.common.inject.Inject +import org.opensearch.common.io.stream.StreamInput +import org.opensearch.index.IndexNotFoundException +import org.opensearch.persistent.PersistentTasksService +import org.opensearch.replication.util.coroutineContext +import org.opensearch.replication.util.startTask +import org.opensearch.replication.util.waitForClusterStateUpdate +import org.opensearch.replication.util.waitForTaskCondition +import org.opensearch.repositories.RepositoriesService +import org.opensearch.threadpool.ThreadPool +import org.opensearch.transport.TransportService import java.io.IOException class TransportReplicateIndexMasterNodeAction @Inject constructor(transportService: TransportService, diff --git a/src/main/kotlin/com/amazon/elasticsearch/replication/action/index/block/TransportUpddateIndexBlockAction.kt b/src/main/kotlin/org/opensearch/replication/action/index/block/TransportUpddateIndexBlockAction.kt similarity index 72% rename from src/main/kotlin/com/amazon/elasticsearch/replication/action/index/block/TransportUpddateIndexBlockAction.kt rename to src/main/kotlin/org/opensearch/replication/action/index/block/TransportUpddateIndexBlockAction.kt index 7aab567f..6b975681 100644 --- a/src/main/kotlin/com/amazon/elasticsearch/replication/action/index/block/TransportUpddateIndexBlockAction.kt +++ b/src/main/kotlin/org/opensearch/replication/action/index/block/TransportUpddateIndexBlockAction.kt @@ -13,32 +13,32 @@ * permissions and limitations under the License. */ -package com.amazon.elasticsearch.replication.action.index.block +package org.opensearch.replication.action.index.block -import com.amazon.elasticsearch.replication.metadata.AddIndexBlockTask -import com.amazon.elasticsearch.replication.metadata.checkIfIndexBlockedWithLevel -import com.amazon.elasticsearch.replication.util.completeWith -import com.amazon.elasticsearch.replication.util.coroutineContext -import com.amazon.elasticsearch.replication.util.waitForClusterStateUpdate +import org.opensearch.replication.metadata.AddIndexBlockTask +import org.opensearch.replication.metadata.checkIfIndexBlockedWithLevel import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.launch import org.apache.logging.log4j.LogManager -import org.elasticsearch.ElasticsearchException -import org.elasticsearch.action.ActionListener -import org.elasticsearch.action.support.ActionFilters -import org.elasticsearch.action.support.master.AcknowledgedResponse -import org.elasticsearch.action.support.master.TransportMasterNodeAction -import org.elasticsearch.client.Client -import org.elasticsearch.cluster.ClusterState -import org.elasticsearch.cluster.block.ClusterBlockException -import org.elasticsearch.cluster.block.ClusterBlockLevel -import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver -import org.elasticsearch.cluster.service.ClusterService -import org.elasticsearch.common.inject.Inject -import org.elasticsearch.common.io.stream.StreamInput -import org.elasticsearch.threadpool.ThreadPool -import org.elasticsearch.transport.TransportService +import org.opensearch.OpenSearchException +import org.opensearch.action.ActionListener +import org.opensearch.action.support.ActionFilters +import org.opensearch.action.support.master.AcknowledgedResponse +import org.opensearch.action.support.master.TransportMasterNodeAction +import org.opensearch.client.Client +import org.opensearch.cluster.ClusterState +import org.opensearch.cluster.block.ClusterBlockException +import org.opensearch.cluster.block.ClusterBlockLevel +import org.opensearch.cluster.metadata.IndexNameExpressionResolver +import org.opensearch.cluster.service.ClusterService +import org.opensearch.common.inject.Inject +import org.opensearch.common.io.stream.StreamInput +import org.opensearch.replication.util.completeWith +import org.opensearch.replication.util.coroutineContext +import org.opensearch.replication.util.waitForClusterStateUpdate +import org.opensearch.threadpool.ThreadPool +import org.opensearch.transport.TransportService import java.io.IOException @@ -84,7 +84,7 @@ class TransportUpddateIndexBlockAction @Inject constructor(transportService: Tra AddIndexBlockTask(UpdateIndexBlockRequest(indexName, IndexBlockUpdateType.ADD_BLOCK), l) } if (!addIndexBlockTaskResponse.isAcknowledged) { - throw ElasticsearchException("Failed to add index block to index:$indexName") + throw OpenSearchException("Failed to add index block to index:$indexName") } return addIndexBlockTaskResponse } diff --git a/src/main/kotlin/com/amazon/elasticsearch/replication/action/index/block/UpdateIndexBlockAction.kt b/src/main/kotlin/org/opensearch/replication/action/index/block/UpdateIndexBlockAction.kt similarity index 84% rename from src/main/kotlin/com/amazon/elasticsearch/replication/action/index/block/UpdateIndexBlockAction.kt rename to src/main/kotlin/org/opensearch/replication/action/index/block/UpdateIndexBlockAction.kt index 9073ae24..3fc99af0 100644 --- a/src/main/kotlin/com/amazon/elasticsearch/replication/action/index/block/UpdateIndexBlockAction.kt +++ b/src/main/kotlin/org/opensearch/replication/action/index/block/UpdateIndexBlockAction.kt @@ -13,10 +13,10 @@ * permissions and limitations under the License. */ -package com.amazon.elasticsearch.replication.action.index.block +package org.opensearch.replication.action.index.block -import org.elasticsearch.action.ActionType -import org.elasticsearch.action.support.master.AcknowledgedResponse +import org.opensearch.action.ActionType +import org.opensearch.action.support.master.AcknowledgedResponse class UpdateIndexBlockAction private constructor(): ActionType(NAME, ::AcknowledgedResponse) { companion object { diff --git a/src/main/kotlin/com/amazon/elasticsearch/replication/action/index/block/UpdateIndexBlockRequest.kt b/src/main/kotlin/org/opensearch/replication/action/index/block/UpdateIndexBlockRequest.kt similarity index 74% rename from src/main/kotlin/com/amazon/elasticsearch/replication/action/index/block/UpdateIndexBlockRequest.kt rename to src/main/kotlin/org/opensearch/replication/action/index/block/UpdateIndexBlockRequest.kt index ef6caf93..ec0a0844 100644 --- a/src/main/kotlin/com/amazon/elasticsearch/replication/action/index/block/UpdateIndexBlockRequest.kt +++ b/src/main/kotlin/org/opensearch/replication/action/index/block/UpdateIndexBlockRequest.kt @@ -13,20 +13,19 @@ * permissions and limitations under the License. */ -package com.amazon.elasticsearch.replication.action.index.block +package org.opensearch.replication.action.index.block -import org.elasticsearch.action.ActionRequestValidationException -import org.elasticsearch.action.IndicesRequest -import org.elasticsearch.action.support.IndicesOptions -import org.elasticsearch.action.support.master.AcknowledgedRequest -import org.elasticsearch.common.ParseField -import org.elasticsearch.common.io.stream.StreamInput -import org.elasticsearch.common.io.stream.StreamOutput -import org.elasticsearch.common.xcontent.ObjectParser -import org.elasticsearch.common.xcontent.ToXContent -import org.elasticsearch.common.xcontent.ToXContentObject -import org.elasticsearch.common.xcontent.XContentBuilder -import java.util.function.Supplier +import org.opensearch.action.ActionRequestValidationException +import org.opensearch.action.IndicesRequest +import org.opensearch.action.support.IndicesOptions +import org.opensearch.action.support.master.AcknowledgedRequest +import org.opensearch.common.ParseField +import org.opensearch.common.io.stream.StreamInput +import org.opensearch.common.io.stream.StreamOutput +import org.opensearch.common.xcontent.ObjectParser +import org.opensearch.common.xcontent.ToXContent +import org.opensearch.common.xcontent.ToXContentObject +import org.opensearch.common.xcontent.XContentBuilder enum class IndexBlockUpdateType { ADD_BLOCK, REMOVE_BLOCK diff --git a/src/main/kotlin/com/amazon/elasticsearch/replication/action/replay/ReplayChangesAction.kt b/src/main/kotlin/org/opensearch/replication/action/replay/ReplayChangesAction.kt similarity index 89% rename from src/main/kotlin/com/amazon/elasticsearch/replication/action/replay/ReplayChangesAction.kt rename to src/main/kotlin/org/opensearch/replication/action/replay/ReplayChangesAction.kt index 87fe8e38..a9182d14 100644 --- a/src/main/kotlin/com/amazon/elasticsearch/replication/action/replay/ReplayChangesAction.kt +++ b/src/main/kotlin/org/opensearch/replication/action/replay/ReplayChangesAction.kt @@ -13,9 +13,9 @@ * permissions and limitations under the License. */ -package com.amazon.elasticsearch.replication.action.replay +package org.opensearch.replication.action.replay -import org.elasticsearch.action.ActionType +import org.opensearch.action.ActionType class ReplayChangesAction private constructor() : ActionType(NAME, ::ReplayChangesResponse) { diff --git a/src/main/kotlin/com/amazon/elasticsearch/replication/action/replay/ReplayChangesRequest.kt b/src/main/kotlin/org/opensearch/replication/action/replay/ReplayChangesRequest.kt similarity index 84% rename from src/main/kotlin/com/amazon/elasticsearch/replication/action/replay/ReplayChangesRequest.kt rename to src/main/kotlin/org/opensearch/replication/action/replay/ReplayChangesRequest.kt index 9e95c878..1fff54d1 100644 --- a/src/main/kotlin/com/amazon/elasticsearch/replication/action/replay/ReplayChangesRequest.kt +++ b/src/main/kotlin/org/opensearch/replication/action/replay/ReplayChangesRequest.kt @@ -13,13 +13,13 @@ * permissions and limitations under the License. */ -package com.amazon.elasticsearch.replication.action.replay +package org.opensearch.replication.action.replay -import org.elasticsearch.action.support.replication.ReplicatedWriteRequest -import org.elasticsearch.common.io.stream.StreamInput -import org.elasticsearch.common.io.stream.StreamOutput -import org.elasticsearch.index.shard.ShardId -import org.elasticsearch.index.translog.Translog +import org.opensearch.action.support.replication.ReplicatedWriteRequest +import org.opensearch.common.io.stream.StreamInput +import org.opensearch.common.io.stream.StreamOutput +import org.opensearch.index.shard.ShardId +import org.opensearch.index.translog.Translog class ReplayChangesRequest : ReplicatedWriteRequest { diff --git a/src/main/kotlin/com/amazon/elasticsearch/replication/action/replay/ReplayChangesResponse.kt b/src/main/kotlin/org/opensearch/replication/action/replay/ReplayChangesResponse.kt similarity index 77% rename from src/main/kotlin/com/amazon/elasticsearch/replication/action/replay/ReplayChangesResponse.kt rename to src/main/kotlin/org/opensearch/replication/action/replay/ReplayChangesResponse.kt index 26dcea72..d765f090 100644 --- a/src/main/kotlin/com/amazon/elasticsearch/replication/action/replay/ReplayChangesResponse.kt +++ b/src/main/kotlin/org/opensearch/replication/action/replay/ReplayChangesResponse.kt @@ -13,11 +13,11 @@ * permissions and limitations under the License. */ -package com.amazon.elasticsearch.replication.action.replay +package org.opensearch.replication.action.replay -import org.elasticsearch.action.support.WriteResponse -import org.elasticsearch.action.support.replication.ReplicationResponse -import org.elasticsearch.common.io.stream.StreamInput +import org.opensearch.action.support.WriteResponse +import org.opensearch.action.support.replication.ReplicationResponse +import org.opensearch.common.io.stream.StreamInput class ReplayChangesResponse : ReplicationResponse, WriteResponse { diff --git a/src/main/kotlin/com/amazon/elasticsearch/replication/action/replay/TransportReplayChangesAction.kt b/src/main/kotlin/org/opensearch/replication/action/replay/TransportReplayChangesAction.kt similarity index 84% rename from src/main/kotlin/com/amazon/elasticsearch/replication/action/replay/TransportReplayChangesAction.kt rename to src/main/kotlin/org/opensearch/replication/action/replay/TransportReplayChangesAction.kt index 61f1ed60..5c99e3d3 100644 --- a/src/main/kotlin/com/amazon/elasticsearch/replication/action/replay/TransportReplayChangesAction.kt +++ b/src/main/kotlin/org/opensearch/replication/action/replay/TransportReplayChangesAction.kt @@ -13,47 +13,47 @@ * permissions and limitations under the License. */ -package com.amazon.elasticsearch.replication.action.replay - -import com.amazon.elasticsearch.replication.ReplicationException -import com.amazon.elasticsearch.replication.metadata.checkIfIndexBlockedWithLevel -import com.amazon.elasticsearch.replication.util.completeWith -import com.amazon.elasticsearch.replication.util.coroutineContext -import com.amazon.elasticsearch.replication.util.suspending -import com.amazon.elasticsearch.replication.util.waitForNextChange +package org.opensearch.replication.action.replay + +import org.opensearch.replication.ReplicationException +import org.opensearch.replication.metadata.checkIfIndexBlockedWithLevel +import org.opensearch.replication.util.suspending +import org.opensearch.replication.util.waitForNextChange import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.SupervisorJob import kotlinx.coroutines.asCoroutineDispatcher import kotlinx.coroutines.launch import org.apache.logging.log4j.LogManager -import org.elasticsearch.action.ActionListener -import org.elasticsearch.action.admin.indices.mapping.get.GetMappingsRequest -import org.elasticsearch.action.admin.indices.mapping.put.PutMappingRequest -import org.elasticsearch.action.bulk.TransportShardBulkAction -import org.elasticsearch.action.resync.TransportResyncReplicationAction -import org.elasticsearch.action.support.ActionFilters -import org.elasticsearch.action.support.IndicesOptions -import org.elasticsearch.action.support.replication.TransportWriteAction -import org.elasticsearch.client.Client -import org.elasticsearch.cluster.ClusterStateObserver -import org.elasticsearch.cluster.action.index.MappingUpdatedAction -import org.elasticsearch.cluster.action.shard.ShardStateAction -import org.elasticsearch.cluster.block.ClusterBlockLevel -import org.elasticsearch.cluster.service.ClusterService -import org.elasticsearch.common.bytes.BytesReference -import org.elasticsearch.common.inject.Inject -import org.elasticsearch.common.io.stream.StreamInput -import org.elasticsearch.common.io.stream.Writeable -import org.elasticsearch.common.settings.Settings -import org.elasticsearch.common.xcontent.XContentType -import org.elasticsearch.index.IndexingPressure -import org.elasticsearch.index.engine.Engine -import org.elasticsearch.index.shard.IndexShard -import org.elasticsearch.index.translog.Translog -import org.elasticsearch.indices.IndicesService -import org.elasticsearch.indices.SystemIndices -import org.elasticsearch.threadpool.ThreadPool -import org.elasticsearch.transport.TransportService +import org.opensearch.action.ActionListener +import org.opensearch.action.admin.indices.mapping.get.GetMappingsRequest +import org.opensearch.action.admin.indices.mapping.put.PutMappingRequest +import org.opensearch.action.bulk.TransportShardBulkAction +import org.opensearch.action.resync.TransportResyncReplicationAction +import org.opensearch.action.support.ActionFilters +import org.opensearch.action.support.IndicesOptions +import org.opensearch.action.support.replication.TransportWriteAction +import org.opensearch.client.Client +import org.opensearch.cluster.ClusterStateObserver +import org.opensearch.cluster.action.index.MappingUpdatedAction +import org.opensearch.cluster.action.shard.ShardStateAction +import org.opensearch.cluster.block.ClusterBlockLevel +import org.opensearch.cluster.service.ClusterService +import org.opensearch.common.bytes.BytesReference +import org.opensearch.common.inject.Inject +import org.opensearch.common.io.stream.StreamInput +import org.opensearch.common.io.stream.Writeable +import org.opensearch.common.settings.Settings +import org.opensearch.common.xcontent.XContentType +import org.opensearch.index.IndexingPressure +import org.opensearch.index.engine.Engine +import org.opensearch.index.shard.IndexShard +import org.opensearch.index.translog.Translog +import org.opensearch.indices.IndicesService +import org.opensearch.indices.SystemIndices +import org.opensearch.replication.util.completeWith +import org.opensearch.replication.util.coroutineContext +import org.opensearch.threadpool.ThreadPool +import org.opensearch.transport.TransportService import java.util.function.Function /** diff --git a/src/main/kotlin/com/amazon/elasticsearch/replication/action/replicationstatedetails/UpdateReplicationStateDetailsRequest.kt b/src/main/kotlin/org/opensearch/replication/action/replicationstatedetails/UpdateReplicationStateDetailsRequest.kt similarity index 81% rename from src/main/kotlin/com/amazon/elasticsearch/replication/action/replicationstatedetails/UpdateReplicationStateDetailsRequest.kt rename to src/main/kotlin/org/opensearch/replication/action/replicationstatedetails/UpdateReplicationStateDetailsRequest.kt index 15e86f87..0504b5bc 100644 --- a/src/main/kotlin/com/amazon/elasticsearch/replication/action/replicationstatedetails/UpdateReplicationStateDetailsRequest.kt +++ b/src/main/kotlin/org/opensearch/replication/action/replicationstatedetails/UpdateReplicationStateDetailsRequest.kt @@ -13,13 +13,13 @@ * permissions and limitations under the License. */ -package com.amazon.elasticsearch.replication.action.replicationstatedetails +package org.opensearch.replication.action.replicationstatedetails -import com.amazon.elasticsearch.replication.metadata.ReplicationStateParams -import org.elasticsearch.action.ActionRequestValidationException -import org.elasticsearch.action.support.master.AcknowledgedRequest -import org.elasticsearch.common.io.stream.StreamInput -import org.elasticsearch.common.io.stream.StreamOutput +import org.opensearch.replication.metadata.ReplicationStateParams +import org.opensearch.action.ActionRequestValidationException +import org.opensearch.action.support.master.AcknowledgedRequest +import org.opensearch.common.io.stream.StreamInput +import org.opensearch.common.io.stream.StreamOutput class UpdateReplicationStateDetailsRequest: AcknowledgedRequest { diff --git a/src/main/kotlin/com/amazon/elasticsearch/replication/action/repository/GetFileChunkAction.kt b/src/main/kotlin/org/opensearch/replication/action/repository/GetFileChunkAction.kt similarity index 89% rename from src/main/kotlin/com/amazon/elasticsearch/replication/action/repository/GetFileChunkAction.kt rename to src/main/kotlin/org/opensearch/replication/action/repository/GetFileChunkAction.kt index 9f0948f2..5fc4650f 100644 --- a/src/main/kotlin/com/amazon/elasticsearch/replication/action/repository/GetFileChunkAction.kt +++ b/src/main/kotlin/org/opensearch/replication/action/repository/GetFileChunkAction.kt @@ -13,9 +13,9 @@ * permissions and limitations under the License. */ -package com.amazon.elasticsearch.replication.action.repository +package org.opensearch.replication.action.repository -import org.elasticsearch.action.ActionType +import org.opensearch.action.ActionType class GetFileChunkAction private constructor() : ActionType(NAME, ::GetFileChunkResponse) { companion object { diff --git a/src/main/kotlin/com/amazon/elasticsearch/replication/action/repository/GetFileChunkRequest.kt b/src/main/kotlin/org/opensearch/replication/action/repository/GetFileChunkRequest.kt similarity index 76% rename from src/main/kotlin/com/amazon/elasticsearch/replication/action/repository/GetFileChunkRequest.kt rename to src/main/kotlin/org/opensearch/replication/action/repository/GetFileChunkRequest.kt index 126f9496..475a7bdc 100644 --- a/src/main/kotlin/com/amazon/elasticsearch/replication/action/repository/GetFileChunkRequest.kt +++ b/src/main/kotlin/org/opensearch/replication/action/repository/GetFileChunkRequest.kt @@ -13,16 +13,16 @@ * permissions and limitations under the License. */ -package com.amazon.elasticsearch.replication.action.repository +package org.opensearch.replication.action.repository -import org.elasticsearch.action.ActionRequestValidationException -import org.elasticsearch.action.support.single.shard.SingleShardRequest -import org.elasticsearch.cluster.node.DiscoveryNode -import org.elasticsearch.common.io.stream.StreamInput -import org.elasticsearch.common.io.stream.StreamOutput -import org.elasticsearch.index.shard.ShardId -import org.elasticsearch.index.store.StoreFileMetadata -import org.elasticsearch.transport.RemoteClusterAwareRequest +import org.opensearch.action.ActionRequestValidationException +import org.opensearch.action.support.single.shard.SingleShardRequest +import org.opensearch.cluster.node.DiscoveryNode +import org.opensearch.common.io.stream.StreamInput +import org.opensearch.common.io.stream.StreamOutput +import org.opensearch.index.shard.ShardId +import org.opensearch.index.store.StoreFileMetadata +import org.opensearch.transport.RemoteClusterAwareRequest class GetFileChunkRequest : RemoteClusterRepositoryRequest { val storeFileMetadata: StoreFileMetadata diff --git a/src/main/kotlin/com/amazon/elasticsearch/replication/action/repository/GetFileChunkResponse.kt b/src/main/kotlin/org/opensearch/replication/action/repository/GetFileChunkResponse.kt similarity index 80% rename from src/main/kotlin/com/amazon/elasticsearch/replication/action/repository/GetFileChunkResponse.kt rename to src/main/kotlin/org/opensearch/replication/action/repository/GetFileChunkResponse.kt index c8ac18b2..8e531309 100644 --- a/src/main/kotlin/com/amazon/elasticsearch/replication/action/repository/GetFileChunkResponse.kt +++ b/src/main/kotlin/org/opensearch/replication/action/repository/GetFileChunkResponse.kt @@ -13,13 +13,13 @@ * permissions and limitations under the License. */ -package com.amazon.elasticsearch.replication.action.repository +package org.opensearch.replication.action.repository -import org.elasticsearch.action.ActionResponse -import org.elasticsearch.common.bytes.BytesReference -import org.elasticsearch.common.io.stream.StreamInput -import org.elasticsearch.common.io.stream.StreamOutput -import org.elasticsearch.index.store.StoreFileMetadata +import org.opensearch.action.ActionResponse +import org.opensearch.common.bytes.BytesReference +import org.opensearch.common.io.stream.StreamInput +import org.opensearch.common.io.stream.StreamOutput +import org.opensearch.index.store.StoreFileMetadata class GetFileChunkResponse : ActionResponse { diff --git a/src/main/kotlin/com/amazon/elasticsearch/replication/action/repository/GetStoreMetadataAction.kt b/src/main/kotlin/org/opensearch/replication/action/repository/GetStoreMetadataAction.kt similarity index 89% rename from src/main/kotlin/com/amazon/elasticsearch/replication/action/repository/GetStoreMetadataAction.kt rename to src/main/kotlin/org/opensearch/replication/action/repository/GetStoreMetadataAction.kt index 9e2432f4..0e2f9bba 100644 --- a/src/main/kotlin/com/amazon/elasticsearch/replication/action/repository/GetStoreMetadataAction.kt +++ b/src/main/kotlin/org/opensearch/replication/action/repository/GetStoreMetadataAction.kt @@ -13,9 +13,9 @@ * permissions and limitations under the License. */ -package com.amazon.elasticsearch.replication.action.repository +package org.opensearch.replication.action.repository -import org.elasticsearch.action.ActionType +import org.opensearch.action.ActionType class GetStoreMetadataAction private constructor() : ActionType(NAME, ::GetStoreMetadataResponse) { companion object { diff --git a/src/main/kotlin/com/amazon/elasticsearch/replication/action/repository/GetStoreMetadataRequest.kt b/src/main/kotlin/org/opensearch/replication/action/repository/GetStoreMetadataRequest.kt similarity index 69% rename from src/main/kotlin/com/amazon/elasticsearch/replication/action/repository/GetStoreMetadataRequest.kt rename to src/main/kotlin/org/opensearch/replication/action/repository/GetStoreMetadataRequest.kt index ca0e481e..753ce64e 100644 --- a/src/main/kotlin/com/amazon/elasticsearch/replication/action/repository/GetStoreMetadataRequest.kt +++ b/src/main/kotlin/org/opensearch/replication/action/repository/GetStoreMetadataRequest.kt @@ -13,15 +13,15 @@ * permissions and limitations under the License. */ -package com.amazon.elasticsearch.replication.action.repository +package org.opensearch.replication.action.repository -import org.elasticsearch.action.ActionRequestValidationException -import org.elasticsearch.action.support.single.shard.SingleShardRequest -import org.elasticsearch.cluster.node.DiscoveryNode -import org.elasticsearch.common.io.stream.StreamInput -import org.elasticsearch.common.io.stream.StreamOutput -import org.elasticsearch.index.shard.ShardId -import org.elasticsearch.transport.RemoteClusterAwareRequest +import org.opensearch.action.ActionRequestValidationException +import org.opensearch.action.support.single.shard.SingleShardRequest +import org.opensearch.cluster.node.DiscoveryNode +import org.opensearch.common.io.stream.StreamInput +import org.opensearch.common.io.stream.StreamOutput +import org.opensearch.index.shard.ShardId +import org.opensearch.transport.RemoteClusterAwareRequest class GetStoreMetadataRequest : RemoteClusterRepositoryRequest { diff --git a/src/main/kotlin/com/amazon/elasticsearch/replication/action/repository/GetStoreMetadataResponse.kt b/src/main/kotlin/org/opensearch/replication/action/repository/GetStoreMetadataResponse.kt similarity index 79% rename from src/main/kotlin/com/amazon/elasticsearch/replication/action/repository/GetStoreMetadataResponse.kt rename to src/main/kotlin/org/opensearch/replication/action/repository/GetStoreMetadataResponse.kt index b36aa44b..f51b7d2a 100644 --- a/src/main/kotlin/com/amazon/elasticsearch/replication/action/repository/GetStoreMetadataResponse.kt +++ b/src/main/kotlin/org/opensearch/replication/action/repository/GetStoreMetadataResponse.kt @@ -13,12 +13,12 @@ * permissions and limitations under the License. */ -package com.amazon.elasticsearch.replication.action.repository +package org.opensearch.replication.action.repository -import org.elasticsearch.action.ActionResponse -import org.elasticsearch.common.io.stream.StreamInput -import org.elasticsearch.common.io.stream.StreamOutput -import org.elasticsearch.index.store.Store +import org.opensearch.action.ActionResponse +import org.opensearch.common.io.stream.StreamInput +import org.opensearch.common.io.stream.StreamOutput +import org.opensearch.index.store.Store class GetStoreMetadataResponse : ActionResponse { diff --git a/src/main/kotlin/com/amazon/elasticsearch/replication/action/repository/ReleaseLeaderResourcesAction.kt b/src/main/kotlin/org/opensearch/replication/action/repository/ReleaseLeaderResourcesAction.kt similarity index 83% rename from src/main/kotlin/com/amazon/elasticsearch/replication/action/repository/ReleaseLeaderResourcesAction.kt rename to src/main/kotlin/org/opensearch/replication/action/repository/ReleaseLeaderResourcesAction.kt index 8a443ba5..df42aaed 100644 --- a/src/main/kotlin/com/amazon/elasticsearch/replication/action/repository/ReleaseLeaderResourcesAction.kt +++ b/src/main/kotlin/org/opensearch/replication/action/repository/ReleaseLeaderResourcesAction.kt @@ -13,10 +13,10 @@ * permissions and limitations under the License. */ -package com.amazon.elasticsearch.replication.action.repository +package org.opensearch.replication.action.repository -import org.elasticsearch.action.ActionType -import org.elasticsearch.action.support.master.AcknowledgedResponse +import org.opensearch.action.ActionType +import org.opensearch.action.support.master.AcknowledgedResponse class ReleaseLeaderResourcesAction private constructor() : ActionType(NAME, ::AcknowledgedResponse) { companion object { diff --git a/src/main/kotlin/com/amazon/elasticsearch/replication/action/repository/ReleaseLeaderResourcesRequest.kt b/src/main/kotlin/org/opensearch/replication/action/repository/ReleaseLeaderResourcesRequest.kt similarity index 79% rename from src/main/kotlin/com/amazon/elasticsearch/replication/action/repository/ReleaseLeaderResourcesRequest.kt rename to src/main/kotlin/org/opensearch/replication/action/repository/ReleaseLeaderResourcesRequest.kt index 0ef25dc1..846563bc 100644 --- a/src/main/kotlin/com/amazon/elasticsearch/replication/action/repository/ReleaseLeaderResourcesRequest.kt +++ b/src/main/kotlin/org/opensearch/replication/action/repository/ReleaseLeaderResourcesRequest.kt @@ -13,12 +13,12 @@ * permissions and limitations under the License. */ -package com.amazon.elasticsearch.replication.action.repository +package org.opensearch.replication.action.repository -import org.elasticsearch.action.ActionRequestValidationException -import org.elasticsearch.cluster.node.DiscoveryNode -import org.elasticsearch.common.io.stream.StreamInput -import org.elasticsearch.index.shard.ShardId +import org.opensearch.action.ActionRequestValidationException +import org.opensearch.cluster.node.DiscoveryNode +import org.opensearch.common.io.stream.StreamInput +import org.opensearch.index.shard.ShardId class ReleaseLeaderResourcesRequest: RemoteClusterRepositoryRequest { diff --git a/src/main/kotlin/com/amazon/elasticsearch/replication/action/repository/RemoteClusterRepositoryRequest.kt b/src/main/kotlin/org/opensearch/replication/action/repository/RemoteClusterRepositoryRequest.kt similarity index 82% rename from src/main/kotlin/com/amazon/elasticsearch/replication/action/repository/RemoteClusterRepositoryRequest.kt rename to src/main/kotlin/org/opensearch/replication/action/repository/RemoteClusterRepositoryRequest.kt index 398b665e..8e3308ea 100644 --- a/src/main/kotlin/com/amazon/elasticsearch/replication/action/repository/RemoteClusterRepositoryRequest.kt +++ b/src/main/kotlin/org/opensearch/replication/action/repository/RemoteClusterRepositoryRequest.kt @@ -13,14 +13,14 @@ * permissions and limitations under the License. */ -package com.amazon.elasticsearch.replication.action.repository +package org.opensearch.replication.action.repository -import org.elasticsearch.action.support.single.shard.SingleShardRequest -import org.elasticsearch.cluster.node.DiscoveryNode -import org.elasticsearch.common.io.stream.StreamInput -import org.elasticsearch.common.io.stream.StreamOutput -import org.elasticsearch.index.shard.ShardId -import org.elasticsearch.transport.RemoteClusterAwareRequest +import org.opensearch.action.support.single.shard.SingleShardRequest +import org.opensearch.cluster.node.DiscoveryNode +import org.opensearch.common.io.stream.StreamInput +import org.opensearch.common.io.stream.StreamOutput +import org.opensearch.index.shard.ShardId +import org.opensearch.transport.RemoteClusterAwareRequest abstract class RemoteClusterRepositoryRequest?>: SingleShardRequest, RemoteClusterAwareRequest { diff --git a/src/main/kotlin/com/amazon/elasticsearch/replication/action/repository/TransportGetFileChunkAction.kt b/src/main/kotlin/org/opensearch/replication/action/repository/TransportGetFileChunkAction.kt similarity index 75% rename from src/main/kotlin/com/amazon/elasticsearch/replication/action/repository/TransportGetFileChunkAction.kt rename to src/main/kotlin/org/opensearch/replication/action/repository/TransportGetFileChunkAction.kt index 4cdf7843..b887116e 100644 --- a/src/main/kotlin/com/amazon/elasticsearch/replication/action/repository/TransportGetFileChunkAction.kt +++ b/src/main/kotlin/org/opensearch/replication/action/repository/TransportGetFileChunkAction.kt @@ -13,26 +13,26 @@ * permissions and limitations under the License. */ -package com.amazon.elasticsearch.replication.action.repository +package org.opensearch.replication.action.repository -import com.amazon.elasticsearch.replication.repository.RemoteClusterRestoreLeaderService -import com.amazon.elasticsearch.replication.util.performOp +import org.opensearch.replication.repository.RemoteClusterRestoreLeaderService import org.apache.logging.log4j.LogManager -import org.elasticsearch.action.support.ActionFilters -import org.elasticsearch.action.support.single.shard.TransportSingleShardAction -import org.elasticsearch.cluster.ClusterState -import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver -import org.elasticsearch.cluster.routing.ShardsIterator -import org.elasticsearch.cluster.service.ClusterService -import org.elasticsearch.common.bytes.BytesArray -import org.elasticsearch.common.inject.Inject -import org.elasticsearch.common.io.stream.StreamInput -import org.elasticsearch.common.io.stream.Writeable -import org.elasticsearch.index.shard.ShardId -import org.elasticsearch.indices.IndicesService -import org.elasticsearch.threadpool.ThreadPool -import org.elasticsearch.transport.TransportActionProxy -import org.elasticsearch.transport.TransportService +import org.opensearch.action.support.ActionFilters +import org.opensearch.action.support.single.shard.TransportSingleShardAction +import org.opensearch.cluster.ClusterState +import org.opensearch.cluster.metadata.IndexNameExpressionResolver +import org.opensearch.cluster.routing.ShardsIterator +import org.opensearch.cluster.service.ClusterService +import org.opensearch.common.bytes.BytesArray +import org.opensearch.common.inject.Inject +import org.opensearch.common.io.stream.StreamInput +import org.opensearch.common.io.stream.Writeable +import org.opensearch.index.shard.ShardId +import org.opensearch.indices.IndicesService +import org.opensearch.replication.util.performOp +import org.opensearch.threadpool.ThreadPool +import org.opensearch.transport.TransportActionProxy +import org.opensearch.transport.TransportService class TransportGetFileChunkAction @Inject constructor(threadPool: ThreadPool, clusterService: ClusterService, transportService: TransportService, actionFilters: ActionFilters, diff --git a/src/main/kotlin/com/amazon/elasticsearch/replication/action/repository/TransportGetStoreMetadataAction.kt b/src/main/kotlin/org/opensearch/replication/action/repository/TransportGetStoreMetadataAction.kt similarity index 74% rename from src/main/kotlin/com/amazon/elasticsearch/replication/action/repository/TransportGetStoreMetadataAction.kt rename to src/main/kotlin/org/opensearch/replication/action/repository/TransportGetStoreMetadataAction.kt index a113e925..50fab4ea 100644 --- a/src/main/kotlin/com/amazon/elasticsearch/replication/action/repository/TransportGetStoreMetadataAction.kt +++ b/src/main/kotlin/org/opensearch/replication/action/repository/TransportGetStoreMetadataAction.kt @@ -13,23 +13,23 @@ * permissions and limitations under the License. */ -package com.amazon.elasticsearch.replication.action.repository +package org.opensearch.replication.action.repository -import com.amazon.elasticsearch.replication.repository.RemoteClusterRestoreLeaderService +import org.opensearch.replication.repository.RemoteClusterRestoreLeaderService import org.apache.logging.log4j.LogManager -import org.elasticsearch.action.support.ActionFilters -import org.elasticsearch.action.support.single.shard.TransportSingleShardAction -import org.elasticsearch.cluster.ClusterState -import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver -import org.elasticsearch.cluster.routing.ShardsIterator -import org.elasticsearch.cluster.service.ClusterService -import org.elasticsearch.common.inject.Inject -import org.elasticsearch.common.io.stream.StreamInput -import org.elasticsearch.common.io.stream.Writeable -import org.elasticsearch.index.shard.ShardId -import org.elasticsearch.threadpool.ThreadPool -import org.elasticsearch.transport.TransportActionProxy -import org.elasticsearch.transport.TransportService +import org.opensearch.action.support.ActionFilters +import org.opensearch.action.support.single.shard.TransportSingleShardAction +import org.opensearch.cluster.ClusterState +import org.opensearch.cluster.metadata.IndexNameExpressionResolver +import org.opensearch.cluster.routing.ShardsIterator +import org.opensearch.cluster.service.ClusterService +import org.opensearch.common.inject.Inject +import org.opensearch.common.io.stream.StreamInput +import org.opensearch.common.io.stream.Writeable +import org.opensearch.index.shard.ShardId +import org.opensearch.threadpool.ThreadPool +import org.opensearch.transport.TransportActionProxy +import org.opensearch.transport.TransportService class TransportGetStoreMetadataAction @Inject constructor(threadPool: ThreadPool, clusterService: ClusterService, transportService: TransportService, actionFilters: ActionFilters, diff --git a/src/main/kotlin/com/amazon/elasticsearch/replication/action/repository/TransportReleaseLeaderResourcesAction.kt b/src/main/kotlin/org/opensearch/replication/action/repository/TransportReleaseLeaderResourcesAction.kt similarity index 73% rename from src/main/kotlin/com/amazon/elasticsearch/replication/action/repository/TransportReleaseLeaderResourcesAction.kt rename to src/main/kotlin/org/opensearch/replication/action/repository/TransportReleaseLeaderResourcesAction.kt index 60bf7bad..f4715fb1 100644 --- a/src/main/kotlin/com/amazon/elasticsearch/replication/action/repository/TransportReleaseLeaderResourcesAction.kt +++ b/src/main/kotlin/org/opensearch/replication/action/repository/TransportReleaseLeaderResourcesAction.kt @@ -13,24 +13,24 @@ * permissions and limitations under the License. */ -package com.amazon.elasticsearch.replication.action.repository +package org.opensearch.replication.action.repository -import com.amazon.elasticsearch.replication.repository.RemoteClusterRestoreLeaderService +import org.opensearch.replication.repository.RemoteClusterRestoreLeaderService import org.apache.logging.log4j.LogManager -import org.elasticsearch.action.support.ActionFilters -import org.elasticsearch.action.support.master.AcknowledgedResponse -import org.elasticsearch.action.support.single.shard.TransportSingleShardAction -import org.elasticsearch.cluster.ClusterState -import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver -import org.elasticsearch.cluster.routing.ShardsIterator -import org.elasticsearch.cluster.service.ClusterService -import org.elasticsearch.common.inject.Inject -import org.elasticsearch.common.io.stream.StreamInput -import org.elasticsearch.common.io.stream.Writeable -import org.elasticsearch.index.shard.ShardId -import org.elasticsearch.threadpool.ThreadPool -import org.elasticsearch.transport.TransportActionProxy -import org.elasticsearch.transport.TransportService +import org.opensearch.action.support.ActionFilters +import org.opensearch.action.support.master.AcknowledgedResponse +import org.opensearch.action.support.single.shard.TransportSingleShardAction +import org.opensearch.cluster.ClusterState +import org.opensearch.cluster.metadata.IndexNameExpressionResolver +import org.opensearch.cluster.routing.ShardsIterator +import org.opensearch.cluster.service.ClusterService +import org.opensearch.common.inject.Inject +import org.opensearch.common.io.stream.StreamInput +import org.opensearch.common.io.stream.Writeable +import org.opensearch.index.shard.ShardId +import org.opensearch.threadpool.ThreadPool +import org.opensearch.transport.TransportActionProxy +import org.opensearch.transport.TransportService class TransportReleaseLeaderResourcesAction @Inject constructor(threadPool: ThreadPool, clusterService: ClusterService, transportService: TransportService, actionFilters: ActionFilters, diff --git a/src/main/kotlin/com/amazon/elasticsearch/replication/action/stop/StopIndexReplicationAction.kt b/src/main/kotlin/org/opensearch/replication/action/stop/StopIndexReplicationAction.kt similarity index 84% rename from src/main/kotlin/com/amazon/elasticsearch/replication/action/stop/StopIndexReplicationAction.kt rename to src/main/kotlin/org/opensearch/replication/action/stop/StopIndexReplicationAction.kt index ec36782c..d88f2cab 100644 --- a/src/main/kotlin/com/amazon/elasticsearch/replication/action/stop/StopIndexReplicationAction.kt +++ b/src/main/kotlin/org/opensearch/replication/action/stop/StopIndexReplicationAction.kt @@ -13,10 +13,10 @@ * permissions and limitations under the License. */ -package com.amazon.elasticsearch.replication.action.stop +package org.opensearch.replication.action.stop -import org.elasticsearch.action.ActionType -import org.elasticsearch.action.support.master.AcknowledgedResponse +import org.opensearch.action.ActionType +import org.opensearch.action.support.master.AcknowledgedResponse class StopIndexReplicationAction private constructor(): ActionType(NAME, ::AcknowledgedResponse) { companion object { diff --git a/src/main/kotlin/com/amazon/elasticsearch/replication/action/stop/StopIndexReplicationRequest.kt b/src/main/kotlin/org/opensearch/replication/action/stop/StopIndexReplicationRequest.kt similarity index 82% rename from src/main/kotlin/com/amazon/elasticsearch/replication/action/stop/StopIndexReplicationRequest.kt rename to src/main/kotlin/org/opensearch/replication/action/stop/StopIndexReplicationRequest.kt index afacc6df..2b3454a4 100644 --- a/src/main/kotlin/com/amazon/elasticsearch/replication/action/stop/StopIndexReplicationRequest.kt +++ b/src/main/kotlin/org/opensearch/replication/action/stop/StopIndexReplicationRequest.kt @@ -13,16 +13,16 @@ * permissions and limitations under the License. */ -package com.amazon.elasticsearch.replication.action.stop - -import org.elasticsearch.action.ActionRequestValidationException -import org.elasticsearch.action.IndicesRequest -import org.elasticsearch.action.support.IndicesOptions -import org.elasticsearch.action.support.master.AcknowledgedRequest -import org.elasticsearch.common.ParseField -import org.elasticsearch.common.io.stream.StreamInput -import org.elasticsearch.common.io.stream.StreamOutput -import org.elasticsearch.common.xcontent.* +package org.opensearch.replication.action.stop + +import org.opensearch.action.ActionRequestValidationException +import org.opensearch.action.IndicesRequest +import org.opensearch.action.support.IndicesOptions +import org.opensearch.action.support.master.AcknowledgedRequest +import org.opensearch.common.ParseField +import org.opensearch.common.io.stream.StreamInput +import org.opensearch.common.io.stream.StreamOutput +import org.opensearch.common.xcontent.* class StopIndexReplicationRequest : AcknowledgedRequest, IndicesRequest.Replaceable, ToXContentObject { diff --git a/src/main/kotlin/com/amazon/elasticsearch/replication/action/stop/TransportStopIndexReplicationAction.kt b/src/main/kotlin/org/opensearch/replication/action/stop/TransportStopIndexReplicationAction.kt similarity index 74% rename from src/main/kotlin/com/amazon/elasticsearch/replication/action/stop/TransportStopIndexReplicationAction.kt rename to src/main/kotlin/org/opensearch/replication/action/stop/TransportStopIndexReplicationAction.kt index 6815434b..23d152c8 100644 --- a/src/main/kotlin/com/amazon/elasticsearch/replication/action/stop/TransportStopIndexReplicationAction.kt +++ b/src/main/kotlin/org/opensearch/replication/action/stop/TransportStopIndexReplicationAction.kt @@ -13,48 +13,48 @@ * permissions and limitations under the License. */ -package com.amazon.elasticsearch.replication.action.stop - -import com.amazon.elasticsearch.replication.ReplicationPlugin.Companion.REPLICATED_INDEX_SETTING -import com.amazon.elasticsearch.replication.metadata.INDEX_REPLICATION_BLOCK -import com.amazon.elasticsearch.replication.metadata.checkIfIndexBlockedWithLevel -import com.amazon.elasticsearch.replication.metadata.REPLICATION_OVERALL_STATE_KEY -import com.amazon.elasticsearch.replication.metadata.REPLICATION_OVERALL_STATE_RUNNING_VALUE -import com.amazon.elasticsearch.replication.metadata.ReplicationMetadata -import com.amazon.elasticsearch.replication.metadata.getReplicationStateParamsForIndex -import com.amazon.elasticsearch.replication.util.completeWith -import com.amazon.elasticsearch.replication.util.coroutineContext -import com.amazon.elasticsearch.replication.util.suspending -import com.amazon.elasticsearch.replication.util.waitForClusterStateUpdate +package org.opensearch.replication.action.stop + +import org.opensearch.replication.ReplicationPlugin.Companion.REPLICATED_INDEX_SETTING +import org.opensearch.replication.metadata.INDEX_REPLICATION_BLOCK +import org.opensearch.replication.metadata.checkIfIndexBlockedWithLevel +import org.opensearch.replication.metadata.REPLICATION_OVERALL_STATE_KEY +import org.opensearch.replication.metadata.REPLICATION_OVERALL_STATE_RUNNING_VALUE +import org.opensearch.replication.metadata.ReplicationMetadata +import org.opensearch.replication.metadata.getReplicationStateParamsForIndex +import org.opensearch.replication.util.suspending import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.launch import org.apache.logging.log4j.LogManager -import org.elasticsearch.ElasticsearchException -import org.elasticsearch.action.ActionListener -import org.elasticsearch.action.admin.indices.close.CloseIndexRequest -import org.elasticsearch.action.admin.indices.open.OpenIndexRequest -import org.elasticsearch.action.support.ActionFilters -import org.elasticsearch.action.support.master.AcknowledgedResponse -import org.elasticsearch.action.support.master.TransportMasterNodeAction -import org.elasticsearch.client.Client -import org.elasticsearch.cluster.AckedClusterStateUpdateTask -import org.elasticsearch.cluster.ClusterState -import org.elasticsearch.cluster.RestoreInProgress -import org.elasticsearch.cluster.block.ClusterBlockException -import org.elasticsearch.cluster.block.ClusterBlockLevel -import org.elasticsearch.cluster.block.ClusterBlocks -import org.elasticsearch.cluster.metadata.IndexMetadata -import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver -import org.elasticsearch.cluster.metadata.Metadata -import org.elasticsearch.cluster.service.ClusterService -import org.elasticsearch.common.inject.Inject -import org.elasticsearch.common.io.stream.StreamInput -import org.elasticsearch.common.settings.Settings -import org.elasticsearch.index.IndexNotFoundException -import org.elasticsearch.threadpool.ThreadPool -import org.elasticsearch.transport.TransportService +import org.opensearch.OpenSearchException +import org.opensearch.action.ActionListener +import org.opensearch.action.admin.indices.close.CloseIndexRequest +import org.opensearch.action.admin.indices.open.OpenIndexRequest +import org.opensearch.action.support.ActionFilters +import org.opensearch.action.support.master.AcknowledgedResponse +import org.opensearch.action.support.master.TransportMasterNodeAction +import org.opensearch.client.Client +import org.opensearch.cluster.AckedClusterStateUpdateTask +import org.opensearch.cluster.ClusterState +import org.opensearch.cluster.RestoreInProgress +import org.opensearch.cluster.block.ClusterBlockException +import org.opensearch.cluster.block.ClusterBlockLevel +import org.opensearch.cluster.block.ClusterBlocks +import org.opensearch.cluster.metadata.IndexMetadata +import org.opensearch.cluster.metadata.IndexNameExpressionResolver +import org.opensearch.cluster.metadata.Metadata +import org.opensearch.cluster.service.ClusterService +import org.opensearch.common.inject.Inject +import org.opensearch.common.io.stream.StreamInput +import org.opensearch.common.settings.Settings +import org.opensearch.index.IndexNotFoundException +import org.opensearch.replication.util.completeWith +import org.opensearch.replication.util.coroutineContext +import org.opensearch.replication.util.waitForClusterStateUpdate +import org.opensearch.threadpool.ThreadPool +import org.opensearch.transport.TransportService import java.io.IOException class TransportStopIndexReplicationAction @Inject constructor(transportService: TransportService, @@ -99,14 +99,14 @@ class TransportStopIndexReplicationAction @Inject constructor(transportService: state.routingTable.hasIndex(request.indexName)) { val closeResponse = suspending(client.admin().indices()::close)(CloseIndexRequest(request.indexName)) if (!closeResponse.isAcknowledged) { - throw ElasticsearchException("Unable to close index: ${request.indexName}") + throw OpenSearchException("Unable to close index: ${request.indexName}") } } val stateUpdateResponse : AcknowledgedResponse = clusterService.waitForClusterStateUpdate("stop_replication") { l -> StopReplicationTask(request, l)} if (!stateUpdateResponse.isAcknowledged) { - throw ElasticsearchException("Failed to update cluster state") + throw OpenSearchException("Failed to update cluster state") } // Index will be deleted if stop is called while it is restoring. So no need to reopen @@ -114,7 +114,7 @@ class TransportStopIndexReplicationAction @Inject constructor(transportService: state.routingTable.hasIndex(request.indexName)) { val reopenResponse = suspending(client.admin().indices()::open)(OpenIndexRequest(request.indexName)) if (!reopenResponse.isAcknowledged) { - throw ElasticsearchException("Failed to reopen index: ${request.indexName}") + throw OpenSearchException("Failed to reopen index: ${request.indexName}") } } AcknowledgedResponse(true) diff --git a/src/main/kotlin/com/amazon/elasticsearch/replication/metadata/AddIndexBlockTask.kt b/src/main/kotlin/org/opensearch/replication/metadata/AddIndexBlockTask.kt similarity index 78% rename from src/main/kotlin/com/amazon/elasticsearch/replication/metadata/AddIndexBlockTask.kt rename to src/main/kotlin/org/opensearch/replication/metadata/AddIndexBlockTask.kt index 3fd56113..d301233a 100644 --- a/src/main/kotlin/com/amazon/elasticsearch/replication/metadata/AddIndexBlockTask.kt +++ b/src/main/kotlin/org/opensearch/replication/metadata/AddIndexBlockTask.kt @@ -13,21 +13,21 @@ * permissions and limitations under the License. */ -package com.amazon.elasticsearch.replication.metadata +package org.opensearch.replication.metadata -import com.amazon.elasticsearch.replication.action.index.block.UpdateIndexBlockRequest -import org.elasticsearch.action.ActionListener -import org.elasticsearch.action.support.master.AcknowledgedResponse -import org.elasticsearch.cluster.AckedClusterStateUpdateTask -import org.elasticsearch.cluster.ClusterState -import org.elasticsearch.cluster.block.ClusterBlock -import org.elasticsearch.cluster.block.ClusterBlockException -import org.elasticsearch.cluster.block.ClusterBlockLevel -import org.elasticsearch.cluster.block.ClusterBlocks -import org.elasticsearch.cluster.service.ClusterService -import org.elasticsearch.common.collect.ImmutableOpenMap -import org.elasticsearch.index.IndexNotFoundException -import org.elasticsearch.rest.RestStatus +import org.opensearch.replication.action.index.block.UpdateIndexBlockRequest +import org.opensearch.action.ActionListener +import org.opensearch.action.support.master.AcknowledgedResponse +import org.opensearch.cluster.AckedClusterStateUpdateTask +import org.opensearch.cluster.ClusterState +import org.opensearch.cluster.block.ClusterBlock +import org.opensearch.cluster.block.ClusterBlockException +import org.opensearch.cluster.block.ClusterBlockLevel +import org.opensearch.cluster.block.ClusterBlocks +import org.opensearch.cluster.service.ClusterService +import org.opensearch.common.collect.ImmutableOpenMap +import org.opensearch.index.IndexNotFoundException +import org.opensearch.rest.RestStatus import java.util.* diff --git a/src/main/kotlin/com/amazon/elasticsearch/replication/metadata/AutoFollowPattern.kt b/src/main/kotlin/org/opensearch/replication/metadata/AutoFollowPattern.kt similarity index 78% rename from src/main/kotlin/com/amazon/elasticsearch/replication/metadata/AutoFollowPattern.kt rename to src/main/kotlin/org/opensearch/replication/metadata/AutoFollowPattern.kt index cf164572..6a61d158 100644 --- a/src/main/kotlin/com/amazon/elasticsearch/replication/metadata/AutoFollowPattern.kt +++ b/src/main/kotlin/org/opensearch/replication/metadata/AutoFollowPattern.kt @@ -13,13 +13,13 @@ * permissions and limitations under the License. */ -package com.amazon.elasticsearch.replication.metadata +package org.opensearch.replication.metadata -import org.elasticsearch.common.io.stream.StreamInput -import org.elasticsearch.common.io.stream.StreamOutput -import org.elasticsearch.common.io.stream.Writeable -import org.elasticsearch.common.xcontent.ToXContent -import org.elasticsearch.common.xcontent.XContentBuilder +import org.opensearch.common.io.stream.StreamInput +import org.opensearch.common.io.stream.StreamOutput +import org.opensearch.common.io.stream.Writeable +import org.opensearch.common.xcontent.ToXContent +import org.opensearch.common.xcontent.XContentBuilder data class AutoFollowPattern(val name: String, val pattern: String?) : Writeable, ToXContent { diff --git a/src/main/kotlin/com/amazon/elasticsearch/replication/metadata/ReplicationMetadata.kt b/src/main/kotlin/org/opensearch/replication/metadata/ReplicationMetadata.kt similarity index 96% rename from src/main/kotlin/com/amazon/elasticsearch/replication/metadata/ReplicationMetadata.kt rename to src/main/kotlin/org/opensearch/replication/metadata/ReplicationMetadata.kt index fba7acce..6b471e78 100644 --- a/src/main/kotlin/com/amazon/elasticsearch/replication/metadata/ReplicationMetadata.kt +++ b/src/main/kotlin/org/opensearch/replication/metadata/ReplicationMetadata.kt @@ -13,24 +13,24 @@ * permissions and limitations under the License. */ -package com.amazon.elasticsearch.replication.metadata - -import org.elasticsearch.Version -import org.elasticsearch.cluster.DiffableUtils -import org.elasticsearch.cluster.DiffableUtils.NonDiffableValueSerializer -import org.elasticsearch.cluster.DiffableUtils.getStringKeySerializer -import org.elasticsearch.cluster.NamedDiff -import org.elasticsearch.cluster.metadata.Metadata -import org.elasticsearch.cluster.service.ClusterService -import org.elasticsearch.common.io.stream.StreamInput -import org.elasticsearch.common.io.stream.StreamOutput -import org.elasticsearch.common.xcontent.ToXContent -import org.elasticsearch.common.xcontent.XContentBuilder -import org.elasticsearch.common.xcontent.XContentParser +package org.opensearch.replication.metadata + +import org.opensearch.Version +import org.opensearch.cluster.DiffableUtils +import org.opensearch.cluster.DiffableUtils.NonDiffableValueSerializer +import org.opensearch.cluster.DiffableUtils.getStringKeySerializer +import org.opensearch.cluster.NamedDiff +import org.opensearch.cluster.metadata.Metadata +import org.opensearch.cluster.service.ClusterService +import org.opensearch.common.io.stream.StreamInput +import org.opensearch.common.io.stream.StreamOutput +import org.opensearch.common.xcontent.ToXContent +import org.opensearch.common.xcontent.XContentBuilder +import org.opensearch.common.xcontent.XContentParser import java.io.IOException import java.util.EnumSet import kotlin.collections.HashMap -import org.elasticsearch.cluster.Diff as ESDiff +import org.opensearch.cluster.Diff as ESDiff // some descriptive type aliases to make it easier to read the code. typealias AutoFollowPatterns = Map // { pattern name -> pattern } @@ -220,7 +220,7 @@ data class ReplicationMetadata(val autoFollowPatterns: Map(request: AckedRequest, listener: ActionListener) : AckedClusterStateUpdateTask(request, listener) { diff --git a/src/main/kotlin/com/amazon/elasticsearch/replication/repository/RemoteClusterMultiChunkTransfer.kt b/src/main/kotlin/org/opensearch/replication/repository/RemoteClusterMultiChunkTransfer.kt similarity index 82% rename from src/main/kotlin/com/amazon/elasticsearch/replication/repository/RemoteClusterMultiChunkTransfer.kt rename to src/main/kotlin/org/opensearch/replication/repository/RemoteClusterMultiChunkTransfer.kt index 75ac3a53..1c8b30e4 100644 --- a/src/main/kotlin/com/amazon/elasticsearch/replication/repository/RemoteClusterMultiChunkTransfer.kt +++ b/src/main/kotlin/org/opensearch/replication/repository/RemoteClusterMultiChunkTransfer.kt @@ -13,12 +13,10 @@ * permissions and limitations under the License. */ -package com.amazon.elasticsearch.replication.repository +package org.opensearch.replication.repository -import com.amazon.elasticsearch.replication.action.repository.GetFileChunkAction -import com.amazon.elasticsearch.replication.action.repository.GetFileChunkRequest -import com.amazon.elasticsearch.replication.util.coroutineContext -import com.amazon.elasticsearch.replication.util.suspendExecute +import org.opensearch.replication.action.repository.GetFileChunkAction +import org.opensearch.replication.action.repository.GetFileChunkRequest import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.GlobalScope @@ -26,17 +24,19 @@ import kotlinx.coroutines.launch import kotlinx.coroutines.sync.Mutex import kotlinx.coroutines.sync.withLock import org.apache.logging.log4j.Logger -import org.elasticsearch.action.ActionListener -import org.elasticsearch.client.Client -import org.elasticsearch.cluster.node.DiscoveryNode -import org.elasticsearch.common.unit.ByteSizeValue -import org.elasticsearch.common.util.concurrent.ThreadContext -import org.elasticsearch.index.shard.ShardId -import org.elasticsearch.index.store.Store -import org.elasticsearch.index.store.StoreFileMetadata -import org.elasticsearch.indices.recovery.MultiChunkTransfer -import org.elasticsearch.indices.recovery.MultiFileWriter -import org.elasticsearch.indices.recovery.RecoveryState +import org.opensearch.action.ActionListener +import org.opensearch.client.Client +import org.opensearch.cluster.node.DiscoveryNode +import org.opensearch.common.unit.ByteSizeValue +import org.opensearch.common.util.concurrent.ThreadContext +import org.opensearch.index.shard.ShardId +import org.opensearch.index.store.Store +import org.opensearch.index.store.StoreFileMetadata +import org.opensearch.indices.recovery.MultiChunkTransfer +import org.opensearch.indices.recovery.MultiFileWriter +import org.opensearch.indices.recovery.RecoveryState +import org.opensearch.replication.util.coroutineContext +import org.opensearch.replication.util.suspendExecute class RemoteClusterMultiChunkTransfer(val logger: Logger, val followerClusterName: String, diff --git a/src/main/kotlin/com/amazon/elasticsearch/replication/repository/RemoteClusterRepositoriesService.kt b/src/main/kotlin/org/opensearch/replication/repository/RemoteClusterRepositoriesService.kt similarity index 84% rename from src/main/kotlin/com/amazon/elasticsearch/replication/repository/RemoteClusterRepositoriesService.kt rename to src/main/kotlin/org/opensearch/replication/repository/RemoteClusterRepositoriesService.kt index c0e1b8f6..91363c68 100644 --- a/src/main/kotlin/com/amazon/elasticsearch/replication/repository/RemoteClusterRepositoriesService.kt +++ b/src/main/kotlin/org/opensearch/replication/repository/RemoteClusterRepositoriesService.kt @@ -13,11 +13,11 @@ * permissions and limitations under the License. */ -package com.amazon.elasticsearch.replication.repository -import org.elasticsearch.cluster.service.ClusterService -import org.elasticsearch.common.settings.ClusterSettings -import org.elasticsearch.repositories.RepositoriesService -import org.elasticsearch.transport.SniffConnectionStrategy.REMOTE_CLUSTER_SEEDS +package org.opensearch.replication.repository +import org.opensearch.cluster.service.ClusterService +import org.opensearch.common.settings.ClusterSettings +import org.opensearch.repositories.RepositoriesService +import org.opensearch.transport.SniffConnectionStrategy.REMOTE_CLUSTER_SEEDS import java.util.function.Supplier class RemoteClusterRepositoriesService(private val repositoriesService: Supplier, diff --git a/src/main/kotlin/com/amazon/elasticsearch/replication/repository/RemoteClusterRepository.kt b/src/main/kotlin/org/opensearch/replication/repository/RemoteClusterRepository.kt similarity index 86% rename from src/main/kotlin/com/amazon/elasticsearch/replication/repository/RemoteClusterRepository.kt rename to src/main/kotlin/org/opensearch/replication/repository/RemoteClusterRepository.kt index 46308c4a..32ae38d4 100644 --- a/src/main/kotlin/com/amazon/elasticsearch/replication/repository/RemoteClusterRepository.kt +++ b/src/main/kotlin/org/opensearch/replication/repository/RemoteClusterRepository.kt @@ -13,53 +13,54 @@ * permissions and limitations under the License. */ -package com.amazon.elasticsearch.replication.repository - -import com.amazon.elasticsearch.replication.ReplicationPlugin -import com.amazon.elasticsearch.replication.action.repository.GetStoreMetadataAction -import com.amazon.elasticsearch.replication.action.repository.GetStoreMetadataRequest -import com.amazon.elasticsearch.replication.action.repository.ReleaseLeaderResourcesAction -import com.amazon.elasticsearch.replication.util.SecurityContext -import com.amazon.elasticsearch.replication.action.repository.ReleaseLeaderResourcesRequest -import com.amazon.elasticsearch.replication.util.executeUnderSecurityContext +package org.opensearch.replication.repository + +import org.opensearch.replication.ReplicationPlugin +import org.opensearch.replication.action.repository.GetStoreMetadataAction +import org.opensearch.replication.action.repository.GetStoreMetadataRequest +import org.opensearch.replication.action.repository.ReleaseLeaderResourcesAction +import org.opensearch.replication.util.SecurityContext +import org.opensearch.replication.action.repository.ReleaseLeaderResourcesRequest import org.apache.logging.log4j.LogManager import org.apache.lucene.index.IndexCommit -import org.elasticsearch.Version -import org.elasticsearch.action.ActionListener -import org.elasticsearch.action.ActionRequest -import org.elasticsearch.action.ActionResponse -import org.elasticsearch.action.ActionType -import org.elasticsearch.action.admin.indices.stats.IndicesStatsAction -import org.elasticsearch.action.admin.indices.stats.IndicesStatsRequest -import org.elasticsearch.action.support.IndicesOptions -import org.elasticsearch.client.Client -import org.elasticsearch.cluster.ClusterState -import org.elasticsearch.cluster.ClusterStateUpdateTask -import org.elasticsearch.cluster.metadata.IndexMetadata -import org.elasticsearch.cluster.metadata.Metadata -import org.elasticsearch.cluster.metadata.RepositoryMetadata -import org.elasticsearch.cluster.node.DiscoveryNode -import org.elasticsearch.cluster.service.ClusterService -import org.elasticsearch.common.Nullable -import org.elasticsearch.common.UUIDs -import org.elasticsearch.common.component.AbstractLifecycleComponent -import org.elasticsearch.common.metrics.CounterMetric -import org.elasticsearch.common.settings.Settings -import org.elasticsearch.index.mapper.MapperService -import org.elasticsearch.index.shard.ShardId -import org.elasticsearch.index.snapshots.IndexShardSnapshotStatus -import org.elasticsearch.index.store.Store -import org.elasticsearch.index.store.StoreStats -import org.elasticsearch.indices.recovery.RecoverySettings -import org.elasticsearch.indices.recovery.RecoveryState -import org.elasticsearch.repositories.IndexId -import org.elasticsearch.repositories.Repository -import org.elasticsearch.repositories.RepositoryData -import org.elasticsearch.repositories.RepositoryShardId -import org.elasticsearch.repositories.ShardGenerations -import org.elasticsearch.snapshots.SnapshotId -import org.elasticsearch.snapshots.SnapshotInfo -import org.elasticsearch.snapshots.SnapshotState +import org.opensearch.Version +import org.opensearch.action.ActionListener +import org.opensearch.action.ActionRequest +import org.opensearch.action.ActionResponse +import org.opensearch.action.ActionType +import org.opensearch.action.admin.indices.stats.IndicesStatsAction +import org.opensearch.action.admin.indices.stats.IndicesStatsRequest +import org.opensearch.action.support.IndicesOptions +import org.opensearch.client.Client +import org.opensearch.cluster.ClusterState +import org.opensearch.cluster.ClusterStateUpdateTask +import org.opensearch.cluster.metadata.IndexMetadata +import org.opensearch.cluster.metadata.Metadata +import org.opensearch.cluster.metadata.RepositoryMetadata +import org.opensearch.cluster.node.DiscoveryNode +import org.opensearch.cluster.service.ClusterService +import org.opensearch.common.Nullable +import org.opensearch.common.UUIDs +import org.opensearch.common.component.AbstractLifecycleComponent +import org.opensearch.common.metrics.CounterMetric +import org.opensearch.common.settings.Settings +import org.opensearch.common.util.concurrent.ThreadContext +import org.opensearch.index.mapper.MapperService +import org.opensearch.index.shard.ShardId +import org.opensearch.index.snapshots.IndexShardSnapshotStatus +import org.opensearch.index.store.Store +import org.opensearch.index.store.StoreStats +import org.opensearch.indices.recovery.RecoverySettings +import org.opensearch.indices.recovery.RecoveryState +import org.opensearch.replication.util.executeUnderSecurityContext +import org.opensearch.repositories.IndexId +import org.opensearch.repositories.Repository +import org.opensearch.repositories.RepositoryData +import org.opensearch.repositories.RepositoryShardId +import org.opensearch.repositories.ShardGenerations +import org.opensearch.snapshots.SnapshotId +import org.opensearch.snapshots.SnapshotInfo +import org.opensearch.snapshots.SnapshotState import java.util.UUID import java.util.function.Consumer import java.util.function.Function @@ -349,9 +350,14 @@ class RemoteClusterRepository(private val repositoryMetadata: RepositoryMetadata val userString = SecurityContext.fromClusterState(clusterService.state(), repositoryMetadata.remoteClusterName(), followerIndex) - remoteClusterClient.threadPool().threadContext.newStoredContext(true).use { + var storedContext: ThreadContext.StoredContext? = null + try { + storedContext = remoteClusterClient.threadPool().threadContext.newStoredContext(true) SecurityContext.toThreadContext(remoteClusterClient.threadPool().threadContext, userString) return remoteClusterClient.execute(actionType, actionRequest).actionGet(REMOTE_CLUSTER_REPO_REQ_TIMEOUT_IN_MILLI_SEC) } + finally { + storedContext?.restore() + } } } diff --git a/src/main/kotlin/com/amazon/elasticsearch/replication/repository/RemoteClusterRepositoryFileChunk.kt b/src/main/kotlin/org/opensearch/replication/repository/RemoteClusterRepositoryFileChunk.kt similarity index 83% rename from src/main/kotlin/com/amazon/elasticsearch/replication/repository/RemoteClusterRepositoryFileChunk.kt rename to src/main/kotlin/org/opensearch/replication/repository/RemoteClusterRepositoryFileChunk.kt index 296a56e6..2d068e8a 100644 --- a/src/main/kotlin/com/amazon/elasticsearch/replication/repository/RemoteClusterRepositoryFileChunk.kt +++ b/src/main/kotlin/org/opensearch/replication/repository/RemoteClusterRepositoryFileChunk.kt @@ -13,10 +13,10 @@ * permissions and limitations under the License. */ -package com.amazon.elasticsearch.replication.repository +package org.opensearch.replication.repository -import org.elasticsearch.index.store.StoreFileMetadata -import org.elasticsearch.indices.recovery.MultiChunkTransfer.ChunkRequest +import org.opensearch.index.store.StoreFileMetadata +import org.opensearch.indices.recovery.MultiChunkTransfer.ChunkRequest class RemoteClusterRepositoryFileChunk constructor(val storeFileMetadata: StoreFileMetadata, val offset: Long, diff --git a/src/main/kotlin/com/amazon/elasticsearch/replication/repository/RemoteClusterRestoreLeaderService.kt b/src/main/kotlin/org/opensearch/replication/repository/RemoteClusterRestoreLeaderService.kt similarity index 81% rename from src/main/kotlin/com/amazon/elasticsearch/replication/repository/RemoteClusterRestoreLeaderService.kt rename to src/main/kotlin/org/opensearch/replication/repository/RemoteClusterRestoreLeaderService.kt index 22b4d343..b330b830 100644 --- a/src/main/kotlin/com/amazon/elasticsearch/replication/repository/RemoteClusterRestoreLeaderService.kt +++ b/src/main/kotlin/org/opensearch/replication/repository/RemoteClusterRestoreLeaderService.kt @@ -13,27 +13,26 @@ * permissions and limitations under the License. */ -package com.amazon.elasticsearch.replication.repository - -import com.amazon.elasticsearch.replication.action.repository.RemoteClusterRepositoryRequest -import com.amazon.elasticsearch.replication.seqno.RemoteClusterRetentionLeaseHelper -import com.amazon.elasticsearch.replication.task.shard.ShardReplicationTask -import com.amazon.elasticsearch.replication.util.performOp -import org.elasticsearch.ElasticsearchException -import org.elasticsearch.action.support.single.shard.SingleShardRequest -import org.elasticsearch.client.node.NodeClient -import org.elasticsearch.common.component.AbstractLifecycleComponent -import org.elasticsearch.common.inject.Inject -import org.elasticsearch.common.inject.Singleton -import org.elasticsearch.common.lucene.store.InputStreamIndexInput -import org.elasticsearch.core.internal.io.IOUtils -import org.elasticsearch.index.engine.Engine -import org.elasticsearch.index.seqno.RetentionLeaseActions -import org.elasticsearch.index.seqno.SequenceNumbers -import org.elasticsearch.index.shard.IndexShard -import org.elasticsearch.index.shard.ShardId -import org.elasticsearch.index.store.Store -import org.elasticsearch.indices.IndicesService +package org.opensearch.replication.repository + +import org.opensearch.replication.action.repository.RemoteClusterRepositoryRequest +import org.opensearch.replication.seqno.RemoteClusterRetentionLeaseHelper +import org.opensearch.OpenSearchException +import org.opensearch.action.support.single.shard.SingleShardRequest +import org.opensearch.client.node.NodeClient +import org.opensearch.common.component.AbstractLifecycleComponent +import org.opensearch.common.inject.Inject +import org.opensearch.common.inject.Singleton +import org.opensearch.common.lucene.store.InputStreamIndexInput +import org.opensearch.core.internal.io.IOUtils +import org.opensearch.index.engine.Engine +import org.opensearch.index.seqno.RetentionLeaseActions +import org.opensearch.index.seqno.SequenceNumbers +import org.opensearch.index.shard.IndexShard +import org.opensearch.index.shard.ShardId +import org.opensearch.index.store.Store +import org.opensearch.indices.IndicesService +import org.opensearch.replication.util.performOp import java.io.Closeable import java.io.IOException @@ -79,7 +78,7 @@ class RemoteClusterRestoreLeaderService @Inject constructor(private val indicesS fileName: String, length: Long): InputStreamIndexInput { val leaderIndexShard = indicesService.getShardOrNull(request.leaderShardId) - ?: throw ElasticsearchException("Shard [$request.leaderShardId] missing") + ?: throw OpenSearchException("Shard [$request.leaderShardId] missing") val store = leaderIndexShard.store() val restoreContext = getRemoteClusterRestore(restoreUUID) val indexInput = restoreContext.openInput(store, fileName) @@ -95,7 +94,7 @@ class RemoteClusterRestoreLeaderService @Inject constructor(private val indicesS private fun ?> constructRestoreContext(restoreUUID: String, request: RemoteClusterRepositoryRequest): RestoreContext { val leaderIndexShard = indicesService.getShardOrNull(request.leaderShardId) - ?: throw ElasticsearchException("Shard [$request.leaderShardId] missing") + ?: throw OpenSearchException("Shard [$request.leaderShardId] missing") // Passing nodeclient of the leader to acquire the retention lease on leader shard val retentionLeaseHelper = RemoteClusterRetentionLeaseHelper(request.followerCluster, nodeClient) /** diff --git a/src/main/kotlin/com/amazon/elasticsearch/replication/repository/RestoreContext.kt b/src/main/kotlin/org/opensearch/replication/repository/RestoreContext.kt similarity index 83% rename from src/main/kotlin/com/amazon/elasticsearch/replication/repository/RestoreContext.kt rename to src/main/kotlin/org/opensearch/replication/repository/RestoreContext.kt index 156807a4..a5f82021 100644 --- a/src/main/kotlin/com/amazon/elasticsearch/replication/repository/RestoreContext.kt +++ b/src/main/kotlin/org/opensearch/replication/repository/RestoreContext.kt @@ -13,15 +13,15 @@ * permissions and limitations under the License. */ -package com.amazon.elasticsearch.replication.repository +package org.opensearch.replication.repository -import com.amazon.elasticsearch.replication.util.performOp import org.apache.lucene.store.IOContext import org.apache.lucene.store.IndexInput -import org.elasticsearch.ElasticsearchException -import org.elasticsearch.index.engine.Engine -import org.elasticsearch.index.shard.IndexShard -import org.elasticsearch.index.store.Store +import org.opensearch.OpenSearchException +import org.opensearch.index.engine.Engine +import org.opensearch.index.shard.IndexShard +import org.opensearch.index.store.Store +import org.opensearch.replication.util.performOp import java.io.Closeable class RestoreContext(val restoreUUID: String, @@ -36,7 +36,7 @@ class RestoreContext(val restoreUUID: String, private val currentFiles = LinkedHashMap(INITIAL_FILE_CACHE_CAPACITY) fun openInput(store: Store, fileName: String): IndexInput { - var currentIndexInput = currentFiles.getOrDefault(fileName, null) + var currentIndexInput = currentFiles.get(fileName) if(currentIndexInput != null) { return currentIndexInput.clone() } diff --git a/src/main/kotlin/com/amazon/elasticsearch/replication/rest/ReplicateIndexHandler.kt b/src/main/kotlin/org/opensearch/replication/rest/ReplicateIndexHandler.kt similarity index 74% rename from src/main/kotlin/com/amazon/elasticsearch/replication/rest/ReplicateIndexHandler.kt rename to src/main/kotlin/org/opensearch/replication/rest/ReplicateIndexHandler.kt index a4ac7331..cd0706f5 100644 --- a/src/main/kotlin/com/amazon/elasticsearch/replication/rest/ReplicateIndexHandler.kt +++ b/src/main/kotlin/org/opensearch/replication/rest/ReplicateIndexHandler.kt @@ -13,17 +13,17 @@ * permissions and limitations under the License. */ -package com.amazon.elasticsearch.replication.rest +package org.opensearch.replication.rest -import com.amazon.elasticsearch.replication.action.index.ReplicateIndexAction -import com.amazon.elasticsearch.replication.action.index.ReplicateIndexRequest -import org.elasticsearch.client.node.NodeClient -import org.elasticsearch.rest.BaseRestHandler -import org.elasticsearch.rest.BaseRestHandler.RestChannelConsumer -import org.elasticsearch.rest.RestChannel -import org.elasticsearch.rest.RestHandler -import org.elasticsearch.rest.RestRequest -import org.elasticsearch.rest.action.RestToXContentListener +import org.opensearch.replication.action.index.ReplicateIndexAction +import org.opensearch.replication.action.index.ReplicateIndexRequest +import org.opensearch.client.node.NodeClient +import org.opensearch.rest.BaseRestHandler +import org.opensearch.rest.BaseRestHandler.RestChannelConsumer +import org.opensearch.rest.RestChannel +import org.opensearch.rest.RestHandler +import org.opensearch.rest.RestRequest +import org.opensearch.rest.action.RestToXContentListener import java.io.IOException class ReplicateIndexHandler : BaseRestHandler() { diff --git a/src/main/kotlin/com/amazon/elasticsearch/replication/rest/StopIndexReplicationHandler.kt b/src/main/kotlin/org/opensearch/replication/rest/StopIndexReplicationHandler.kt similarity index 76% rename from src/main/kotlin/com/amazon/elasticsearch/replication/rest/StopIndexReplicationHandler.kt rename to src/main/kotlin/org/opensearch/replication/rest/StopIndexReplicationHandler.kt index 28180fc9..6ca2abb3 100644 --- a/src/main/kotlin/com/amazon/elasticsearch/replication/rest/StopIndexReplicationHandler.kt +++ b/src/main/kotlin/org/opensearch/replication/rest/StopIndexReplicationHandler.kt @@ -13,16 +13,16 @@ * permissions and limitations under the License. */ -package com.amazon.elasticsearch.replication.rest +package org.opensearch.replication.rest -import com.amazon.elasticsearch.replication.action.stop.StopIndexReplicationAction -import com.amazon.elasticsearch.replication.action.stop.StopIndexReplicationRequest -import org.elasticsearch.client.node.NodeClient -import org.elasticsearch.rest.BaseRestHandler -import org.elasticsearch.rest.RestChannel -import org.elasticsearch.rest.RestHandler -import org.elasticsearch.rest.RestRequest -import org.elasticsearch.rest.action.RestToXContentListener +import org.opensearch.replication.action.stop.StopIndexReplicationAction +import org.opensearch.replication.action.stop.StopIndexReplicationRequest +import org.opensearch.client.node.NodeClient +import org.opensearch.rest.BaseRestHandler +import org.opensearch.rest.RestChannel +import org.opensearch.rest.RestHandler +import org.opensearch.rest.RestRequest +import org.opensearch.rest.action.RestToXContentListener import java.io.IOException class StopIndexReplicationHandler : BaseRestHandler() { diff --git a/src/main/kotlin/com/amazon/elasticsearch/replication/rest/UpdateAutoFollowPatternsHandler.kt b/src/main/kotlin/org/opensearch/replication/rest/UpdateAutoFollowPatternsHandler.kt similarity index 70% rename from src/main/kotlin/com/amazon/elasticsearch/replication/rest/UpdateAutoFollowPatternsHandler.kt rename to src/main/kotlin/org/opensearch/replication/rest/UpdateAutoFollowPatternsHandler.kt index 4cb5757f..141dfd3f 100644 --- a/src/main/kotlin/com/amazon/elasticsearch/replication/rest/UpdateAutoFollowPatternsHandler.kt +++ b/src/main/kotlin/org/opensearch/replication/rest/UpdateAutoFollowPatternsHandler.kt @@ -13,18 +13,18 @@ * permissions and limitations under the License. */ -package com.amazon.elasticsearch.replication.rest - -import com.amazon.elasticsearch.replication.action.autofollow.UpdateAutoFollowPatternAction -import com.amazon.elasticsearch.replication.action.autofollow.UpdateAutoFollowPatternRequest -import org.elasticsearch.ElasticsearchStatusException -import org.elasticsearch.client.node.NodeClient -import org.elasticsearch.rest.BaseRestHandler -import org.elasticsearch.rest.BaseRestHandler.RestChannelConsumer -import org.elasticsearch.rest.RestHandler -import org.elasticsearch.rest.RestRequest -import org.elasticsearch.rest.RestStatus -import org.elasticsearch.rest.action.RestToXContentListener +package org.opensearch.replication.rest + +import org.opensearch.replication.action.autofollow.UpdateAutoFollowPatternAction +import org.opensearch.replication.action.autofollow.UpdateAutoFollowPatternRequest +import org.opensearch.OpenSearchStatusException +import org.opensearch.client.node.NodeClient +import org.opensearch.rest.BaseRestHandler +import org.opensearch.rest.BaseRestHandler.RestChannelConsumer +import org.opensearch.rest.RestHandler +import org.opensearch.rest.RestRequest +import org.opensearch.rest.RestStatus +import org.opensearch.rest.action.RestToXContentListener class UpdateAutoFollowPatternsHandler : BaseRestHandler() { @@ -45,7 +45,7 @@ class UpdateAutoFollowPatternsHandler : BaseRestHandler() { request.method() == RestRequest.Method.DELETE -> UpdateAutoFollowPatternRequest.Action.REMOVE // Should not be reached unless someone updates the restController with a new method but forgets to add it here. else -> - throw ElasticsearchStatusException("Unsupported method ", RestStatus.METHOD_NOT_ALLOWED, request.method()) + throw OpenSearchStatusException("Unsupported method ", RestStatus.METHOD_NOT_ALLOWED, request.method()) } val updateRequest = UpdateAutoFollowPatternRequest.fromXContent(request.contentParser(), action) diff --git a/src/main/kotlin/com/amazon/elasticsearch/replication/seqno/RemoteClusterRetentionLeaseHelper.kt b/src/main/kotlin/org/opensearch/replication/seqno/RemoteClusterRetentionLeaseHelper.kt similarity index 91% rename from src/main/kotlin/com/amazon/elasticsearch/replication/seqno/RemoteClusterRetentionLeaseHelper.kt rename to src/main/kotlin/org/opensearch/replication/seqno/RemoteClusterRetentionLeaseHelper.kt index 70c28ffe..ca7b08ea 100644 --- a/src/main/kotlin/com/amazon/elasticsearch/replication/seqno/RemoteClusterRetentionLeaseHelper.kt +++ b/src/main/kotlin/org/opensearch/replication/seqno/RemoteClusterRetentionLeaseHelper.kt @@ -13,16 +13,16 @@ * permissions and limitations under the License. */ -package com.amazon.elasticsearch.replication.seqno +package org.opensearch.replication.seqno -import com.amazon.elasticsearch.replication.util.suspendExecute import org.apache.logging.log4j.LogManager -import org.elasticsearch.client.Client -import org.elasticsearch.common.logging.Loggers -import org.elasticsearch.index.seqno.RetentionLeaseActions -import org.elasticsearch.index.seqno.RetentionLeaseAlreadyExistsException -import org.elasticsearch.index.seqno.RetentionLeaseNotFoundException -import org.elasticsearch.index.shard.ShardId +import org.opensearch.client.Client +import org.opensearch.common.logging.Loggers +import org.opensearch.index.seqno.RetentionLeaseActions +import org.opensearch.index.seqno.RetentionLeaseAlreadyExistsException +import org.opensearch.index.seqno.RetentionLeaseNotFoundException +import org.opensearch.index.shard.ShardId +import org.opensearch.replication.util.suspendExecute class RemoteClusterRetentionLeaseHelper constructor(val followerClusterName: String, val client: Client) { diff --git a/src/main/kotlin/com/amazon/elasticsearch/replication/task/CrossClusterReplicationTask.kt b/src/main/kotlin/org/opensearch/replication/task/CrossClusterReplicationTask.kt similarity index 86% rename from src/main/kotlin/com/amazon/elasticsearch/replication/task/CrossClusterReplicationTask.kt rename to src/main/kotlin/org/opensearch/replication/task/CrossClusterReplicationTask.kt index 400b192e..085702fb 100644 --- a/src/main/kotlin/com/amazon/elasticsearch/replication/task/CrossClusterReplicationTask.kt +++ b/src/main/kotlin/org/opensearch/replication/task/CrossClusterReplicationTask.kt @@ -13,11 +13,10 @@ * permissions and limitations under the License. */ -package com.amazon.elasticsearch.replication.task +package org.opensearch.replication.task -import com.amazon.elasticsearch.replication.util.SecurityContext -import com.amazon.elasticsearch.replication.util.coroutineContext -import com.amazon.elasticsearch.replication.util.suspending +import org.opensearch.replication.util.SecurityContext +import org.opensearch.replication.util.suspending import kotlinx.coroutines.CancellationException import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.NonCancellable @@ -26,21 +25,22 @@ import kotlinx.coroutines.launch import kotlinx.coroutines.withContext import kotlinx.coroutines.withTimeoutOrNull import org.apache.logging.log4j.Logger -import org.elasticsearch.action.ActionListener -import org.elasticsearch.action.ActionResponse -import org.elasticsearch.client.Client -import org.elasticsearch.cluster.service.ClusterService -import org.elasticsearch.common.io.stream.StreamOutput -import org.elasticsearch.common.xcontent.ToXContent -import org.elasticsearch.common.xcontent.ToXContentObject -import org.elasticsearch.common.xcontent.XContentBuilder -import org.elasticsearch.index.shard.ShardId -import org.elasticsearch.persistent.AllocatedPersistentTask -import org.elasticsearch.persistent.PersistentTaskState -import org.elasticsearch.persistent.PersistentTasksService -import org.elasticsearch.tasks.TaskId -import org.elasticsearch.tasks.TaskManager -import org.elasticsearch.threadpool.ThreadPool +import org.opensearch.action.ActionListener +import org.opensearch.action.ActionResponse +import org.opensearch.client.Client +import org.opensearch.cluster.service.ClusterService +import org.opensearch.common.io.stream.StreamOutput +import org.opensearch.common.xcontent.ToXContent +import org.opensearch.common.xcontent.ToXContentObject +import org.opensearch.common.xcontent.XContentBuilder +import org.opensearch.index.shard.ShardId +import org.opensearch.persistent.AllocatedPersistentTask +import org.opensearch.persistent.PersistentTaskState +import org.opensearch.persistent.PersistentTasksService +import org.opensearch.replication.util.coroutineContext +import org.opensearch.tasks.TaskId +import org.opensearch.tasks.TaskManager +import org.opensearch.threadpool.ThreadPool abstract class CrossClusterReplicationTask(id: Long, type: String, action: String, description: String, parentTask: TaskId, headers: Map, diff --git a/src/main/kotlin/com/amazon/elasticsearch/replication/task/IndexCloseListener.kt b/src/main/kotlin/org/opensearch/replication/task/IndexCloseListener.kt similarity index 86% rename from src/main/kotlin/com/amazon/elasticsearch/replication/task/IndexCloseListener.kt rename to src/main/kotlin/org/opensearch/replication/task/IndexCloseListener.kt index 4b3cef81..5b154c1f 100644 --- a/src/main/kotlin/com/amazon/elasticsearch/replication/task/IndexCloseListener.kt +++ b/src/main/kotlin/org/opensearch/replication/task/IndexCloseListener.kt @@ -13,14 +13,14 @@ * permissions and limitations under the License. */ -package com.amazon.elasticsearch.replication.task +package org.opensearch.replication.task -import org.elasticsearch.common.settings.Settings -import org.elasticsearch.index.IndexService -import org.elasticsearch.index.shard.IndexEventListener -import org.elasticsearch.index.shard.IndexShard -import org.elasticsearch.index.shard.ShardId -import org.elasticsearch.indices.cluster.IndicesClusterStateService +import org.opensearch.common.settings.Settings +import org.opensearch.index.IndexService +import org.opensearch.index.shard.IndexEventListener +import org.opensearch.index.shard.IndexShard +import org.opensearch.index.shard.ShardId +import org.opensearch.indices.cluster.IndicesClusterStateService import java.util.Collections import java.util.concurrent.ConcurrentHashMap diff --git a/src/main/kotlin/com/amazon/elasticsearch/replication/task/ReplicationState.kt b/src/main/kotlin/org/opensearch/replication/task/ReplicationState.kt similarity index 75% rename from src/main/kotlin/com/amazon/elasticsearch/replication/task/ReplicationState.kt rename to src/main/kotlin/org/opensearch/replication/task/ReplicationState.kt index e8f6fa55..ae38248e 100644 --- a/src/main/kotlin/com/amazon/elasticsearch/replication/task/ReplicationState.kt +++ b/src/main/kotlin/org/opensearch/replication/task/ReplicationState.kt @@ -13,14 +13,14 @@ * permissions and limitations under the License. */ -package com.amazon.elasticsearch.replication.task +package org.opensearch.replication.task -import org.elasticsearch.common.io.stream.StreamInput -import org.elasticsearch.common.io.stream.StreamOutput -import org.elasticsearch.common.io.stream.Writeable -import org.elasticsearch.common.xcontent.ToXContent -import org.elasticsearch.common.xcontent.ToXContentFragment -import org.elasticsearch.common.xcontent.XContentBuilder +import org.opensearch.common.io.stream.StreamInput +import org.opensearch.common.io.stream.StreamOutput +import org.opensearch.common.io.stream.Writeable +import org.opensearch.common.xcontent.ToXContent +import org.opensearch.common.xcontent.ToXContentFragment +import org.opensearch.common.xcontent.XContentBuilder /** * Enum that represents the state of replication of either shards or indices. diff --git a/src/main/kotlin/com/amazon/elasticsearch/replication/task/autofollow/AutoFollowExecutor.kt b/src/main/kotlin/org/opensearch/replication/task/autofollow/AutoFollowExecutor.kt similarity index 80% rename from src/main/kotlin/com/amazon/elasticsearch/replication/task/autofollow/AutoFollowExecutor.kt rename to src/main/kotlin/org/opensearch/replication/task/autofollow/AutoFollowExecutor.kt index 8b7caf55..6b68c0be 100644 --- a/src/main/kotlin/com/amazon/elasticsearch/replication/task/autofollow/AutoFollowExecutor.kt +++ b/src/main/kotlin/org/opensearch/replication/task/autofollow/AutoFollowExecutor.kt @@ -13,16 +13,16 @@ * permissions and limitations under the License. */ -package com.amazon.elasticsearch.replication.task.autofollow +package org.opensearch.replication.task.autofollow -import org.elasticsearch.client.Client -import org.elasticsearch.cluster.service.ClusterService -import org.elasticsearch.persistent.AllocatedPersistentTask -import org.elasticsearch.persistent.PersistentTaskState -import org.elasticsearch.persistent.PersistentTasksCustomMetadata.PersistentTask -import org.elasticsearch.persistent.PersistentTasksExecutor -import org.elasticsearch.tasks.TaskId -import org.elasticsearch.threadpool.ThreadPool +import org.opensearch.client.Client +import org.opensearch.cluster.service.ClusterService +import org.opensearch.persistent.AllocatedPersistentTask +import org.opensearch.persistent.PersistentTaskState +import org.opensearch.persistent.PersistentTasksCustomMetadata.PersistentTask +import org.opensearch.persistent.PersistentTasksExecutor +import org.opensearch.tasks.TaskId +import org.opensearch.threadpool.ThreadPool class AutoFollowExecutor(executor: String, private val clusterService: ClusterService, private val threadPool: ThreadPool, private val client: Client) : diff --git a/src/main/kotlin/com/amazon/elasticsearch/replication/task/autofollow/AutoFollowParams.kt b/src/main/kotlin/org/opensearch/replication/task/autofollow/AutoFollowParams.kt similarity index 77% rename from src/main/kotlin/com/amazon/elasticsearch/replication/task/autofollow/AutoFollowParams.kt rename to src/main/kotlin/org/opensearch/replication/task/autofollow/AutoFollowParams.kt index bbbf6c01..b721e6e4 100644 --- a/src/main/kotlin/com/amazon/elasticsearch/replication/task/autofollow/AutoFollowParams.kt +++ b/src/main/kotlin/org/opensearch/replication/task/autofollow/AutoFollowParams.kt @@ -13,17 +13,17 @@ * permissions and limitations under the License. */ -package com.amazon.elasticsearch.replication.task.autofollow +package org.opensearch.replication.task.autofollow -import org.elasticsearch.Version -import org.elasticsearch.common.ParseField -import org.elasticsearch.common.io.stream.StreamInput -import org.elasticsearch.common.io.stream.StreamOutput -import org.elasticsearch.common.xcontent.ObjectParser -import org.elasticsearch.common.xcontent.ToXContent -import org.elasticsearch.common.xcontent.XContentBuilder -import org.elasticsearch.common.xcontent.XContentParser -import org.elasticsearch.persistent.PersistentTaskParams +import org.opensearch.Version +import org.opensearch.common.ParseField +import org.opensearch.common.io.stream.StreamInput +import org.opensearch.common.io.stream.StreamOutput +import org.opensearch.common.xcontent.ObjectParser +import org.opensearch.common.xcontent.ToXContent +import org.opensearch.common.xcontent.XContentBuilder +import org.opensearch.common.xcontent.XContentParser +import org.opensearch.persistent.PersistentTaskParams import java.io.IOException class AutoFollowParams : PersistentTaskParams { @@ -63,7 +63,7 @@ class AutoFollowParams : PersistentTaskParams { override fun getWriteableName() = NAME - override fun getMinimalSupportedVersion() = Version.V_7_1_0 + override fun getMinimalSupportedVersion() = Version.V_1_0_0 override fun toXContent(builder: XContentBuilder, params: ToXContent.Params): XContentBuilder { return builder.startObject() diff --git a/src/main/kotlin/com/amazon/elasticsearch/replication/task/autofollow/AutoFollowTask.kt b/src/main/kotlin/org/opensearch/replication/task/autofollow/AutoFollowTask.kt similarity index 83% rename from src/main/kotlin/com/amazon/elasticsearch/replication/task/autofollow/AutoFollowTask.kt rename to src/main/kotlin/org/opensearch/replication/task/autofollow/AutoFollowTask.kt index b3de2a39..9ea08574 100644 --- a/src/main/kotlin/com/amazon/elasticsearch/replication/task/autofollow/AutoFollowTask.kt +++ b/src/main/kotlin/org/opensearch/replication/task/autofollow/AutoFollowTask.kt @@ -13,26 +13,26 @@ * permissions and limitations under the License. */ -package com.amazon.elasticsearch.replication.task.autofollow +package org.opensearch.replication.task.autofollow -import com.amazon.elasticsearch.replication.action.index.ReplicateIndexAction -import com.amazon.elasticsearch.replication.action.index.ReplicateIndexRequest -import com.amazon.elasticsearch.replication.metadata.ReplicationMetadata -import com.amazon.elasticsearch.replication.task.CrossClusterReplicationTask -import com.amazon.elasticsearch.replication.task.ReplicationState -import com.amazon.elasticsearch.replication.util.suspendExecute -import com.amazon.elasticsearch.replication.util.suspending +import org.opensearch.replication.action.index.ReplicateIndexAction +import org.opensearch.replication.action.index.ReplicateIndexRequest +import org.opensearch.replication.metadata.ReplicationMetadata +import org.opensearch.replication.task.CrossClusterReplicationTask +import org.opensearch.replication.task.ReplicationState +import org.opensearch.replication.util.suspending import kotlinx.coroutines.delay import kotlinx.coroutines.isActive -import org.elasticsearch.action.admin.indices.get.GetIndexRequest -import org.elasticsearch.action.support.IndicesOptions -import org.elasticsearch.client.Client -import org.elasticsearch.cluster.service.ClusterService -import org.elasticsearch.common.logging.Loggers -import org.elasticsearch.common.unit.TimeValue -import org.elasticsearch.persistent.PersistentTaskState -import org.elasticsearch.tasks.TaskId -import org.elasticsearch.threadpool.ThreadPool +import org.opensearch.action.admin.indices.get.GetIndexRequest +import org.opensearch.action.support.IndicesOptions +import org.opensearch.client.Client +import org.opensearch.cluster.service.ClusterService +import org.opensearch.common.logging.Loggers +import org.opensearch.common.unit.TimeValue +import org.opensearch.persistent.PersistentTaskState +import org.opensearch.replication.util.suspendExecute +import org.opensearch.tasks.TaskId +import org.opensearch.threadpool.ThreadPool class AutoFollowTask(id: Long, type: String, action: String, description: String, parentTask: TaskId, headers: Map, diff --git a/src/main/kotlin/com/amazon/elasticsearch/replication/task/index/IndexReplicationExecutor.kt b/src/main/kotlin/org/opensearch/replication/task/index/IndexReplicationExecutor.kt similarity index 78% rename from src/main/kotlin/com/amazon/elasticsearch/replication/task/index/IndexReplicationExecutor.kt rename to src/main/kotlin/org/opensearch/replication/task/index/IndexReplicationExecutor.kt index 8dab25b7..f682ea70 100644 --- a/src/main/kotlin/com/amazon/elasticsearch/replication/task/index/IndexReplicationExecutor.kt +++ b/src/main/kotlin/org/opensearch/replication/task/index/IndexReplicationExecutor.kt @@ -13,22 +13,22 @@ * permissions and limitations under the License. */ -package com.amazon.elasticsearch.replication.task.index +package org.opensearch.replication.task.index -import com.amazon.elasticsearch.replication.metadata.REPLICATION_OVERALL_STATE_KEY -import com.amazon.elasticsearch.replication.metadata.REPLICATION_OVERALL_STATE_RUNNING_VALUE -import com.amazon.elasticsearch.replication.metadata.getReplicationStateParamsForIndex -import com.amazon.elasticsearch.replication.util.persistentTasksService +import org.opensearch.replication.metadata.REPLICATION_OVERALL_STATE_KEY +import org.opensearch.replication.metadata.REPLICATION_OVERALL_STATE_RUNNING_VALUE +import org.opensearch.replication.metadata.getReplicationStateParamsForIndex +import org.opensearch.replication.util.persistentTasksService import org.apache.logging.log4j.LogManager -import org.elasticsearch.client.Client -import org.elasticsearch.cluster.ClusterState -import org.elasticsearch.cluster.service.ClusterService -import org.elasticsearch.persistent.AllocatedPersistentTask -import org.elasticsearch.persistent.PersistentTaskState -import org.elasticsearch.persistent.PersistentTasksCustomMetadata.PersistentTask -import org.elasticsearch.persistent.PersistentTasksExecutor -import org.elasticsearch.tasks.TaskId -import org.elasticsearch.threadpool.ThreadPool +import org.opensearch.client.Client +import org.opensearch.cluster.ClusterState +import org.opensearch.cluster.service.ClusterService +import org.opensearch.persistent.AllocatedPersistentTask +import org.opensearch.persistent.PersistentTaskState +import org.opensearch.persistent.PersistentTasksCustomMetadata.PersistentTask +import org.opensearch.persistent.PersistentTasksExecutor +import org.opensearch.tasks.TaskId +import org.opensearch.threadpool.ThreadPool class IndexReplicationExecutor(executor: String, private val clusterService: ClusterService, private val threadPool: ThreadPool, private val client: Client) diff --git a/src/main/kotlin/com/amazon/elasticsearch/replication/task/index/IndexReplicationParams.kt b/src/main/kotlin/org/opensearch/replication/task/index/IndexReplicationParams.kt similarity index 79% rename from src/main/kotlin/com/amazon/elasticsearch/replication/task/index/IndexReplicationParams.kt rename to src/main/kotlin/org/opensearch/replication/task/index/IndexReplicationParams.kt index 5823e9d7..44beae79 100644 --- a/src/main/kotlin/com/amazon/elasticsearch/replication/task/index/IndexReplicationParams.kt +++ b/src/main/kotlin/org/opensearch/replication/task/index/IndexReplicationParams.kt @@ -13,20 +13,20 @@ * permissions and limitations under the License. */ -package com.amazon.elasticsearch.replication.task.index +package org.opensearch.replication.task.index -import org.elasticsearch.Version -import org.elasticsearch.common.ParseField -import org.elasticsearch.common.Strings -import org.elasticsearch.common.io.stream.StreamInput -import org.elasticsearch.common.io.stream.StreamOutput -import org.elasticsearch.common.xcontent.ContextParser -import org.elasticsearch.common.xcontent.ObjectParser -import org.elasticsearch.common.xcontent.ToXContent -import org.elasticsearch.common.xcontent.XContentBuilder -import org.elasticsearch.common.xcontent.XContentParser -import org.elasticsearch.index.Index -import org.elasticsearch.persistent.PersistentTaskParams +import org.opensearch.Version +import org.opensearch.common.ParseField +import org.opensearch.common.Strings +import org.opensearch.common.io.stream.StreamInput +import org.opensearch.common.io.stream.StreamOutput +import org.opensearch.common.xcontent.ContextParser +import org.opensearch.common.xcontent.ObjectParser +import org.opensearch.common.xcontent.ToXContent +import org.opensearch.common.xcontent.XContentBuilder +import org.opensearch.common.xcontent.XContentParser +import org.opensearch.index.Index +import org.opensearch.persistent.PersistentTaskParams import java.io.IOException class IndexReplicationParams : PersistentTaskParams { @@ -81,7 +81,7 @@ class IndexReplicationParams : PersistentTaskParams { } override fun getMinimalSupportedVersion(): Version { - return Version.V_7_1_0 + return Version.V_1_0_0 } override fun toString(): String { diff --git a/src/main/kotlin/com/amazon/elasticsearch/replication/task/index/IndexReplicationState.kt b/src/main/kotlin/org/opensearch/replication/task/index/IndexReplicationState.kt similarity index 86% rename from src/main/kotlin/com/amazon/elasticsearch/replication/task/index/IndexReplicationState.kt rename to src/main/kotlin/org/opensearch/replication/task/index/IndexReplicationState.kt index d7d8216f..963f8643 100644 --- a/src/main/kotlin/com/amazon/elasticsearch/replication/task/index/IndexReplicationState.kt +++ b/src/main/kotlin/org/opensearch/replication/task/index/IndexReplicationState.kt @@ -13,21 +13,20 @@ * permissions and limitations under the License. */ -package com.amazon.elasticsearch.replication.task.index - -import com.amazon.elasticsearch.replication.task.ReplicationState -import com.amazon.elasticsearch.replication.task.autofollow.AutoFollowParams -import com.amazon.elasticsearch.replication.task.shard.ShardReplicationParams -import org.elasticsearch.common.ParseField -import org.elasticsearch.common.io.stream.StreamInput -import org.elasticsearch.common.io.stream.StreamOutput -import org.elasticsearch.common.xcontent.ObjectParser -import org.elasticsearch.common.xcontent.ToXContent -import org.elasticsearch.common.xcontent.XContentBuilder -import org.elasticsearch.common.xcontent.XContentParser -import org.elasticsearch.index.shard.ShardId -import org.elasticsearch.persistent.PersistentTaskState -import org.elasticsearch.persistent.PersistentTasksCustomMetadata.PersistentTask +package org.opensearch.replication.task.index + +import org.opensearch.replication.task.ReplicationState +import org.opensearch.replication.task.shard.ShardReplicationParams +import org.opensearch.common.ParseField +import org.opensearch.common.io.stream.StreamInput +import org.opensearch.common.io.stream.StreamOutput +import org.opensearch.common.xcontent.ObjectParser +import org.opensearch.common.xcontent.ToXContent +import org.opensearch.common.xcontent.XContentBuilder +import org.opensearch.common.xcontent.XContentParser +import org.opensearch.index.shard.ShardId +import org.opensearch.persistent.PersistentTaskState +import org.opensearch.persistent.PersistentTasksCustomMetadata.PersistentTask import java.io.IOException import java.lang.IllegalArgumentException diff --git a/src/main/kotlin/com/amazon/elasticsearch/replication/task/index/IndexReplicationTask.kt b/src/main/kotlin/org/opensearch/replication/task/index/IndexReplicationTask.kt similarity index 82% rename from src/main/kotlin/com/amazon/elasticsearch/replication/task/index/IndexReplicationTask.kt rename to src/main/kotlin/org/opensearch/replication/task/index/IndexReplicationTask.kt index 6087ed82..415c498d 100644 --- a/src/main/kotlin/com/amazon/elasticsearch/replication/task/index/IndexReplicationTask.kt +++ b/src/main/kotlin/org/opensearch/replication/task/index/IndexReplicationTask.kt @@ -13,60 +13,60 @@ * permissions and limitations under the License. */ -package com.amazon.elasticsearch.replication.task.index - -import com.amazon.elasticsearch.replication.ReplicationException -import com.amazon.elasticsearch.replication.action.index.block.IndexBlockUpdateType -import com.amazon.elasticsearch.replication.action.index.block.UpdateIndexBlockRequest -import com.amazon.elasticsearch.replication.action.stop.StopIndexReplicationAction -import com.amazon.elasticsearch.replication.action.stop.StopIndexReplicationRequest -import com.amazon.elasticsearch.replication.metadata.getReplicationStateParamsForIndex -import com.amazon.elasticsearch.replication.repository.REMOTE_SNAPSHOT_NAME -import com.amazon.elasticsearch.replication.repository.RemoteClusterRepository -import com.amazon.elasticsearch.replication.seqno.RemoteClusterRetentionLeaseHelper -import com.amazon.elasticsearch.replication.task.CrossClusterReplicationTask -import com.amazon.elasticsearch.replication.task.ReplicationState -import com.amazon.elasticsearch.replication.task.shard.ShardReplicationExecutor -import com.amazon.elasticsearch.replication.task.shard.ShardReplicationParams -import com.amazon.elasticsearch.replication.task.shard.ShardReplicationTask -import com.amazon.elasticsearch.replication.util.suspending -import com.amazon.elasticsearch.replication.util.waitForNextChange -import com.amazon.elasticsearch.replication.util.startTask -import com.amazon.elasticsearch.replication.util.suspendExecute +package org.opensearch.replication.task.index + +import org.opensearch.replication.ReplicationException +import org.opensearch.replication.action.index.block.IndexBlockUpdateType +import org.opensearch.replication.action.index.block.UpdateIndexBlockRequest +import org.opensearch.replication.action.stop.StopIndexReplicationAction +import org.opensearch.replication.action.stop.StopIndexReplicationRequest +import org.opensearch.replication.metadata.getReplicationStateParamsForIndex +import org.opensearch.replication.repository.REMOTE_SNAPSHOT_NAME +import org.opensearch.replication.repository.RemoteClusterRepository +import org.opensearch.replication.seqno.RemoteClusterRetentionLeaseHelper +import org.opensearch.replication.task.CrossClusterReplicationTask +import org.opensearch.replication.task.ReplicationState +import org.opensearch.replication.task.shard.ShardReplicationExecutor +import org.opensearch.replication.task.shard.ShardReplicationParams +import org.opensearch.replication.task.shard.ShardReplicationTask +import org.opensearch.replication.util.suspending import kotlinx.coroutines.cancel import kotlinx.coroutines.delay import kotlinx.coroutines.isActive -import org.elasticsearch.ElasticsearchTimeoutException -import org.elasticsearch.ResourceNotFoundException -import org.elasticsearch.action.ActionListener -import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest -import org.elasticsearch.client.Client -import org.elasticsearch.cluster.ClusterChangedEvent -import org.elasticsearch.cluster.ClusterState -import org.elasticsearch.cluster.ClusterStateListener -import org.elasticsearch.cluster.ClusterStateObserver -import org.elasticsearch.cluster.RestoreInProgress -import org.elasticsearch.cluster.service.ClusterService -import org.elasticsearch.common.io.stream.StreamOutput -import org.elasticsearch.common.logging.Loggers -import org.elasticsearch.common.xcontent.ToXContent -import org.elasticsearch.common.xcontent.ToXContentObject -import org.elasticsearch.common.xcontent.XContentBuilder -import org.elasticsearch.index.Index -import org.elasticsearch.index.shard.ShardId -import org.elasticsearch.persistent.PersistentTaskState -import org.elasticsearch.persistent.PersistentTasksCustomMetadata -import org.elasticsearch.persistent.PersistentTasksCustomMetadata.PersistentTask -import org.elasticsearch.persistent.PersistentTasksNodeService -import org.elasticsearch.persistent.PersistentTasksService -import org.elasticsearch.tasks.TaskId -import org.elasticsearch.threadpool.ThreadPool +import org.opensearch.OpenSearchTimeoutException +import org.opensearch.ResourceNotFoundException +import org.opensearch.action.ActionListener +import org.opensearch.action.admin.indices.delete.DeleteIndexRequest +import org.opensearch.client.Client +import org.opensearch.cluster.ClusterChangedEvent +import org.opensearch.cluster.ClusterState +import org.opensearch.cluster.ClusterStateListener +import org.opensearch.cluster.ClusterStateObserver +import org.opensearch.cluster.RestoreInProgress +import org.opensearch.cluster.service.ClusterService +import org.opensearch.common.io.stream.StreamOutput +import org.opensearch.common.logging.Loggers +import org.opensearch.common.xcontent.ToXContent +import org.opensearch.common.xcontent.ToXContentObject +import org.opensearch.common.xcontent.XContentBuilder +import org.opensearch.index.Index +import org.opensearch.index.shard.ShardId +import org.opensearch.persistent.PersistentTaskState +import org.opensearch.persistent.PersistentTasksCustomMetadata +import org.opensearch.persistent.PersistentTasksCustomMetadata.PersistentTask +import org.opensearch.persistent.PersistentTasksNodeService +import org.opensearch.persistent.PersistentTasksService +import org.opensearch.tasks.TaskId +import org.opensearch.threadpool.ThreadPool import java.util.function.Predicate import java.util.stream.Collectors import kotlin.coroutines.resume import kotlin.coroutines.resumeWithException import kotlin.coroutines.suspendCoroutine -import com.amazon.elasticsearch.replication.action.index.block.UpdateIndexBlockAction +import org.opensearch.replication.action.index.block.UpdateIndexBlockAction +import org.opensearch.replication.util.startTask +import org.opensearch.replication.util.suspendExecute +import org.opensearch.replication.util.waitForNextChange class IndexReplicationTask(id: Long, type: String, action: String, description: String, parentTask: TaskId, @@ -261,7 +261,7 @@ class IndexReplicationTask(id: Long, type: String, action: String, description: while (restore.state() != RestoreInProgress.State.FAILURE && restore.state() != RestoreInProgress.State.SUCCESS) { try { cso.waitForNextChange("remote restore finish") - } catch(e: ElasticsearchTimeoutException) { + } catch(e: OpenSearchTimeoutException) { log.info("Waiting for restore to complete") } restore = inProgressRestore() ?: throw ResourceNotFoundException(""" diff --git a/src/main/kotlin/com/amazon/elasticsearch/replication/task/shard/ShardReplicationExecutor.kt b/src/main/kotlin/org/opensearch/replication/task/shard/ShardReplicationExecutor.kt similarity index 78% rename from src/main/kotlin/com/amazon/elasticsearch/replication/task/shard/ShardReplicationExecutor.kt rename to src/main/kotlin/org/opensearch/replication/task/shard/ShardReplicationExecutor.kt index 1247315b..d816c7ff 100644 --- a/src/main/kotlin/com/amazon/elasticsearch/replication/task/shard/ShardReplicationExecutor.kt +++ b/src/main/kotlin/org/opensearch/replication/task/shard/ShardReplicationExecutor.kt @@ -13,23 +13,23 @@ * permissions and limitations under the License. */ -package com.amazon.elasticsearch.replication.task.shard +package org.opensearch.replication.task.shard -import com.amazon.elasticsearch.replication.metadata.REPLICATION_OVERALL_STATE_KEY -import com.amazon.elasticsearch.replication.metadata.REPLICATION_OVERALL_STATE_RUNNING_VALUE -import com.amazon.elasticsearch.replication.metadata.getReplicationStateParamsForIndex +import org.opensearch.replication.metadata.REPLICATION_OVERALL_STATE_KEY +import org.opensearch.replication.metadata.REPLICATION_OVERALL_STATE_RUNNING_VALUE +import org.opensearch.replication.metadata.getReplicationStateParamsForIndex import org.apache.logging.log4j.LogManager -import org.elasticsearch.ElasticsearchException -import org.elasticsearch.client.Client -import org.elasticsearch.cluster.ClusterState -import org.elasticsearch.cluster.service.ClusterService -import org.elasticsearch.persistent.AllocatedPersistentTask -import org.elasticsearch.persistent.PersistentTaskState -import org.elasticsearch.persistent.PersistentTasksCustomMetadata.Assignment -import org.elasticsearch.persistent.PersistentTasksCustomMetadata.PersistentTask -import org.elasticsearch.persistent.PersistentTasksExecutor -import org.elasticsearch.tasks.TaskId -import org.elasticsearch.threadpool.ThreadPool +import org.opensearch.OpenSearchException +import org.opensearch.client.Client +import org.opensearch.cluster.ClusterState +import org.opensearch.cluster.service.ClusterService +import org.opensearch.persistent.AllocatedPersistentTask +import org.opensearch.persistent.PersistentTaskState +import org.opensearch.persistent.PersistentTasksCustomMetadata.Assignment +import org.opensearch.persistent.PersistentTasksCustomMetadata.PersistentTask +import org.opensearch.persistent.PersistentTasksExecutor +import org.opensearch.tasks.TaskId +import org.opensearch.threadpool.ThreadPool class ShardReplicationExecutor(executor: String, private val clusterService : ClusterService, private val threadPool: ThreadPool, private val client: Client) : @@ -44,7 +44,7 @@ class ShardReplicationExecutor(executor: String, private val clusterService : Cl override fun validate(params: ShardReplicationParams, clusterState: ClusterState) { // Checks that there is a primary shard. Side-effect will check that the index and shard exists. clusterState.routingTable.shardRoutingTable(params.followerShardId) - .primaryShard() ?: throw ElasticsearchException("no primary shard available for ${params.followerShardId}") + .primaryShard() ?: throw OpenSearchException("no primary shard available for ${params.followerShardId}") val replicationStateParams = getReplicationStateParamsForIndex(clusterService, params.followerShardId.indexName) ?: throw IllegalStateException("Cant find replication details metadata for followIndex:${params.followerShardId.indexName}. " + diff --git a/src/main/kotlin/com/amazon/elasticsearch/replication/task/shard/ShardReplicationParams.kt b/src/main/kotlin/org/opensearch/replication/task/shard/ShardReplicationParams.kt similarity index 86% rename from src/main/kotlin/com/amazon/elasticsearch/replication/task/shard/ShardReplicationParams.kt rename to src/main/kotlin/org/opensearch/replication/task/shard/ShardReplicationParams.kt index 1612d75f..5ed8d2dc 100644 --- a/src/main/kotlin/com/amazon/elasticsearch/replication/task/shard/ShardReplicationParams.kt +++ b/src/main/kotlin/org/opensearch/replication/task/shard/ShardReplicationParams.kt @@ -13,21 +13,21 @@ * permissions and limitations under the License. */ -package com.amazon.elasticsearch.replication.task.shard - -import org.elasticsearch.Version -import org.elasticsearch.common.ParseField -import org.elasticsearch.common.Strings -import org.elasticsearch.common.io.stream.StreamInput -import org.elasticsearch.common.io.stream.StreamOutput -import org.elasticsearch.common.xcontent.ObjectParser -import org.elasticsearch.common.xcontent.ToXContent -import org.elasticsearch.common.xcontent.XContentBuilder -import org.elasticsearch.common.xcontent.XContentParser -import org.elasticsearch.index.shard.ShardId -import org.elasticsearch.persistent.PersistentTaskParams +package org.opensearch.replication.task.shard + +import org.opensearch.Version +import org.opensearch.common.ParseField +import org.opensearch.common.Strings +import org.opensearch.common.io.stream.StreamInput +import org.opensearch.common.io.stream.StreamOutput +import org.opensearch.common.xcontent.ObjectParser +import org.opensearch.common.xcontent.ToXContent +import org.opensearch.common.xcontent.XContentBuilder +import org.opensearch.common.xcontent.XContentParser +import org.opensearch.index.shard.ShardId +import org.opensearch.persistent.PersistentTaskParams import java.io.IOException -import org.elasticsearch.index.Index +import org.opensearch.index.Index class ShardReplicationParams : PersistentTaskParams { @@ -84,7 +84,7 @@ class ShardReplicationParams : PersistentTaskParams { } override fun getMinimalSupportedVersion(): Version { - return Version.V_7_1_0 + return Version.V_1_0_0 } override fun toString(): String { diff --git a/src/main/kotlin/com/amazon/elasticsearch/replication/task/shard/ShardReplicationState.kt b/src/main/kotlin/org/opensearch/replication/task/shard/ShardReplicationState.kt similarity index 86% rename from src/main/kotlin/com/amazon/elasticsearch/replication/task/shard/ShardReplicationState.kt rename to src/main/kotlin/org/opensearch/replication/task/shard/ShardReplicationState.kt index 0c5163ff..23e61bf1 100644 --- a/src/main/kotlin/com/amazon/elasticsearch/replication/task/shard/ShardReplicationState.kt +++ b/src/main/kotlin/org/opensearch/replication/task/shard/ShardReplicationState.kt @@ -13,17 +13,17 @@ * permissions and limitations under the License. */ -package com.amazon.elasticsearch.replication.task.shard +package org.opensearch.replication.task.shard -import com.amazon.elasticsearch.replication.task.ReplicationState -import org.elasticsearch.common.ParseField -import org.elasticsearch.common.io.stream.StreamInput -import org.elasticsearch.common.io.stream.StreamOutput -import org.elasticsearch.common.xcontent.ObjectParser -import org.elasticsearch.common.xcontent.ToXContent -import org.elasticsearch.common.xcontent.XContentBuilder -import org.elasticsearch.common.xcontent.XContentParser -import org.elasticsearch.persistent.PersistentTaskState +import org.opensearch.replication.task.ReplicationState +import org.opensearch.common.ParseField +import org.opensearch.common.io.stream.StreamInput +import org.opensearch.common.io.stream.StreamOutput +import org.opensearch.common.xcontent.ObjectParser +import org.opensearch.common.xcontent.ToXContent +import org.opensearch.common.xcontent.XContentBuilder +import org.opensearch.common.xcontent.XContentParser +import org.opensearch.persistent.PersistentTaskState import java.io.IOException import java.lang.IllegalArgumentException import java.lang.IllegalStateException diff --git a/src/main/kotlin/com/amazon/elasticsearch/replication/task/shard/ShardReplicationTask.kt b/src/main/kotlin/org/opensearch/replication/task/shard/ShardReplicationTask.kt similarity index 80% rename from src/main/kotlin/com/amazon/elasticsearch/replication/task/shard/ShardReplicationTask.kt rename to src/main/kotlin/org/opensearch/replication/task/shard/ShardReplicationTask.kt index a012dc77..0cca4455 100644 --- a/src/main/kotlin/com/amazon/elasticsearch/replication/task/shard/ShardReplicationTask.kt +++ b/src/main/kotlin/org/opensearch/replication/task/shard/ShardReplicationTask.kt @@ -13,39 +13,39 @@ * permissions and limitations under the License. */ -package com.amazon.elasticsearch.replication.task.shard - -import com.amazon.elasticsearch.replication.ReplicationPlugin.Companion.REPLICATION_CHANGE_BATCH_SIZE -import com.amazon.elasticsearch.replication.action.changes.GetChangesAction -import com.amazon.elasticsearch.replication.action.changes.GetChangesRequest -import com.amazon.elasticsearch.replication.action.changes.GetChangesResponse -import com.amazon.elasticsearch.replication.metadata.getReplicationStateParamsForIndex -import com.amazon.elasticsearch.replication.seqno.RemoteClusterRetentionLeaseHelper -import com.amazon.elasticsearch.replication.task.CrossClusterReplicationTask -import com.amazon.elasticsearch.replication.task.ReplicationState -import com.amazon.elasticsearch.replication.util.indicesService -import com.amazon.elasticsearch.replication.util.suspendExecuteWithRetries -import com.amazon.elasticsearch.replication.util.suspending +package org.opensearch.replication.task.shard + +import org.opensearch.replication.ReplicationPlugin.Companion.REPLICATION_CHANGE_BATCH_SIZE +import org.opensearch.replication.action.changes.GetChangesAction +import org.opensearch.replication.action.changes.GetChangesRequest +import org.opensearch.replication.action.changes.GetChangesResponse +import org.opensearch.replication.metadata.getReplicationStateParamsForIndex +import org.opensearch.replication.seqno.RemoteClusterRetentionLeaseHelper +import org.opensearch.replication.task.CrossClusterReplicationTask +import org.opensearch.replication.task.ReplicationState +import org.opensearch.replication.util.indicesService +import org.opensearch.replication.util.suspending import kotlinx.coroutines.ObsoleteCoroutinesApi import kotlinx.coroutines.cancel import kotlinx.coroutines.isActive import kotlinx.coroutines.sync.Semaphore -import org.elasticsearch.ElasticsearchTimeoutException -import org.elasticsearch.action.NoSuchNodeException -import org.elasticsearch.action.support.IndicesOptions -import org.elasticsearch.client.Client -import org.elasticsearch.cluster.ClusterChangedEvent -import org.elasticsearch.cluster.ClusterStateListener -import org.elasticsearch.cluster.node.DiscoveryNode -import org.elasticsearch.cluster.service.ClusterService -import org.elasticsearch.common.logging.Loggers -import org.elasticsearch.index.seqno.RetentionLeaseActions -import org.elasticsearch.index.shard.ShardId -import org.elasticsearch.index.shard.ShardNotFoundException -import org.elasticsearch.persistent.PersistentTaskState -import org.elasticsearch.persistent.PersistentTasksNodeService -import org.elasticsearch.tasks.TaskId -import org.elasticsearch.threadpool.ThreadPool +import org.opensearch.OpenSearchTimeoutException +import org.opensearch.action.NoSuchNodeException +import org.opensearch.action.support.IndicesOptions +import org.opensearch.client.Client +import org.opensearch.cluster.ClusterChangedEvent +import org.opensearch.cluster.ClusterStateListener +import org.opensearch.cluster.node.DiscoveryNode +import org.opensearch.cluster.service.ClusterService +import org.opensearch.common.logging.Loggers +import org.opensearch.index.seqno.RetentionLeaseActions +import org.opensearch.index.shard.ShardId +import org.opensearch.index.shard.ShardNotFoundException +import org.opensearch.persistent.PersistentTaskState +import org.opensearch.persistent.PersistentTasksNodeService +import org.opensearch.replication.util.suspendExecuteWithRetries +import org.opensearch.tasks.TaskId +import org.opensearch.threadpool.ThreadPool class ShardReplicationTask(id: Long, type: String, action: String, description: String, parentTask: TaskId, params: ShardReplicationParams, executor: String, clusterService: ClusterService, @@ -133,7 +133,7 @@ class ShardReplicationTask(id: Long, type: String, action: String, description: log.info("Got ${changesResponse.changes.size} changes starting from seqNo: $seqNo") sequencer.send(changesResponse) seqNo = changesResponse.changes.lastOrNull()?.seqNo()?.inc() ?: seqNo - } catch (e: ElasticsearchTimeoutException) { + } catch (e: OpenSearchTimeoutException) { log.info("Timed out waiting for new changes. Current seqNo: $seqNo") rateLimiter.release() continue diff --git a/src/main/kotlin/com/amazon/elasticsearch/replication/task/shard/TranslogSequencer.kt b/src/main/kotlin/org/opensearch/replication/task/shard/TranslogSequencer.kt similarity index 87% rename from src/main/kotlin/com/amazon/elasticsearch/replication/task/shard/TranslogSequencer.kt rename to src/main/kotlin/org/opensearch/replication/task/shard/TranslogSequencer.kt index fb52cb0f..c7f1c6f7 100644 --- a/src/main/kotlin/com/amazon/elasticsearch/replication/task/shard/TranslogSequencer.kt +++ b/src/main/kotlin/org/opensearch/replication/task/shard/TranslogSequencer.kt @@ -13,24 +13,24 @@ * permissions and limitations under the License. */ -package com.amazon.elasticsearch.replication.task.shard +package org.opensearch.replication.task.shard -import com.amazon.elasticsearch.replication.ReplicationException -import com.amazon.elasticsearch.replication.action.changes.GetChangesResponse -import com.amazon.elasticsearch.replication.action.replay.ReplayChangesAction -import com.amazon.elasticsearch.replication.action.replay.ReplayChangesRequest -import com.amazon.elasticsearch.replication.util.suspendExecute +import org.opensearch.replication.ReplicationException +import org.opensearch.replication.action.changes.GetChangesResponse +import org.opensearch.replication.action.replay.ReplayChangesAction +import org.opensearch.replication.action.replay.ReplayChangesRequest import kotlinx.coroutines.CompletableDeferred import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.ObsoleteCoroutinesApi import kotlinx.coroutines.channels.Channel import kotlinx.coroutines.channels.actor import kotlinx.coroutines.sync.Semaphore -import org.elasticsearch.client.Client -import org.elasticsearch.common.logging.Loggers -import org.elasticsearch.index.shard.ShardId -import org.elasticsearch.index.translog.Translog -import org.elasticsearch.tasks.TaskId +import org.opensearch.client.Client +import org.opensearch.common.logging.Loggers +import org.opensearch.index.shard.ShardId +import org.opensearch.index.translog.Translog +import org.opensearch.replication.util.suspendExecute +import org.opensearch.tasks.TaskId import java.util.concurrent.ConcurrentHashMap /** diff --git a/src/main/kotlin/com/amazon/elasticsearch/replication/util/Coroutines.kt b/src/main/kotlin/org/opensearch/replication/util/Coroutines.kt similarity index 82% rename from src/main/kotlin/com/amazon/elasticsearch/replication/util/Coroutines.kt rename to src/main/kotlin/org/opensearch/replication/util/Coroutines.kt index 1279ef05..461f08a5 100644 --- a/src/main/kotlin/com/amazon/elasticsearch/replication/util/Coroutines.kt +++ b/src/main/kotlin/org/opensearch/replication/util/Coroutines.kt @@ -13,30 +13,30 @@ * permissions and limitations under the License. */ -package com.amazon.elasticsearch.replication.util +package org.opensearch.replication.util import kotlinx.coroutines.* -import org.elasticsearch.ElasticsearchTimeoutException -import org.elasticsearch.ExceptionsHelper -import org.elasticsearch.action.ActionListener -import org.elasticsearch.action.ActionRequest -import org.elasticsearch.action.ActionResponse -import org.elasticsearch.action.ActionType -import org.elasticsearch.action.support.master.AcknowledgedRequest -import org.elasticsearch.action.support.master.MasterNodeRequest -import org.elasticsearch.client.Client -import org.elasticsearch.client.ElasticsearchClient -import org.elasticsearch.cluster.* -import org.elasticsearch.cluster.service.ClusterService -import org.elasticsearch.common.Priority -import org.elasticsearch.common.unit.TimeValue -import org.elasticsearch.common.util.concurrent.ThreadContext -import org.elasticsearch.index.shard.GlobalCheckpointListeners -import org.elasticsearch.index.shard.IndexShard -import org.elasticsearch.persistent.PersistentTaskParams -import org.elasticsearch.persistent.PersistentTasksCustomMetadata.PersistentTask -import org.elasticsearch.persistent.PersistentTasksService -import org.elasticsearch.threadpool.ThreadPool +import org.opensearch.OpenSearchTimeoutException +import org.opensearch.ExceptionsHelper +import org.opensearch.action.ActionListener +import org.opensearch.action.ActionRequest +import org.opensearch.action.ActionResponse +import org.opensearch.action.ActionType +import org.opensearch.action.support.master.AcknowledgedRequest +import org.opensearch.action.support.master.MasterNodeRequest +import org.opensearch.client.Client +import org.opensearch.client.OpenSearchClient +import org.opensearch.cluster.* +import org.opensearch.cluster.service.ClusterService +import org.opensearch.common.Priority +import org.opensearch.common.unit.TimeValue +import org.opensearch.common.util.concurrent.ThreadContext +import org.opensearch.index.shard.GlobalCheckpointListeners +import org.opensearch.index.shard.IndexShard +import org.opensearch.persistent.PersistentTaskParams +import org.opensearch.persistent.PersistentTasksCustomMetadata.PersistentTask +import org.opensearch.persistent.PersistentTasksService +import org.opensearch.threadpool.ThreadPool import java.util.concurrent.TimeoutException import kotlin.coroutines.* @@ -60,7 +60,7 @@ fun suspending(fn: (Req, ActionListener) -> Unit): suspend (Re } suspend fun - ElasticsearchClient.suspendExecute(action: ActionType, req: Req) : Resp { + OpenSearchClient.suspendExecute(action: ActionType, req: Req) : Resp { return suspendCancellableCoroutine { cont -> execute(action, req, CoroutineActionListener(cont)) } } @@ -73,7 +73,7 @@ suspend fun IndexShard.waitForGlobalCheckpoint(waitingForGlobalCheckpoint: Long, override fun accept(gcp: Long, e: Exception?) { when { - e is TimeoutException -> cont.resumeWithException(ElasticsearchTimeoutException(e.message)) + e is TimeoutException -> cont.resumeWithException(OpenSearchTimeoutException(e.message)) e != null -> cont.resumeWithException(e) else -> cont.resume(gcp) } @@ -96,7 +96,7 @@ suspend fun ClusterStateObserver.waitForNextChange(reason: String, predicate: (C } override fun onTimeout(timeout: TimeValue?) { - cont.resumeWithException(ElasticsearchTimeoutException("timed out waiting for $reason")) + cont.resumeWithException(OpenSearchTimeoutException("timed out waiting for $reason")) } }, predicate) } @@ -144,9 +144,9 @@ inline fun ActionListener.completeWith(block : () -> T) { } /** - * Stores and restores the Elasticsearch [ThreadContext] when the coroutine is suspended and resumed. + * Stores and restores the OpenSearch [ThreadContext] when the coroutine is suspended and resumed. * - * The implementation is a little confusing because Elasticsearch and Kotlin uses [ThreadContext.stashContext] to + * The implementation is a little confusing because OpenSearch and Kotlin uses [ThreadContext.stashContext] to * restore the default context. * * @param threadContext - a [ThreadContext] instance diff --git a/src/main/kotlin/com/amazon/elasticsearch/replication/util/Extensions.kt b/src/main/kotlin/org/opensearch/replication/util/Extensions.kt similarity index 79% rename from src/main/kotlin/com/amazon/elasticsearch/replication/util/Extensions.kt rename to src/main/kotlin/org/opensearch/replication/util/Extensions.kt index cd12fab3..fc45577b 100644 --- a/src/main/kotlin/com/amazon/elasticsearch/replication/util/Extensions.kt +++ b/src/main/kotlin/org/opensearch/replication/util/Extensions.kt @@ -13,19 +13,20 @@ * permissions and limitations under the License. */ -package com.amazon.elasticsearch.replication.util +package org.opensearch.replication.util import kotlinx.coroutines.delay import org.apache.logging.log4j.Logger -import org.elasticsearch.ElasticsearchException -import org.elasticsearch.action.ActionRequest -import org.elasticsearch.action.ActionResponse -import org.elasticsearch.action.ActionType -import org.elasticsearch.client.Client -import org.elasticsearch.cluster.service.ClusterService -import org.elasticsearch.index.store.Store -import org.elasticsearch.transport.ConnectTransportException -import org.elasticsearch.transport.NodeDisconnectedException +import org.opensearch.OpenSearchException +import org.opensearch.action.ActionRequest +import org.opensearch.action.ActionResponse +import org.opensearch.action.ActionType +import org.opensearch.client.Client +import org.opensearch.cluster.service.ClusterService +import org.opensearch.common.util.concurrent.ThreadContext +import org.opensearch.index.store.Store +import org.opensearch.transport.ConnectTransportException +import org.opensearch.transport.NodeDisconnectedException /* * Extension function to use the store object @@ -47,10 +48,14 @@ fun Client.executeUnderSecurityContext(clusterService: ClusterService, block: () -> T) { val userString = SecurityContext.fromClusterState(clusterService.state(), remoteClusterName, followerIndexName) - this.threadPool().threadContext.newStoredContext(true).use { + var storedContext: ThreadContext.StoredContext? = null + try { SecurityContext.toThreadContext(this.threadPool().threadContext, userString) block() } + finally { + storedContext?.restore() + } } @@ -63,7 +68,7 @@ fun Client.executeUnderSecurityContext(clusterService: ClusterService, * @param maxTimeOut - Time out for retries * @param factor - ExponentialBackoff factor * @param log - logger used to log intermediate failures - * @param retryOn - javaClass name of Elasticsearch exceptions that should be retried along with default retryable exceptions + * @param retryOn - javaClass name of OpenSearch exceptions that should be retried along with default retryable exceptions * @param block - the block of code to retry. This should be a suspend function. */ suspend fun Client.suspendExecuteWithRetries( @@ -80,7 +85,7 @@ suspend fun Client.suspendExecuteWith repeat(numberOfRetries - 1) { try { return suspendExecute(action, req) - } catch (e: ElasticsearchException) { + } catch (e: OpenSearchException) { if (retryOn.contains(e.javaClass)) { log.warn("Encountered a failure. Retrying in ${currentBackoff/1000} seconds.", e) delay(currentBackoff) diff --git a/src/main/kotlin/com/amazon/elasticsearch/replication/util/Injectables.kt b/src/main/kotlin/org/opensearch/replication/util/Injectables.kt similarity index 83% rename from src/main/kotlin/com/amazon/elasticsearch/replication/util/Injectables.kt rename to src/main/kotlin/org/opensearch/replication/util/Injectables.kt index 2dfd5c0b..0dc7243f 100644 --- a/src/main/kotlin/com/amazon/elasticsearch/replication/util/Injectables.kt +++ b/src/main/kotlin/org/opensearch/replication/util/Injectables.kt @@ -13,12 +13,12 @@ * permissions and limitations under the License. */ -package com.amazon.elasticsearch.replication.util +package org.opensearch.replication.util -import org.elasticsearch.common.component.AbstractLifecycleComponent -import org.elasticsearch.common.inject.Inject -import org.elasticsearch.indices.IndicesService -import org.elasticsearch.persistent.PersistentTasksService +import org.opensearch.common.component.AbstractLifecycleComponent +import org.opensearch.common.inject.Inject +import org.opensearch.indices.IndicesService +import org.opensearch.persistent.PersistentTasksService lateinit var indicesService: IndicesService lateinit var persistentTasksService: PersistentTasksService diff --git a/src/main/kotlin/com/amazon/elasticsearch/replication/util/SecurityContext.kt b/src/main/kotlin/org/opensearch/replication/util/SecurityContext.kt similarity index 92% rename from src/main/kotlin/com/amazon/elasticsearch/replication/util/SecurityContext.kt rename to src/main/kotlin/org/opensearch/replication/util/SecurityContext.kt index 3df6ae1e..e3cff5c0 100644 --- a/src/main/kotlin/com/amazon/elasticsearch/replication/util/SecurityContext.kt +++ b/src/main/kotlin/org/opensearch/replication/util/SecurityContext.kt @@ -13,12 +13,12 @@ * permissions and limitations under the License. */ -package com.amazon.elasticsearch.replication.util +package org.opensearch.replication.util -import com.amazon.elasticsearch.replication.metadata.ReplicationMetadata +import org.opensearch.replication.metadata.ReplicationMetadata import org.apache.logging.log4j.LogManager -import org.elasticsearch.cluster.ClusterState -import org.elasticsearch.common.util.concurrent.ThreadContext +import org.opensearch.cluster.ClusterState +import org.opensearch.common.util.concurrent.ThreadContext interface SecurityContext { companion object { diff --git a/src/test/kotlin/com/amazon/elasticsearch/replication/BasicReplicationIT.kt b/src/test/kotlin/org/opensearch/replication/BasicReplicationIT.kt similarity index 84% rename from src/test/kotlin/com/amazon/elasticsearch/replication/BasicReplicationIT.kt rename to src/test/kotlin/org/opensearch/replication/BasicReplicationIT.kt index 556113c1..5ac40519 100644 --- a/src/test/kotlin/com/amazon/elasticsearch/replication/BasicReplicationIT.kt +++ b/src/test/kotlin/org/opensearch/replication/BasicReplicationIT.kt @@ -13,19 +13,17 @@ * permissions and limitations under the License. */ -package com.amazon.elasticsearch.replication +package org.opensearch.replication -import com.amazon.elasticsearch.replication.MultiClusterAnnotations.ClusterConfiguration -import com.amazon.elasticsearch.replication.MultiClusterAnnotations.ClusterConfigurations import org.assertj.core.api.Assertions.assertThat -import org.elasticsearch.ElasticsearchStatusException -import org.elasticsearch.action.DocWriteResponse.Result -import org.elasticsearch.action.get.GetRequest -import org.elasticsearch.action.index.IndexRequest -import org.elasticsearch.client.RequestOptions -import org.elasticsearch.client.indices.CreateIndexRequest -import org.elasticsearch.test.ESTestCase.assertBusy -import org.junit.Assert +import org.opensearch.replication.MultiClusterAnnotations.ClusterConfiguration +import org.opensearch.replication.MultiClusterAnnotations.ClusterConfigurations +import org.opensearch.action.DocWriteResponse.Result +import org.opensearch.client.indices.CreateIndexRequest +import org.opensearch.action.get.GetRequest +import org.opensearch.action.index.IndexRequest +import org.opensearch.client.RequestOptions +import org.opensearch.test.OpenSearchTestCase.assertBusy import java.util.Locale const val LEADER = "leaderCluster" diff --git a/src/test/kotlin/com/amazon/elasticsearch/replication/MultiClusterAnnotations.kt b/src/test/kotlin/org/opensearch/replication/MultiClusterAnnotations.kt similarity index 98% rename from src/test/kotlin/com/amazon/elasticsearch/replication/MultiClusterAnnotations.kt rename to src/test/kotlin/org/opensearch/replication/MultiClusterAnnotations.kt index c592cb6e..905c8a8a 100644 --- a/src/test/kotlin/com/amazon/elasticsearch/replication/MultiClusterAnnotations.kt +++ b/src/test/kotlin/org/opensearch/replication/MultiClusterAnnotations.kt @@ -13,7 +13,7 @@ * permissions and limitations under the License. */ -package com.amazon.elasticsearch.replication +package org.opensearch.replication import java.util.ArrayList diff --git a/src/test/kotlin/com/amazon/elasticsearch/replication/MultiClusterRestTestCase.kt b/src/test/kotlin/org/opensearch/replication/MultiClusterRestTestCase.kt similarity index 83% rename from src/test/kotlin/com/amazon/elasticsearch/replication/MultiClusterRestTestCase.kt rename to src/test/kotlin/org/opensearch/replication/MultiClusterRestTestCase.kt index 93638c64..f231ac24 100644 --- a/src/test/kotlin/com/amazon/elasticsearch/replication/MultiClusterRestTestCase.kt +++ b/src/test/kotlin/org/opensearch/replication/MultiClusterRestTestCase.kt @@ -13,13 +13,11 @@ * permissions and limitations under the License. */ -package com.amazon.elasticsearch.replication +package org.opensearch.replication -import com.amazon.elasticsearch.replication.MultiClusterAnnotations.ClusterConfiguration -import com.amazon.elasticsearch.replication.MultiClusterAnnotations.ClusterConfigurations -import com.amazon.elasticsearch.replication.MultiClusterAnnotations.getAnnotationsFromClass -import com.amazon.elasticsearch.replication.task.index.IndexReplicationExecutor -import com.amazon.elasticsearch.replication.task.shard.ShardReplicationExecutor +import org.opensearch.replication.MultiClusterAnnotations.ClusterConfiguration +import org.opensearch.replication.MultiClusterAnnotations.ClusterConfigurations +import org.opensearch.replication.MultiClusterAnnotations.getAnnotationsFromClass import org.apache.http.Header import org.apache.http.HttpHost import org.apache.http.HttpStatus @@ -31,23 +29,22 @@ import org.apache.http.nio.conn.ssl.SSLIOSessionStrategy import org.apache.http.nio.entity.NStringEntity import org.apache.http.ssl.SSLContexts import org.apache.lucene.util.SetOnce -import org.elasticsearch.action.admin.cluster.node.tasks.list.ListTasksRequest -import org.elasticsearch.action.admin.cluster.node.tasks.list.ListTasksRequestBuilder -import org.elasticsearch.bootstrap.BootstrapInfo -import org.elasticsearch.client.* -import org.elasticsearch.common.Strings -import org.elasticsearch.common.io.PathUtils -import org.elasticsearch.common.settings.Settings -import org.elasticsearch.common.unit.TimeValue -import org.elasticsearch.common.util.concurrent.ThreadContext -import org.elasticsearch.common.xcontent.XContentHelper -import org.elasticsearch.common.xcontent.XContentType -import org.elasticsearch.common.xcontent.json.JsonXContent -import org.elasticsearch.snapshots.SnapshotState -import org.elasticsearch.tasks.TaskInfo -import org.elasticsearch.test.ESTestCase -import org.elasticsearch.test.ESTestCase.assertBusy -import org.elasticsearch.test.rest.ESRestTestCase +import org.opensearch.action.admin.cluster.node.tasks.list.ListTasksRequest +import org.opensearch.bootstrap.BootstrapInfo +import org.opensearch.client.* +import org.opensearch.common.Strings +import org.opensearch.common.io.PathUtils +import org.opensearch.common.settings.Settings +import org.opensearch.common.unit.TimeValue +import org.opensearch.common.util.concurrent.ThreadContext +import org.opensearch.common.xcontent.XContentHelper +import org.opensearch.common.xcontent.XContentType +import org.opensearch.common.xcontent.json.JsonXContent +import org.opensearch.snapshots.SnapshotState +import org.opensearch.tasks.TaskInfo +import org.opensearch.test.OpenSearchTestCase +import org.opensearch.test.OpenSearchTestCase.assertBusy +import org.opensearch.test.rest.OpenSearchRestTestCase import org.hamcrest.Matchers import org.junit.After import org.junit.AfterClass @@ -65,7 +62,7 @@ import java.util.concurrent.atomic.AtomicReference * This class provides basic support of managing life-cyle of * multiple clusters defined as part of ES build. */ -abstract class MultiClusterRestTestCase : ESTestCase() { +abstract class MultiClusterRestTestCase : OpenSearchTestCase() { class TestCluster(clusterName: String, val httpHosts: List, val transportPorts: List, val preserveSnapshots: Boolean, val preserveIndices: Boolean, @@ -126,26 +123,26 @@ abstract class MultiClusterRestTestCase : ESTestCase() { } protected fun getClusterSettings(clusterName: String): Settings { - /* The default implementation is to return default settings from [ESRestTestCase]. + /* The default implementation is to return default settings from [OpenSearchRestTestCase]. * This method can be overridden in base classes to allow different settings * for specific cluster. */ val builder = Settings.builder() if (System.getProperty("tests.rest.client_path_prefix") != null) { - builder.put(ESRestTestCase.CLIENT_PATH_PREFIX, System.getProperty("tests.rest.client_path_prefix")) + builder.put(OpenSearchRestTestCase.CLIENT_PATH_PREFIX, System.getProperty("tests.rest.client_path_prefix")) } return builder.build() } /* Copied this method from [ESRestCase] */ protected fun configureClient(builder: RestClientBuilder, settings: Settings) { - val keystorePath = settings[ESRestTestCase.TRUSTSTORE_PATH] + val keystorePath = settings[OpenSearchRestTestCase.TRUSTSTORE_PATH] if (keystorePath != null) { - val keystorePass = settings[ESRestTestCase.TRUSTSTORE_PASSWORD] - ?: throw IllegalStateException(ESRestTestCase.TRUSTSTORE_PATH - + " is provided but not " + ESRestTestCase.TRUSTSTORE_PASSWORD) + val keystorePass = settings[OpenSearchRestTestCase.TRUSTSTORE_PASSWORD] + ?: throw IllegalStateException(OpenSearchRestTestCase.TRUSTSTORE_PATH + + " is provided but not " + OpenSearchRestTestCase.TRUSTSTORE_PASSWORD) val path = PathUtils.get(keystorePath) check( - Files.exists(path)) { ESRestTestCase.TRUSTSTORE_PATH + " is set but points to a non-existing file" } + Files.exists(path)) { OpenSearchRestTestCase.TRUSTSTORE_PATH + " is set but points to a non-existing file" } try { val keyStoreType = if (keystorePath.endsWith(".p12")) "PKCS12" else "jks" val keyStore = KeyStore.getInstance(keyStoreType) @@ -172,15 +169,15 @@ abstract class MultiClusterRestTestCase : ESTestCase() { defaultHeaders[i++] = BasicHeader(key, value) } builder.setDefaultHeaders(defaultHeaders) - val socketTimeoutString = settings[ESRestTestCase.CLIENT_SOCKET_TIMEOUT] + val socketTimeoutString = settings[OpenSearchRestTestCase.CLIENT_SOCKET_TIMEOUT] val socketTimeout = TimeValue.parseTimeValue(socketTimeoutString ?: "60s", - ESRestTestCase.CLIENT_SOCKET_TIMEOUT) + OpenSearchRestTestCase.CLIENT_SOCKET_TIMEOUT) builder.setRequestConfigCallback { conf: RequestConfig.Builder -> conf.setSocketTimeout( Math.toIntExact(socketTimeout.millis)) } - if (settings.hasValue(ESRestTestCase.CLIENT_PATH_PREFIX)) { - builder.setPathPrefix(settings[ESRestTestCase.CLIENT_PATH_PREFIX]) + if (settings.hasValue(OpenSearchRestTestCase.CLIENT_PATH_PREFIX)) { + builder.setPathPrefix(settings[OpenSearchRestTestCase.CLIENT_PATH_PREFIX]) } } } @@ -216,7 +213,7 @@ abstract class MultiClusterRestTestCase : ESTestCase() { } protected fun wipeClusterSettings(testCluster: TestCluster) { - val getResponse: Map = ESRestTestCase.entityAsMap(testCluster.lowLevelClient.performRequest( + val getResponse: Map = OpenSearchRestTestCase.entityAsMap(testCluster.lowLevelClient.performRequest( Request("GET", "/_cluster/settings"))) var mustClear = false val clearCommand = JsonXContent.contentBuilder() @@ -260,7 +257,7 @@ abstract class MultiClusterRestTestCase : ESTestCase() { protected fun _wipeSnapshots(testCluster: TestCluster): Map>> { val inProgressSnapshots: MutableMap>> = mutableMapOf() - for ((repoName, value) in ESRestTestCase.entityAsMap( + for ((repoName, value) in OpenSearchRestTestCase.entityAsMap( testCluster.lowLevelClient.performRequest(Request("GET", "/_snapshot/_all")))) { val repoSpec = value as Map<*, *> val repoType = repoSpec["type"] as String @@ -268,7 +265,7 @@ abstract class MultiClusterRestTestCase : ESTestCase() { // All other repo types we really don't have a chance of being able to iterate properly, sadly. val listRequest = Request("GET", "/_snapshot/$repoName/_all") listRequest.addParameter("ignore_unavailable", "true") - val snapshots = ESRestTestCase.entityAsMap( + val snapshots = OpenSearchRestTestCase.entityAsMap( testCluster.lowLevelClient.performRequest(listRequest))["snapshots"] as List> for (snapshot in snapshots) { val snapshotInfo = snapshot @@ -302,7 +299,7 @@ abstract class MultiClusterRestTestCase : ESTestCase() { } fun getAsMap(client: RestClient, endpoint: String): Map { - return ESRestTestCase.entityAsMap(client.performRequest(Request("GET", endpoint))) + return OpenSearchRestTestCase.entityAsMap(client.performRequest(Request("GET", endpoint))) } protected fun createConnectionBetweenClusters(fromClusterName: String, toClusterName: String, connectionName: String="source") { diff --git a/src/test/kotlin/com/amazon/elasticsearch/replication/MultiClusterSetupIT.kt b/src/test/kotlin/org/opensearch/replication/MultiClusterSetupIT.kt similarity index 92% rename from src/test/kotlin/com/amazon/elasticsearch/replication/MultiClusterSetupIT.kt rename to src/test/kotlin/org/opensearch/replication/MultiClusterSetupIT.kt index db89ec55..db97a381 100644 --- a/src/test/kotlin/com/amazon/elasticsearch/replication/MultiClusterSetupIT.kt +++ b/src/test/kotlin/org/opensearch/replication/MultiClusterSetupIT.kt @@ -13,11 +13,11 @@ * permissions and limitations under the License. */ -package com.amazon.elasticsearch.replication +package org.opensearch.replication -import com.amazon.elasticsearch.replication.MultiClusterAnnotations.ClusterConfiguration +import org.opensearch.replication.MultiClusterAnnotations.ClusterConfiguration import org.apache.http.util.EntityUtils -import org.elasticsearch.client.Request +import org.opensearch.client.Request @MultiClusterAnnotations.ClusterConfigurations( ClusterConfiguration(clusterName = "leaderCluster"), @@ -48,7 +48,7 @@ class MultiClusterSetupIT : MultiClusterRestTestCase() { } private fun isReplicationPluginInstalledOnNode(nodePlugins: List>?): Boolean { - for (plugin in nodePlugins!!) if (plugin["name"] == "opendistro-cross-cluster-replication") return true + for (plugin in nodePlugins!!) if (plugin["name"] == "opensearch-cross-cluster-replication") return true return false } diff --git a/src/test/kotlin/com/amazon/elasticsearch/replication/ReplicationHelpers.kt b/src/test/kotlin/org/opensearch/replication/ReplicationHelpers.kt similarity index 87% rename from src/test/kotlin/com/amazon/elasticsearch/replication/ReplicationHelpers.kt rename to src/test/kotlin/org/opensearch/replication/ReplicationHelpers.kt index 773291c6..6bd30c30 100644 --- a/src/test/kotlin/com/amazon/elasticsearch/replication/ReplicationHelpers.kt +++ b/src/test/kotlin/org/opensearch/replication/ReplicationHelpers.kt @@ -13,23 +13,23 @@ * permissions and limitations under the License. */ -package com.amazon.elasticsearch.replication +package org.opensearch.replication -import com.amazon.elasticsearch.replication.task.index.IndexReplicationExecutor -import com.amazon.elasticsearch.replication.task.shard.ShardReplicationExecutor import org.assertj.core.api.Assertions.assertThat -import org.elasticsearch.action.admin.cluster.health.ClusterHealthRequest -import org.elasticsearch.action.admin.cluster.node.tasks.list.ListTasksRequest -import org.elasticsearch.action.support.master.AcknowledgedResponse -import org.elasticsearch.client.Request -import org.elasticsearch.client.RequestOptions -import org.elasticsearch.client.Response -import org.elasticsearch.client.RestHighLevelClient -import org.elasticsearch.common.unit.TimeValue -import org.elasticsearch.common.xcontent.DeprecationHandler -import org.elasticsearch.common.xcontent.NamedXContentRegistry -import org.elasticsearch.common.xcontent.XContentType -import org.elasticsearch.test.ESTestCase.assertBusy +import org.opensearch.action.admin.cluster.health.ClusterHealthRequest +import org.opensearch.action.admin.cluster.node.tasks.list.ListTasksRequest +import org.opensearch.action.support.master.AcknowledgedResponse +import org.opensearch.client.Request +import org.opensearch.client.RequestOptions +import org.opensearch.client.Response +import org.opensearch.client.RestHighLevelClient +import org.opensearch.common.unit.TimeValue +import org.opensearch.common.xcontent.DeprecationHandler +import org.opensearch.common.xcontent.NamedXContentRegistry +import org.opensearch.common.xcontent.XContentType +import org.opensearch.replication.task.index.IndexReplicationExecutor +import org.opensearch.replication.task.shard.ShardReplicationExecutor +import org.opensearch.test.OpenSearchTestCase.assertBusy import java.util.concurrent.TimeUnit data class StartReplicationRequest(val remoteClusterAlias: String, val remoteIndex: String, val toIndex: String) diff --git a/src/test/kotlin/com/amazon/elasticsearch/replication/ReplicationIntegTestCaseIT.kt b/src/test/kotlin/org/opensearch/replication/ReplicationIntegTestCaseIT.kt similarity index 80% rename from src/test/kotlin/com/amazon/elasticsearch/replication/ReplicationIntegTestCaseIT.kt rename to src/test/kotlin/org/opensearch/replication/ReplicationIntegTestCaseIT.kt index e21e470d..a66991cd 100644 --- a/src/test/kotlin/com/amazon/elasticsearch/replication/ReplicationIntegTestCaseIT.kt +++ b/src/test/kotlin/org/opensearch/replication/ReplicationIntegTestCaseIT.kt @@ -13,11 +13,11 @@ * permissions and limitations under the License. */ -package com.amazon.elasticsearch.replication +package org.opensearch.replication -import org.elasticsearch.test.ESIntegTestCase +import org.opensearch.test.OpenSearchIntegTestCase -class ReplicationIntegTestCaseIT : ESIntegTestCase() { +class ReplicationIntegTestCaseIT : OpenSearchIntegTestCase() { } diff --git a/src/test/kotlin/com/amazon/elasticsearch/replication/ReplicationPluginTests.kt b/src/test/kotlin/org/opensearch/replication/ReplicationPluginTests.kt similarity index 83% rename from src/test/kotlin/com/amazon/elasticsearch/replication/ReplicationPluginTests.kt rename to src/test/kotlin/org/opensearch/replication/ReplicationPluginTests.kt index 0e6117a2..a7a179ed 100644 --- a/src/test/kotlin/com/amazon/elasticsearch/replication/ReplicationPluginTests.kt +++ b/src/test/kotlin/org/opensearch/replication/ReplicationPluginTests.kt @@ -13,11 +13,11 @@ * permissions and limitations under the License. */ -package com.amazon.elasticsearch.replication +package org.opensearch.replication -import org.elasticsearch.test.ESTestCase +import org.opensearch.test.OpenSearchTestCase -class ReplicationPluginTests : ESTestCase() { +class ReplicationPluginTests : OpenSearchTestCase() { fun testNothing() { assertTrue("Write some tests!", true) } diff --git a/src/test/kotlin/com/amazon/elasticsearch/replication/integ/rest/StartReplicationIT.kt b/src/test/kotlin/org/opensearch/replication/integ/rest/StartReplicationIT.kt similarity index 91% rename from src/test/kotlin/com/amazon/elasticsearch/replication/integ/rest/StartReplicationIT.kt rename to src/test/kotlin/org/opensearch/replication/integ/rest/StartReplicationIT.kt index 8f6a6d95..6fe6ea7e 100644 --- a/src/test/kotlin/com/amazon/elasticsearch/replication/integ/rest/StartReplicationIT.kt +++ b/src/test/kotlin/org/opensearch/replication/integ/rest/StartReplicationIT.kt @@ -13,31 +13,31 @@ * permissions and limitations under the License. */ -package com.amazon.elasticsearch.replication.integ.rest +package org.opensearch.replication.integ.rest -import com.amazon.elasticsearch.replication.MultiClusterAnnotations -import com.amazon.elasticsearch.replication.MultiClusterRestTestCase -import com.amazon.elasticsearch.replication.StartReplicationRequest -import com.amazon.elasticsearch.replication.startReplication +import org.opensearch.replication.MultiClusterAnnotations +import org.opensearch.replication.MultiClusterRestTestCase +import org.opensearch.replication.StartReplicationRequest import org.apache.http.HttpStatus import org.apache.http.entity.ContentType import org.apache.http.nio.entity.NStringEntity import org.assertj.core.api.Assertions.assertThat import org.assertj.core.api.Assertions.assertThatThrownBy -import org.elasticsearch.action.admin.indices.alias.Alias -import org.elasticsearch.action.admin.indices.alias.get.GetAliasesRequest -import org.elasticsearch.action.admin.indices.settings.get.GetSettingsRequest -import org.elasticsearch.client.Request -import org.elasticsearch.client.RequestOptions -import org.elasticsearch.client.ResponseException -import org.elasticsearch.client.indices.CreateIndexRequest -import org.elasticsearch.client.indices.GetIndexRequest -import org.elasticsearch.client.indices.GetMappingsRequest -import org.elasticsearch.cluster.metadata.IndexMetadata -import org.elasticsearch.common.settings.Settings -import org.elasticsearch.test.ESTestCase.assertBusy +import org.opensearch.action.admin.indices.alias.Alias +import org.opensearch.action.admin.indices.alias.get.GetAliasesRequest +import org.opensearch.action.admin.indices.settings.get.GetSettingsRequest +import org.opensearch.client.Request +import org.opensearch.client.RequestOptions +import org.opensearch.client.ResponseException +import org.opensearch.client.indices.CreateIndexRequest +import org.opensearch.client.indices.GetIndexRequest +import org.opensearch.client.indices.GetMappingsRequest +import org.opensearch.cluster.metadata.IndexMetadata +import org.opensearch.common.settings.Settings +import org.opensearch.test.OpenSearchTestCase.assertBusy import org.junit.Assert +import org.opensearch.replication.startReplication @MultiClusterAnnotations.ClusterConfigurations( diff --git a/src/test/kotlin/com/amazon/elasticsearch/replication/integ/rest/StopReplicationIT.kt b/src/test/kotlin/org/opensearch/replication/integ/rest/StopReplicationIT.kt similarity index 87% rename from src/test/kotlin/com/amazon/elasticsearch/replication/integ/rest/StopReplicationIT.kt rename to src/test/kotlin/org/opensearch/replication/integ/rest/StopReplicationIT.kt index 5943f73f..8a9190e3 100644 --- a/src/test/kotlin/com/amazon/elasticsearch/replication/integ/rest/StopReplicationIT.kt +++ b/src/test/kotlin/org/opensearch/replication/integ/rest/StopReplicationIT.kt @@ -13,32 +13,32 @@ * permissions and limitations under the License. */ -package com.amazon.elasticsearch.replication.integ.rest +package org.opensearch.replication.integ.rest -import com.amazon.elasticsearch.replication.MultiClusterAnnotations -import com.amazon.elasticsearch.replication.MultiClusterRestTestCase -import com.amazon.elasticsearch.replication.StartReplicationRequest -import com.amazon.elasticsearch.replication.startReplication -import com.amazon.elasticsearch.replication.stopReplication +import org.opensearch.replication.MultiClusterAnnotations +import org.opensearch.replication.MultiClusterRestTestCase +import org.opensearch.replication.StartReplicationRequest import org.apache.http.util.EntityUtils import org.assertj.core.api.Assertions.assertThat import org.assertj.core.api.Assertions.assertThatThrownBy -import org.elasticsearch.ElasticsearchStatusException -import org.elasticsearch.action.DocWriteResponse -import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest -import org.elasticsearch.action.admin.indices.flush.FlushRequest -import org.elasticsearch.action.index.IndexRequest -import org.elasticsearch.client.Request -import org.elasticsearch.client.RequestOptions -import org.elasticsearch.client.ResponseException -import org.elasticsearch.client.RestHighLevelClient -import org.elasticsearch.client.indices.CreateIndexRequest -import org.elasticsearch.client.indices.GetIndexRequest -import org.elasticsearch.cluster.metadata.IndexMetadata -import org.elasticsearch.common.settings.Settings -import org.elasticsearch.common.unit.TimeValue -import org.elasticsearch.index.mapper.MapperService -import org.elasticsearch.test.ESTestCase.assertBusy +import org.opensearch.OpenSearchStatusException +import org.opensearch.action.DocWriteResponse +import org.opensearch.action.admin.indices.delete.DeleteIndexRequest +import org.opensearch.action.admin.indices.flush.FlushRequest +import org.opensearch.action.index.IndexRequest +import org.opensearch.client.Request +import org.opensearch.client.RequestOptions +import org.opensearch.client.ResponseException +import org.opensearch.client.RestHighLevelClient +import org.opensearch.client.indices.CreateIndexRequest +import org.opensearch.client.indices.GetIndexRequest +import org.opensearch.cluster.metadata.IndexMetadata +import org.opensearch.common.settings.Settings +import org.opensearch.common.unit.TimeValue +import org.opensearch.index.mapper.MapperService +import org.opensearch.replication.startReplication +import org.opensearch.replication.stopReplication +import org.opensearch.test.OpenSearchTestCase.assertBusy import java.util.concurrent.TimeUnit @@ -177,8 +177,8 @@ class StopReplicationIT: MultiClusterRestTestCase() { assertThatThrownBy { followerClient.index(IndexRequest(followerIndexName).id("blocked").source(sourceMap), RequestOptions .DEFAULT) - }.isInstanceOf(ElasticsearchStatusException::class.java) - .hasMessage("Elasticsearch exception [type=cluster_block_exception, reason=index [$followerIndexName] " + + }.isInstanceOf(OpenSearchStatusException::class.java) + .hasMessage("OpenSearch exception [type=cluster_block_exception, reason=index [$followerIndexName] " + "blocked by: [FORBIDDEN/1000/index read-only(cross-cluster-replication)];]") //Stop replication and verify that index is not blocked any more @@ -190,9 +190,9 @@ class StopReplicationIT: MultiClusterRestTestCase() { fun `test stop without replication in progress`() { val followerClient = getClientForCluster(FOLLOWER) assertThatThrownBy { - followerClient.stopReplication(followerIndexName) + followerClient.stopReplication("test-no-replication") }.isInstanceOf(ResponseException::class.java) - .hasMessageContaining("No replication in progress for index:follower_index") + .hasMessageContaining("No replication in progress for index:test-no-replication") } fun `test stop with deleted follower index`() { diff --git a/src/test/kotlin/com/amazon/elasticsearch/replication/integ/rest/UpdateAutoFollowPatternIT.kt b/src/test/kotlin/org/opensearch/replication/integ/rest/UpdateAutoFollowPatternIT.kt similarity index 88% rename from src/test/kotlin/com/amazon/elasticsearch/replication/integ/rest/UpdateAutoFollowPatternIT.kt rename to src/test/kotlin/org/opensearch/replication/integ/rest/UpdateAutoFollowPatternIT.kt index 89a06289..426812e0 100644 --- a/src/test/kotlin/com/amazon/elasticsearch/replication/integ/rest/UpdateAutoFollowPatternIT.kt +++ b/src/test/kotlin/org/opensearch/replication/integ/rest/UpdateAutoFollowPatternIT.kt @@ -13,29 +13,29 @@ * permissions and limitations under the License. */ -package com.amazon.elasticsearch.replication.integ.rest - -import com.amazon.elasticsearch.replication.MultiClusterAnnotations -import com.amazon.elasticsearch.replication.MultiClusterRestTestCase -import com.amazon.elasticsearch.replication.StartReplicationRequest -import com.amazon.elasticsearch.replication.deleteAutoFollowPattern -import com.amazon.elasticsearch.replication.startReplication -import com.amazon.elasticsearch.replication.stopReplication -import com.amazon.elasticsearch.replication.task.autofollow.AutoFollowExecutor -import com.amazon.elasticsearch.replication.task.index.IndexReplicationExecutor -import com.amazon.elasticsearch.replication.updateAutoFollowPattern +package org.opensearch.replication.integ.rest + +import org.opensearch.replication.MultiClusterAnnotations +import org.opensearch.replication.MultiClusterRestTestCase +import org.opensearch.replication.StartReplicationRequest +import org.opensearch.replication.task.autofollow.AutoFollowExecutor +import org.opensearch.replication.task.index.IndexReplicationExecutor import org.apache.http.HttpStatus import org.apache.http.entity.ContentType import org.apache.http.nio.entity.NStringEntity import org.assertj.core.api.Assertions -import org.elasticsearch.client.Request -import org.elasticsearch.client.RequestOptions -import org.elasticsearch.client.ResponseException -import org.elasticsearch.client.RestHighLevelClient -import org.elasticsearch.client.indices.CreateIndexRequest -import org.elasticsearch.client.indices.GetIndexRequest -import org.elasticsearch.common.unit.TimeValue -import org.elasticsearch.tasks.TaskInfo +import org.opensearch.client.Request +import org.opensearch.client.RequestOptions +import org.opensearch.client.ResponseException +import org.opensearch.client.RestHighLevelClient +import org.opensearch.client.indices.CreateIndexRequest +import org.opensearch.client.indices.GetIndexRequest +import org.opensearch.common.unit.TimeValue +import org.opensearch.replication.deleteAutoFollowPattern +import org.opensearch.replication.startReplication +import org.opensearch.replication.stopReplication +import org.opensearch.replication.updateAutoFollowPattern +import org.opensearch.tasks.TaskInfo import java.util.Locale import java.util.concurrent.TimeUnit diff --git a/src/test/kotlin/com/amazon/elasticsearch/replication/metadata/ReplicationMetadataTests.kt b/src/test/kotlin/org/opensearch/replication/metadata/ReplicationMetadataTests.kt similarity index 94% rename from src/test/kotlin/com/amazon/elasticsearch/replication/metadata/ReplicationMetadataTests.kt rename to src/test/kotlin/org/opensearch/replication/metadata/ReplicationMetadataTests.kt index 43824846..6045e873 100644 --- a/src/test/kotlin/com/amazon/elasticsearch/replication/metadata/ReplicationMetadataTests.kt +++ b/src/test/kotlin/org/opensearch/replication/metadata/ReplicationMetadataTests.kt @@ -13,14 +13,14 @@ * permissions and limitations under the License. */ -package com.amazon.elasticsearch.replication.metadata +package org.opensearch.replication.metadata import org.assertj.core.api.Assertions.assertThat -import org.elasticsearch.common.io.stream.BytesStreamOutput -import org.elasticsearch.test.ESTestCase -import org.elasticsearch.test.XContentTestUtils +import org.opensearch.common.io.stream.BytesStreamOutput +import org.opensearch.test.OpenSearchTestCase +import org.opensearch.test.XContentTestUtils -class ReplicationMetadataTests : ESTestCase() { +class ReplicationMetadataTests : OpenSearchTestCase() { companion object { val TEST_PATTERN = AutoFollowPattern("2020 logs", "logs-2020*") diff --git a/src/test/kotlin/com/amazon/elasticsearch/replication/task/shard/TranslogSequencerTests.kt b/src/test/kotlin/org/opensearch/replication/task/shard/TranslogSequencerTests.kt similarity index 79% rename from src/test/kotlin/com/amazon/elasticsearch/replication/task/shard/TranslogSequencerTests.kt rename to src/test/kotlin/org/opensearch/replication/task/shard/TranslogSequencerTests.kt index fb129db5..0c87d8c5 100644 --- a/src/test/kotlin/com/amazon/elasticsearch/replication/task/shard/TranslogSequencerTests.kt +++ b/src/test/kotlin/org/opensearch/replication/task/shard/TranslogSequencerTests.kt @@ -13,32 +13,32 @@ * permissions and limitations under the License. */ -package com.amazon.elasticsearch.replication.task.shard +package org.opensearch.replication.task.shard -import com.amazon.elasticsearch.replication.action.changes.GetChangesResponse -import com.amazon.elasticsearch.replication.action.replay.ReplayChangesAction -import com.amazon.elasticsearch.replication.action.replay.ReplayChangesRequest -import com.amazon.elasticsearch.replication.action.replay.ReplayChangesResponse +import org.opensearch.replication.action.changes.GetChangesResponse +import org.opensearch.replication.action.replay.ReplayChangesAction +import org.opensearch.replication.action.replay.ReplayChangesRequest +import org.opensearch.replication.action.replay.ReplayChangesResponse import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.ObsoleteCoroutinesApi import kotlinx.coroutines.sync.Semaphore import kotlinx.coroutines.test.runBlockingTest import org.assertj.core.api.Assertions.assertThat -import org.elasticsearch.action.ActionListener -import org.elasticsearch.action.ActionRequest -import org.elasticsearch.action.ActionResponse -import org.elasticsearch.action.ActionType -import org.elasticsearch.action.support.replication.ReplicationResponse.ShardInfo -import org.elasticsearch.index.shard.ShardId -import org.elasticsearch.index.translog.Translog -import org.elasticsearch.tasks.TaskId.EMPTY_TASK_ID -import org.elasticsearch.test.ESTestCase -import org.elasticsearch.test.ESTestCase.randomList -import org.elasticsearch.test.client.NoOpClient +import org.opensearch.action.ActionListener +import org.opensearch.action.ActionRequest +import org.opensearch.action.ActionResponse +import org.opensearch.action.ActionType +import org.opensearch.action.support.replication.ReplicationResponse.ShardInfo +import org.opensearch.index.shard.ShardId +import org.opensearch.index.translog.Translog +import org.opensearch.tasks.TaskId.EMPTY_TASK_ID +import org.opensearch.test.OpenSearchTestCase +import org.opensearch.test.OpenSearchTestCase.randomList +import org.opensearch.test.client.NoOpClient import java.util.Locale @ObsoleteCoroutinesApi -class TranslogSequencerTests : ESTestCase() { +class TranslogSequencerTests : OpenSearchTestCase() { class RequestCapturingClient : NoOpClient(TranslogSequencerTests::class.java.simpleName) { val requestsReceived = mutableListOf()