Search in sources :

Example 1 with SinkConnectionStatusObserver

use of io.mantisrx.connector.job.core.SinkConnectionStatusObserver in project mantis by Netflix.

the class JobSource method call.

@Override
public Observable<Observable<MantisServerSentEvent>> call(Context context, Index index) {
    if (targets.isEmpty()) {
        targets = parseInputParameters(context);
    }
    Observable<Observable<MantisServerSentEvent>> sourceObs = null;
    int workerNo = context.getWorkerInfo().getWorkerNumber();
    targets = enforceClientIdConsistency(targets, context.getJobId());
    for (TargetInfo targetInfo : targets) {
        MantisSSEJob job;
        String sourceJobName = targetInfo.sourceJobName;
        String criterion = targetInfo.criterion;
        int samplePerSec = targetInfo.samplePerSec;
        boolean enableMetaMessages = targetInfo.enableMetaMessages;
        LOGGER.info("Processing job " + sourceJobName);
        boolean singleton = false;
        SinkConnectionStatusObserver obs = DefaultSinkConnectionStatusObserver.getInstance(singleton);
        MultiSinkConnectionStatusObserver.INSTANCE.addSinkConnectionObserver(sourceJobName, obs);
        String clientId = targetInfo.clientId;
        if (targetInfo.isBroadcastMode) {
            clientId = clientId + "_" + workerNo;
        }
        boolean enableCompressedBinary = targetInfo.enableCompressedBinary;
        job = getSourceJob(sourceJobName, criterion, clientId, samplePerSec, enableMetaMessages, enableCompressedBinary, obs, Optional.<SinkParameters>empty());
        if (sourceObs == null) {
            sourceObs = job.connectAndGet();
        } else {
            if (job != null) {
                Observable<Observable<MantisServerSentEvent>> clientObs = job.connectAndGet();
                if (clientObs != null) {
                    sourceObs = sourceObs.mergeWith(clientObs);
                } else {
                    LOGGER.error("Could not connect to job " + sourceJobName);
                }
            } else {
                LOGGER.error("Could not connect to job " + sourceJobName);
            }
        }
    }
    return sourceObs;
}
Also used : SinkParameters(io.mantisrx.runtime.parameter.SinkParameters) SinkConnectionStatusObserver(io.mantisrx.connector.job.core.SinkConnectionStatusObserver) MultiSinkConnectionStatusObserver(io.mantisrx.connector.job.core.MultiSinkConnectionStatusObserver) DefaultSinkConnectionStatusObserver(io.mantisrx.connector.job.core.DefaultSinkConnectionStatusObserver) Observable(rx.Observable) MantisSSEJob(io.mantisrx.client.MantisSSEJob)

Aggregations

MantisSSEJob (io.mantisrx.client.MantisSSEJob)1 DefaultSinkConnectionStatusObserver (io.mantisrx.connector.job.core.DefaultSinkConnectionStatusObserver)1 MultiSinkConnectionStatusObserver (io.mantisrx.connector.job.core.MultiSinkConnectionStatusObserver)1 SinkConnectionStatusObserver (io.mantisrx.connector.job.core.SinkConnectionStatusObserver)1 SinkParameters (io.mantisrx.runtime.parameter.SinkParameters)1 Observable (rx.Observable)1