You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jcs-users@jakarta.apache.org by Narendra Verma <Na...@symphonysv.com> on 2011/12/25 11:51:23 UTC
Need Help on JCS Remote Cache
Hi All,
I have made setup of JCS in my Linux environment and trying to make a POC using Remote Cache.
My System Setup:
* RMI Server : Running on 10.55.164.215 (using RMI Start up Servlet)
* Client-1: Running on box 10.55.164.215 on same machine where serer is running
* Client-2: Running on box 10.55.164.45
My Configuration Files:
* Server Configuration
# ----------------------------------------------
# Registry used to register and provide the
# IRemoteCacheService service.
registry.host=10.55.164.215
registry.port=1102
# call back port to local caches.
remote.cache.service.port=1102
# rmi socket factory timeout
remote.cache.rmiSocketFactoryTimeoutMillis=5000
# cluster setting
remote.cluster.LocalClusterConsistency=false
remote.cluster.AllowClusterGet=false
# ----------------------------------------------
# DEFAULT CACHE REGION
jcs.default=
jcs.default.cacheattributes=org.apache.jcs.engine.CompositeCacheAttributes
jcs.default.cacheattributes.MaxObjects=1000
jcs.default.cacheattributes.MemoryCacheName=org.apache.jcs.engine.memory.lru.LRUMemoryCache
# PRE-DEFINED CACHE REGIONS
jcs.region.userCache=
jcs.region.userCache.cacheattributes=org.apache.jcs.engine.CompositeCacheAttributes
jcs.region.userCache.cacheattributes.MaxObjects=1000
jcs.region.userCache.cacheattributes.MemoryCacheName=org.apache.jcs.engine.memory.lru.LRUMemoryCache
jcs.region.userCache.cacheattributes.UseMemoryShrinker=false
jcs.region.userCache.cacheattributes.MaxMemoryIdleTimeSeconds=3600
jcs.region.userCache.cacheattributes.ShrinkerIntervalSeconds=60
jcs.region.userCache.cacheattributes.MaxSpoolPerRun=500
jcs.region.userCache.elementattributes=org.apache.jcs.engine.ElementAttributes
jcs.region.userCache.elementattributes.IsEternal=false
* Client-1 and Client-2 Configuration at separate boxes - See the above in System Setup Section
# DEFAULT CACHE REGION
# sets the default aux value for any non configured caches
jcs.default=RC
jcs.default.cacheattributes=org.apache.jcs.engine.CompositeCacheAttributes
jcs.default.cacheattributes.MaxObjects=1000
jcs.default.cacheattributes.MemoryCacheName=org.apache.jcs.engine.memory.lru.LRUMemoryCache
jcs.default.elementattributes.IsEternal=false
jcs.default.elementattributes.MaxLifeSeconds=3600
jcs.default.elementattributes.IdleTime=1800
jcs.default.elementattributes.IsSpool=true
jcs.default.elementattributes.IsRemote=true
jcs.default.elementattributes.IsLateral=false
# CACHE REGIONS AVAILABLE
# Regions preconfigured for caching
jcs.region.userCache=RC
jcs.region.userCache.cacheattributes=org.apache.jcs.engine.CompositeCacheAttributes
jcs.region.userCache.cacheattributes.MaxObjects=1200
jcs.region.userCache.cacheattributes.MemoryCacheName=org.apache.jcs.engine.memory.lru.LRUMemoryCache
jcs.region.userCache.elementattributes.IsEternal=false
jcs.region.userCache.elementattributes.MaxLifeSeconds=7200
jcs.region.userCache.elementattributes.IdleTime=1800
jcs.region.userCache.elementattributes.IsSpool=true
jcs.region.userCache.elementattributes.IsRemote=true
jcs.region.userCache.elementattributes.IsLateral=false
# Remote RMI Cache set up to failover
# This remote client does not receive
jcs.auxiliary.RC=org.apache.jcs.auxiliary.remote.RemoteCacheFactory
jcs.auxiliary.RC.attributes=org.apache.jcs.auxiliary.remote.RemoteCacheAttributes
jcs.auxiliary.RC.attributes.FailoverServers=10.55.164.215:1102
jcs.auxiliary.RC.attributes.LocalPort=1202
jcs.auxiliary.RC.attributes.RemoveUponRemotePut=true
jcs.auxiliary.RC.attributes.RmiSocketFactoryTimeoutMillis=5000
jcs.auxiliary.RC.attributes.GetOnly=false
jcs.auxiliary.RC.attributes.Receive=true
Client Test Programs:
Input parameters while running client-1 : java com.brightsky.util.JCSTest /cache-client1.ccf
Input parameters while running client-2 : java com.brightsky.util.JCSTest /cache.ccf-client1
package com.brightsky.util;
import java.util.Date;
/*
* This code is property of BrightSky, Inc. Use, duplication and disclosure
* in any form without permission of copyright holder is prohibited.
*
* (C) Copyright BrightSky, Inc. 2011. All rights reserved.
*/
/**
* @author nverma
*
*/
public class JCSTest {
public static void main(String a[]) throws InterruptedException {
System.out.println("\n =======================================================================================\n" );
System.out.println("\n =================================== QA Node - "+a[0]+ "================================\n" );
System.out.println("\n =======================================================================================\n" );
System.out.println("\n ----------------------------------Initializing JCS....\n" );
CacheManager cm = CacheManager.getInstance(a[0]);
System.out.println("\n ----------------------------------Initialized Successfully.\n" );
int userId = 1;
int notificationCount = 10 ;
int loopCount = 5 ;
int threadSleepSec = 2 ;
userId = 1;
notificationCount =10;
loopCount =5;
threadSleepSec =2;
UserCacheObj userObject;
// If no, then write and fetch in loop
// if yes, no write only fetch object of passed userid
if("no".equals(a[6])){
// Create Object
userObject = new UserCacheObj();
userObject.setUserId(userId);
userObject.setNotificationCount(notificationCount);
System.out.println("\n ----------------------------------Storing object into cache....\n" );
// Store the object into cache
cm.storeUserbj(userObject);
System.out.println("\n ----------------------------------Stored Successfully.\n" );
}
System.out.println("\n ---------------Starting loop to fetch and increment notification count for userId ["+userId+"] .....\n" );
for(int i=1; i<=loopCount; i++){
System.out.println("\n -----------[Attemp : "+i+"] \n" );
Date date = new Date();
userObject = cm.getUserObj(userId);
System.out.println("\n ----------- ["+date+"] Fetched Notification Count = "+userObject.getNotificationCount());
int notificationCnt = userObject.getNotificationCount() + 1;
userObject.setNotificationCount(notificationCnt);
date = new Date();
System.out.println("\n ----------- Incremented notification count ["+notificationCnt+"] ");
cm.storeUserbj(userObject);
System.out.println("\n ----------- ... ["+date+"] Pushed to updated object ");
Thread.sleep(1000 * threadSleepSec);
}
System.out.println("\n ----------- Loop End. !!!! Good Bye !!!!\n" );
}
}
Question and Problem:
When I put any object from either client-1 or client-2 then server shows log that it is creating listener for corresponding clients. And event is put successfully.
Server logs on Client-1 Run
2011-12-25 15:46:12,801 INFO [org.apache.jcs.auxiliary.remote.server.RemoteCacheServer] (RMI TCP Connection(78)-10.55.164.145) adding vm listener under new id = [46], listenerAddress [127.0.0.1]
2011-12-25 15:46:12,801 INFO [org.apache.jcs.auxiliary.remote.server.RemoteCacheServer] (RMI TCP Connection(78)-10.55.164.145) Region userCache's listener size = 2
Server logs on Client-2 Run
2011-12-25 16:04:11,509 INFO [org.apache.jcs.auxiliary.remote.server.RemoteCacheServer] (RMI TCP Connection(91)-10.55.164.215) adding vm listener under new id = [48], listenerAddress [10.55.164.215]
2011-12-25 16:04:11,509 INFO [org.apache.jcs.auxiliary.remote.server.RemoteCacheServer] (RMI TCP Connection(91)-10.55.164.215) Region userCache's listener size = 3
Scenario-1:
When I put object from client-2 and access it in client-1, it is fetched successfully. But when I update it in client-1 and pushed it again then clien-2 does not access the object with same ID and null pointer exception comes. Event when I try to access it again with client-1 again null pointer exception comes. Need to confirm why object is not accessible after updating by any of the client?
Scenario-2:
When I put object from client-1 and access it in client-2, it never fetched. Need to confirm why client-2 never access the object put by the client-1? Where client-1 access once if client-2 puts.
Please help/guide me to resolve these issues.
Thanks & Regards,
Narendra Verma
________________________________
NOTICE TO RECIPIENT: THIS E-MAIL (INCLUDING ANY ATTACHMENTS) IS MEANT FOR ONLY THE INTENDED RECIPIENT OF THE TRANSMISSION, MAY CONTAIN CONFIDENTIAL INFORMATION, AND IS PROTECTED BY LAW. IF YOU RECEIVED THIS E-MAIL IN ERROR, PLEASE IMMEDIATELY NOTIFY THE SENDER OF THE ERROR BY RETURN E-MAIL, DELETE THIS COMMUNICATION AND SHRED ANY ATTACHMENTS. UNAUTHORIZED REVIEW, USE, DISSEMINATION, DISTRIBUTION, COPYING OR TAKING OF ANY ACTION BASED ON THIS COMMUNICATION IS STRICTLY PROHIBITED.