Skip to content

Commit 12f3a41

Browse files
authored
[cuebot] Fix issue #1572 (#1573)
Changes added on #1570 caused a NullPointerException due to an incorrect @autowire property. Fixes #1572
1 parent 3341bcb commit 12f3a41

File tree

5 files changed

+32
-16
lines changed

5 files changed

+32
-16
lines changed

cuebot/src/main/java/com/imageworks/spcue/dispatcher/FrameCompleteHandler.java

+5-3
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ public class FrameCompleteHandler {
8686
private WhiteboardDao whiteboardDao;
8787
private ServiceDao serviceDao;
8888
private ShowDao showDao;
89+
private Environment env;
8990

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

123124
@Autowired
124125
public FrameCompleteHandler(Environment env) {
126+
this.env = env;
125127
satisfyDependOnlyOnFrameSuccess = env.getProperty(
126128
"depend.satisfy_only_on_frame_success", Boolean.class, true);
127129
}
@@ -460,7 +462,7 @@ else if (report.getHost().getNimbyLocked()) {
460462
&& dispatchSupport.isCueBookable(job)) {
461463

462464
bookingQueue.execute(new DispatchBookHost(hostManager
463-
.getDispatchHost(proc.getHostId()), dispatcher));
465+
.getDispatchHost(proc.getHostId()), dispatcher, env));
464466
}
465467

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

511513
bookingQueue.execute(
512-
new DispatchBookHost(host, dispatcher));
514+
new DispatchBookHost(host, dispatcher, env));
513515
return;
514516
}
515517
} catch (JobLookupException e) {
@@ -538,7 +540,7 @@ else if (report.getHost().getNimbyLocked()) {
538540
dispatchSupport.strandCores(host, stranded_cores);
539541
dispatchSupport.unbookProc(proc);
540542
bookingQueue.execute(new DispatchBookHost(host, job,
541-
dispatcher));
543+
dispatcher, env));
542544
return;
543545
}
544546
}

cuebot/src/main/java/com/imageworks/spcue/dispatcher/HostReportHandler.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -320,11 +320,11 @@ else if (!dispatchSupport.isCueBookable(host)) {
320320
*/
321321
if (hostManager.isPreferShow(host)) {
322322
bookingQueue.execute(new DispatchBookHost(
323-
host, hostManager.getPreferredShow(host), dispatcher));
323+
host, hostManager.getPreferredShow(host), dispatcher, env));
324324
return;
325325
}
326326

327-
bookingQueue.execute(new DispatchBookHost(host, dispatcher));
327+
bookingQueue.execute(new DispatchBookHost(host, dispatcher, env));
328328
}
329329

330330
} finally {

cuebot/src/main/java/com/imageworks/spcue/dispatcher/RedirectManager.java

+9-3
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@
2424
import org.apache.logging.log4j.Logger;
2525
import org.apache.logging.log4j.LogManager;
2626

27+
import org.springframework.beans.factory.annotation.Autowired;
28+
import org.springframework.core.env.Environment;
29+
2730
import com.imageworks.spcue.DispatchHost;
2831
import com.imageworks.spcue.GroupInterface;
2932
import com.imageworks.spcue.JobInterface;
@@ -59,8 +62,11 @@ public class RedirectManager {
5962
private DispatchSupport dispatchSupport;
6063
private RedirectService redirectService;
6164
private ProcSearchFactory procSearchFactory;
65+
private Environment env;
6266

63-
public RedirectManager(RedirectService redirectService) {
67+
@Autowired
68+
public RedirectManager(RedirectService redirectService, Environment env) {
69+
this.env = env;
6470
this.redirectService = redirectService;
6571
}
6672

@@ -332,7 +338,7 @@ public boolean redirect(VirtualProc proc) {
332338
}
333339
else {
334340
bookingQueue.execute(new
335-
DispatchBookHost(host, job, dispatcher));
341+
DispatchBookHost(host, job, dispatcher, env));
336342
}
337343
return true;
338344

@@ -348,7 +354,7 @@ public boolean redirect(VirtualProc proc) {
348354
}
349355
else {
350356
bookingQueue.execute(new DispatchBookHost(host,
351-
group, dispatcher));
357+
group, dispatcher, env));
352358
}
353359
return true;
354360

cuebot/src/main/java/com/imageworks/spcue/dispatcher/commands/DispatchBookHost.java

+8-5
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
*/
3636
public class DispatchBookHost extends KeyRunnable {
3737

38-
@Autowired
3938
private Environment env;
4039
private ShowInterface show = null;
4140
private GroupInterface group = null;
@@ -48,31 +47,35 @@ public DispatchHost getDispatchHost() {
4847
return host;
4948
}
5049

51-
public DispatchBookHost(DispatchHost host, Dispatcher d) {
50+
public DispatchBookHost(DispatchHost host, Dispatcher d, Environment env) {
5251
super(host.getId());
5352
this.host = host;
5453
this.dispatcher = d;
54+
this.env = env;
5555
}
5656

57-
public DispatchBookHost(DispatchHost host, JobInterface job, Dispatcher d) {
57+
public DispatchBookHost(DispatchHost host, JobInterface job, Dispatcher d, Environment env) {
5858
super(host.getId() + "_job_" + job.getJobId());
5959
this.host = host;
6060
this.job = job;
6161
this.dispatcher = d;
62+
this.env = env;
6263
}
6364

64-
public DispatchBookHost(DispatchHost host, GroupInterface group, Dispatcher d) {
65+
public DispatchBookHost(DispatchHost host, GroupInterface group, Dispatcher d, Environment env) {
6566
super(host.getId() + "_group_" + group.getGroupId());
6667
this.host = host;
6768
this.group = group;
6869
this.dispatcher = d;
70+
this.env = env;
6971
}
7072

71-
public DispatchBookHost(DispatchHost host, ShowInterface show, Dispatcher d) {
73+
public DispatchBookHost(DispatchHost host, ShowInterface show, Dispatcher d, Environment env) {
7274
super(host.getId() + "_name_" + show.getName());
7375
this.host = host;
7476
this.show = show;
7577
this.dispatcher = d;
78+
this.env = env;
7679
}
7780

7881
public void run() {

cuebot/src/test/java/com/imageworks/spcue/test/dispatcher/TestBookingQueue.java

+8-3
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
import org.springframework.test.context.junit4.AbstractTransactionalJUnit4SpringContextTests;
3030
import org.springframework.test.context.support.AnnotationConfigContextLoader;
3131
import org.springframework.transaction.annotation.Transactional;
32+
import org.springframework.core.env.Environment;
33+
import org.springframework.beans.factory.annotation.Autowired;
3234

3335
import com.imageworks.spcue.DispatchHost;
3436
import com.imageworks.spcue.config.TestAppConfig;
@@ -57,6 +59,9 @@ public class TestBookingQueue extends AbstractTransactionalJUnit4SpringContextTe
5759
@Resource
5860
BookingQueue bookingQueue;
5961

62+
@Autowired
63+
Environment env;
64+
6065
private static final String HOSTNAME = "beta";
6166

6267
@Before
@@ -102,9 +107,9 @@ public void testBookingQueue() {
102107
DispatchHost host3 = hostDao.findDispatchHost(HOSTNAME);
103108
BookingQueue queue = new BookingQueue(healthThreshold, minUnhealthyPeriodMin, queueCapacity,
104109
corePoolSize, maxPoolSize);
105-
bookingQueue.execute(new DispatchBookHost(host2,dispatcher));
106-
bookingQueue.execute(new DispatchBookHost(host3,dispatcher));
107-
bookingQueue.execute(new DispatchBookHost(host1,dispatcher));
110+
bookingQueue.execute(new DispatchBookHost(host2,dispatcher, env));
111+
bookingQueue.execute(new DispatchBookHost(host3,dispatcher, env));
112+
bookingQueue.execute(new DispatchBookHost(host1,dispatcher, env));
108113
try {
109114
Thread.sleep(10000);
110115
} catch (InterruptedException e) {

0 commit comments

Comments
 (0)