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

io.prestosql.server.TaskUpdateRequest Maven / Gradle / Ivy

There is a newer version: 350
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 io.prestosql.server;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.common.collect.ImmutableList;
import io.prestosql.SessionRepresentation;
import io.prestosql.execution.TaskSource;
import io.prestosql.execution.buffer.OutputBuffers;
import io.prestosql.sql.planner.PlanFragment;

import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.OptionalInt;

import static com.google.common.base.MoreObjects.toStringHelper;
import static java.util.Objects.requireNonNull;

public class TaskUpdateRequest
{
    private final SessionRepresentation session;
    // extraCredentials is stored separately from SessionRepresentation to avoid being leaked
    private final Map extraCredentials;
    private final Optional fragment;
    private final List sources;
    private final OutputBuffers outputIds;
    private final OptionalInt totalPartitions;

    @JsonCreator
    public TaskUpdateRequest(
            @JsonProperty("session") SessionRepresentation session,
            @JsonProperty("extraCredentials") Map extraCredentials,
            @JsonProperty("fragment") Optional fragment,
            @JsonProperty("sources") List sources,
            @JsonProperty("outputIds") OutputBuffers outputIds,
            @JsonProperty("totalPartitions") OptionalInt totalPartitions)
    {
        requireNonNull(session, "session is null");
        requireNonNull(extraCredentials, "credentials is null");
        requireNonNull(fragment, "fragment is null");
        requireNonNull(sources, "sources is null");
        requireNonNull(outputIds, "outputIds is null");
        requireNonNull(totalPartitions, "totalPartitions is null");

        this.session = session;
        this.extraCredentials = extraCredentials;
        this.fragment = fragment;
        this.sources = ImmutableList.copyOf(sources);
        this.outputIds = outputIds;
        this.totalPartitions = totalPartitions;
    }

    @JsonProperty
    public SessionRepresentation getSession()
    {
        return session;
    }

    @JsonProperty
    public Map getExtraCredentials()
    {
        return extraCredentials;
    }

    @JsonProperty
    public Optional getFragment()
    {
        return fragment;
    }

    @JsonProperty
    public List getSources()
    {
        return sources;
    }

    @JsonProperty
    public OutputBuffers getOutputIds()
    {
        return outputIds;
    }

    @JsonProperty
    public OptionalInt getTotalPartitions()
    {
        return totalPartitions;
    }

    @Override
    public String toString()
    {
        return toStringHelper(this)
                .add("session", session)
                .add("extraCredentials", extraCredentials.keySet())
                .add("fragment", fragment)
                .add("sources", sources)
                .add("outputIds", outputIds)
                .add("totalPartitions", totalPartitions)
                .toString();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy