首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 其他教程 > 其他相关 >

【memcached】initialize是不是一个有关问题

2012-10-24 
【memcached】initialize是不是一个问题?版本:gwhalin-Memcached-Java-Client-release_2.6.1-0-gab2cc7e?在m

【memcached】initialize是不是一个问题?

版本:gwhalin-Memcached-Java-Client-release_2.6.1-0-gab2cc7e

?

在memcached使用中:

?

static {String[] serverlist = { "cache0.server.com:12345", "cache1.server.com:12345" };SockIOPool pool = SockIOPool.getInstance();pool.setServers(serverlist);pool.initialize();}
?

最后需要对pool进行initialize();其实就是调用的SchoonerSockIOPool的initialize:

?

public void initialize() {schoonerSockIOPool.initialize();}
?

而在SchoonerSockIOPool初始化中,

?

public void initialize() {initDeadLock.lock();try {// if servers is not set, or it empty, then// throw a runtime exceptionif (servers == null || servers.length <= 0) {log.error("++++ trying to initialize with no servers");throw new IllegalStateException("++++ trying to initialize with no servers");}// poolssocketPool = new HashMap<String, GenericObjectPool>(servers.length);hostDead = new ConcurrentHashMap<String, Date>();hostDeadDur = new ConcurrentHashMap<String, Long>();// only create up to maxCreate connections at once// initalize our internal hashing structuresif (this.hashingAlg == CONSISTENT_HASH)populateConsistentBuckets();elsepopulateBuckets();// mark pool as initializedthis.initialized = true;} finally {initDeadLock.unlock();}}
?

在初始化最后设置了this.initialized = true

?

如果拿到的是同一个SchoonerSockIOPool,就会又一次初始化,这个算不算一个bug?

?

--------------------

?

在自己编程序的时候,把pool的设置集中在一个地方,只进行一次,这样应该就不会有什么问题了。

?

下面就是在MemCachedClient 中,使用这些Pool了

?

?

?

?

?

热点排行