(String queryHost, int queryPort, BPrepareBatches.Data batches)
| 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(); |
nothing calls this directly
no test coverage detected