-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Poojita Raj <[email protected]>
- Loading branch information
1 parent
a0a8a18
commit 137177c
Showing
11 changed files
with
248 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
...r/src/main/java/org/opensearch/indices/replication/SegmentReplicationUpgradeListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
|
||
package org.opensearch.indices.replication; | ||
|
||
import org.apache.logging.log4j.LogManager; | ||
import org.apache.logging.log4j.Logger; | ||
import org.apache.lucene.store.AlreadyClosedException; | ||
import org.opensearch.cluster.ClusterChangedEvent; | ||
import org.opensearch.cluster.ClusterStateListener; | ||
import org.opensearch.cluster.node.DiscoveryNodes; | ||
import org.opensearch.index.IndexService; | ||
import org.opensearch.index.shard.IndexShard; | ||
import org.opensearch.indices.IndicesService; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class SegmentReplicationUpgradeListener implements ClusterStateListener { | ||
|
||
private static final Logger logger = LogManager.getLogger(SegmentReplicationUpgradeListener.class); | ||
|
||
private final IndicesService indicesService; | ||
|
||
public SegmentReplicationUpgradeListener(IndicesService indicesService) { | ||
this.indicesService = indicesService; | ||
} | ||
|
||
@Override | ||
public void clusterChanged(ClusterChangedEvent event) { | ||
List<IndexShard> indexShardList = new ArrayList<>(); | ||
DiscoveryNodes nodes = event.state().nodes(); | ||
if (nodes.getMinNodeVersion().equals(nodes.getMaxNodeVersion())) { | ||
for (IndexService indexService : indicesService.indices().values()) { | ||
for (IndexShard indexShard : indexService) { | ||
try { | ||
if ((indexShard.getEngine().config().isReadOnlyReplica() == false) && (indexShard.getEngine().config().getClusterMinVersion() != nodes.getMaxNodeVersion())) { | ||
indexShardList.add(indexShard); | ||
} | ||
} catch (AlreadyClosedException e) { | ||
logger.warn("Index shard [{}] engine is already closed.", indexShard.shardId()); | ||
} | ||
} | ||
} | ||
} | ||
try { | ||
if (indexShardList.isEmpty() == false) { | ||
for (IndexShard is : indexShardList) { | ||
is.resetEngineToGlobalCheckpoint(); | ||
} | ||
} | ||
} catch (Exception e) { | ||
logger.error("Received unexpected exception: [{}]", e.getMessage()); | ||
} | ||
|
||
} | ||
|
||
} |
31 changes: 31 additions & 0 deletions
31
...er/src/main/java/org/opensearch/indices/replication/SegmentReplicationUpgradeService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
|
||
package org.opensearch.indices.replication; | ||
|
||
import org.opensearch.cluster.service.ClusterApplierService; | ||
import org.opensearch.common.lease.Releasable; | ||
import org.opensearch.indices.IndicesService; | ||
|
||
public class SegmentReplicationUpgradeService implements Releasable { | ||
|
||
private final ClusterApplierService clusterApplierService; | ||
private final SegmentReplicationUpgradeListener clusterStateListener; | ||
|
||
public SegmentReplicationUpgradeService(IndicesService indicesService, ClusterApplierService clusterApplierService) { | ||
SegmentReplicationUpgradeListener clusterStateListener = new SegmentReplicationUpgradeListener(indicesService); | ||
this.clusterApplierService = clusterApplierService; | ||
this.clusterStateListener = clusterStateListener; | ||
this.clusterApplierService.addListener(this.clusterStateListener); | ||
} | ||
|
||
@Override | ||
public void close() { | ||
this.clusterApplierService.removeListener(this.clusterStateListener); | ||
} | ||
} |
Oops, something went wrong.