cancel
Showing results for 
Search instead for 
Did you mean: 

WDServerState.getActualApplications() issues

former_member182374
Active Contributor
0 Kudos

Hi All,

I'm using the 'WDServerState.getActualApplications()' to see how many times a <b>specific</b> application is currently running on my portal.

However, I'm having 2 issues:

1) Say I'm counting how many instances of application1 are running. If I navigate to application2 the counter will decrease but if logoff from the portal (by the 'log off' link or by closing the browser), the counter stays at the same value and I need to

wait to the timeout in order it to decrease. Is there a way to control this?

2) On a load balancing system the ''WDServerState.getActualApplications()' sometimes throws an exception (I don't know why because exception details doesn't contain any information). Any idea what's causing this?

Also, any suggestions for counting the number of instances of a specific WD application are welcomed...

Regards,

Omri

Accepted Solutions (0)

Answers (1)

Answers (1)

former_member182374
Active Contributor
0 Kudos

One more try...

Former Member
0 Kudos

Omri,

Never tried API you mentioned, so here what I would do if this API never exists:

1. Create Entity Bean with primary key as string and sole counter field of type int

2. In wdDoInit of root component controller (root component == top-level component used by application)

-- get Entity Bean by primary key (application name) and increment counter;

-- if bean does not exists then create it and set counter to 1

3. In wdDoExit of same controller decrement counter and / or optionally remove bean.

To make operations transactional, I'd even combine steps in [2] and [3] and expose them via some stateless session bean operations, like the following pseudocode:


[Transaction=Required]
incrementCount(String appName) {
  try {
    bean = getByPK(appName);
    bean.counter++;
  }
    catch (NotFoundException) {
    bean = create(appName);
    bean.counter = 1;
  }
}

[Transaction=Required]
decrementCount(appName) {
  try {
    bean = getByPK(appName);
    bean.counter--;
  }
    catch (NotFoundException) {
    /* Nothing to do */
  }
}

Valery Silaev

SaM Solutions

http://www.sam-solutions.net

former_member182374
Active Contributor
0 Kudos

Hi Valery,

Some questions about wdDoExit:

1) Will it be called when I close the browser?

2) Will it be called when I logoff from the portal?

Does it matter if I use a cluster?

Say I have 3 applications server in the cluster (3 machines). Will the the counter work for the cluster or will it be for each application server?

Thanks,

Omri

Former Member
0 Kudos

Omri,

Definitely it must work in cluster while it's mandatory requirement to synchronize entity beans across all cluster nodes.

What I'm sure about is that wdDoExit is invoked when you are closing browser with stand-alone WD application. Not sure about portal, but I firmly believe it should. Just try a cheap test: add code to wdDoExit that saves some file at predefined location and see what happens when logging-out in portal or closing browser window with portal.

Valery Silaev

SaM Solutions

http://www.sam-solutions.net

former_member182374
Active Contributor
0 Kudos

Thanks Valery.

I will try that.

I remember having trouble in the past working with wdDoExit (when I closed the browser, it wasn't called). But I will again.

Omri

former_member182374
Active Contributor
0 Kudos

Hi Valery,

I've written some text to a filename and it worked for all 3 cases (navigating to other application, closing the browser, logoff from portal).

Before using a bean I tried to implement a quick solution by using jdbc java code.

in wdDoinit I wrote a query that increases counter - this is always working

in wdDoExit I wrote a query that decreases counter - this isn't working

How do I know what kind of code in wdDoExit will be executed (why jdbc doesn't work and writing to a file/using entity bean should work)?

Thanks,

Omri

former_member182374
Active Contributor
0 Kudos

Hi Valery,

I've written some text to a filename and it worked for all 3 cases (navigating to other application, closing the browser, logoff from portal).

Before using a bean I tried to implement a quick solution by using jdbc java code.

in wdDoinit I wrote a query that increases counter - this is always working

in wdDoExit I wrote a query that decreases counter - this isn't working

How do I know what kind of code in wdDoExit will be executed (why jdbc doesn't work and writing to a file/using entity bean should work)?

Thanks,

Omri