| | |
| | | import java.util.zip.DataFormatException; |
| | | |
| | | import org.opends.server.replication.common.ServerState; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.DirectoryException; |
| | | |
| | | /** |
| | | * Message sent by a replication server to a directory server in reply to the |
| | |
| | | { |
| | | private int serverId; |
| | | private String serverURL; |
| | | private String baseDn = null; |
| | | private DN baseDN; |
| | | private int windowSize; |
| | | private ServerState serverState; |
| | | |
| | |
| | | * |
| | | * @param serverId replication server id |
| | | * @param serverURL replication server URL |
| | | * @param baseDn base DN for which the ReplServerStartDSMsg is created. |
| | | * @param baseDN base DN for which the ReplServerStartDSMsg is created. |
| | | * @param windowSize The window size. |
| | | * @param serverState our ServerState for this baseDn. |
| | | * @param serverState our ServerState for this baseDN. |
| | | * @param generationId The generationId for this server. |
| | | * @param sslEncryption Whether to continue using SSL to encrypt messages |
| | | * after the start messages have been exchanged. |
| | |
| | | * @param connectedDSNumber Number of currently connected DS to the |
| | | * replication server. |
| | | */ |
| | | public ReplServerStartDSMsg(int serverId, String serverURL, String baseDn, |
| | | public ReplServerStartDSMsg(int serverId, String serverURL, DN baseDN, |
| | | int windowSize, |
| | | ServerState serverState, |
| | | long generationId, |
| | |
| | | super((short) -1 /* version set when sending */, generationId); |
| | | this.serverId = serverId; |
| | | this.serverURL = serverURL; |
| | | if (baseDn != null) |
| | | this.baseDn = baseDn; |
| | | else |
| | | this.baseDn = null; |
| | | this.baseDN = baseDN; |
| | | this.windowSize = windowSize; |
| | | this.serverState = serverState; |
| | | this.sslEncryption = sslEncryption; |
| | |
| | | try |
| | | { |
| | | /* The ReplServerStartDSMsg payload is stored in the form : |
| | | * <baseDn><serverId><serverURL><windowSize><sslEncryption> |
| | | * <baseDN><serverId><serverURL><windowSize><sslEncryption> |
| | | * <degradedStatusThreshold><weight><connectedDSNumber> |
| | | * <serverState> |
| | | */ |
| | |
| | | * first calculate the length then construct the string |
| | | */ |
| | | int length = getNextLength(in, pos); |
| | | baseDn = new String(in, pos, length, "UTF-8"); |
| | | baseDN = DN.decode(new String(in, pos, length, "UTF-8")); |
| | | pos += length +1; |
| | | |
| | | /* |
| | |
| | | // the ServerState to be the last. This should be changed and we want to |
| | | // have more than one ServerState field. |
| | | serverState = new ServerState(in, pos, in.length - 1); |
| | | } catch (UnsupportedEncodingException e) |
| | | } |
| | | catch (UnsupportedEncodingException e) |
| | | { |
| | | throw new DataFormatException("UTF-8 is not supported by this jvm."); |
| | | } |
| | | catch (DirectoryException e) |
| | | { |
| | | throw new DataFormatException(e.getLocalizedMessage()); |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | * |
| | | * @return the base DN from this ReplServerStartDSMsg. |
| | | */ |
| | | public String getBaseDn() |
| | | public DN getBaseDN() |
| | | { |
| | | return baseDn; |
| | | return baseDN; |
| | | } |
| | | |
| | | /** |
| | |
| | | throws UnsupportedEncodingException |
| | | { |
| | | /* The ReplServerStartDSMsg is stored in the form : |
| | | * <operation type><baseDn><serverId><serverURL><windowSize><sslEncryption> |
| | | * <operation type><baseDN><serverId><serverURL><windowSize><sslEncryption> |
| | | * <degradedStatusThreshold><weight><connectedDSNumber> |
| | | * <serverState> |
| | | */ |
| | | byte[] byteDn = baseDn.getBytes("UTF-8"); |
| | | byte[] byteDn = baseDN.toString().getBytes("UTF-8"); |
| | | byte[] byteServerId = String.valueOf(serverId).getBytes("UTF-8"); |
| | | byte[] byteServerUrl = serverURL.getBytes("UTF-8"); |
| | | byte[] byteServerState = serverState.getBytes(); |
| | |
| | | return "ReplServerStartDSMsg content: " + |
| | | "\nprotocolVersion: " + protocolVersion + |
| | | "\ngenerationId: " + generationId + |
| | | "\nbaseDn: " + baseDn + |
| | | "\nbaseDN: " + baseDN + |
| | | "\ngroupId: " + groupId + |
| | | "\nserverId: " + serverId + |
| | | "\nserverState: " + serverState + |