Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Make web application temporarily unavailable while data refresh takes place

Posted on 2004-08-05
8
Medium Priority
?
206 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 2000 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
Suggested Courses

604 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