Skip to content

Commit ae7e5b1

Browse files
[cuebot] Refactor MonitoringEventBuilder to Spring-managed bean
Move MonitoringEventBuilder instantiation from inline setter creation to proper Spring dependency injection via applicationContext configuration. Changes: - Wire monitoringEventBuilder bean to dispatchSupport, jobManagerSupport, frameCompleteHandler, and hostReportHandler in applicationContext-service.xml - Simplify setKafkaEventPublisher() setters to just assign the field - Add setMonitoringEventBuilder() setters for Spring injection - Remove try-catch blocks that silently swallowed exceptions in Prometheus metrics and Kafka event publishing (per review feedback) This follows Spring DI best practices where MonitoringEventBuilder is a shared singleton managed by the container rather than being manually instantiated in each class.
1 parent 3ea47e2 commit ae7e5b1

File tree

5 files changed

+24
-16
lines changed

5 files changed

+24
-16
lines changed

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -694,10 +694,11 @@ public KafkaEventPublisher getKafkaEventPublisher() {
694694
}
695695

696696
public void setKafkaEventPublisher(KafkaEventPublisher kafkaEventPublisher) {
697-
if (kafkaEventPublisher != null) {
698-
this.kafkaEventPublisher = kafkaEventPublisher;
699-
this.monitoringEventBuilder = new MonitoringEventBuilder(kafkaEventPublisher);
700-
}
697+
this.kafkaEventPublisher = kafkaEventPublisher;
698+
}
699+
700+
public void setMonitoringEventBuilder(MonitoringEventBuilder monitoringEventBuilder) {
701+
this.monitoringEventBuilder = monitoringEventBuilder;
701702
}
702703

703704
/**

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -765,10 +765,11 @@ public KafkaEventPublisher getKafkaEventPublisher() {
765765
}
766766

767767
public void setKafkaEventPublisher(KafkaEventPublisher kafkaEventPublisher) {
768-
if (kafkaEventPublisher != null) {
769-
this.kafkaEventPublisher = kafkaEventPublisher;
770-
this.monitoringEventBuilder = new MonitoringEventBuilder(kafkaEventPublisher);
771-
}
768+
this.kafkaEventPublisher = kafkaEventPublisher;
769+
}
770+
771+
public void setMonitoringEventBuilder(MonitoringEventBuilder monitoringEventBuilder) {
772+
this.monitoringEventBuilder = monitoringEventBuilder;
772773
}
773774

774775
public PrometheusMetricsCollector getPrometheusMetrics() {

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1118,10 +1118,11 @@ public KafkaEventPublisher getKafkaEventPublisher() {
11181118
}
11191119

11201120
public void setKafkaEventPublisher(KafkaEventPublisher kafkaEventPublisher) {
1121-
if (kafkaEventPublisher != null) {
1122-
this.kafkaEventPublisher = kafkaEventPublisher;
1123-
this.monitoringEventBuilder = new MonitoringEventBuilder(kafkaEventPublisher);
1124-
}
1121+
this.kafkaEventPublisher = kafkaEventPublisher;
1122+
}
1123+
1124+
public void setMonitoringEventBuilder(MonitoringEventBuilder monitoringEventBuilder) {
1125+
this.monitoringEventBuilder = monitoringEventBuilder;
11251126
}
11261127

11271128
/**

cuebot/src/main/java/com/imageworks/spcue/service/JobManagerSupport.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -659,9 +659,10 @@ public KafkaEventPublisher getKafkaEventPublisher() {
659659
}
660660

661661
public void setKafkaEventPublisher(KafkaEventPublisher kafkaEventPublisher) {
662-
if (kafkaEventPublisher != null) {
663-
this.kafkaEventPublisher = kafkaEventPublisher;
664-
this.monitoringEventBuilder = new MonitoringEventBuilder(kafkaEventPublisher);
665-
}
662+
this.kafkaEventPublisher = kafkaEventPublisher;
663+
}
664+
665+
public void setMonitoringEventBuilder(MonitoringEventBuilder monitoringEventBuilder) {
666+
this.monitoringEventBuilder = monitoringEventBuilder;
666667
}
667668
}

cuebot/src/main/resources/conf/spring/applicationContext-service.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@
196196
<property name="bookingManager" ref="bookingManager" />
197197
<property name="bookingDao" ref="bookingDao" />
198198
<property name="kafkaEventPublisher" ref="kafkaEventPublisher" />
199+
<property name="monitoringEventBuilder" ref="monitoringEventBuilder" />
199200
</bean>
200201

201202
<bean id="filterManager" class="com.imageworks.spcue.service.FilterManagerService">
@@ -252,6 +253,7 @@
252253
<property name="prometheusMetrics" ref="prometheusMetricsCollector" />
253254
<property name="showDao" ref="showDao" />
254255
<property name="kafkaEventPublisher" ref="kafkaEventPublisher" />
256+
<property name="monitoringEventBuilder" ref="monitoringEventBuilder" />
255257
</bean>
256258

257259
<bean id="jobLauncher" class="com.imageworks.spcue.service.JobLauncher">
@@ -385,6 +387,7 @@
385387
<property name="showDao" ref="showDao" />
386388
<property name="kafkaEventPublisher" ref="kafkaEventPublisher" />
387389
<property name="prometheusMetrics" ref="prometheusMetricsCollector" />
390+
<property name="monitoringEventBuilder" ref="monitoringEventBuilder" />
388391
</bean>
389392

390393
<bean id="hostReportHandler" class="com.imageworks.spcue.dispatcher.HostReportHandler" destroy-method="shutdown">
@@ -401,6 +404,7 @@
401404
<property name="layerDao" ref="layerDao" />
402405
<property name="killQueue" ref="killQueue"/>
403406
<property name="kafkaEventPublisher" ref="kafkaEventPublisher" />
407+
<property name="monitoringEventBuilder" ref="monitoringEventBuilder" />
404408
</bean>
405409

406410
<!-- ##################################################################################### -->

0 commit comments

Comments
 (0)