| | |
| | | import static org.opends.messages.AdminToolMessages.*; |
| | | import static org.opends.messages.QuickSetupMessages.*; |
| | | import static org.opends.messages.ToolMessages.*; |
| | | import static org.opends.messages.UtilityMessages. |
| | | ERR_CONFIRMATION_TRIES_LIMIT_REACHED; |
| | | import static org.opends.quicksetup.util.Utils.getFirstValue; |
| | | import static org.opends.quicksetup.util.Utils.getThrowableMsg; |
| | | import static org.opends.server.tools.ToolConstants.*; |
| | |
| | | println(INFO_REPLICATION_ENABLE_ADMINISTRATOR_MUST_BE_CREATED.get()); |
| | | promptedForAdmin = true; |
| | | adminUid= askForAdministratorUID( |
| | | argParser.getDefaultAdministratorUID()); |
| | | argParser.getDefaultAdministratorUID(), LOG); |
| | | println(); |
| | | } |
| | | uData.setAdminUid(adminUid); |
| | |
| | | if (!cancelled && (uData.getAdminPwd() == null) && !administratorDefined) |
| | | { |
| | | adminPwd = null; |
| | | int nPasswordPrompts = 0; |
| | | while (adminPwd == null) |
| | | { |
| | | if (nPasswordPrompts > CONFIRMATION_MAX_TRIES) |
| | | { |
| | | println(ERR_CONFIRMATION_TRIES_LIMIT_REACHED.get( |
| | | CONFIRMATION_MAX_TRIES)); |
| | | cancelled = true; |
| | | break; |
| | | } |
| | | nPasswordPrompts ++; |
| | | if (!promptedForAdmin) |
| | | { |
| | | println(); |
| | |
| | | } |
| | | while (adminPwd == null) |
| | | { |
| | | adminPwd = askForAdministratorPwd(); |
| | | adminPwd = askForAdministratorPwd(LOG); |
| | | println(); |
| | | } |
| | | String adminPwdConfirm = null; |
| | |
| | | getTrustManager()); |
| | | cache.getFilter().setSearchMonitoringInformation(false); |
| | | cache.getFilter().setSearchBaseDNInformation(false); |
| | | cache.setPreferredConnections(getPreferredConnections(ctx[0])); |
| | | cache.setPreferredConnections( |
| | | PreferredConnection.getPreferredConnections(ctx[0])); |
| | | cache.reloadTopology(); |
| | | |
| | | reloadTopology = false; |
| | |
| | | errorDisplayed = true; |
| | | } |
| | | adminUid = askForAdministratorUID( |
| | | argParser.getDefaultAdministratorUID()); |
| | | argParser.getDefaultAdministratorUID(), LOG); |
| | | println(); |
| | | adminPwd = askForAdministratorPwd(); |
| | | adminPwd = askForAdministratorPwd(LOG); |
| | | println(); |
| | | } |
| | | try |
| | |
| | | cache.getFilter().setSearchMonitoringInformation(false); |
| | | cache.getFilter().setSearchBaseDNInformation(false); |
| | | cache.setPreferredConnections( |
| | | getPreferredConnections(ctx[0])); |
| | | PreferredConnection.getPreferredConnections(ctx[0])); |
| | | connected = true; |
| | | } |
| | | catch (Throwable t) |
| | |
| | | { |
| | | LinkedHashSet<PreferredConnection> cnx = |
| | | new LinkedHashSet<PreferredConnection>(); |
| | | cnx.addAll(getPreferredConnections(ctx1)); |
| | | cnx.addAll(getPreferredConnections(ctx2)); |
| | | cnx.addAll(PreferredConnection.getPreferredConnections(ctx1)); |
| | | cnx.addAll(PreferredConnection.getPreferredConnections(ctx2)); |
| | | if (adsCtx1.hasAdminData()) |
| | | { |
| | | TopologyCache cache = new TopologyCache(adsCtx1, getTrustManager()); |
| | |
| | | { |
| | | LinkedHashSet<PreferredConnection> cnx = |
| | | new LinkedHashSet<PreferredConnection>(); |
| | | cnx.addAll(getPreferredConnections(ctx1)); |
| | | cnx.addAll(getPreferredConnections(ctx2)); |
| | | cnx.addAll(PreferredConnection.getPreferredConnections(ctx1)); |
| | | cnx.addAll(PreferredConnection.getPreferredConnections(ctx2)); |
| | | if (adsCtx1.hasAdminData()) |
| | | { |
| | | cache1 = new TopologyCache(adsCtx1, getTrustManager()); |
| | |
| | | if (adsCtx.hasAdminData() && tryToUpdateRemote) |
| | | { |
| | | cache = new TopologyCache(adsCtx, getTrustManager()); |
| | | cache.setPreferredConnections(getPreferredConnections(ctx)); |
| | | cache.setPreferredConnections( |
| | | PreferredConnection.getPreferredConnections(ctx)); |
| | | cache.getFilter().setSearchMonitoringInformation(false); |
| | | for (String dn : uData.getBaseDNs()) |
| | | { |
| | |
| | | { |
| | | removeReferencesInServer(s, replicationServerHostPort, bindDn, pwd, |
| | | baseDNsToUpdate, disableReplicationServer, |
| | | getPreferredConnections(ctx)); |
| | | PreferredConnection.getPreferredConnections(ctx)); |
| | | } |
| | | |
| | | if (disableReplicationServer) |
| | |
| | | try |
| | | { |
| | | cache = new TopologyCache(adsCtx, getTrustManager()); |
| | | cache.setPreferredConnections(getPreferredConnections(ctx)); |
| | | cache.setPreferredConnections( |
| | | PreferredConnection.getPreferredConnections(ctx)); |
| | | for (String dn : uData.getBaseDNs()) |
| | | { |
| | | cache.getFilter().addBaseDNToSearch(dn); |
| | |
| | | if (!rServers.isEmpty()) |
| | | { |
| | | displayStatus(rServers, uData.isScriptFriendly(), |
| | | getPreferredConnections(ctx)); |
| | | PreferredConnection.getPreferredConnections(ctx)); |
| | | somethingDisplayed = true; |
| | | } |
| | | } |
| | |
| | | { |
| | | printlnProgress(); |
| | | displayStatus(replicas, uData.isScriptFriendly(), |
| | | getPreferredConnections(ctx), cache.getServers(), |
| | | PreferredConnection.getPreferredConnections(ctx), |
| | | cache.getServers(), |
| | | replicasWithNoReplicationServer, serversWithNoReplica); |
| | | somethingDisplayed = true; |
| | | } |
| | |
| | | } |
| | | else if (!areReplicationServersEqual(servers, replicationServers)) |
| | | { |
| | | replicationServers.addAll(servers); |
| | | replicationServer.setReplicationServer( |
| | | mergeReplicationServers(replicationServers, servers)); |
| | | mustCommit = true; |
| | |
| | | } |
| | | |
| | | /** |
| | | * Prompts the user to give the Global Administrator UID. |
| | | * @param defaultValue the default value that will be proposed in the prompt |
| | | * message. |
| | | * @return the Global Administrator UID as provided by the user. |
| | | */ |
| | | private String askForAdministratorUID(String defaultValue) |
| | | { |
| | | String s = defaultValue; |
| | | try |
| | | { |
| | | s = readInput(INFO_ADMINISTRATOR_UID_PROMPT.get(), defaultValue); |
| | | } |
| | | catch (CLIException ce) |
| | | { |
| | | LOG.log(Level.WARNING, "Error reading input: "+ce, ce); |
| | | } |
| | | return s; |
| | | } |
| | | |
| | | /** |
| | | * Prompts the user to give the Global Administrator password. |
| | | * @return the Global Administrator password as provided by the user. |
| | | */ |
| | | private String askForAdministratorPwd() |
| | | { |
| | | String pwd = readPassword(INFO_ADMINISTRATOR_PWD_PROMPT.get(), LOG); |
| | | return pwd; |
| | | } |
| | | |
| | | /** |
| | | * Prints a message to the output with no wrapping if we are not in quiet |
| | | * mode. |
| | | * @param msg the message to be displayed. |
| | |
| | | } |
| | | |
| | | /** |
| | | * Commodity method that generates a list of preferred connection (of just |
| | | * one) with the information on a given InitialLdapContext. |
| | | * @param ctx the connection we retrieve the inforamtion from. |
| | | * @return a list containing the preferred connection object. |
| | | */ |
| | | private LinkedHashSet<PreferredConnection> getPreferredConnections( |
| | | InitialLdapContext ctx) |
| | | { |
| | | PreferredConnection cnx = PreferredConnection.getPreferredConnection(ctx); |
| | | LinkedHashSet<PreferredConnection> returnValue = |
| | | new LinkedHashSet<PreferredConnection>(); |
| | | returnValue.add(cnx); |
| | | return returnValue; |
| | | } |
| | | |
| | | /** |
| | | * Returns the host port representation of the server to be used in progress, |
| | | * status and error messages. It takes into account the fact the host and |
| | | * port provided by the user. |
| | |
| | | { |
| | | cache1 = new TopologyCache(adsContext, getTrustManager()); |
| | | cache1.getFilter().setSearchMonitoringInformation(false); |
| | | cache1.setPreferredConnections(getPreferredConnections(ctx1)); |
| | | cache1.setPreferredConnections( |
| | | PreferredConnection.getPreferredConnections(ctx1)); |
| | | cache1.reloadTopology(); |
| | | } |
| | | } |
| | |
| | | { |
| | | cache2 = new TopologyCache(adsContext, getTrustManager()); |
| | | cache2.getFilter().setSearchMonitoringInformation(false); |
| | | cache2.setPreferredConnections(getPreferredConnections(ctx2)); |
| | | cache2.setPreferredConnections( |
| | | PreferredConnection.getPreferredConnections(ctx2)); |
| | | cache2.reloadTopology(); |
| | | } |
| | | } |
| | |
| | | { |
| | | LinkedHashSet<PreferredConnection> cnx = |
| | | new LinkedHashSet<PreferredConnection>(); |
| | | cnx.addAll(getPreferredConnections(adsCtx1.getDirContext())); |
| | | cnx.addAll(getPreferredConnections(adsCtx2.getDirContext())); |
| | | cnx.addAll(PreferredConnection.getPreferredConnections( |
| | | adsCtx1.getDirContext())); |
| | | cnx.addAll(PreferredConnection.getPreferredConnections( |
| | | adsCtx2.getDirContext())); |
| | | // Check that there are no errors. We do not allow to do the merge with |
| | | // errors. |
| | | TopologyCache cache1 = new TopologyCache(adsCtx1, getTrustManager()); |