| | |
| | | |
| | | package org.opends.server.tools.dsreplication; |
| | | |
| | | import static org.opends.admin.ads.ServerDescriptor.getReplicationServer; |
| | | import static org.opends.admin.ads.ServerDescriptor.getServerRepresentation; |
| | | import static org.opends.admin.ads.ServerDescriptor.getSuffixDisplay; |
| | | 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 java.io.BufferedWriter; |
| | | import java.io.File; |
| | |
| | | import java.util.logging.Level; |
| | | import java.util.logging.Logger; |
| | | |
| | | import static org.opends.admin.ads.ServerDescriptor.getReplicationServer; |
| | | import static org.opends.admin.ads.ServerDescriptor.getServerRepresentation; |
| | | import static org.opends.admin.ads.ServerDescriptor.getSuffixDisplay; |
| | | 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 javax.naming.NameAlreadyBoundException; |
| | | import javax.naming.NameNotFoundException; |
| | | import javax.naming.NamingEnumeration; |
| | |
| | | { |
| | | String[] newArgs = new String[args.length + 1]; |
| | | newArgs[0] = subCommand; |
| | | for (int i=0; i<args.length ; i++) |
| | | { |
| | | newArgs[i+1] = args[i]; |
| | | } |
| | | System.arraycopy(args, 0, newArgs, 1, args.length); |
| | | // The server (if requested) has already been initialized. |
| | | return execute(newArgs, false); |
| | | } |
| | |
| | | private ReplicationCliReturnCode purgeHistorical( |
| | | PurgeHistoricalUserData uData) |
| | | { |
| | | ReplicationCliReturnCode returnValue = null; |
| | | ReplicationCliReturnCode returnValue; |
| | | if (uData.isOnline()) |
| | | { |
| | | returnValue = purgeHistoricalRemotely(uData); |
| | |
| | | uData.setBaseDNs(baseDNs); |
| | | printPurgeHistoricalEquivalentIfRequired(uData); |
| | | |
| | | returnValue = SUCCESSFUL; |
| | | try |
| | | { |
| | | returnValue = purgeHistoricalLocallyTask(uData); |
| | |
| | | env.put("RECURSIVE_LOCAL_CALL", "true"); |
| | | try |
| | | { |
| | | ProcessReader outReader = null; |
| | | ProcessReader errReader = null; |
| | | Process process = pb.start(); |
| | | outReader = new ProcessReader(process, getOutputStream(), false); |
| | | errReader = new ProcessReader(process, getErrorStream(), true); |
| | | ProcessReader outReader = |
| | | new ProcessReader(process, getOutputStream(), false); |
| | | ProcessReader errReader = |
| | | new ProcessReader(process, getErrorStream(), true); |
| | | |
| | | outReader.startReading(); |
| | | errReader.startReading(); |
| | |
| | | private ReplicationCliReturnCode purgeHistoricalRemotely( |
| | | PurgeHistoricalUserData uData) |
| | | { |
| | | ReplicationCliReturnCode returnValue = SUCCESSFUL_NOP; |
| | | ReplicationCliReturnCode returnValue; |
| | | InitialLdapContext ctx = null; |
| | | |
| | | // Connect to the provided server |
| | |
| | | uData.setBaseDNs(baseDNs); |
| | | printPurgeHistoricalEquivalentIfRequired(uData); |
| | | |
| | | returnValue = SUCCESSFUL; |
| | | try |
| | | { |
| | | returnValue = purgeHistoricalRemoteTask(ctx, uData); |
| | |
| | | Collection<String> notReplicatedSuffixes, |
| | | boolean interactive) |
| | | { |
| | | if (availableSuffixes.size() == 0) |
| | | if (availableSuffixes.isEmpty()) |
| | | { |
| | | println(); |
| | | println(ERR_NO_SUFFIXES_AVAILABLE_TO_PURGE_HISTORICAL.get()); |
| | |
| | | JNDIDirContextAdaptor.adapt(ctx)); |
| | | RootCfgClient root = mCtx.getRootConfiguration(); |
| | | |
| | | ReplicationSynchronizationProviderCfgClient sync = null; |
| | | sync = (ReplicationSynchronizationProviderCfgClient) |
| | | root.getSynchronizationProvider("Multimaster Synchronization"); |
| | | ReplicationSynchronizationProviderCfgClient sync = |
| | | (ReplicationSynchronizationProviderCfgClient) |
| | | root.getSynchronizationProvider("Multimaster Synchronization"); |
| | | if (sync.hasReplicationServer()) |
| | | { |
| | | ReplicationServerCfgClient replicationServer = |
| | |
| | | private ReplicationCliReturnCode disableReplication( |
| | | DisableReplicationUserData uData) |
| | | { |
| | | ReplicationCliReturnCode returnValue = SUCCESSFUL_NOP; |
| | | ReplicationCliReturnCode returnValue; |
| | | InitialLdapContext ctx = null; |
| | | printProgress( |
| | | formatter.getFormattedWithPoints(INFO_REPLICATION_CONNECTING.get())); |
| | |
| | | private ReplicationCliReturnCode statusReplication( |
| | | StatusReplicationUserData uData) |
| | | { |
| | | ReplicationCliReturnCode returnValue = SUCCESSFUL_NOP; |
| | | ReplicationCliReturnCode returnValue; |
| | | InitialLdapContext ctx = null; |
| | | try |
| | | { |
| | |
| | | private ReplicationCliReturnCode preExternalInitialization( |
| | | PreExternalInitializationUserData uData) |
| | | { |
| | | ReplicationCliReturnCode returnValue = SUCCESSFUL_NOP; |
| | | ReplicationCliReturnCode returnValue; |
| | | InitialLdapContext ctx = null; |
| | | try |
| | | { |
| | |
| | | private ReplicationCliReturnCode postExternalInitialization( |
| | | PostExternalInitializationUserData uData) |
| | | { |
| | | ReplicationCliReturnCode returnValue = SUCCESSFUL_NOP; |
| | | ReplicationCliReturnCode returnValue; |
| | | InitialLdapContext ctx = null; |
| | | try |
| | | { |
| | |
| | | availableSuffixes, alreadyReplicatedSuffixes); |
| | | } |
| | | |
| | | if (availableSuffixes.size() == 0) |
| | | if (availableSuffixes.isEmpty()) |
| | | { |
| | | println(); |
| | | if (!uData.configureReplicationDomain1() && |
| | |
| | | notReplicatedSuffixes.add(dn); |
| | | } |
| | | } |
| | | if (availableSuffixes.size() == 0) |
| | | if (availableSuffixes.isEmpty()) |
| | | { |
| | | if (displayErrors) |
| | | { |
| | |
| | | notReplicatedSuffixes.add(dn); |
| | | } |
| | | } |
| | | if (availableSuffixes.size() == 0) |
| | | if (availableSuffixes.isEmpty()) |
| | | { |
| | | println(); |
| | | if (argParser.isInitializeAllReplicationSubcommand()) |
| | |
| | | TreeSet<String> availableSuffixes = new TreeSet<String>( |
| | | getCommonSuffixes(ctxSource, ctxDestination, |
| | | SuffixRelationType.REPLICATED)); |
| | | if (availableSuffixes.size() == 0) |
| | | if (availableSuffixes.isEmpty()) |
| | | { |
| | | println(); |
| | | println(ERR_NO_SUFFIXES_AVAILABLE_TO_INITIALIZE_REPLICATION.get()); |
| | |
| | | printProgressMessageNoWrap(msg); |
| | | printlnProgress(); |
| | | int length = msg.length(); |
| | | StringBuffer buf = new StringBuffer(); |
| | | StringBuilder buf = new StringBuilder(); |
| | | for (i=0; i<length; i++) |
| | | { |
| | | buf.append("="); |
| | |
| | | printProgressMessageNoWrap(msg); |
| | | printlnProgress(); |
| | | int length = msg.length(); |
| | | StringBuffer buf = new StringBuffer(); |
| | | StringBuilder buf = new StringBuilder(); |
| | | for (i=0; i<length; i++) |
| | | { |
| | | buf.append("="); |
| | |
| | | domains[i] = sync.getReplicationDomain(domainNames[i]); |
| | | } |
| | | ReplicationDomainCfgClient domain = null; |
| | | String domainName = null; |
| | | for (int i=0; i<domains.length && (domain == null); i++) |
| | | { |
| | | if (Utils.areDnsEqual(baseDN, domains[i].getBaseDN().toString())) |
| | | { |
| | | domain = domains[i]; |
| | | domainName = domainNames[i]; |
| | | break; |
| | | } |
| | | } |
| | | boolean mustCommit = false; |
| | |
| | | { |
| | | int domainId = InstallerHelper.getReplicationId(usedReplicationDomainIds); |
| | | usedReplicationDomainIds.add(domainId); |
| | | domainName = InstallerHelper.getDomainName(domainNames, domainId, baseDN); |
| | | String domainName = |
| | | InstallerHelper.getDomainName(domainNames, domainId, baseDN); |
| | | domain = sync.createReplicationDomain( |
| | | ReplicationDomainCfgDefn.getInstance(), domainName, |
| | | new ArrayList<DefaultBehaviorException>()); |
| | |
| | | installer.setProgressMessageFormatter(formatter); |
| | | installer.addProgressUpdateListener(new ProgressUpdateListener() |
| | | { |
| | | @Override |
| | | public void progressUpdate(ProgressUpdateEvent ev) |
| | | { |
| | | Message newLogDetails = ev.getNewLogs(); |
| | |
| | | String lastLogMsg = null; |
| | | long lastTimeMsgDisplayed = -1; |
| | | long lastTimeMsgLogged = -1; |
| | | int totalEntries = 0; |
| | | long totalEntries = 0; |
| | | while (!isOver) |
| | | { |
| | | try |
| | |
| | | "ds-task-processed-entry-count"); |
| | | String sUnprocessed = getFirstValue(sr, |
| | | "ds-task-unprocessed-entry-count"); |
| | | int processed = -1; |
| | | int unprocessed = -1; |
| | | long processed = -1; |
| | | long unprocessed = -1; |
| | | if (sProcessed != null) |
| | | { |
| | | processed = Integer.parseInt(sProcessed); |
| | |
| | | { |
| | | if (processed + unprocessed > 0) |
| | | { |
| | | int perc = (100 * processed) / (processed + unprocessed); |
| | | long perc = (100 * processed) / (processed + unprocessed); |
| | | msg = INFO_INITIALIZE_PROGRESS_WITH_PERCENTAGE.get(sProcessed, |
| | | String.valueOf(perc)); |
| | | } |
| | |
| | | { |
| | | boolean isReplicatedInBoth = false; |
| | | ReplicaDescriptor replica1 = null; |
| | | ReplicaDescriptor replica2 = null; |
| | | ReplicaDescriptor replica2; |
| | | for (ReplicaDescriptor replica : server1.getReplicas()) |
| | | { |
| | | if (Utils.areDnsEqual(replica.getSuffix().getDN(), baseDN)) |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public int compare(ServerDescriptor s1, ServerDescriptor s2) |
| | | { |
| | | int compare = s1.getHostName().compareTo(s2.getHostName()); |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public int compare(SuffixDescriptor s1, SuffixDescriptor s2) |
| | | { |
| | | return s1.getId().compareTo(s2.getId()); |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public int compare(ServerDescriptor s1, ServerDescriptor s2) |
| | | { |
| | | return s1.getId().compareTo(s2.getId()); |