Skip to content

Commit

Permalink
Fix compilation on Java 8 + tests that rely on ordering
Browse files Browse the repository at this point in the history
Note, we still have tests failing because of mvel compilation bugs, see more here: http://jira.codehaus.org/browse/MVEL-299
closes elastic#4510
  • Loading branch information
kimchy authored and brusic committed Jan 19, 2014
1 parent 13d910d commit 14dea0e
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 12 deletions.
6 changes: 3 additions & 3 deletions src/main/java/jsr166e/ConcurrentHashMapV8.java
Expand Up @@ -4510,7 +4510,7 @@ public boolean equals(Object o) {
(containsAll(c) && c.containsAll(this))));
}

public ConcurrentHashMapSpliterator<K> spliterator() {
public ConcurrentHashMapSpliterator<K> spliteratorJSR166() {
Node<K,V>[] t;
ConcurrentHashMapV8<K,V> m = map;
long n = m.sumCount();
Expand Down Expand Up @@ -4568,7 +4568,7 @@ public final boolean addAll(Collection<? extends V> c) {
throw new UnsupportedOperationException();
}

public ConcurrentHashMapSpliterator<V> spliterator() {
public ConcurrentHashMapSpliterator<V> spliteratorJSR166() {
Node<K,V>[] t;
ConcurrentHashMapV8<K,V> m = map;
long n = m.sumCount();
Expand Down Expand Up @@ -4656,7 +4656,7 @@ public final boolean equals(Object o) {
(containsAll(c) && c.containsAll(this))));
}

public ConcurrentHashMapSpliterator<Map.Entry<K,V>> spliterator() {
public ConcurrentHashMapSpliterator<Map.Entry<K,V>> spliteratorJSR166() {
Node<K,V>[] t;
ConcurrentHashMapV8<K,V> m = map;
long n = m.sumCount();
Expand Down
Expand Up @@ -507,6 +507,18 @@ public List<ShardRouting> replicaShards() {
return this.replicas;
}

public List<ShardRouting> replicaShardsWithState(ShardRoutingState... states) {
List<ShardRouting> shards = newArrayList();
for (ShardRouting shardEntry : replicas) {
for (ShardRoutingState state : states) {
if (shardEntry.state() == state) {
shards.add(shardEntry);
}
}
}
return shards;
}

public List<ShardRouting> shardsWithState(ShardRoutingState... states) {
List<ShardRouting> shards = newArrayList();
for (ShardRouting shardEntry : this) {
Expand Down
Expand Up @@ -34,6 +34,7 @@
import static org.elasticsearch.cluster.routing.ShardRoutingState.*;
import static org.elasticsearch.cluster.routing.allocation.RoutingAllocationTests.newNode;
import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder;
import static org.hamcrest.Matchers.anyOf;
import static org.hamcrest.Matchers.equalTo;

public class ClusterRebalanceRoutingTests extends ElasticsearchAllocationTestCase {
Expand Down Expand Up @@ -434,7 +435,7 @@ public void testClusterAllActive1() {
routingNodes = clusterState.routingNodes();

assertThat(routingNodes.node("node3").size(), equalTo(1));
assertThat(routingNodes.node("node3").get(0).shardId().index().name(), equalTo("test1"));
assertThat(routingNodes.node("node3").get(0).shardId().index().name(), anyOf(equalTo("test1"), equalTo("test2")));
}

@Test
Expand Down
Expand Up @@ -111,10 +111,10 @@ public void testUpdateNumberOfReplicas() {
assertThat(routingTable.index("test").shard(0).primaryShard().state(), equalTo(STARTED));
assertThat(routingTable.index("test").shard(0).primaryShard().currentNodeId(), equalTo(nodeHoldingPrimary));
assertThat(routingTable.index("test").shard(0).replicaShards().size(), equalTo(2));
assertThat(routingTable.index("test").shard(0).replicaShards().get(0).state(), equalTo(STARTED));
assertThat(routingTable.index("test").shard(0).replicaShards().get(0).currentNodeId(), equalTo(nodeHoldingReplica));
assertThat(routingTable.index("test").shard(0).replicaShards().get(1).state(), equalTo(INITIALIZING));
assertThat(routingTable.index("test").shard(0).replicaShards().get(1).currentNodeId(), equalTo("node3"));
assertThat(routingTable.index("test").shard(0).replicaShardsWithState(STARTED).size(), equalTo(1));
assertThat(routingTable.index("test").shard(0).replicaShardsWithState(STARTED).get(0).currentNodeId(), equalTo(nodeHoldingReplica));
assertThat(routingTable.index("test").shard(0).replicaShardsWithState(INITIALIZING).size(), equalTo(1));
assertThat(routingTable.index("test").shard(0).replicaShardsWithState(INITIALIZING).get(0).currentNodeId(), equalTo("node3"));

routingNodes = clusterState.routingNodes();
prevRoutingTable = routingTable;
Expand All @@ -127,10 +127,9 @@ public void testUpdateNumberOfReplicas() {
assertThat(routingTable.index("test").shard(0).primaryShard().state(), equalTo(STARTED));
assertThat(routingTable.index("test").shard(0).primaryShard().currentNodeId(), equalTo(nodeHoldingPrimary));
assertThat(routingTable.index("test").shard(0).replicaShards().size(), equalTo(2));
assertThat(routingTable.index("test").shard(0).replicaShards().get(0).state(), equalTo(STARTED));
assertThat(routingTable.index("test").shard(0).replicaShards().get(0).currentNodeId(), equalTo(nodeHoldingReplica));
assertThat(routingTable.index("test").shard(0).replicaShards().get(1).state(), equalTo(STARTED));
assertThat(routingTable.index("test").shard(0).replicaShards().get(1).currentNodeId(), equalTo("node3"));
assertThat(routingTable.index("test").shard(0).replicaShardsWithState(STARTED).size(), equalTo(2));
assertThat(routingTable.index("test").shard(0).replicaShardsWithState(STARTED).get(0).currentNodeId(), anyOf(equalTo(nodeHoldingReplica), equalTo("node3")));
assertThat(routingTable.index("test").shard(0).replicaShardsWithState(STARTED).get(1).currentNodeId(), anyOf(equalTo(nodeHoldingReplica), equalTo("node3")));

logger.info("now remove a replica");
routingNodes = clusterState.routingNodes();
Expand Down

0 comments on commit 14dea0e

Please sign in to comment.