bug 11910: no need to do full sync as first thing after connect

This commit is contained in:
Abhinandan Prateek 2011-11-29 11:35:11 +05:30
parent 9cade8e061
commit 59a48ce59d
4 changed files with 9 additions and 23 deletions

View File

@ -27,8 +27,6 @@ public class ClusterSyncAnswer extends Answer {
private HashMap<String, Pair<String, State>> _newStates;
private HashMap<String, Pair<String, State>> _allStates;
private int _type = -1; // 0 for full, 1 for delta
private boolean isExecuted=false; // this is to avoid double execution first time, due to framework ???
public static final int FULL_SYNC=0;
public static final int DELTA_SYNC=1;
@ -75,12 +73,4 @@ public class ClusterSyncAnswer extends Answer {
public boolean isDelta(){
return _type==1;
}
public boolean execute(){
return !isExecuted;
}
public void setExecuted(){
isExecuted = true;
}
}

View File

@ -46,11 +46,11 @@ public class ClusterSyncCommand extends Command implements CronCommand {
public void incrStep(){
_steps++;
if (_steps>=_skipSteps)_steps=0;
if (_steps>_skipSteps)_steps=0;
}
public boolean isRightStep(){
return (_steps==0);
public boolean isRightStep(){
return (_steps==_skipSteps);
}
public long getClusterId() {

View File

@ -6469,14 +6469,13 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
return new ClusterSyncAnswer(cmd.getClusterId());
}
HashMap<String, Pair<String, State>> newStates = deltaClusterSync(conn);
cmd.incrStep();
if (cmd.isRightStep()){
// do full sync
HashMap<String, Pair<String, State>> allStates=fullClusterSync(conn);
cmd.incrStep();
return new ClusterSyncAnswer(cmd.getClusterId(), newStates, allStates);
}
else {
cmd.incrStep();
return new ClusterSyncAnswer(cmd.getClusterId(), newStates);
}
}

View File

@ -1958,15 +1958,12 @@ public class VirtualMachineManagerImpl implements VirtualMachineManager, Listene
for (final Answer answer : answers) {
if (answer instanceof ClusterSyncAnswer) {
ClusterSyncAnswer hs = (ClusterSyncAnswer) answer;
if (hs.execute()){
if (hs.isFull()) {
deltaSync(hs.getNewStates());
fullSync(hs.getClusterId(), hs.getAllStates());
} else if (hs.isDelta()) {
deltaSync(hs.getNewStates());
}
if (hs.isFull()) {
deltaSync(hs.getNewStates());
fullSync(hs.getClusterId(), hs.getAllStates());
} else if (hs.isDelta()) {
deltaSync(hs.getNewStates());
}
hs.setExecuted();
} else if (!answer.getResult()) {
s_logger.warn("Cleanup failed due to " + answer.getDetails() + " for " + answer.getClass().getName());
} else {