iterator doesn't implement #remove()
This commit is contained in:
parent
e3d4d73242
commit
efba3a50dd
|
@ -20,7 +20,7 @@
|
||||||
package org.elasticsearch.gateway.local;
|
package org.elasticsearch.gateway.local;
|
||||||
|
|
||||||
import com.carrotsearch.hppc.ObjectLongOpenHashMap;
|
import com.carrotsearch.hppc.ObjectLongOpenHashMap;
|
||||||
import com.carrotsearch.hppc.cursors.ObjectLongCursor;
|
import com.carrotsearch.hppc.predicates.ObjectPredicate;
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
import org.elasticsearch.ExceptionsHelper;
|
import org.elasticsearch.ExceptionsHelper;
|
||||||
|
@ -358,7 +358,7 @@ public class LocalGatewayAllocator extends AbstractComponent implements GatewayA
|
||||||
return changed;
|
return changed;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ObjectLongOpenHashMap<DiscoveryNode> buildShardStates(DiscoveryNodes nodes, MutableShardRouting shard) {
|
private ObjectLongOpenHashMap<DiscoveryNode> buildShardStates(final DiscoveryNodes nodes, MutableShardRouting shard) {
|
||||||
ObjectLongOpenHashMap<DiscoveryNode> shardStates = cachedShardsState.get(shard.shardId());
|
ObjectLongOpenHashMap<DiscoveryNode> shardStates = cachedShardsState.get(shard.shardId());
|
||||||
Set<String> nodeIds;
|
Set<String> nodeIds;
|
||||||
if (shardStates == null) {
|
if (shardStates == null) {
|
||||||
|
@ -367,12 +367,12 @@ public class LocalGatewayAllocator extends AbstractComponent implements GatewayA
|
||||||
nodeIds = nodes.dataNodes().keySet();
|
nodeIds = nodes.dataNodes().keySet();
|
||||||
} else {
|
} else {
|
||||||
// clean nodes that have failed
|
// clean nodes that have failed
|
||||||
for (Iterator<ObjectLongCursor<DiscoveryNode>> it = shardStates.iterator(); it.hasNext(); ) {
|
shardStates.keys().removeAll(new ObjectPredicate<DiscoveryNode>() {
|
||||||
DiscoveryNode node = it.next().key;
|
@Override
|
||||||
if (!nodes.nodeExists(node.id())) {
|
public boolean apply(DiscoveryNode node) {
|
||||||
it.remove();
|
return !nodes.nodeExists(node.id());
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
});
|
||||||
nodeIds = Sets.newHashSet();
|
nodeIds = Sets.newHashSet();
|
||||||
// we have stored cached from before, see if the nodes changed, if they have, go fetch again
|
// we have stored cached from before, see if the nodes changed, if they have, go fetch again
|
||||||
for (DiscoveryNode node : nodes.dataNodes().values()) {
|
for (DiscoveryNode node : nodes.dataNodes().values()) {
|
||||||
|
|
Loading…
Reference in New Issue