Search in sources :

Example 16 with TaskStatus

use of com.facebook.presto.execution.TaskStatus in project presto by prestodb.

the class GcStatusMonitor method logTaskStats.

private static void logTaskStats(List<QueryId> queryIds, ListMultimap<QueryId, SqlTask> tasksByQueryId) {
    List<List<String>> rows = queryIds.stream().flatMap(queryId -> {
        List<SqlTask> sqlTasks = tasksByQueryId.get(queryId);
        Comparator<SqlTask> comparator = (first, second) -> {
            TaskStats aTaskStats = first.getTaskInfo().getStats();
            TaskStats bTaskStats = second.getTaskInfo().getStats();
            return Long.compare(aTaskStats.getUserMemoryReservationInBytes() + aTaskStats.getSystemMemoryReservationInBytes(), bTaskStats.getUserMemoryReservationInBytes() + bTaskStats.getSystemMemoryReservationInBytes());
        };
        return sqlTasks.stream().sorted(comparator.reversed()).map(task -> {
            TaskInfo taskInfo = task.getTaskInfo();
            SqlTaskIoStats taskIOStats = task.getIoStats();
            TaskStatus taskStatus = taskInfo.getTaskStatus();
            TaskStats taskStats = taskInfo.getStats();
            return ImmutableList.of(task.getQueryContext().getQueryId().toString(), task.getTaskId().toString(), taskStatus.getState().toString(), taskStats.getCreateTime().toString(), Long.toString(taskStats.getUserMemoryReservationInBytes()), Long.toString(taskStats.getSystemMemoryReservationInBytes()), Long.toString(taskIOStats.getInputDataSize().getTotalCount()), Long.toString(taskIOStats.getOutputDataSize().getTotalCount()), Long.toString(taskIOStats.getInputPositions().getTotalCount()), Long.toString(taskIOStats.getOutputPositions().getTotalCount()));
        });
    }).collect(toImmutableList());
    if (!rows.isEmpty()) {
        logInfoTable(ImmutableList.<List<String>>builder().add(ImmutableList.of("Query ID", "Task ID", "State", "Created Ts", "User Memory", "System Memory", "Input Bytes", "Output Bytes", "Input Row Count", "Output Row Count")).addAll(rows).build());
    }
}
Also used : TaskStats(com.facebook.presto.operator.TaskStats) NotificationListener(javax.management.NotificationListener) Logger(com.facebook.airlift.log.Logger) ListMultimap(com.google.common.collect.ListMultimap) TaskStatus(com.facebook.presto.execution.TaskStatus) Function(java.util.function.Function) Inject(javax.inject.Inject) PreDestroy(javax.annotation.PreDestroy) ImmutableListMultimap.toImmutableListMultimap(com.google.common.collect.ImmutableListMultimap.toImmutableListMultimap) SqlTaskManager(com.facebook.presto.execution.SqlTaskManager) ImmutableList(com.google.common.collect.ImmutableList) GarbageCollectorMXBean(java.lang.management.GarbageCollectorMXBean) Objects.requireNonNull(java.util.Objects.requireNonNull) SqlTask(com.facebook.presto.execution.SqlTask) GarbageCollectionNotificationInfo(com.facebook.airlift.stats.GarbageCollectionNotificationInfo) ManagementFactory(java.lang.management.ManagementFactory) SimpleEntry(java.util.AbstractMap.SimpleEntry) StringTableUtils.getTableStrings(com.facebook.presto.util.StringTableUtils.getTableStrings) SqlTaskIoStats(com.facebook.presto.execution.SqlTaskIoStats) ImmutableList.toImmutableList(com.google.common.collect.ImmutableList.toImmutableList) CompositeData(javax.management.openmbean.CompositeData) ObjectName(javax.management.ObjectName) Notification(javax.management.Notification) List(java.util.List) JMException(javax.management.JMException) QueryId(com.facebook.presto.spi.QueryId) PostConstruct(javax.annotation.PostConstruct) Entry(java.util.Map.Entry) Comparator(java.util.Comparator) TaskInfo(com.facebook.presto.execution.TaskInfo) TaskInfo(com.facebook.presto.execution.TaskInfo) SqlTaskIoStats(com.facebook.presto.execution.SqlTaskIoStats) ImmutableList(com.google.common.collect.ImmutableList) ImmutableList.toImmutableList(com.google.common.collect.ImmutableList.toImmutableList) List(java.util.List) TaskStats(com.facebook.presto.operator.TaskStats) TaskStatus(com.facebook.presto.execution.TaskStatus) Comparator(java.util.Comparator)

Example 17 with TaskStatus

use of com.facebook.presto.execution.TaskStatus in project presto by prestodb.

the class TestHttpRemoteTask method createHttpRemoteTaskFactory.

