@@ -95,18 +95,24 @@ public Decision canAllocate(ShardRouting shardRouting, RoutingNode node, Routing
95
95
);
96
96
}
97
97
98
- if (migrationDirection .equals (Direction .REMOTE_STORE ) == false ) {
99
- // docrep migration direction is currently not supported
98
+ IndexMetadata indexMetadata = allocation .metadata ().getIndexSafe (shardRouting .index ());
99
+ boolean remoteStoreBackedIndex = IndexMetadata .INDEX_REMOTE_STORE_ENABLED_SETTING .get (indexMetadata .getSettings ());
100
+
101
+ if (migrationDirection .equals (Direction .NONE )) {
102
+ boolean isNoDecision = (remoteStoreBackedIndex && targetNode .isRemoteStoreNode () == false )
103
+ || (remoteStoreBackedIndex == false && targetNode .isRemoteStoreNode ());
104
+ String reason = String .format (Locale .ROOT , " for %sremote store backed index" , remoteStoreBackedIndex ? "" : "non " );
100
105
return allocation .decision (
101
- Decision .YES ,
106
+ isNoDecision ? Decision . NO : Decision .YES ,
102
107
NAME ,
103
- getDecisionDetails (true , shardRouting , targetNode , " for non remote_store direction" )
108
+ getDecisionDetails (! isNoDecision , shardRouting , targetNode , reason )
104
109
);
110
+ } else if (migrationDirection .equals (Direction .DOCREP )) {
111
+ // docrep migration direction is currently not supported
112
+ return allocation .decision (Decision .YES , NAME , getDecisionDetails (true , shardRouting , targetNode , " for DOCREP direction" ));
105
113
}
106
114
107
115
// check for remote store backed indices
108
- IndexMetadata indexMetadata = allocation .metadata ().getIndexSafe (shardRouting .index ());
109
- boolean remoteStoreBackedIndex = IndexMetadata .INDEX_REMOTE_STORE_ENABLED_SETTING .get (indexMetadata .getSettings ());
110
116
if (remoteStoreBackedIndex && targetNode .isRemoteStoreNode () == false ) {
111
117
// allocations and relocations must be to a remote node
112
118
String reason = String .format (
0 commit comments