cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From anthon...@apache.org
Subject [1/3] completed the new vmsync TODOs in the code. removed old vmsync logic
Date Mon, 28 Jul 2014 19:52:42 GMT
Repository: cloudstack
Updated Branches:
  refs/heads/master acc9c7937 -> 330c4ba57


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/330c4ba5/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/CitrixResourceBase.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/CitrixResourceBase.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/CitrixResourceBase.java
index 4fa0456..775f5455 100644
--- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/CitrixResourceBase.java
+++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/CitrixResourceBase.java
@@ -244,7 +244,6 @@ import com.cloud.utils.ssh.SshHelper;
 import com.cloud.vm.DiskProfile;
 import com.cloud.vm.VirtualMachine;
 import com.cloud.vm.VirtualMachine.PowerState;
-import com.cloud.vm.VirtualMachine.State;
 import com.cloud.vm.snapshot.VMSnapshot;
 
 /**
@@ -271,7 +270,6 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
     protected long _dcId;
     protected String _pod;
     protected String _cluster;
-    protected static final XenServerPoolVms s_vms = new XenServerPoolVms();
     protected String _privateNetworkName;
     protected String _linkLocalPrivateNetworkName;
     protected String _publicNetworkName;
@@ -328,29 +326,16 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
         }
     }
 
-    protected static final HashMap<Types.VmPowerState, PowerState> s_powerStatesTable;
+    protected static final HashMap<VmPowerState, PowerState> s_powerStatesTable;
     static {
-        s_powerStatesTable = new HashMap<Types.VmPowerState, PowerState>();
-        s_powerStatesTable.put(Types.VmPowerState.HALTED, PowerState.PowerOff);
-        s_powerStatesTable.put(Types.VmPowerState.PAUSED, PowerState.PowerOff);
-        s_powerStatesTable.put(Types.VmPowerState.RUNNING, PowerState.PowerOn);
-        s_powerStatesTable.put(Types.VmPowerState.SUSPENDED, PowerState.PowerOff);
-        s_powerStatesTable.put(Types.VmPowerState.UNRECOGNIZED, PowerState.PowerUnknown);
+        s_powerStatesTable = new HashMap<VmPowerState, PowerState>();
+        s_powerStatesTable.put(VmPowerState.HALTED, PowerState.PowerOff);
+        s_powerStatesTable.put(VmPowerState.PAUSED, PowerState.PowerOff);
+        s_powerStatesTable.put(VmPowerState.RUNNING, PowerState.PowerOn);
+        s_powerStatesTable.put(VmPowerState.SUSPENDED, PowerState.PowerOff);
+        s_powerStatesTable.put(VmPowerState.UNRECOGNIZED, PowerState.PowerUnknown);
     }
 
-    // TODO vmsync {
-    protected static final HashMap<Types.VmPowerState, State> s_statesTable;
-    static {
-        s_statesTable = new HashMap<Types.VmPowerState, State>();
-        s_statesTable.put(Types.VmPowerState.HALTED, State.Stopped);
-        s_statesTable.put(Types.VmPowerState.PAUSED, State.Running);
-        s_statesTable.put(Types.VmPowerState.RUNNING, State.Running);
-        s_statesTable.put(Types.VmPowerState.SUSPENDED, State.Running);
-        s_statesTable.put(Types.VmPowerState.UNRECOGNIZED, State.Unknown);
-    }
-
-    // TODO vmsync }
-
     public XsHost getHost() {
         return _host;
     }
@@ -790,13 +775,10 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
         VMSnapshot.Type vmSnapshotType = cmd.getTarget().getType();
         Boolean snapshotMemory = vmSnapshotType == VMSnapshot.Type.DiskAndMemory;
         Connection conn = getConnection();
-        VirtualMachine.State vmState = null;
+        PowerState vmState = null;
         VM vm = null;
         try {
 
-            // remove vm from s_vms, for delta sync
-            s_vms.remove(_cluster, _name, vmName);
-
             Set<VM> vmSnapshots = VM.getByNameLabel(conn, cmd.getTarget().getSnapshotName());
             if (vmSnapshots.size() == 0)
                 return new RevertToVMSnapshotAnswer(cmd, false, "Cannot find vmSnapshot with name: " + cmd.getTarget().getSnapshotName());
@@ -830,10 +812,9 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
 
             if (!snapshotMemory) {
                 vm.destroy(conn);
-                vmState = VirtualMachine.State.Stopped;
+                vmState = PowerState.PowerOff;
             } else {
-                s_vms.put(_cluster, _name, vmName, State.Running);
-                vmState = VirtualMachine.State.Running;
+                vmState = PowerState.PowerOn;
             }
 
             // after revert, VM's volumes path have been changed, need to report to manager
@@ -1710,7 +1691,7 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
         Connection conn = getConnection();
         VirtualMachineTO vmSpec = cmd.getVirtualMachine();
         String vmName = vmSpec.getName();
-        State state = State.Stopped;
+        VmPowerState state = VmPowerState.HALTED;
         VM vm = null;
         // if a VDI is created, record its UUID to send back to the CS MS
         Map<String, String> iqnToPath = new HashMap<String, String>();
@@ -1733,9 +1714,6 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
                     }
                 }
             }
-            synchronized (_cluster.intern()) {
-                s_vms.put(_cluster, _name, vmName, State.Starting);
-            }
             s_logger.debug("1. The VM " + vmName + " is in Starting state.");
 
             Host host = Host.getByUuid(conn, _host.uuid);
@@ -1839,7 +1817,7 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
                 }
             }
 
-            state = State.Running;
+            state = VmPowerState.RUNNING;
 
             StartAnswer startAnswer = new StartAnswer(cmd);
 
@@ -1856,14 +1834,10 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
 
             return startAnswer;
         } finally {
-            synchronized (_cluster.intern()) {
-                if (state != State.Stopped) {
-                    s_vms.put(_cluster, _name, vmName, state);
-                    s_logger.debug("2. The VM " + vmName + " is in " + state + " state.");
-                } else {
-                    s_vms.remove(_cluster, _name, vmName);
-                    s_logger.debug("The VM is in stopped state, detected problem during startup : " + vmName);
-                }
+            if (state != VmPowerState.HALTED) {
+                s_logger.debug("2. The VM " + vmName + " is in " + state + " state.");
+            } else {
+                s_logger.debug("The VM is in stopped state, detected problem during startup : " + vmName);
             }
         }
     }
@@ -2575,13 +2549,9 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
 
     }
 
-    protected State convertToState(Types.VmPowerState ps) {
-        final State state = s_statesTable.get(ps);
-        return state == null ? State.Unknown : state;
-    }
-
-    private static PowerState convertPowerState(Types.VmPowerState powerState) {
-        return s_powerStatesTable.get(powerState);
+    private static PowerState convertToPowerState(VmPowerState ps) {
+        final PowerState powerState = s_powerStatesTable.get(ps);
+        return powerState == null ?  PowerState.PowerUnknown : powerState;
     }
 
     protected HashMap<String, HostVmStateReportEntry> getHostVmStateReport(Connection conn) {
@@ -2629,7 +2599,7 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
                 if (host_uuid.equalsIgnoreCase(_host.uuid)) {
                     vmStates.put(
                             record.nameLabel,
-                            new HostVmStateReportEntry(convertPowerState(ps), host_uuid)
+                            new HostVmStateReportEntry(convertToPowerState(ps), host_uuid)
                             );
                 }
             }
@@ -2638,65 +2608,13 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
         return vmStates;
     }
 
-    // TODO vmsync {
-    protected HashMap<String, Pair<String, State>> getAllVms(Connection conn) {
-        final HashMap<String, Pair<String, State>> vmStates = new HashMap<String, Pair<String, State>>();
-        Map<VM, VM.Record> vm_map = null;
-        for (int i = 0; i < 2; i++) {
-            try {
-                vm_map = VM.getAllRecords(conn);  //USE THIS TO GET ALL VMS FROM  A CLUSTER
-                break;
-            } catch (final Throwable e) {
-                s_logger.warn("Unable to get vms", e);
-            }
-            try {
-                Thread.sleep(1000);
-            } catch (final InterruptedException ex) {
-
-            }
-        }
-
-        if (vm_map == null) {
-            return null;
-        }
-        for (VM.Record record : vm_map.values()) {
-            if (record.isControlDomain || record.isASnapshot || record.isATemplate) {
-                continue; // Skip DOM0
-            }
-
-            VmPowerState ps = record.powerState;
-            final State state = convertToState(ps);
-            if (s_logger.isTraceEnabled()) {
-                s_logger.trace("VM " + record.nameLabel + ": powerstate = " + ps + "; vm state=" + state.toString());
-            }
-            Host host = record.residentOn;
-            String host_uuid = null;
-            if (!isRefNull(host)) {
-                try {
-                    host_uuid = host.getUuid(conn);
-                } catch (BadServerResponse e) {
-                    s_logger.error("Failed to get host uuid for host " + host.toWireString(), e);
-                } catch (XenAPIException e) {
-                    s_logger.error("Failed to get host uuid for host " + host.toWireString(), e);
-                } catch (XmlRpcException e) {
-                    s_logger.error("Failed to get host uuid for host " + host.toWireString(), e);
-                }
-                vmStates.put(record.nameLabel, new Pair<String, State>(host_uuid, state));
-            }
-        }
-
-        return vmStates;
-    }
-
-    // TODO vmsync }
-
-    protected State getVmState(Connection conn, final String vmName) {
+    protected PowerState getVmState(Connection conn, final String vmName) {
         int retry = 3;
         while (retry-- > 0) {
             try {
                 Set<VM> vms = VM.getByNameLabel(conn, vmName);
                 for (final VM vm : vms) {
-                    return convertToState(vm.getPowerState(conn));
+                    return convertToPowerState(vm.getPowerState(conn));
                 }
             } catch (final BadServerResponse e) {
                 // There is a race condition within xenserver such that if a vm is
@@ -2727,22 +2645,19 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
             }
         }
 
-        return State.Stopped;
+        return PowerState.PowerOff;
     }
 
     protected CheckVirtualMachineAnswer execute(final CheckVirtualMachineCommand cmd) {
         Connection conn = getConnection();
         final String vmName = cmd.getVmName();
-        final State state = getVmState(conn, vmName);
+        final PowerState powerState = getVmState(conn, vmName);
         Integer vncPort = null;
-        if (state == State.Running) {
-            synchronized (_cluster.intern()) {
-                s_vms.put(_cluster, _name, vmName, State.Running);
-            }
+        if (powerState == PowerState.PowerOn) {
             s_logger.debug("3. The VM " + vmName + " is in Running state");
         }
 
-        return new CheckVirtualMachineAnswer(cmd, state, vncPort);
+        return new CheckVirtualMachineAnswer(cmd, powerState, vncPort);
     }
 
     protected PrepareForMigrationAnswer execute(PrepareForMigrationCommand cmd) {
@@ -2760,9 +2675,6 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
             for (NicTO nic : nics) {
                 getNetwork(conn, nic);
             }
-            synchronized (_cluster.intern()) {
-                s_vms.put(_cluster, _name, vm.getName(), State.Migrating);
-            }
             s_logger.debug("4. The VM " + vm.getName() + " is in Migrating state");
 
             return new PrepareForMigrationAnswer(cmd);
@@ -3000,14 +2912,7 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
     protected MigrateAnswer execute(final MigrateCommand cmd) {
         Connection conn = getConnection();
         final String vmName = cmd.getVmName();
-        State state = null;
-
-        state = s_vms.getState(_cluster, vmName);
 
-        synchronized (_cluster.intern()) {
-            s_vms.put(_cluster, _name, vmName, State.Stopping);
-        }
-        s_logger.debug("5. The VM " + vmName + " is in Stopping state");
         try {
             Set<VM> vms = VM.getByNameLabel(conn, vmName);
 
@@ -3037,54 +2942,16 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
                 }
                 migrateVM(conn, dsthost, vm, vmName);
                 vm.setAffinity(conn, dsthost);
-                state = State.Stopping;
             }
             return new MigrateAnswer(cmd, true, "migration succeeded", null);
         } catch (Exception e) {
             String msg = "Catch Exception " + e.getClass().getName() + ": Migration failed due to " + e.toString();
             s_logger.warn(msg, e);
             return new MigrateAnswer(cmd, false, msg, null);
-        } finally {
-            synchronized (_cluster.intern()) {
-                s_vms.put(_cluster, _name, vmName, state);
-            }
-            s_logger.debug("6. The VM " + vmName + " is in " + state + " state");
         }
 
     }
 
-    protected State getRealPowerState(Connection conn, String label) {
-        int i = 0;
-        s_logger.trace("Checking on the HALTED State");
-        for (; i < 20; i++) {
-            try {
-                Set<VM> vms = VM.getByNameLabel(conn, label);
-                if (vms == null || vms.size() == 0) {
-                    continue;
-                }
-
-                VM vm = vms.iterator().next();
-
-                VmPowerState vps = vm.getPowerState(conn);
-                if (vps != null && vps != VmPowerState.HALTED && vps != VmPowerState.UNRECOGNIZED) {
-                    return convertToState(vps);
-                }
-            } catch (XenAPIException e) {
-                String msg = "Unable to get real power state due to " + e.toString();
-                s_logger.warn(msg, e);
-            } catch (XmlRpcException e) {
-                String msg = "Unable to get real power state due to " + e.getMessage();
-                s_logger.warn(msg, e);
-            }
-
-            try {
-                Thread.sleep(1000);
-            } catch (InterruptedException e) {
-            }
-        }
-        return State.Stopped;
-    }
-
     protected Pair<VM, VM.Record> getControlDomain(Connection conn) throws XenAPIException, XmlRpcException {
         Host host = Host.getByUuid(conn, _host.uuid);
         Set<VM> vms = null;
@@ -3172,9 +3039,6 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
     @Override
     public RebootAnswer execute(RebootCommand cmd) {
         Connection conn = getConnection();
-        synchronized (_cluster.intern()) {
-            s_vms.put(_cluster, _name, cmd.getVmName(), State.Starting);
-        }
         s_logger.debug("7. The VM " + cmd.getVmName() + " is in Starting state");
         try {
             Set<VM> vms = null;
@@ -3198,9 +3062,6 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
             }
             return new RebootAnswer(cmd, "reboot succeeded", true);
         } finally {
-            synchronized (_cluster.intern()) {
-                s_vms.put(_cluster, _name, cmd.getVmName(), State.Running);
-            }
             s_logger.debug("8. The VM " + cmd.getVmName() + " is in Running state");
         }
     }
@@ -3342,7 +3203,7 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
                 waitForTask(conn, task, 1000, 10 * 60 * 1000);
                 checkForSuccess(conn, task);
             } catch (Types.HandleInvalid e) {
-                if (vm.getPowerState(conn) == Types.VmPowerState.RUNNING) {
+                if (vm.getPowerState(conn) == VmPowerState.RUNNING) {
                     task = null;
                     return;
                 }
@@ -3390,7 +3251,7 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
                 waitForTask(conn, task, 1000, 10 * 60 * 1000);
                 checkForSuccess(conn, task);
             } catch (TimeoutException e) {
-                if (vm.getPowerState(conn) == Types.VmPowerState.HALTED) {
+                if (vm.getPowerState(conn) == VmPowerState.HALTED) {
                     task = null;
                     return;
                 }
@@ -3399,19 +3260,19 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
         } catch (XenAPIException e) {
             s_logger.debug("Unable to cleanShutdown VM(" + vmName + ") on host(" + _host.uuid + ") due to " + e.toString());
             try {
-                Types.VmPowerState state = vm.getPowerState(conn);
-                if (state == Types.VmPowerState.RUNNING) {
+                VmPowerState state = vm.getPowerState(conn);
+                if (state == VmPowerState.RUNNING) {
                     try {
                         vm.hardShutdown(conn);
                     } catch (Exception e1) {
                         s_logger.debug("Unable to hardShutdown VM(" + vmName + ") on host(" + _host.uuid + ") due to " + e.toString());
                         state = vm.getPowerState(conn);
-                        if (state == Types.VmPowerState.RUNNING) {
+                        if (state == VmPowerState.RUNNING) {
                             forceShutdownVM(conn, vm);
                         }
                         return;
                     }
-                } else if (state == Types.VmPowerState.HALTED) {
+                } else if (state == VmPowerState.HALTED) {
                     return;
                 } else {
                     String msg = "After cleanShutdown the VM status is " + state.toString() + ", that is not expected";
@@ -3443,14 +3304,14 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
                 waitForTask(conn, task, 1000, 10 * 60 * 1000);
                 checkForSuccess(conn, task);
             } catch (Types.HandleInvalid e) {
-                if (vm.getPowerState(conn) == Types.VmPowerState.RUNNING) {
+                if (vm.getPowerState(conn) == VmPowerState.RUNNING) {
                     s_logger.debug("VM " + vmName + " is in Running status");
                     task = null;
                     return;
                 }
                 throw new CloudRuntimeException("Start VM " + vmName + " catch HandleInvalid and VM is not in RUNNING state");
             } catch (TimeoutException e) {
-                if (vm.getPowerState(conn) == Types.VmPowerState.RUNNING) {
+                if (vm.getPowerState(conn) == VmPowerState.RUNNING) {
                     s_logger.debug("VM " + vmName + " is in Running status");
                     task = null;
                     return;
@@ -3593,10 +3454,6 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
             }
 
             if (vms.size() == 0) {
-                synchronized (_cluster.intern()) {
-                    s_logger.info("VM does not exist on XenServer" + _host.uuid);
-                    s_vms.remove(_cluster, _name, vmName);
-                }
                 return new StopAnswer(cmd, "VM does not exist", true);
             }
             for (VM vm : vms) {
@@ -3620,11 +3477,6 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
                     return new StopAnswer(cmd, msg, false);
                 }
 
-                State state = s_vms.getState(_cluster, vmName);
-
-                synchronized (_cluster.intern()) {
-                    s_vms.put(_cluster, _name, vmName, State.Stopping);
-                }
                 s_logger.debug("9. The VM " + vmName + " is in Stopping state");
 
                 try {
@@ -3668,7 +3520,6 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
                                 networks.add(vif.getNetwork(conn));
                             }
                             vm.destroy(conn);
-                            state = State.Stopped;
                             SR sr = getISOSRbyVmName(conn, cmd.getVmName());
                             removeSR(conn, sr);
                             // Disable any VLAN networks that aren't used
@@ -3688,10 +3539,7 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
                         String msg = "VM destroy failed in Stop " + vmName + " Command due to " + e.getMessage();
                         s_logger.warn(msg, e);
                     } finally {
-                        synchronized (_cluster.intern()) {
-                            s_vms.put(_cluster, _name, vmName, state);
-                        }
-                        s_logger.debug("10. The VM " + vmName + " is in " + state + " state");
+                        s_logger.debug("10. The VM " + vmName + " is in Stopped state");
                     }
                 }
             }
@@ -4317,13 +4165,13 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
             }
             Connection conn = getConnection();
             if (!_canBridgeFirewall && !_isOvs) {
-                return new PingRoutingCommand(getType(), id, null, getHostVmStateReport(conn));
+                return new PingRoutingCommand(getType(), id, getHostVmStateReport(conn));
             } else if (_isOvs) {
                 List<Pair<String, Long>> ovsStates = ovsFullSyncStates();
-                return new PingRoutingWithOvsCommand(getType(), id, null, getHostVmStateReport(conn), ovsStates);
+                return new PingRoutingWithOvsCommand(getType(), id, getHostVmStateReport(conn), ovsStates);
             } else {
                 HashMap<String, Pair<Long, Long>> nwGrpStates = syncNetworkGroups(conn, id);
-                return new PingRoutingWithNwGroupsCommand(getType(), id, null, getHostVmStateReport(conn), nwGrpStates);
+                return new PingRoutingWithNwGroupsCommand(getType(), id, getHostVmStateReport(conn), nwGrpStates);
             }
         } catch (Exception e) {
             s_logger.warn("Unable to get current status", e);
@@ -4581,7 +4429,6 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
         cmd.setHypervisorType(HypervisorType.XenServer);
         cmd.setCluster(_cluster);
         cmd.setPoolSync(false);
-        cmd.setHostVmStateReport(getHostVmStateReport(conn));
 
         Pool pool;
         try {
@@ -4589,10 +4436,6 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
             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");
         }
@@ -6411,7 +6254,7 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
         String vmName = cmd.getVmName();
         String vmSnapshotName = cmd.getTarget().getSnapshotName();
         List<VolumeObjectTO> listVolumeTo = cmd.getVolumeTOs();
-        VirtualMachine.State vmState = cmd.getVmState();
+        VmPowerState vmState = VmPowerState.HALTED;
         String guestOSType = cmd.getGuestOSType();
         String platformEmulator = cmd.getPlatformEmulator();
 
@@ -6446,6 +6289,7 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
             if (task == null) {
                 try {
                     vm = getVM(conn, vmName);
+                    vmState = vm.getPowerState(conn);
                 } catch (Exception e) {
                     if (!snapshotMemory) {
                         vm = createWorkingVM(conn, vmName, guestOSType, platformEmulator, listVolumeTo);
@@ -6525,7 +6369,7 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
                         vmSnapshot.destroy(conn);
                     }
                 }
-                if (vmState == VirtualMachine.State.Stopped) {
+                if (vmState == VmPowerState.HALTED) {
                     if (vm != null) {
                         vm.destroy(conn);
                     }
@@ -7193,146 +7037,6 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
         return vmMetaDatum;
     }
 
-    protected HashMap<String, Pair<String, State>> fullClusterSync(Connection conn) {
-        synchronized (_cluster.intern()) {
-            s_vms.clear(_cluster);
-        }
-        try {
-            Map<VM, VM.Record> vm_map = VM.getAllRecords(conn);  //USE THIS TO GET ALL VMS FROM  A CLUSTER
-            for (VM.Record record : vm_map.values()) {
-                if (record.isControlDomain || record.isASnapshot || record.isATemplate) {
-                    continue; // Skip DOM0
-                }
-                String vm_name = record.nameLabel;
-                VmPowerState ps = record.powerState;
-                final State state = convertToState(ps);
-                Host host = record.residentOn;
-                String host_uuid = null;
-                if (!isRefNull(host)) {
-                    host_uuid = host.getUuid(conn);
-                    synchronized (_cluster.intern()) {
-                        s_vms.put(_cluster, host_uuid, vm_name, state);
-                    }
-                }
-                if (s_logger.isTraceEnabled()) {
-                    s_logger.trace("VM " + vm_name + ": powerstate = " + ps + "; vm state=" + state.toString());
-                }
-            }
-        } catch (final Throwable e) {
-            String msg = "Unable to get vms through host " + _host.uuid + " due to to " + e.toString();
-            s_logger.warn(msg, e);
-            throw new CloudRuntimeException(msg);
-        }
-        return s_vms.getClusterVmState(_cluster);
-    }
-
-    protected HashMap<String, Pair<String, State>> deltaClusterSync(Connection conn) {
-        final HashMap<String, Pair<String, State>> changes = new HashMap<String, Pair<String, State>>();
-
-        synchronized (_cluster.intern()) {
-            HashMap<String, Pair<String, State>> newStates = getAllVms(conn);
-            if (newStates == null) {
-                s_logger.warn("Unable to get the vm states so no state sync at this point.");
-                return null;
-            }
-            HashMap<String, Pair<String, State>> oldStates = new HashMap<String, Pair<String, State>>(s_vms.size(_cluster));
-            oldStates.putAll(s_vms.getClusterVmState(_cluster));
-
-            for (final Map.Entry<String, Pair<String, State>> entry : newStates.entrySet()) {
-                final String vm = entry.getKey();
-                State newState = entry.getValue().second();
-                String host_uuid = entry.getValue().first();
-                final Pair<String, State> oldState = oldStates.remove(vm);
-
-                //check if host is changed
-                if (host_uuid != null && oldState != null) {
-                    if (!host_uuid.equals(oldState.first()) && newState != State.Stopped && newState != State.Stopping) {
-                        s_logger.warn("Detecting a change in host for " + vm);
-                        changes.put(vm, new Pair<String, State>(host_uuid, newState));
-
-                        s_logger.debug("11. The VM " + vm + " is in " + newState + " state");
-                        s_vms.put(_cluster, host_uuid, vm, newState);
-                        continue;
-                    }
-                }
-
-                if (newState == State.Stopped && oldState != null && oldState.second() != State.Stopping && oldState.second() != State.Stopped) {
-                    newState = getRealPowerState(conn, vm);
-                }
-
-                if (s_logger.isTraceEnabled()) {
-                    s_logger.trace("VM " + vm + ": xenserver has state " + newState + " and we have state " + (oldState != null ? oldState.toString() : "null"));
-                }
-
-                if (vm.startsWith("migrating")) {
-                    s_logger.warn("Migrating from xenserver detected.  Skipping");
-                    continue;
-                }
-                if (oldState == null) {
-                    s_vms.put(_cluster, host_uuid, vm, newState);
-                    s_logger.warn("Detecting a new state but couldn't find a old state so adding it to the changes: " + vm);
-                    changes.put(vm, new Pair<String, State>(host_uuid, newState));
-                } else if (oldState.second() == State.Starting) {
-                    if (newState == State.Running) {
-                        s_logger.debug("12. The VM " + vm + " is in " + State.Running + " state");
-                        s_vms.put(_cluster, host_uuid, vm, newState);
-                    } else if (newState == State.Stopped) {
-                        s_logger.warn("Ignoring vm " + vm + " because of a lag in starting the vm.");
-                    }
-                } else if (oldState.second() == State.Migrating) {
-                    if (newState == State.Running) {
-                        s_logger.debug("Detected that an migrating VM is now running: " + vm);
-                        s_vms.put(_cluster, host_uuid, vm, newState);
-                    }
-                } else if (oldState.second() == State.Stopping) {
-                    if (newState == State.Stopped) {
-                        s_logger.debug("13. The VM " + vm + " is in " + State.Stopped + " state");
-                        s_vms.put(_cluster, host_uuid, vm, newState);
-                    } else if (newState == State.Running) {
-                        s_logger.warn("Ignoring vm " + vm + " because of a lag in stopping the vm. ");
-                    }
-                } else if (oldState.second() != newState) {
-                    s_logger.debug("14. The VM " + vm + " is in " + newState + " state was " + oldState.second());
-                    s_vms.put(_cluster, host_uuid, vm, newState);
-                    if (newState == State.Stopped) {
-                        /*
-                         * if (s_vmsKilled.remove(vm)) { s_logger.debug("VM " + vm + " has been killed for storage. ");
-                         * newState = State.Error; }
-                         */
-                    }
-                    changes.put(vm, new Pair<String, State>(host_uuid, newState));
-                }
-            }
-
-            for (final Map.Entry<String, Pair<String, State>> entry : oldStates.entrySet()) {
-                final String vm = entry.getKey();
-                final State oldState = entry.getValue().second();
-                String host_uuid = entry.getValue().first();
-
-                if (s_logger.isTraceEnabled()) {
-                    s_logger.trace("VM " + vm + " is now missing from xenserver so reporting stopped");
-                }
-
-                if (oldState == State.Stopping) {
-                    s_logger.warn("Ignoring VM " + vm + " in transition state stopping.");
-                    s_vms.remove(_cluster, host_uuid, vm);
-                } else if (oldState == State.Starting) {
-                    s_logger.warn("Ignoring VM " + vm + " in transition state starting.");
-                } else if (oldState == State.Stopped) {
-                    s_logger.debug("VM missing " + vm + " old state stopped so removing.");
-                    s_vms.remove(_cluster, host_uuid, vm);
-                } else if (oldState == State.Migrating) {
-                    s_logger.warn("Ignoring VM " + vm + " in migrating state.");
-                } else {
-                    State newState = State.Stopped;
-                    s_logger.warn("The VM is now missing marking it as Stopped " + vm);
-                    changes.put(vm, new Pair<String, State>(host_uuid, newState));
-                }
-            }
-        }
-        return changes;
-    }
-
     /**
      * @param cmd
      * @return

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/330c4ba5/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/XenServer56FP1Resource.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/XenServer56FP1Resource.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/XenServer56FP1Resource.java
index e1669a5..1a04f1f 100644
--- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/XenServer56FP1Resource.java
+++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/XenServer56FP1Resource.java
@@ -101,9 +101,6 @@ public class XenServer56FP1Resource extends XenServer56Resource {
                         vdis.add(vdi);
                     }
                 }
-                synchronized (_cluster.intern()) {
-                    s_vms.remove(_cluster, _name, vm.getNameLabel(conn));
-                }
                 s_logger.info("Fence command for VM " + cmd.getVmName());
                 vm.powerStateReset(conn);
                 vm.destroy(conn);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/330c4ba5/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/XenServer56Resource.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/XenServer56Resource.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/XenServer56Resource.java
index d3e17bd..6f3537d 100644
--- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/XenServer56Resource.java
+++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/XenServer56Resource.java
@@ -261,9 +261,6 @@ public class XenServer56Resource extends CitrixResourceBase {
             }
             Set<VM> vms = VM.getByNameLabel(conn, cmd.getVmName());
             for (VM vm : vms) {
-                synchronized (_cluster.intern()) {
-                    s_vms.remove(_cluster, _name, vm.getNameLabel(conn));
-                }
                 s_logger.info("Fence command for VM " + cmd.getVmName());
                 vm.powerStateReset(conn);
                 vm.destroy(conn);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/330c4ba5/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/XenServer610Resource.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/XenServer610Resource.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/XenServer610Resource.java
index b099c99..c4a0056 100644
--- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/XenServer610Resource.java
+++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/XenServer610Resource.java
@@ -62,7 +62,6 @@ import com.cloud.network.Networks.TrafficType;
 import com.cloud.resource.ServerResource;
 import com.cloud.storage.Volume;
 import com.cloud.utils.exception.CloudRuntimeException;
-import com.cloud.vm.VirtualMachine.State;
 
 @Local(value = ServerResource.class)
 public class XenServer610Resource extends XenServer602Resource {
@@ -143,13 +142,8 @@ public class XenServer610Resource extends XenServer602Resource {
         VirtualMachineTO vmSpec = cmd.getVirtualMachine();
         Map<VolumeTO, StorageFilerTO> volumeToFiler = cmd.getVolumeToFiler();
         final String vmName = vmSpec.getName();
-        State state = s_vms.getState(_cluster, vmName);
         Task task = null;
 
-        synchronized (_cluster.intern()) {
-            s_vms.put(_cluster, _name, vmName, State.Stopping);
-        }
-
         try {
             prepareISO(connection, vmSpec.getName());
             Map<String, String> other = new HashMap<String, String>();
@@ -196,8 +190,6 @@ public class XenServer610Resource extends XenServer602Resource {
             // Volume paths would have changed. Return that information.
             List<VolumeObjectTO> volumeToList = getUpdatedVolumePathsOfMigratedVm(connection, vmToMigrate, vmSpec.getDisks());
             vmToMigrate.setAffinity(connection, host);
-            state = State.Stopping;
-
             return new MigrateWithStorageAnswer(cmd, volumeToList);
         } catch (Exception e) {
             s_logger.warn("Catch Exception " + e.getClass().getName() + ". Storage motion failed due to " + e.toString(), e);
@@ -210,10 +202,6 @@ public class XenServer610Resource extends XenServer602Resource {
                     s_logger.debug("Unable to destroy task " + task.toString() + " on host " + _host.uuid + " due to " + e.toString());
                 }
             }
-
-            synchronized (_cluster.intern()) {
-                s_vms.put(_cluster, _name, vmName, state);
-            }
         }
     }
 
@@ -260,15 +248,9 @@ public class XenServer610Resource extends XenServer602Resource {
         Map<NicTO, Object> nicToNetwork = cmd.getNicToNetwork();
         Map<String, String> token = cmd.getToken();
         final String vmName = vmSpec.getName();
-        State state = s_vms.getState(_cluster, vmName);
         Set<VolumeTO> volumeToSet = null;
         boolean migrated = false;
         Task task = null;
-
-        synchronized (_cluster.intern()) {
-            s_vms.put(_cluster, _name, vmName, State.Stopping);
-        }
-
         try {
             Set<VM> vms = VM.getByNameLabel(connection, vmSpec.getName());
             VM vmToMigrate = vms.iterator().next();
@@ -339,15 +321,6 @@ public class XenServer610Resource extends XenServer602Resource {
                     s_logger.debug("Unable to destroy task " + task.toString() + " on host " + _host.uuid + " due to " + e.toString());
                 }
             }
-
-            // Keep cluster/vm sync happy.
-            synchronized (_cluster.intern()) {
-                if (migrated) {
-                    s_vms.remove(_cluster, _name, vmName);
-                } else {
-                    s_vms.put(_cluster, _name, vmName, state);
-                }
-            }
         }
     }
 
@@ -369,10 +342,6 @@ public class XenServer610Resource extends XenServer602Resource {
             List<VolumeObjectTO> volumeToSet = getUpdatedVolumePathsOfMigratedVm(connection, migratedVm, vmSpec.getDisks());
             migratedVm.setAffinity(connection, host);
 
-            synchronized (_cluster.intern()) {
-                s_vms.put(_cluster, _name, vmSpec.getName(), State.Running);
-            }
-
             return new MigrateWithStorageCompleteAnswer(cmd, volumeToSet);
         } catch (CloudRuntimeException e) {
             s_logger.error("Migration of vm " + vmSpec.getName() + " with storage failed due to " + e.toString(), e);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/330c4ba5/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/XenServerPoolVms.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/XenServerPoolVms.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/XenServerPoolVms.java
deleted file mode 100644
index 9cbf71f..0000000
--- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/XenServerPoolVms.java
+++ /dev/null
@@ -1,92 +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.hypervisor.xenserver.resource;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-
-import org.apache.log4j.Logger;
-
-import com.cloud.utils.Pair;
-import com.cloud.vm.VirtualMachine.State;
-
-public class XenServerPoolVms {
-    private static final Logger s_logger = Logger.getLogger(XenServerPoolVms.class);
-    private final Map<String/* clusterId */, HashMap<String/* vm name */, Pair<String/* host uuid */, State/* vm state */>>> _clusterVms =
-        new ConcurrentHashMap<String, HashMap<String, Pair<String, State>>>();
-
-    public HashMap<String, Pair<String, State>> getClusterVmState(String clusterId) {
-        HashMap<String, Pair<String, State>> _vms = _clusterVms.get(clusterId);
-        if (_vms == null) {
-            HashMap<String, Pair<String, State>> vmStates = new HashMap<String, Pair<String, State>>();
-            _clusterVms.put(clusterId, vmStates);
-            return vmStates;
-        } else
-            return _vms;
-    }
-
-    public void clear(String clusterId) {
-        HashMap<String, Pair<String, State>> _vms = getClusterVmState(clusterId);
-        _vms.clear();
-    }
-
-    public State getState(String clusterId, String name) {
-        HashMap<String, Pair<String, State>> vms = getClusterVmState(clusterId);
-        Pair<String, State> pv = vms.get(name);
-        return pv == null ? State.Stopped : pv.second(); // if a VM is absent on the cluster, it is effectively in stopped state.
-    }
-
-    public Pair<String, State> get(String clusterId, String name) {
-        HashMap<String, Pair<String, State>> vms = getClusterVmState(clusterId);
-        return vms.get(name);
-    }
-
-    public void put(String clusterId, String hostUuid, String name, State state) {
-        HashMap<String, Pair<String, State>> vms = getClusterVmState(clusterId);
-        vms.put(name, new Pair<String, State>(hostUuid, state));
-    }
-
-    public void remove(String clusterId, String hostUuid, String name) {
-        HashMap<String, Pair<String, State>> vms = getClusterVmState(clusterId);
-        vms.remove(name);
-    }
-
-    public void putAll(String clusterId, HashMap<String, Pair<String, State>> newVms) {
-        HashMap<String, Pair<String, State>> vms = getClusterVmState(clusterId);
-        vms.putAll(newVms);
-    }
-
-    public int size(String clusterId) {
-        HashMap<String, Pair<String, State>> vms = getClusterVmState(clusterId);
-        return vms.size();
-    }
-
-    @Override
-    public String toString() {
-        StringBuilder sbuf = new StringBuilder("PoolVms=");
-        for (HashMap<String/* vm name */, Pair<String/* host uuid */, State/* vm state */>> clusterVM : _clusterVms.values()) {
-            for (Map.Entry<String,Pair<String,State>> entry: clusterVM.entrySet()) {
-                String vmname = entry.getKey();
-                Pair<String,State> vmstate= entry.getValue();
-                sbuf.append(vmname).append("-").append(vmstate.second()).append(",");
-            }
-        }
-        return sbuf.toString();
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/330c4ba5/plugins/hypervisors/xenserver/src/org/apache/cloudstack/hypervisor/xenserver/XenServerResourceNewBase.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/xenserver/src/org/apache/cloudstack/hypervisor/xenserver/XenServerResourceNewBase.java b/plugins/hypervisors/xenserver/src/org/apache/cloudstack/hypervisor/xenserver/XenServerResourceNewBase.java
index def1b05..161a7b2 100644
--- a/plugins/hypervisors/xenserver/src/org/apache/cloudstack/hypervisor/xenserver/XenServerResourceNewBase.java
+++ b/plugins/hypervisors/xenserver/src/org/apache/cloudstack/hypervisor/xenserver/XenServerResourceNewBase.java
@@ -40,7 +40,6 @@ import com.cloud.hypervisor.xenserver.resource.XenServer620SP1Resource;
 import com.cloud.utils.Pair;
 import com.cloud.utils.exception.CloudRuntimeException;
 import com.cloud.vm.VirtualMachine;
-import com.cloud.vm.VirtualMachineName;
 
 /**
  *
@@ -205,99 +204,7 @@ public class XenServerResourceNewBase extends XenServer620SP1Resource {
         }
 
         protected void recordChanges(Connection conn, VM.Record rec, String hostUuid) {
-            String vm = rec.nameLabel;
-            if (!VirtualMachineName.isValidCloudStackVmName(vm, _instance)) {
-                s_logger.debug("Skipping over VMs that does not conform to CloudStack naming convention: " + vm);
-                return;
-            }
-
-            VirtualMachine.State currentState = convertToState(rec.powerState);
-            if (vm.startsWith("migrating")) {
-                s_logger.warn("Skipping " + vm + " because it is migrating.");
-                return;
-            }
-
-            if (currentState == VirtualMachine.State.Stopped) {
-                if (s_logger.isTraceEnabled()) {
-                    s_logger.trace("Double check the power state to make sure we got the correct state for " + vm);
-                }
-                currentState = getRealPowerState(conn, vm);
-            }
-
-            boolean updateMap = false;
-            boolean reportChange = false;
-
-            // NOTE: For now we only record change when the VM is stopped.  We don't find out any VMs starting for now.
-            synchronized (_cluster.intern()) {
-                Pair<String, VirtualMachine.State> oldState = s_vms.get(_cluster, vm);
-                if (oldState == null) {
-                    if (s_logger.isTraceEnabled()) {
-                        s_logger.trace("Unable to find " + vm + " from previous map.  Assuming it was in Stopped state.");
-                    }
-                    oldState = new Pair<String, VirtualMachine.State>(null, VirtualMachine.State.Stopped);
-                }
-
-                if (s_logger.isTraceEnabled()) {
-                    s_logger.trace(vm + ": current state=" + currentState + ", previous state=" + oldState);
-                }
 
-                if (oldState.second() == VirtualMachine.State.Starting) {
-                    if (currentState == VirtualMachine.State.Running) {
-                        updateMap = true;
-                        reportChange = false;
-                    } else if (currentState == VirtualMachine.State.Stopped) {
-                        updateMap = false;
-                        reportChange = false;
-                    }
-                } else if (oldState.second() == VirtualMachine.State.Migrating) {
-                    updateMap = true;
-                    reportChange = false;
-                } else if (oldState.second() == VirtualMachine.State.Stopping) {
-                    if (currentState == VirtualMachine.State.Stopped) {
-                        updateMap = true;
-                        reportChange = false;
-                    } else if (currentState == VirtualMachine.State.Running) {
-                        updateMap = false;
-                        reportChange = false;
-                    }
-                } else if (oldState.second() != currentState) {
-                    updateMap = true;
-                    reportChange = true;
-                } else if (hostUuid != null && !hostUuid.equals(oldState.first())) {
-                    if (s_logger.isDebugEnabled()) {
-                        s_logger.debug("Detecting " + vm + " moved from " + oldState.first() + " to " + hostUuid);
-                    }
-                    reportChange = true;
-                    updateMap = true;
-                }
-
-                if (updateMap) {
-                    s_vms.put(_cluster, hostUuid, vm, currentState);
-                    if (s_logger.isTraceEnabled()) {
-                        s_logger.trace("Updated " + vm + " to [" + hostUuid + ", " + currentState);
-                    }
-                }
-                if (reportChange) {
-                    Pair<String, VirtualMachine.State> change = _changes.get(vm);
-                    if (hostUuid == null) {
-                        // This is really strange code.  It looks like the sync
-                        // code wants this to be set, which is extremely weird
-                        // for VMs that are dead.  Why would I want to set the
-                        // hostUuid if the VM is stopped.
-                        hostUuid = oldState.first();
-                        if (hostUuid == null) {
-                            hostUuid = _host.uuid;
-                        }
-                    }
-                    if (change == null) {
-                        change = new Pair<String, VirtualMachine.State>(hostUuid, currentState);
-                    } else {
-                        change.first(hostUuid);
-                        change.second(currentState);
-                    }
-                    _changes.put(vm, change);
-                }
-            }
         }
 
         @Override

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/330c4ba5/server/src/com/cloud/ha/CheckOnAgentInvestigator.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/ha/CheckOnAgentInvestigator.java b/server/src/com/cloud/ha/CheckOnAgentInvestigator.java
index 1dfe8c0..b361199 100644
--- a/server/src/com/cloud/ha/CheckOnAgentInvestigator.java
+++ b/server/src/com/cloud/ha/CheckOnAgentInvestigator.java
@@ -30,7 +30,7 @@ import com.cloud.host.Host;
 import com.cloud.host.Status;
 import com.cloud.utils.component.AdapterBase;
 import com.cloud.vm.VirtualMachine;
-import com.cloud.vm.VirtualMachine.State;
+import com.cloud.vm.VirtualMachine.PowerState;
 
 @Local(value = Investigator.class)
 public class CheckOnAgentInvestigator extends AdapterBase implements Investigator {
@@ -57,7 +57,7 @@ public class CheckOnAgentInvestigator extends AdapterBase implements Investigato
             }
 
             s_logger.debug("Agent responded with state " + answer.getState().toString());
-            return answer.getState() == State.Running;
+            return answer.getState() == PowerState.PowerOn;
         } catch (AgentUnavailableException e) {
             s_logger.debug("Unable to reach the agent for " + vm.toString() + ": " + e.getMessage());
             return null;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/330c4ba5/server/src/com/cloud/hypervisor/kvm/discoverer/KvmDummyResourceBase.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/hypervisor/kvm/discoverer/KvmDummyResourceBase.java b/server/src/com/cloud/hypervisor/kvm/discoverer/KvmDummyResourceBase.java
index 33548c8..ee69a07 100644
--- a/server/src/com/cloud/hypervisor/kvm/discoverer/KvmDummyResourceBase.java
+++ b/server/src/com/cloud/hypervisor/kvm/discoverer/KvmDummyResourceBase.java
@@ -23,11 +23,9 @@ import javax.naming.ConfigurationException;
 
 import com.cloud.agent.api.Answer;
 import com.cloud.agent.api.Command;
-import com.cloud.agent.api.HostVmStateReportEntry;
 import com.cloud.agent.api.PingCommand;
 import com.cloud.agent.api.StartupCommand;
 import com.cloud.agent.api.StartupRoutingCommand;
-import com.cloud.agent.api.StartupRoutingCommand.VmState;
 import com.cloud.host.Host.Type;
 import com.cloud.hypervisor.Hypervisor;
 import com.cloud.resource.ServerResource;
@@ -49,8 +47,7 @@ public class KvmDummyResourceBase extends ServerResourceBase implements ServerRe
     @Override
     public StartupCommand[] initialize() {
         StartupRoutingCommand cmd =
-            new StartupRoutingCommand(0, 0, 0, 0, null, Hypervisor.HypervisorType.KVM, new HashMap<String, String>(), new HashMap<String, VmState>(),
-                new HashMap<String, HostVmStateReportEntry>());
+            new StartupRoutingCommand(0, 0, 0, 0, null, Hypervisor.HypervisorType.KVM, new HashMap<String, String>());
         cmd.setDataCenter(_zoneId);
         cmd.setPod(_podId);
         cmd.setCluster(_clusterId);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/330c4ba5/server/src/com/cloud/resource/DummyHostServerResource.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/resource/DummyHostServerResource.java b/server/src/com/cloud/resource/DummyHostServerResource.java
index 2252a81..41f5d3d 100644
--- a/server/src/com/cloud/resource/DummyHostServerResource.java
+++ b/server/src/com/cloud/resource/DummyHostServerResource.java
@@ -31,7 +31,6 @@ import com.cloud.agent.api.StartupRoutingCommand;
 import com.cloud.host.Host.Type;
 import com.cloud.hypervisor.Hypervisor.HypervisorType;
 import com.cloud.utils.net.MacAddress;
-import com.cloud.vm.VirtualMachine;
 
 public class DummyHostServerResource extends ServerResourceBase {
 
@@ -57,8 +56,7 @@ public class DummyHostServerResource extends ServerResourceBase {
 
     @Override
     public PingCommand getCurrentStatus(long id) {
-        HashMap<String, VirtualMachine.State> newStates = new HashMap<String, VirtualMachine.State>();
-        return new PingRoutingCommand(com.cloud.host.Host.Type.Routing, id, newStates, new HashMap<String, HostVmStateReportEntry>());
+        return new PingRoutingCommand(com.cloud.host.Host.Type.Routing, id, new HashMap<String, HostVmStateReportEntry>());
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/330c4ba5/server/src/com/cloud/storage/VolumeApiServiceImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/VolumeApiServiceImpl.java b/server/src/com/cloud/storage/VolumeApiServiceImpl.java
index 54ae965..7432fc4 100644
--- a/server/src/com/cloud/storage/VolumeApiServiceImpl.java
+++ b/server/src/com/cloud/storage/VolumeApiServiceImpl.java
@@ -220,10 +220,6 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
 
     VmWorkJobHandlerProxy _jobHandlerProxy = new VmWorkJobHandlerProxy(this);
 
-    // TODO
-    static final ConfigKey<Boolean> VmJobEnabled = new ConfigKey<Boolean>("Advanced",
-            Boolean.class, "vm.job.enabled", "true",
-            "True to enable new VM sync model. false to use the old way", false);
     static final ConfigKey<Long> VmJobCheckInterval = new ConfigKey<Long>("Advanced", Long.class, "vm.job.check.interval", "3000",
             "Interval in milliseconds to check if the job is complete", false);
 
@@ -898,22 +894,18 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
             // serialize VM operation
             AsyncJobExecutionContext jobContext = AsyncJobExecutionContext.getCurrentExecutionContext();
 
-            if (!VmJobEnabled.value() || jobContext.isJobDispatchedBy(VmWorkConstants.VM_WORK_JOB_DISPATCHER)) {
+            if ( jobContext.isJobDispatchedBy(VmWorkConstants.VM_WORK_JOB_DISPATCHER)) {
                 // avoid re-entrance
 
                 VmWorkJobVO placeHolder = null;
 
-                if (VmJobEnabled.value()) {
-                    placeHolder = createPlaceHolderWork(userVm.getId());
-                }
+                placeHolder = createPlaceHolderWork(userVm.getId());
 
                 try {
                     return orchestrateResizeVolume(volume.getId(), currentSize, newSize, newMinIops, newMaxIops,
                             newDiskOffering != null ? cmd.getNewDiskOfferingId() : null, shrinkOk);
                 } finally {
-                    if (VmJobEnabled.value()) {
-                        _workJobDao.expunge(placeHolder.getId());
-                    }
+                    _workJobDao.expunge(placeHolder.getId());
                 }
             } else {
                 Outcome<Volume> outcome = resizeVolumeThroughJobQueue(userVm.getId(), volume.getId(), currentSize, newSize, newMinIops, newMaxIops,
@@ -1328,18 +1320,15 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
         }
 
         AsyncJobExecutionContext jobContext = AsyncJobExecutionContext.getCurrentExecutionContext();
-        if (!VmJobEnabled.value() || jobContext.isJobDispatchedBy(VmWorkConstants.VM_WORK_JOB_DISPATCHER)) {
+        if (jobContext.isJobDispatchedBy(VmWorkConstants.VM_WORK_JOB_DISPATCHER)) {
             // avoid re-entrance
 
             VmWorkJobVO placeHolder = null;
-            if (VmJobEnabled.value()) {
-                placeHolder = createPlaceHolderWork(vmId);
-            }
+            placeHolder = createPlaceHolderWork(vmId);
             try {
                 return orchestrateAttachVolumeToVM(vmId, volumeId, deviceId);
             } finally {
-                if (VmJobEnabled.value())
-                    _workJobDao.expunge(placeHolder.getId());
+                _workJobDao.expunge(placeHolder.getId());
             }
 
         } else {
@@ -1536,17 +1525,14 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
         }
 
         AsyncJobExecutionContext jobContext = AsyncJobExecutionContext.getCurrentExecutionContext();
-        if (!VmJobEnabled.value() || jobContext.isJobDispatchedBy(VmWorkConstants.VM_WORK_JOB_DISPATCHER)) {
+        if (jobContext.isJobDispatchedBy(VmWorkConstants.VM_WORK_JOB_DISPATCHER)) {
             // avoid re-entrance
             VmWorkJobVO placeHolder = null;
-            if (VmJobEnabled.value()) {
-                placeHolder = createPlaceHolderWork(vmId);
-            }
+            placeHolder = createPlaceHolderWork(vmId);
             try {
                 return orchestrateDetachVolumeFromVM(vmId, volumeId);
             } finally {
-                if (VmJobEnabled.value())
-                    _workJobDao.expunge(placeHolder.getId());
+                _workJobDao.expunge(placeHolder.getId());
             }
         } else {
             Outcome<Volume> outcome = detachVolumeFromVmThroughJobQueue(vmId, volumeId);
@@ -1733,18 +1719,15 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
         if (vm != null) {
             // serialize VM operation
             AsyncJobExecutionContext jobContext = AsyncJobExecutionContext.getCurrentExecutionContext();
-            if (!VmJobEnabled.value() || jobContext.isJobDispatchedBy(VmWorkConstants.VM_WORK_JOB_DISPATCHER)) {
+            if (jobContext.isJobDispatchedBy(VmWorkConstants.VM_WORK_JOB_DISPATCHER)) {
                 // avoid re-entrance
 
                 VmWorkJobVO placeHolder = null;
-                if (VmJobEnabled.value()) {
-                    placeHolder = createPlaceHolderWork(vm.getId());
-                }
+                placeHolder = createPlaceHolderWork(vm.getId());
                 try {
                     return orchestrateMigrateVolume(vol.getId(), destPool.getId(), liveMigrateVolume);
                 } finally {
-                    if ((VmJobEnabled.value())&&(placeHolder != null))
-                        _workJobDao.expunge(placeHolder.getId());
+                    _workJobDao.expunge(placeHolder.getId());
                 }
 
             } else {
@@ -1835,18 +1818,15 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
         if (vm != null) {
             // serialize VM operation
             AsyncJobExecutionContext jobContext = AsyncJobExecutionContext.getCurrentExecutionContext();
-            if (!VmJobEnabled.value() || jobContext.isJobDispatchedBy(VmWorkConstants.VM_WORK_JOB_DISPATCHER)) {
+            if (jobContext.isJobDispatchedBy(VmWorkConstants.VM_WORK_JOB_DISPATCHER)) {
                 // avoid re-entrance
 
                 VmWorkJobVO placeHolder = null;
-                if (VmJobEnabled.value()) {
-                    placeHolder = createPlaceHolderWork(vm.getId());
-                }
+                placeHolder = createPlaceHolderWork(vm.getId());
                 try {
                     return orchestrateTakeVolumeSnapshot(volumeId, policyId, snapshotId, account, quiescevm);
                 } finally {
-                    if (VmJobEnabled.value())
-                        _workJobDao.expunge(placeHolder.getId());
+                    _workJobDao.expunge(placeHolder.getId());
                 }
 
             } else {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/330c4ba5/server/src/com/cloud/vm/snapshot/VMSnapshotManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/vm/snapshot/VMSnapshotManagerImpl.java b/server/src/com/cloud/vm/snapshot/VMSnapshotManagerImpl.java
index e46aded..c7d7a8c 100644
--- a/server/src/com/cloud/vm/snapshot/VMSnapshotManagerImpl.java
+++ b/server/src/com/cloud/vm/snapshot/VMSnapshotManagerImpl.java
@@ -134,10 +134,6 @@ public class VMSnapshotManagerImpl extends ManagerBase implements VMSnapshotMana
     int _vmSnapshotMax;
     int _wait;
 
-    // TODO
-    static final ConfigKey<Boolean> VmJobEnabled = new ConfigKey<Boolean>("Advanced",
-            Boolean.class, "vm.job.enabled", "true",
-            "True to enable new VM sync model. false to use the old way", false);
     static final ConfigKey<Long> VmJobCheckInterval = new ConfigKey<Long>("Advanced",
             Long.class, "vm.job.check.interval", "3000",
             "Interval in milliseconds to check if the job is complete", false);
@@ -368,17 +364,14 @@ public class VMSnapshotManagerImpl extends ManagerBase implements VMSnapshotMana
 
         // serialize VM operation
         AsyncJobExecutionContext jobContext = AsyncJobExecutionContext.getCurrentExecutionContext();
-        if (!VmJobEnabled.value() || jobContext.isJobDispatchedBy(VmWorkConstants.VM_WORK_JOB_DISPATCHER)) {
+        if (jobContext.isJobDispatchedBy(VmWorkConstants.VM_WORK_JOB_DISPATCHER)) {
             // avoid re-entrance
             VmWorkJobVO placeHolder = null;
-            if (VmJobEnabled.value()) {
-                placeHolder = createPlaceHolderWork(vmId);
-            }
+            placeHolder = createPlaceHolderWork(vmId);
             try {
-            return orchestrateCreateVMSnapshot(vmId, vmSnapshotId, quiescevm);
+                return orchestrateCreateVMSnapshot(vmId, vmSnapshotId, quiescevm);
             } finally {
-                if (VmJobEnabled.value())
-                    _workJobDao.expunge(placeHolder.getId());
+                _workJobDao.expunge(placeHolder.getId());
             }
 
         } else {
@@ -466,17 +459,14 @@ public class VMSnapshotManagerImpl extends ManagerBase implements VMSnapshotMana
 
         // serialize VM operation
         AsyncJobExecutionContext jobContext = AsyncJobExecutionContext.getCurrentExecutionContext();
-        if (!VmJobEnabled.value() || jobContext.isJobDispatchedBy(VmWorkConstants.VM_WORK_JOB_DISPATCHER)) {
+        if (jobContext.isJobDispatchedBy(VmWorkConstants.VM_WORK_JOB_DISPATCHER)) {
             // avoid re-entrance
             VmWorkJobVO placeHolder = null;
-            if (VmJobEnabled.value()) {
-                placeHolder = createPlaceHolderWork(vmSnapshot.getVmId());
-            }
+            placeHolder = createPlaceHolderWork(vmSnapshot.getVmId());
             try {
-            return orchestrateDeleteVMSnapshot(vmSnapshotId);
+                return orchestrateDeleteVMSnapshot(vmSnapshotId);
             } finally {
-                if (VmJobEnabled.value())
-                    _workJobDao.expunge(placeHolder.getId());
+                _workJobDao.expunge(placeHolder.getId());
             }
         } else {
             Outcome<VMSnapshot> outcome = deleteVMSnapshotThroughJobQueue(vmSnapshot.getVmId(), vmSnapshotId);
@@ -581,18 +571,15 @@ public class VMSnapshotManagerImpl extends ManagerBase implements VMSnapshotMana
 
         // serialize VM operation
         AsyncJobExecutionContext jobContext = AsyncJobExecutionContext.getCurrentExecutionContext();
-        if (!VmJobEnabled.value() || jobContext.isJobDispatchedBy(VmWorkConstants.VM_WORK_JOB_DISPATCHER)) {
+        if (jobContext.isJobDispatchedBy(VmWorkConstants.VM_WORK_JOB_DISPATCHER)) {
             // avoid re-entrance
 
             VmWorkJobVO placeHolder = null;
-            if (VmJobEnabled.value()) {
-                placeHolder = createPlaceHolderWork(vmSnapshotVo.getVmId());
-            }
+            placeHolder = createPlaceHolderWork(vmSnapshotVo.getVmId());
             try {
-            return orchestrateRevertToVMSnapshot(vmSnapshotId);
+                return orchestrateRevertToVMSnapshot(vmSnapshotId);
             } finally {
-                if (VmJobEnabled.value())
-                    _workJobDao.expunge(placeHolder.getId());
+                _workJobDao.expunge(placeHolder.getId());
             }
 
         } else {
@@ -718,16 +705,14 @@ public class VMSnapshotManagerImpl extends ManagerBase implements VMSnapshotMana
     public boolean deleteAllVMSnapshots(long vmId, VMSnapshot.Type type) {
         // serialize VM operation
         AsyncJobExecutionContext jobContext = AsyncJobExecutionContext.getCurrentExecutionContext();
-        if (!VmJobEnabled.value() || jobContext.isJobDispatchedBy(VmWorkConstants.VM_WORK_JOB_DISPATCHER)) {
+        if (jobContext.isJobDispatchedBy(VmWorkConstants.VM_WORK_JOB_DISPATCHER)) {
             // avoid re-entrance
             VmWorkJobVO placeHolder = null;
-            if (VmJobEnabled.value()) {
-                placeHolder = createPlaceHolderWork(vmId);
-            }
+            placeHolder = createPlaceHolderWork(vmId);
             try {
-            return orchestrateDeleteAllVMSnapshots(vmId, type);
+                return orchestrateDeleteAllVMSnapshots(vmId, type);
             } finally {
-                if ( (VmJobEnabled.value()) && (placeHolder != null))
+                if (placeHolder != null)
                     _workJobDao.expunge(placeHolder.getId());
             }
 


Mime
View raw message