20
20
package org .elasticsearch .cluster .routing .allocation .decider ;
21
21
22
22
import org .elasticsearch .cluster .metadata .IndexMetaData ;
23
+ import org .elasticsearch .cluster .node .DiscoveryNode ;
23
24
import org .elasticsearch .cluster .node .DiscoveryNodeFilters ;
24
25
import org .elasticsearch .cluster .routing .RecoverySource ;
25
26
import org .elasticsearch .cluster .routing .RoutingNode ;
@@ -109,20 +110,31 @@ public Decision canAllocate(ShardRouting shardRouting, RoutingNode node, Routing
109
110
return allocation .decision (Decision .NO , NAME , explanation , initialRecoveryFilters );
110
111
}
111
112
}
112
- return shouldFilter (shardRouting , node , allocation );
113
+ return shouldFilter (shardRouting , node . node () , allocation );
113
114
}
114
115
115
116
@ Override
116
117
public Decision canAllocate (IndexMetaData indexMetaData , RoutingNode node , RoutingAllocation allocation ) {
117
- return shouldFilter (indexMetaData , node , allocation );
118
+ return shouldFilter (indexMetaData , node . node () , allocation );
118
119
}
119
120
120
121
@ Override
121
122
public Decision canRemain (ShardRouting shardRouting , RoutingNode node , RoutingAllocation allocation ) {
122
- return shouldFilter (shardRouting , node , allocation );
123
+ return shouldFilter (shardRouting , node . node () , allocation );
123
124
}
124
125
125
- private Decision shouldFilter (ShardRouting shardRouting , RoutingNode node , RoutingAllocation allocation ) {
126
+ @ Override
127
+ public Decision shouldAutoExpandToNode (IndexMetaData indexMetaData , DiscoveryNode node , RoutingAllocation allocation ) {
128
+ Decision decision = shouldClusterFilter (node , allocation );
129
+ if (decision != null ) return decision ;
130
+
131
+ decision = shouldIndexFilter (indexMetaData , node , allocation );
132
+ if (decision != null ) return decision ;
133
+
134
+ return allocation .decision (Decision .YES , NAME , "node passes include/exclude/require filters" );
135
+ }
136
+
137
+ private Decision shouldFilter (ShardRouting shardRouting , DiscoveryNode node , RoutingAllocation allocation ) {
126
138
Decision decision = shouldClusterFilter (node , allocation );
127
139
if (decision != null ) return decision ;
128
140
@@ -132,7 +144,7 @@ private Decision shouldFilter(ShardRouting shardRouting, RoutingNode node, Routi
132
144
return allocation .decision (Decision .YES , NAME , "node passes include/exclude/require filters" );
133
145
}
134
146
135
- private Decision shouldFilter (IndexMetaData indexMd , RoutingNode node , RoutingAllocation allocation ) {
147
+ private Decision shouldFilter (IndexMetaData indexMd , DiscoveryNode node , RoutingAllocation allocation ) {
136
148
Decision decision = shouldClusterFilter (node , allocation );
137
149
if (decision != null ) return decision ;
138
150
@@ -142,43 +154,43 @@ private Decision shouldFilter(IndexMetaData indexMd, RoutingNode node, RoutingAl
142
154
return allocation .decision (Decision .YES , NAME , "node passes include/exclude/require filters" );
143
155
}
144
156
145
- private Decision shouldIndexFilter (IndexMetaData indexMd , RoutingNode node , RoutingAllocation allocation ) {
157
+ private Decision shouldIndexFilter (IndexMetaData indexMd , DiscoveryNode node , RoutingAllocation allocation ) {
146
158
if (indexMd .requireFilters () != null ) {
147
- if (indexMd .requireFilters ().match (node . node () ) == false ) {
159
+ if (indexMd .requireFilters ().match (node ) == false ) {
148
160
return allocation .decision (Decision .NO , NAME , "node does not match index setting [%s] filters [%s]" ,
149
161
IndexMetaData .INDEX_ROUTING_REQUIRE_GROUP_PREFIX , indexMd .requireFilters ());
150
162
}
151
163
}
152
164
if (indexMd .includeFilters () != null ) {
153
- if (indexMd .includeFilters ().match (node . node () ) == false ) {
165
+ if (indexMd .includeFilters ().match (node ) == false ) {
154
166
return allocation .decision (Decision .NO , NAME , "node does not match index setting [%s] filters [%s]" ,
155
167
IndexMetaData .INDEX_ROUTING_INCLUDE_GROUP_PREFIX , indexMd .includeFilters ());
156
168
}
157
169
}
158
170
if (indexMd .excludeFilters () != null ) {
159
- if (indexMd .excludeFilters ().match (node . node () )) {
171
+ if (indexMd .excludeFilters ().match (node )) {
160
172
return allocation .decision (Decision .NO , NAME , "node matches index setting [%s] filters [%s]" ,
161
173
IndexMetaData .INDEX_ROUTING_EXCLUDE_GROUP_SETTING .getKey (), indexMd .excludeFilters ());
162
174
}
163
175
}
164
176
return null ;
165
177
}
166
178
167
- private Decision shouldClusterFilter (RoutingNode node , RoutingAllocation allocation ) {
179
+ private Decision shouldClusterFilter (DiscoveryNode node , RoutingAllocation allocation ) {
168
180
if (clusterRequireFilters != null ) {
169
- if (clusterRequireFilters .match (node . node () ) == false ) {
181
+ if (clusterRequireFilters .match (node ) == false ) {
170
182
return allocation .decision (Decision .NO , NAME , "node does not match cluster setting [%s] filters [%s]" ,
171
183
CLUSTER_ROUTING_REQUIRE_GROUP_PREFIX , clusterRequireFilters );
172
184
}
173
185
}
174
186
if (clusterIncludeFilters != null ) {
175
- if (clusterIncludeFilters .match (node . node () ) == false ) {
187
+ if (clusterIncludeFilters .match (node ) == false ) {
176
188
return allocation .decision (Decision .NO , NAME , "node does not cluster setting [%s] filters [%s]" ,
177
189
CLUSTER_ROUTING_INCLUDE_GROUP_PREFIX , clusterIncludeFilters );
178
190
}
179
191
}
180
192
if (clusterExcludeFilters != null ) {
181
- if (clusterExcludeFilters .match (node . node () )) {
193
+ if (clusterExcludeFilters .match (node )) {
182
194
return allocation .decision (Decision .NO , NAME , "node matches cluster setting [%s] filters [%s]" ,
183
195
CLUSTER_ROUTING_EXCLUDE_GROUP_PREFIX , clusterExcludeFilters );
184
196
}
0 commit comments