src/main/java/io/mantisrx/api/services/JobDiscoveryService.java
private void init() {
            if (!inited.getAndSet(true)) {
                subscription = mantisClient.getSchedulingChanges(jobId)
                        .retryWhen(Util.getRetryFunc(log, "job scheduling information for " + jobId))
                        .doOnError((t) -> {
                            schedulingInfoBehaviorSubjectingSubject.toSerialized().onError(t);
                            doOnZeroConnections.call(jobId);
                        })
                        .doOnCompleted(() -> {
                            schedulingInfoBehaviorSubjectingSubject.toSerialized().onCompleted();
                            doOnZeroConnections.call(jobId);
                        })
                        .subscribeOn(scheduler)
                        .subscribe((schedInfo) -> schedulingInfoBehaviorSubjectingSubject.onNext(schedInfo));
                initComplete.countDown();

            } else {
                try {
                    initComplete.await();
                } catch (InterruptedException e) {
                    log.error(e.getMessage());
                }
            }
        }
/**
         * If invoked the first time it will subscribe to the schedulingInfo Observable via mantisClient and onNext
         * the results to the schedulinginfoSubject
         * If 2 or more threads concurrently invoke this only 1 will do the initialization while others wait.
         */
If invoked the first time it will subscribe to the schedulingInfo Observable via mantisClient and onNext
the results to the schedulinginfoSubject
If 2 or more threads concurrently invoke this only 1 will do the initialization while others wait.
If invoked the first time it will subscribe to the schedulingInfo Observable via mantisClient and onNext the results to the schedulinginfoSubject If 2 or more threads concurrently invoke this only 1 will do the initialization while others wait .
private void init() {
            if (!inited.getAndSet(true)) {
                subscription = mantisClient.getSchedulingChanges(jobId)
                        .retryWhen(Util.getRetryFunc(log, "job scheduling information for " + jobId))
                        .doOnError((t) -> {
                            schedulingInfoBehaviorSubjectingSubject.toSerialized().onError(t);
                            doOnZeroConnections.call(jobId);
                        })
                        .doOnCompleted(() -> {
                            schedulingInfoBehaviorSubjectingSubject.toSerialized().onCompleted();
                            doOnZeroConnections.call(jobId);
                        })
                        .subscribeOn(scheduler)
                        .subscribe((schedInfo) -> schedulingInfoBehaviorSubjectingSubject.onNext(schedInfo));
                initComplete.countDown();
            } else {
                try {
                    initComplete.await();
                } catch (InterruptedException e) {
                    log.error(e.getMessage());
                }
            }
        }
private void init ( ) { if ( ! inited . getAndSet ( true ) ) { subscription = mantisClient . getSchedulingChanges ( jobId ) . retryWhen ( Util . getRetryFunc ( log , "job scheduling information for " + jobId ) ) . doOnError ( ( t ) -> { schedulingInfoBehaviorSubjectingSubject . toSerialized ( ) . onError ( t ) ; doOnZeroConnections . call ( jobId ) ; } ) . doOnCompleted ( ( ) -> { schedulingInfoBehaviorSubjectingSubject . toSerialized ( ) . onCompleted ( ) ; doOnZeroConnections . call ( jobId ) ; } ) . subscribeOn ( scheduler ) . subscribe ( ( schedInfo ) -> schedulingInfoBehaviorSubjectingSubject . onNext ( schedInfo ) ) ; initComplete . countDown ( ) ; } else { try { initComplete . await ( ) ; } catch ( InterruptedException e ) { log . error ( e . getMessage ( ) ) ; } } }
If invoked the first time it will subscribe to the schedulingInfo Observable via mantisClient and onNext
 the results to the schedulinginfoSubject
 If 2 or more threads concurrently invoke this only 1 will do the initialization while others wait.
If invoked the first time it will subscribe to the schedulingInfo Observable via mantisClient and onNext the results to the schedulinginfoSubject If 2 or more threads concurrently invoke this only 1 will do the initialization while others wait .