From: Roman R. <rro...@ac...> - 2002-12-15 12:08:28
|
Hi, Sorry for breaking into the conversation... >> BTW as I recall JINI also has leases on transactions for their timeout >> model. This would be fine with me also since it is even more flexible >> than the simple timeout model. It does seem to involve some >> asynchronous communication (sending lease renewals while you are >> waiting for a query to complete). > > Interesting. Can you design an API concept for FB ? I would suggest following (Java syntax): /** * Lease new transaction. This method tries to obtain a lease on * starting new transaction, and in case of success starts it. * * @param trHandle object that will contain transaction handle in case * of success. * @param dbHandle database handle obtained in isc_attach_database. * @param tpb transaction parameters buffer. * @param leasePeriod desired period of transaction duration in * milliseconds. * * @return granted period of transaction duration. * * @throws GDSException if lease cannot be granted. */ int isc_lease_transaction(isc_tr_handle trHandle, isc_db_handle dbHandle, byte[] tpb, int leasePeriod) throws GDSException; /** * Renew already obtained transaction lease. This method tries to * extend lease duration for the specified period of time. * * @param trHandle object that will contain transaction handle in case * of success. * @param dbHandle database handle obtained in isc_attach_database. * @param newLeasePeriod amount of time for which lease should be * extended in milliseconds starting from now. * * @return granted period of transaction duration. * * @throws GDSException if lease cannot be renewed. */ int isc_renew_lease(isc_tr_handle trHandle, isc_db_handle dbHandle, int newLeasePeriod) throws GDSException; Method isc_lease_transaction should be used instead of isc_start_transaction. Cancelling of the lease happens in isc_prepare_transaction2 or isc_rollback_transaction. If neither isc_prepare_transaction2 nor isc_rollback_transaction was called during the granted lease duration, transaction is marked "rollback only". No other statement can be executed in this transaction except isc_rollback_transaction. In this case server can perform rollback internally, but should keep transaction handle until isc_rollback_transaction is called or database connection is closed. Having this implemented you can limit serializable transactions the same way Oracle does this. Client might ask for very long transaction, but server will return only few hours duration and will deny all lease renewals. Similar thing is implemented in JavaGroups and it works. I use it as a lock manager, JBoss people thought about using it for JBoss clustering. Main drawback of this scheme is that when duration of the transaction is not known you have to start thread to renew lease before it expires. If CPU is quite busy, you might fail to renew it. Another drawback is increased network traffic when lease duration is short. Best regards, Roman Rokytskyy __________________________________________________ Do You Yahoo!? Everything you'll ever need on one web page from News and Sport to Email and Music Charts http://uk.my.yahoo.com |