Solved

Make web application temporarily unavailable while data refresh takes place

Posted on 2004-08-05
8
195 Views
Last Modified: 2010-03-31
Hello All,

We are working on an application in which data needs to be refreshed on a regular basis. Currently the application server is shutdown before the data refresh takes place and started again when data has been refreshed. But the problem is that due to certain reasons the application take a huge amount of time to start up. What we are looking at now is to find out if the web application can be flagged as unavailable for a short duration till the data refresh takes place. Is there some way this can be done. We are using Weblogic 8.1.

The data refresh part is a Java batch job (i.e a standalone program) that reads some xml files and inserts data into a SQL Server database (the database is re-created and the old one is archived or deleted). This batch job need not reside on the same host as the database server or application server. It could be on a seperate host on its own. When the application starts up on Weblogic it reads all the data from the SQL Server database and caches it into memory in suitable java objects. It caches each and every record.

These are the questions that we are facing.
1] How do we notify the application that it should stop servicing any requests from the java batch job (not stopping the app server).
2] How to we suspend the web application for a short duration
3] How do we notify the application that it should start servicing any requests from the java batch job (not restarting the app server).
4] How do we kill all the user sessions that are currently active.
5] How can the cache in memory be updated to reflect the new data.

Its a very complex problem and I dont know if its even possible. Even if I can get answers to a few of the above questions I would appreciate it very much.

Thanks,
Bhay
0
Comment
Question by:bhayzone
8 Comments
 
LVL 35

Expert Comment

by:TimYates
ID: 11725068
I have a thread with watches a properties file.  When that properties file changes, it reloads the file into the System.properties (taking the old values it knew about out first)

Then, I have a Filter in my webapplication.  Each request it gets, it checks the "system.down" property (a String)  If it exists, it redirects the user to a holding page, and displays the string.

So shutting down the website nicely, is just a matter of uncommenting a property in a properties file :-)

And waiting for the thread to pick up that the file has changed :-)

Tim
0
 
LVL 12

Expert Comment

by:Giant2
ID: 11725252
another solution could be to send a message to stop to the system (like done in Tomcat shutdown).
And when this message is reached, all the request could be redirected to some other place (like TimYates told).

Giant.
0
 
LVL 3

Expert Comment

by:kumvjuec
ID: 11791797
I assume you are using struts. The problem will be easy to solve then Here are the steps you should take, obviously, your java program will flag the maintainance activity using may be a .lock file or by specially putting something inside a file

1. Extend the Action class by MyAction class.
2. In its execute() method, check for the flag you have set(.lock exists or not for eg)
    If you find the flag set, then do these
        a. request.getSession().invalidate()
        b. redirect the request to an error jsp.
    else If all is well, just return from the method.
3. Extend all your custom Action classes to extend MyAction instead.
4. In the execute method of each class, just call super.execute() on the FIRST line.

When your maintenance activity is done, just delete the .lock file and your applcation will resume operation.
Hope this addresses most of your questions :)
0
 

Author Comment

by:bhayzone
ID: 11807246
Hi All,

Sorry for replying so late. I liked your idea of using a filter. I have come up with a way to suspend the application and start it again without restarting the webserver. I simply make my struts AcitonServlet throw an UnavailableException, which takes a paramereter to specify how long do you want the servlet to be unavailable. Do you think this is a good way to do it.


    throw new UnavailableException (50000);

I cannot use the option suggested by kumvjuec because the application is one which has already been developmed and we are making enhancements. It wont be possible to modify each and every existing Action class.

We are now working on a workaround for this task. For example, we now wont be replacing the already existing cached data with the new one, but will maintain two cached objects. All new requests will pick up data from the new cache object while the old object will service the old data. Once there are no more sessions using the old object, it will be discarded and everyone will now use the new object.

There will be an array of cache objects. An index in each users session will indicate which of the cache objects to use. I dont know if what we have come up with is a good approach or not.

I think the notification to the web applicaiton to start and stop accepting requests temporarily is out. There is no requirement for a notification mechanism because we will now be providing the trigger to start caching manually (probably through a button on the page)

It would be of great help if you could identify some potential problems with the approach that we are taking.

For my own knowledge, is there anyway that we can kill all user sessions? I know of a way that can be done, but for that it is essential that struts be implemented properly.
0
 
LVL 35

Accepted Solution

by:
TimYates earned 500 total points
ID: 11807870
> Do you think this is a good way to do it.

You could just put the bit in the Filter, so that for each request, it can throw an UnavailableException before it even gets to the actions, you can then define an Exception handler in the struts-config file, so that when unavailable, it forwards to a page that says the site is down :-)

> There will be an array of cache objects. An index in each users session will indicate which of the cache objects to use. I dont know if what we have come up with is a good approach or not.

That sounds ok!  By doing it this way, you won't have problems of users having stale objects in their session...  One thing to be careful of though, is if the cached object can be changed by the user, you might get problems with concurrency (someone writes at the same time as someone else, at the same time someone reads) ;-)

Tim
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now