Loading cadcAccessControl-Server/src/ca/nrc/cadc/ac/server/ldap/LdapConnectionPool.java +18 −11 Original line number Original line Diff line number Diff line Loading @@ -69,6 +69,7 @@ package ca.nrc.cadc.ac.server.ldap; package ca.nrc.cadc.ac.server.ldap; import com.unboundid.ldap.sdk.SearchResult; import org.apache.log4j.Logger; import org.apache.log4j.Logger; import ca.nrc.cadc.ac.server.ldap.LdapConfig.LdapPool; import ca.nrc.cadc.ac.server.ldap.LdapConfig.LdapPool; Loading Loading @@ -107,8 +108,6 @@ public class LdapConnectionPool OFFLINE OFFLINE }; }; Profiler profiler = new Profiler(LdapConnectionPool.class); protected LdapConfig currentConfig; protected LdapConfig currentConfig; private String poolName; private String poolName; private LDAPConnectionPool pool; private LDAPConnectionPool pool; Loading Loading @@ -137,6 +136,7 @@ public class LdapConnectionPool logger.debug("Construct pool: " + poolName + ". system state: " + systemState); logger.debug("Construct pool: " + poolName + ". system state: " + systemState); if (SystemState.ONLINE.equals(systemState) || (SystemState.READONLY.equals(systemState) && readOnly)) if (SystemState.ONLINE.equals(systemState) || (SystemState.READONLY.equals(systemState) && readOnly)) { { Profiler profiler = new Profiler(LdapConnectionPool.class); synchronized (poolMonitor) synchronized (poolMonitor) { { if (!boundPool) if (!boundPool) Loading Loading @@ -176,23 +176,27 @@ public class LdapConnectionPool try try { { Profiler profiler = new Profiler(LdapConnectionPool.class); LDAPConnection conn = null; LDAPConnection conn = null; synchronized (poolMonitor) synchronized (poolMonitor) { { conn = pool.getConnection(); conn = pool.getConnection(); profiler.checkpoint("pool.getConnection"); // BM: This query to the base dn (starting at dc=) has the // BM: This query to the base dn (starting at dc=) has the // effect of clearing any proxied authorization state associated // effect of clearing any proxied authorization state associated // with the receiving ldap server connection. Without this in // with the receiving ldap server connection. Without this in // place, proxied authorization information is sometimes ignored. // place, proxied authorization information is sometimes ignored. logger.debug("Testing connection"); // logger.debug("Testing connection"); int dcIndex = currentConfig.getGroupsDN().indexOf("dc="); // int index = currentConfig.getGroupsDN().indexOf(','); String dcDN = currentConfig.getGroupsDN().substring(dcIndex); // String rdn = currentConfig.getGroupsDN().substring(0, index); Filter filter = Filter.createEqualityFilter("dc", "*"); // Filter filter = Filter.create("(" + rdn + ")"); SearchRequest searchRequest = new SearchRequest(dcDN, SearchScope.BASE, filter, new String[] {"entrydn"}); // conn.search(searchRequest); // index = rdn.indexOf('='); profiler.checkpoint("pool.initConnection"); // String attribute = rdn.substring(0, index); // // SearchRequest searchRequest = new SearchRequest(currentConfig.getGroupsDN(), SearchScope.BASE, filter, new String[] {attribute}); // conn.search(searchRequest); // profiler.checkpoint("pool.initConnection"); } } logger.debug(poolName + " pool statistics after borrow:\n" + pool.getConnectionPoolStatistics()); logger.debug(poolName + " pool statistics after borrow:\n" + pool.getConnectionPoolStatistics()); profiler.checkpoint("get " + poolName + " only connection"); profiler.checkpoint("get " + poolName + " only connection"); Loading @@ -210,7 +214,9 @@ public class LdapConnectionPool { { if (pool != null) if (pool != null) { { Profiler profiler = new Profiler(LdapConnectionPool.class); pool.releaseConnection(conn); pool.releaseConnection(conn); profiler.checkpoint("pool.releaseConnection"); logger.debug(poolName + " pool statistics after release:\n" + pool.getConnectionPoolStatistics()); logger.debug(poolName + " pool statistics after release:\n" + pool.getConnectionPoolStatistics()); } } } } Loading @@ -225,8 +231,9 @@ public class LdapConnectionPool if (pool != null) if (pool != null) { { logger.debug("Closing pool..."); logger.debug("Closing pool..."); Profiler profiler = new Profiler(LdapConnectionPool.class); pool.close(); pool.close(); profiler.checkpoint("Pool closed."); profiler.checkpoint("pool.shutdown"); } } } } Loading cadcAccessControl-Server/src/ca/nrc/cadc/ac/server/ldap/LdapConnections.java +4 −2 Original line number Original line Diff line number Diff line Loading @@ -91,8 +91,6 @@ class LdapConnections { { private final static Logger log = Logger.getLogger(LdapConnections.class); private final static Logger log = Logger.getLogger(LdapConnections.class); Profiler profiler = new Profiler(LdapConnections.class); private LdapPersistence persistence; private LdapPersistence persistence; private LdapConfig config; private LdapConfig config; Loading Loading @@ -134,6 +132,7 @@ class LdapConnections if (autoConfigReadOnlyConn == null) if (autoConfigReadOnlyConn == null) { { log.debug("Getting new auto config read only connection."); log.debug("Getting new auto config read only connection."); Profiler profiler = new Profiler(LdapConnections.class); autoConfigReadOnlyConn = readOnlyPool.getConnection(); autoConfigReadOnlyConn = readOnlyPool.getConnection(); profiler.checkpoint("Get read only connection"); profiler.checkpoint("Get read only connection"); } } Loading Loading @@ -173,6 +172,7 @@ class LdapConnections if (autoConfigReadWriteConn == null) if (autoConfigReadWriteConn == null) { { log.debug("Getting new auto config read write connection."); log.debug("Getting new auto config read write connection."); Profiler profiler = new Profiler(LdapConnections.class); autoConfigReadWriteConn = readWritePool.getConnection(); autoConfigReadWriteConn = readWritePool.getConnection(); profiler.checkpoint("Get read write connection"); profiler.checkpoint("Get read write connection"); } } Loading Loading @@ -212,6 +212,7 @@ class LdapConnections if (autoConfigUnboundReadOnlyConn == null) if (autoConfigUnboundReadOnlyConn == null) { { log.debug("Getting new auto config unbound read only connection."); log.debug("Getting new auto config unbound read only connection."); Profiler profiler = new Profiler(LdapConnections.class); autoConfigUnboundReadOnlyConn = unboundReadOnlyPool.getConnection(); autoConfigUnboundReadOnlyConn = unboundReadOnlyPool.getConnection(); profiler.checkpoint("Get read write connection"); profiler.checkpoint("Get read write connection"); } } Loading Loading @@ -242,6 +243,7 @@ class LdapConnections void releaseConnections() void releaseConnections() { { Profiler profiler = new Profiler(LdapConnections.class); if (persistence != null) if (persistence != null) { { if (autoConfigReadOnlyConn != null) if (autoConfigReadOnlyConn != null) Loading cadcAccessControl-Server/src/ca/nrc/cadc/ac/server/ldap/LdapDAO.java +1 −3 Original line number Original line Diff line number Diff line Loading @@ -103,8 +103,6 @@ public abstract class LdapDAO DN subjDN = null; DN subjDN = null; private Profiler profiler = new Profiler(LdapDAO.class); public LdapDAO(LdapConnections connections) public LdapDAO(LdapConnections connections) { { this.connections = connections; this.connections = connections; Loading Loading @@ -192,8 +190,8 @@ public abstract class LdapDAO if (config.isSecure()) if (config.isSecure()) { { socketFactory = createSSLSocketFactory(); Profiler profiler = new Profiler(LdapDAO.class); Profiler profiler = new Profiler(LdapDAO.class); socketFactory = createSSLSocketFactory(); profiler.checkpoint("createSSLSocketFactory"); profiler.checkpoint("createSSLSocketFactory"); } } else else Loading cadcAccessControl-Server/src/ca/nrc/cadc/ac/server/ldap/LdapGroupDAO.java +2 −3 Original line number Original line Diff line number Diff line Loading @@ -137,8 +137,6 @@ public class LdapGroupDAO<T extends Principal> extends LdapDAO "modifytimestamp", "description", "uniquemember" "modifytimestamp", "description", "uniquemember" }; }; private final Profiler profiler = new Profiler(LdapGroupDAO.class); private LdapUserDAO<T> userDAO; private LdapUserDAO<T> userDAO; // this gets filled by the LdapgroupPersistence // this gets filled by the LdapgroupPersistence Loading Loading @@ -396,6 +394,7 @@ public class LdapGroupDAO<T extends Principal> extends LdapDAO SearchResult searchResult = null; SearchResult searchResult = null; try try { { Profiler profiler = new Profiler(LdapGroupDAO.class); LDAPInterface con = getReadOnlyConnection(); LDAPInterface con = getReadOnlyConnection(); profiler.checkpoint("getGroupNames.getConnection"); profiler.checkpoint("getGroupNames.getConnection"); searchResult = con.search(searchRequest); searchResult = con.search(searchRequest); Loading @@ -414,7 +413,7 @@ public class LdapGroupDAO<T extends Principal> extends LdapDAO } } LdapDAO.checkLdapResult(searchResult.getResultCode()); LdapDAO.checkLdapResult(searchResult.getResultCode()); profiler.checkpoint("checkLdapResult"); // profiler.checkpoint("checkLdapResult"); return groupNames; return groupNames; } } Loading cadcAccessControl-Server/src/ca/nrc/cadc/ac/server/ldap/LdapPersistence.java +3 −2 Original line number Original line Diff line number Diff line Loading @@ -97,8 +97,6 @@ public abstract class LdapPersistence private static final String LDAP_POOL_JNDI_NAME = ConnectionPools.class.getName(); private static final String LDAP_POOL_JNDI_NAME = ConnectionPools.class.getName(); private static final int POOL_CHECK_INTERVAL_MILLESCONDS = 10000; // 10 seconds private static final int POOL_CHECK_INTERVAL_MILLESCONDS = 10000; // 10 seconds Profiler profiler = new Profiler(LdapPersistence.class); // static monitor is required for when multiple LdapPersistence objects // static monitor is required for when multiple LdapPersistence objects // are created. // are created. private static Object jndiMonitor = new Object(); private static Object jndiMonitor = new Object(); Loading Loading @@ -208,6 +206,7 @@ public abstract class LdapPersistence } } if (pools == null) if (pools == null) { { Profiler profiler = new Profiler(LdapPersistence.class); LdapConfig config = LdapConfig.getLdapConfig(); LdapConfig config = LdapConfig.getLdapConfig(); pools = createPools(config); pools = createPools(config); InitialContext ic = new InitialContext(); InitialContext ic = new InitialContext(); Loading Loading @@ -238,6 +237,7 @@ public abstract class LdapPersistence private ConnectionPools createPools(LdapConfig config) private ConnectionPools createPools(LdapConfig config) { { Profiler profiler = new Profiler(LdapPersistence.class); Map<String,LdapConnectionPool> poolMap = new HashMap<String,LdapConnectionPool>(3); Map<String,LdapConnectionPool> poolMap = new HashMap<String,LdapConnectionPool>(3); poolMap.put(POOL_READONLY, new LdapConnectionPool( poolMap.put(POOL_READONLY, new LdapConnectionPool( config, config.getReadOnlyPool(), POOL_READONLY, true, true)); config, config.getReadOnlyPool(), POOL_READONLY, true, true)); Loading Loading @@ -276,6 +276,7 @@ public abstract class LdapPersistence else else { { logger.debug("Detected ldap configuration change, rebuilding pools"); logger.debug("Detected ldap configuration change, rebuilding pools"); Profiler profiler = new Profiler(LdapPersistence.class); boolean poolRecreated = false; boolean poolRecreated = false; final ConnectionPools oldPools = pools; final ConnectionPools oldPools = pools; ConnectionPools newPools = null; ConnectionPools newPools = null; Loading Loading
cadcAccessControl-Server/src/ca/nrc/cadc/ac/server/ldap/LdapConnectionPool.java +18 −11 Original line number Original line Diff line number Diff line Loading @@ -69,6 +69,7 @@ package ca.nrc.cadc.ac.server.ldap; package ca.nrc.cadc.ac.server.ldap; import com.unboundid.ldap.sdk.SearchResult; import org.apache.log4j.Logger; import org.apache.log4j.Logger; import ca.nrc.cadc.ac.server.ldap.LdapConfig.LdapPool; import ca.nrc.cadc.ac.server.ldap.LdapConfig.LdapPool; Loading Loading @@ -107,8 +108,6 @@ public class LdapConnectionPool OFFLINE OFFLINE }; }; Profiler profiler = new Profiler(LdapConnectionPool.class); protected LdapConfig currentConfig; protected LdapConfig currentConfig; private String poolName; private String poolName; private LDAPConnectionPool pool; private LDAPConnectionPool pool; Loading Loading @@ -137,6 +136,7 @@ public class LdapConnectionPool logger.debug("Construct pool: " + poolName + ". system state: " + systemState); logger.debug("Construct pool: " + poolName + ". system state: " + systemState); if (SystemState.ONLINE.equals(systemState) || (SystemState.READONLY.equals(systemState) && readOnly)) if (SystemState.ONLINE.equals(systemState) || (SystemState.READONLY.equals(systemState) && readOnly)) { { Profiler profiler = new Profiler(LdapConnectionPool.class); synchronized (poolMonitor) synchronized (poolMonitor) { { if (!boundPool) if (!boundPool) Loading Loading @@ -176,23 +176,27 @@ public class LdapConnectionPool try try { { Profiler profiler = new Profiler(LdapConnectionPool.class); LDAPConnection conn = null; LDAPConnection conn = null; synchronized (poolMonitor) synchronized (poolMonitor) { { conn = pool.getConnection(); conn = pool.getConnection(); profiler.checkpoint("pool.getConnection"); // BM: This query to the base dn (starting at dc=) has the // BM: This query to the base dn (starting at dc=) has the // effect of clearing any proxied authorization state associated // effect of clearing any proxied authorization state associated // with the receiving ldap server connection. Without this in // with the receiving ldap server connection. Without this in // place, proxied authorization information is sometimes ignored. // place, proxied authorization information is sometimes ignored. logger.debug("Testing connection"); // logger.debug("Testing connection"); int dcIndex = currentConfig.getGroupsDN().indexOf("dc="); // int index = currentConfig.getGroupsDN().indexOf(','); String dcDN = currentConfig.getGroupsDN().substring(dcIndex); // String rdn = currentConfig.getGroupsDN().substring(0, index); Filter filter = Filter.createEqualityFilter("dc", "*"); // Filter filter = Filter.create("(" + rdn + ")"); SearchRequest searchRequest = new SearchRequest(dcDN, SearchScope.BASE, filter, new String[] {"entrydn"}); // conn.search(searchRequest); // index = rdn.indexOf('='); profiler.checkpoint("pool.initConnection"); // String attribute = rdn.substring(0, index); // // SearchRequest searchRequest = new SearchRequest(currentConfig.getGroupsDN(), SearchScope.BASE, filter, new String[] {attribute}); // conn.search(searchRequest); // profiler.checkpoint("pool.initConnection"); } } logger.debug(poolName + " pool statistics after borrow:\n" + pool.getConnectionPoolStatistics()); logger.debug(poolName + " pool statistics after borrow:\n" + pool.getConnectionPoolStatistics()); profiler.checkpoint("get " + poolName + " only connection"); profiler.checkpoint("get " + poolName + " only connection"); Loading @@ -210,7 +214,9 @@ public class LdapConnectionPool { { if (pool != null) if (pool != null) { { Profiler profiler = new Profiler(LdapConnectionPool.class); pool.releaseConnection(conn); pool.releaseConnection(conn); profiler.checkpoint("pool.releaseConnection"); logger.debug(poolName + " pool statistics after release:\n" + pool.getConnectionPoolStatistics()); logger.debug(poolName + " pool statistics after release:\n" + pool.getConnectionPoolStatistics()); } } } } Loading @@ -225,8 +231,9 @@ public class LdapConnectionPool if (pool != null) if (pool != null) { { logger.debug("Closing pool..."); logger.debug("Closing pool..."); Profiler profiler = new Profiler(LdapConnectionPool.class); pool.close(); pool.close(); profiler.checkpoint("Pool closed."); profiler.checkpoint("pool.shutdown"); } } } } Loading
cadcAccessControl-Server/src/ca/nrc/cadc/ac/server/ldap/LdapConnections.java +4 −2 Original line number Original line Diff line number Diff line Loading @@ -91,8 +91,6 @@ class LdapConnections { { private final static Logger log = Logger.getLogger(LdapConnections.class); private final static Logger log = Logger.getLogger(LdapConnections.class); Profiler profiler = new Profiler(LdapConnections.class); private LdapPersistence persistence; private LdapPersistence persistence; private LdapConfig config; private LdapConfig config; Loading Loading @@ -134,6 +132,7 @@ class LdapConnections if (autoConfigReadOnlyConn == null) if (autoConfigReadOnlyConn == null) { { log.debug("Getting new auto config read only connection."); log.debug("Getting new auto config read only connection."); Profiler profiler = new Profiler(LdapConnections.class); autoConfigReadOnlyConn = readOnlyPool.getConnection(); autoConfigReadOnlyConn = readOnlyPool.getConnection(); profiler.checkpoint("Get read only connection"); profiler.checkpoint("Get read only connection"); } } Loading Loading @@ -173,6 +172,7 @@ class LdapConnections if (autoConfigReadWriteConn == null) if (autoConfigReadWriteConn == null) { { log.debug("Getting new auto config read write connection."); log.debug("Getting new auto config read write connection."); Profiler profiler = new Profiler(LdapConnections.class); autoConfigReadWriteConn = readWritePool.getConnection(); autoConfigReadWriteConn = readWritePool.getConnection(); profiler.checkpoint("Get read write connection"); profiler.checkpoint("Get read write connection"); } } Loading Loading @@ -212,6 +212,7 @@ class LdapConnections if (autoConfigUnboundReadOnlyConn == null) if (autoConfigUnboundReadOnlyConn == null) { { log.debug("Getting new auto config unbound read only connection."); log.debug("Getting new auto config unbound read only connection."); Profiler profiler = new Profiler(LdapConnections.class); autoConfigUnboundReadOnlyConn = unboundReadOnlyPool.getConnection(); autoConfigUnboundReadOnlyConn = unboundReadOnlyPool.getConnection(); profiler.checkpoint("Get read write connection"); profiler.checkpoint("Get read write connection"); } } Loading Loading @@ -242,6 +243,7 @@ class LdapConnections void releaseConnections() void releaseConnections() { { Profiler profiler = new Profiler(LdapConnections.class); if (persistence != null) if (persistence != null) { { if (autoConfigReadOnlyConn != null) if (autoConfigReadOnlyConn != null) Loading
cadcAccessControl-Server/src/ca/nrc/cadc/ac/server/ldap/LdapDAO.java +1 −3 Original line number Original line Diff line number Diff line Loading @@ -103,8 +103,6 @@ public abstract class LdapDAO DN subjDN = null; DN subjDN = null; private Profiler profiler = new Profiler(LdapDAO.class); public LdapDAO(LdapConnections connections) public LdapDAO(LdapConnections connections) { { this.connections = connections; this.connections = connections; Loading Loading @@ -192,8 +190,8 @@ public abstract class LdapDAO if (config.isSecure()) if (config.isSecure()) { { socketFactory = createSSLSocketFactory(); Profiler profiler = new Profiler(LdapDAO.class); Profiler profiler = new Profiler(LdapDAO.class); socketFactory = createSSLSocketFactory(); profiler.checkpoint("createSSLSocketFactory"); profiler.checkpoint("createSSLSocketFactory"); } } else else Loading
cadcAccessControl-Server/src/ca/nrc/cadc/ac/server/ldap/LdapGroupDAO.java +2 −3 Original line number Original line Diff line number Diff line Loading @@ -137,8 +137,6 @@ public class LdapGroupDAO<T extends Principal> extends LdapDAO "modifytimestamp", "description", "uniquemember" "modifytimestamp", "description", "uniquemember" }; }; private final Profiler profiler = new Profiler(LdapGroupDAO.class); private LdapUserDAO<T> userDAO; private LdapUserDAO<T> userDAO; // this gets filled by the LdapgroupPersistence // this gets filled by the LdapgroupPersistence Loading Loading @@ -396,6 +394,7 @@ public class LdapGroupDAO<T extends Principal> extends LdapDAO SearchResult searchResult = null; SearchResult searchResult = null; try try { { Profiler profiler = new Profiler(LdapGroupDAO.class); LDAPInterface con = getReadOnlyConnection(); LDAPInterface con = getReadOnlyConnection(); profiler.checkpoint("getGroupNames.getConnection"); profiler.checkpoint("getGroupNames.getConnection"); searchResult = con.search(searchRequest); searchResult = con.search(searchRequest); Loading @@ -414,7 +413,7 @@ public class LdapGroupDAO<T extends Principal> extends LdapDAO } } LdapDAO.checkLdapResult(searchResult.getResultCode()); LdapDAO.checkLdapResult(searchResult.getResultCode()); profiler.checkpoint("checkLdapResult"); // profiler.checkpoint("checkLdapResult"); return groupNames; return groupNames; } } Loading
cadcAccessControl-Server/src/ca/nrc/cadc/ac/server/ldap/LdapPersistence.java +3 −2 Original line number Original line Diff line number Diff line Loading @@ -97,8 +97,6 @@ public abstract class LdapPersistence private static final String LDAP_POOL_JNDI_NAME = ConnectionPools.class.getName(); private static final String LDAP_POOL_JNDI_NAME = ConnectionPools.class.getName(); private static final int POOL_CHECK_INTERVAL_MILLESCONDS = 10000; // 10 seconds private static final int POOL_CHECK_INTERVAL_MILLESCONDS = 10000; // 10 seconds Profiler profiler = new Profiler(LdapPersistence.class); // static monitor is required for when multiple LdapPersistence objects // static monitor is required for when multiple LdapPersistence objects // are created. // are created. private static Object jndiMonitor = new Object(); private static Object jndiMonitor = new Object(); Loading Loading @@ -208,6 +206,7 @@ public abstract class LdapPersistence } } if (pools == null) if (pools == null) { { Profiler profiler = new Profiler(LdapPersistence.class); LdapConfig config = LdapConfig.getLdapConfig(); LdapConfig config = LdapConfig.getLdapConfig(); pools = createPools(config); pools = createPools(config); InitialContext ic = new InitialContext(); InitialContext ic = new InitialContext(); Loading Loading @@ -238,6 +237,7 @@ public abstract class LdapPersistence private ConnectionPools createPools(LdapConfig config) private ConnectionPools createPools(LdapConfig config) { { Profiler profiler = new Profiler(LdapPersistence.class); Map<String,LdapConnectionPool> poolMap = new HashMap<String,LdapConnectionPool>(3); Map<String,LdapConnectionPool> poolMap = new HashMap<String,LdapConnectionPool>(3); poolMap.put(POOL_READONLY, new LdapConnectionPool( poolMap.put(POOL_READONLY, new LdapConnectionPool( config, config.getReadOnlyPool(), POOL_READONLY, true, true)); config, config.getReadOnlyPool(), POOL_READONLY, true, true)); Loading Loading @@ -276,6 +276,7 @@ public abstract class LdapPersistence else else { { logger.debug("Detected ldap configuration change, rebuilding pools"); logger.debug("Detected ldap configuration change, rebuilding pools"); Profiler profiler = new Profiler(LdapPersistence.class); boolean poolRecreated = false; boolean poolRecreated = false; final ConnectionPools oldPools = pools; final ConnectionPools oldPools = pools; ConnectionPools newPools = null; ConnectionPools newPools = null; Loading