forked from apache/pulsar
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[transaction] Add transaction coordinator client (apache#4953)
*Motivation* Add the interface of transaction coordinator client. So that it can be used by coordinator for committing transactions on topics and subscriptions. NOTE: this PR is only introducing the interface. The implementation will come in subsequent pull requests
- Loading branch information
Showing
3 changed files
with
161 additions
and
0 deletions.
There are no files selected for viewing
80 changes: 80 additions & 0 deletions
80
...src/main/java/org/apache/pulsar/client/impl/transaction/TransactionCoordinatorClient.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
/** | ||
* 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.client.impl.transaction; | ||
|
||
import java.util.concurrent.CompletableFuture; | ||
|
||
/** | ||
* The transaction coordinator client to commit and abort transactions on topics. | ||
*/ | ||
public interface TransactionCoordinatorClient { | ||
|
||
/** | ||
* Commit the transaction associated with the topic. | ||
* | ||
* @param topic topic name | ||
* @param txnIdMostBits the most bits of txn id | ||
* @param txnIdLeastBits the least bits of txn id | ||
* @return the future represents the commit result | ||
*/ | ||
CompletableFuture<Void> commitTxnOnTopic(String topic, | ||
long txnIdMostBits, | ||
long txnIdLeastBits); | ||
|
||
/** | ||
* Abort the transaction associated with the topic. | ||
* | ||
* @param topic topic name | ||
* @param txnIdMostBits the most bits of txn id | ||
* @param txnIdLeastBits the least bits of txn id | ||
* @return the future represents the abort result | ||
*/ | ||
CompletableFuture<Void> abortTxnOnTopic(String topic, | ||
long txnIdMostBits, | ||
long txnIdLeastBits); | ||
|
||
/** | ||
* Commit the transaction associated with the topic subscription. | ||
* | ||
* @param topic topic name | ||
* @param subscription subscription name | ||
* @param txnIdMostBits the most bits of txn id | ||
* @param txnIdLeastBits the least bits of txn id | ||
* @return the future represents the commit result | ||
*/ | ||
CompletableFuture<Void> commitTxnOnSubscription(String topic, | ||
String subscription, | ||
long txnIdMostBits, | ||
long txnIdLeastBits); | ||
|
||
/** | ||
* Abort the transaction associated with the topic subscription. | ||
* | ||
* @param topic topic name | ||
* @param subscription subscription name | ||
* @param txnIdMostBits the most bits of txn id | ||
* @param txnIdLeastBits the least bits of txn id | ||
* @return the future represents the abort result | ||
*/ | ||
CompletableFuture<Void> abortTxnOnSubscription(String topic, | ||
String subscription, | ||
long txnIdMostBits, | ||
long txnIdLeastBits); | ||
|
||
} |
59 changes: 59 additions & 0 deletions
59
...main/java/org/apache/pulsar/client/impl/transaction/TransactionCoordinatorClientImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/** | ||
* 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.client.impl.transaction; | ||
|
||
import java.util.concurrent.CompletableFuture; | ||
import org.apache.pulsar.client.impl.PulsarClientImpl; | ||
import org.apache.pulsar.common.util.FutureUtil; | ||
|
||
/** | ||
* The implementation of {@link TransactionCoordinatorClient}. | ||
*/ | ||
public class TransactionCoordinatorClientImpl implements TransactionCoordinatorClient { | ||
|
||
private final PulsarClientImpl client; | ||
|
||
public TransactionCoordinatorClientImpl(PulsarClientImpl client) { | ||
this.client = client; | ||
} | ||
|
||
@Override | ||
public CompletableFuture<Void> commitTxnOnTopic(String topic, long txnIdMostBits, long txnIdLeastBits) { | ||
return FutureUtil.failedFuture( | ||
new UnsupportedOperationException("Not Implemented Yet")); | ||
} | ||
|
||
@Override | ||
public CompletableFuture<Void> abortTxnOnTopic(String topic, long txnIdMostBits, long txnIdLeastBits) { | ||
return FutureUtil.failedFuture( | ||
new UnsupportedOperationException("Not Implemented Yet")); | ||
} | ||
|
||
@Override | ||
public CompletableFuture<Void> commitTxnOnSubscription(String topic, String subscription, long txnIdMostBits, long txnIdLeastBits) { | ||
return FutureUtil.failedFuture( | ||
new UnsupportedOperationException("Not Implemented Yet")); | ||
} | ||
|
||
@Override | ||
public CompletableFuture<Void> abortTxnOnSubscription(String topic, String subscription, long txnIdMostBits, long txnIdLeastBits) { | ||
return FutureUtil.failedFuture( | ||
new UnsupportedOperationException("Not Implemented Yet")); | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
pulsar-client/src/main/java/org/apache/pulsar/client/impl/transaction/package-info.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/** | ||
* 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. | ||
*/ | ||
/** | ||
* Transaction client implementation. | ||
*/ | ||
package org.apache.pulsar.client.impl.transaction; |