• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Dr. Miguel 'Optimistic Locking' Arroz [was Re: WebObjects stress Testing tool?]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Dr. Miguel 'Optimistic Locking' Arroz [was Re: WebObjects stress Testing tool?]


  • Subject: Dr. Miguel 'Optimistic Locking' Arroz [was Re: WebObjects stress Testing tool?]
  • From: Kieran Kelleher <email@hidden>
  • Date: Thu, 3 Dec 2009 10:02:13 -0500

By the way Miguel, I made a little Optimistic lock action utility class to handle this (similar to how ERXEOAccessUtilities.ChannelAction is constructed)... you might find it useful....... example of usage nippet is shown after the class listing below .......

<snip content = "snippet of static inner class from my EO utilities class">
/**
* Deals with the nitty-gritty of a critical <strong>short-running</strong>
* task where we depend on optimistic locking to guarantee that another
* process does not change optimistic locking attributes at the same time. To
* understand why this is necessary, read this: 
* {@link http://terminalapp.net/dr-optimistic-locking/}. 
* 
* Wraps the actions in
* appropriate locks. WARNING: The OSC is locked for the period of the
* transaction. All EOF access on this OSC is blocked. Do not use this for
* actions that take more than a few milliseconds on OSC's that are being
* used by request threads!
* 
* Code design inspired by {@link ERXEOAccessUtilities.ChannelAction}
* 
* @author kieran
*/
public static abstract class OptimisticLockAction {

/**
* This method is called in a new locked editing context that has been
* created in the osc passed in. Perform your changes in this editing
* context. Any errors will be thrown. Return any result you want.
* 
* @param osc
*/
protected abstract Object doPerform(EOEditingContext ec);

public Object perform() throws Exception {
return perform(null);
}

/**
* @param osc
*            the root object store to be locked so that true optimistic
*            locking can be enforced.
* @return the result of your doPerform method implementation
* @throws Exception
*/
public Object perform(EOObjectStore osc) throws Exception {
osc.lock();
try {
ERXEC ec = (ERXEC) ERXEC.newEditingContext(osc);
ec.setCoalesceAutoLocks(false);
ec.setUseAutoLock(false);
ec.lock();
try {
// Don't use stale EO's to begin with
ec.setFetchTimestamp(System.currentTimeMillis());
return doPerform(ec);
} catch (Exception e) {
throw e;
} finally {
ec.unlock();
ec.dispose();
}
} catch (Exception e) {
throw e;
} finally {
osc.unlock();
}
}
}
</snip>



<snip content = "example usage">

// Create a new Optimistic Lock action
OptimisticLockAction action = "" WKEOUtils.OptimisticLockAction() {

@Override
protected Object doPerform(EOEditingContext actionEditingContext) {            
CTCampaign localCampaign = (CTCampaign) actionEditingContext.faultForGlobalID(gid, actionEditingContext);
try {
// Make the critical concurrent changes that depend on optimistic locking failure
localCampaign.shipMessages();
actionEditingContext.saveChanges();
} catch (EOGeneralAdaptorException e) {
// Handle the optimistic lock failure ...
}
return null;
}
};


// Perform the optimistic lock action
try {
action.perform(parentObjectStore());
} catch (Exception e) {
// Unexpected exception
throw new NestableRuntimeException(e);
}

</snip>



On Dec 3, 2009, at 8:45 AM, Miguel Arroz wrote:

Hello

 We use JMeter, not so much to test how much load can the server get, but to test my beloved weird concurrency handling situations. As almost any software in the world, it sucks specially at the UI level (it's far from being integrated in OS X, not even copy/paste works between it and the Mac world), and you have to allocate it a lot of RAM or it will eventually blow up the heap, but it gets the job done.

 Yours

Miguel Arroz



 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Dr. Miguel 'Optimistic Locking' Arroz [was Re: WebObjects stress Testing tool?]
      • From: Miguel Arroz <email@hidden>
    • Re: Dr. Miguel 'Optimistic Locking' Arroz [was Re: WebObjects stress Testing tool?]
      • From: Anjo Krank <email@hidden>
  • Prev by Date: Re: Qualifier through relationship
  • Next by Date: Re: You backtrack too far problem.
  • Previous by thread: Re: Qualifier through relationship
  • Next by thread: Re: Dr. Miguel 'Optimistic Locking' Arroz [was Re: WebObjects stress Testing tool?]
  • Index(es):
    • Date
    • Thread