private static HttpRemoteTaskFactory createHttpRemoteTaskFactory(TestingTaskResource testingTaskResource, boolean useThriftEncoding) throws Exception {
    Bootstrap app = new Bootstrap(new JsonModule(), new SmileModule(), new ThriftCodecModule(), new HandleJsonModule(), new Module() {

        @Override
        public void configure(Binder binder) {
            binder.bind(JsonMapper.class);
            binder.bind(ThriftMapper.class);
            configBinder(binder).bindConfig(FeaturesConfig.class);
            FunctionAndTypeManager functionAndTypeManager = createTestFunctionAndTypeManager();
            binder.bind(TypeManager.class).toInstance(functionAndTypeManager);
            jsonBinder(binder).addDeserializerBinding(Type.class).to(TypeDeserializer.class);
            newSetBinder(binder, Type.class);
            smileCodecBinder(binder).bindSmileCodec(TaskStatus.class);
            smileCodecBinder(binder).bindSmileCodec(TaskInfo.class);
            smileCodecBinder(binder).bindSmileCodec(TaskUpdateRequest.class);
            smileCodecBinder(binder).bindSmileCodec(PlanFragment.class);
            smileCodecBinder(binder).bindSmileCodec(MetadataUpdates.class);
            jsonCodecBinder(binder).bindJsonCodec(TaskStatus.class);
            jsonCodecBinder(binder).bindJsonCodec(TaskInfo.class);
            jsonCodecBinder(binder).bindJsonCodec(TaskUpdateRequest.class);
            jsonCodecBinder(binder).bindJsonCodec(PlanFragment.class);
            jsonCodecBinder(binder).bindJsonCodec(MetadataUpdates.class);
            jsonBinder(binder).addKeySerializerBinding(VariableReferenceExpression.class).to(Serialization.VariableReferenceExpressionSerializer.class);
            jsonBinder(binder).addKeyDeserializerBinding(VariableReferenceExpression.class).to(Serialization.VariableReferenceExpressionDeserializer.class);
            thriftCodecBinder(binder).bindThriftCodec(TaskStatus.class);
        }

        @Provides
        private HttpRemoteTaskFactory createHttpRemoteTaskFactory(JsonMapper jsonMapper, ThriftMapper thriftMapper, JsonCodec<TaskStatus> taskStatusJsonCodec, SmileCodec<TaskStatus> taskStatusSmileCodec, ThriftCodec<TaskStatus> taskStatusThriftCodec, JsonCodec<TaskInfo> taskInfoJsonCodec, SmileCodec<TaskInfo> taskInfoSmileCodec, JsonCodec<TaskUpdateRequest> taskUpdateRequestJsonCodec, SmileCodec<TaskUpdateRequest> taskUpdateRequestSmileCodec, JsonCodec<PlanFragment> planFragmentJsonCodec, SmileCodec<PlanFragment> planFragmentSmileCodec, JsonCodec<MetadataUpdates> metadataUpdatesJsonCodec, SmileCodec<MetadataUpdates> metadataUpdatesSmileCodec) {
            JaxrsTestingHttpProcessor jaxrsTestingHttpProcessor = new JaxrsTestingHttpProcessor(URI.create("http://fake.invalid/"), testingTaskResource, jsonMapper, thriftMapper);
            TestingHttpClient testingHttpClient = new TestingHttpClient(jaxrsTestingHttpProcessor.setTrace(TRACE_HTTP));
            testingTaskResource.setHttpClient(testingHttpClient);
            return new HttpRemoteTaskFactory(new QueryManagerConfig(), TASK_MANAGER_CONFIG, testingHttpClient, new TestSqlTaskManager.MockLocationFactory(), taskStatusJsonCodec, taskStatusSmileCodec, taskStatusThriftCodec, taskInfoJsonCodec, taskInfoSmileCodec, taskUpdateRequestJsonCodec, taskUpdateRequestSmileCodec, planFragmentJsonCodec, planFragmentSmileCodec, metadataUpdatesJsonCodec, metadataUpdatesSmileCodec, new RemoteTaskStats(), new InternalCommunicationConfig().setThriftTransportEnabled(useThriftEncoding), createTestMetadataManager(), new TestQueryManager());
        }
    });
    Injector injector = app.doNotInitializeLogging().quiet().initialize();
    HandleResolver handleResolver = injector.getInstance(HandleResolver.class);
    handleResolver.addConnectorName("test", new TestingHandleResolver());
    return injector.getInstance(HttpRemoteTaskFactory.class);
}
Also used : TestingHandleResolver(com.facebook.presto.testing.TestingHandleResolver) HandleResolver(com.facebook.presto.metadata.HandleResolver) FeaturesConfig(com.facebook.presto.sql.analyzer.FeaturesConfig) ThriftMapper(com.facebook.airlift.jaxrs.thrift.ThriftMapper) TaskTestUtils.createPlanFragment(com.facebook.presto.execution.TaskTestUtils.createPlanFragment) PlanFragment(com.facebook.presto.sql.planner.PlanFragment) JsonMapper(com.facebook.airlift.jaxrs.JsonMapper) TaskInfo(com.facebook.presto.execution.TaskInfo) MetadataUpdates(com.facebook.presto.metadata.MetadataUpdates) Multibinder.newSetBinder(com.google.inject.multibindings.Multibinder.newSetBinder) Binder(com.google.inject.Binder) ThriftCodecBinder.thriftCodecBinder(com.facebook.drift.codec.guice.ThriftCodecBinder.thriftCodecBinder) JsonBinder.jsonBinder(com.facebook.airlift.json.JsonBinder.jsonBinder) JsonCodecBinder.jsonCodecBinder(com.facebook.airlift.json.JsonCodecBinder.jsonCodecBinder) SmileCodecBinder.smileCodecBinder(com.facebook.airlift.json.smile.SmileCodecBinder.smileCodecBinder) ConfigBinder.configBinder(com.facebook.airlift.configuration.ConfigBinder.configBinder) InternalCommunicationConfig(com.facebook.presto.server.InternalCommunicationConfig) ThriftCodecModule(com.facebook.drift.codec.guice.ThriftCodecModule) FunctionAndTypeManager.createTestFunctionAndTypeManager(com.facebook.presto.metadata.FunctionAndTypeManager.createTestFunctionAndTypeManager) FunctionAndTypeManager(com.facebook.presto.metadata.FunctionAndTypeManager) JaxrsTestingHttpProcessor(com.facebook.airlift.jaxrs.testing.JaxrsTestingHttpProcessor) HandleJsonModule(com.facebook.presto.metadata.HandleJsonModule) Injector(com.google.inject.Injector) TestingHttpClient(com.facebook.airlift.http.client.testing.TestingHttpClient) Bootstrap(com.facebook.airlift.bootstrap.Bootstrap) TestQueryManager(com.facebook.presto.execution.TestQueryManager) TypeDeserializer(com.facebook.presto.type.TypeDeserializer) TestingHandleResolver(com.facebook.presto.testing.TestingHandleResolver) TaskUpdateRequest(com.facebook.presto.server.TaskUpdateRequest) TaskStatus(com.facebook.presto.execution.TaskStatus) Provides(com.google.inject.Provides) JsonModule(com.facebook.airlift.json.JsonModule) HandleJsonModule(com.facebook.presto.metadata.HandleJsonModule) MediaType(javax.ws.rs.core.MediaType) Type(com.facebook.presto.common.type.Type) SmileModule(com.facebook.airlift.json.smile.SmileModule) QueryManagerConfig(com.facebook.presto.execution.QueryManagerConfig) JsonModule(com.facebook.airlift.json.JsonModule) SmileModule(com.facebook.airlift.json.smile.SmileModule) ThriftCodecModule(com.facebook.drift.codec.guice.ThriftCodecModule) Module(com.google.inject.Module) HandleJsonModule(com.facebook.presto.metadata.HandleJsonModule)

