当前位置: 首页>>代码示例>>Java>>正文


Java QueryInProgress类代码示例

本文整理汇总了Java中org.apache.tajo.master.querymaster.QueryInProgress的典型用法代码示例。如果您正苦于以下问题:Java QueryInProgress类的具体用法?Java QueryInProgress怎么用?Java QueryInProgress使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


QueryInProgress类属于org.apache.tajo.master.querymaster包,在下文中一共展示了QueryInProgress类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: stopQueryMaster

import org.apache.tajo.master.querymaster.QueryInProgress; //导入依赖的package包/类
@Override
public void stopQueryMaster(QueryId queryId) {
  try {
    FinalApplicationStatus appStatus = FinalApplicationStatus.UNDEFINED;
    QueryInProgress queryInProgress = masterContext.getQueryJobManager().getQueryInProgress(queryId);
    if(queryInProgress == null) {
      return;
    }
    TajoProtos.QueryState state = queryInProgress.getQueryInfo().getQueryState();
    if (state == TajoProtos.QueryState.QUERY_SUCCEEDED) {
      appStatus = FinalApplicationStatus.SUCCEEDED;
    } else if (state == TajoProtos.QueryState.QUERY_FAILED || state == TajoProtos.QueryState.QUERY_ERROR) {
      appStatus = FinalApplicationStatus.FAILED;
    } else if (state == TajoProtos.QueryState.QUERY_ERROR) {
      appStatus = FinalApplicationStatus.FAILED;
    }
    FinishApplicationMasterRequest request = recordFactory
        .newRecordInstance(FinishApplicationMasterRequest.class);
    request.setAppAttemptId(ApplicationIdUtils.createApplicationAttemptId(queryId));
    request.setFinishApplicationStatus(appStatus);
    request.setDiagnostics("QueryMaster shutdown by TajoMaster.");
    rmClient.finishApplicationMaster(request);
  } catch (Exception e) {
    LOG.error(e.getMessage(), e);
  }
}
 
开发者ID:gruter,项目名称:tajo-cdh,代码行数:27,代码来源:YarnTajoResourceManager.java

示例2: stopQueryMaster

import org.apache.tajo.master.querymaster.QueryInProgress; //导入依赖的package包/类
@Override
public void stopQueryMaster(QueryId queryId) {
  try {
    FinalApplicationStatus appStatus = FinalApplicationStatus.UNDEFINED;
    QueryInProgress queryInProgress = masterContext.getQueryJobManager().getQueryInProgress(queryId);
    if(queryInProgress == null) {
      return;
    }
    TajoProtos.QueryState state = queryInProgress.getQueryInfo().getQueryState();
    if (state == TajoProtos.QueryState.QUERY_SUCCEEDED) {
      appStatus = FinalApplicationStatus.SUCCEEDED;
    } else if (state == TajoProtos.QueryState.QUERY_FAILED || state == TajoProtos.QueryState.QUERY_ERROR) {
      appStatus = FinalApplicationStatus.FAILED;
    } else if (state == TajoProtos.QueryState.QUERY_ERROR) {
      appStatus = FinalApplicationStatus.FAILED;
    }
    FinishApplicationMasterRequest request = recordFactory
        .newRecordInstance(FinishApplicationMasterRequest.class);
    request.setFinalApplicationStatus(appStatus);
    request.setDiagnostics("QueryMaster shutdown by TajoMaster.");
    rmClient.finishApplicationMaster(request);
  } catch (Exception e) {
    LOG.error(e.getMessage(), e);
  }
}
 
开发者ID:apache,项目名称:incubator-tajo,代码行数:26,代码来源:YarnTajoResourceManager.java

示例3: allocateQueryMaster

import org.apache.tajo.master.querymaster.QueryInProgress; //导入依赖的package包/类
@Override
public WorkerAllocatedResource allocateQueryMaster(QueryInProgress queryInProgress) {
  // Create a resource request for a query master
  WorkerResourceAllocationRequest qmResourceRequest = createQMResourceRequest(queryInProgress.getQueryId());

  // call future for async call
  CallFuture<WorkerResourceAllocationResponse> callFuture = new CallFuture<WorkerResourceAllocationResponse>();
  allocateWorkerResources(qmResourceRequest, callFuture);

  // Wait for 3 seconds
  WorkerResourceAllocationResponse response = null;
  try {
    response = callFuture.get(3, TimeUnit.SECONDS);
  } catch (Throwable t) {
    LOG.error(t);
    return null;
  }

  if (response.getWorkerAllocatedResourceList().size() == 0) {
    return null;
  }

  WorkerAllocatedResource resource = response.getWorkerAllocatedResource(0);
  registerQueryMaster(queryInProgress.getQueryId(), resource.getContainerId());
  return resource;
}
 
开发者ID:apache,项目名称:incubator-tajo,代码行数:27,代码来源:TajoWorkerResourceManager.java

示例4: sortQueryInProgress

import org.apache.tajo.master.querymaster.QueryInProgress; //导入依赖的package包/类
public static List<QueryInProgress> sortQueryInProgress(Collection<QueryInProgress> queryInProgresses,
                                                        final boolean desc) {
  List<QueryInProgress> queryProgressList = new ArrayList<QueryInProgress>(queryInProgresses);

  Collections.sort(queryProgressList, new Comparator<QueryInProgress>() {
    @Override
    public int compare(QueryInProgress query1, QueryInProgress query2) {
      if(desc) {
        return query2.getQueryId().toString().compareTo(query1.getQueryId().toString());
      } else {
        return query1.getQueryId().toString().compareTo(query2.getQueryId().toString());
      }
    }
  });

  return queryProgressList;
}
 
开发者ID:apache,项目名称:incubator-tajo,代码行数:18,代码来源:JSPUtil.java

示例5: getRunningQueryList

import org.apache.tajo.master.querymaster.QueryInProgress; //导入依赖的package包/类
@Override
public GetQueryListResponse getRunningQueryList(RpcController controller, GetQueryListRequest request)

    throws ServiceException {

  try {
    context.getSessionManager().touch(request.getSessionId().getId());
    GetQueryListResponse.Builder builder= GetQueryListResponse.newBuilder();

    Collection<QueryInProgress> queries
      = context.getQueryJobManager().getRunningQueries();

    BriefQueryInfo.Builder infoBuilder = BriefQueryInfo.newBuilder();

    for (QueryInProgress queryInProgress : queries) {
      QueryInfo queryInfo = queryInProgress.getQueryInfo();

      infoBuilder.setQueryId(queryInfo.getQueryId().getProto());
      infoBuilder.setState(queryInfo.getQueryState());
      infoBuilder.setQuery(queryInfo.getSql());
      infoBuilder.setStartTime(queryInfo.getStartTime());
      long endTime = (queryInfo.getFinishTime() == 0) ?
                     System.currentTimeMillis() : queryInfo.getFinishTime();
      infoBuilder.setFinishTime(endTime);
      infoBuilder.setProgress(queryInfo.getProgress());
      infoBuilder.setQueryMasterPort(queryInfo.getQueryMasterPort());
      infoBuilder.setQueryMasterHost(queryInfo.getQueryMasterHost());

      builder.addQueryList(infoBuilder.build());
    }

    GetQueryListResponse result = builder.build();
    return result;
  } catch (Throwable t) {
    throw new ServiceException(t);
  }
}
 
开发者ID:gruter,项目名称:tajo-cdh,代码行数:38,代码来源:TajoMasterClientService.java

示例6: startQueryMaster

