Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 /*
  * 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.server;
import static io.airlift.http.client.HttpUriBuilder.uriBuilderFrom;
public class HttpLocationFactory
        implements LocationFactory
    private final NodeManager nodeManager;
    private final URI baseUri;
    @Inject
    public HttpLocationFactory(NodeManager nodeManagerHttpServerInfo httpServerInfo)
    {
        this(nodeManagerhttpServerInfo.getHttpUri());
    }
    public HttpLocationFactory(NodeManager nodeManagerURI baseUri)
    {
        this. = nodeManager;
        this. = baseUri;
    }
    @Override
    public URI createQueryLocation(QueryId queryId)
    {
        Preconditions.checkNotNull(queryId"queryId is null");
        return uriBuilderFrom()
                .appendPath("/v1/query")
                .appendPath(queryId.toString())
                .build();
    }
    @Override
    public URI createStageLocation(StageId stageId)
    {
        Preconditions.checkNotNull(stageId"stageId is null");
        return uriBuilderFrom()
                .appendPath("v1/stage")
                .appendPath(stageId.toString())
                .build();
    }
    @Override
    public URI createLocalTaskLocation(TaskId taskId)
    {
        return createTaskLocation(.getCurrentNode(), taskId);
    }
    @Override
    public URI createTaskLocation(Node nodeTaskId taskId)
    {
        Preconditions.checkNotNull(node"node is null");
        Preconditions.checkNotNull(taskId"taskId is null");
        return uriBuilderFrom(node.getHttpUri())
                .appendPath("/v1/task")
                .appendPath(taskId.toString())
                .build();
    }
New to GrepCode? Check out our FAQ X