Skip to content

Commit 35ea8e1

Browse files
committed
Fix errors in bringing up user VM under new VMsync framework
1 parent 03a9445 commit 35ea8e1

5 files changed

Lines changed: 30 additions & 28 deletions

File tree

engine/schema/src/com/cloud/vm/dao/NicDaoImpl.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ public NicDaoImpl() {
5353
AllFieldsSearch.and("broadcastUri", AllFieldsSearch.entity().getBroadcastUri(), Op.EQ);
5454
AllFieldsSearch.and("secondaryip", AllFieldsSearch.entity().getSecondaryIp(), Op.EQ);
5555
AllFieldsSearch.and("nicid", AllFieldsSearch.entity().getId(), Op.EQ);
56+
AllFieldsSearch.and("strategy", AllFieldsSearch.entity().getReservationStrategy(), Op.EQ);
5657
AllFieldsSearch.done();
5758

5859
IpSearch = createSearchBuilder(String.class);

framework/jobs/src/org/apache/cloudstack/framework/jobs/impl/AsyncJobMonitor.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,12 @@ public void unregisterActiveTask(long jobId) {
141141
}
142142
}
143143

144+
public boolean isJobActive(long jobId) {
145+
synchronized(this) {
146+
return _activeTasks.get(jobId) != null;
147+
}
148+
}
149+
144150
public int getActivePoolThreads() {
145151
return _activePoolThreads;
146152
}

server/src/com/cloud/async/AsyncJobManagerImpl.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -535,13 +535,17 @@ public void run() {
535535
}
536536

537537
if((getAndResetPendingSignals(job) & AsyncJobConstants.SIGNAL_MASK_WAKEUP) != 0) {
538-
AsyncJobDispatcher jobDispatcher = getWakeupDispatcher(job);
539-
if(jobDispatcher != null) {
540-
jobDispatcher.runJob(job);
541-
} else {
542-
s_logger.error("Unable to find a wakeup dispatcher from the joined job. job-" + job.getId());
538+
if(!_jobMonitor.isJobActive(job.getId())) {
539+
AsyncJobDispatcher jobDispatcher = getWakeupDispatcher(job);
540+
if(jobDispatcher != null) {
541+
jobDispatcher.runJob(job);
542+
} else {
543+
s_logger.error("Unable to find a wakeup dispatcher from the joined job. job-" + job.getId());
544+
}
543545
}
544546
} else {
547+
assert(_jobMonitor.isJobActive(job.getId()));
548+
545549
AsyncJobDispatcher jobDispatcher = getDispatcher(job.getDispatcher());
546550
if(jobDispatcher != null) {
547551
jobDispatcher.runJob(job);

server/src/com/cloud/vm/VmWorkStart.java

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -51,19 +51,23 @@ public VmWorkStart() {
5151
}
5252

5353
public DeploymentPlan getPlan() {
54-
// this is ugly, to work with legacy code, we need to re-construct the DeploymentPlan hard-codely
55-
// this has to be refactored together with migrating legacy code into the new way
5654

57-
ReservationContext context = null;
58-
if(reservationId != null) {
59-
Journal journal = new Journal.LogJournal("VmWorkStart", s_logger);
60-
context = new ReservationContextImpl(reservationId, journal, CallContext.current().getCallingUser(), CallContext.current().getCallingAccount());
55+
if(podId != null || clusterId != null || hostId != null || poolId != null || physicalNetworkId != null) {
56+
// this is ugly, to work with legacy code, we need to re-construct the DeploymentPlan hard-codely
57+
// this has to be refactored together with migrating legacy code into the new way
58+
ReservationContext context = null;
59+
if(reservationId != null) {
60+
Journal journal = new Journal.LogJournal("VmWorkStart", s_logger);
61+
context = new ReservationContextImpl(reservationId, journal, CallContext.current().getCallingUser(), CallContext.current().getCallingAccount());
62+
}
63+
64+
DeploymentPlan plan = new DataCenterDeployment(
65+
dcId, podId, clusterId, hostId, poolId, physicalNetworkId,
66+
context);
67+
return plan;
6168
}
6269

63-
DeploymentPlan plan = new DataCenterDeployment(
64-
dcId, podId, clusterId, hostId, poolId, physicalNetworkId,
65-
context);
66-
return plan;
70+
return null;
6771
}
6872

6973
public void setPlan(DeploymentPlan plan) {

server/test/com/cloud/vm/VmWorkMockVirtualMachineManagerImpl.java

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
package com.cloud.vm;
1818

1919
import java.net.URI;
20-
import java.util.Collection;
2120
import java.util.List;
2221
import java.util.Map;
2322

@@ -165,18 +164,6 @@ public void registerGuru(Type type, VirtualMachineGuru guru) {
165164

166165
}
167166

168-
@Override
169-
public Collection<VirtualMachineGuru> getRegisteredGurus() {
170-
// TODO Auto-generated method stub
171-
return null;
172-
}
173-
174-
@Override
175-
public VirtualMachineGuru getVmGuru(VirtualMachine vm) {
176-
// TODO Auto-generated method stub
177-
return null;
178-
}
179-
180167
@Override
181168
public boolean stateTransitTo(VMInstanceVO vm, Event e, Long hostId)
182169
throws NoTransitionException {

0 commit comments

Comments
 (0)