WencongLiu commented on code in PR #20451: URL: https://github.com/apache/flink/pull/20451#discussion_r938459685
########## flink-table/flink-sql-gateway/src/main/java/org/apache/flink/table/gateway/rest/handler/operation/AbstractOperationHandler.java: ########## @@ -0,0 +1,91 @@ +/* + * 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.handler.operation; + +import org.apache.flink.runtime.rest.handler.HandlerRequest; +import org.apache.flink.runtime.rest.handler.RestHandlerException; +import org.apache.flink.runtime.rest.messages.EmptyRequestBody; +import org.apache.flink.runtime.rest.messages.MessageHeaders; +import org.apache.flink.table.gateway.api.SqlGatewayService; +import org.apache.flink.table.gateway.api.operation.OperationHandle; +import org.apache.flink.table.gateway.api.operation.OperationStatus; +import org.apache.flink.table.gateway.api.session.SessionHandle; +import org.apache.flink.table.gateway.api.utils.SqlGatewayException; +import org.apache.flink.table.gateway.rest.handler.AbstractSqlGatewayRestHandler; +import org.apache.flink.table.gateway.rest.message.operation.OperationHandleIdPathParameter; +import org.apache.flink.table.gateway.rest.message.operation.OperationMessageParameters; +import org.apache.flink.table.gateway.rest.message.operation.OperationStatusResponseBody; +import org.apache.flink.table.gateway.rest.message.session.SessionHandleIdPathParameter; +import org.apache.flink.table.gateway.rest.util.SqlGatewayRestAPIVersion; + +import org.apache.flink.shaded.netty4.io.netty.handler.codec.http.HttpResponseStatus; + +import javax.annotation.Nonnull; + +import java.util.Map; +import java.util.concurrent.CompletableFuture; + +/** Abstract operation handler. */ +public abstract class AbstractOperationHandler + extends AbstractSqlGatewayRestHandler< + EmptyRequestBody, OperationStatusResponseBody, OperationMessageParameters> { + + public AbstractOperationHandler( + SqlGatewayService service, + Map<String, String> responseHeaders, + MessageHeaders< + EmptyRequestBody, + OperationStatusResponseBody, + OperationMessageParameters> + messageHeaders) { + super(service, responseHeaders, messageHeaders); + } + + private String getStatus(SessionHandle sessionHandle, OperationHandle operationHandle) { + if (execute(sessionHandle, operationHandle)) { + return this.service + .getOperationInfo(sessionHandle, operationHandle) + .getStatus() + .toString(); + } else { + return OperationStatus.CLOSED.toString(); + } + } + + boolean execute(SessionHandle sessionHandle, OperationHandle operationHandle) { Review Comment: The class inheritance structure has been refactored. -- 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]
