All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.deepsense.neptune.clientlibrary.models.impl.context.NeptuneContextImpl Maven / Gradle / Ivy

There is a newer version: 1.6.1
Show newest version
/**
 * Copyright (c) 2016, CodiLime Inc.
 */

package io.deepsense.neptune.clientlibrary.models.impl.context;

import com.google.common.base.Preconditions;
import io.deepsense.neptune.clientlibrary.models.Job;
import io.deepsense.neptune.clientlibrary.models.JobParameters;
import io.deepsense.neptune.clientlibrary.models.NeptuneContext;
import io.deepsense.neptune.clientlibrary.models.impl.job.JobBuilder;
import io.deepsense.neptune.clientlibrary.models.impl.parameters.JobParametersFactory;
import io.deepsense.neptune.clientlibrary.services.apimodelconverter.ApiModelConverter;
import io.deepsense.neptune.clientlibrary.services.apimodelconverter.ApiModelConverterFactory;
import io.deepsense.neptune.clientlibrary.services.apiservice.ApiService;
import io.deepsense.neptune.clientlibrary.services.apiservice.ApiServiceBuilder;
import io.deepsense.neptune.clientlibrary.threads.ChannelValueSendingThread;

import java.net.URI;

public final class NeptuneContextImpl implements NeptuneContext {

    private final ApiService apiService;

    private final ApiModelConverter apiModelConverter;

    private final ChannelValueSendingThread channelValueSendingThread;

    private final Job job;

    private final URI dumpDirUrl;

    private final JobParameters parameters;

    NeptuneContextImpl(
            ApiModelConverterFactory apiModelConverterFactory,
            ApiServiceBuilder apiServiceBuilder,
            ChannelValueSendingThread channelValueSendingThread,
            JobBuilder jobBuilder,
            JobParametersFactory jobParametersFactory,
            URI dumpDirUrl) {

        this.apiModelConverter = Preconditions.checkNotNull(apiModelConverterFactory).create();

        this.apiService = Preconditions.checkNotNull(apiServiceBuilder)
                .withApiModelConverter(apiModelConverter)
                .build();

        this.dumpDirUrl = Preconditions.checkNotNull(dumpDirUrl);

        this.channelValueSendingThread = Preconditions.checkNotNull(channelValueSendingThread);

        this.job = Preconditions.checkNotNull(jobBuilder)
                .withChannelValueSendingProxy(channelValueSendingThread)
                .build();

        this.parameters = Preconditions.checkNotNull(jobParametersFactory).create();

        startThreads();
    }

    @Override
    public Job getJob() {
        return job;
    }

    @Override
    public URI getDumpDirUrl() {
        return dumpDirUrl;
    }

    @Override
    public JobParameters getParams() {
        return parameters;
    }

    private void startThreads() {
        channelValueSendingThread.start();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy