本文整理汇总了Java中com.facebook.presto.execution.QueryStats类的典型用法代码示例。如果您正苦于以下问题:Java QueryStats类的具体用法?Java QueryStats怎么用?Java QueryStats使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
QueryStats类属于com.facebook.presto.execution包,在下文中一共展示了QueryStats类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handle
import com.facebook.presto.execution.QueryStats; //导入依赖的package包/类
@Override
public Optional<QueryStats> handle(Request request, Response response)
{
if (response.getStatusCode() == HttpStatus.GONE.code()) {
return Optional.empty();
}
else if (response.getStatusCode() != HttpStatus.OK.code()) {
throw new RuntimeException("unexpected error code " + response.getStatusCode() + "; reason=" + response.getStatusMessage());
}
try {
JsonNode rootNode = objectMapper.readTree(response.getInputStream());
JsonNode queryStatsNode = rootNode.get("queryStats");
if (queryStatsNode == null) {
return Optional.empty();
}
QueryStats queryStats = objectMapper.treeToValue(queryStatsNode, QueryStats.class);
return Optional.of(queryStats);
}
catch (IOException e) {
throw Throwables.propagate(e);
}
}
示例2: cursor
import com.facebook.presto.execution.QueryStats; //导入依赖的package包/类
@Override
public RecordCursor cursor(ConnectorTransactionHandle transactionHandle, ConnectorSession session, TupleDomain<Integer> constraint)
{
Builder table = InMemoryRecordSet.builder(QUERY_TABLE);
for (QueryInfo queryInfo : queryManager.getAllQueryInfo()) {
QueryStats queryStats = queryInfo.getQueryStats();
table.addRow(
nodeId,
queryInfo.getQueryId().toString(),
queryInfo.getState().toString(),
queryInfo.getSession().getUser(),
queryInfo.getSession().getSource().orElse(null),
queryInfo.getQuery(),
toMillis(queryStats.getQueuedTime()),
toMillis(queryStats.getAnalysisTime()),
toMillis(queryStats.getDistributedPlanningTime()),
toTimeStamp(queryStats.getCreateTime()),
toTimeStamp(queryStats.getExecutionStartTime()),
toTimeStamp(queryStats.getLastHeartbeat()),
toTimeStamp(queryStats.getEndTime()));
}
return table.build().cursor();
}
示例3: toStatementStats
import com.facebook.presto.execution.QueryStats; //导入依赖的package包/类
private static StatementStats toStatementStats(QueryInfo queryInfo)
{
QueryStats queryStats = queryInfo.getQueryStats();
return StatementStats.builder()
.setState(queryInfo.getState().toString())
.setScheduled(queryInfo.isScheduled())
.setNodes(globalUniqueNodes(queryInfo.getOutputStage()).size())
.setTotalSplits(queryStats.getTotalDrivers())
.setQueuedSplits(queryStats.getQueuedDrivers())
.setRunningSplits(queryStats.getRunningDrivers())
.setCompletedSplits(queryStats.getCompletedDrivers())
.setUserTimeMillis(queryStats.getTotalUserTime().toMillis())
.setCpuTimeMillis(queryStats.getTotalCpuTime().toMillis())
.setWallTimeMillis(queryStats.getTotalScheduledTime().toMillis())
.setProcessedRows(queryStats.getRawInputPositions())
.setProcessedBytes(queryStats.getRawInputDataSize().toBytes())
.setRootStage(toStageStats(queryInfo.getOutputStage()))
.build();
}
示例4: Job
import com.facebook.presto.execution.QueryStats; //导入依赖的package包/类
@JsonCreator
public Job(@JsonProperty("user") final String user,
@JsonProperty("query") final String query,
@JsonProperty("uuid") final UUID uuid,
@JsonProperty("output") final PersistentJobOutput output,
@JsonProperty("queryStats") final QueryStats queryStats,
@JsonProperty("state") final JobState state,
@JsonProperty("columns") final List<Column> columns,
@JsonProperty("tablesUsed") final Set<Table> tablesUsed,
@JsonProperty("queryStarted") final DateTime queryStarted,
@JsonProperty("error") final QueryError error,
@JsonProperty("queryFinished") final DateTime queryFinished)
{
this.user = user;
this.query = query;
this.uuid = uuid;
this.output = output;
this.queryStats = queryStats;
this.state = state;
this.columns = columns;
this.tablesUsed = tablesUsed;
this.queryStarted = queryStarted;
this.error = error;
this.queryFinished = queryFinished;
}
示例5: getQueryStats
import com.facebook.presto.execution.QueryStats; //导入依赖的package包/类
@Override
public Optional<QueryStats> getQueryStats(String queryId)
{
URI uri = uriBuilderFrom(baseUri).appendPath("/v1/query").appendPath(queryId).build();
Request request = prepareGet().setUri(uri).build();
return httpClient.execute(request, new GetQueryStatsResponseHandler());
}
示例6: testGetInfoForQuery
import com.facebook.presto.execution.QueryStats; //导入依赖的package包/类
@Test
public void testGetInfoForQuery()
throws Exception
{
mockHttpResponse(SINGLE_QUERY_INFO);
Optional<QueryStats> infoForQuery = queryStatsClient.getQueryStats("20150505_160116_00005_sdzex");
assertThat(infoForQuery).isPresent();
assertThat(infoForQuery.get().getTotalCpuTime().getValue()).isEqualTo(1.19);
}
示例7: testGetInfoForUnknownQuery
import com.facebook.presto.execution.QueryStats; //导入依赖的package包/类
@Test
public void testGetInfoForUnknownQuery()
throws Exception
{
mockErrorHttpResponse(HttpStatus.GONE);
Optional<QueryStats> infoForQuery = queryStatsClient.getQueryStats("20150505_160116_00005_sdzex");
assertThat(infoForQuery).isEmpty();
}
示例8: BasicQueryInfo
import com.facebook.presto.execution.QueryStats; //导入依赖的package包/类
@JsonCreator
public BasicQueryInfo(
@JsonProperty("queryStats") QueryStats queryStats,
@JsonProperty("inputs") Set<Input> inputs)
{
this.queryStats = queryStats;
this.inputs = inputs;
}
示例9: rlUpdateJobInfo
import com.facebook.presto.execution.QueryStats; //导入依赖的package包/类
/**
* Rate Limited updateJobInfo
*/
protected void rlUpdateJobInfo(
Set<Table> usedTables,
List<Column> columns,
QueryStats queryStats,
JobState state,
QueryError error,
List<List<Object>> outputPreview)
{
if (updateLimiter.tryAcquire(1)) {
updateJobInfo(usedTables, columns, queryStats, state, error, outputPreview, true);
} else {
updateJobInfo(usedTables, columns, queryStats, state, error, outputPreview, false);
}
}
示例10: handleException
import com.facebook.presto.execution.QueryStats; //导入依赖的package包/类
@Override
public Optional<QueryStats> handleException(Request request, Exception exception)
{
throw propagate(request, exception);
}
示例11: completionEvent
import com.facebook.presto.execution.QueryStats; //导入依赖的package包/类
public void completionEvent(QueryInfo queryInfo)
{
try {
QueryStats queryStats = queryInfo.getQueryStats();
FailureInfo failureInfo = queryInfo.getFailureInfo();
String failureType = failureInfo == null ? null : failureInfo.getType();
String failureMessage = failureInfo == null ? null : failureInfo.getMessage();
ImmutableMap.Builder<String, String> mergedProperties = ImmutableMap.builder();
mergedProperties.putAll(queryInfo.getSession().getSystemProperties());
for (Map.Entry<String, Map<String, String>> catalogEntry : queryInfo.getSession().getCatalogProperties().entrySet()) {
for (Map.Entry<String, String> entry : catalogEntry.getValue().entrySet()) {
mergedProperties.put(catalogEntry.getKey() + "." + entry.getKey(), entry.getValue());
}
}
TaskInfo task = null;
StageInfo stageInfo = queryInfo.getOutputStage();
if (stageInfo != null) {
task = stageInfo.getTasks().stream()
.filter(taskInfo -> taskInfo.getState() == TaskState.FAILED)
.findFirst().orElse(null);
}
String failureHost = task == null ? null : task.getSelf().getHost();
String failureTask = task == null ? null : task.getTaskId().toString();
eventClient.post(
new QueryCompletionEvent(
queryInfo.getQueryId(),
queryInfo.getSession().getTransactionId().map(TransactionId::toString).orElse(null),
queryInfo.getSession().getUser(),
queryInfo.getSession().getPrincipal().orElse(null),
queryInfo.getSession().getSource().orElse(null),
serverVersion,
environment,
queryInfo.getSession().getCatalog().orElse(null),
queryInfo.getSession().getSchema().orElse(null),
queryInfo.getSession().getRemoteUserAddress().orElse(null),
queryInfo.getSession().getUserAgent().orElse(null),
queryInfo.getState(),
queryInfo.getSelf(),
queryInfo.getFieldNames(),
queryInfo.getQuery(),
queryStats.getPeakMemoryReservation().toBytes(),
queryStats.getCreateTime(),
queryStats.getExecutionStartTime(),
queryStats.getEndTime(),
queryStats.getQueuedTime(),
queryStats.getAnalysisTime(),
queryStats.getDistributedPlanningTime(),
queryStats.getTotalScheduledTime(),
queryStats.getTotalCpuTime(),
queryStats.getRawInputDataSize(),
queryStats.getRawInputPositions(),
queryStats.getTotalDrivers(),
queryInfo.getErrorCode(),
failureType,
failureMessage,
failureTask,
failureHost,
objectMapper.writeValueAsString(queryInfo.getOutputStage()),
objectMapper.writeValueAsString(queryInfo.getFailureInfo()),
objectMapper.writeValueAsString(queryInfo.getInputs()),
objectMapper.writeValueAsString(mergedProperties.build())
)
);
logQueryTimeline(queryInfo);
}
catch (JsonProcessingException e) {
throw Throwables.propagate(e);
}
}
示例12: updateJobInfo
import com.facebook.presto.execution.QueryStats; //导入依赖的package包/类
protected void updateJobInfo(
Set<Table> usedTables,
List<Column> columns,
QueryStats queryStats,
JobState state,
QueryError error,
List<List<Object>> outputPreview,
boolean postUpdate)
{
if ((usedTables != null) && (usedTables.size() > 0)) {
job.getTablesUsed().addAll(usedTables);
}
if ((columns != null) && (columns.size() > 0)) {
job.setColumns(columns);
}
if (queryStats != null) {
job.setQueryStats(queryStats);
}
if ((state != null) && (job.getState() != JobState.FINISHED) && (job.getState() != JobState.FAILED)) {
job.setState(state);
}
if (error != null) {
FailureInfo failureInfo = new FailureInfo(
error.getFailureInfo().getType(),
error.getFailureInfo().getMessage(),
null,
Collections.<FailureInfo>emptyList(),
Collections.<String>emptyList(),
error.getFailureInfo().getErrorLocation());
QueryError queryError = new QueryError(
error.getMessage(),
error.getSqlState(),
error.getErrorCode(),
error.getErrorName(),
error.getErrorType(),
error.getErrorLocation(),
failureInfo);
job.setError(queryError);
}
if (postUpdate) {
eventBus.post(new JobUpdateEvent(job, outputPreview));
}
}
示例13: createNoOpQueryStats
import com.facebook.presto.execution.QueryStats; //导入依赖的package包/类
public static QueryStats createNoOpQueryStats()
{
DateTime now = DateTime.now();
io.airlift.units.Duration zeroDuration = new io.airlift.units.Duration(0, TimeUnit.SECONDS);
DataSize zeroData = new DataSize(0, DataSize.Unit.BYTE);
return new QueryStats(
now,
null,
now,
now,
zeroDuration,
zeroDuration,
zeroDuration,
zeroDuration,
zeroDuration,
zeroDuration,
0,
0,
0,
0,
0,
0,
0,
0.0,
zeroData,
zeroData,
zeroDuration,
zeroDuration,
zeroDuration,
zeroDuration,
false,
ImmutableSet.of(),
zeroData,
0,
zeroData,
0,
zeroData,
0
);
}
示例14: getQueryStats
import com.facebook.presto.execution.QueryStats; //导入依赖的package包/类
/**
* Obtains QueryStats for query with given id. If query does not exist or
* does not contain queryStats information Optional.empty() is returned.
*/
Optional<QueryStats> getQueryStats(String queryId);