简体   繁体   English

使用Oracle Internet Directory的连接池

[英]Connection Pooling with Oracle Internet Directory

I'm using Oracle's Java API Extensions to JNDI for accessing Oracle Internet Directory 11g (ldapjclnt11.jar library). 我正在使用Oracle对JNDI的Java API扩展来访问Oracle Internet Directory 11g(ldapjclnt11.jar库)。 A new dir context (connection) is created by calling ConnectionUtil.getDefaultDirCtx(). 通过调用ConnectionUtil.getDefaultDirCtx()创建新的目录上下文(连接)。

My question is: does this mechanism for creating a connection to the OID use some kind of connection pooling for the JNDI connections? 我的问题是:用于创建与OID的连接的这种机制是否对JNDI连接使用某种连接池? if not, is there a way to pool the connections? 如果没有,是否可以合并连接?

I'll be authenticating hundreds of users concurrently with OID, and I'm worried that the performance would suffer if I don't pool my OID connections. 我将同时通过OID认证数百个用户,并且我担心如果不合并OID连接会降低性能。

Your fear is probably well founded: Pooling reduces garbage collection and pause times for socket connects, but I would highly advise checking your assumptions against a profiler like VisualVM. 您的担心可能是有根据的:池化可以减少垃圾收集和套接字连接的暂停时间,但是我强烈建议您对照VisualVM之类的分析器检查您的假设。 Every performance problem I've ever solved was not what I thought it was. 我曾经解决的每个性能问题都不是我想的那样。 Don't make blind guesses about your code! 不要对您的代码盲目猜测!

Assuming you're on a Sun/Oracle JVM, there is a property to enable transparent pooling: 假设您使用的是Sun / Oracle JVM,则有一个属性可以启用透明池:

Hashtable env = new Hashtable();
env.put(Context.PROVIDER_URL, "ldap://localhost:389/o=myroot");
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
env.put("com.sun.jndi.ldap.connect.pool", "true");
DirContext ctx = new InitialDirContext(env);

The ConnectionUtil class does not allow for setting this property, but you could try setting the following properties on your JVM if you have to use ConnectionUtil: ConnectionUtil类不允许设置此属性,但是如果必须使用ConnectionUtil,则可以尝试在JVM上设置以下属性:

-Dcom.sun.jndi.ldap.connect.pool=true

Not sure if that will work though. 不确定是否可以。 You'll have to use wireshark or something to verify the behavior. 您必须使用wireshark或其他方法来验证行为。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM