|
View:
New views
1 Messages
—
Rating Filter:
Alert me
|
|
|
oscache issues: Cannot get my objects to replicate across my cluster nomatter what I doI placed this question on the forums a few weeks ago bit I am not sure anyone noticed it, thought I might try the ML. from http://forums.opensymphony.com/thread.jspa?threadID=577818&tstart=0 Hi, I was wondering if anyone could help me on this one, spent over 2 days on this and trawled the web for a solution but a solution still evades me. I have 2 tomcat servers running the exact same web application which are successfully clustered, Server1 runs a batch job and stores the results on the cache, server 2 has the same cache object but when I go there pick up the results from server 1 nothing is there. Here is my cache object.... public class FootballCache { private transient static Logger logger = Logger.getLogger(FootballCache.class); private static GeneralCacheAdministrator analysisCache = new GeneralCacheAdministrator() ; private final static FootballCache thisFootballCache = new FootballCache() ; /** * */ private FootballCache(){ } /** * * @return */ public static synchronized FootballCache getInstance(){ return thisFootballCache ; } /** * */ public void putAnalysisInCache( Competition competition , String date , ArrayList<AnalysisList> analysisResults ){ logger.debug( "ADDING TO CACHE: '" + competition.getId() + "_" + date + "' games: " + analysisResults.size() ) ; String key = "" + competition.getId() + "_" + date ; analysisCache.putInCache( key , analysisResults , new ExpiresRefreshPolicy( CacheEntry.INDEFINITE_EXPIRY ) ) ; } /** * * @return */ public Set<Date> getCachedAnalysisCompetition( Competition competition ) throws Exception { Set<Date> sortedDates = new TreeSet<Date>() ; // WE WANT TO GET TODAYS DATE, KEEP ADDING AMONTHS WORK OF DAYS TO IT Date todaysDate = new Date() ; DateFormat formatter = new SimpleDateFormat("dd.MM.yy"); for( int i = 0 ; i < 31 ; i++ ){ String dateString = formatter.format(todaysDate) ; try{ analysisCache.getFromCache( competition.getId() + "_" + dateString , CacheEntry.INDEFINITE_EXPIRY ) ; sortedDates.add( formatter.parse(dateString) ) ; } catch( Exception e ){ analysisCache.cancelUpdate(competition.getId() + "_" + dateString ) ; } todaysDate.setTime( todaysDate.getTime() + 86400000 ) ; } return sortedDates ; } } The code is slightly messy, but the basics are server 1 calls putAnalysisInCache and server 2 calls getCachedAnalysisCompetition, the business logic is correct, if server 1 calls getCachedAnalysisCompetition it all works. Just that the objects put on the analysisCache object do not seem to be replicated across to server 2 but are always there on server 1. I was not sure if jgroups worked and my machine was able to multicast but the jgroups test draw application ran OK, if I run server 2 with jgroups log4j set to DEBUG I can see the GMS address of server 2 in this line.. 11:07:36,663 DEBUG GMS:77 - initial_mbrs are [[own_addr=192.168.1.65:62613, coord_addr=192.168.1.64:4479, is_server=true], [own_addr=192.168.1.64:4479, coord_ad dr=192.168.1.64:4479, is_server=true]] I can also see JavaGroups output on server 1 when I call the getCachedAnalysisCompetition method on the cache on server 2, so I am fairly sure it is my coding and not the set up. I have added the logs for both server for completness. Many thanks David oscache.properties cache.event.listeners=com.opensymphony.oscache.plugins.clustersupport.J avaGroupsBroadcastingListener versions: oscache 2.4.1 jgroups 2.6.9 Windows Liveā¢: Keep your life in sync. Check it out. |
| Free embeddable forum powered by Nabble | Forum Help |