grouper-dev - added transactional support for GSH
Subject: Grouper Developers Forum
List archive
- From: Chris Hyzer <>
- To: Grouper Dev <>
- Subject: added transactional support for GSH
- Date: Mon, 22 Sep 2008 11:19:27 -0400
- Accept-language: en-US
- Acceptlanguage: en-US
Hey, This bug is completed: https://bugs.internet2.edu/jira/browse/GRP-116 This acts just like the API. You can begin a
transaction of various types, commit, rollback, end transaction, nest
transactions, get transaction status, and get help for transactions. One
thing which is a little complicated is error handling. In the API you are
in inverse of control, so any exception will rollback the transaction.
However, in GSH, if there is an exception, and you are running a batch script,
you don’t want subsequent commands to keep executing (since would be
outside the transaction boundaries), so if a transaction is open, and there is
any problem, all transactions will rollback and GSH will exit. Here is the help: gsh-0.1.1 0%
help("transaction") transaction help: -
help("transaction") print help
information Transactions facilitate all commands
succeeding or failing together, and perhaps some level of repeatable reads of
the DB (depending on the DB). If there is an open transaction and an
exception is thrown in a command, GSH will shut down so that subsequent
commands will not execute outside of a transaction. -
transactionStatus() print the
list of nested transactions -
transactionStart("<GrouperTransactionType>")
start a transaction, or make sure one is already started Can use:
"READONLY_OR_USE_EXISTING", "NONE",
"READONLY_NEW",
"READ_WRITE_OR_USE_EXISTING", "READ_WRITE_NEW" -
transactionCommit("<GrouperCommitType>")
commit a transaction Can use:
"COMMIT_NOW", "COMMIT_IF_NEW_TRANSACTION - transactionRollback("<GrouperRollbackType>")
rollback a transaction Can use:
"ROLLBACK_NOW", "ROLLBACK_IF_NEW_TRANSACTION -
transactionEnd() end a
transaction. Note if it was
read/write, and not committed or rolled back, this will commit and end gsh-0.1.1 1% Here is the test case: GSH_DEVEL = true resetRegistry() root =
addRootStem("uchicago", "uchicago") ns =
addStem(root.getName(), "nsit", "nsit") ns2 =
addStem(root.getName(), "nsit2", "nsit2") ns3 =
addStem(root.getName(), "nsit3", "nsit3") ns4 =
addStem(root.getName(), "nsit4", "nsit4") assertTrue( "before tx",
transactionStatus() == 0) # Transaction test transactionStart("READ_WRITE_NEW") assertTrue( "outer tx",
transactionStatus() == 1) g2 = addGroup(ns2.getName(), "nas2",
"nas2") transactionStart("READ_WRITE_NEW") assertTrue( "inner rollback tx",
transactionStatus() == 2) g3 = addGroup(ns3.getName(), "nas3",
"nas3") transactionRollback("ROLLBACK_NOW") transactionEnd() assertTrue( "inner rollback end tx",
transactionStatus() == 1) transactionStart("READ_WRITE_NEW") assertTrue( "inner commit tx",
transactionStatus() == 2) g4 = addGroup(ns4.getName(), "nas4",
"nas4") transactionEnd() assertTrue( "inner commit end tx",
transactionStatus() == 1) transactionRollback("ROLLBACK_NOW") transactionEnd() assertTrue( "after tx",
transactionStatus() == 0) groups2 = getGroups("uchicago:nsit2:nas2") groups3 = getGroups("uchicago:nsit3:nas3") groups4 = getGroups("uchicago:nsit4:nas4") assertTrue( "outer rollback",
groups2.size() == 0) assertTrue( "inner rollback",
groups3.size() == 0) assertTrue( "inner commit", groups4.size()
== 1) quit Reminder, this is the GSH help page: https://wiki.internet2.edu/confluence/display/GrouperWG/GrouperShell+(gsh) Regards, Chris |
- added transactional support for GSH, Chris Hyzer, 09/22/2008
Archive powered by MHonArc 2.6.16.