WencongLiu commented on code in PR #20236: URL: https://github.com/apache/flink/pull/20236#discussion_r931883425
########## flink-table/flink-sql-gateway/src/main/java/org/apache/flink/table/gateway/rest/SqlGatewayRestEndpoint.java: ########## @@ -0,0 +1,75 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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 org.apache.flink.table.gateway.rest; + +import org.apache.flink.api.java.tuple.Tuple2; +import org.apache.flink.configuration.Configuration; +import org.apache.flink.configuration.ReadableConfig; +import org.apache.flink.runtime.rest.RestServerEndpoint; +import org.apache.flink.runtime.rest.RestServerEndpointConfiguration; +import org.apache.flink.runtime.rest.handler.RestHandlerSpecification; +import org.apache.flink.table.gateway.api.SqlGatewayService; +import org.apache.flink.table.gateway.api.endpoint.SqlGatewayEndpoint; +import org.apache.flink.table.gateway.rest.util.SqlGatewayRestOptions; +import org.apache.flink.util.ConfigurationException; + +import org.apache.flink.shaded.netty4.io.netty.channel.ChannelInboundHandler; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.CompletableFuture; + +/** The rest endpoint for sql gateway. */ +public class SqlGatewayRestEndpoint extends RestServerEndpoint implements SqlGatewayEndpoint { + + public final SqlGatewayService service; + + public SqlGatewayRestEndpoint(ReadableConfig configuration, SqlGatewayService sqlGatewayService) + throws IOException, ConfigurationException { + super( + (Configuration) configuration, + getRestServerEndpointConfiguration((Configuration) configuration)); + service = sqlGatewayService; + } + + @Override + protected List<Tuple2<RestHandlerSpecification, ChannelInboundHandler>> initializeHandlers( + CompletableFuture<String> localAddressFuture) { + return new ArrayList<>(); + } + + @Override + protected void startInternal() {} + + @Override + public void stop() throws Exception { + super.close(); + } + + public static RestServerEndpointConfiguration getRestServerEndpointConfiguration( + Configuration config) throws ConfigurationException { + RestServerEndpointConfiguration.Builder builder = + RestServerEndpointConfiguration.builderFromConfiguration(config); + builder.setRestAddress(config.getString(SqlGatewayRestOptions.ADDRESS)); + builder.setRestBindAddress(config.getString(SqlGatewayRestOptions.BIND_ADDRESS)); + builder.setRestBindPortRange(config.getString(SqlGatewayRestOptions.BIND_PORT)); + return builder.build(); Review Comment: RestServerEndpointConfiguration only use BIND_PORT so the builder does't contains this property, and it will fallback to PORT. The default value of PORT is 8083 currently, which will adapt to the previous version of SQL gateway and reduce the user migration cost. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
