MCPcopy Create free account
hub / github.com/e2wugui/zeze / commit

Method commit

ZezeJava/ZezeJava/src/main/java/Zeze/Dbh2/CommitRocks.java:211–238  ·  view source on GitHub ↗
(String queryHost, int queryPort, BPrepareBatches.Data batches)

Source from the content-addressed store, hash-verified

209 }
210
211 public void commit(String queryHost, int queryPort, BPrepareBatches.Data batches) {
212 var state = buildTransactionState(batches);
213 var tidBytes = new byte[8];
214 var tid = prepare(queryHost, queryPort, state, batches, tidBytes);
215
216 try {
217 // 保存 commit-point,如果失败,则 undo。
218 saveCommitPoint(tidBytes, state, Commit.eCommitting);
219 } catch (Throwable ex) {
220 undo(tid, state);
221 removeCommitIndex(tidBytes);
222 throw new RuntimeException(ex);
223 }
224
225 // commit
226 try {
227 var futures = new ArrayList<TaskCompletionSource<?>>();
228 for (var e : state.getBuckets()) {
229 futures.add(manager.openBucket(e).commitBatch(tid));
230 }
231 for (var e : futures)
232 e.await();
233 removeCommitIndex(tidBytes);
234 } catch (Throwable ex) {
235 // timer will redo
236 logger.error("", ex);
237 }
238 }
239
240 public static BTransactionState.Data buildTransactionState(BPrepareBatches.Data batches) {
241 var bState = new BTransactionState.Data();

Callers

nothing calls this directly

Calls 10

buildTransactionStateMethod · 0.95
prepareMethod · 0.95
saveCommitPointMethod · 0.95
undoMethod · 0.95
removeCommitIndexMethod · 0.95
addMethod · 0.65
awaitMethod · 0.65
getBucketsMethod · 0.45
commitBatchMethod · 0.45
openBucketMethod · 0.45

Tested by

no test coverage detected