| | |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Copyright 2008-2009 Sun Microsystems, Inc. |
| | | * Copyright 2008-2010 Sun Microsystems, Inc. |
| | | */ |
| | | |
| | | package org.opends.admin.ads; |
| | |
| | | { |
| | | private ADSContext adsContext; |
| | | private ApplicationTrustManager trustManager; |
| | | private int timeout; |
| | | private String dn; |
| | | private String pwd; |
| | | private Set<ServerDescriptor> servers = new HashSet<ServerDescriptor>(); |
| | |
| | | * @param trustManager the ApplicationTrustManager that must be used to trust |
| | | * certificates when we create connections to the registered servers to read |
| | | * their configuration. |
| | | * @param timeout the timeout to establish the connection in milliseconds. |
| | | * Use {@code 0} to express no timeout. |
| | | */ |
| | | public TopologyCache(ADSContext adsContext, |
| | | ApplicationTrustManager trustManager) |
| | | ApplicationTrustManager trustManager, |
| | | int timeout) |
| | | { |
| | | this.adsContext = adsContext; |
| | | this.trustManager = trustManager; |
| | | this.timeout = timeout; |
| | | dn = ConnectionUtils.getBindDN(adsContext.getDirContext()); |
| | | pwd = ConnectionUtils.getBindPassword(adsContext.getDirContext()); |
| | | } |
| | |
| | | } |
| | | |
| | | /** |
| | | * Returns the timeout to establish the connection in milliseconds. |
| | | * @return the timeout to establish the connection in milliseconds. Returns |
| | | * {@code 0} to express no timeout. |
| | | */ |
| | | public int getConnectTimeout() |
| | | { |
| | | return timeout; |
| | | } |
| | | |
| | | /** |
| | | * Reads the replication monitoring. |
| | | * @throws NamingException if an error occurs reading the replication |
| | | * monitoring. |
| | |
| | | { |
| | | return new ServerLoader(serverProperties, dn, pwd, |
| | | trustManager == null ? null : trustManager.createCopy(), |
| | | timeout, |
| | | getPreferredConnections(), getFilter()); |
| | | } |
| | | |
| | |
| | | ServerLoader loader = |
| | | getServerLoader(replicationServer.getAdsProperties()); |
| | | ctx = loader.createContext(); |
| | | NamingEnumeration monitorEntries = ctx.search(jndiName, filter, ctls); |
| | | NamingEnumeration<SearchResult> monitorEntries = |
| | | ctx.search(jndiName, filter, ctls); |
| | | |
| | | while(monitorEntries.hasMore()) |
| | | { |
| | | SearchResult sr = (SearchResult)monitorEntries.next(); |
| | | SearchResult sr = monitorEntries.next(); |
| | | |
| | | String dn = ConnectionUtils.getFirstValue(sr, "domain-name"); |
| | | int replicaId = -1; |