mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
removed unused command ClusterSyncCommand
This commit is contained in:
parent
537536835b
commit
b3491bcbac
@ -1,54 +0,0 @@
|
||||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
package com.cloud.agent.api;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import com.cloud.utils.Pair;
|
||||
import com.cloud.vm.VirtualMachine.State;
|
||||
|
||||
public class ClusterSyncAnswer extends Answer {
|
||||
private long _clusterId;
|
||||
private HashMap<String, Pair<String, State>> _newStates;
|
||||
private boolean _isExecuted = false;
|
||||
|
||||
// this is here because a cron command answer is being sent twice
|
||||
// AgentAttache.processAnswers
|
||||
// AgentManagerImpl.notifyAnswersToMonitors
|
||||
public boolean isExecuted() {
|
||||
return _isExecuted;
|
||||
}
|
||||
|
||||
public void setExecuted() {
|
||||
_isExecuted = true;
|
||||
}
|
||||
|
||||
public ClusterSyncAnswer(long clusterId, HashMap<String, Pair<String, State>> newStates) {
|
||||
_clusterId = clusterId;
|
||||
_newStates = newStates;
|
||||
result = true;
|
||||
}
|
||||
|
||||
public long getClusterId() {
|
||||
return _clusterId;
|
||||
}
|
||||
|
||||
public HashMap<String, Pair<String, State>> getNewStates() {
|
||||
return _newStates;
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,46 +0,0 @@
|
||||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
package com.cloud.agent.api;
|
||||
|
||||
public class ClusterSyncCommand extends Command implements CronCommand {
|
||||
int _interval;
|
||||
|
||||
long _clusterId;
|
||||
|
||||
public ClusterSyncCommand() {
|
||||
}
|
||||
|
||||
public ClusterSyncCommand(int interval, long clusterId) {
|
||||
_interval = interval;
|
||||
_clusterId = clusterId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInterval() {
|
||||
return _interval;
|
||||
}
|
||||
|
||||
public long getClusterId() {
|
||||
return _clusterId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean executeInSequence() {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@ -41,7 +41,6 @@ import com.cloud.agent.api.CheckHealthCommand;
|
||||
import com.cloud.agent.api.CheckNetworkCommand;
|
||||
import com.cloud.agent.api.CheckVirtualMachineCommand;
|
||||
import com.cloud.agent.api.CleanupNetworkRulesCmd;
|
||||
import com.cloud.agent.api.ClusterSyncCommand;
|
||||
import com.cloud.agent.api.Command;
|
||||
import com.cloud.agent.api.MaintainCommand;
|
||||
import com.cloud.agent.api.MigrateCommand;
|
||||
@ -113,7 +112,7 @@ public abstract class AgentAttache {
|
||||
|
||||
public final static String[] s_commandsAllowedInMaintenanceMode = new String[] {MaintainCommand.class.toString(), MigrateCommand.class.toString(),
|
||||
StopCommand.class.toString(), CheckVirtualMachineCommand.class.toString(), PingTestCommand.class.toString(), CheckHealthCommand.class.toString(),
|
||||
ReadyCommand.class.toString(), ShutdownCommand.class.toString(), SetupCommand.class.toString(), ClusterSyncCommand.class.toString(),
|
||||
ReadyCommand.class.toString(), ShutdownCommand.class.toString(), SetupCommand.class.toString(),
|
||||
CleanupNetworkRulesCmd.class.toString(), CheckNetworkCommand.class.toString(), PvlanSetupCommand.class.toString()};
|
||||
protected final static String[] s_commandsNotAllowedInConnectingMode = new String[] {StartCommand.class.toString(), CreateCommand.class.toString()};
|
||||
static {
|
||||
|
||||
@ -77,8 +77,6 @@ import com.cloud.agent.api.AgentControlCommand;
|
||||
import com.cloud.agent.api.Answer;
|
||||
import com.cloud.agent.api.CheckVirtualMachineAnswer;
|
||||
import com.cloud.agent.api.CheckVirtualMachineCommand;
|
||||
import com.cloud.agent.api.ClusterSyncAnswer;
|
||||
import com.cloud.agent.api.ClusterSyncCommand;
|
||||
import com.cloud.agent.api.ClusterVMMetaDataSyncAnswer;
|
||||
import com.cloud.agent.api.ClusterVMMetaDataSyncCommand;
|
||||
import com.cloud.agent.api.Command;
|
||||
@ -2602,41 +2600,6 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
||||
}
|
||||
}
|
||||
|
||||
public void deltaSync(Map<String, Pair<String, State>> newStates) {
|
||||
Map<Long, AgentVmInfo> states = convertToInfos(newStates);
|
||||
|
||||
for (Map.Entry<Long, AgentVmInfo> entry : states.entrySet()) {
|
||||
AgentVmInfo info = entry.getValue();
|
||||
VMInstanceVO vm = info.vm;
|
||||
Command command = null;
|
||||
if (vm != null) {
|
||||
Host host = _resourceMgr.findHostByGuid(info.getHostUuid());
|
||||
long hId = host.getId();
|
||||
|
||||
HypervisorGuru hvGuru = _hvGuruMgr.getGuru(vm.getHypervisorType());
|
||||
command = compareState(hId, vm, info, false, hvGuru.trackVmHostChange());
|
||||
} else {
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Cleaning up a VM that is no longer found <deltaSync>: " + info.name);
|
||||
}
|
||||
command = cleanup(info.name);
|
||||
}
|
||||
if (command != null) {
|
||||
try {
|
||||
Host host = _resourceMgr.findHostByGuid(info.getHostUuid());
|
||||
if (host != null) {
|
||||
Answer answer = _agentMgr.send(host.getId(), cleanup(info.name));
|
||||
if (!answer.getResult()) {
|
||||
s_logger.warn("Unable to stop a VM due to " + answer.getDetails());
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
s_logger.warn("Unable to stop a VM due to " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void fullSync(final long clusterId, Map<String, Pair<String, State>> newStates) {
|
||||
if (newStates == null)
|
||||
return;
|
||||
@ -3077,15 +3040,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
||||
@Override
|
||||
public boolean processAnswers(long agentId, long seq, Answer[] answers) {
|
||||
for (final Answer answer : answers) {
|
||||
if (answer instanceof ClusterSyncAnswer) {
|
||||
if (!VmJobEnabled.value()) {
|
||||
ClusterSyncAnswer hs = (ClusterSyncAnswer)answer;
|
||||
if (!hs.isExecuted()) {
|
||||
deltaSync(hs.getNewStates());
|
||||
hs.setExecuted();
|
||||
}
|
||||
}
|
||||
} else if ( answer instanceof ClusterVMMetaDataSyncAnswer) {
|
||||
if ( answer instanceof ClusterVMMetaDataSyncAnswer) {
|
||||
ClusterVMMetaDataSyncAnswer cvms = (ClusterVMMetaDataSyncAnswer)answer;
|
||||
if (!cvms.isExecuted()) {
|
||||
syncVMMetaData(cvms.getVMMetaDatum());
|
||||
@ -3182,14 +3137,6 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
||||
if (allStates != null) {
|
||||
fullSync(clusterId, allStates);
|
||||
}
|
||||
// initiate the cron job
|
||||
ClusterSyncCommand syncCmd = new ClusterSyncCommand(ClusterDeltaSyncInterval.value(), clusterId);
|
||||
try {
|
||||
long seq_no = _agentMgr.send(agentId, new Commands(syncCmd), this);
|
||||
s_logger.debug("Cluster VM sync started with jobid " + seq_no);
|
||||
} catch (AgentUnavailableException e) {
|
||||
s_logger.fatal("The Cluster VM sync process failed for cluster id " + clusterId + " with ", e);
|
||||
}
|
||||
}
|
||||
// initiate the cron job
|
||||
ClusterVMMetaDataSyncCommand syncVMMetaDataCmd = new ClusterVMMetaDataSyncCommand(ClusterVMMetaDataSyncInterval.value(), clusterId);
|
||||
|
||||
@ -46,7 +46,6 @@ import com.cloud.agent.api.CheckRouterCommand;
|
||||
import com.cloud.agent.api.CheckS2SVpnConnectionsCommand;
|
||||
import com.cloud.agent.api.CheckVirtualMachineCommand;
|
||||
import com.cloud.agent.api.CleanupNetworkRulesCmd;
|
||||
import com.cloud.agent.api.ClusterSyncCommand;
|
||||
import com.cloud.agent.api.Command;
|
||||
import com.cloud.agent.api.ComputeChecksumCommand;
|
||||
import com.cloud.agent.api.CreatePrivateTemplateFromSnapshotCommand;
|
||||
@ -373,8 +372,6 @@ public class SimulatorManagerImpl extends ManagerBase implements SimulatorManage
|
||||
answer = _mockVmMgr.bumpPriority((BumpUpPriorityCommand)cmd);
|
||||
} else if (cmd instanceof GetDomRVersionCmd) {
|
||||
answer = _mockVmMgr.getDomRVersion((GetDomRVersionCmd)cmd);
|
||||
} else if (cmd instanceof ClusterSyncCommand) {
|
||||
answer = new Answer(cmd);
|
||||
} else if (cmd instanceof CopyVolumeCommand) {
|
||||
answer = _mockStorageMgr.CopyVolume((CopyVolumeCommand)cmd);
|
||||
} else if (cmd instanceof PlugNicCommand) {
|
||||
|
||||
@ -30,8 +30,6 @@ import com.cloud.agent.api.CheckOnHostCommand;
|
||||
import com.cloud.agent.api.CheckVirtualMachineAnswer;
|
||||
import com.cloud.agent.api.CheckVirtualMachineCommand;
|
||||
import com.cloud.agent.api.CleanupNetworkRulesCmd;
|
||||
import com.cloud.agent.api.ClusterSyncAnswer;
|
||||
import com.cloud.agent.api.ClusterSyncCommand;
|
||||
import com.cloud.agent.api.ClusterVMMetaDataSyncAnswer;
|
||||
import com.cloud.agent.api.ClusterVMMetaDataSyncCommand;
|
||||
import com.cloud.agent.api.Command;
|
||||
@ -528,8 +526,6 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
|
||||
return execute((OvsDestroyTunnelCommand)cmd);
|
||||
} else if (clazz == UpdateHostPasswordCommand.class) {
|
||||
return execute((UpdateHostPasswordCommand)cmd);
|
||||
} else if (cmd instanceof ClusterSyncCommand) {
|
||||
return execute((ClusterSyncCommand)cmd);
|
||||
} else if (cmd instanceof ClusterVMMetaDataSyncCommand) {
|
||||
return execute((ClusterVMMetaDataSyncCommand)cmd);
|
||||
} else if (clazz == CheckNetworkCommand.class) {
|
||||
@ -7173,27 +7169,6 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
|
||||
return new Answer(cmd, success, "");
|
||||
}
|
||||
|
||||
protected Answer execute(final ClusterSyncCommand cmd) {
|
||||
Connection conn = getConnection();
|
||||
//check if this is master
|
||||
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)) {
|
||||
return new Answer(cmd);
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
s_logger.warn("Check for master failed, failing the Cluster sync command");
|
||||
return new Answer(cmd);
|
||||
}
|
||||
HashMap<String, Pair<String, State>> newStates = deltaClusterSync(conn);
|
||||
return new ClusterSyncAnswer(cmd.getClusterId(), newStates);
|
||||
}
|
||||
|
||||
|
||||
protected ClusterVMMetaDataSyncAnswer execute(final ClusterVMMetaDataSyncCommand cmd) {
|
||||
Connection conn = getConnection();
|
||||
//check if this is master
|
||||
|
||||
@ -35,9 +35,6 @@ import com.xensource.xenapi.Types;
|
||||
import com.xensource.xenapi.Types.XenAPIException;
|
||||
import com.xensource.xenapi.VM;
|
||||
|
||||
import com.cloud.agent.api.Answer;
|
||||
import com.cloud.agent.api.ClusterSyncAnswer;
|
||||
import com.cloud.agent.api.ClusterSyncCommand;
|
||||
import com.cloud.agent.api.StartupCommand;
|
||||
import com.cloud.hypervisor.xen.resource.XenServer620SP1Resource;
|
||||
import com.cloud.utils.Pair;
|
||||
@ -152,16 +149,6 @@ public class XenServerResourceNewBase extends XenServer620SP1Resource {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected Answer execute(final ClusterSyncCommand cmd) {
|
||||
if (!_listener.isListening()) {
|
||||
return new Answer(cmd);
|
||||
}
|
||||
|
||||
HashMap<String, Pair<String, VirtualMachine.State>> newStates = _listener.getChanges();
|
||||
return new ClusterSyncAnswer(cmd.getClusterId(), newStates);
|
||||
}
|
||||
|
||||
protected class VmEventListener extends Thread {
|
||||
boolean _stop = false;
|
||||
HashMap<String, Pair<String, VirtualMachine.State>> _changes = new HashMap<String, Pair<String, VirtualMachine.State>>();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user