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

This commit is contained in:
Abhinandan Prateek 2011-11-29 11:23:21 +05:30
parent 31172a4205
commit a560d6f055
4 changed files with 11 additions and 25 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

@ -6574,19 +6574,18 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
if (!_host.uuid.equals(hostr.uuid)) {
return new ClusterSyncAnswer(cmd.getClusterId());
}
} catch (Exception e) {
} catch (Throwable e) {
s_logger.warn("Check for master failed, failing the Cluster sync command");
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

@ -2044,15 +2044,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());
} else {
@ -2126,7 +2123,7 @@ public class VirtualMachineManagerImpl implements VirtualMachineManager, Listene
long agentId = agent.getId();
if (agent.getHypervisorType() == HypervisorType.XenServer) { // only for Xen
ClusterSyncCommand syncCmd = new ClusterSyncCommand(Integer.parseInt(Config.ClusterDeltaSyncInterval.getDefaultValue()),
Integer.parseInt(Config.ClusterFullSyncSkipSteps.getDefaultValue()), clusterId);
Integer.parseInt(Config.ClusterFullSyncSkipSteps.getDefaultValue()), clusterId);
try {
long seq_no = _agentMgr.send(agentId, new Commands(syncCmd), this);
s_logger.debug("Cluster VM sync started with jobid " + seq_no);