Skip to content

Commit 56ad3fa

Browse files
committed
Merge branch 'datacouch_1145_transaction_support' of github.com:spring-projects/spring-data-couchbase into datacouch_1145_transaction_support
2 parents 4e93e55 + b6989d8 commit 56ad3fa

File tree

56 files changed

+3137
-2953
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+3137
-2953
lines changed

pom.xml

+8-56
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,10 @@
1818
</parent>
1919

2020
<properties>
21-
<couchbase>3.2.5</couchbase>
22-
<couchbase.osgi>3.2.5</couchbase.osgi>
21+
<couchbase>3.3.0</couchbase>
22+
<couchbase.osgi>3.3.0</couchbase.osgi>
2323
<springdata.commons>2.7.0-SNAPSHOT</springdata.commons>
24-
<couchbase-transactions>1.2.2</couchbase-transactions>
2524
<java-module-name>spring.data.couchbase</java-module-name>
26-
<!--
27-
<spring.boot>2.6.0-RC1</spring.boot>
28-
-->
2925
</properties>
3026

3127
<dependencyManagement>
@@ -42,32 +38,6 @@
4238

4339
<dependencies>
4440

45-
<!--
46-
<dependency>
47-
<groupId>org.springframework.boot</groupId>
48-
<artifactId>spring-boot-starter-web</artifactId>
49-
<version>${spring.boot}</version>
50-
</dependency>
51-
<dependency>
52-
<groupId>org.springframework.boot</groupId>
53-
<artifactId>spring-boot-starter-aop</artifactId>
54-
<version>${spring.boot}</version>
55-
</dependency>
56-
-->
57-
58-
59-
<dependency>
60-
<groupId>com.couchbase.client</groupId>
61-
<artifactId>couchbase-transactions</artifactId>
62-
<version>${couchbase-transactions}</version>
63-
<exclusions>
64-
<exclusion>
65-
<groupId>com.couchbase.client</groupId>
66-
<artifactId>java-client</artifactId>
67-
</exclusion>
68-
</exclusions>
69-
</dependency>
70-
7141
<dependency>
7242
<groupId>org.springframework</groupId>
7343
<artifactId>spring-context-support</artifactId>
@@ -89,6 +59,12 @@
8959
<version>${springdata.commons}</version>
9060
</dependency>
9161

62+
<dependency>
63+
<groupId>com.couchbase.client</groupId>
64+
<artifactId>java-client</artifactId>
65+
<version>${couchbase}</version>
66+
</dependency>
67+
9268
<dependency>
9369
<groupId>org.springframework</groupId>
9470
<artifactId>spring-test</artifactId>
@@ -244,29 +220,11 @@
244220
<version>4.0.3</version>
245221
<scope>test</scope>
246222
</dependency>
247-
<dependency>
248-
<groupId>com.couchbase.client</groupId>
249-
<artifactId>couchbase-transactions</artifactId>
250-
<version>${couchbase-transactions}</version>
251-
<scope>compile</scope>
252-
<exclusions>
253-
<exclusion>
254-
<groupId>com.couchbase.client</groupId>
255-
<artifactId>java-client</artifactId>
256-
</exclusion>
257-
</exclusions>
258-
</dependency>
259223
<dependency>
260224
<groupId>org.testcontainers</groupId>
261225
<artifactId>testcontainers</artifactId>
262226
</dependency>
263227

264-
<dependency>
265-
<groupId>com.couchbase.client</groupId>
266-
<artifactId>java-client</artifactId>
267-
<version>3.2.5</version>
268-
</dependency>
269-
270228
<dependency>
271229
<groupId>ch.qos.logback</groupId>
272230
<artifactId>logback-classic</artifactId>
@@ -292,12 +250,6 @@
292250
<enabled>false</enabled>
293251
</releases>
294252
</repository>
295-
<!--
296-
<repository>
297-
<id>jitpack.io</id>
298-
<url>https://jitpack.io</url>
299-
</repository>
300-
-->
301253
</repositories>
302254

303255
<pluginRepositories>

