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

com.facebook.presto.spark.launcher.PrestoSparkRunnerContext Maven / Gradle / Ivy

There is a newer version: 0.290
Show newest version
/*
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.facebook.presto.spark.launcher;

import com.facebook.presto.spark.classloader_interface.ExecutionStrategy;

import java.security.Principal;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;

import static java.util.Objects.requireNonNull;

public class PrestoSparkRunnerContext
{
    private final String user;
    private final Optional principal;
    private final Map extraCredentials;
    private final String catalog;
    private final String schema;
    private final Optional source;
    private final Optional userAgent;
    private final Optional clientInfo;
    private final Set clientTags;
    private final Map sessionProperties;
    private final Map> catalogSessionProperties;
    private final Optional sqlText;
    private final Optional sqlLocation;
    private final Optional sqlFileHexHash;
    private final Optional sqlFileSizeInBytes;
    private final Optional traceToken;
    private final Optional sparkQueueName;
    private final Optional queryStatusInfoOutputLocation;
    private final Optional queryDataOutputLocation;
    private final List executionStrategies;

    public PrestoSparkRunnerContext(
            String user,
            Optional principal,
            Map extraCredentials,
            String catalog,
            String schema,
            Optional source,
            Optional userAgent,
            Optional clientInfo,
            Set clientTags,
            Map sessionProperties,
            Map> catalogSessionProperties,
            Optional sqlText,
            Optional sqlLocation,
            Optional sqlFileHexHash,
            Optional sqlFileSizeInBytes,
            Optional traceToken,
            Optional sparkQueueName,
            Optional queryStatusInfoOutputLocation,
            Optional queryDataOutputLocation,
            List executionStrategies)
    {
        this.user = user;
        this.principal = principal;
        this.extraCredentials = extraCredentials;
        this.catalog = catalog;
        this.schema = schema;
        this.source = source;
        this.userAgent = userAgent;
        this.clientInfo = clientInfo;
        this.clientTags = clientTags;
        this.sessionProperties = sessionProperties;
        this.catalogSessionProperties = catalogSessionProperties;
        this.sqlText = sqlText;
        this.sqlLocation = sqlLocation;
        this.sqlFileHexHash = sqlFileHexHash;
        this.sqlFileSizeInBytes = sqlFileSizeInBytes;
        this.traceToken = traceToken;
        this.sparkQueueName = sparkQueueName;
        this.queryStatusInfoOutputLocation = queryStatusInfoOutputLocation;
        this.queryDataOutputLocation = queryDataOutputLocation;
        this.executionStrategies = executionStrategies;
    }

    public String getUser()
    {
        return user;
    }

    public Optional getPrincipal()
    {
        return principal;
    }

    public Map getExtraCredentials()
    {
        return extraCredentials;
    }

    public String getCatalog()
    {
        return catalog;
    }

    public String getSchema()
    {
        return schema;
    }

    public Optional getSource()
    {
        return source;
    }

    public Optional getUserAgent()
    {
        return userAgent;
    }

    public Optional getClientInfo()
    {
        return clientInfo;
    }

    public Set getClientTags()
    {
        return clientTags;
    }

    public Map getSessionProperties()
    {
        return sessionProperties;
    }

    public Map> getCatalogSessionProperties()
    {
        return catalogSessionProperties;
    }

    public Optional getSqlText()
    {
        return sqlText;
    }

    public Optional getSqlLocation()
    {
        return sqlLocation;
    }

    public Optional getSqlFileHexHash()
    {
        return sqlFileHexHash;
    }

    public Optional getSqlFileSizeInBytes()
    {
        return sqlFileSizeInBytes;
    }

    public Optional getTraceToken()
    {
        return traceToken;
    }

    public Optional getSparkQueueName()
    {
        return sparkQueueName;
    }

    public Optional getQueryStatusInfoOutputLocation()
    {
        return queryStatusInfoOutputLocation;
    }

    public Optional getQueryDataOutputLocation()
    {
        return queryDataOutputLocation;
    }

    public List getExecutionStrategies()
    {
        return executionStrategies;
    }

    public static class Builder
    {
        private String user;
        private Optional principal;
        private Map extraCredentials;
        private String catalog;
        private String schema;
        private Optional source;
        private Optional userAgent;
        private Optional clientInfo;
        private Set clientTags;
        private Map sessionProperties;
        private Map> catalogSessionProperties;
        private Optional sqlText;
        private Optional sqlLocation;
        private Optional sqlFileHexHash;
        private Optional sqlFileSizeInBytes;
        private Optional traceToken;
        private Optional sparkQueueName;
        private Optional queryStatusInfoOutputLocation;
        private Optional queryDataOutputLocation;
        private List executionStrategies;

        public Builder(PrestoSparkRunnerContext prestoSparkRunnerContext)
        {
            this.user = prestoSparkRunnerContext.getUser();
            this.principal = prestoSparkRunnerContext.getPrincipal();
            this.extraCredentials = prestoSparkRunnerContext.getExtraCredentials();
            this.catalog = prestoSparkRunnerContext.getCatalog();
            this.schema = prestoSparkRunnerContext.getSchema();
            this.source = prestoSparkRunnerContext.getSource();
            this.userAgent = prestoSparkRunnerContext.getUserAgent();
            this.clientInfo = prestoSparkRunnerContext.getClientInfo();
            this.clientTags = prestoSparkRunnerContext.getClientTags();
            this.sessionProperties = prestoSparkRunnerContext.getSessionProperties();
            this.catalogSessionProperties = prestoSparkRunnerContext.getCatalogSessionProperties();
            this.sqlText = prestoSparkRunnerContext.getSqlText();
            this.sqlLocation = prestoSparkRunnerContext.getSqlLocation();
            this.sqlFileHexHash = prestoSparkRunnerContext.getSqlFileHexHash();
            this.sqlFileSizeInBytes = prestoSparkRunnerContext.getSqlFileSizeInBytes();
            this.traceToken = prestoSparkRunnerContext.getTraceToken();
            this.sparkQueueName = prestoSparkRunnerContext.getSparkQueueName();
            this.queryStatusInfoOutputLocation = prestoSparkRunnerContext.getQueryStatusInfoOutputLocation();
            this.queryDataOutputLocation = prestoSparkRunnerContext.getQueryDataOutputLocation();
            this.executionStrategies = prestoSparkRunnerContext.getExecutionStrategies();
        }

        public Builder setExecutionStrategies(List executionStrategies)
        {
            this.executionStrategies = requireNonNull(executionStrategies, "executionStrategies is null");
            return this;
        }

        public PrestoSparkRunnerContext build()
        {
            return new PrestoSparkRunnerContext(
                    user,
                    principal,
                    extraCredentials,
                    catalog,
                    schema,
                    source,
                    userAgent,
                    clientInfo,
                    clientTags,
                    sessionProperties,
                    catalogSessionProperties,
                    sqlText,
                    sqlLocation,
                    sqlFileHexHash,
                    sqlFileSizeInBytes,
                    traceToken,
                    sparkQueueName,
                    queryStatusInfoOutputLocation,
                    queryDataOutputLocation,
                    executionStrategies);
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy