(Dbh2Transaction txn)
| 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 { |
no test coverage detected