WebSphere Dynacache线程阻塞

时间:2016-10-10 16:07:54

标签: caching websphere websphere-7

我在WebSphere Application Server 7.0.0.37上运行一个Web应用程序,它使用IBM的DynaCache来存储下拉列表的数据。当我向迭代列表的代码添加加载时,我最终看到线程阻塞了对堆的分析。

以下是检索DistributedMap的代码。注意,我没有缓存InitialContext,因为IBM指出它会为你缓存;但是,我将继续测试它是否能解决我遇到的问题。

public PinqCache() {
    if (getProviderTypeSpecialtyMap() != null) {
        getProviderTypeSpecialtyMap().clear();
    }
}

public DistributedMap getProviderTypeSpecialtyMap() {
    return getDistributedMapByName("/services/cache/provTypeSpecialty");
}

private DistributedMap getDistributedMapByName(String name) {
    InitialContext ic;
    DistributedMap dm = null;
    try {
        ic = new InitialContext();
        dm = (DistributedMap) ic.lookup(name);
    } catch (NamingException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    return dm;
}

当我从IBM的线程分析工具查看线程分析时,我看到有41个线程被阻塞。这是来自其中一个被阻塞线程的堆栈跟踪:

Thread Name = WebContainer : 3758
State = Blocked
Monitor = Waiting for Monitor Lock on com/ibm/ws/naming/jcache/Cache@0x0000000041FDBCC0/0x0000000041FDBCCC
Java Stack = 
at com/ibm/ws/naming/jcache/Cache.bind(Cache.java:374(Compiled Code)) 
at com/ibm/ws/naming/jndicos/CNContextImpl.processResolveResults(CNContextImpl.java:3738(Compiled Code)) 
at com/ibm/ws/naming/jndicos/CNContextImpl.doLookup(CNContextImpl.java:1861(Compiled Code)) 
at com/ibm/ws/naming/jndicos/CNContextImpl.doLookup(CNContextImpl.java:1762(Compiled Code)) 
at com/ibm/ws/naming/jndicos/CNContextImpl.lookupExt(CNContextImpl.java:1513(Compiled Code)) 
at com/ibm/ws/naming/jndicos/CNContextImpl.lookup(CNContextImpl.java:645(Compiled Code)) 
at com/ibm/ws/naming/util/WsnInitCtx.lookup(WsnInitCtx.java:166(Compiled Code)) 
at com/ibm/ws/naming/util/WsnInitCtx.lookup(WsnInitCtx.java:180(Compiled Code)) 
at javax/naming/InitialContext.lookup(InitialContext.java:436(Compiled Code)) 
at PinqCache.getDistributedMapByName(PinqCache.java:32(Compiled Code)) 

有不同的API方法显示块:

com/ibm/ws/naming/jcache/Cache.lookup
com/ibm/ws/naming/jcache/Cache.bind
com/ibm/ws/naming/jcache/Cache.setLifetimeProperties

我的问题是,在调用InitialContext.lookup时线程阻塞的情况是什么?

---更新---

我添加了拥有显示器锁的线程。

    Thread Name = WebContainer : 3709
    State = Waiting on Condition
    Monitor = Owns Monitor Lock on com/ibm/ws/naming/jcache/Cache@0x0000000041FDBCC0/0x0000000041FDBCCC
    Java Stack = 
at com/ibm/ws/naming/jcache/Cache.getParentContext(Cache.java:1003(Compiled Code)) 
at com/ibm/ws/naming/jcache/Cache.bind(Cache.java:382(Compiled Code)) 
at com/ibm/ws/naming/jndicos/CNContextImpl.processResolveResults(CNContextImpl.java:3738(Compiled Code)) 
at com/ibm/ws/naming/jndicos/CNContextImpl.doLookup(CNContextImpl.java:1861(Compiled Code)) 
at com/ibm/ws/naming/jndicos/CNContextImpl.doLookup(CNContextImpl.java:1762(Compiled Code)) 
at com/ibm/ws/naming/jndicos/CNContextImpl.lookupExt(CNContextImpl.java:1513(Compiled Code)) 
at com/ibm/ws/naming/jndicos/CNContextImpl.lookup(CNContextImpl.java:645(Compiled Code)) 
at com/ibm/ws/naming/util/WsnInitCtx.lookup(WsnInitCtx.java:166(Compiled Code)) 
at com/ibm/ws/naming/util/WsnInitCtx.lookup(WsnInitCtx.java:180(Compiled Code)) 
at javax/naming/InitialContext.lookup(InitialContext.java:436(Compiled Code)) 
at com/hcsc/rtb/fs/DAO/pinqDs/PinqCache.getDistributedMapByName(PinqCache.java:32(Compiled Code))

---更新2 ---

我能够从JNDI跟踪中捕获信息。我已经包含了一些我认为相关的内容;但是,这里显然还有更多。

我一直在看下面的例外情况。我不得不将群集名称视为隐私。

[10/12/16 14:22:59:986 CDT] 00000084 CNContextImpl >  getNameInNamespace Entry
[10/12/16 14:22:59:986 CDT] 00000084 CNContextImpl <  getNameInNamespace Exit ********
[10/12/16 14:22:59:986 CDT] 00000084 NameSpace     3   lookupInternal
                                 lookupInternal, nsID=10, name=: this=com.ibm.ws.naming.ipbase.NameSpace@1c781c78[_nameSpaceID=10, _nameSpaceType=2, _contextsTable=java.util.HashMap@a5c8e52d[size=9], _bindingsTable=java.util.HashMap@7cd83d3c[size=24]], currContext=com.ibm.ws.naming.jndicos.CNContextImpl@27442744[contextID=t-shrdm-was70-2Cell01/clusters/rtb_uat2, nameInNamespace=********]
[10/12/16 14:22:59:986 CDT] 00000084 NameSpace     3   validateName
                                 Name is null or empty.
[10/12/16 14:22:59:987 CDT] 00000084 Cache         3   getParentContext
                                 javax.naming.InvalidNameException: A null or empty name is not allowed.
    at com.ibm.ws.naming.ipbase.NameSpace.validateName(NameSpace.java:1632)
    at com.ibm.ws.naming.ipbase.NameSpace.lookupInternal(NameSpace.java:1115)
    at com.ibm.ws.naming.ipbase.NameSpace.intermediateCacheLookup(NameSpace.java:1101)
    at com.ibm.ws.naming.jcache.Cache.getParentContext(Cache.java:943)
    at com.ibm.ws.naming.jcache.Cache.bind(Cache.java:382)
    at com.ibm.ws.naming.jndicos.CNContextImpl.processResolveResults(CNContextImpl.java:3738)
    at com.ibm.ws.naming.jndicos.CNContextImpl.doLookup(CNContextImpl.java:1861)
    at com.ibm.ws.naming.jndicos.CNContextImpl.doLookup(CNContextImpl.java:1762)
    at com.ibm.ws.naming.jndicos.CNContextImpl.lookupExt(CNContextImpl.java:1513)
    at com.ibm.ws.naming.jndicos.CNContextImpl.lookup(CNContextImpl.java:645)
    at com.ibm.ws.naming.util.WsnInitCtx.lookup(WsnInitCtx.java:166)
    at com.ibm.ws.naming.util.WsnInitCtx.lookup(WsnInitCtx.java:180)
    at javax.naming.InitialContext.lookup(InitialContext.java:436)

0 个答案:

没有答案