Search in sources :

Example 1 with ZimbraLdapConfig

use of com.zimbra.cs.ldap.LdapServerConfig.ZimbraLdapConfig in project zm-mailbox by Zimbra.

the class UBIDLdapContext method init.

public static synchronized void init(boolean alwaysUseMaster) throws LdapException {
    assert (!initialized);
    if (initialized) {
        return;
    }
    initialized = true;
    try {
        masterConfig = new ZimbraLdapConfig(LdapServerType.MASTER);
        masterConnPool = LdapConnectionPool.createConnectionPool(LdapConnectionPool.CP_ZIMBRA_MASTER, masterConfig);
    } catch (LdapException e) {
        ZimbraLog.ldap.info("master is down, falling back to replica...");
        replicaConfig = new ZimbraLdapConfig(LdapServerType.REPLICA);
        replicaConnPool = LdapConnectionPool.createConnectionPool(LdapConnectionPool.CP_ZIMBRA_REPLICA, replicaConfig);
        masterConfig = replicaConfig;
        masterConnPool = replicaConnPool;
        ZimbraLog.ldap.info("using replica");
    }
    if (alwaysUseMaster) {
        replicaConfig = masterConfig;
        replicaConnPool = masterConnPool;
    } else {
        if (replicaConfig == null) {
            replicaConfig = new ZimbraLdapConfig(LdapServerType.REPLICA);
        }
        if (replicaConnPool == null) {
            replicaConnPool = LdapConnectionPool.createConnectionPool(LdapConnectionPool.CP_ZIMBRA_REPLICA, replicaConfig);
        }
    }
}
Also used : ZimbraLdapConfig(com.zimbra.cs.ldap.LdapServerConfig.ZimbraLdapConfig) LdapException(com.zimbra.cs.ldap.LdapException)

Aggregations

LdapException (com.zimbra.cs.ldap.LdapException)1 ZimbraLdapConfig (com.zimbra.cs.ldap.LdapServerConfig.ZimbraLdapConfig)1