bug 12875: vm-sunc syncronizing on cluster ids

This commit is contained in:
Abhinandan Prateek 2012-01-16 15:11:06 +05:30
parent 8a3a4ab9c0
commit c13c4b12a4

View File

@ -1089,7 +1089,7 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
}
}
}
synchronized (s_vms) {
synchronized (_cluster.intern()) {
s_logger.debug("1. The VM " + vmName + " is in Starting state.");
s_vms.put(_cluster, _name, vmName, State.Starting);
}
@ -1172,7 +1172,7 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
String msg = handleVmStartFailure(conn, vmName, vm, "", e);
return new StartAnswer(cmd, msg);
} finally {
synchronized (s_vms) {
synchronized (_cluster.intern()) {
if (state != State.Stopped) {
s_logger.debug("2. The VM " + vmName + " is in " + state + " state.");
s_vms.put(_cluster, _name, vmName, state);
@ -2179,7 +2179,7 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
final State state = getVmState(conn, vmName);
Integer vncPort = null;
if (state == State.Running) {
synchronized (s_vms) {
synchronized (_cluster.intern()) {
s_logger.debug("3. The VM " + vmName + " is in " + State.Running + " state");
s_vms.put(_cluster, _name, vmName, State.Running);
}
@ -2203,7 +2203,7 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
for (NicTO nic : nics) {
getNetwork(conn, nic);
}
synchronized (s_vms) {
synchronized (_cluster.intern()) {
s_logger.debug("4. The VM " + vm.getName() + " is in " + State.Migrating + " state");
s_vms.put(_cluster, _name, vm.getName(), State.Migrating);
}
@ -2482,7 +2482,7 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
state = s_vms.getState(_cluster, vmName);
synchronized (s_vms) {
synchronized (_cluster.intern()) {
s_logger.debug("5. The VM " + vmName + " is in " + State.Stopping + " state");
s_vms.put(_cluster, _name, vmName, State.Stopping);
}
@ -2551,7 +2551,7 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
s_logger.warn(msg, e);
return new MigrateAnswer(cmd, false, msg, null);
} finally {
synchronized (s_vms) {
synchronized (_cluster.intern()) {
s_logger.debug("6. The VM " + vmName + " is in " + state + " state");
s_vms.put(_cluster, _name, vmName, state);
}
@ -2676,7 +2676,7 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
@Override
public RebootAnswer execute(RebootCommand cmd) {
Connection conn = getConnection();
synchronized (s_vms) {
synchronized (_cluster.intern()) {
s_logger.debug("7. The VM " + cmd.getVmName() + " is in " + State.Starting + " state");
s_vms.put(_cluster, _name, cmd.getVmName(), State.Starting);
}
@ -2702,7 +2702,7 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
}
return new RebootAnswer(cmd, "reboot succeeded", null, null);
} finally {
synchronized (s_vms) {
synchronized (_cluster.intern()) {
s_logger.debug("8. The VM " + cmd.getVmName() + " is in " + State.Running + " state");
s_vms.put(_cluster, _name, cmd.getVmName(), State.Running);
}
@ -3179,7 +3179,7 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
}
if (vms.size() == 0) {
synchronized (s_vms) {
synchronized (_cluster.intern()) {
s_logger.info("VM does not exist on XenServer" + _host.uuid);
s_vms.remove(_cluster, _name, vmName);
}
@ -3204,7 +3204,7 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
State state = s_vms.getState(_cluster, vmName);
synchronized (s_vms) {
synchronized (_cluster.intern()) {
s_logger.debug("9. The VM " + vmName + " is in " + State.Stopping + " state");
s_vms.put(_cluster, _name, vmName, State.Stopping);
}
@ -3268,7 +3268,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 (s_vms) {
synchronized (_cluster.intern()) {
s_logger.debug("10. The VM " + vmName + " is in " + state + " state");
s_vms.put(_cluster, _name, vmName, state);
}
@ -6711,7 +6711,7 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
final HashMap<String, Pair<String, State>> changes = new HashMap<String, Pair<String, State>>();
synchronized (s_vms) {
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.");