import org.apache.tajo.master.querymaster.QueryInProgress; //导入依赖的package包/类
@Override
public void startQueryMaster(QueryInProgress queryInProgress) {
  WorkerResource queryMasterWorkerResource = null;
  synchronized(workerResourceLock) {
    queryMasterWorkerResource = queryMasterMap.get(queryInProgress.getQueryId());
  }

  if(queryMasterWorkerResource != null) {
    AllocatedWorkerResource allocatedWorkerResource = new AllocatedWorkerResource();
    allocatedWorkerResource.workerResource = queryMasterWorkerResource;
    allocatedWorkerResource.allocatedMemoryMB = queryMasterDefaultMemoryMB;
    allocatedWorkerResource.allocatedDiskSlots = queryMasterDefaultDiskSlot;

    startQueryMaster(queryInProgress.getQueryId(), allocatedWorkerResource);
  } else {
    //add queue
    TajoMasterProtocol.WorkerResourceAllocationRequest request =
        TajoMasterProtocol.WorkerResourceAllocationRequest.newBuilder()
          .setExecutionBlockId(QueryIdFactory.newExecutionBlockId(QueryIdFactory.NULL_QUERY_ID, 0).getProto())
          .setNumContainers(1)
          .setMinMemoryMBPerContainer(queryMasterDefaultMemoryMB)
          .setMaxMemoryMBPerContainer(queryMasterDefaultMemoryMB)
          .setMinDiskSlotPerContainer(queryMasterDefaultDiskSlot)
          .setMaxDiskSlotPerContainer(queryMasterDefaultDiskSlot)
          .setResourceRequestPriority(TajoMasterProtocol.ResourceRequestPriority.MEMORY)
          .build();
    try {
      requestQueue.put(new WorkerResourceRequest(queryInProgress.getQueryId(), true, request, null));
    } catch (InterruptedException e) {
    }
  }
}
 
开发者ID:gruter,项目名称:tajo-cdh,代码行数:33,代码来源:TajoWorkerResourceManager.java

示例7: getQueryResult

import org.apache.tajo.master.querymaster.QueryInProgress; //导入依赖的package包/类
@Override
public GetQueryResultResponse getQueryResult(RpcController controller,
                                             GetQueryResultRequest request)
    throws ServiceException {
  QueryId queryId = new QueryId(request.getQueryId());
  QueryInProgress queryInProgress = context.getQueryJobManager().getQueryInProgress(queryId);
  QueryInfo queryInfo = queryInProgress.getQueryInfo();
  GetQueryResultResponse.Builder builder
      = GetQueryResultResponse.newBuilder();

  try {
    //TODO After implementation Tajo's user security feature, Should be modified.
    builder.setTajoUserName(UserGroupInformation.getCurrentUser().getUserName());
  } catch (IOException e) {
    LOG.warn("Can't get current user name");
  }
  switch (queryInfo.getQueryState()) {
    case QUERY_SUCCEEDED:
      // TODO check this logic needed
      //builder.setTableDesc((TableDescProto) queryJobManager.getResultDesc().getProto());
      break;
    case QUERY_FAILED:
    case QUERY_ERROR:
      builder.setErrorMessage("Query " + queryId + " is failed");
    default:
      builder.setErrorMessage("Query " + queryId + " is still running");
  }

  return builder.build();
}
 
开发者ID:apache,项目名称:incubator-tajo,代码行数:31,代码来源:TajoMasterClientService.java

示例8: getRunningQueryList

import org.apache.tajo.master.querymaster.QueryInProgress; //导入依赖的package包/类
@Override
public GetQueryListResponse getRunningQueryList(RpcController controller,
                                         GetQueryListRequest request)
    throws ServiceException {
  GetQueryListResponse.Builder builder
    = GetQueryListResponse.newBuilder(); 
   
  Collection<QueryInProgress> queries 
    = context.getQueryJobManager().getRunningQueries();

  BriefQueryInfo.Builder infoBuilder = BriefQueryInfo.newBuilder();
 
  for (QueryInProgress queryInProgress : queries) {
    QueryInfo queryInfo = queryInProgress.getQueryInfo();

    infoBuilder.setQueryId(queryInfo.getQueryId().getProto());
    infoBuilder.setState(queryInfo.getQueryState());
    infoBuilder.setQuery(queryInfo.getSql());
    infoBuilder.setStartTime(queryInfo.getStartTime());
    long endTime = (queryInfo.getFinishTime() == 0) ? 
                   System.currentTimeMillis() : queryInfo.getFinishTime();
    infoBuilder.setFinishTime(endTime);
    infoBuilder.setProgress(queryInfo.getProgress());
    infoBuilder.setQueryMasterPort(queryInfo.getQueryMasterPort());
    infoBuilder.setQueryMasterHost(queryInfo.getQueryMasterHost());

    builder.addQueryList(infoBuilder.build());
  }

  GetQueryListResponse result = builder.build();
  return result;
}
 
