diff --git a/presto-function-namespace-managers/pom.xml b/presto-function-namespace-managers/pom.xml index 0d01a7a864845..91ebd8cb7e66e 100644 --- a/presto-function-namespace-managers/pom.xml +++ b/presto-function-namespace-managers/pom.xml @@ -149,6 +149,21 @@ provided + + com.facebook.drift + drift-transport-netty + + + + com.squareup.okhttp3 + okhttp + + + + com.facebook.airlift + http-client + + com.facebook.presto @@ -174,12 +189,6 @@ test - - com.facebook.drift - drift-transport-netty - test - - org.assertj assertj-core diff --git a/presto-function-namespace-managers/src/main/java/com/facebook/presto/functionNamespace/execution/rest/RestSqlFunctionExecutionModule.java b/presto-function-namespace-managers/src/main/java/com/facebook/presto/functionNamespace/execution/rest/RestSqlFunctionExecutionModule.java new file mode 100644 index 0000000000000..664aed6b3ee4d --- /dev/null +++ b/presto-function-namespace-managers/src/main/java/com/facebook/presto/functionNamespace/execution/rest/RestSqlFunctionExecutionModule.java @@ -0,0 +1,29 @@ +/* + * 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.functionNamespace.execution.rest; + +import com.facebook.presto.functionNamespace.execution.SqlFunctionExecutionModule; +import com.facebook.presto.spi.function.SqlFunctionExecutor; +import com.google.inject.Binder; +import com.google.inject.Scopes; + +public class RestSqlFunctionExecutionModule + extends SqlFunctionExecutionModule +{ + @Override + protected void setup(Binder binder) + { + binder.bind(SqlFunctionExecutor.class).to(RestSqlFunctionExecutor.class).in(Scopes.SINGLETON); + } +} diff --git a/presto-function-namespace-managers/src/main/java/com/facebook/presto/functionNamespace/execution/rest/RestSqlFunctionExecutor.java b/presto-function-namespace-managers/src/main/java/com/facebook/presto/functionNamespace/execution/rest/RestSqlFunctionExecutor.java new file mode 100644 index 0000000000000..11b6000e77f6b --- /dev/null +++ b/presto-function-namespace-managers/src/main/java/com/facebook/presto/functionNamespace/execution/rest/RestSqlFunctionExecutor.java @@ -0,0 +1,164 @@ +/* + * 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.functionNamespace.execution.rest; + +import com.facebook.airlift.http.client.HttpUriBuilder; +import com.facebook.presto.common.Page; +import com.facebook.presto.common.block.BlockEncodingSerde; +import com.facebook.presto.common.function.SqlFunctionResult; +import com.facebook.presto.common.type.Type; +import com.facebook.presto.common.type.TypeSignature; +import com.facebook.presto.spi.NodeManager; +import com.facebook.presto.spi.PrestoException; +import com.facebook.presto.spi.RestURIManager; +import com.facebook.presto.spi.function.FunctionImplementationType; +import com.facebook.presto.spi.function.RemoteScalarFunctionImplementation; +import com.facebook.presto.spi.function.SqlFunctionExecutor; +import com.facebook.presto.spi.function.SqlFunctionHandle; +import com.facebook.presto.spi.function.SqlFunctionId; +import com.facebook.presto.spi.page.PagesSerde; +import com.facebook.presto.spi.page.SerializedPage; +import io.airlift.slice.BasicSliceInput; +import io.airlift.slice.DynamicSliceOutput; +import io.airlift.slice.Slice; +import io.airlift.slice.Slices; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.MediaType; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; + +import javax.annotation.PostConstruct; +import javax.inject.Inject; + +import java.io.IOException; +import java.net.URI; +import java.util.List; +import java.util.Optional; +import java.util.concurrent.CompletableFuture; + +import static com.facebook.airlift.http.client.HttpUriBuilder.uriBuilderFrom; +import static com.facebook.presto.spi.StandardErrorCode.NOT_FOUND; +import static com.facebook.presto.spi.function.FunctionImplementationType.REST; +import static com.facebook.presto.spi.page.PagesSerdeUtil.readSerializedPage; +import static com.facebook.presto.spi.page.PagesSerdeUtil.writeSerializedPage; +import static com.google.common.base.Preconditions.checkState; +import static com.google.common.collect.ImmutableList.toImmutableList; +import static java.util.Objects.requireNonNull; + +public class RestSqlFunctionExecutor + implements SqlFunctionExecutor +{ + private BlockEncodingSerde blockEncodingSerde; + private PagesSerde pageSerde; + private OkHttpClient okHttpClient; + private NodeManager nodeManager; + private final RestURIManager restURIManager; + + @Inject + public RestSqlFunctionExecutor(NodeManager nodeManager, RestURIManager restURIManager) + { + this.nodeManager = nodeManager; + this.restURIManager = restURIManager; + } + + @PostConstruct + public void init() + { + this.okHttpClient = new OkHttpClient(); + } + + @Override + public FunctionImplementationType getImplementationType() + { + return REST; + } + + @Override + public void setBlockEncodingSerde(BlockEncodingSerde blockEncodingSerde) + { + checkState(this.blockEncodingSerde == null, "blockEncodingSerde already set"); + requireNonNull(blockEncodingSerde, "blockEncodingSerde is null"); + this.blockEncodingSerde = blockEncodingSerde; + this.pageSerde = new PagesSerde(blockEncodingSerde, Optional.empty(), Optional.empty(), Optional.empty()); + } + + @Override + public CompletableFuture executeFunction( + String source, + RemoteScalarFunctionImplementation functionImplementation, + Page input, + List channels, + List argumentTypes, + Type returnType) + { + SqlFunctionHandle functionHandle = functionImplementation.getFunctionHandle(); + SqlFunctionId functionId = functionHandle.getFunctionId(); + DynamicSliceOutput sliceOutput = new DynamicSliceOutput((int) input.getRetainedSizeInBytes()); + writeSerializedPage(sliceOutput, pageSerde.serialize(input)); + RequestBody body = RequestBody.create(MediaType.parse("text/plain; charset=utf-8"), sliceOutput.slice().byteArray()); + Request request = new Request.Builder() + .url(getNativeWorkerUri(nodeManager, functionId, returnType).toString()) + .post(body) + .build(); + CallbackFuture future = new CallbackFuture(); + okHttpClient.newCall(request).enqueue(future); + return future; + } + + private URI getNativeWorkerUri(NodeManager nodeManager, SqlFunctionId functionId, Type returnType) + { + List functionArgumentTypes = functionId.getArgumentTypes().stream().map(TypeSignature::toString).collect(toImmutableList()); + if (restURIManager.getRestUriManager() == null) { + throw new PrestoException(NOT_FOUND, "failed to find native node !"); + } + HttpUriBuilder uri = uriBuilderFrom(URI.create("http://" + restURIManager.getRestUriManager())) + .appendPath("/v1/function/" + functionId.getFunctionName().getObjectName()) + .addParameter("returnType", returnType.toString()) + .addParameter("numArgs", "" + functionArgumentTypes.size()); + for (int i = 1; i <= functionArgumentTypes.size(); i++) { + uri.addParameter("argType" + i, functionArgumentTypes.get(i - 1)); + } + return uri.build(); + } + + private class CallbackFuture + extends CompletableFuture + implements Callback + { + @Override + public void onFailure(Call call, IOException e) + { + super.completeExceptionally(e); + } + @Override + public void onResponse(Call call, Response response) + { + try { + if (response.code() != 200) { + super.completeExceptionally(new IllegalStateException("Failed to get response for rest function call. Response code: " + response.code())); + } + Slice slice = Slices.wrappedBuffer(response.body().bytes()); + SerializedPage serializedPage = readSerializedPage(new BasicSliceInput(slice)); + SqlFunctionResult output = new SqlFunctionResult(pageSerde.deserialize(serializedPage).getBlock(0), response.receivedResponseAtMillis()); + super.complete(output); + } + catch (IOException | NullPointerException e) { + super.completeExceptionally(new IllegalStateException("Failed to get response for rest function call, " + e.getMessage())); + } + } + } +} diff --git a/presto-function-namespace-managers/src/main/java/com/facebook/presto/functionNamespace/execution/rest/SimpleAddressRestSqlFunctionExecutorsModule.java b/presto-function-namespace-managers/src/main/java/com/facebook/presto/functionNamespace/execution/rest/SimpleAddressRestSqlFunctionExecutorsModule.java new file mode 100644 index 0000000000000..4ec0938fbaea7 --- /dev/null +++ b/presto-function-namespace-managers/src/main/java/com/facebook/presto/functionNamespace/execution/rest/SimpleAddressRestSqlFunctionExecutorsModule.java @@ -0,0 +1,58 @@ +/* + * 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.functionNamespace.execution.rest; + +import com.facebook.airlift.configuration.AbstractConfigurationAwareModule; +import com.facebook.presto.functionNamespace.execution.SqlFunctionExecutionModule; +import com.facebook.presto.functionNamespace.execution.SqlFunctionExecutors; +import com.facebook.presto.spi.function.FunctionImplementationType; +import com.facebook.presto.spi.function.RoutineCharacteristics.Language; +import com.google.common.collect.ImmutableMap; +import com.google.inject.Binder; +import com.google.inject.TypeLiteral; + +import java.util.Map; + +import static com.facebook.presto.spi.function.FunctionImplementationType.REST; +import static com.google.inject.Scopes.SINGLETON; +import static java.util.Objects.requireNonNull; + +public class SimpleAddressRestSqlFunctionExecutorsModule + extends AbstractConfigurationAwareModule +{ + private final SqlFunctionExecutionModule sqlFunctionExecutorModule; + + public SimpleAddressRestSqlFunctionExecutorsModule() + { + this(new RestSqlFunctionExecutionModule()); + } + + public SimpleAddressRestSqlFunctionExecutorsModule(SqlFunctionExecutionModule sqlFunctionExecutorModule) + { + this.sqlFunctionExecutorModule = requireNonNull(sqlFunctionExecutorModule, "sqlFunctionExecutorModule is null"); + } + + @Override + protected void setup(Binder binder) + { + Map languageImplementationTypeMap = ImmutableMap.of(new Language("CPP"), REST); + Map supportedLanguages = ImmutableMap.of("CPP", REST); + // for SqlFunctionExecutor + sqlFunctionExecutorModule.setSupportedLanguages(supportedLanguages); + install(sqlFunctionExecutorModule); + // for SqlFunctionExecutors + binder.bind(SqlFunctionExecutors.class).in(SINGLETON); + binder.bind(new TypeLiteral>() {}).toInstance(languageImplementationTypeMap); + } +} diff --git a/presto-function-namespace-managers/src/main/java/com/facebook/presto/functionNamespace/rest-openapi.yml b/presto-function-namespace-managers/src/main/java/com/facebook/presto/functionNamespace/rest-openapi.yml new file mode 100644 index 0000000000000..b13105fcd3030 --- /dev/null +++ b/presto-function-namespace-managers/src/main/java/com/facebook/presto/functionNamespace/rest-openapi.yml @@ -0,0 +1,170 @@ +openapi: 3.0.0 +info: + title: Presto FunctionNameSpace Rest API + description: API for retrieving functions in Presto. + version: "1" +servers: + - url: http://localhost:8080 + description: Presto endpoint when running locally +# http://127.0.0.1:7777/v1/function/array_constructor?returnType=array(unknown)&numArgs=0 +paths: + /v1/function/{functionName}: + post: + summary: Retrieve value from function + parameters: + - in: path + name: functionName + schema: + $ref: '#/components/schemas/QualifiedObjectName/properties/objectName' + required: true + description: The return type of the function of the user to get + - in: query + name: returnType + schema: + $ref: '#/components/schemas/TypeSignature/properties/base' + required: true + description: The return type of the function + - in: query + name: numArgs + schema: + type: integer + required: true + description: The numbers of arguments passed in + - in: query + name: argType + schema: + type: object + # $ref: '#/components/schemas/TypeSignature/parameters' + additionalProperties: + type: string + pattern: '^[A-Za-z][A-Za-z0-9]*$' + example: + argType1: string + argType2: double + description: The type for each argument passed in + requestBody: + required: true + content: + text/plain; charset=utf-8: + schema: + $ref: '#/components/schemas/SerializedPage' + type: object + properties: + username: + type: string + format: binary + responses: + '200': + description: function value output + content: + text/plain; charset=utf-8: + schema: + $ref: '#/components/schemas/SerializedPageBinary' +components: + schemas: + QualifiedObjectName: + type: object + properties: + catalogName: + type: string + description: The name of the catalog + schemaName: + type: string + description: The name of the Schema + objectName: + type: string + description: The name of the function + TypeSignature: + type: object + properties: + base: + type: object + description: The base signature type + parameters: + type: array + items: + $ref: '#/components/schemas/TypeSignatureParameter' + description: list of type signature parameters + calculated: + type: boolean + IDENTIFIER_PATTERN: + type: object + description: The pattern of identification + BASE_NAME_ALIAS_TO_CANONICAL: + type: object + SIMPLE_TYPE_WITH_SPACES: + type: object + BIGINT_ENUM_PREFIX: + type: string + ENUM_PREFIX: + type: object + DISTINCT_TYPE_PREFIX: + type: object + TypeSignatureParameter: + type: object + properties: + kind: + type: object + description: The parameter kind + value: + type: object + description: The value + Page: + type: object + properties: + INSTANCE_SIZE: + type: integer + description: size + EMPTY_BLOCKS: + type: object + description: array of blocks + blocks: + type: object + positionCount: + type: integer + sizeInBytes: + type: number + retainedSizeInBytes: + type: number + logicalSizeInBytes: + type: number + SerializedPage: + type: object + properties: + INSTANCE_SIZE: + type: integer + description: size + slice: + type: object + positionCount: + type: integer + uncompressedSizeInBytes: + type: integer + pageCodecMarkers: + type: object + checksum: + type: number + SqlFunctionId: + type: object + properties: + functionName: + $ref: '#/components/schemas/QualifiedObjectName' + argumentTypes: + type: array + items: + $ref: '#/components/schemas/TypeSignature' + # size->possibly add the size as property in SqlFunctionId and just get it from here as well since we need it for url??? + SqlFunctionResult: + type: object + properties: + result: + type: object + description: the Block type result + cpuTimeMs: + type: number + description: time it took on the cpu + SerializedPageBinary: + type: string + format: binary + # can indicate max/min length but can not split it up into sections in this form... + # Match this format https://prestodb.io/docs/current/develop/serialized-page.html diff --git a/presto-main/src/main/java/com/facebook/presto/resturi/RestUriManager.java b/presto-main/src/main/java/com/facebook/presto/resturi/RestUriManager.java new file mode 100644 index 0000000000000..6b1f800820700 --- /dev/null +++ b/presto-main/src/main/java/com/facebook/presto/resturi/RestUriManager.java @@ -0,0 +1,35 @@ +/* + * 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.resturi; + +import com.facebook.presto.server.ServerConfig; +import com.facebook.presto.spi.RestURIManager; + +import javax.inject.Inject; + +public class RestUriManager + implements RestURIManager +{ + private final ServerConfig serverConfig; + @Inject + public RestUriManager(ServerConfig serverConfig) + { + this.serverConfig = serverConfig; + } + @Override + public String getRestUriManager() + { + return serverConfig.getRestUri(); + } +} diff --git a/presto-main/src/main/java/com/facebook/presto/server/ServerConfig.java b/presto-main/src/main/java/com/facebook/presto/server/ServerConfig.java index 30e9f0b506bce..e43a3ec620914 100644 --- a/presto-main/src/main/java/com/facebook/presto/server/ServerConfig.java +++ b/presto-main/src/main/java/com/facebook/presto/server/ServerConfig.java @@ -44,6 +44,8 @@ public class ServerConfig private boolean nestedDataSerializationEnabled = true; private Duration clusterResourceGroupStateInfoExpirationDuration = new Duration(0, MILLISECONDS); + private String restUri; + public boolean isResourceManager() { return resourceManager; @@ -241,4 +243,16 @@ public ServerConfig setClusterResourceGroupStateInfoExpirationDuration(Duration this.clusterResourceGroupStateInfoExpirationDuration = clusterResourceGroupStateInfoExpirationDuration; return this; } + + public String getRestUri() + { + return this.restUri; + } + + @Config("rest-uri") + public ServerConfig setRestUri(String restUri) + { + this.restUri = restUri; + return this; + } } diff --git a/presto-main/src/main/java/com/facebook/presto/sql/InterpretedFunctionInvoker.java b/presto-main/src/main/java/com/facebook/presto/sql/InterpretedFunctionInvoker.java index b6997ee5ae547..df7e0afd358c0 100644 --- a/presto-main/src/main/java/com/facebook/presto/sql/InterpretedFunctionInvoker.java +++ b/presto-main/src/main/java/com/facebook/presto/sql/InterpretedFunctionInvoker.java @@ -15,8 +15,13 @@ import com.facebook.presto.common.InvalidFunctionArgumentException; import com.facebook.presto.common.NotSupportedException; +import com.facebook.presto.common.Page; +import com.facebook.presto.common.PageBuilder; +import com.facebook.presto.common.block.Block; +import com.facebook.presto.common.block.BlockBuilder; import com.facebook.presto.common.function.SqlFunctionProperties; import com.facebook.presto.common.type.TimeZoneNotSupportedException; +import com.facebook.presto.common.type.Type; import com.facebook.presto.metadata.FunctionAndTypeManager; import com.facebook.presto.operator.scalar.BuiltInScalarFunctionImplementation; import com.facebook.presto.operator.scalar.ScalarFunctionImplementationChoice; @@ -25,11 +30,13 @@ import com.facebook.presto.spi.function.FunctionHandle; import com.facebook.presto.spi.function.JavaScalarFunctionImplementation; import com.google.common.base.Defaults; +import io.airlift.slice.Slice; import java.lang.invoke.MethodHandle; import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import java.util.concurrent.ExecutionException; import static com.facebook.presto.operator.scalar.ScalarFunctionImplementationChoice.ArgumentType.VALUE_TYPE; import static com.facebook.presto.operator.scalar.ScalarFunctionImplementationChoice.NullConvention.RETURN_NULL_ON_NULL; @@ -60,6 +67,22 @@ public Object invoke(FunctionHandle functionHandle, SqlFunctionProperties proper return invoke(functionAndTypeManager.getJavaScalarFunctionImplementation(functionHandle), properties, arguments); } + public Object invoke(FunctionHandle functionHandle, List arguments, List types, List channels, Type returnType) + { + PageBuilder pageBuilder = new PageBuilder(types); + pageBuilder.declarePosition(); + for (int i = 0; i < types.size(); i++) { + writeOutput(types.get(i), pageBuilder.getBlockBuilder(i), arguments.get(i)); + } + Page inputPage = pageBuilder.build(); + try { + return convertObject(returnType, functionAndTypeManager.executeFunction("", functionHandle, inputPage, channels).get().getResult()); + } + catch (InterruptedException | ExecutionException e) { + throw new RuntimeException(e); + } + } + /** * Arguments must be the native container type for the corresponding SQL types. *

@@ -146,4 +169,45 @@ private static RuntimeException propagate(Throwable throwable) throwIfUnchecked(throwable); throw new RuntimeException(throwable); } + + public void writeOutput(Type type, BlockBuilder output, Object argument) + { + switch (type.getJavaType().getSimpleName()) { + case "long": + type.writeLong(output, (Long) argument); + break; + case "double": + type.writeDouble(output, (Double) argument); + break; + case "boolean": + type.writeBoolean(output, (Boolean) argument); + break; + case "Slice": + type.writeSlice(output, (Slice) argument); + break; + case "Block": + type.writeObject(output, argument); + break; + default: + throw new IllegalArgumentException("Unexpected type: " + type.getJavaType().getSimpleName()); + } + } + + public Object convertObject(Type returnType, Block result) + { + switch (returnType.getJavaType().getSimpleName()) { + case "long": + return returnType.getLong(result, 0); + case "double": + return returnType.getDouble(result, 0); + case "boolean": + return returnType.getBoolean(result, 0); + case "Slice": + return returnType.getSlice(result, 0); + case "Block": + return returnType.getObject(result, 0); + default: + throw new IllegalArgumentException("Unexpected return type: " + returnType.getJavaType().getSimpleName()); + } + } } diff --git a/presto-main/src/main/java/com/facebook/presto/sql/planner/RowExpressionInterpreter.java b/presto-main/src/main/java/com/facebook/presto/sql/planner/RowExpressionInterpreter.java index 7939cf298cf33..205e290b04d0f 100644 --- a/presto-main/src/main/java/com/facebook/presto/sql/planner/RowExpressionInterpreter.java +++ b/presto-main/src/main/java/com/facebook/presto/sql/planner/RowExpressionInterpreter.java @@ -76,6 +76,7 @@ import static com.facebook.presto.metadata.CastType.JSON_TO_MAP_CAST; import static com.facebook.presto.metadata.CastType.JSON_TO_ROW_CAST; import static com.facebook.presto.spi.function.FunctionImplementationType.JAVA; +import static com.facebook.presto.spi.function.FunctionImplementationType.REST; import static com.facebook.presto.spi.function.FunctionImplementationType.SQL; import static com.facebook.presto.spi.function.FunctionKind.SCALAR; import static com.facebook.presto.spi.relation.ExpressionOptimizer.Level; @@ -217,6 +218,7 @@ public Object visitCall(CallExpression node, Object context) { List argumentTypes = new ArrayList<>(); List argumentValues = new ArrayList<>(); + List channels = new ArrayList<>(); for (RowExpression expression : node.getArguments()) { Object value = expression.accept(this, context); argumentValues.add(value); @@ -280,6 +282,14 @@ public Object visitCall(CallExpression node, Object context) // do not interpret remote functions or cpp UDF on coordinator return call(node.getDisplayName(), functionHandle, node.getType(), toRowExpressions(argumentValues, node.getArguments())); } + else if (implementationType.equals(REST)) { + value = functionInvoker.invoke( + functionHandle, + argumentValues, + argumentTypes, + channels, + node.getType()); + } else if (implementationType.equals(JAVA)) { value = functionInvoker.invoke(functionHandle, session.getSqlFunctionProperties(), argumentValues); } diff --git a/presto-main/src/test/java/com/facebook/presto/server/TestServerConfig.java b/presto-main/src/test/java/com/facebook/presto/server/TestServerConfig.java index 56f94a1ec216b..92657a3260f36 100644 --- a/presto-main/src/test/java/com/facebook/presto/server/TestServerConfig.java +++ b/presto-main/src/test/java/com/facebook/presto/server/TestServerConfig.java @@ -49,7 +49,8 @@ public void testDefaults() .setPoolType(DEFAULT) .setClusterStatsExpirationDuration(new Duration(0, MILLISECONDS)) .setNestedDataSerializationEnabled(true) - .setClusterResourceGroupStateInfoExpirationDuration(new Duration(0, MILLISECONDS))); + .setClusterResourceGroupStateInfoExpirationDuration(new Duration(0, MILLISECONDS)) + .setRestUri(null)); } @Test @@ -72,6 +73,7 @@ public void testExplicitPropertyMappings() .put("cluster-stats-expiration-duration", "10s") .put("nested-data-serialization-enabled", "false") .put("cluster-resource-group-state-info-expiration-duration", "10s") + .put("rest-uri", "7778") .build(); ServerConfig expected = new ServerConfig() @@ -90,7 +92,8 @@ public void testExplicitPropertyMappings() .setPoolType(LEAF) .setClusterStatsExpirationDuration(new Duration(10, SECONDS)) .setNestedDataSerializationEnabled(false) - .setClusterResourceGroupStateInfoExpirationDuration(new Duration(10, SECONDS)); + .setClusterResourceGroupStateInfoExpirationDuration(new Duration(10, SECONDS)) + .setRestUri("7778"); assertFullMapping(properties, expected); } diff --git a/presto-spi/src/main/java/com/facebook/presto/spi/RestURIManager.java b/presto-spi/src/main/java/com/facebook/presto/spi/RestURIManager.java new file mode 100644 index 0000000000000..fafc535741aac --- /dev/null +++ b/presto-spi/src/main/java/com/facebook/presto/spi/RestURIManager.java @@ -0,0 +1,19 @@ +/* + * 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.spi; + +public interface RestURIManager +{ + String getRestUriManager(); +} diff --git a/presto-spi/src/main/java/com/facebook/presto/spi/function/FunctionImplementationType.java b/presto-spi/src/main/java/com/facebook/presto/spi/function/FunctionImplementationType.java index 88bc6d8e1ebe9..60a51a06fcd98 100644 --- a/presto-spi/src/main/java/com/facebook/presto/spi/function/FunctionImplementationType.java +++ b/presto-spi/src/main/java/com/facebook/presto/spi/function/FunctionImplementationType.java @@ -19,7 +19,8 @@ public enum FunctionImplementationType SQL(false, true), THRIFT(true, false), GRPC(true, false), - CPP(false, false); + CPP(false, false), + REST(true, false); private final boolean externalExecution; private final boolean evaluatedInCoordinator;