Skip to content

Commit

Permalink
Handling exception in getAssignment method
Browse files Browse the repository at this point in the history
Handling exception in getAssignment method

Signed-off-by: Nishant Goel <[email protected]>

Signed-off-by: Nishant Goel <[email protected]>
  • Loading branch information
nisgoel-amazon authored May 23, 2023
1 parent 3e3787d commit 7bf4de9
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,14 @@ class ShardReplicationExecutor(executor: String, private val clusterService : Cl
}

override fun getAssignment(params: ShardReplicationParams, clusterState: ClusterState) : Assignment {
val primaryShard = clusterState.routingTable().shardRoutingTable(params.followerShardId).primaryShard()
if (!primaryShard.active()) return SHARD_NOT_ACTIVE
return Assignment(primaryShard.currentNodeId(), "node with primary shard")
try {
val primaryShard = clusterState.routingTable().shardRoutingTable(params.followerShardId).primaryShard()
if (!primaryShard.active()) return SHARD_NOT_ACTIVE
return Assignment(primaryShard.currentNodeId(), "node with primary shard")
} catch (e: Exception) {
log.error("Failed to assign shard replication task with id ${params.followerShardId}", e)
return SHARD_NOT_ACTIVE
}
}

override fun nodeOperation(task: AllocatedPersistentTask, params: ShardReplicationParams, state: PersistentTaskState?) {
Expand Down

0 comments on commit 7bf4de9

Please sign in to comment.