| | |
| | | package org.opends.server.tools.dsreplication; |
| | | |
| | | |
| | | import java.io.BufferedWriter; |
| | | import java.io.File; |
| | | import java.io.FileWriter; |
| | | import java.io.IOException; |
| | | import java.io.InputStream; |
| | | import java.io.OutputStream; |
| | | import java.io.PrintStream; |
| | | import java.util.ArrayList; |
| | | import java.util.Collection; |
| | | import java.util.Collections; |
| | | import java.util.Comparator; |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | | import java.util.HashSet; |
| | | import java.util.LinkedHashMap; |
| | | import java.util.LinkedHashSet; |
| | | import java.util.LinkedList; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Set; |
| | | import java.util.SortedSet; |
| | | import java.util.TreeSet; |
| | | import java.util.logging.Level; |
| | | import java.util.logging.Logger; |
| | | |
| | | import static org.opends.admin.ads.ServerDescriptor.*; |
| | | import static org.opends.messages.AdminToolMessages.*; |
| | | import static org.opends.messages.QuickSetupMessages.*; |
| | | import static org.opends.messages.ToolMessages.*; |
| | | import static org.opends.messages.UtilityMessages.*; |
| | | import static org.opends.quicksetup.util.Utils.*; |
| | | import static org.opends.server.tools.ToolConstants.*; |
| | | import static org.opends.server.tools.dsreplication.ReplicationCliReturnCode.*; |
| | | |
| | | import javax.naming.NameAlreadyBoundException; |
| | | import javax.naming.NameNotFoundException; |
| | | import javax.naming.NamingEnumeration; |
| | | import javax.naming.NamingException; |
| | | import javax.naming.directory.Attribute; |
| | | import javax.naming.directory.BasicAttribute; |
| | | import javax.naming.directory.BasicAttributes; |
| | | import javax.naming.directory.DirContext; |
| | | import javax.naming.directory.SearchControls; |
| | | import javax.naming.directory.SearchResult; |
| | | import javax.naming.ldap.InitialLdapContext; |
| | | import javax.net.ssl.TrustManager; |
| | | |
| | | import org.opends.admin.ads.ADSContext; |
| | | import org.opends.admin.ads.*; |
| | | import org.opends.admin.ads.ADSContext.ADSPropertySyntax; |
| | | import org.opends.admin.ads.ADSContext.AdministratorProperty; |
| | | import org.opends.admin.ads.ADSContext.ServerProperty; |
| | | import org.opends.admin.ads.ADSContextException; |
| | | import org.opends.admin.ads.ReplicaDescriptor; |
| | | import org.opends.admin.ads.ServerDescriptor; |
| | | import org.opends.admin.ads.SuffixDescriptor; |
| | | import org.opends.admin.ads.TopologyCache; |
| | | import org.opends.admin.ads.TopologyCacheException; |
| | | import org.opends.admin.ads.TopologyCacheFilter; |
| | | import org.opends.admin.ads.util.ApplicationTrustManager; |
| | | import org.opends.admin.ads.util.ConnectionUtils; |
| | | import org.opends.admin.ads.util.PreferredConnection; |
| | | import org.opends.admin.ads.util.ServerLoader; |
| | | import org.opends.guitools.controlpanel.datamodel.BackendDescriptor; |
| | | import org.opends.guitools.controlpanel.datamodel.BaseDNDescriptor; |
| | | import org.opends.guitools.controlpanel.util.ConfigFromDirContext; |
| | | import org.opends.guitools.controlpanel.util.ConfigFromFile; |
| | | import org.opends.guitools.controlpanel.util.ControlPanelLog; |
| | | import org.opends.guitools.controlpanel.util.ProcessReader; |
| | | import org.opends.guitools.controlpanel.util.Utilities; |
| | | import org.opends.guitools.controlpanel.util.*; |
| | | import org.opends.messages.Message; |
| | | import org.opends.messages.MessageBuilder; |
| | | import org.opends.quicksetup.ApplicationException; |
| | |
| | | import org.opends.quicksetup.installer.offline.OfflineInstaller; |
| | | import org.opends.quicksetup.util.PlainTextProgressMessageFormatter; |
| | | import org.opends.quicksetup.util.Utils; |
| | | import org.opends.server.admin.AttributeTypePropertyDefinition; |
| | | import org.opends.server.admin.ClassLoaderProvider; |
| | | import org.opends.server.admin.ClassPropertyDefinition; |
| | | import org.opends.server.admin.DefaultBehaviorException; |
| | | import org.opends.server.admin.ManagedObjectNotFoundException; |
| | | import org.opends.server.admin.*; |
| | | import org.opends.server.admin.client.ManagementContext; |
| | | import org.opends.server.admin.client.ldap.JNDIDirContextAdaptor; |
| | | import org.opends.server.admin.client.ldap.LDAPManagementContext; |
| | | import org.opends.server.admin.std.client.*; |
| | | import org.opends.server.admin.std.meta.*; |
| | | import org.opends.server.admin.std.meta.ReplicationDomainCfgDefn; |
| | | import org.opends.server.admin.std.meta.ReplicationServerCfgDefn; |
| | | import org.opends.server.admin.std.meta. |
| | | ReplicationSynchronizationProviderCfgDefn; |
| | | import org.opends.server.config.ConfigException; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.tasks.PurgeConflictsHistoricalTask; |
| | |
| | | import org.opends.server.util.ServerConstants; |
| | | import org.opends.server.util.SetupUtils; |
| | | import org.opends.server.util.StaticUtils; |
| | | import org.opends.server.util.args.Argument; |
| | | import org.opends.server.util.args.ArgumentException; |
| | | import org.opends.server.util.args.BooleanArgument; |
| | | import org.opends.server.util.args.FileBasedArgument; |
| | | import org.opends.server.util.args.IntegerArgument; |
| | | import org.opends.server.util.args.StringArgument; |
| | | import org.opends.server.util.cli.CLIException; |
| | | import org.opends.server.util.cli.CommandBuilder; |
| | | import org.opends.server.util.cli.ConsoleApplication; |
| | | import org.opends.server.util.cli.LDAPConnectionConsoleInteraction; |
| | | import org.opends.server.util.cli.MenuBuilder; |
| | | import org.opends.server.util.cli.MenuResult; |
| | | import org.opends.server.util.cli.PointAdder; |
| | | import org.opends.server.util.args.*; |
| | | import org.opends.server.util.cli.*; |
| | | import org.opends.server.util.table.TabSeparatedTablePrinter; |
| | | import org.opends.server.util.table.TableBuilder; |
| | | import org.opends.server.util.table.TablePrinter; |
| | | import org.opends.server.util.table.TextTablePrinter; |
| | | |
| | | import javax.naming.NameAlreadyBoundException; |
| | | import javax.naming.NameNotFoundException; |
| | | import javax.naming.NamingEnumeration; |
| | | import javax.naming.NamingException; |
| | | import javax.naming.directory.*; |
| | | import javax.naming.ldap.InitialLdapContext; |
| | | import java.io.*; |
| | | import java.util.*; |
| | | import java.util.logging.Level; |
| | | import java.util.logging.Logger; |
| | | |
| | | import static org.opends.admin.ads.ServerDescriptor.*; |
| | | 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.*; |
| | | import static org.opends.server.tools.dsreplication.ReplicationCliReturnCode.*; |
| | | import static org.opends.server.util.StaticUtils.close; |
| | | |
| | | /** |
| | | * This class provides a tool that can be used to enable and disable replication |
| | | * and also to initialize the contents of a replicated suffix with the contents |
| | |
| | | returnValue = ERROR_CONNECTING; |
| | | } |
| | | |
| | | if (ctx != null) |
| | | { |
| | | try |
| | | { |
| | | ctx.close(); |
| | | } |
| | | catch (Throwable t) |
| | | { |
| | | } |
| | | } |
| | | close(ctx); |
| | | return returnValue; |
| | | } |
| | | |
| | |
| | | LOG.log(Level.INFO, "created task entry: "+attrs); |
| | | dirCtx.close(); |
| | | } |
| | | catch (NameAlreadyBoundException x) |
| | | catch (NameAlreadyBoundException ex) |
| | | { |
| | | LOG.log(Level.SEVERE, "Error creating task "+attrs, ex); |
| | | Message msg = ERR_LAUNCHING_PURGE_HISTORICAL.get(); |
| | | ReplicationCliReturnCode code = ERROR_LAUNCHING_PURGE_HISTORICAL; |
| | | throw new ReplicationCliException( |
| | | getThrowableMsg(msg, ex), code, ex); |
| | | } |
| | | catch (NamingException ne) |
| | | { |
| | |
| | | cancelled = true; |
| | | } |
| | | } |
| | | |
| | | if (ctx != null) |
| | | { |
| | | try |
| | | { |
| | | ctx.close(); |
| | | } |
| | | catch (Throwable t) |
| | | { |
| | | } |
| | | } |
| | | |
| | | close(ctx); |
| | | return !cancelled; |
| | | } |
| | | |
| | |
| | | // enableReplication(EnableReplicationUserData) method. Here we have |
| | | // to load the ADS to ask the user to accept the certificates and |
| | | // eventually admin authentication data. |
| | | InitialLdapContext[] aux = new InitialLdapContext[] {ctx1}; |
| | | cancelled = !loadADSAndAcceptCertificates(aux, uData, true); |
| | | ctx1 = aux[0]; |
| | | if (!cancelled) |
| | | { |
| | | InitialLdapContext[] aux = new InitialLdapContext[] {ctx1}; |
| | | cancelled = !loadADSAndAcceptCertificates(aux, uData, true); |
| | | ctx1 = aux[0]; |
| | | } |
| | | if (!cancelled) |
| | | { |
| | | administratorDefined |= hasAdministrator(ctx1); |
| | |
| | | // there are issues with the ADS they will be encountered in the |
| | | // enableReplication(EnableReplicationUserData) method. Here we have |
| | | // to load the ADS to ask the user to accept the certificates. |
| | | InitialLdapContext[] aux = new InitialLdapContext[] {ctx2}; |
| | | cancelled = !loadADSAndAcceptCertificates(aux, uData, false); |
| | | ctx2 = aux[0]; |
| | | if (!cancelled) |
| | | { |
| | | InitialLdapContext[] aux = new InitialLdapContext[] {ctx2}; |
| | | cancelled = !loadADSAndAcceptCertificates(aux, uData, false); |
| | | ctx2 = aux[0]; |
| | | } |
| | | if (!cancelled) |
| | | { |
| | | administratorDefined |= hasAdministrator(ctx2); |
| | |
| | | uData.setBaseDNs(suffixes); |
| | | } |
| | | |
| | | if (ctx1 != null) |
| | | { |
| | | try |
| | | { |
| | | ctx1.close(); |
| | | } |
| | | catch (Throwable t) |
| | | { |
| | | } |
| | | } |
| | | |
| | | if (ctx2 != null) |
| | | { |
| | | try |
| | | { |
| | | ctx2.close(); |
| | | } |
| | | catch (Throwable t) |
| | | { |
| | | } |
| | | } |
| | | |
| | | close(ctx1, ctx2); |
| | | uData.setReplicateSchema(!argParser.noSchemaReplication()); |
| | | |
| | | return !cancelled; |
| | |
| | | println(); |
| | | try |
| | | { |
| | | if (uData.disableAll()) |
| | | if (!uData.disableAll() && |
| | | !uData.getBaseDNs().isEmpty()) |
| | | { |
| | | // Another confirmation is redundant: we already asked the user... |
| | | } |
| | | else |
| | | { |
| | | if (!uData.getBaseDNs().isEmpty()) |
| | | { |
| | | cancelled = !askConfirmation( |
| | | INFO_REPLICATION_CONFIRM_DISABLE_GENERIC.get(), true, |
| | | LOG); |
| | | } |
| | | else |
| | | { |
| | | // Another confirmation for the replication server is redundant. |
| | | } |
| | | cancelled = !askConfirmation( |
| | | INFO_REPLICATION_CONFIRM_DISABLE_GENERIC.get(), true, |
| | | LOG); |
| | | } |
| | | } |
| | | catch (CLIException ce) |
| | |
| | | } |
| | | } |
| | | |
| | | if (ctx != null) |
| | | { |
| | | try |
| | | { |
| | | ctx.close(); |
| | | } |
| | | catch (Throwable t) |
| | | { |
| | | } |
| | | } |
| | | close(ctx); |
| | | |
| | | return !cancelled; |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | if (ctx != null) |
| | | { |
| | | try |
| | | { |
| | | ctx.close(); |
| | | } |
| | | catch (Throwable t) |
| | | { |
| | | } |
| | | } |
| | | |
| | | close(ctx); |
| | | return !cancelled; |
| | | } |
| | | |
| | |
| | | uData.setBaseDNs(suffixes); |
| | | } |
| | | |
| | | if (ctx != null) |
| | | { |
| | | try |
| | | { |
| | | ctx.close(); |
| | | } |
| | | catch (Throwable t) |
| | | { |
| | | } |
| | | } |
| | | |
| | | close(ctx); |
| | | return !cancelled; |
| | | } |
| | | |
| | |
| | | uData.setBaseDNs(suffixes); |
| | | } |
| | | |
| | | if (ctx != null) |
| | | { |
| | | try |
| | | { |
| | | ctx.close(); |
| | | } |
| | | catch (Throwable t) |
| | | { |
| | | } |
| | | } |
| | | |
| | | close(ctx); |
| | | return !cancelled; |
| | | } |
| | | |
| | |
| | | uData.setBaseDNs(suffixes); |
| | | } |
| | | |
| | | if (ctx != null) |
| | | { |
| | | try |
| | | { |
| | | ctx.close(); |
| | | } |
| | | catch (Throwable t) |
| | | { |
| | | } |
| | | } |
| | | |
| | | close(ctx); |
| | | return !cancelled; |
| | | } |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | if (ctxSource != null) |
| | | { |
| | | try |
| | | { |
| | | ctxSource.close(); |
| | | } |
| | | catch (Throwable t) |
| | | { |
| | | } |
| | | } |
| | | |
| | | if (ctxDestination != null) |
| | | { |
| | | try |
| | | { |
| | | ctxDestination.close(); |
| | | } |
| | | catch (Throwable t) |
| | | { |
| | | } |
| | | } |
| | | close(ctxSource, ctxDestination); |
| | | return !cancelled; |
| | | } |
| | | |
| | |
| | | ApplicationTrustManager trust; |
| | | if (isInteractive()) |
| | | { |
| | | TrustManager t = ci.getTrustManager(); |
| | | if (t == null) |
| | | { |
| | | trust = null; |
| | | } |
| | | else if (t instanceof ApplicationTrustManager) |
| | | { |
| | | trust = (ApplicationTrustManager)t; |
| | | } |
| | | else |
| | | { |
| | | trust = new ApplicationTrustManager(ci.getKeyStore()); |
| | | } |
| | | trust = ci.getTrustManager(); |
| | | } |
| | | else |
| | | { |
| | |
| | | adminPwd = askForAdministratorPwd(LOG); |
| | | println(); |
| | | } |
| | | try |
| | | { |
| | | ctx[0].close(); |
| | | } |
| | | catch (Throwable t) |
| | | { |
| | | } |
| | | close(ctx[0]); |
| | | try |
| | | { |
| | | ctx[0] = createAdministrativeContext(host, port, isSSL, |
| | |
| | | if ((time1 != -1) && (time2 != -1)) |
| | | { |
| | | if (Math.abs(time1 - time2) > |
| | | (Installer.WARNING_CLOCK_DIFFERENCE_THRESOLD_MINUTES * 60 * 1000)) |
| | | (Installer.THRESHOLD_CLOCK_DIFFERENCE_WARNING * 60 * 1000)) |
| | | { |
| | | println(INFO_WARNING_SERVERS_CLOCK_DIFFERENCE.get( |
| | | ConnectionUtils.getHostPort(ctx1), |
| | | ConnectionUtils.getHostPort(ctx2), |
| | | String.valueOf( |
| | | Installer.WARNING_CLOCK_DIFFERENCE_THRESOLD_MINUTES))); |
| | | Installer.THRESHOLD_CLOCK_DIFFERENCE_WARNING))); |
| | | } |
| | | } |
| | | printlnProgress(); |
| | |
| | | printlnProgress(); |
| | | } |
| | | |
| | | if (ctx1 != null) |
| | | { |
| | | try |
| | | { |
| | | ctx1.close(); |
| | | } |
| | | catch (Throwable t) |
| | | { |
| | | } |
| | | } |
| | | |
| | | if (ctx2 != null) |
| | | { |
| | | try |
| | | { |
| | | ctx2.close(); |
| | | } |
| | | catch (Throwable t) |
| | | { |
| | | } |
| | | } |
| | | close(ctx1, ctx2); |
| | | return returnValue; |
| | | } |
| | | |
| | |
| | | returnValue = ERROR_CONNECTING; |
| | | } |
| | | |
| | | if (ctx != null) |
| | | { |
| | | try |
| | | { |
| | | ctx.close(); |
| | | } |
| | | catch (Throwable t) |
| | | { |
| | | } |
| | | } |
| | | close(ctx); |
| | | return returnValue; |
| | | } |
| | | |
| | |
| | | returnValue = ERROR_CONNECTING; |
| | | } |
| | | |
| | | if (ctx != null) |
| | | { |
| | | try |
| | | { |
| | | ctx.close(); |
| | | } |
| | | catch (Throwable t) |
| | | { |
| | | } |
| | | } |
| | | close(ctx); |
| | | return returnValue; |
| | | } |
| | | |
| | |
| | | InitializeReplicationUserData uData) |
| | | { |
| | | ReplicationCliReturnCode returnValue = SUCCESSFUL_NOP; |
| | | InitialLdapContext ctxSource = null; |
| | | InitialLdapContext ctxDestination = null; |
| | | |
| | | ctxSource = getAdministrativeContext(uData.getHostNameSource(), |
| | | uData.getPortSource(), useSSL, |
| | | useStartTLS, |
| | | ADSContext.getAdministratorDN(uData.getAdminUid()), |
| | | uData.getAdminPwd(), getConnectTimeout(), getTrustManager()); |
| | | InitialLdapContext ctxSource = getAdministrativeContext( |
| | | uData.getHostNameSource(), |
| | | uData.getPortSource(), useSSL, |
| | | useStartTLS, |
| | | ADSContext.getAdministratorDN(uData.getAdminUid()), |
| | | uData.getAdminPwd(), getConnectTimeout(), getTrustManager()); |
| | | |
| | | ctxDestination = getAdministrativeContext( |
| | | uData.getHostNameDestination(), |
| | | uData.getPortDestination(), useSSL, |
| | | useStartTLS, |
| | | ADSContext.getAdministratorDN(uData.getAdminUid()), |
| | | uData.getAdminPwd(), getConnectTimeout(), getTrustManager()); |
| | | InitialLdapContext ctxDestination = getAdministrativeContext( |
| | | uData.getHostNameDestination(), |
| | | uData.getPortDestination(), useSSL, |
| | | useStartTLS, |
| | | ADSContext.getAdministratorDN(uData.getAdminUid()), |
| | | uData.getAdminPwd(), getConnectTimeout(), getTrustManager()); |
| | | |
| | | if ((ctxSource != null) && (ctxDestination != null)) |
| | | { |
| | |
| | | returnValue = ERROR_CONNECTING; |
| | | } |
| | | |
| | | if (ctxSource != null) |
| | | { |
| | | try |
| | | { |
| | | ctxSource.close(); |
| | | } |
| | | catch (Throwable t) |
| | | { |
| | | } |
| | | } |
| | | |
| | | if (ctxDestination != null) |
| | | { |
| | | try |
| | | { |
| | | ctxDestination.close(); |
| | | } |
| | | catch (Throwable t) |
| | | { |
| | | } |
| | | } |
| | | close(ctxDestination, ctxSource); |
| | | return returnValue; |
| | | } |
| | | |
| | |
| | | { |
| | | returnValue = REPLICATION_CANNOT_BE_INITIALIZED_ON_BASEDN; |
| | | } |
| | | close(ctx); |
| | | } |
| | | else |
| | | { |
| | | returnValue = ERROR_CONNECTING; |
| | | } |
| | | |
| | | if (ctx != null) |
| | | { |
| | | try |
| | | { |
| | | ctx.close(); |
| | | } |
| | | catch (Throwable t) |
| | | { |
| | | } |
| | | } |
| | | |
| | | return returnValue; |
| | | } |
| | | |
| | |
| | | private ReplicationCliReturnCode preExternalInitialization( |
| | | PreExternalInitializationUserData uData) |
| | | { |
| | | ReplicationCliReturnCode returnValue; |
| | | ReplicationCliReturnCode returnValue = ERROR_CONNECTING; |
| | | InitialLdapContext ctx = null; |
| | | try |
| | | { |
| | |
| | | { |
| | | returnValue = REPLICATION_CANNOT_BE_INITIALIZED_ON_BASEDN; |
| | | } |
| | | close(ctx); |
| | | } |
| | | else |
| | | { |
| | | returnValue = ERROR_CONNECTING; |
| | | } |
| | | |
| | | if (ctx != null) |
| | | { |
| | | try |
| | | { |
| | | ctx.close(); |
| | | } |
| | | catch (Throwable t) |
| | | { |
| | | } |
| | | } |
| | | |
| | | return returnValue; |
| | | } |
| | | |
| | |
| | | private ReplicationCliReturnCode postExternalInitialization( |
| | | PostExternalInitializationUserData uData) |
| | | { |
| | | ReplicationCliReturnCode returnValue; |
| | | ReplicationCliReturnCode returnValue = ERROR_CONNECTING; |
| | | InitialLdapContext ctx = null; |
| | | try |
| | | { |
| | |
| | | { |
| | | returnValue = REPLICATION_CANNOT_BE_INITIALIZED_ON_BASEDN; |
| | | } |
| | | close(ctx); |
| | | } |
| | | else |
| | | { |
| | | returnValue = ERROR_CONNECTING; |
| | | } |
| | | |
| | | if (ctx != null) |
| | | { |
| | | try |
| | | { |
| | | ctx.close(); |
| | | } |
| | | catch (Throwable t) |
| | | { |
| | | } |
| | | } |
| | | |
| | | return returnValue; |
| | | } |
| | | |
| | |
| | | } |
| | | hmUsedReplicationDomainIds.put(baseDN, ids); |
| | | } |
| | | for (LinkedHashSet<String> v : hmRepServers.values()) |
| | | for (Set<String> v : hmRepServers.values()) |
| | | { |
| | | allRepServers.addAll(v); |
| | | } |
| | |
| | | |
| | | for (String baseDN : uData.getBaseDNs()) |
| | | { |
| | | LinkedHashSet<String> repServers = hmRepServers.get(baseDN); |
| | | Set<String> repServers = hmRepServers.get(baseDN); |
| | | Set<Integer> usedIds = hmUsedReplicationDomainIds.get(baseDN); |
| | | Set<String> alreadyConfiguredServers = new HashSet<String>(); |
| | | |
| | |
| | | ADSContext adsCtx = new ADSContext(ctx); |
| | | |
| | | boolean somethingDisplayed = false; |
| | | TopologyCache cache = null; |
| | | TopologyCache cache; |
| | | try |
| | | { |
| | | cache = new TopologyCache(adsCtx, getTrustManager(), |
| | |
| | | { |
| | | // Inform the user of the potential errors that we found. |
| | | LinkedHashSet<Message> messages = new LinkedHashSet<Message>(); |
| | | if (cache != null) |
| | | { |
| | | messages.addAll(cache.getErrorMessages()); |
| | | } |
| | | messages.addAll(cache.getErrorMessages()); |
| | | if (!messages.isEmpty()) |
| | | { |
| | | Message msg = |
| | |
| | | } |
| | | } |
| | | |
| | | LinkedList<String> userBaseDNs = uData.getBaseDNs(); |
| | | LinkedList<Set<ReplicaDescriptor>> replicaLists = |
| | | List<String> userBaseDNs = uData.getBaseDNs(); |
| | | List<Set<ReplicaDescriptor>> replicaLists = |
| | | new LinkedList<Set<ReplicaDescriptor>>(); |
| | | |
| | | boolean oneReplicated = false; |
| | |
| | | |
| | | if (!replicaLists.isEmpty()) |
| | | { |
| | | LinkedList<Set<ReplicaDescriptor>> orderedReplicaLists = |
| | | List<Set<ReplicaDescriptor>> orderedReplicaLists = |
| | | new LinkedList<Set<ReplicaDescriptor>>(); |
| | | for (Set<ReplicaDescriptor> replicas : replicaLists) |
| | | { |
| | |
| | | * all the replicas are replicated with each other. |
| | | * Note: the code assumes that all the objects come from the same read of the |
| | | * topology cache. So comparisons in terms of pointers can be made. |
| | | * @param replicas the list of replicas that we are trying to display. |
| | | * @param orderedReplicaLists the list of replicas that we are trying to |
| | | * display. |
| | | * @param scriptFriendly whether to display it on script-friendly mode or not. |
| | | * @param cnx the preferred connections used to connect to the server. |
| | | * @param scriptFriendly wheter to display it on script-friendly mode or not. |
| | | * @param servers all the servers configured in the topology. |
| | | * @param replicasWithNoReplicationServer the set of replicas that will be |
| | | * updated with all the replicas that have no replication server. |
| | |
| | | * no replica. |
| | | */ |
| | | private void displayStatus( |
| | | LinkedList<Set<ReplicaDescriptor>> orderedReplicaLists, |
| | | List<Set<ReplicaDescriptor>> orderedReplicaLists, |
| | | boolean scriptFriendly, LinkedHashSet<PreferredConnection> cnx, |
| | | Set<ServerDescriptor> servers, |
| | | Set<ReplicaDescriptor> replicasWithNoReplicationServer, |
| | |
| | | } |
| | | |
| | | PrintStream out = getOutputStream(); |
| | | TablePrinter printer = null; |
| | | TablePrinter printer; |
| | | |
| | | if (scriptFriendly) |
| | | { |
| | |
| | | * to replicate the baseDN defined in the server described by the |
| | | * ServerDescriptor. |
| | | */ |
| | | private LinkedHashSet<String> getReplicationServers(String baseDN, |
| | | private Set<String> getReplicationServers(String baseDN, |
| | | TopologyCache cache, ServerDescriptor server) |
| | | { |
| | | LinkedHashSet<String> servers = new LinkedHashSet<String>(); |
| | | Set<String> servers = new LinkedHashSet<String>(); |
| | | for (ReplicaDescriptor replica : server.getReplicas()) |
| | | { |
| | | if (Utils.areDnsEqual(replica.getSuffix().getDN(), baseDN)) |
| | |
| | | // If we do: we are dealing with the same replication topology |
| | | // (we must consider the case of disjoint replication topologies |
| | | // replicating the same base DN). |
| | | HashSet<String> copy = new HashSet<String>(s); |
| | | Set<String> copy = new HashSet<String>(s); |
| | | copy.retainAll(servers); |
| | | if (!copy.isEmpty()) |
| | | { |
| | |
| | | /* |
| | | * Configure the replication server. |
| | | */ |
| | | ReplicationServerCfgClient replicationServer = null; |
| | | ReplicationServerCfgClient replicationServer; |
| | | |
| | | boolean mustCommit = false; |
| | | |
| | |
| | | * @throws OpenDsException if there is an error updating the configuration. |
| | | */ |
| | | private void updateReplicationServer(InitialLdapContext ctx, |
| | | LinkedHashSet<String> replicationServers) throws OpenDsException |
| | | Set<String> replicationServers) throws OpenDsException |
| | | { |
| | | printProgress(formatter.getFormattedWithPoints( |
| | | INFO_REPLICATION_ENABLE_UPDATING_REPLICATION_SERVER.get( |
| | |
| | | */ |
| | | private void configureToReplicateBaseDN(InitialLdapContext ctx, |
| | | String baseDN, |
| | | LinkedHashSet<String> replicationServers, |
| | | Set<String> replicationServers, |
| | | Set<Integer> usedReplicationDomainIds) throws OpenDsException |
| | | { |
| | | boolean userSpecifiedAdminBaseDN = false; |
| | | LinkedList<String> l = argParser.getBaseDNs(); |
| | | List<String> l = argParser.getBaseDNs(); |
| | | if (l != null) |
| | | { |
| | | for (String dn : l) |
| | |
| | | * @throws ReplicationCliException if something goes wrong. |
| | | */ |
| | | private void configureToReplicateBaseDN(String baseDN, |
| | | LinkedHashSet<String> repServers, Set<Integer> usedIds, |
| | | Set<String> repServers, Set<Integer> usedIds, |
| | | TopologyCache cache, ServerDescriptor server, |
| | | Set<String> alreadyConfiguredServers, LinkedHashSet<String> allRepServers, |
| | | Set<String> alreadyConfiguredServers, Set<String> allRepServers, |
| | | Set<String> alreadyConfiguredReplicationServers) |
| | | throws ReplicationCliException |
| | | { |
| | |
| | | } |
| | | finally |
| | | { |
| | | if (ctx != null) |
| | | { |
| | | try |
| | | { |
| | | ctx.close(); |
| | | } |
| | | catch (Throwable t) |
| | | { |
| | | } |
| | | } |
| | | close(ctx); |
| | | } |
| | | alreadyConfiguredServers.add(s.getId()); |
| | | alreadyConfiguredReplicationServers.add(s.getId()); |
| | |
| | | * @param pwd the password that must be used to log to the server. |
| | | * @param baseDNs the list of base DNs where we want to remove the references |
| | | * to the provided replication server. |
| | | * @param removeFromReplicationServers if references must be removed from |
| | | * the replication servers. |
| | | * @param preferredURLs the preferred LDAP URLs to be used to connect to the |
| | | * @param updateReplicationServers if references in the replication servers |
| | | * must be updated. |
| | | * @param cnx the preferred LDAP URLs to be used to connect to the |
| | | * server. |
| | | * @throws ReplicationCliException if there is an error updating the |
| | | * configuration. |
| | |
| | | } |
| | | finally |
| | | { |
| | | if (ctx != null) |
| | | { |
| | | try |
| | | { |
| | | ctx.close(); |
| | | } |
| | | catch (Throwable t) |
| | | { |
| | | } |
| | | } |
| | | close(ctx); |
| | | } |
| | | } |
| | | |
| | |
| | | { |
| | | s = c.toString(); |
| | | } |
| | | if (mb.toString().indexOf(s) == -1) |
| | | if (!mb.toString().contains(s)) |
| | | { |
| | | mb.append(Constants.LINE_SEPARATOR); |
| | | mb.append(INFO_REPLICATION_CRITICAL_ERROR_DETAILS.get(s)); |
| | |
| | | { |
| | | String id1 = server1.getSchemaReplicationID(); |
| | | String id2 = server2.getSchemaReplicationID(); |
| | | if (id1 != null) |
| | | { |
| | | mustInitializeSchema = !id1.equals(id2); |
| | | } |
| | | else |
| | | { |
| | | mustInitializeSchema = true; |
| | | } |
| | | mustInitializeSchema = id1 == null || !id1.equals(id2); |
| | | } |
| | | if (mustInitializeSchema) |
| | | { |
| | |
| | | * already registered it unregisters it and registers again (some properties |
| | | * might have changed). |
| | | * @param adsContext the ADS Context to be used. |
| | | * @param server the server to be registered. |
| | | * @param serverProperties the properties of the server to be registered. |
| | | * @throws ADSContextException if an error occurs during the registration or |
| | | * unregistration of the server. |
| | | */ |
| | |
| | | */ |
| | | @Override |
| | | public boolean isInteractive() { |
| | | if (forceNonInteractive) |
| | | { |
| | | return false; |
| | | } |
| | | else |
| | | { |
| | | return argParser.isInteractive(); |
| | | } |
| | | return !forceNonInteractive && argParser.isInteractive(); |
| | | } |
| | | |
| | | /** |
| | |
| | | } |
| | | finally |
| | | { |
| | | if (ctx != null) |
| | | { |
| | | ctx.close(); |
| | | } |
| | | close(ctx); |
| | | } |
| | | } |
| | | } |