开发者ID:apache,项目名称:incubator-tajo,代码行数:33,代码来源:TajoMasterClientService.java

示例9: getFinishedQueryList

import org.apache.tajo.master.querymaster.QueryInProgress; //导入依赖的package包/类
@Override
public GetQueryListResponse getFinishedQueryList(RpcController controller,
                                         GetQueryListRequest request)
    throws ServiceException {
  GetQueryListResponse.Builder builder
      = GetQueryListResponse.newBuilder();

  Collection<QueryInProgress> queries
      = context.getQueryJobManager().getFinishedQueries();

  BriefQueryInfo.Builder infoBuilder = BriefQueryInfo.newBuilder();

  for (QueryInProgress queryInProgress : queries) {
    QueryInfo queryInfo = queryInProgress.getQueryInfo();

    infoBuilder.setQueryId(queryInfo.getQueryId().getProto());
    infoBuilder.setState(queryInfo.getQueryState());
    infoBuilder.setQuery(queryInfo.getSql());
    infoBuilder.setStartTime(queryInfo.getStartTime());
    long endTime = (queryInfo.getFinishTime() == 0) ?
        System.currentTimeMillis() : queryInfo.getFinishTime();
    infoBuilder.setFinishTime(endTime);
    infoBuilder.setProgress(queryInfo.getProgress());
    infoBuilder.setQueryMasterPort(queryInfo.getQueryMasterPort());
    infoBuilder.setQueryMasterHost(queryInfo.getQueryMasterHost());

    builder.addQueryList(infoBuilder.build());
  }

  GetQueryListResponse result = builder.build();
  return result;
}
 
开发者ID:apache,项目名称:incubator-tajo,代码行数:33,代码来源:TajoMasterClientService.java

示例10: getQueryStatus

import org.apache.tajo.master.querymaster.QueryInProgress; //导入依赖的package包/类
@Override
public GetQueryStatusResponse getQueryStatus(RpcController controller,
                                             GetQueryStatusRequest request)
    throws ServiceException {

  GetQueryStatusResponse.Builder builder
      = GetQueryStatusResponse.newBuilder();
  QueryId queryId = new QueryId(request.getQueryId());
  builder.setQueryId(request.getQueryId());

  if (queryId.equals(QueryIdFactory.NULL_QUERY_ID)) {
    builder.setResultCode(ResultCode.OK);
    builder.setState(TajoProtos.QueryState.QUERY_SUCCEEDED);
  } else {
    QueryInProgress queryInProgress = context.getQueryJobManager().getQueryInProgress(queryId);
    if (queryInProgress != null) {
      QueryInfo queryInfo = queryInProgress.getQueryInfo();
      builder.setResultCode(ResultCode.OK);
      builder.setState(queryInfo.getQueryState());
      builder.setProgress(queryInfo.getProgress());
      builder.setSubmitTime(queryInfo.getStartTime());
      if(queryInfo.getQueryMasterHost() != null) {
        builder.setQueryMasterHost(queryInfo.getQueryMasterHost());
        builder.setQueryMasterPort(queryInfo.getQueryMasterClientPort());
      }
      //builder.setInitTime(queryJobManager.getInitializationTime());
      //builder.setHasResult(!queryJobManager.isCreateTableStmt());
      if (queryInfo.getQueryState() == TajoProtos.QueryState.QUERY_SUCCEEDED) {
        builder.setFinishTime(queryInfo.getFinishTime());
      } else {
        builder.setFinishTime(System.currentTimeMillis());
      }
    } else {
      builder.setResultCode(ResultCode.ERROR);
      builder.setErrorMessage("No such query: " + queryId.toString());
    }
  }

  return builder.build();
}
 
