nevdmitry commented on code in PR #5080: URL: https://github.com/apache/ignite-3/pull/5080#discussion_r1926630881
########## modules/rest/src/main/java/org/apache/ignite/internal/rest/transaction/TransactionController.java: ########## @@ -0,0 +1,103 @@ +/* + * 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.ignite.internal.rest.transaction; + +import static java.util.concurrent.CompletableFuture.completedFuture; +import static org.apache.ignite.internal.util.CompletableFutures.nullCompletedFuture; + +import io.micronaut.http.annotation.Controller; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.UUID; +import java.util.concurrent.CompletableFuture; +import org.apache.ignite.internal.rest.ResourceHolder; +import org.apache.ignite.internal.rest.api.transaction.TransactionApi; +import org.apache.ignite.internal.rest.api.transaction.TransactionInfo; +import org.apache.ignite.internal.rest.transaction.exception.TransactionNotFoundException; +import org.apache.ignite.sql.IgniteSql; +import org.apache.ignite.sql.ResultSet; +import org.apache.ignite.sql.SqlRow; +import org.apache.ignite.sql.Statement; + +/** + * REST endpoint allows to manage transactions. + */ +@Controller("/management/v1/transaction") +public class TransactionController implements TransactionApi, ResourceHolder { + + private IgniteSql igniteSql; + + public TransactionController(IgniteSql igniteSql) { + this.igniteSql = igniteSql; + } + + @Override + public CompletableFuture<Collection<TransactionInfo>> transactions() { + return completedFuture(transactionInfos()); + } + + @Override + public CompletableFuture<TransactionInfo> transaction(UUID transactionId) { + return completedFuture(transactionInfos(transactionId)).thenApply(transactionInfos -> { + if (transactionInfos.isEmpty()) { + throw new TransactionNotFoundException(transactionId.toString()); + } else { + return transactionInfos.get(0); + } + }); + } + + @Override + public CompletableFuture<Void> cancelTransaction(UUID transactionId) { + // Waiting https://issues.apache.org/jira/browse/IGNITE-23488 Review Comment: I decided to leave implementation but right now it is doesn't work. Once [IGNITE-23488](https://issues.apache.org/jira/browse/IGNITE-23488) will be done, we will update rest and test https://issues.apache.org/jira/browse/IGNITE-24296 ########## modules/sql-engine-api/src/main/java/org/apache/ignite/internal/sql/engine/api/kill/KillHandlerRegistry.java: ########## @@ -28,4 +28,12 @@ public interface KillHandlerRegistry { * @param handler Handler to register. */ void register(OperationKillHandler handler); + + /** + * Returns operation kill handler for specified operation type. + * + * @param type operation type. Review Comment: done ########## modules/sql-engine-api/src/main/java/org/apache/ignite/internal/sql/engine/api/kill/KillHandlerRegistry.java: ########## @@ -28,4 +28,12 @@ public interface KillHandlerRegistry { * @param handler Handler to register. */ void register(OperationKillHandler handler); + + /** + * Returns operation kill handler for specified operation type. + * + * @param type operation type. + * @return operation kill handler for specified operation type. Review Comment: done -- 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]
