@@ -34,8 +34,8 @@ public Decision canAllocate(ShardRouting shardRouting, RoutingNode node, Routing
34
34
if (replacementOngoing (allocation ) == false ) {
35
35
return YES__NO_REPLACEMENTS ;
36
36
} else if (replacementFromSourceToTarget (allocation , shardRouting .currentNodeId (), node .node ().getName ())) {
37
- return Decision . single (
38
- Decision .Type . YES ,
37
+ return allocation . decision (
38
+ Decision .YES ,
39
39
NAME ,
40
40
"node [%s] is replacing node [%s], and may receive shards from it" ,
41
41
shardRouting .currentNodeId (),
@@ -48,16 +48,16 @@ public Decision canAllocate(ShardRouting shardRouting, RoutingNode node, Routing
48
48
return YES__RECONCILING ;
49
49
}
50
50
51
- return Decision . single (
52
- Decision .Type . NO ,
51
+ return allocation . decision (
52
+ Decision .NO ,
53
53
NAME ,
54
54
"node [%s] is being replaced, and its shards may only be allocated to the replacement target [%s]" ,
55
55
shardRouting .currentNodeId (),
56
56
getReplacementName (allocation , shardRouting .currentNodeId ())
57
57
);
58
58
} else if (isReplacementSource (allocation , node .nodeId ())) {
59
- return Decision . single (
60
- Decision .Type . NO ,
59
+ return allocation . decision (
60
+ Decision .NO ,
61
61
NAME ,
62
62
"node [%s] is being replaced by [%s], so no data may be allocated to it" ,
63
63
node .nodeId (),
@@ -73,8 +73,8 @@ public Decision canAllocate(ShardRouting shardRouting, RoutingNode node, Routing
73
73
}
74
74
75
75
final SingleNodeShutdownMetadata shutdown = allocation .replacementTargetShutdowns ().get (node .node ().getName ());
76
- return Decision . single (
77
- Decision .Type . NO ,
76
+ return allocation . decision (
77
+ Decision .NO ,
78
78
NAME ,
79
79
"node [%s] is replacing the vacating node [%s], only data currently allocated to the source node "
80
80
+ "may be allocated to it until the replacement is complete" ,
@@ -92,8 +92,8 @@ public Decision canRemain(IndexMetadata indexMetadata, ShardRouting shardRouting
92
92
if (replacementOngoing (allocation ) == false ) {
93
93
return YES__NO_REPLACEMENTS ;
94
94
} else if (isReplacementSource (allocation , node .nodeId ())) {
95
- return Decision . single (
96
- Decision .Type . NO ,
95
+ return allocation . decision (
96
+ Decision .NO ,
97
97
NAME ,
98
98
"node [%s] is being replaced by node [%s], so no data may remain on it" ,
99
99
node .nodeId (),
@@ -110,17 +110,17 @@ public Decision shouldAutoExpandToNode(IndexMetadata indexMetadata, DiscoveryNod
110
110
return YES__NO_REPLACEMENTS ;
111
111
} else if (isReplacementTargetName (allocation , node .getName ())) {
112
112
final SingleNodeShutdownMetadata shutdown = allocation .replacementTargetShutdowns ().get (node .getName ());
113
- return Decision . single (
114
- Decision .Type . NO ,
113
+ return allocation . decision (
114
+ Decision .NO ,
115
115
NAME ,
116
116
"node [%s] is a node replacement target for node [%s], "
117
117
+ "shards cannot auto expand to be on it until the replacement is complete" ,
118
118
node .getId (),
119
119
shutdown == null ? null : shutdown .getNodeId ()
120
120
);
121
121
} else if (isReplacementSource (allocation , node .getId ())) {
122
- return Decision . single (
123
- Decision .Type . NO ,
122
+ return allocation . decision (
123
+ Decision .NO ,
124
124
NAME ,
125
125
"node [%s] is being replaced by [%s], shards cannot auto expand to be on it" ,
126
126
node .getId (),
@@ -134,16 +134,16 @@ public Decision shouldAutoExpandToNode(IndexMetadata indexMetadata, DiscoveryNod
134
134
@ Override
135
135
public Decision canForceAllocateDuringReplace (ShardRouting shardRouting , RoutingNode node , RoutingAllocation allocation ) {
136
136
if (replacementFromSourceToTarget (allocation , shardRouting .currentNodeId (), node .node ().getName ())) {
137
- return Decision . single (
138
- Decision .Type . YES ,
137
+ return allocation . decision (
138
+ Decision .YES ,
139
139
NAME ,
140
140
"node [%s] is being replaced by node [%s], and can be force vacated to the target" ,
141
141
shardRouting .currentNodeId (),
142
142
node .nodeId ()
143
143
);
144
144
} else {
145
- return Decision . single (
146
- Decision .Type . NO ,
145
+ return allocation . decision (
146
+ Decision .NO ,
147
147
NAME ,
148
148
"shard is not on the source of a node replacement relocated to the replacement target"
149
149
);
@@ -153,8 +153,8 @@ public Decision canForceAllocateDuringReplace(ShardRouting shardRouting, Routing
153
153
@ Override
154
154
public Decision canAllocateReplicaWhenThereIsRetentionLease (ShardRouting shardRouting , RoutingNode node , RoutingAllocation allocation ) {
155
155
if (isReplacementTargetName (allocation , node .node ().getName ())) {
156
- return Decision . single (
157
- Decision .Type . YES ,
156
+ return allocation . decision (
157
+ Decision .YES ,
158
158
NAME ,
159
159
"node [%s] is a node replacement target and can have a previously allocated replica re-allocated to it" ,
160
160
node .nodeId ()
0 commit comments