mirror of https://github.com/apache/cloudstack.git
bug 12530: moved the initial full sunc from the cron to host connect.
This commit is contained in:
parent
7e6bbf9b16
commit
a60d8cea86
|
|
@ -31,7 +31,6 @@ public class ClusterSyncAnswer extends Answer {
|
|||
|
||||
public static final int FULL_SYNC=0;
|
||||
public static final int DELTA_SYNC=1;
|
||||
public static final int INITIAL_FULL_SYNC=2;
|
||||
|
||||
// this is here because a cron command answer is being sent twice
|
||||
// AgentAttache.processAnswers
|
||||
|
|
@ -61,14 +60,6 @@ public class ClusterSyncAnswer extends Answer {
|
|||
result = true;
|
||||
}
|
||||
|
||||
public ClusterSyncAnswer(long clusterId, HashMap<String, Pair<String, State>> newStates, HashMap<String, Pair<String, State>> allStates, boolean init){
|
||||
_clusterId = clusterId;
|
||||
_newStates = newStates;
|
||||
_allStates = allStates;
|
||||
_type = INITIAL_FULL_SYNC;
|
||||
result = true;
|
||||
}
|
||||
|
||||
public long getClusterId() {
|
||||
return _clusterId;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
/* Copyright (C) 2010 Cloud.com, Inc. All rights reserved.
|
||||
/* Copyright (C) 2012 Citrix.com, Inc. All rights reserved.
|
||||
*
|
||||
* This software is licensed under the GNU General Public License v3 or later.
|
||||
*
|
||||
|
|
@ -19,18 +19,20 @@ package com.cloud.agent.api;
|
|||
|
||||
|
||||
public class ClusterSyncCommand extends Command implements CronCommand {
|
||||
private int _interval;
|
||||
private int _skipSteps; // skip this many steps for full sync
|
||||
private int _steps;
|
||||
private boolean _init;
|
||||
private long _clusterId;
|
||||
int _interval;
|
||||
int _skipSteps; // skip this many steps for full sync
|
||||
int _steps;
|
||||
|
||||
long _clusterId;
|
||||
|
||||
public ClusterSyncCommand() {
|
||||
}
|
||||
|
||||
public ClusterSyncCommand(int interval, int skipSteps, long clusterId){
|
||||
_interval = interval;
|
||||
_skipSteps = skipSteps;
|
||||
_clusterId = clusterId;
|
||||
_steps=0;
|
||||
_init=true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -44,10 +46,10 @@ public class ClusterSyncCommand extends Command implements CronCommand {
|
|||
|
||||
public void incrStep(){
|
||||
_steps++;
|
||||
if (_steps>_skipSteps)_steps=0;
|
||||
if (_steps>=_skipSteps)_steps=0;
|
||||
}
|
||||
|
||||
public boolean isRightStep(){
|
||||
public boolean isRightStep(){
|
||||
return (_steps==0);
|
||||
}
|
||||
|
||||
|
|
@ -60,12 +62,4 @@ public class ClusterSyncCommand extends Command implements CronCommand {
|
|||
return false;
|
||||
}
|
||||
|
||||
public boolean isInit(){
|
||||
return _init;
|
||||
}
|
||||
|
||||
public void unsetInit(){
|
||||
_init = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -23,6 +23,7 @@ import java.util.Map;
|
|||
import com.cloud.host.Host;
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import com.cloud.network.Networks.RouterPrivateIpStrategy;
|
||||
import com.cloud.utils.Pair;
|
||||
import com.cloud.vm.VirtualMachine.State;
|
||||
|
||||
public class StartupRoutingCommand extends StartupCommand {
|
||||
|
|
@ -48,6 +49,7 @@ public class StartupRoutingCommand extends StartupCommand {
|
|||
long dom0MinMemory;
|
||||
boolean poolSync;
|
||||
Map<String, VmState> vms;
|
||||
HashMap<String, Pair<String, State>> _clusterVMStates;
|
||||
String caps;
|
||||
String pool;
|
||||
HypervisorType hypervisorType;
|
||||
|
|
@ -127,6 +129,10 @@ getHostDetails().put(RouterPrivateIpStrategy.class.getCanonicalName(), privIpStr
|
|||
this.vms.put(vm_name, new VmState(vms.get(vm_name), null));
|
||||
}
|
||||
}
|
||||
|
||||
public void setClusterVMStateChanges(HashMap<String, Pair<String, State>> allStates){
|
||||
_clusterVMStates = allStates;
|
||||
}
|
||||
|
||||
public int getCpus() {
|
||||
return cpus;
|
||||
|
|
@ -151,6 +157,10 @@ getHostDetails().put(RouterPrivateIpStrategy.class.getCanonicalName(), privIpStr
|
|||
public Map<String, VmState> getVmStates() {
|
||||
return vms;
|
||||
}
|
||||
|
||||
public HashMap<String, Pair<String, State>> getClusterVMStateChanges() {
|
||||
return _clusterVMStates;
|
||||
}
|
||||
|
||||
public void setSpeed(long speed) {
|
||||
this.speed = speed;
|
||||
|
|
|
|||
|
|
@ -4032,6 +4032,20 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
|
|||
cmd.setHypervisorType(HypervisorType.XenServer);
|
||||
cmd.setCluster(_cluster);
|
||||
cmd.setPoolSync(false);
|
||||
|
||||
Pool pool;
|
||||
try {
|
||||
pool = Pool.getByUuid(conn, _host.pool);
|
||||
Pool.Record poolr = pool.getRecord(conn);
|
||||
|
||||
Host.Record hostr = poolr.master.getRecord(conn);
|
||||
if (_host.uuid.equals(hostr.uuid)) {
|
||||
HashMap<String, Pair<String, State>> allStates=fullClusterSync(conn);
|
||||
cmd.setClusterVMStateChanges(allStates);
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
s_logger.warn("Check for master failed, failing the FULL Cluster sync command");
|
||||
}
|
||||
|
||||
StartupStorageCommand sscmd = initializeLocalSR(conn);
|
||||
if (sscmd != null) {
|
||||
|
|
@ -6590,17 +6604,11 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
|
|||
return new Answer(cmd);
|
||||
}
|
||||
HashMap<String, Pair<String, State>> newStates = deltaClusterSync(conn);
|
||||
cmd.incrStep();
|
||||
if (cmd.isRightStep()){
|
||||
cmd.incrStep();
|
||||
// do full sync
|
||||
HashMap<String, Pair<String, State>> allStates=fullClusterSync(conn);
|
||||
if (cmd.isInit()){
|
||||
cmd.unsetInit();
|
||||
return new ClusterSyncAnswer(cmd.getClusterId(), newStates, allStates, true);
|
||||
}
|
||||
else {
|
||||
return new ClusterSyncAnswer(cmd.getClusterId(), newStates, allStates);
|
||||
}
|
||||
return new ClusterSyncAnswer(cmd.getClusterId(), newStates, allStates);
|
||||
}
|
||||
else {
|
||||
cmd.incrStep();
|
||||
|
|
|
|||
|
|
@ -2092,9 +2092,6 @@ public class VirtualMachineManagerImpl implements VirtualMachineManager, Listene
|
|||
} else if (hs.isDelta()){
|
||||
deltaSync(hs.getNewStates());
|
||||
}
|
||||
else {
|
||||
fullSync(hs.getClusterId(), hs.getAllStates(), true);
|
||||
}
|
||||
hs.setExecuted();
|
||||
}
|
||||
} else if (!answer.getResult()) {
|
||||
|
|
@ -2169,6 +2166,13 @@ public class VirtualMachineManagerImpl implements VirtualMachineManager, Listene
|
|||
Long clusterId = agent.getClusterId();
|
||||
long agentId = agent.getId();
|
||||
if (agent.getHypervisorType() == HypervisorType.XenServer) { // only for Xen
|
||||
StartupRoutingCommand startup = (StartupRoutingCommand) cmd;
|
||||
HashMap<String, Pair<String, State>> allStates = startup.getClusterVMStateChanges();
|
||||
if (allStates != null){
|
||||
this.fullSync(clusterId, allStates, true);
|
||||
}
|
||||
|
||||
// initiate the cron job
|
||||
ClusterSyncCommand syncCmd = new ClusterSyncCommand(Integer.parseInt(Config.ClusterDeltaSyncInterval.getDefaultValue()),
|
||||
Integer.parseInt(Config.ClusterFullSyncSkipSteps.getDefaultValue()), clusterId);
|
||||
try {
|
||||
|
|
|
|||
Loading…
Reference in New Issue