-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
High availablity. Performing round robin between nodes .issue #3
- Loading branch information
Showing
12 changed files
with
178 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package il.co.topq.elastic; | ||
|
||
import java.io.IOException; | ||
import java.util.List; | ||
|
||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
import il.co.topq.elastic.model.Post; | ||
|
||
public class TestMutipleNodes extends AbstractCreateRemoveIndexTestCase { | ||
|
||
@Override | ||
protected ESClient initClient() { | ||
return ESClient.builder().addClient("localhost", 9200).addClient("localhost", 9201).build(); | ||
} | ||
|
||
@Test | ||
public void testHighAvailiablity() throws IOException, InterruptedException { | ||
addPostAndVerify(555); | ||
System.out.println("Stop the main Elasticsearch node"); | ||
// sleep(10); | ||
addPostAndVerify(666); | ||
System.out.println("Restart the main Elasticsearch node and take down the secondery"); | ||
// sleep(10); | ||
addPostAndVerify(777); | ||
} | ||
|
||
private void addPostAndVerify(int id) throws IOException { | ||
if (!client.index(INDEX).isExists()) { | ||
client.index(INDEX).create(SETTINGS); | ||
} | ||
Post post0 = new Post(); | ||
post0.setId(id); | ||
post0.setOp("Itai"); | ||
post0.setPoints(100); | ||
post0.setSubreddit("all"); | ||
client.index(INDEX).document(DOC).add().single(id + "", post0); | ||
sleep(1); | ||
List<Post> posts = client.index(INDEX).document(DOC).search().byTerm("id", id + "").asClass(Post.class); | ||
Assert.assertNotNull(posts); | ||
Assert.assertEquals(1, posts.size()); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters