• 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
Re: How to do DB failover with WO
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to do DB failover with WO


  • Subject: Re: How to do DB failover with WO
  • From: Matteo Centro <email@hidden>
  • Date: Tue, 22 May 2007 18:00:22 +0200

We had a "disappearing database" problem (the common customer practice was to randomly reboot the DB, à la Windows)...
We created a Class to handle all the "disappearing database" stuff (was basically a batch process that fetched stuff from that DB) and in the constructor of the class (could be Application) we declared


EODatabaseContext.setDefaultDelegate(this);

and in the class we implemented the following method:

public synchronized boolean databaseContextShouldHandleDatabaseException (EODatabaseContext dbContext, Throwable anException) {

//inside here we do all sorts of notifications and decide to wait for x minutes before trying to reconnect with
dbContext.database().handleDroppedConnection();


	}

Just my 2 cents!


Matteo

On 22-mag-07, at 17:29, Mike Schrag wrote:

For what it's worth, FrontBase supports clustering (and seamless failover) out-of-the-box also. If you're looking for a cheap and reliable way to get resiliency, FB's definitely worth a look.

ms

On May 22, 2007, at 11:20 AM, Tetsuya Takeo wrote:

Hi list,

I could not find how to do DB failover with WO, and managed to find a solution by myself. Not to repeat such effort, I'd like to make brief comment on this.

I have a system has two databases with replication. Everytime they copy changes each other, if one of the databases goes wrong, the other database runs continuously with same data sets. What I want to do is that, when an accident occurs on a db, then applications switches db, run as if nothing have happend.

My solution is, override WOApplication#handleException method to handle exception typical with DB connection trouble.

Code follows;
---
public WOResponse handleException(Exception ex, WOContext aContext) {
// Sometimes, it receives exception nested with NSForwardException, remove them.
while ( ex instanceof NSForwardException ) {
ex = (Exception)((NSForwardException) ex).originalException();
}
// TODO: It may not be good method to tell whether trouble is about DB connection.
if ( ex.toString().contains("_obtainOpenChannel") ) {
EOModel model = EOModelGroup.defaultGroup().modelNamed ("MyModel");
if ( model != null ) {
NSMutableDictionary newDict = new NSMutableDictionary();
newDict.addEntriesFromDictionary (model.connectionDictionary());
newDict.setObjectForKey("<OTHER DB URL>", "URL");
// Very important spell
EODatabaseContext.forceConnectionWithModel(model, newDict, new EOEditingContext());
return aContext.page().generateResponse();
}
}
WOComponent nextPage = pageWithName( "ErrorPage", aContext );
nextPage.takeValueForKey( ex.toString(), "message" );
return nextPage.generateResponse();
}
---


This code returns the page which met the trouble. To consider improvements, show some message notifying users the DB trouble, switch db urls alternately, etc.

BTW, I cannot attend WWDC this year, have happy WWDC days to attender!
---
竹尾 哲也
email@hidden




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


This email sent to email@hidden


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


This email sent to email@hidden

_______________________________________________ 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
References: 
 >How to do DB failover with WO (From: Tetsuya Takeo <email@hidden>)
 >Re: How to do DB failover with WO (From: Mike Schrag <email@hidden>)

  • Prev by Date: Re: How to do DB failover with WO
  • Next by Date: Re: Is WO dead?
  • Previous by thread: Re: How to do DB failover with WO
  • Next by thread: [WOWODC] More seats available
  • Index(es):
    • Date
    • Thread