src/main/java/com/couchbase/client/java/Cluster.java

+11
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
import com.couchbase.client.java.search.SearchOptions;
4545
import com.couchbase.client.java.search.SearchQuery;
4646
import com.couchbase.client.java.search.result.SearchResult;
47+
import com.couchbase.client.java.transactions.Transactions;
4748

4849
import java.time.Duration;
4950
import java.util.Map;
@@ -102,6 +103,7 @@
102103
* The SDK will only work against Couchbase Server 5.0 and later, because RBAC (role-based access control) is a first
103104
* class concept since 3.0 and therefore required.
104105
*/
106+
// todo gp is this required?
105107
public class Cluster implements ClusterInterface {
106108

107109
/**
@@ -574,5 +576,14 @@ public void waitUntilReady(final Duration timeout, final WaitUntilReadyOptions o
574576
block(asyncCluster.waitUntilReady(timeout, options));
575577
}
576578

579+
/**
580+
* Allows access to transactions.
581+
*
582+
* @return the {@link Transactions} interface.
583+
*/
584+
@Stability.Uncommitted
585+
public Transactions transactions() {
586+
return new Transactions(core(), environment().jsonSerializer());
587+
}
577588
}
578589

src/main/java/com/couchbase/transactions/AttemptContextReactiveAccessor.java

+54-57
Original file line numberDiff line numberDiff line change
@@ -18,79 +18,76 @@
1818

1919
import java.time.Duration;
2020
import java.time.temporal.ChronoUnit;
21-
import java.util.Optional;
22-
import java.util.UUID;
2321

24-
import com.couchbase.client.core.annotation.Stability;
25-
import com.couchbase.transactions.config.MergedTransactionConfig;
26-
import com.couchbase.transactions.config.PerTransactionConfig;
27-
import com.couchbase.transactions.config.PerTransactionConfigBuilder;
28-
import com.couchbase.transactions.config.TransactionConfig;
29-
import com.couchbase.transactions.forwards.Supported;
30-
import com.couchbase.transactions.log.TransactionLogger;
22+
import com.couchbase.client.core.transaction.log.CoreTransactionLogger;
23+
import com.couchbase.client.java.transactions.ReactiveTransactionAttemptContext;
24+
import com.couchbase.client.java.transactions.TransactionAttemptContext;
3125