Aggregations

TaskStatus (com.facebook.presto.execution.TaskStatus)17 TaskInfo (com.facebook.presto.execution.TaskInfo)6 Request (com.facebook.airlift.http.client.Request)5 ResponseHandler (com.facebook.airlift.http.client.ResponseHandler)4 SimpleHttpResponseHandler (com.facebook.presto.server.SimpleHttpResponseHandler)4 TaskUpdateRequest (com.facebook.presto.server.TaskUpdateRequest)4 AdaptingJsonResponseHandler.createAdaptingJsonResponseHandler (com.facebook.presto.server.smile.AdaptingJsonResponseHandler.createAdaptingJsonResponseHandler)4 FullSmileResponseHandler.createFullSmileResponseHandler (com.facebook.presto.server.smile.FullSmileResponseHandler.createFullSmileResponseHandler)4 HttpUriBuilder (com.facebook.airlift.http.client.HttpUriBuilder)3 QueryManagerConfig (com.facebook.presto.execution.QueryManagerConfig)3 JsonCodec (com.facebook.airlift.json.JsonCodec)2 SmileCodec (com.facebook.airlift.json.smile.SmileCodec)2 NodeTaskMap (com.facebook.presto.execution.NodeTaskMap)2 MetadataUpdates (com.facebook.presto.metadata.MetadataUpdates)2 TaskStats (com.facebook.presto.operator.TaskStats)2 BaseResponse (com.facebook.presto.server.smile.BaseResponse)2 URI (java.net.URI)2 Bootstrap (com.facebook.airlift.bootstrap.Bootstrap)1 SetThreadName (com.facebook.airlift.concurrent.SetThreadName)1 ConfigBinder.configBinder (com.facebook.airlift.configuration.ConfigBinder.configBinder)1