@@ -259,7 +259,7 @@ public ShardAllocationDecision explainShardAllocation(final ShardRouting shard,
259259 } else {
260260 moveDecision = balancer .decideMove (index , shard );
261261 if (moveDecision .isDecisionTaken () && moveDecision .canRemain ()) {
262- moveDecision = balancer .decideRebalance (index , shard , moveDecision .getCanRemainDecision ());
262+ moveDecision = balancer .explainRebalanceDecision (index , shard , moveDecision .getCanRemainDecision ());
263263 }
264264 }
265265 return new ShardAllocationDecision (allocateUnassignedDecision , moveDecision );
@@ -465,7 +465,7 @@ private boolean balance() {
465465 * optimally balanced cluster. This method is invoked from the cluster allocation
466466 * explain API only.
467467 */
468- private MoveDecision decideRebalance (final ProjectIndex index , final ShardRouting shard , Decision canRemain ) {
468+ private MoveDecision explainRebalanceDecision (final ProjectIndex index , final ShardRouting shard , Decision canRemain ) {
469469 final NodeSorter sorter = nodeSorters .sorterForShard (shard );
470470 index .assertMatch (shard );
471471 if (shard .started () == false ) {
@@ -852,7 +852,7 @@ public boolean moveShards() {
852852 }
853853 shardMoved = true ;
854854 }
855- } else if (moveDecision .isDecisionTaken () && moveDecision .canRemain () == false ) {
855+ } else if (moveDecision .isDecisionTaken () && moveDecision .cannotRemain () ) {
856856 logger .trace ("[{}][{}] can't move" , shardRouting .index (), shardRouting .id ());
857857 }
858858 }
@@ -945,13 +945,13 @@ private MoveDecision decideMove(ProjectIndex index, ShardRouting shardRouting, P
945945 final ModelNode sourceNode = nodes .get (shardRouting .currentNodeId ());
946946 assert sourceNode != null && sourceNode .containsShard (index , shardRouting );
947947 RoutingNode routingNode = sourceNode .getRoutingNode ();
948- Decision canRemain = allocation .deciders ().canRemain (shardRouting , routingNode , allocation );
949- if (canRemain .type () != Decision .Type .NO && canRemain .type () != Decision .Type .NOT_PREFERRED ) {
950- return MoveDecision .createRemainYesDecision (canRemain );
948+ Decision canRemainDecision = allocation .deciders ().canRemain (shardRouting , routingNode , allocation );
949+ if (canRemainDecision .type () != Decision .Type .NO && canRemainDecision .type () != Decision .Type .NOT_PREFERRED ) {
950+ return MoveDecision .createRemainYesDecision (canRemainDecision );
951951 }
952952
953953 // Check predicate to decide whether to assess movement options
954- if (canRemain .type () == Type .NOT_PREFERRED && nonPreferredPredicate .test (shardRouting ) == false ) {
954+ if (canRemainDecision .type () == Type .NOT_PREFERRED && nonPreferredPredicate .test (shardRouting ) == false ) {
955955 return MoveDecision .NOT_TAKEN ;
956956 }
957957
@@ -962,11 +962,11 @@ private MoveDecision decideMove(ProjectIndex index, ShardRouting shardRouting, P
962962 * This is not guaranteed to be balanced after this operation we still try best effort to
963963 * allocate on the minimal eligible node.
964964 */
965- final MoveDecision moveDecision = decideMove (sorter , shardRouting , sourceNode , canRemain , this ::decideCanAllocate );
965+ final MoveDecision moveDecision = decideMove (sorter , shardRouting , sourceNode , canRemainDecision , this ::decideCanAllocate );
966966 if (moveDecision .cannotRemainAndCannotMove ()) {
967967 final boolean shardsOnReplacedNode = allocation .metadata ().nodeShutdowns ().contains (shardRouting .currentNodeId (), REPLACE );
968968 if (shardsOnReplacedNode ) {
969- return decideMove (sorter , shardRouting , sourceNode , canRemain , this ::decideCanForceAllocateForVacate );
969+ return decideMove (sorter , shardRouting , sourceNode , canRemainDecision , this ::decideCanForceAllocateForVacate );
970970 }
971971 }
972972 return moveDecision ;
0 commit comments