提交 cc52d9fb authored 作者: Andrei Tokar's avatar Andrei Tokar

rename COMMITTING -> COMMITTED

上级 f9694244
...@@ -253,7 +253,7 @@ public class MVTableEngine implements TableEngine { ...@@ -253,7 +253,7 @@ public class MVTableEngine implements TableEngine {
public void initTransactions() { public void initTransactions() {
List<Transaction> list = transactionStore.getOpenTransactions(); List<Transaction> list = transactionStore.getOpenTransactions();
for (Transaction t : list) { for (Transaction t : list) {
if (t.getStatus() == Transaction.STATUS_COMMITTING) { if (t.getStatus() == Transaction.STATUS_COMMITTED) {
t.commit(); t.commit();
} else if (t.getStatus() != Transaction.STATUS_PREPARED) { } else if (t.getStatus() != Transaction.STATUS_PREPARED) {
t.rollback(); t.rollback();
......
...@@ -46,7 +46,7 @@ public class Transaction { ...@@ -46,7 +46,7 @@ public class Transaction {
* When opening a store, such transactions will automatically * When opening a store, such transactions will automatically
* be processed and closed as committed. * be processed and closed as committed.
*/ */
public static final int STATUS_COMMITTING = 3; public static final int STATUS_COMMITTED = 3;
/** /**
* The status of a transaction that currently in a process of rolling back * The status of a transaction that currently in a process of rolling back
...@@ -192,19 +192,19 @@ public class Transaction { ...@@ -192,19 +192,19 @@ public class Transaction {
case STATUS_PREPARED: case STATUS_PREPARED:
valid = currentStatus == STATUS_OPEN; valid = currentStatus == STATUS_OPEN;
break; break;
case STATUS_COMMITTING: case STATUS_COMMITTED:
valid = currentStatus == STATUS_OPEN || valid = currentStatus == STATUS_OPEN ||
currentStatus == STATUS_PREPARED || currentStatus == STATUS_PREPARED ||
// this case is only possible if called // this case is only possible if called
// from endLeftoverTransactions() // from endLeftoverTransactions()
currentStatus == STATUS_COMMITTING; currentStatus == STATUS_COMMITTED;
break; break;
case STATUS_ROLLED_BACK: case STATUS_ROLLED_BACK:
valid = currentStatus == STATUS_OPEN || valid = currentStatus == STATUS_OPEN ||
currentStatus == STATUS_PREPARED; currentStatus == STATUS_PREPARED;
break; break;
case STATUS_CLOSED: case STATUS_CLOSED:
valid = currentStatus == STATUS_COMMITTING || valid = currentStatus == STATUS_COMMITTED ||
currentStatus == STATUS_ROLLED_BACK; currentStatus == STATUS_ROLLED_BACK;
break; break;
default: default:
...@@ -361,11 +361,11 @@ public class Transaction { ...@@ -361,11 +361,11 @@ public class Transaction {
Throwable ex = null; Throwable ex = null;
boolean hasChanges = false; boolean hasChanges = false;
try { try {
long state = setStatus(STATUS_COMMITTING); long state = setStatus(STATUS_COMMITTED);
hasChanges = hasChanges(state); hasChanges = hasChanges(state);
int previousStatus = getStatus(state); int previousStatus = getStatus(state);
if (hasChanges) { if (hasChanges) {
store.commit(this, previousStatus == STATUS_COMMITTING); store.commit(this, previousStatus == STATUS_COMMITTED);
} }
} catch (Throwable e) { } catch (Throwable e) {
ex = e; ex = e;
......
...@@ -166,7 +166,7 @@ public class TransactionStore { ...@@ -166,7 +166,7 @@ public class TransactionStore {
String name; String name;
if (data == null) { if (data == null) {
status = mapName.charAt(UNDO_LOG_NAME_PEFIX.length()) == UNDO_LOG_OPEN ? status = mapName.charAt(UNDO_LOG_NAME_PEFIX.length()) == UNDO_LOG_OPEN ?
Transaction.STATUS_OPEN : Transaction.STATUS_COMMITTING; Transaction.STATUS_OPEN : Transaction.STATUS_COMMITTED;
name = null; name = null;
} else { } else {
status = (Integer) data[0]; status = (Integer) data[0];
...@@ -337,7 +337,7 @@ public class TransactionStore { ...@@ -337,7 +337,7 @@ public class TransactionStore {
transactions.set(transactionId, transaction); transactions.set(transactionId, transaction);
if (undoLogs[transactionId] == null) { if (undoLogs[transactionId] == null) {
String undoName = getUndoLogName(status == Transaction.STATUS_COMMITTING, transactionId); String undoName = getUndoLogName(status == Transaction.STATUS_COMMITTED, transactionId);
MVMap<Long, Object[]> undoLog = store.openMap(undoName, undoLogBuilder); MVMap<Long, Object[]> undoLog = store.openMap(undoName, undoLogBuilder);
undoLogs[transactionId] = undoLog; undoLogs[transactionId] = undoLog;
} }
......
...@@ -411,7 +411,7 @@ public class TestTransactionStore extends TestBase { ...@@ -411,7 +411,7 @@ public class TestTransactionStore extends TestBase {
List<Transaction> list = ts.getOpenTransactions(); List<Transaction> list = ts.getOpenTransactions();
if (list.size() != 0) { if (list.size() != 0) {
tx = list.get(0); tx = list.get(0);
if (tx.getStatus() == Transaction.STATUS_COMMITTING) { if (tx.getStatus() == Transaction.STATUS_COMMITTED) {
i++; i++;
} }
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论