ivankelly commented on a change in pull request #4161: [transaction][coordinator] add the interfaces for transaction metadata store and an in-memory implementation URL: https://github.com/apache/pulsar/pull/4161#discussion_r279543086
########## File path: pulsar-transaction/coordinator/src/main/java/org/apache/pulsar/transaction/coordinator/TransactionMetadataStore.java ########## @@ -0,0 +1,96 @@ +/** + * 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.pulsar.transaction.coordinator; + +import com.google.common.annotations.Beta; +import java.util.List; +import java.util.concurrent.CompletableFuture; +import org.apache.pulsar.transaction.common.TxnID; +import org.apache.pulsar.transaction.common.TxnStatus; + +/** + * A store for storing all the transaction metadata. + */ +@Beta +public interface TransactionMetadataStore { + + /** + * Query the {@link TxnStatus} of a given transaction <tt>txnid</tt>. + * + * @param txnid transaction id + * @return a future represents the result of this operation. + * it returns {@link TxnStatus} of the given transaction. + */ + default CompletableFuture<TxnStatus> getTxnStatus(TxnID txnid) { + return getTxnMeta(txnid).thenApply(txnMeta -> txnMeta.status()); + } + + /** + * Query the {@link TxnMeta} of a given transaction <tt>txnid</tt>. + * + * @param txnid transaction id + * @return a future represents the result of this operation. + * it returns {@link TxnMeta} of the given transaction. + */ + CompletableFuture<TxnMeta> getTxnMeta(TxnID txnid); + + /** + * Create a new transaction in the transaction metadata store. + * + * @return a future represents the result of creating a new transaction. + * it returns {@link TxnID} as the identifier for identifying the + * transaction. + */ + CompletableFuture<TxnID> newTransaction(); + + /** + * Add the produced partitions to transaction identified by <tt>txnid</tt>. + * + * @param txnid transaction id + * @param partitions the list of partitions that a transaction produces to + * @return a future represents the result of this operation + */ + CompletableFuture<Void> addProducedPartitionToTxn( + TxnID txnid, List<String> partitions); Review comment: Do we have a more precise identifier for partition than String? like TopicName or something ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services
