From b3491bcbac9bbd0e20999a0983bca69dab5daf0b Mon Sep 17 00:00:00 2001 From: Anthony Xu Date: Thu, 1 May 2014 11:45:19 -0700 Subject: [PATCH] removed unused command ClusterSyncCommand --- .../cloud/agent/api/ClusterSyncAnswer.java | 54 ------------------ .../cloud/agent/api/ClusterSyncCommand.java | 46 ---------------- .../com/cloud/agent/manager/AgentAttache.java | 3 +- .../cloud/vm/VirtualMachineManagerImpl.java | 55 +------------------ .../agent/manager/SimulatorManagerImpl.java | 3 - .../xen/resource/CitrixResourceBase.java | 25 --------- .../xenserver/XenServerResourceNewBase.java | 13 ----- 7 files changed, 2 insertions(+), 197 deletions(-) delete mode 100644 core/src/com/cloud/agent/api/ClusterSyncAnswer.java delete mode 100644 core/src/com/cloud/agent/api/ClusterSyncCommand.java diff --git a/core/src/com/cloud/agent/api/ClusterSyncAnswer.java b/core/src/com/cloud/agent/api/ClusterSyncAnswer.java deleted file mode 100644 index 7b8a525b69e..00000000000 --- a/core/src/com/cloud/agent/api/ClusterSyncAnswer.java +++ /dev/null @@ -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> _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> newStates) { - _clusterId = clusterId; - _newStates = newStates; - result = true; - } - - public long getClusterId() { - return _clusterId; - } - - public HashMap> getNewStates() { - return _newStates; - } - -} diff --git a/core/src/com/cloud/agent/api/ClusterSyncCommand.java b/core/src/com/cloud/agent/api/ClusterSyncCommand.java deleted file mode 100644 index 6a2749104de..00000000000 --- a/core/src/com/cloud/agent/api/ClusterSyncCommand.java +++ /dev/null @@ -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; - } - -} diff --git a/engine/orchestration/src/com/cloud/agent/manager/AgentAttache.java b/engine/orchestration/src/com/cloud/agent/manager/AgentAttache.java index fd1531e25a6..ebf9366eb2c 100755 --- a/engine/orchestration/src/com/cloud/agent/manager/AgentAttache.java +++ b/engine/orchestration/src/com/cloud/agent/manager/AgentAttache.java @@ -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 { diff --git a/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java b/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java index b7978754d33..e15d28700ff 100755 --- a/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java +++ b/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java @@ -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> newStates) { - Map states = convertToInfos(newStates); - - for (Map.Entry 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 : " + 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> 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); diff --git a/plugins/hypervisors/simulator/src/com/cloud/agent/manager/SimulatorManagerImpl.java b/plugins/hypervisors/simulator/src/com/cloud/agent/manager/SimulatorManagerImpl.java index 3bc689e383b..321f06fa4f7 100644 --- a/plugins/hypervisors/simulator/src/com/cloud/agent/manager/SimulatorManagerImpl.java +++ b/plugins/hypervisors/simulator/src/com/cloud/agent/manager/SimulatorManagerImpl.java @@ -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) { diff --git a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java index 6ba7fae6c17..e3fbe2e0e90 100644 --- a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java +++ b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java @@ -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> newStates = deltaClusterSync(conn); - return new ClusterSyncAnswer(cmd.getClusterId(), newStates); - } - - protected ClusterVMMetaDataSyncAnswer execute(final ClusterVMMetaDataSyncCommand cmd) { Connection conn = getConnection(); //check if this is master diff --git a/plugins/hypervisors/xen/src/org/apache/cloudstack/hypervisor/xenserver/XenServerResourceNewBase.java b/plugins/hypervisors/xen/src/org/apache/cloudstack/hypervisor/xenserver/XenServerResourceNewBase.java index 4a039c6bbcd..0b3bca81755 100644 --- a/plugins/hypervisors/xen/src/org/apache/cloudstack/hypervisor/xenserver/XenServerResourceNewBase.java +++ b/plugins/hypervisors/xen/src/org/apache/cloudstack/hypervisor/xenserver/XenServerResourceNewBase.java @@ -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> newStates = _listener.getChanges(); - return new ClusterSyncAnswer(cmd.getClusterId(), newStates); - } - protected class VmEventListener extends Thread { boolean _stop = false; HashMap> _changes = new HashMap>();