@@ -89,7 +89,7 @@ public Decision canAllocate(ShardRouting shardRouting, RoutingNode node, Routing
89
89
return allocation .decision (
90
90
Decision .YES ,
91
91
NAME ,
92
- getDecisionDetails (true , shardRouting , targetNode , " for strict compatibility mode" )
92
+ getDecisionDetails (true , shardRouting , targetNode , " for strict compatibility mode" , allocation )
93
93
);
94
94
}
95
95
@@ -103,19 +103,23 @@ public Decision canAllocate(ShardRouting shardRouting, RoutingNode node, Routing
103
103
return allocation .decision (
104
104
isNoDecision ? Decision .NO : Decision .YES ,
105
105
NAME ,
106
- getDecisionDetails (!isNoDecision , shardRouting , targetNode , reason )
106
+ getDecisionDetails (!isNoDecision , shardRouting , targetNode , reason , allocation )
107
107
);
108
108
} else if (migrationDirection .equals (Direction .DOCREP )) {
109
109
// docrep migration direction is currently not supported
110
- return allocation .decision (Decision .YES , NAME , getDecisionDetails (true , shardRouting , targetNode , " for DOCREP direction" ));
110
+ return allocation .decision (
111
+ Decision .YES ,
112
+ NAME ,
113
+ getDecisionDetails (true , shardRouting , targetNode , " for DOCREP direction" , allocation )
114
+ );
111
115
} else {
112
116
// check for remote store backed indices
113
117
if (remoteSettingsBackedIndex && targetNode .isRemoteStoreNode () == false ) {
114
118
// allocations and relocations must be to a remote node
115
119
String reason = new StringBuilder (" because a remote store backed index's shard copy can only be " ).append (
116
120
(shardRouting .assignedToNode () == false ) ? "allocated" : "relocated"
117
121
).append (" to a remote node" ).toString ();
118
- return allocation .decision (Decision .NO , NAME , getDecisionDetails (false , shardRouting , targetNode , reason ));
122
+ return allocation .decision (Decision .NO , NAME , getDecisionDetails (false , shardRouting , targetNode , reason , allocation ));
119
123
}
120
124
121
125
if (shardRouting .primary ()) {
@@ -128,9 +132,9 @@ public Decision canAllocate(ShardRouting shardRouting, RoutingNode node, Routing
128
132
// handle scenarios for allocation of a new shard's primary copy
129
133
private Decision primaryShardDecision (ShardRouting primaryShardRouting , DiscoveryNode targetNode , RoutingAllocation allocation ) {
130
134
if (targetNode .isRemoteStoreNode () == false ) {
131
- return allocation .decision (Decision .NO , NAME , getDecisionDetails (false , primaryShardRouting , targetNode , "" ));
135
+ return allocation .decision (Decision .NO , NAME , getDecisionDetails (false , primaryShardRouting , targetNode , "" , allocation ));
132
136
}
133
- return allocation .decision (Decision .YES , NAME , getDecisionDetails (true , primaryShardRouting , targetNode , "" ));
137
+ return allocation .decision (Decision .YES , NAME , getDecisionDetails (true , primaryShardRouting , targetNode , "" , allocation ));
134
138
}
135
139
136
140
// Checks if primary shard is on a remote node.
@@ -150,20 +154,41 @@ private Decision replicaShardDecision(ShardRouting replicaShardRouting, Discover
150
154
return allocation .decision (
151
155
Decision .NO ,
152
156
NAME ,
153
- getDecisionDetails (false , replicaShardRouting , targetNode , " since primary shard copy is not yet migrated to remote" )
157
+ getDecisionDetails (
158
+ false ,
159
+ replicaShardRouting ,
160
+ targetNode ,
161
+ " since primary shard copy is not yet migrated to remote" ,
162
+ allocation
163
+ )
154
164
);
155
165
}
156
166
return allocation .decision (
157
167
Decision .YES ,
158
168
NAME ,
159
- getDecisionDetails (true , replicaShardRouting , targetNode , " since primary shard copy has been migrated to remote" )
169
+ getDecisionDetails (
170
+ true ,
171
+ replicaShardRouting ,
172
+ targetNode ,
173
+ " since primary shard copy has been migrated to remote" ,
174
+ allocation
175
+ )
160
176
);
161
177
}
162
- return allocation .decision (Decision .YES , NAME , getDecisionDetails (true , replicaShardRouting , targetNode , "" ));
178
+ return allocation .decision (Decision .YES , NAME , getDecisionDetails (true , replicaShardRouting , targetNode , "" , allocation ));
163
179
}
164
180
165
181
// get detailed reason for the decision
166
- private String getDecisionDetails (boolean isYes , ShardRouting shardRouting , DiscoveryNode targetNode , String reason ) {
182
+ private String getDecisionDetails (
183
+ boolean isYes ,
184
+ ShardRouting shardRouting ,
185
+ DiscoveryNode targetNode ,
186
+ String reason ,
187
+ RoutingAllocation allocation
188
+ ) {
189
+ if (allocation .debugDecision () == false ) {
190
+ return null ;
191
+ }
167
192
return new StringBuilder ("[" ).append (migrationDirection .direction )
168
193
.append (" migration_direction]: " )
169
194
.append (shardRouting .primary () ? "primary" : "replica" )
0 commit comments