on 09-25-2006 2:46 PM
I'm looking at using JBoss Cache to cache a large amount of data. If you're unfamiliar with JC, it's a cachine system that will synchronize multiple remote caches in a clustered environment. However, I don't want each cache to load itself at cluster startup, and then sync with all the other caches - there's a lot of data, and I don't want all the caches to become really chatty during startup for performance reasons. I would rather have one server instance act as the master cache, and then have it sync all the other empty caches...
I therefore need a way to determine what node in the cluster I'm running on. How can I programatically do this? I've looked through the API's, but it's like trying to find a needle in a haystack...
Does nobody have this requirement to run a task once in a cluster?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Ken,
That depends on which server version you are using. For the latest ones the scheduler service is the obvious solution.
Btw, I am just wondering, how exactly are you planning to synchronize the cache on the master server with the rest of the servers ? I.e. how you will communicate across the cluster and what will happen if not all "secondary" servers have started ?
How your master server will "understand" that a new server has started so that it will go and update its cache ?
Or if it is the other way - how the "secondary" server will choose between the two modes - "ok, I am up and the master cache has finished updating before 1 day, I will go and update myslef" and "ok, I am up but the master cache has started before one minute, I will wait for it to update me"
Best Regards
Peter
JBoss Cache uses multicasting to communicate between the various nodes in the cluster. The caches synchronize at startup, and when data is modified in the cache (transactions are supported).
We're running NW2004 SP16. I don't see a scheduler service in the VA, so perhaps you're referring to something offered in 2004s?
Hi Ken,
Ok, at least according t its documentation the jboss cache will deal in its own with the failure detection, replication, new servers joining, which answers my curiosity in the upper memo
I was speaking of servers later than NW 2004, but here is a suggestion how to deal with NW 2004:
In order to achieve your goal - "prefetch everything only on one node", you could play with the locking feature. Here is a possible algorithm that could be put in code executed at application start (servlet init method, etc.):
1) Check if the cache is empty, if it is not, you are secondary and someone has already updated you - exit
2) Try to take a cluster unique logical lock in the locking service (here is the <a href="http://help.sap.com/saphelp_erp2005/helpdata/en/9a/4cdcc80fa4c747a2ccb5859f467412/frameset.htm">locking documentation</a>
)If you cannot take the lock- you are the secondary server and someone is refreshing the cache at the moment, exit
3) Update the cache
4) Release the lock
If there is no API to check if the cache is empty, you could potentially use some variable that is part of the cache and will be replicated to all servers. Before releasing the lock, you put some value "CacheUpdated" there.
Another option would be to use some hardcoded logic and workarounds - do something only for specific server id as suggested in upper memo, do something if there is a specific property (System.getProperty()...) that you would put manually in only one server JVM startup options.
Perhaps the simplest solution is to turn off all the cache prefetching - i.e. all nodes will start with empty cache and will load data on demand. You won't screw the performance of the "master" server as well.
HTH
Peter
Hi,
not sure if this helps you - I'm starting a service on the portal on a specified node by using ClusterInformation Service:
IClusterInformation clusterInformation = (IClusterInformation) PortalRuntime.getRuntimeResources().getService("com.sap.portal.runtime.system.clusterinformation.clusterinformation");
int curr_server_id = clusterInformation.getNodeId();
Romano
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
89 | |
10 | |
9 | |
9 | |
9 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.