Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
* 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.client;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;

import static java.util.Objects.requireNonNull;

public enum ExecutionType
{
JAVA("java"),
NATIVE("native"),
NATIVE_GPU("native-gpu");

private final String value;

ExecutionType(String value)
{
this.value = requireNonNull(value, "value is null");
}

@JsonValue
public String getValue()
{
return value;
}

@JsonCreator
public static ExecutionType fromValue(String value)
{
requireNonNull(value, "value is null");
for (ExecutionType executionType : ExecutionType.values()) {
if (executionType.getValue().equals(value)) {
return executionType;
}
}
throw new IllegalArgumentException("Unknown execution type: " + value);
}

@Override
public String toString()
{
return value;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,25 @@ public class ServerInfo

// optional to maintain compatibility with older servers
private final Optional<Duration> uptime;
private final Optional<ExecutionType> executionType;

@ThriftConstructor
@JsonCreator
public ServerInfo(
@JsonProperty("nodeVersion") NodeVersion nodeVersion,
@JsonProperty("environment") String environment,
@JsonProperty("coordinator") boolean coordinator,
@JsonProperty("starting") boolean starting,
@JsonProperty("uptime") Optional<Duration> uptime,
@JsonProperty("executionType") Optional<ExecutionType> executionType)
{
this.nodeVersion = requireNonNull(nodeVersion, "nodeVersion is null");
this.environment = requireNonNull(environment, "environment is null");
this.coordinator = coordinator;
this.starting = starting;
this.uptime = requireNonNull(uptime, "uptime is null");
this.executionType = requireNonNull(executionType, "executionType is null");
}

@ThriftConstructor
@JsonCreator
Expand All @@ -53,6 +72,7 @@ public ServerInfo(
this.coordinator = coordinator;
this.starting = starting;
this.uptime = requireNonNull(uptime, "uptime is null");
this.executionType = Optional.empty();
}

@ThriftField(1)
Expand Down Expand Up @@ -90,6 +110,13 @@ public Optional<Duration> getUptime()
return uptime;
}

@ThriftField(6)
@JsonProperty
public Optional<ExecutionType> getExecutionType()
{
return executionType;
}

@Override
public boolean equals(Object o)
{
Expand Down Expand Up @@ -118,6 +145,7 @@ public String toString()
.add("nodeVersion", nodeVersion)
.add("environment", environment)
.add("coordinator", coordinator)
.add("executionType", executionType.map(ExecutionType::toString).orElse(null))
.add("uptime", uptime.orElse(null))
.omitNullValues()
.toString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,14 @@ public Object[][] codecCombinations()
@Test
public void testJsonRoundTrip()
{
assertJsonRoundTrip(new ServerInfo(UNKNOWN, "test", true, false, Optional.of(Duration.valueOf("2m"))));
assertJsonRoundTrip(new ServerInfo(UNKNOWN, "test", true, false, Optional.empty()));
assertJsonRoundTrip(new ServerInfo(UNKNOWN, "test", true, false, Optional.of(Duration.valueOf("2m")), Optional.of(ExecutionType.JAVA)));
assertJsonRoundTrip(new ServerInfo(UNKNOWN, "test", true, false, Optional.empty(), Optional.empty()));
}

@Test
public void testBackwardsCompatible()
{
ServerInfo newServerInfo = new ServerInfo(UNKNOWN, "test", true, false, Optional.empty());
ServerInfo newServerInfo = new ServerInfo(UNKNOWN, "test", true, false, Optional.empty(), Optional.empty());
ServerInfo legacyServerInfo = SERVER_INFO_CODEC.fromJson("{\"nodeVersion\":{\"version\":\"<unknown>\"},\"environment\":\"test\",\"coordinator\":true}");
assertEquals(newServerInfo, legacyServerInfo);
}
Expand Down Expand Up @@ -108,7 +108,7 @@ public void testRoundTripSerializeFacebookCompactProtocol(ThriftCodec<ServerInfo

private ServerInfo getServerInfo()
{
return new ServerInfo(UNKNOWN, "test", true, false, Optional.of(Duration.valueOf("2m")));
return new ServerInfo(UNKNOWN, "test", true, false, Optional.of(Duration.valueOf("2m")), Optional.of(ExecutionType.JAVA));
}

private ServerInfo getRoundTripSerialize(ThriftCodec<ServerInfo> readCodec, ThriftCodec<ServerInfo> writeCodec,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

import com.facebook.airlift.json.JsonCodec;
import com.facebook.airlift.units.Duration;
import com.facebook.presto.client.ExecutionType;
import com.facebook.presto.client.ServerInfo;
import okhttp3.OkHttpClient;
import okhttp3.mockwebserver.MockResponse;
Expand Down Expand Up @@ -57,7 +58,7 @@ public void teardown()
public void testGetServerInfo()
throws Exception
{
ServerInfo expected = new ServerInfo(UNKNOWN, "test", true, false, Optional.of(Duration.valueOf("2m")));
ServerInfo expected = new ServerInfo(UNKNOWN, "test", true, false, Optional.of(Duration.valueOf("2m")), Optional.of(ExecutionType.JAVA));

server.enqueue(new MockResponse()
.addHeader(CONTENT_TYPE, "application/json")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
package com.facebook.presto.server;

import com.facebook.airlift.node.NodeInfo;
import com.facebook.presto.client.ExecutionType;
import com.facebook.presto.client.NodeVersion;
import com.facebook.presto.client.ServerInfo;
import com.facebook.presto.execution.resourceGroups.ResourceGroupManager;
Expand Down Expand Up @@ -78,7 +79,8 @@ public ServerInfoResource(NodeVersion nodeVersion, NodeInfo nodeInfo, ServerConf
public ServerInfo getInfo()
{
boolean starting = resourceManager ? true : !catalogStore.areCatalogsLoaded();
return new ServerInfo(version, environment, coordinator, starting, Optional.of(nanosSince(startTime)));
Optional<ExecutionType> executionType = Optional.of(ExecutionType.JAVA);
return new ServerInfo(version, environment, coordinator, starting, Optional.of(nanosSince(startTime)), executionType);
}

@PUT
Expand Down
11 changes: 10 additions & 1 deletion presto-native-execution/presto_cpp/main/PrestoServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1637,12 +1637,21 @@ void PrestoServer::reportMemoryInfo(proxygen::ResponseHandler* downstream) {
}

void PrestoServer::reportServerInfo(proxygen::ResponseHandler* downstream) {

// Determine execution type based on GPU support
#ifdef PRESTO_ENABLE_CUDF
auto executionType = std::make_shared<protocol::ExecutionType>(protocol::ExecutionType::NATIVE_GPU);
#else
auto executionType = std::make_shared<protocol::ExecutionType>(protocol::ExecutionType::NATIVE);
#endif

const protocol::ServerInfo serverInfo{
{nodeVersion_},
environment_,
false,
false,
std::make_shared<protocol::Duration>(getUptime(start_))};
std::make_shared<protocol::Duration>(getUptime(start_)),
executionType};
http::sendOkResponse(downstream, json(serverInfo));
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
[
{
"comment": "// This file is generated DO NOT EDIT @generated"
},
{
"class_name": "ArrowColumnHandle",
"hinc": "// ArrowColumnHandle is special since it needs an implementation of\n// operator<().\n\nnamespace facebook::presto::protocol::arrow_flight {\nstruct ArrowColumnHandle : public ColumnHandle {\n String columnName = {};\n Type columnType = {};\n\n ArrowColumnHandle() noexcept;\n\n bool operator<(const ColumnHandle& o) const override {\n return columnName < dynamic_cast<const ArrowColumnHandle&>(o).columnName;\n }\n};\n\nvoid to_json(json& j, const ArrowColumnHandle& p);\nvoid from_json(const json& j, ArrowColumnHandle& p);\n\n} // namespace facebook::presto::protocol::arrow_flight",
"struct": true,
"fields": [
{
"field_type": "String",
"field_name": "columnName",
"field_text": "String",
"_N": 1,
"field_local": true
},
{
"field_type": "Type",
"field_name": "columnType",
"field_text": "Type",
"_N": 2,
"field_local": true
}
],
"subclass": true,
"super_class": "ColumnHandle",
"json_key": "arrow-flight"
},
{
"class_name": "ArrowSplit",
"struct": true,
"fields": [
{
"field_type": "String",
"field_name": "schemaName",
"field_text": "String",
"_N": 1,
"field_local": true
},
{
"field_type": "String",
"field_name": "tableName",
"field_text": "String",
"_N": 2,
"field_local": true
},
{
"field_type": "byte[]",
"field_name": "flightEndpointBytes",
"field_text": "String",
"_N": 3,
"field_local": true
}
],
"subclass": true,
"super_class": "ConnectorSplit",
"json_key": "arrow-flight"
},
{
"class_name": "ArrowTableHandle",
"struct": true,
"fields": [
{
"field_type": "String",
"field_name": "schema",
"field_text": "String",
"_N": 1,
"field_local": true
},
{
"field_type": "String",
"field_name": "table",
"field_text": "String",
"_N": 2,
"field_local": true
}
],
"subclass": true,
"super_class": "ConnectorTableHandle",
"json_key": "arrow-flight"
},
{
"class_name": "ColumnHandle",
"field_name": "columnHandle",
"abstract": true,
"super_class": "JsonEncodedSubclass",
"comparable": true,
"subclasses": [
{
"type": "ArrowColumnHandle",
"name": "arrowColumnHandle",
"key": "arrow-flight",
"_N": 1,
"_last": true
}
],
"fields": []
},
{
"class_name": "ArrowTableLayoutHandle",
"struct": true,
"fields": [
{
"field_type": "ArrowTableHandle",
"field_name": "table",
"field_text": "ArrowTableHandle",
"_N": 1,
"field_local": true
},
{
"field_type": "List<ArrowColumnHandle>",
"field_name": "columnHandles",
"field_text": "List<ArrowColumnHandle>",
"_N": 2,
"field_local": true
},
{
"field_type": "TupleDomain<ColumnHandle>",
"field_name": "tupleDomain",
"field_text": "TupleDomain<std::shared_ptr<ColumnHandle>>",
"_N": 3,
"field_local": true
}
],
"subclass": true,
"super_class": "ConnectorTableLayoutHandle",
"json_key": "arrow-flight"
}
]
Loading
Loading