2016-10-11 3 views
0

라운드 로빈 방식으로 사용하려는 두 개의 LDAP 서버가 있습니다. 이 코드는 항상 첫 번째 서버를 선택하는 것으로 보입니다. 어떻게 균등하게 고를 수 있나요??스프링에서 LDAP 연결로드 균형 조정

SearchControls searchControls = new SearchControls(); 
searchControls.setTimeLimit(5000); 

List ldapResultList = ldapTemplate.search("", filter.encode(), searchControls, (ContextMapper) o -> { 
    // do things with result... 
}); 

답변

1

확인 spring-ldap reference documentation :

private static LdapTemplate createLdapTemplate(String[] urls, String username, String password) { 

    LdapContextSource contextSource = new LdapContextSource(); 
    contextSource.setUrls(urls); 
    contextSource.setBase(LDAP_SEARCH_BASE); 

    // username is the same for both LDAP servers 
    contextSource.setUserDn(username); 
    contextSource.setPassword(password); 

    contextSource.setPooled(true); 
    contextSource.afterPropertiesSet(); 

    return new LdapTemplate(contextSource); 
} 

이와 나는 LDAP 템플릿과 같이 사용 장애 복구 기능이 필요한 경우, 하나 개 이상의 URL을 지정할 수 있습니다

따라서로드 균형 조정을이 방법으로 수행 할 수 없습니다.

다른 LDAP 서버간에로드 균형을 조정하려면 LDAP 서버 앞에있는로드 밸런서 (예 : HaProxy)를 가리키는 단일 LDAP 서버 URL을 사용하고 mode tcp , 및 balance roundrobin.