Reformat all files in the project according to java conventions.
This commit is contained in:
@@ -37,42 +37,45 @@ public class ClusterCommandsTest extends JedisTestBase {
|
||||
node1.disconnect();
|
||||
node2.disconnect();
|
||||
}
|
||||
|
||||
|
||||
@AfterClass
|
||||
public static void removeSlots() throws InterruptedException {
|
||||
//This is to wait for gossip to replicate data.
|
||||
waitForEqualClusterSize();
|
||||
String[] nodes = node1.clusterNodes().split("\n");
|
||||
String node1Id = nodes[0].split(" ")[0];
|
||||
node1.clusterDelSlots(1,2,3,4,5,500);
|
||||
node1.clusterSetSlotNode(5000, node1Id);
|
||||
node1.clusterDelSlots(5000, 10000);
|
||||
node1.clusterDelSlots(6000);
|
||||
node2.clusterDelSlots(6000,1,2,3,4,5,500,5000);
|
||||
try {
|
||||
node2.clusterDelSlots(10000);
|
||||
} catch (JedisDataException jde) {
|
||||
//Do nothing, slot may or may not be assigned depending on gossip
|
||||
}
|
||||
// This is to wait for gossip to replicate data.
|
||||
waitForEqualClusterSize();
|
||||
String[] nodes = node1.clusterNodes().split("\n");
|
||||
String node1Id = nodes[0].split(" ")[0];
|
||||
node1.clusterDelSlots(1, 2, 3, 4, 5, 500);
|
||||
node1.clusterSetSlotNode(5000, node1Id);
|
||||
node1.clusterDelSlots(5000, 10000);
|
||||
node1.clusterDelSlots(6000);
|
||||
node2.clusterDelSlots(6000, 1, 2, 3, 4, 5, 500, 5000);
|
||||
try {
|
||||
node2.clusterDelSlots(10000);
|
||||
} catch (JedisDataException jde) {
|
||||
// Do nothing, slot may or may not be assigned depending on gossip
|
||||
}
|
||||
}
|
||||
|
||||
private static void waitForEqualClusterSize() throws InterruptedException {
|
||||
boolean notEqualSize = true;
|
||||
while (notEqualSize) {
|
||||
notEqualSize = getClusterAttribute(node1.clusterInfo(), "cluster_known_nodes") == getClusterAttribute(node2.clusterInfo(), "cluster_size") ? false : true;
|
||||
}
|
||||
boolean notEqualSize = true;
|
||||
while (notEqualSize) {
|
||||
notEqualSize = getClusterAttribute(node1.clusterInfo(),
|
||||
"cluster_known_nodes") == getClusterAttribute(
|
||||
node2.clusterInfo(), "cluster_size") ? false : true;
|
||||
}
|
||||
}
|
||||
|
||||
private static int getClusterAttribute(String clusterInfo, String attributeName) {
|
||||
for (String infoElement: clusterInfo.split("\n")) {
|
||||
if (infoElement.contains(attributeName)) {
|
||||
return Integer.valueOf(infoElement.split(":")[1].trim());
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
private static int getClusterAttribute(String clusterInfo,
|
||||
String attributeName) {
|
||||
for (String infoElement : clusterInfo.split("\n")) {
|
||||
if (infoElement.contains(attributeName)) {
|
||||
return Integer.valueOf(infoElement.split(":")[1].trim());
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Test
|
||||
@Test
|
||||
public void clusterNodes() {
|
||||
String nodes = node1.clusterNodes();
|
||||
assertTrue(nodes.split("\n").length > 0);
|
||||
|
||||
Reference in New Issue
Block a user