开发者ID:apache,项目名称:incubator-tajo,代码行数:41,代码来源:TajoMasterClientService.java

示例11: getFinishedQueryList

import org.apache.tajo.master.querymaster.QueryInProgress; //导入依赖的package包/类
@Override
public GetQueryListResponse getFinishedQueryList(RpcController controller, GetQueryListRequest request)
    throws ServiceException {

  try {
    context.getSessionManager().touch(request.getSessionId().getId());
    GetQueryListResponse.Builder builder = GetQueryListResponse.newBuilder();

    Collection<QueryInProgress> queries
        = context.getQueryJobManager().getFinishedQueries();

    BriefQueryInfo.Builder infoBuilder = BriefQueryInfo.newBuilder();

    for (QueryInProgress queryInProgress : queries) {
      QueryInfo queryInfo = queryInProgress.getQueryInfo();

      infoBuilder.setQueryId(queryInfo.getQueryId().getProto());
      infoBuilder.setState(queryInfo.getQueryState());
      infoBuilder.setQuery(queryInfo.getSql());
      infoBuilder.setStartTime(queryInfo.getStartTime());
      long endTime = (queryInfo.getFinishTime() == 0) ?
          System.currentTimeMillis() : queryInfo.getFinishTime();
      infoBuilder.setFinishTime(endTime);
      infoBuilder.setProgress(queryInfo.getProgress());
      infoBuilder.setQueryMasterPort(queryInfo.getQueryMasterPort());
      infoBuilder.setQueryMasterHost(queryInfo.getQueryMasterHost());

      builder.addQueryList(infoBuilder.build());
    }

    GetQueryListResponse result = builder.build();
    return result;
  } catch (Throwable t) {
    throw new ServiceException(t);
  }
}
 
开发者ID:gruter,项目名称:tajo-cdh,代码行数:37,代码来源:TajoMasterClientService.java

示例12: startQueryMaster

import org.apache.tajo.master.querymaster.QueryInProgress; //导入依赖的package包/类
@Override
public void startQueryMaster(QueryInProgress queryInProgress) {
  try {
    allocateAndLaunchQueryMaster(queryInProgress);

    queryInProgress.getEventHandler().handle(
        new QueryJobEvent(QueryJobEvent.Type.QUERY_JOB_START, queryInProgress.getQueryInfo()));

  } catch (YarnRemoteException e) {
    LOG.error(e.getMessage(), e);
    //TODO set QueryState(fail)
  }
}
 
开发者ID:gruter,项目名称:tajo-cdh,代码行数:14,代码来源:YarnTajoResourceManager.java

示例13: allocateQueryMaster

import org.apache.tajo.master.querymaster.QueryInProgress; //导入依赖的package包/类
@Override
public WorkerAllocatedResource allocateQueryMaster(QueryInProgress queryInProgress) {
  throw new UnimplementedException("allocateQueryMaster");
}
 
开发者ID:apache,项目名称:incubator-tajo,代码行数:5,代码来源:YarnTajoResourceManager.java

示例14: getQueryResult

