• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Design Problem In Multi-Clustered Environment

 
Ranch Hand
Posts: 2937
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I need some feedback on our implementation of a particular concept in our application.
What we have is a fairly complex system (1500+ java classes) that performs some heavy calculations. The front end for the system is a servlet, and once the request to calculate is submitted from the servlet, it may take up to 10 minutes to calculate it. We would like to provide some feedback to the user during the calc time on the calc status/progress. However, since the servlet is by definition a request/response type of animal, the only way to implement this would be to do a servlet push (which Netscape can do and IE can't). An additional problem is that our front end is housed on the light (presentation) cluster, and the calc engine is on the heavy (business) cluster. Normally, the components from different would talk to each other using an EJB (that is, a servlet will make a "calculate" request to the EJB, and the EJB will spend some time to process the request and return the results). To get a calc status, I would have to re-enter an EJB, which I don't think is possible.
What we eneded up with was a separate status window that would pop up as soon as calculations start and reload itself every N number of seconds. As it reloads itself, it makes a call to JNDI to read the status object from there, and the calc engine itself writes to that object in JNDI as it calculates. JNDI essentially is a medium of communications betweeen the status servlet on the light cluster and the calc engine on the heavy cluster.
What I'd like to know is how sound this scheme is in an enterprise environment. We run under Weblogic 5.1 SP10.
Thanks,
Eugene Kononov.
 
Author
Posts: 6055
8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Interestng question, and a good one. I haven't worked with JSPs, although I have done really basic servlet work years ago, and reread the specs fairly recently. In other words, this is just speculation...
A servlet is a request/response animal. Can you send multiple responses? I think with servlet chaining this is possible.I am thinking of something like the following.
Let's assume the calc has 3 checkpoints, START, 50%, and COMPLETED, and the actual calculation process can recognize when these checkpoints are reached (which I'm assuming b/c your question was on presentation). We do the following...
  • Submit the "start calc" http request
  • The servlet recieves the request

  • a. the calc is started
    b. a new servelet is called, I think in a new thread (see 3)
    c. the servlet returns the request, and displays a page which denotes the START state
  • This second servlet polls the calc state. Wehn the 50% state is reached, it returns the new HTTP reply, which updates the web page (can this be done, I've seen web pages which exhibit this behavior, but I don't know how it's done). this servlet also spawns off another one like it, again in a new thread.
  • This servlet polls untilt he COMPLETED state and does as the previous one did.


  • I have no idea how practical this is, I'm just brain storming. I hope it helps.
    --Mark
    [ May 09, 2002: Message edited by: Mark Herschberg ]
     
    author
    Posts: 621
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    You'd certainly have to adjust you servers request time out parameters to allow the connection to remain open for up to 10 min plus If you want to avoid having any sort of app running in the clients browser (i.e. applet, flash6 which can hit a DB, etc), then you could use a meta-refresh in the web page (a pull rather than a push, which most browsers support) to poll a servlet on the status of the calculation. Have a controller servlet that instantiates a thread (or another servlet, I guess) to do the calculation. Here's a technique to do that.
    1) client requests a calculation to a controller servlet
    2) The controller contains a static map (class scope obviously) and, in this, places the user's sessionId as the key and the calculation thread object)
    i.e.
    protected static Map currentProcesses;
    static {
    currentProcesses = new HashMap();
    }
    public void doPost( blah, blah ) {
    if( startCal ) {
    long sessionId = request.getSession().getId();
    MyCalcThread thread = new MyCalcThread( ... );
    currentProcesses.put( sessionId+"", thread );
    // Then do step 3).
    }
    else if( checkProgress ) {
    // look up the thread in the map using the
    // session id and get an update.
    // Then do step 4).
    }
    }
    3) The servlet responds by writing back a status web page that has a meta refresh header set to check back with the controller servlet.
    4) The controller can continue to send back new pages with updated statuses if you want.
    5) this will continue until the calculation is done.
    Now, I've done each of these things here and there but not in this complete form (my brainstorming). So I'm sure there will be some issues but maybe there is an idea or two you can use.
    Sean
     
    Consider Paul's rocket mass heater.
    reply
      Bookmark Topic Watch Topic
    • New Topic