public static class TestAccount.TxAccount extends Object
TestAccount.Account
. Each transaction has its own
transaction local state (low, high, and change). All operations within a
transaction are applied to the TestAccount.TxAccount
. If the transaction
validates and commits, then the net change in the balance due to
the operations on the transaction is applied to the TestAccount.Account
balance.Modifier and Type | Class and Description |
---|---|
static class |
TestAccount.TxAccount.OverdraftException |
Constructor and Description |
---|
TestAccount.TxAccount(TestAccount.Account account) |
Modifier and Type | Method and Description |
---|---|
void |
commit()
Validate against the current account balance and commit the change to
the account.
|
void |
credit(long cents)
Credit the account.
|
void |
debit(long cents)
Debit the account.
|
String |
toString() |
boolean |
validate()
Validate the transaction against the current account balance.
|
public TestAccount.TxAccount(TestAccount.Account account)
public void credit(long cents)
cents
- The amount.public void debit(long cents) throws TestAccount.TxAccount.OverdraftException
cents
- The amount.TestAccount.TxAccount.OverdraftException
- iff an overdraft must result.public boolean validate()
Validate the transaction against the current account balance.
Note: Validation is currently invoked from within the commit()
,
which handles atomicity with respect to the account balance.
public void commit()
Validate against the current account balance and commit the change to the account.
Note: This validate + commit operation needs to be atomic. That is
achieved here by synchronizing on the account
. However that
technique will not work in a distributed system.
Copyright © 2006–2019 SYSTAP, LLC DBA Blazegraph. All rights reserved.