import org.apache.tajo.master.querymaster.QueryInProgress; //导入依赖的package包/类
@Override
public GetQueryResultResponse getQueryResult(RpcController controller,
                                             GetQueryResultRequest request) throws ServiceException {
  try {
    context.getSessionManager().touch(request.getSessionId().getId());
    QueryId queryId = new QueryId(request.getQueryId());
    QueryInProgress queryInProgress = context.getQueryJobManager().getQueryInProgress(queryId);

    // if we cannot get a QueryInProgress instance from QueryJobManager,
    // the instance can be in the finished query list.
    if (queryInProgress == null) {
      queryInProgress = context.getQueryJobManager().getFinishedQuery(queryId);
    }

    GetQueryResultResponse.Builder builder = GetQueryResultResponse.newBuilder();

    // If we cannot the QueryInProgress instance from the finished list,
    // the query result was expired due to timeout.
    // In this case, we will result in error.
    if (queryInProgress == null) {
      builder.setErrorMessage("No such query: " + queryId.toString());
      return builder.build();
    }

    QueryInfo queryInfo = queryInProgress.getQueryInfo();

    try {
      //TODO After implementation Tajo's user security feature, Should be modified.
      builder.setTajoUserName(UserGroupInformation.getCurrentUser().getUserName());
    } catch (IOException e) {
      LOG.warn("Can't get current user name");
    }
    switch (queryInfo.getQueryState()) {
      case QUERY_SUCCEEDED:
        // TODO check this logic needed
        //builder.setTableDesc((TableDescProto) queryJobManager.getResultDesc().getProto());
        break;
      case QUERY_FAILED:
      case QUERY_ERROR:
        builder.setErrorMessage("Query " + queryId + " is failed");
      default:
        builder.setErrorMessage("Query " + queryId + " is still running");
    }

    return builder.build();
  } catch (Throwable t) {
    throw new ServiceException(t);
  }
}
 
开发者ID:gruter,项目名称:tajo-cdh,代码行数:50,代码来源:TajoMasterClientService.java

示例15: getQueryStatus

import org.apache.tajo.master.querymaster.QueryInProgress; //导入依赖的package包/类
@Override
public GetQueryStatusResponse getQueryStatus(RpcController controller,
                                             GetQueryStatusRequest request)
    throws ServiceException {

  try {
    context.getSessionManager().touch(request.getSessionId().getId());

    GetQueryStatusResponse.Builder builder = GetQueryStatusResponse.newBuilder();
    QueryId queryId = new QueryId(request.getQueryId());
    builder.setQueryId(request.getQueryId());

    if (queryId.equals(QueryIdFactory.NULL_QUERY_ID)) {
      builder.setResultCode(ResultCode.OK);
      builder.setState(TajoProtos.QueryState.QUERY_SUCCEEDED);
    } else {
      QueryInProgress queryInProgress = context.getQueryJobManager().getQueryInProgress(queryId);

      // It will try to find a query status from a finished query list.
      if (queryInProgress == null) {
        queryInProgress = context.getQueryJobManager().getFinishedQuery(queryId);
      }
      if (queryInProgress != null) {
        QueryInfo queryInfo = queryInProgress.getQueryInfo();
        builder.setResultCode(ResultCode.OK);
        builder.setState(queryInfo.getQueryState());
        builder.setProgress(queryInfo.getProgress());
        builder.setSubmitTime(queryInfo.getStartTime());
        if(queryInfo.getQueryMasterHost() != null) {
          builder.setQueryMasterHost(queryInfo.getQueryMasterHost());
          builder.setQueryMasterPort(queryInfo.getQueryMasterClientPort());
        }
        if (queryInfo.getQueryState() == TajoProtos.QueryState.QUERY_SUCCEEDED) {
          builder.setFinishTime(queryInfo.getFinishTime());
        } else {
          builder.setFinishTime(System.currentTimeMillis());
        }
      } else {
        builder.setResultCode(ResultCode.ERROR);
        builder.setErrorMessage("No such query: " + queryId.toString());
      }
    }
    return builder.build();

  } catch (Throwable t) {
    throw new  ServiceException(t);
  }
}
 
开发者ID:gruter,项目名称:tajo-cdh,代码行数:49,代码来源:TajoMasterClientService.java


注:本文中的org.apache.tajo.master.querymaster.QueryInProgress类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。