Skip to content

Commit

Permalink
[cuebot] Fix issue #1572 (#1573)
Browse files Browse the repository at this point in the history
Changes added on
#1570 caused a
NullPointerException due to an incorrect @autowire property.

Fixes #1572
  • Loading branch information
DiegoTavares authored Nov 6, 2024
1 parent 3341bcb commit 12f3a41
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ public class FrameCompleteHandler {
private WhiteboardDao whiteboardDao;
private ServiceDao serviceDao;
private ShowDao showDao;
private Environment env;

/*
* The last time a proc was unbooked for subscription or job balancing.
Expand Down Expand Up @@ -122,6 +123,7 @@ public void setSatisfyDependOnlyOnFrameSuccess(boolean satisfyDependOnlyOnFrameS

@Autowired
public FrameCompleteHandler(Environment env) {
this.env = env;
satisfyDependOnlyOnFrameSuccess = env.getProperty(
"depend.satisfy_only_on_frame_success", Boolean.class, true);
}
Expand Down Expand Up @@ -460,7 +462,7 @@ else if (report.getHost().getNimbyLocked()) {
&& dispatchSupport.isCueBookable(job)) {

bookingQueue.execute(new DispatchBookHost(hostManager
.getDispatchHost(proc.getHostId()), dispatcher));
.getDispatchHost(proc.getHostId()), dispatcher, env));
}

if (job.state.equals(JobState.FINISHED)) {
Expand Down Expand Up @@ -509,7 +511,7 @@ else if (report.getHost().getNimbyLocked()) {
hostManager.getDispatchHost(proc.getHostId());

bookingQueue.execute(
new DispatchBookHost(host, dispatcher));
new DispatchBookHost(host, dispatcher, env));
return;
}
} catch (JobLookupException e) {
Expand Down Expand Up @@ -538,7 +540,7 @@ else if (report.getHost().getNimbyLocked()) {
dispatchSupport.strandCores(host, stranded_cores);
dispatchSupport.unbookProc(proc);
bookingQueue.execute(new DispatchBookHost(host, job,
dispatcher));
dispatcher, env));
return;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -320,11 +320,11 @@ else if (!dispatchSupport.isCueBookable(host)) {
*/
if (hostManager.isPreferShow(host)) {
bookingQueue.execute(new DispatchBookHost(
host, hostManager.getPreferredShow(host), dispatcher));
host, hostManager.getPreferredShow(host), dispatcher, env));
return;
}

bookingQueue.execute(new DispatchBookHost(host, dispatcher));
bookingQueue.execute(new DispatchBookHost(host, dispatcher, env));
}

} finally {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;

import com.imageworks.spcue.DispatchHost;
import com.imageworks.spcue.GroupInterface;
import com.imageworks.spcue.JobInterface;
Expand Down Expand Up @@ -59,8 +62,11 @@ public class RedirectManager {
private DispatchSupport dispatchSupport;
private RedirectService redirectService;
private ProcSearchFactory procSearchFactory;
private Environment env;

public RedirectManager(RedirectService redirectService) {
@Autowired
public RedirectManager(RedirectService redirectService, Environment env) {
this.env = env;
this.redirectService = redirectService;
}

Expand Down Expand Up @@ -332,7 +338,7 @@ public boolean redirect(VirtualProc proc) {
}
else {
bookingQueue.execute(new
DispatchBookHost(host, job, dispatcher));
DispatchBookHost(host, job, dispatcher, env));
}
return true;

Expand All @@ -348,7 +354,7 @@ public boolean redirect(VirtualProc proc) {
}
else {
bookingQueue.execute(new DispatchBookHost(host,
group, dispatcher));
group, dispatcher, env));
}
return true;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
*/
public class DispatchBookHost extends KeyRunnable {

@Autowired
private Environment env;
private ShowInterface show = null;
private GroupInterface group = null;
Expand All @@ -48,31 +47,35 @@ public DispatchHost getDispatchHost() {
return host;
}

public DispatchBookHost(DispatchHost host, Dispatcher d) {
public DispatchBookHost(DispatchHost host, Dispatcher d, Environment env) {
super(host.getId());
this.host = host;
this.dispatcher = d;
this.env = env;
}

public DispatchBookHost(DispatchHost host, JobInterface job, Dispatcher d) {
public DispatchBookHost(DispatchHost host, JobInterface job, Dispatcher d, Environment env) {
super(host.getId() + "_job_" + job.getJobId());
this.host = host;
this.job = job;
this.dispatcher = d;
this.env = env;
}

public DispatchBookHost(DispatchHost host, GroupInterface group, Dispatcher d) {
public DispatchBookHost(DispatchHost host, GroupInterface group, Dispatcher d, Environment env) {
super(host.getId() + "_group_" + group.getGroupId());
this.host = host;
this.group = group;
this.dispatcher = d;
this.env = env;
}

public DispatchBookHost(DispatchHost host, ShowInterface show, Dispatcher d) {
public DispatchBookHost(DispatchHost host, ShowInterface show, Dispatcher d, Environment env) {
super(host.getId() + "_name_" + show.getName());
this.host = host;
this.show = show;
this.dispatcher = d;
this.env = env;
}

public void run() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
import org.springframework.test.context.junit4.AbstractTransactionalJUnit4SpringContextTests;
import org.springframework.test.context.support.AnnotationConfigContextLoader;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.core.env.Environment;
import org.springframework.beans.factory.annotation.Autowired;

import com.imageworks.spcue.DispatchHost;
import com.imageworks.spcue.config.TestAppConfig;
Expand Down Expand Up @@ -57,6 +59,9 @@ public class TestBookingQueue extends AbstractTransactionalJUnit4SpringContextTe
@Resource
BookingQueue bookingQueue;

@Autowired
Environment env;

private static final String HOSTNAME = "beta";

@Before
Expand Down Expand Up @@ -102,9 +107,9 @@ public void testBookingQueue() {
DispatchHost host3 = hostDao.findDispatchHost(HOSTNAME);
BookingQueue queue = new BookingQueue(healthThreshold, minUnhealthyPeriodMin, queueCapacity,
corePoolSize, maxPoolSize);
bookingQueue.execute(new DispatchBookHost(host2,dispatcher));
bookingQueue.execute(new DispatchBookHost(host3,dispatcher));
bookingQueue.execute(new DispatchBookHost(host1,dispatcher));
bookingQueue.execute(new DispatchBookHost(host2,dispatcher, env));
bookingQueue.execute(new DispatchBookHost(host3,dispatcher, env));
bookingQueue.execute(new DispatchBookHost(host1,dispatcher, env));
try {
Thread.sleep(10000);
} catch (InterruptedException e) {
Expand Down

0 comments on commit 12f3a41

Please sign in to comment.