try {
boolean dnode1NotPresent = true;
for(int i = 0; i < N_QNODES; i++) {
Map.Entry<String, Tablespace> tEntry = clients[i].overview().getTablespaceMap().entrySet()
.iterator().next();
ReplicationMap currentReplicationMap = tEntry.getValue().getReplicationMap();
for(ReplicationEntry entry : currentReplicationMap.getReplicationEntries()) {
if(entry.getNodes().contains(dnode1.getAddress())) {
dnode1NotPresent = false;
}
}
}
return dnode1NotPresent;
} catch(IOException e) {
// test failed
e.printStackTrace();
return true;
}
}
}.waitAtMost(5000);
// waiting now until the system recovers itself without dnode1
new TestUtils.NotWaitingForeverCondition() {
@Override
public boolean endCondition() {
try {
boolean balanced = true;
for(int i = 0; i < N_QNODES; i++) {
Map.Entry<String, Tablespace> tEntry = clients[i].overview().getTablespaceMap().entrySet()
.iterator().next();
ReplicationMap currentReplicationMap = tEntry.getValue().getReplicationMap();
for(ReplicationEntry entry : currentReplicationMap.getReplicationEntries()) {
if(entry.getNodes().size() < entry.getExpectedReplicationFactor()) {
balanced = false;
}
}
}
return balanced;
} catch(IOException e) {
// test failed
e.printStackTrace();
return true;
}
}
}.waitAtMost(5000);
// now we bring back dnode1 to life
// what will happen now is that the partitions it seves will be over-replicated
dnode1.testCommand(TestCommands.RESTART.toString());
// waiting now until the system is over-replicated
new TestUtils.NotWaitingForeverCondition() {
@Override
public boolean endCondition() {
try {
boolean overreplicated = true;
for(int i = 0; i < N_QNODES; i++) {
Map.Entry<String, Tablespace> tEntry = clients[i].overview().getTablespaceMap().entrySet()
.iterator().next();
ReplicationMap currentReplicationMap = tEntry.getValue().getReplicationMap();
for(ReplicationEntry entry : currentReplicationMap.getReplicationEntries()) {
if(partitionsByNode1.contains(entry.getShard())
&& entry.getNodes().size() <= entry.getExpectedReplicationFactor()) {
overreplicated = false;
}
}