|
18 | 18 |
|
19 | 19 | import java.time.Duration; |
20 | 20 | import java.time.temporal.ChronoUnit; |
21 | | -import java.util.Optional; |
22 | | -import java.util.UUID; |
23 | 21 |
|
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; |
31 | 25 |
|
32 | 26 | /** |
33 | | - * To access the AttemptContextReactive held by AttemptContext |
| 27 | + * To access the ReactiveTransactionAttemptContext held by TransactionAttemptContext |
34 | 28 | * |
35 | 29 | * @author Michael Reiche |
36 | 30 | */ |
37 | 31 | public class AttemptContextReactiveAccessor { |
38 | 32 |
|
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; |
41 | 37 | } |
42 | 38 |
|
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); |
45 | 43 | } |
46 | 44 |
|
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; |
70 | 49 | } |
| 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 | + // } |
71 | 66 |
|
72 | 67 | private static Duration now() { |
73 | 68 | return Duration.of(System.nanoTime(), ChronoUnit.NANOS); |
74 | 69 | } |
75 | 70 |
|
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 | + |
96 | 93 | } |
0 commit comments