Skip to content

Commit

Permalink
Merge branch '1.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
grmblfrz committed Aug 11, 2014
2 parents f5ef369 + a9c5fb0 commit e9e432c
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 17 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.sonian</groupId>
<artifactId>elasticsearch-zookeeper</artifactId>
<version>1.2.0</version>
<version>1.2.3</version>
<packaging>jar</packaging>
<description>ZooKeeper plugin for Elasticsearch</description>
<inceptionYear>2011</inceptionYear>
Expand All @@ -30,7 +30,7 @@
</parent>

<properties>
<elasticsearch.version>1.2.1</elasticsearch.version>
<elasticsearch.version>1.2.3</elasticsearch.version>
<zookeeper.version>3.4.6</zookeeper.version>
</properties>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,13 +215,27 @@ public void shutdownZooKeeper() {
buildNode("node2");

// Ensure node1 is master
ClusterStateMonitor nodeMonitor = new ClusterStateMonitor("node1");
ClusterStateMonitor nodeMonitor = new ClusterStateMonitor("node1", new ClusterStateCondition() {
@Override public boolean check(ClusterChangedEvent event) {
return event.state().nodes().masterNode() != null;
}
});
node("node1").start();
ClusterState cs = nodeMonitor.await();
assertThat(nodeMonitor.await().nodes().masterNode().name(), equalTo("node1"));

// Start all other nodes
ClusterStateMonitor clientMonitor = new ClusterStateMonitor("client");
nodeMonitor = new ClusterStateMonitor("node2");
ClusterStateMonitor clientMonitor = new ClusterStateMonitor("client", new ClusterStateCondition() {
@Override
public boolean check(ClusterChangedEvent event) {
return event.state().nodes().masterNode() != null;
}
});
nodeMonitor = new ClusterStateMonitor("node2", new ClusterStateCondition() {
@Override public boolean check(ClusterChangedEvent event) {
return event.state().nodes().masterNode() != null;
}
});
node("node2").start();
node("client").start();
assertThat(nodeMonitor.await().nodes().masterNode().name(), equalTo("node1"));
Expand Down Expand Up @@ -280,7 +294,11 @@ public void shutdownZooKeeper() {
buildNode("node1");

// Ensure node1 is master
ClusterStateMonitor nodeMonitor = new ClusterStateMonitor("node1");
ClusterStateMonitor nodeMonitor = new ClusterStateMonitor("node1", new ClusterStateCondition() {
@Override public boolean check(ClusterChangedEvent event) {
return event.state().nodes().masterNode() != null;
}
});
node("node1").start();
assertThat(nodeMonitor.await().nodes().masterNode().name(), equalTo("node1"));

Expand All @@ -298,12 +316,20 @@ public void shutdownZooKeeper() {
buildNode("node2");

// Ensure node1 is master
ClusterStateMonitor nodeMonitor = new ClusterStateMonitor("node1");
ClusterStateMonitor nodeMonitor = new ClusterStateMonitor("node1", new ClusterStateCondition() {
@Override public boolean check(ClusterChangedEvent event) {
return event.state().nodes().masterNode() != null;
}
});
node("node1").start();
assertThat(nodeMonitor.await().nodes().masterNode().name(), equalTo("node1"));

// Wait for the second node to start
nodeMonitor = new ClusterStateMonitor("node2");
nodeMonitor = new ClusterStateMonitor("node2", new ClusterStateCondition() {
@Override public boolean check(ClusterChangedEvent event) {
return event.state().nodes().masterNode() != null;
}
});
node("node2").start();
assertThat(nodeMonitor.await().nodes().masterNode().name(), equalTo("node1"));

Expand All @@ -324,12 +350,20 @@ public void shutdownZooKeeper() {
buildNode("node2");

// Ensure node1 is master
ClusterStateMonitor nodeMonitor = new ClusterStateMonitor("node1");
ClusterStateMonitor nodeMonitor = new ClusterStateMonitor("node1", new ClusterStateCondition() {
@Override public boolean check(ClusterChangedEvent event) {
return event.state().nodes().masterNode() != null;
}
});
node("node1").start();
assertThat(nodeMonitor.await().nodes().masterNode().name(), equalTo("node1"));

// Wait for the second node to start
nodeMonitor = new ClusterStateMonitor("node2");
nodeMonitor = new ClusterStateMonitor("node2", new ClusterStateCondition() {
@Override public boolean check(ClusterChangedEvent event) {
return event.state().nodes().masterNode() != null;
}
});
node("node2").start();
assertThat(nodeMonitor.await().nodes().masterNode().name(), equalTo("node1"));

Expand Down Expand Up @@ -368,17 +402,29 @@ public void shutdownZooKeeper() {
);

// Ensure node1 is master
ClusterStateMonitor nodeMonitor = new ClusterStateMonitor("node1");
ClusterStateMonitor nodeMonitor = new ClusterStateMonitor("node1", new ClusterStateCondition() {
@Override public boolean check(ClusterChangedEvent event) {
return event.state().nodes().masterNode() != null;
}
});
node("node1").start();
assertThat(nodeMonitor.await().nodes().masterNode().name(), equalTo("node1"));

// Wait for the second node to start
nodeMonitor = new ClusterStateMonitor("node2");
nodeMonitor = new ClusterStateMonitor("node2", new ClusterStateCondition() {
@Override public boolean check(ClusterChangedEvent event) {
return event.state().nodes().masterNode() != null;
}
});
node("node2").start();
assertThat(nodeMonitor.await().nodes().masterNode().name(), equalTo("node1"));

// Wait for the third node to start
nodeMonitor = new ClusterStateMonitor("node3");
nodeMonitor = new ClusterStateMonitor("node3", new ClusterStateCondition() {
@Override public boolean check(ClusterChangedEvent event) {
return event.state().nodes().masterNode() != null;
}
});
node("node3").start();
assertThat(nodeMonitor.await().nodes().masterNode().name(), equalTo("node1"));

Expand Down Expand Up @@ -531,17 +577,29 @@ private long countResults(int indexCount) throws InterruptedException {
);

// Ensure node1 is master
ClusterStateMonitor nodeMonitor = new ClusterStateMonitor("node1");
ClusterStateMonitor nodeMonitor = new ClusterStateMonitor("node1", new ClusterStateCondition() {
@Override public boolean check(ClusterChangedEvent event) {
return event.state().nodes().masterNode() != null;
}
});
node("node1").start();
assertThat(nodeMonitor.await().nodes().masterNode().name(), equalTo("node1"));

// Wait for the second node to start
nodeMonitor = new ClusterStateMonitor("node2");
nodeMonitor = new ClusterStateMonitor("node2", new ClusterStateCondition() {
@Override public boolean check(ClusterChangedEvent event) {
return event.state().nodes().masterNode() != null;
}
});
node("node2").start();
assertThat(nodeMonitor.await().nodes().masterNode().name(), equalTo("node1"));

// Wait for the third node to start
nodeMonitor = new ClusterStateMonitor("node3");
nodeMonitor = new ClusterStateMonitor("node3", new ClusterStateCondition() {
@Override public boolean check(ClusterChangedEvent event) {
return event.state().nodes().masterNode() != null;
}
});
node("node3").start();
assertThat(nodeMonitor.await().nodes().masterNode().name(), equalTo("node1"));

Expand Down Expand Up @@ -636,8 +694,8 @@ public ClusterStateMonitor(final String id, ClusterStateCondition condition) {
clusterStateListener = new ClusterStateListener() {
@Override public void clusterChanged(ClusterChangedEvent event) {
if (checkCondition(event)) {
logger.info("clusterChangedEvent {} state {} ", event.source(), state);
state = event.state();
logger.info("clusterChangedEvent {} state {} ", event.source(), state);
clusterService(id).remove(this);
latchNode.countDown();
} else {
Expand Down

0 comments on commit e9e432c

Please sign in to comment.