-
Notifications
You must be signed in to change notification settings - Fork 174
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New SendPayment txn for SmallBank benchmark.
New config parameters for controlling hotpot and dtxn information. Fixes for the Amalgamate txn. Watching baseball with KB. I should probably head upstairs and focus a little bit more so I can graduate and move to Pittsburgh (and KB will get a terrier). We're finally getting rid of Carleton's cards... #117
- Loading branch information
Showing
7 changed files
with
158 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 75 additions & 0 deletions
75
src/benchmarks/edu/brown/benchmark/smallbank/procedures/SendPayment.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
package edu.brown.benchmark.smallbank.procedures; | ||
|
||
import org.voltdb.ProcInfo; | ||
import org.voltdb.SQLStmt; | ||
import org.voltdb.VoltProcedure; | ||
import org.voltdb.VoltTable; | ||
|
||
import edu.brown.benchmark.smallbank.SmallBankConstants; | ||
|
||
/** | ||
* SendPayment Procedure | ||
* @author pavlo | ||
*/ | ||
@ProcInfo ( | ||
partitionParam=0 | ||
) | ||
public class SendPayment extends VoltProcedure { | ||
|
||
public final SQLStmt GetAccount = new SQLStmt( | ||
"SELECT * FROM " + SmallBankConstants.TABLENAME_ACCOUNTS + | ||
" WHERE custid = ?" | ||
); | ||
|
||
public final SQLStmt GetCheckingBalance = new SQLStmt( | ||
"SELECT bal FROM " + SmallBankConstants.TABLENAME_CHECKING + | ||
" WHERE custid = ?" | ||
); | ||
|
||
public final SQLStmt UpdateCheckingBalance = new SQLStmt( | ||
"UPDATE " + SmallBankConstants.TABLENAME_CHECKING + | ||
" SET bal = bal + ? " + | ||
" WHERE custid = ?" | ||
); | ||
|
||
public VoltTable[] run(long sendAcct, long destAcct, double amount) { | ||
// Get Account Information | ||
voltQueueSQL(GetAccount, destAcct); | ||
voltQueueSQL(GetAccount, sendAcct); | ||
final VoltTable acctResults[] = voltExecuteSQL(); | ||
if (acctResults[0].getRowCount() != 1) { | ||
String msg = "Invalid sender account '" + sendAcct + "'"; | ||
throw new VoltAbortException(msg); | ||
} | ||
else if (acctResults[1].getRowCount() != 1) { | ||
String msg = "Invalid destination account '" + destAcct + "'"; | ||
throw new VoltAbortException(msg); | ||
} | ||
|
||
// Get the sender's account balance | ||
voltQueueSQL(GetCheckingBalance, sendAcct); | ||
final VoltTable balResults[] = voltExecuteSQL(); | ||
if (balResults[0].getRowCount() != 1) { | ||
String msg = String.format("No %s for customer #%d", | ||
SmallBankConstants.TABLENAME_SAVINGS, | ||
sendAcct); | ||
throw new VoltAbortException(msg); | ||
} | ||
balResults[0].advanceRow(); | ||
double balance = balResults[0].getDouble(0); | ||
|
||
if (balance < 0) { | ||
String msg = String.format("Insufficient %s funds for customer #%d", | ||
SmallBankConstants.TABLENAME_CHECKING, sendAcct); | ||
throw new VoltAbortException(msg); | ||
} | ||
|
||
// Debt | ||
voltQueueSQL(UpdateCheckingBalance, amount*-1d, sendAcct); | ||
|
||
// Credit | ||
voltQueueSQL(UpdateCheckingBalance, amount, destAcct); | ||
|
||
return (voltExecuteSQL(true)); | ||
} | ||
} |