Skip to content

Commit 330c4ba

Browse files
author
Anthony Xu
committed
completed the new vmsync TODOs in the code.
removed old vmsync logic
1 parent acc9c79 commit 330c4ba

36 files changed

Lines changed: 233 additions & 2393 deletions

File tree

agent/src/com/cloud/agent/resource/DummyResource.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
import com.cloud.agent.api.PingCommand;
3333
import com.cloud.agent.api.StartupCommand;
3434
import com.cloud.agent.api.StartupRoutingCommand;
35-
import com.cloud.agent.api.StartupRoutingCommand.VmState;
3635
import com.cloud.agent.api.StartupStorageCommand;
3736
import com.cloud.agent.api.StoragePoolInfo;
3837
import com.cloud.host.Host;
@@ -147,13 +146,11 @@ protected StoragePoolInfo initializeLocalStorage() {
147146

148147
@Override
149148
public StartupCommand[] initialize() {
150-
Map<String, VmState> changes = null;
151-
152149
final List<Object> info = getHostInfo();
153150

154151
final StartupRoutingCommand cmd =
155152
new StartupRoutingCommand((Integer)info.get(0), (Long)info.get(1), (Long)info.get(2), (Long)info.get(4), (String)info.get(3), HypervisorType.KVM,
156-
RouterPrivateIpStrategy.HostLocal, changes, null);
153+
RouterPrivateIpStrategy.HostLocal);
157154
fillNetworkInformation(cmd);
158155
cmd.getHostDetails().putAll(getVersionStrings());
159156
cmd.setCluster(getConfiguredProperty("cluster", "1"));

core/src/com/cloud/agent/api/CheckVirtualMachineAnswer.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,23 +19,23 @@
1919

2020
package com.cloud.agent.api;
2121

22-
import com.cloud.vm.VirtualMachine.State;
22+
import com.cloud.vm.VirtualMachine.PowerState;
2323

2424
public class CheckVirtualMachineAnswer extends Answer {
2525

2626
Integer vncPort;
27-
State state;
27+
PowerState state;
2828

2929
protected CheckVirtualMachineAnswer() {
3030
}
3131

32-
public CheckVirtualMachineAnswer(CheckVirtualMachineCommand cmd, State state, Integer vncPort, String detail) {
32+
public CheckVirtualMachineAnswer(CheckVirtualMachineCommand cmd, PowerState state, Integer vncPort, String detail) {
3333
super(cmd, true, detail);
3434
this.state = state;
3535
this.vncPort = vncPort;
3636
}
3737

38-
public CheckVirtualMachineAnswer(CheckVirtualMachineCommand cmd, State state, Integer vncPort) {
38+
public CheckVirtualMachineAnswer(CheckVirtualMachineCommand cmd, PowerState state, Integer vncPort) {
3939
this(cmd, state, vncPort, null);
4040
}
4141

@@ -47,7 +47,7 @@ public Integer getVncPort() {
4747
return vncPort;
4848
}
4949

50-
public State getState() {
50+
public PowerState getState() {
5151
return state;
5252
}
5353
}

core/src/com/cloud/agent/api/CreateVMSnapshotCommand.java

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,23 +23,10 @@
2323

2424
import org.apache.cloudstack.storage.to.VolumeObjectTO;
2525

26-
import com.cloud.vm.VirtualMachine;
2726

2827
public class CreateVMSnapshotCommand extends VMSnapshotBaseCommand {
2928

30-
public CreateVMSnapshotCommand(String vmName, VMSnapshotTO snapshot, List<VolumeObjectTO> volumeTOs, String guestOSType, VirtualMachine.State vmState) {
29+
public CreateVMSnapshotCommand(String vmName, VMSnapshotTO snapshot, List<VolumeObjectTO> volumeTOs, String guestOSType) {
3130
super(vmName, snapshot, volumeTOs, guestOSType);
32-
this.vmState = vmState;
3331
}
34-
35-
private VirtualMachine.State vmState;
36-
37-
public VirtualMachine.State getVmState() {
38-
return vmState;
39-
}
40-
41-
public void setVmState(VirtualMachine.State vmState) {
42-
this.vmState = vmState;
43-
}
44-
4532
}

core/src/com/cloud/agent/api/PingRoutingCommand.java

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,9 @@
2222
import java.util.Map;
2323

2424
import com.cloud.host.Host;
25-
import com.cloud.vm.VirtualMachine.State;
2625

2726
public class PingRoutingCommand extends PingCommand {
2827

29-
// TODO vmsync {
30-
Map<String, State> newStates;
31-
// TODO vmsync }
32-
3328
Map<String, HostVmStateReportEntry> _hostVmStateReport;
3429

3530
boolean _gatewayAccessible = true;
@@ -38,16 +33,11 @@ public class PingRoutingCommand extends PingCommand {
3833
protected PingRoutingCommand() {
3934
}
4035

41-
public PingRoutingCommand(Host.Type type, long id, Map<String, State> states, Map<String, HostVmStateReportEntry> hostVmStateReport) {
36+
public PingRoutingCommand(Host.Type type, long id, Map<String, HostVmStateReportEntry> hostVmStateReport) {
4237
super(type, id);
43-
this.newStates = states;
4438
this._hostVmStateReport = hostVmStateReport;
4539
}
4640

47-
public Map<String, State> getNewStates() {
48-
return newStates;
49-
}
50-
5141
public Map<String, HostVmStateReportEntry> getHostVmStateReport() {
5242
return this._hostVmStateReport;
5343
}

core/src/com/cloud/agent/api/PingRoutingWithNwGroupsCommand.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424

2525
import com.cloud.host.Host;
2626
import com.cloud.utils.Pair;
27-
import com.cloud.vm.VirtualMachine.State;
2827

2928
public class PingRoutingWithNwGroupsCommand extends PingRoutingCommand {
3029
HashMap<String, Pair<Long, Long>> newGroupStates;
@@ -33,9 +32,9 @@ protected PingRoutingWithNwGroupsCommand() {
3332
super();
3433
}
3534

36-
public PingRoutingWithNwGroupsCommand(Host.Type type, long id, Map<String, State> states, Map<String, HostVmStateReportEntry> hostVmStateReport,
35+
public PingRoutingWithNwGroupsCommand(Host.Type type, long id, Map<String, HostVmStateReportEntry> hostVmStateReport,
3736
HashMap<String, Pair<Long, Long>> nwGrpStates) {
38-
super(type, id, states, hostVmStateReport);
37+
super(type, id, hostVmStateReport);
3938
newGroupStates = nwGrpStates;
4039
}
4140

core/src/com/cloud/agent/api/PingRoutingWithOvsCommand.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424

2525
import com.cloud.host.Host;
2626
import com.cloud.utils.Pair;
27-
import com.cloud.vm.VirtualMachine.State;
2827

2928
public class PingRoutingWithOvsCommand extends PingRoutingCommand {
3029
List<Pair<String, Long>> states;
@@ -33,9 +32,9 @@ protected PingRoutingWithOvsCommand() {
3332
super();
3433
}
3534

36-
public PingRoutingWithOvsCommand(Host.Type type, long id, Map<String, State> states, Map<String, HostVmStateReportEntry> hostVmStateReport,
35+
public PingRoutingWithOvsCommand(Host.Type type, long id, Map<String, HostVmStateReportEntry> hostVmStateReport,
3736
List<Pair<String, Long>> ovsStates) {
38-
super(type, id, states, hostVmStateReport);
37+
super(type, id, hostVmStateReport);
3938

4039
this.states = ovsStates;
4140
}

core/src/com/cloud/agent/api/RevertToVMSnapshotAnswer.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
public class RevertToVMSnapshotAnswer extends Answer {
2929

3030
private List<VolumeObjectTO> volumeTOs;
31-
private VirtualMachine.State vmState;
31+
private VirtualMachine.PowerState vmState;
3232

3333
public RevertToVMSnapshotAnswer(RevertToVMSnapshotCommand cmd, boolean result, String message) {
3434
super(cmd, result, message);
@@ -38,13 +38,13 @@ public RevertToVMSnapshotAnswer() {
3838
super();
3939
}
4040

41-
public RevertToVMSnapshotAnswer(RevertToVMSnapshotCommand cmd, List<VolumeObjectTO> volumeTOs, VirtualMachine.State vmState) {
41+
public RevertToVMSnapshotAnswer(RevertToVMSnapshotCommand cmd, List<VolumeObjectTO> volumeTOs, VirtualMachine.PowerState vmState) {
4242
super(cmd, true, "");
4343
this.volumeTOs = volumeTOs;
4444
this.vmState = vmState;
4545
}
4646

47-
public VirtualMachine.State getVmState() {
47+
public VirtualMachine.PowerState getVmState() {
4848
return vmState;
4949
}
5050

@@ -56,7 +56,7 @@ public void setVolumeTOs(List<VolumeObjectTO> volumeTOs) {
5656
this.volumeTOs = volumeTOs;
5757
}
5858

59-
public void setVmState(VirtualMachine.State vmState) {
59+
public void setVmState(VirtualMachine.PowerState vmState) {
6060
this.vmState = vmState;
6161
}
6262

core/src/com/cloud/agent/api/StartupRoutingCommand.java

Lines changed: 7 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -25,48 +25,15 @@
2525
import com.cloud.host.Host;
2626
import com.cloud.hypervisor.Hypervisor.HypervisorType;
2727
import com.cloud.network.Networks.RouterPrivateIpStrategy;
28-
import com.cloud.utils.Pair;
29-
import com.cloud.vm.VirtualMachine.State;
3028

3129
public class StartupRoutingCommand extends StartupCommand {
32-
public static class VmState {
33-
State state;
34-
String host;
35-
36-
public VmState() {
37-
}
38-
39-
public VmState(State state, String host) {
40-
this.state = state;
41-
this.host = host;
42-
}
43-
44-
public State getState() {
45-
return state;
46-
}
47-
48-
public String getHost() {
49-
return host;
50-
}
51-
}
52-
5330
Integer cpuSockets;
5431
int cpus;
5532
long speed;
5633
long memory;
5734
long dom0MinMemory;
5835
boolean poolSync;
5936

60-
// VM power state report is added in a side-by-side way as old VM state report
61-
// this is to allow a graceful migration from the old VM state sync model to the new model
62-
//
63-
// side-by-side addition of power state sync
64-
Map<String, HostVmStateReportEntry> _hostVmStateReport;
65-
66-
// TODO vmsync
67-
// deprecated, will delete after full replacement
68-
Map<String, VmState> vms;
69-
HashMap<String, Pair<String, State>> _clusterVMStates;
7037

7138
String caps;
7239
String pool;
@@ -82,68 +49,30 @@ public StartupRoutingCommand() {
8249

8350
}
8451

85-
public StartupRoutingCommand(int cpus, long speed, long memory, long dom0MinMemory, String caps, HypervisorType hypervisorType,
86-
RouterPrivateIpStrategy privIpStrategy, Map<String, VmState> vms, Map<String, HostVmStateReportEntry> hostVmStateReport) {
87-
this(cpus, speed, memory, dom0MinMemory, caps, hypervisorType, vms, hostVmStateReport);
88-
getHostDetails().put(RouterPrivateIpStrategy.class.getCanonicalName(), privIpStrategy.toString());
89-
}
90-
91-
public StartupRoutingCommand(int cpus, long speed, long memory, long dom0MinMemory, String caps, HypervisorType hypervisorType, RouterPrivateIpStrategy privIpStrategy) {
92-
this(cpus,
93-
speed,
94-
memory,
95-
dom0MinMemory,
96-
caps,
97-
hypervisorType,
98-
new HashMap<String, String>(),
99-
new HashMap<String, VmState>(),
100-
new HashMap<String, HostVmStateReportEntry>());
101-
102-
getHostDetails().put(RouterPrivateIpStrategy.class.getCanonicalName(), privIpStrategy.toString());
103-
}
104-
10552
public StartupRoutingCommand(int cpus, long speed, long memory, long dom0MinMemory, final String caps, final HypervisorType hypervisorType,
106-
final Map<String, String> hostDetails, Map<String, VmState> vms, Map<String, HostVmStateReportEntry> hostVmStateReport) {
53+
final Map<String, String> hostDetails) {
10754
super(Host.Type.Routing);
10855
this.cpus = cpus;
10956
this.speed = speed;
11057
this.memory = memory;
11158
this.dom0MinMemory = dom0MinMemory;
112-
this.vms = vms;
113-
this._hostVmStateReport = hostVmStateReport;
11459
this.hypervisorType = hypervisorType;
11560
this.hostDetails = hostDetails;
11661
this.caps = caps;
11762
this.poolSync = false;
11863
}
11964

120-
public StartupRoutingCommand(int cpus2, long speed2, long memory2, long dom0MinMemory2, String caps2, HypervisorType hypervisorType2, Map<String, VmState> vms2,
121-
Map<String, HostVmStateReportEntry> hostVmStateReport) {
122-
this(cpus2, speed2, memory2, dom0MinMemory2, caps2, hypervisorType2, new HashMap<String, String>(), vms2, hostVmStateReport);
123-
}
124-
125-
public StartupRoutingCommand(int cpus, long speed, long memory, long dom0MinMemory, final String caps, final HypervisorType hypervisorType,
126-
final Map<String, String> hostDetails, Map<String, VmState> vms, Map<String, HostVmStateReportEntry> vmPowerStates, String hypervisorVersion) {
127-
this(cpus, speed, memory, dom0MinMemory, caps, hypervisorType, hostDetails, vms, vmPowerStates);
128-
this.hypervisorVersion = hypervisorVersion;
65+
public StartupRoutingCommand(int cpus, long speed, long memory, long dom0MinMemory, String caps, HypervisorType hypervisorType,
66+
RouterPrivateIpStrategy privIpStrategy) {
67+
this(cpus, speed, memory, dom0MinMemory, caps, hypervisorType);
68+
getHostDetails().put(RouterPrivateIpStrategy.class.getCanonicalName(), privIpStrategy.toString());
12969
}
13070

131-
public void setChanges(Map<String, VmState> vms) {
132-
this.vms = vms;
133-
}
13471

135-
public void setStateChanges(Map<String, State> vms) {
136-
for (String vm_name : vms.keySet()) {
137-
if (this.vms == null) {
138-
this.vms = new HashMap<String, VmState>();
139-
}
140-
this.vms.put(vm_name, new VmState(vms.get(vm_name), null));
141-
}
72+
public StartupRoutingCommand(int cpus2, long speed2, long memory2, long dom0MinMemory2, String caps2, HypervisorType hypervisorType2) {
73+
this(cpus2, speed2, memory2, dom0MinMemory2, caps2, hypervisorType2, new HashMap<String, String>());
14274
}
14375

144-
public void setClusterVMStateChanges(HashMap<String, Pair<String, State>> allStates) {
145-
_clusterVMStates = allStates;
146-
}
14776

14877
public Integer getCpuSockets() {
14978
return cpuSockets;
@@ -169,14 +98,6 @@ public long getDom0MinMemory() {
16998
return dom0MinMemory;
17099
}
171100

172-
public Map<String, VmState> getVmStates() {
173-
return vms;
174-
}
175-
176-
public HashMap<String, Pair<String, State>> getClusterVMStateChanges() {
177-
return _clusterVMStates;
178-
}
179-
180101
public void setSpeed(long speed) {
181102
this.speed = speed;
182103
}
@@ -241,14 +162,6 @@ public void setHypervisorVersion(String hypervisorVersion) {
241162
this.hypervisorVersion = hypervisorVersion;
242163
}
243164

244-
public Map<String, HostVmStateReportEntry> getHostVmStateReport() {
245-
return this._hostVmStateReport;
246-
}
247-
248-
public void setHostVmStateReport(Map<String, HostVmStateReportEntry> hostVmStateReport) {
249-
this._hostVmStateReport = hostVmStateReport;
250-
}
251-
252165
public HashMap<String, HashMap<String, VgpuTypesInfo>> getGpuGroupDetails() {
253166
return groupDetails;
254167
}

engine/orchestration/src/com/cloud/agent/manager/AgentManagerImpl.java

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1184,13 +1184,9 @@ protected void processRequest(final Link link, final Request request) {
11841184
if (s_logger.isDebugEnabled()) {
11851185
if (cmd instanceof PingRoutingCommand) {
11861186
final PingRoutingCommand ping = (PingRoutingCommand)cmd;
1187-
if (ping.getNewStates().size() > 0) {
1188-
s_logger.debug("SeqA " + hostId + "-" + request.getSequence() + ": Processing " + request);
1189-
} else {
1190-
logD = false;
1191-
s_logger.debug("Ping from " + hostId);
1192-
s_logger.trace("SeqA " + hostId + "-" + request.getSequence() + ": Processing " + request);
1193-
}
1187+
logD = false;
1188+
s_logger.debug("Ping from " + hostId);
1189+
s_logger.trace("SeqA " + hostId + "-" + request.getSequence() + ": Processing " + request);
11941190
} else if (cmd instanceof PingCommand) {
11951191
logD = false;
11961192
s_logger.debug("Ping from " + hostId);

0 commit comments

Comments
 (0)