Fix OPENDJ-866 Local RS is named differently to remote RS under cn=replication,cn=monitor
* add host:port information to each replication node monitoring entry
* make replication monitor entry naming more consistent
* bump the protocol version in order to support including the remote server URL in DSInfo/TopologyMsg.
| | |
| | | * |
| | | * |
| | | * Copyright 2008-2010 Sun Microsystems, Inc. |
| | | * Portions copyright 2011-2012 ForgeRock AS |
| | | * Portions copyright 2011-2013 ForgeRock AS |
| | | */ |
| | | package org.opends.server.replication.common; |
| | | |
| | |
| | | |
| | | // DS server id |
| | | private int dsId = -1; |
| | | // DS server url |
| | | private String dsUrl; |
| | | // Server id of the RS the DS is connected to |
| | | private int rsId = -1; |
| | | // DS Generation Id |
| | |
| | | * |
| | | * @param dsId |
| | | * The DS id |
| | | * @param dsUrl Url of the DS |
| | | * @param rsId |
| | | * The RS id the DS is connected to |
| | | * @param generationId |
| | |
| | | * @param protocolVersion |
| | | * Protocol version supported by this server. |
| | | */ |
| | | public DSInfo(int dsId, int rsId, long generationId, |
| | | public DSInfo(int dsId, String dsUrl, int rsId, long generationId, |
| | | ServerStatus status, boolean assuredFlag, |
| | | AssuredMode assuredMode, byte safeDataLevel, byte groupId, |
| | | List<String> refUrls, Set<String> eclIncludes, |
| | | Set<String> eclIncludesForDeletes, short protocolVersion) |
| | | { |
| | | this.dsId = dsId; |
| | | this.dsUrl = dsUrl; |
| | | this.rsId = rsId; |
| | | this.generationId = generationId; |
| | | this.status = status; |
| | |
| | | } |
| | | |
| | | /** |
| | | * Get the DS URL. |
| | | * @return the DS URL |
| | | */ |
| | | public String getDsUrl() |
| | | { |
| | | return dsUrl; |
| | | } |
| | | |
| | | /** |
| | | * Get the RS id the DS is connected to. |
| | | * @return the RS id the DS is connected to |
| | | */ |
| | |
| | | StringBuilder sb = new StringBuilder(); |
| | | sb.append("\nDS id: "); |
| | | sb.append(dsId); |
| | | sb.append(" ; DS url: "); |
| | | sb.append(dsUrl); |
| | | sb.append(" ; RS id: "); |
| | | sb.append(rsId); |
| | | sb.append(" ; Generation id: "); |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2009 Sun Microsystems, Inc. |
| | | * Portions copyright 2011 ForgeRock AS |
| | | * Portions copyright 2011-2013 ForgeRock AS |
| | | */ |
| | | package org.opends.server.replication.protocol; |
| | | |
| | |
| | | public abstract boolean isEncrypted(); |
| | | |
| | | /** |
| | | * Retrieve the local URL in the form host:port. |
| | | * |
| | | * @return The local URL. |
| | | */ |
| | | public abstract String getLocalUrl(); |
| | | |
| | | /** |
| | | * Retrieve the IP address of the remote server. |
| | | * |
| | | * @return The IP address of the remote server. |
| | |
| | | public static final short REPLICATION_PROTOCOL_V5 = 5; |
| | | |
| | | /** |
| | | * The constant for the 6th version of the replication protocol. |
| | | * - include DS local URL in the DSInfo of TopologyMsg. |
| | | */ |
| | | public static final short REPLICATION_PROTOCOL_V6 = 6; |
| | | |
| | | /** |
| | | * The replication protocol version used by the instance of RS/DS in this VM. |
| | | */ |
| | | private static short currentVersion = -1; |
| | | |
| | | static |
| | | { |
| | | resetCurrentVersion(); |
| | | } |
| | | private static final short CURRENT_VERSION = REPLICATION_PROTOCOL_V6; |
| | | |
| | | /** |
| | | * Gets the current version of the replication protocol. |
| | |
| | | */ |
| | | public static short getCurrentVersion() |
| | | { |
| | | return currentVersion; |
| | | } |
| | | |
| | | /** |
| | | * For test purpose. |
| | | * @param curVersion The provided current version. |
| | | */ |
| | | public static void setCurrentVersion(short curVersion) |
| | | { |
| | | currentVersion = curVersion; |
| | | } |
| | | |
| | | /** |
| | | * Resets the protocol version to the default value (the latest version). |
| | | * For test purpose. |
| | | */ |
| | | public static void resetCurrentVersion() |
| | | { |
| | | currentVersion = REPLICATION_PROTOCOL_V5; |
| | | return CURRENT_VERSION; |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | public static short minWithCurrent(short version) |
| | | { |
| | | return (version < currentVersion ? version : currentVersion); |
| | | return (version < CURRENT_VERSION ? version : CURRENT_VERSION); |
| | | } |
| | | } |
| | | |
| | |
| | | package org.opends.server.replication.protocol; |
| | | |
| | | import java.io.UnsupportedEncodingException; |
| | | import java.net.InetAddress; |
| | | import java.net.UnknownHostException; |
| | | import java.util.zip.DataFormatException; |
| | | |
| | | import org.opends.server.replication.common.ServerState; |
| | |
| | | * Server after being connected to a replication server for a given |
| | | * replication domain. |
| | | * |
| | | * @param serverURL directory server URL |
| | | * @param maxReceiveDelay The max receive delay for this server. |
| | | * @param maxReceiveQueue The max receive Queue for this server. |
| | | * @param maxSendDelay The max Send Delay from this server. |
| | |
| | | * after the start messages have been exchanged. |
| | | * @param groupId The group id of the DS for this DN |
| | | */ |
| | | public ServerStartECLMsg(int maxReceiveDelay, |
| | | public ServerStartECLMsg(String serverURL, int maxReceiveDelay, |
| | | int maxReceiveQueue, int maxSendDelay, |
| | | int maxSendQueue, int windowSize, |
| | | long heartbeatInterval, |
| | |
| | | { |
| | | super(protocolVersion, generationId); |
| | | |
| | | this.serverURL = serverURL; |
| | | this.maxReceiveDelay = maxReceiveDelay; |
| | | this.maxReceiveQueue = maxReceiveQueue; |
| | | this.maxSendDelay = maxSendDelay; |
| | |
| | | this.sslEncryption = sslEncryption; |
| | | this.serverState = serverState; |
| | | this.groupId = groupId; |
| | | |
| | | try |
| | | { |
| | | /* TODO : find a better way to get the server URL */ |
| | | this.serverURL = InetAddress.getLocalHost().getHostName(); |
| | | } catch (UnknownHostException e) |
| | | { |
| | | this.serverURL = "Unknown host"; |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | package org.opends.server.replication.protocol; |
| | | |
| | | import java.io.UnsupportedEncodingException; |
| | | import java.net.InetAddress; |
| | | import java.net.UnknownHostException; |
| | | import java.util.zip.DataFormatException; |
| | | |
| | | import org.opends.server.replication.common.ServerState; |
| | |
| | | * |
| | | * @param serverId2 The serverId of the server for which the ServerStartMsg |
| | | * is created. |
| | | * @param serverURL directory server URL |
| | | * @param baseDn The base DN. |
| | | * @param windowSize The window size used by this server. |
| | | * @param heartbeatInterval The requested heartbeat interval. |
| | |
| | | * after the start messages have been exchanged. |
| | | * @param groupId The group id of the DS for this DN |
| | | */ |
| | | public ServerStartMsg(int serverId2, String baseDn, int windowSize, |
| | | long heartbeatInterval, |
| | | ServerState serverState, |
| | | short protocolVersion, |
| | | long generationId, |
| | | boolean sslEncryption, |
| | | byte groupId) |
| | | public ServerStartMsg(int serverId2, String serverURL, String baseDn, |
| | | int windowSize, long heartbeatInterval, ServerState serverState, |
| | | short protocolVersion, long generationId, boolean sslEncryption, |
| | | byte groupId) |
| | | { |
| | | super(protocolVersion, generationId); |
| | | |
| | | this.serverId = serverId2; |
| | | this.serverURL = serverURL; |
| | | this.baseDn = baseDn; |
| | | this.maxReceiveDelay = 0; |
| | | this.maxReceiveQueue = 0; |
| | |
| | | this.sslEncryption = sslEncryption; |
| | | this.serverState = serverState; |
| | | this.groupId = groupId; |
| | | |
| | | try |
| | | { |
| | | /* TODO : find a better way to get the server URL */ |
| | | this.serverURL = InetAddress.getLocalHost().getHostName(); |
| | | } catch (UnknownHostException e) |
| | | { |
| | | this.serverURL = "Unknown host"; |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2012 ForgeRock AS |
| | | * Portions Copyright 2011-2013 ForgeRock AS |
| | | */ |
| | | package org.opends.server.replication.protocol; |
| | | |
| | |
| | | private final byte[] rcvLengthBuf = new byte[8]; |
| | | private final String readableRemoteAddress; |
| | | private final String remoteAddress; |
| | | private final String localUrl; |
| | | |
| | | /** |
| | | * The time the last message published to this session. |
| | |
| | | this.output = secureSocket.getOutputStream(); |
| | | this.readableRemoteAddress = plainSocket.getRemoteSocketAddress() |
| | | .toString(); |
| | | this.remoteAddress = plainSocket.getInetAddress() |
| | | .getHostAddress(); |
| | | this.remoteAddress = plainSocket.getInetAddress().getHostAddress(); |
| | | this.localUrl = plainSocket.getLocalAddress().getHostName() + ":" |
| | | + plainSocket.getLocalPort(); |
| | | } |
| | | |
| | | |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public String getLocalUrl() |
| | | { |
| | | return localUrl; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public String getReadableRemoteAddress() |
| | | { |
| | | return readableRemoteAddress; |
| | |
| | | int dsId = Integer.valueOf(serverIdString); |
| | | pos += length + 1; |
| | | |
| | | /* Read DS URL */ |
| | | String dsUrl; |
| | | if (version >= ProtocolVersion.REPLICATION_PROTOCOL_V6) |
| | | { |
| | | length = getNextLength(in, pos); |
| | | dsUrl = new String(in, pos, length, "UTF-8"); |
| | | pos += length + 1; |
| | | } |
| | | else |
| | | { |
| | | dsUrl = ""; |
| | | } |
| | | |
| | | /* Read RS id */ |
| | | length = |
| | | getNextLength(in, pos); |
| | |
| | | |
| | | /* Now create DSInfo and store it in list */ |
| | | |
| | | DSInfo dsInfo = new DSInfo(dsId, rsId, generationId, status, |
| | | DSInfo dsInfo = new DSInfo(dsId, dsUrl, rsId, generationId, status, |
| | | assuredFlag, assuredMode, safeDataLevel, groupId, refUrls, attrs, |
| | | delattrs, protocolVersion); |
| | | dsList.add(dsInfo); |
| | |
| | | String.valueOf(dsInfo.getDsId()).getBytes("UTF-8"); |
| | | oStream.write(byteServerId); |
| | | oStream.write(0); |
| | | if (version >= ProtocolVersion.REPLICATION_PROTOCOL_V6) |
| | | { |
| | | // Put DS URL |
| | | oStream.write(dsInfo.getDsUrl().getBytes("UTF-8")); |
| | | oStream.write(0); |
| | | } |
| | | // Put RS id |
| | | byteServerId = |
| | | String.valueOf(dsInfo.getRsId()).getBytes("UTF-8"); |
| | |
| | | @Override |
| | | public String getMonitorInstanceName() |
| | | { |
| | | String str = serverURL + " " + String.valueOf(serverId); |
| | | |
| | | return "Connected Replica " + str + |
| | | ",cn=" + replicationServerDomain.getMonitorInstanceName(); |
| | | return "Connected directory server DS(" + serverId + ") " + serverURL |
| | | + ",cn=" + replicationServerDomain.getMonitorInstanceName(); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | public DSInfo toDSInfo() |
| | | { |
| | | |
| | | return new DSInfo(serverId, replicationServerId, generationId, |
| | | return new DSInfo(serverId, serverURL, replicationServerId, generationId, |
| | | status, assuredFlag, assuredMode, safeDataLevel, groupId, refUrls, |
| | | eclIncludes, eclIncludesForDeletes, protocolVersion); |
| | | } |
| | |
| | | @Override |
| | | public String getMonitorInstanceName() |
| | | { |
| | | ReplicationServerDomain domain = |
| | | replicationServer.getReplicationServerDomain(baseDn, false); |
| | | |
| | | return "ReplicationServer database " + String.valueOf(serverId) + |
| | | ",cn=" + domain.getMonitorInstanceName(); |
| | | ReplicationServerDomain domain = replicationServer |
| | | .getReplicationServerDomain(baseDn, false); |
| | | return "Changelog for DS(" + serverId + "),cn=" |
| | | + domain.getMonitorInstanceName(); |
| | | } |
| | | |
| | | /** |
| | |
| | | @Override |
| | | public String getMonitorInstanceName() |
| | | { |
| | | return "ReplicationServer DraftCN database "; |
| | | return "Draft Changelog"; |
| | | } |
| | | |
| | | /** |
| | |
| | | |
| | | // Server id of this DS |
| | | private int serverId = -1; |
| | | // Server URL of this DS |
| | | private String serverUrl = null; |
| | | // Generation id of this DS |
| | | private long generationId = -1; |
| | | // Group id of the DS; |
| | |
| | | * @param replicationServerId The serverId of the RS this remote DS is |
| | | * connected to |
| | | * @param serverId The serverId of this remote DS. |
| | | * @param serverUrl The serverUrl of this remote DS. |
| | | * @param generationId The generation id of this remote DS. |
| | | * @param groupId The group id of the remote DS |
| | | * @param status The id of the remote DS |
| | |
| | | * @param protocolVersion The protocol version supported by the remote DS. |
| | | */ |
| | | public LightweightServerHandler(ReplicationServerHandler replServerHandler, |
| | | int replicationServerId, int serverId, long generationId, byte groupId, |
| | | ServerStatus status, List<String> refUrls, boolean assuredFlag, |
| | | AssuredMode assuredMode, byte safeDataLevel, Set<String> eclInclude, |
| | | Set<String> eclIncludeForDeletes, short protocolVersion) |
| | | int replicationServerId, int serverId, String serverUrl, |
| | | long generationId, byte groupId, ServerStatus status, |
| | | List<String> refUrls, boolean assuredFlag, AssuredMode assuredMode, |
| | | byte safeDataLevel, Set<String> eclInclude, |
| | | Set<String> eclIncludeForDeletes, short protocolVersion) |
| | | { |
| | | this.replServerHandler = replServerHandler; |
| | | this.rsDomain = replServerHandler.getDomain(); |
| | | this.replicationServerId = replicationServerId; |
| | | this.serverId = serverId; |
| | | this.serverUrl = serverUrl; |
| | | this.generationId = generationId; |
| | | this.groupId = groupId; |
| | | this.status = status; |
| | |
| | | */ |
| | | public DSInfo toDSInfo() |
| | | { |
| | | return new DSInfo(serverId, replicationServerId, generationId, |
| | | return new DSInfo(serverId, serverUrl, replicationServerId, generationId, |
| | | status, assuredFlag, assuredMode, safeDataLevel, groupId, refUrls, |
| | | eclInclude, eclIncludeForDeletes, protocolVersion); |
| | | } |
| | |
| | | @Override |
| | | public String getMonitorInstanceName() |
| | | { |
| | | String serverURL=""; // FIXME |
| | | String str = serverURL + " " + String.valueOf(serverId); |
| | | return "Undirect Replica " + str + |
| | | ",cn=" + replServerHandler.getMonitorInstanceName(); |
| | | return "Connected directory server DS(" + serverId + ") " + serverUrl |
| | | + ",cn=" + replServerHandler.getMonitorInstanceName(); |
| | | } |
| | | |
| | | /** |
| | |
| | | for (DSInfo dsInfo : dsInfos) |
| | | { |
| | | LightweightServerHandler lsh = new LightweightServerHandler(this, |
| | | serverId, dsInfo.getDsId(), dsInfo.getGenerationId(), |
| | | dsInfo.getGroupId(), dsInfo.getStatus(), dsInfo.getRefUrls(), |
| | | dsInfo.isAssured(), dsInfo.getAssuredMode(), |
| | | dsInfo.getSafeDataLevel(), |
| | | dsInfo.getEclIncludes(), |
| | | dsInfo.getEclIncludesForDeletes(), |
| | | dsInfo.getProtocolVersion()); |
| | | serverId, dsInfo.getDsId(), dsInfo.getDsUrl(), |
| | | dsInfo.getGenerationId(), dsInfo.getGroupId(), dsInfo.getStatus(), |
| | | dsInfo.getRefUrls(), dsInfo.isAssured(), dsInfo.getAssuredMode(), |
| | | dsInfo.getSafeDataLevel(), dsInfo.getEclIncludes(), |
| | | dsInfo.getEclIncludesForDeletes(), dsInfo.getProtocolVersion()); |
| | | lsh.startHandler(); |
| | | remoteDirectoryServers.put(lsh.getServerId(), lsh); |
| | | } |
| | |
| | | @Override |
| | | public String getMonitorInstanceName() |
| | | { |
| | | String str = serverURL + " " + String.valueOf(serverId); |
| | | |
| | | return "Connected Replication Server " + str + |
| | | ",cn=" + replicationServerDomain.getMonitorInstanceName(); |
| | | return "Connected replication server RS(" + serverId + ") " + serverURL |
| | | + ",cn=" + replicationServerDomain.getMonitorInstanceName(); |
| | | } |
| | | |
| | | /** |
| | |
| | | .isSslEncryption(server); |
| | | |
| | | // Send our ServerStartMsg. |
| | | String url = socket.getLocalAddress().getHostName() + ":" |
| | | + socket.getLocalPort(); |
| | | StartMsg serverStartMsg; |
| | | if (!isECL) |
| | | { |
| | | serverStartMsg = new ServerStartMsg(serverId, baseDn, |
| | | serverStartMsg = new ServerStartMsg(serverId, url, baseDn, |
| | | maxRcvWindow, heartbeatInterval, state, |
| | | ProtocolVersion.getCurrentVersion(), |
| | | this.getGenerationID(), isSslEncryption, groupId); |
| | | } |
| | | else |
| | | { |
| | | serverStartMsg = new ServerStartECLMsg(0, 0, 0, 0, |
| | | serverStartMsg = new ServerStartECLMsg(url, 0, 0, 0, 0, |
| | | maxRcvWindow, heartbeatInterval, state, |
| | | ProtocolVersion.getCurrentVersion(), |
| | | this.getGenerationID(), isSslEncryption, groupId); |
| | |
| | | return shutdown; |
| | | } |
| | | |
| | | /** |
| | | * Returns the local address of this replication domain, or the empty string |
| | | * if it is not yet connected. |
| | | * |
| | | * @return The local address. |
| | | */ |
| | | String getLocalUrl() |
| | | { |
| | | final ProtocolSession tmp = session; |
| | | return tmp != null ? tmp.getLocalUrl() : ""; |
| | | } |
| | | |
| | | } |
| | |
| | | } |
| | | |
| | | /** |
| | | * Returns the local address of this replication domain, or the empty string |
| | | * if it is not yet connected. |
| | | * |
| | | * @return The local address. |
| | | */ |
| | | String getLocalUrl() |
| | | { |
| | | final ReplicationBroker tmp = broker; |
| | | return tmp != null ? tmp.getLocalUrl() : ""; |
| | | } |
| | | |
| | | /** |
| | | * Returns the total number of entries to be processed when a total update |
| | | * is in progress. |
| | | * |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2010 Sun Microsystems, Inc. |
| | | * Portions copyright 2013 ForgeRock AS. |
| | | */ |
| | | package org.opends.server.replication.service; |
| | | |
| | |
| | | @Override |
| | | public String getMonitorInstanceName() |
| | | { |
| | | return "Replication Domain " + domain.getServerId() |
| | | + ",cn=" + domain.getServiceID().replace(',', '_').replace('=', '_') |
| | | + ",cn=replication"; |
| | | return "Directory server DS(" + domain.getServerId() + ") " |
| | | + domain.getLocalUrl() + ",cn=" |
| | | + domain.getServiceID().replace(',', '_').replace('=', '_') |
| | | + ",cn=Replication"; |
| | | } |
| | | |
| | | /** |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2012 ForgeRock AS |
| | | * Portions Copyright 2011-2013 ForgeRock AS |
| | | */ |
| | | package org.opends.server.replication; |
| | | |
| | |
| | | protected long getMonitorAttrValue(DN baseDn, String attr) throws Exception |
| | | { |
| | | String monitorFilter = |
| | | "(&(cn=replication Domain*)(domain-name=" + baseDn + "))"; |
| | | "(&(cn=Directory server*)(domain-name=" + baseDn + "))"; |
| | | |
| | | InternalSearchOperation op; |
| | | int count = 0; |
| | |
| | | if (count++>0) |
| | | Thread.sleep(100); |
| | | op = connection.processSearch( |
| | | ByteString.valueOf("cn=monitor"), |
| | | ByteString.valueOf("cn=replication,cn=monitor"), |
| | | SearchScope.WHOLE_SUBTREE, |
| | | LDAPFilter.decode(monitorFilter)); |
| | | } |
| | |
| | | * |
| | | * |
| | | * Copyright 2008-2010 Sun Microsystems, Inc. |
| | | * Portions copyright 2011 ForgeRock AS |
| | | * Portions copyright 2011-2013 ForgeRock AS |
| | | */ |
| | | package org.opends.server.replication.plugin; |
| | | |
| | |
| | | * Find monitoring entry for requested base DN |
| | | */ |
| | | String monitorFilter = |
| | | "(&(cn=replication Domain*)(domain-name=" + baseDn + "))"; |
| | | "(&(cn=Directory server*)(domain-name=" + baseDn + "))"; |
| | | |
| | | InternalSearchOperation op; |
| | | int count = 0; |
| | |
| | | if (count++>0) |
| | | Thread.sleep(100); |
| | | op = connection.processSearch( |
| | | ByteString.valueOf("cn=monitor"), |
| | | ByteString.valueOf("cn=replication,cn=monitor"), |
| | | SearchScope.WHOLE_SUBTREE, |
| | | LDAPFilter.decode(monitorFilter)); |
| | | } |
| | |
| | | * |
| | | * |
| | | * Copyright 2008-2010 Sun Microsystems, Inc. |
| | | * Portions copyright 2011 ForgeRock AS |
| | | * Portions copyright 2011-2013 ForgeRock AS |
| | | */ |
| | | package org.opends.server.replication.plugin; |
| | | |
| | |
| | | urls.add(str); |
| | | } |
| | | |
| | | return new DSInfo(dsId, rsId, TEST_DN_WITH_ROOT_ENTRY_GENID, status, assuredFlag, assMode, |
| | | return new DSInfo(dsId, "dummy:1234", rsId, TEST_DN_WITH_ROOT_ENTRY_GENID, status, assuredFlag, assMode, |
| | | (byte)assuredSdLevel, groupId, urls, eclIncludes, eclIncludes, protocolVersion); |
| | | } |
| | | |
| | |
| | | Set<String> eclInclude = rd.getEclIncludes(); |
| | | Set<String> eclIncludeForDeletes = rd.getEclIncludesForDeletes(); |
| | | short protocolVersion = ProtocolVersion.getCurrentVersion(); |
| | | DSInfo dsInfo = new DSInfo(dsId, rsId, TEST_DN_WITH_ROOT_ENTRY_GENID, status, assuredFlag, assuredMode, |
| | | DSInfo dsInfo = new DSInfo(dsId, "dummy:1234", rsId, TEST_DN_WITH_ROOT_ENTRY_GENID, status, assuredFlag, assuredMode, |
| | | safeDataLevel, groupId, refUrls, eclInclude, eclIncludeForDeletes, protocolVersion); |
| | | dsList.add(dsInfo); |
| | | |
| | |
| | | * |
| | | * |
| | | * Copyright 2009-2010 Sun Microsystems, Inc. |
| | | * Portions copyright 2011-2012 ForgeRock AS |
| | | * Portions copyright 2011-2013 ForgeRock AS |
| | | */ |
| | | |
| | | package org.opends.server.replication.protocol; |
| | |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | import static org.opends.server.replication.protocol.OperationContext.SYNCHROCONTEXT; |
| | | import static org.opends.server.util.StaticUtils.byteToHex; |
| | | import static org.opends.messages.ReplicationMessages.*; |
| | | |
| | | import static org.testng.Assert.assertEquals; |
| | |
| | | */ |
| | | public class ProtocolCompatibilityTest extends ReplicationTestCase { |
| | | |
| | | short REPLICATION_PROTOCOL_VLAST = ProtocolVersion.REPLICATION_PROTOCOL_V5; |
| | | short REPLICATION_PROTOCOL_VLAST = ProtocolVersion.getCurrentVersion(); |
| | | |
| | | /** |
| | | * Set up the environment for performing the tests in this Class. |
| | | * |
| | |
| | | public void setUp() throws Exception |
| | | { |
| | | super.setUp(); |
| | | // Be sure we use the latest protocol version for these tests |
| | | ProtocolVersion.resetCurrentVersion(); |
| | | } |
| | | |
| | | /** |
| | |
| | | public void classCleanUp() throws Exception |
| | | { |
| | | super.classCleanUp(); |
| | | // Do not disturb other tests |
| | | ProtocolVersion.resetCurrentVersion(); |
| | | } |
| | | |
| | | @DataProvider(name="createReplServerStartData") |
| | |
| | | @DataProvider(name = "createOldServerStartData") |
| | | public Object[][] createOldServerStartData() |
| | | { |
| | | return new Object[][] { |
| | | {"140531323438001f6f3d74657374003136006675726f6e0030003000" + |
| | | "300030003130300031303000747275650032363300303030303030303030303030303034" + |
| | | "623031303730303030303030350000", |
| | | 16, "o=test", (byte) 31,} |
| | | }; |
| | | return new Object[][] { { |
| | | "14" |
| | | + byteToHex((byte) ProtocolVersion.getCurrentVersion()) |
| | | + "31323438001f6f3d74657374003136006675726f6e0030003000" |
| | | + "300030003130300031303000747275650032363300303030303030303030303030303034" |
| | | + "623031303730303030303030350000", 16, "o=test", (byte) 31, } }; |
| | | } |
| | | |
| | | @Test(dataProvider = "createOldServerStartData") |
| | |
| | | assertEquals(msg.getServerId(), serverId); |
| | | assertEquals(msg.getBaseDn(), dn); |
| | | assertEquals(msg.getGroupId(), groupId); |
| | | // We use V4 here because these PDU have not changed since 2.0. |
| | | BigInteger bi = new BigInteger(msg.getBytes(ProtocolVersion.REPLICATION_PROTOCOL_V5)); |
| | | BigInteger bi = new BigInteger(msg.getBytes()); |
| | | assertEquals(bi.toString(16), oldPdu); |
| | | } |
| | | |
| | |
| | | urls4.add("ldaps://host:port/dc=foobar1??sub?(sn=Another Entry 1)"); |
| | | urls4.add("ldaps://host:port/dc=foobar2??sub?(sn=Another Entry 2)"); |
| | | |
| | | DSInfo dsInfo1 = new DSInfo(13, 26, (long)154631, ServerStatus.FULL_UPDATE_STATUS, |
| | | DSInfo dsInfo1 = new DSInfo(13, "dsHost1:111", 26, (long)154631, ServerStatus.FULL_UPDATE_STATUS, |
| | | false, AssuredMode.SAFE_DATA_MODE, (byte)12, (byte)132, urls1, new HashSet<String>(), new HashSet<String>(), (short)-1); |
| | | |
| | | DSInfo dsInfo2 = new DSInfo(-436, 493, (long)-227896, ServerStatus.DEGRADED_STATUS, |
| | | DSInfo dsInfo2 = new DSInfo(-436, "dsHost2:222", 493, (long)-227896, ServerStatus.DEGRADED_STATUS, |
| | | true, AssuredMode.SAFE_READ_MODE, (byte)-7, (byte)-265, urls2, new HashSet<String>(), new HashSet<String>(), (short)-1); |
| | | |
| | | DSInfo dsInfo3 = new DSInfo(2436, 591, (long)0, ServerStatus.NORMAL_STATUS, |
| | | DSInfo dsInfo3 = new DSInfo(2436, "dsHost3:333", 591, (long)0, ServerStatus.NORMAL_STATUS, |
| | | false, AssuredMode.SAFE_READ_MODE, (byte)17, (byte)0, urls3, new HashSet<String>(), new HashSet<String>(), (short)-1); |
| | | |
| | | DSInfo dsInfo4 = new DSInfo(415, 146, (long)0, ServerStatus.BAD_GEN_ID_STATUS, |
| | | DSInfo dsInfo4 = new DSInfo(415, "dsHost4:444", 146, (long)0, ServerStatus.BAD_GEN_ID_STATUS, |
| | | true, AssuredMode.SAFE_DATA_MODE, (byte)2, (byte)15, urls4, new HashSet<String>(), new HashSet<String>(), (short)-1); |
| | | |
| | | List<DSInfo> dsList1 = new ArrayList<DSInfo>(); |
| | |
| | | public void setUp() throws Exception |
| | | { |
| | | super.setUp(); |
| | | // Be sure we use the latest protocol version for these tests |
| | | ProtocolVersion.resetCurrentVersion(); |
| | | } |
| | | |
| | | /** |
| | |
| | | ServerState state, long genId, boolean sslEncryption, byte groupId) throws Exception |
| | | { |
| | | ServerStartMsg msg = new ServerStartMsg( |
| | | serverId, baseDN, window, window, state, |
| | | serverId, "localhost:1234", baseDN, window, window, state, |
| | | ProtocolVersion.getCurrentVersion(), genId, sslEncryption, groupId); |
| | | ServerStartMsg newMsg = new ServerStartMsg(msg.getBytes()); |
| | | assertEquals(msg.getServerId(), newMsg.getServerId()); |
| | | assertEquals(msg.getServerURL(), newMsg.getServerURL()); |
| | | assertEquals(msg.getBaseDn(), newMsg.getBaseDn()); |
| | | assertEquals(msg.getWindowSize(), newMsg.getWindowSize()); |
| | | assertEquals(msg.getHeartbeatInterval(), newMsg.getHeartbeatInterval()); |
| | |
| | | a3.add("uid"); |
| | | Set<String> a4 = new HashSet<String>(); |
| | | |
| | | DSInfo dsInfo1 = new DSInfo(13, 26, (long)154631, ServerStatus.FULL_UPDATE_STATUS, |
| | | DSInfo dsInfo1 = new DSInfo(13, "dsHost1:111", 26, (long)154631, ServerStatus.FULL_UPDATE_STATUS, |
| | | false, AssuredMode.SAFE_DATA_MODE, (byte)12, (byte)132, urls1, a1, a1, (short)1); |
| | | |
| | | DSInfo dsInfo2 = new DSInfo(-436, 493, (long)-227896, ServerStatus.DEGRADED_STATUS, |
| | | DSInfo dsInfo2 = new DSInfo(-436, "dsHost2:222", 493, (long)-227896, ServerStatus.DEGRADED_STATUS, |
| | | true, AssuredMode.SAFE_READ_MODE, (byte)-7, (byte)-265, urls2, a2, a2, (short)2); |
| | | |
| | | DSInfo dsInfo3 = new DSInfo(2436, 591, (long)0, ServerStatus.NORMAL_STATUS, |
| | | DSInfo dsInfo3 = new DSInfo(2436, "dsHost3:333", 591, (long)0, ServerStatus.NORMAL_STATUS, |
| | | false, AssuredMode.SAFE_READ_MODE, (byte)17, (byte)0, urls3, a3, a3, (short)3); |
| | | |
| | | DSInfo dsInfo4 = new DSInfo(415, 146, (long)0, ServerStatus.BAD_GEN_ID_STATUS, |
| | | DSInfo dsInfo4 = new DSInfo(415, "dsHost4:444", 146, (long)0, ServerStatus.BAD_GEN_ID_STATUS, |
| | | true, AssuredMode.SAFE_DATA_MODE, (byte)2, (byte)15, urls4, a4, a4, (short)4); |
| | | |
| | | DSInfo dsInfo5 = new DSInfo(452436, 45591, (long)0, ServerStatus.NORMAL_STATUS, |
| | | DSInfo dsInfo5 = new DSInfo(452436, "dsHost5:555", 45591, (long)0, ServerStatus.NORMAL_STATUS, |
| | | false, AssuredMode.SAFE_READ_MODE, (byte)17, (byte)0, urls3, a1, a1, (short)5); |
| | | |
| | | List<DSInfo> dsList1 = new ArrayList<DSInfo>(); |
| | |
| | | ServerState state, long genId, boolean sslEncryption, byte groupId) throws Exception |
| | | { |
| | | ServerStartECLMsg msg = new ServerStartECLMsg( |
| | | window, window, window, window, window, window, state, |
| | | "localhost:1234", window, window, window, window, window, window, state, |
| | | ProtocolVersion.getCurrentVersion(), genId, sslEncryption, groupId); |
| | | ServerStartECLMsg newMsg = new ServerStartECLMsg(msg.getBytes()); |
| | | assertEquals(msg.getServerURL(), newMsg.getServerURL()); |
| | | assertEquals(msg.getMaxReceiveDelay(), newMsg.getMaxReceiveDelay()); |
| | | assertEquals(msg.getMaxReceiveQueue(), newMsg.getMaxReceiveQueue()); |
| | | assertEquals(msg.getMaxSendDelay(), newMsg.getMaxSendDelay()); |
| | |
| | | try |
| | | { |
| | | // send a ServerStartMsg with an empty ServerState. |
| | | String url = socket.getLocalAddress().getCanonicalHostName() + ":" |
| | | + socket.getLocalPort(); |
| | | ServerStartMsg msg = |
| | | new ServerStartMsg( 1723, TEST_ROOT_DN_STRING, |
| | | new ServerStartMsg( 1723, url, TEST_ROOT_DN_STRING, |
| | | WINDOW, 5000, new ServerState(), |
| | | ProtocolVersion.getCurrentVersion(), 0, sslEncryption, (byte)-1); |
| | | session.publish(msg); |
| | |
| | | { |
| | | ByteArrayOutputStream oStream = new ByteArrayOutputStream(); |
| | | ByteArrayOutputStream eStream = new ByteArrayOutputStream(); |
| | | |
| | | |
| | | // test search as anonymous |
| | | String[] args = |
| | | { |