3226
/**
33-
* To access the AttemptContextReactive held by AttemptContext
27+
* To access the ReactiveTransactionAttemptContext held by TransactionAttemptContext
3428
*
3529
* @author Michael Reiche
3630
*/
3731
public class AttemptContextReactiveAccessor {
3832

39-
public static AttemptContextReactive getACR(AttemptContext attemptContext) {
40-
return attemptContext.ctx();
33+
public static ReactiveTransactionAttemptContext getACR(TransactionAttemptContext attemptContext) {
34+
// return attemptContext.ctx();
35+
// todo gp is this access needed. Could hold the raw CoreTransactionAttemptContext instead.
36+
return null;
4137
}
4238

43-
public static AttemptContext from(AttemptContextReactive attemptContextReactive) {
44-
return new AttemptContext(attemptContextReactive);
39+
public static TransactionAttemptContext from(ReactiveTransactionAttemptContext attemptContextReactive) {
40+
// todo gp needed?
41+
return null;
42+
// return new TransactionAttemptContext(attemptContextReactive);
4543
}
4644

47-
public static TransactionLogger getLogger(AttemptContextReactive attemptContextReactive) {
48-
return attemptContextReactive.LOGGER;
49-
}
50-
51-
@Stability.Internal
52-
public static AttemptContextReactive newAttemptContextReactive(TransactionsReactive transactions) {
53-
PerTransactionConfig perConfig = PerTransactionConfigBuilder.create().build();
54-
MergedTransactionConfig merged = new MergedTransactionConfig(transactions.config(), Optional.of(perConfig));
55-
56-
TransactionContext overall = new TransactionContext(
57-
transactions.cleanup().clusterData().cluster().environment().requestTracer(),
58-
transactions.cleanup().clusterData().cluster().environment().eventBus(), UUID.randomUUID().toString(), now(),
59-
Duration.ZERO, merged);
60-
61-
String txnId = UUID.randomUUID().toString();
62-
overall.LOGGER.info(configDebug(transactions.config(), perConfig));
63-
return newAttemptContextReactive(transactions, overall, merged, txnId);
64-
}
65-
66-
@Stability.Internal
67-
public static AttemptContextReactive newAttemptContextReactive(TransactionsReactive reactive,
68-
TransactionContext overall, MergedTransactionConfig merged, String txnId) {
69-
return reactive.createAttemptContext(overall, merged, txnId);
45+
public static CoreTransactionLogger getLogger(ReactiveTransactionAttemptContext attemptContextReactive) {
46+
// todo gp needed?
47+
return null;
48+
// return attemptContextReactive;
7049
}
50+
// todo gp needed?
51+
// @Stability.Internal
52+
// public static ReactiveTransactionAttemptContext newAttemptContextReactive(TransactionsReactive transactions){
53+
// return null;
54+
// PerTransactionConfig perConfig = PerTransactionConfigBuilder.create().build();
55+
// MergedTransactionConfig merged = new MergedTransactionConfig(transactions.config(), Optional.of(perConfig));
56+
//
57+
// TransactionContext overall = new TransactionContext(
58+
// transactions.cleanup().clusterData().cluster().environment().requestTracer(),
59+
// transactions.cleanup().clusterData().cluster().environment().eventBus(),
60+
// UUID.randomUUID().toString(), now(), Duration.ZERO, merged);
61+
//
62+
// String txnId = UUID.randomUUID().toString();
63+
// overall.LOGGER.info(configDebug(transactions.config(), perConfig));
64+
// return transactions.createAttemptContext(overall, merged, txnId);
65+
// }
7166

7267
private static Duration now() {
7368
return Duration.of(System.nanoTime(), ChronoUnit.NANOS);
7469
}
7570

76-
static private String configDebug(TransactionConfig config, PerTransactionConfig perConfig) {
77-
StringBuilder sb = new StringBuilder();
78-
sb.append("library version: ");
79-
sb.append(TransactionsReactive.class.getPackage().getImplementationVersion());
80-
sb.append(" config: ");
81-
sb.append("atrs=");
82-
sb.append(config.numAtrs());
83-
sb.append(", metadataCollection=");
84-
sb.append(config.metadataCollection());
85-
sb.append(", expiry=");
86-
sb.append(perConfig.expirationTime().orElse(config.transactionExpirationTime()).toMillis());
87-
sb.append("msecs durability=");
88-
sb.append(config.durabilityLevel());
89-
sb.append(" per-txn config=");
90-
sb.append(" durability=");
91-
sb.append(perConfig.durabilityLevel());
92-
sb.append(", supported=");
93-
sb.append(Supported.SUPPORTED);
94-
return sb.toString();
95-
}
71+
// todo gp if needed let's expose in the SDK
72+
// static private String configDebug(TransactionConfig config, PerTransactionConfig perConfig) {
73+
// StringBuilder sb = new StringBuilder();
74+
// sb.append("library version: ");
75+
// sb.append(TransactionsReactive.class.getPackage().getImplementationVersion());
76+
// sb.append(" config: ");
77+
// sb.append("atrs=");
78+
// sb.append(config.numAtrs());
79+
// sb.append(", metadataCollection=");
80+
// sb.append(config.metadataCollection());
81+
// sb.append(", expiry=");
82+
// sb.append(perConfig.expirationTime().orElse(config.transactionExpirationTime()).toMillis());
83+
// sb.append("msecs durability=");
84+
// sb.append(config.durabilityLevel());
85+
// sb.append(" per-txn config=");
86+
// sb.append(" durability=");
87+
// sb.append(perConfig.durabilityLevel());
88+
// sb.append(", supported=");
89+
// sb.append(Supported.SUPPORTED);
90+
// return sb.toString();
91+
// }
92+
9693
}

0 commit comments

Comments
 (0)