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

Method onCommitBatch

ZezeJava/ZezeJava/src/main/java/Zeze/Dbh2/Dbh2.java:779–808  ·  view source on GitHub ↗
(Dbh2Transaction txn)

Source from the content-addressed store, hash-verified

777 }
778
779 public void onCommitBatch(Dbh2Transaction txn) {
780 var splittingMeta = stateMachine.getBucket().getSplittingMeta();
781 if (splittingMeta == null || dbh2Splitting == null)
782 return;
783
784 var r = new SplitPut();
785 r.Argument.setFromTransaction(true);
786
787 // 如果修改的记录落在分桶目标桶中,则同步过去。
788 for (var e : txn.getBatch().getPuts().entrySet()) {
789 if (splittingMeta.getKeyFirst().compareTo(e.getKey()) <= 0)
790 r.Argument.getPuts().put(e.getKey(), e.getValue());
791 }
792 for (var delete : txn.getBatch().getDeletes()) {
793 if (splittingMeta.getKeyFirst().compareTo(delete) <= 0)
794 r.Argument.getPuts().put(delete, Binary.Empty);
795 }
796
797 // 事务同步流程不能重试,因为提交之后就有新的并发事务过来,而这里是异步的,重试时数据可能不是最新的了。
798 dbh2Splitting.getRaftAgent().send(r, (p) -> {
799 try {
800 if (r.getResultCode() != 0)
801 recoverSplitting(); // restart split.
802 return 0;
803 } catch (Exception ex) {
804 logger.error("", ex);
805 return Procedure.Exception;
806 }
807 });
808 }
809
810 @Override
811 protected long ProcessSplitPutRequest(SplitPut r) throws Exception {

Callers 1

commitBatchMethod · 0.80

Calls 15

recoverSplittingMethod · 0.95
getSplittingMetaMethod · 0.80
getBucketMethod · 0.80
getRaftAgentMethod · 0.80
getKeyFirstMethod · 0.65
getKeyMethod · 0.65
putMethod · 0.65
getValueMethod · 0.65
sendMethod · 0.65
setFromTransactionMethod · 0.45
entrySetMethod · 0.45
getPutsMethod · 0.45

Tested by

no test coverage detected