+ @Getter
+ private final String producerSupervisionCallbackUrl;
+
+ private final Set<String> enabledJobs = new HashSet<>();
+
+ private int unresponsiveCounter = 0;
+
+ public EiProducer(String id, Collection<EiType> eiTypes, String jobCallbackUrl,
+ String producerSupervisionCallbackUrl) {
+ this.id = id;
+ this.eiTypes = eiTypes;
+ this.jobCallbackUrl = jobCallbackUrl;
+ this.producerSupervisionCallbackUrl = producerSupervisionCallbackUrl;
+ }
+
+ public synchronized void setAliveStatus(boolean isAlive) {
+ if (isAlive) {
+ unresponsiveCounter = 0;
+ } else {
+ unresponsiveCounter++;
+ }
+ }
+
+ public synchronized boolean isDead() {
+ return this.unresponsiveCounter >= 3;
+ }
+
+ public synchronized boolean isAvailable() {
+ return this.unresponsiveCounter == 0;
+ }
+
+ public synchronized void setJobEnabled(EiJob job) {
+ this.enabledJobs.add(job.getId());
+ }
+
+ public synchronized void setJobDisabled(EiJob job) {
+ this.enabledJobs.remove(job.getId());
+ }
+
+ /**
+ * Is the job enabled for this producer?
+ */
+ public synchronized boolean isJobEnabled(EiJob job) {
+ return this.enabledJobs.contains(job.getId());
+ }