| | |
| | | private static final long serialVersionUID = -8802722277749190740L; |
| | | private final long timeStamp; |
| | | private final int seqnum; |
| | | private final short serverId; |
| | | private final int serverId; |
| | | |
| | | // A String representation of the ChangeNumber suitable for network |
| | | // transmission. |
| | |
| | | timeStamp = Long.parseLong(temp, 16); |
| | | |
| | | temp = str.substring(16, 20); |
| | | serverId = Short.parseShort(temp, 16); |
| | | serverId = Integer.parseInt(temp, 16); |
| | | |
| | | temp = str.substring(20, 28); |
| | | seqnum = Integer.parseInt(temp, 16); |
| | |
| | | * |
| | | * @param time time for the ChangeNumber |
| | | * @param seq sequence number |
| | | * @param id identity of server |
| | | * @param serverId2 identity of server |
| | | */ |
| | | public ChangeNumber(long time, int seq, short id) |
| | | public ChangeNumber(long time, int seq, int serverId2) |
| | | { |
| | | serverId = id; |
| | | serverId = serverId2; |
| | | timeStamp = time; |
| | | seqnum = seq; |
| | | } |
| | |
| | | * Getter for the server ID. |
| | | * @return the server ID |
| | | */ |
| | | public short getServerId() |
| | | public int getServerId() |
| | | { |
| | | return serverId; |
| | | } |
| | |
| | | { |
| | | private long lastTime; |
| | | private int seqnum; |
| | | private short serverId; |
| | | private int serverId; |
| | | |
| | | /** |
| | | * Create a new ChangeNumber Generator. |
| | | * @param id id to use when creating change numbers. |
| | | * @param serverID2 id to use when creating change numbers. |
| | | * @param timestamp time to start with. |
| | | */ |
| | | public ChangeNumberGenerator(short id, long timestamp) |
| | | public ChangeNumberGenerator(int serverID2, long timestamp) |
| | | { |
| | | this.lastTime = timestamp; |
| | | this.serverId = id; |
| | | this.serverId = serverID2; |
| | | this.seqnum = 0; |
| | | } |
| | | |
| | |
| | | * all change numbers generated will be larger than all the |
| | | * changenumbers currently in state. |
| | | */ |
| | | public ChangeNumberGenerator(short id, ServerState state) |
| | | public ChangeNumberGenerator(int id, ServerState state) |
| | | { |
| | | this.lastTime = TimeThread.getTime(); |
| | | for (short stateId : state) |
| | | for (int stateId : state) |
| | | { |
| | | if (this.lastTime < state.getMaxChangeNumber(stateId).getTime()) |
| | | this.lastTime = state.getMaxChangeNumber(stateId).getTime(); |
| | |
| | | |
| | | long rcvdTime = number.getTime(); |
| | | |
| | | short changeServerId = number.getServerId(); |
| | | int changeServerId = number.getServerId(); |
| | | int changeSeqNum = number.getSeqnum(); |
| | | |
| | | /* need to synchronize with NewChangeNumber method so that we |
| | |
| | | */ |
| | | public void adjust(ServerState state) |
| | | { |
| | | for (short localServerId : state) |
| | | for (int localServerId : state) |
| | | { |
| | | adjust(state.getMaxChangeNumber(localServerId)); |
| | | } |
| | |
| | | { |
| | | |
| | | // DS server id |
| | | private short dsId = -1; |
| | | private int dsId = -1; |
| | | // Server id of the RS the DS is connected to |
| | | private short rsId = -1; |
| | | private int rsId = -1; |
| | | // DS Generation Id |
| | | private long generationId = -1; |
| | | // DS Status |
| | |
| | | * @param refUrls DS exported referrals URLs |
| | | * @param eclIncludes The list of entry attributes to include in the ECL. |
| | | */ |
| | | public DSInfo(short dsId, short rsId, long generationId, ServerStatus status, |
| | | public DSInfo(int dsId, int rsId, long generationId, ServerStatus status, |
| | | boolean assuredFlag, AssuredMode assuredMode, byte safeDataLevel, |
| | | byte groupId, List<String> refUrls, Set<String> eclIncludes) |
| | | { |
| | |
| | | * Get the DS id. |
| | | * @return the DS id |
| | | */ |
| | | public short getDsId() |
| | | public int getDsId() |
| | | { |
| | | return dsId; |
| | | } |
| | |
| | | * Get the RS id the DS is connected to. |
| | | * @return the RS id the DS is connected to |
| | | */ |
| | | public short getRsId() |
| | | public int getRsId() |
| | | { |
| | | return rsId; |
| | | } |
| | |
| | | (safeDataLevel == dsInfo.getSafeDataLevel()) && |
| | | (groupId == dsInfo.getGroupId()) && |
| | | (refUrls.equals(dsInfo.getRefUrls())) && |
| | | (eclIncludes.equals(dsInfo.getEclIncludes()))); |
| | | (((eclIncludes == null) && (dsInfo.getEclIncludes() == null)) || |
| | | ((eclIncludes != null) && |
| | | (eclIncludes.equals(dsInfo.getEclIncludes()))))); |
| | | } else |
| | | { |
| | | return false; |
| | |
| | | StringBuffer sb = new StringBuffer(); |
| | | sb.append("DS id: "); |
| | | sb.append(dsId); |
| | | sb.append("\nRS id: "); |
| | | sb.append(" RS id: "); |
| | | sb.append(rsId); |
| | | sb.append("\nGeneration id: "); |
| | | sb.append(" Generation id: "); |
| | | sb.append(generationId); |
| | | sb.append("\nStatus: "); |
| | | sb.append(" Status: "); |
| | | sb.append(status); |
| | | sb.append("\nAssured replication: "); |
| | | sb.append(" Assured replication: "); |
| | | sb.append(assuredFlag); |
| | | sb.append("\nAssured mode: "); |
| | | sb.append(" Assured mode: "); |
| | | sb.append(assuredMode); |
| | | sb.append("\nSafe data level: "); |
| | | sb.append(" Safe data level: "); |
| | | sb.append(safeDataLevel); |
| | | sb.append("\nGroup id: "); |
| | | sb.append(" Group id: "); |
| | | sb.append(groupId); |
| | | sb.append("\nReferral URLs: "); |
| | | sb.append(" Referral URLs: "); |
| | | sb.append(refUrls); |
| | | sb.append("\nECL Include: "); |
| | | sb.append(" ECL Include: "); |
| | | sb.append(eclIncludes); |
| | | return sb.toString(); |
| | | } |
| | |
| | | |
| | | synchronized(this) |
| | | { |
| | | Short serverId = changeNumber.getServerId(); |
| | | int serverId = changeNumber.getServerId(); |
| | | ServerState oldServerState = list.get(serviceId); |
| | | if (oldServerState == null) |
| | | oldServerState = new ServerState(); |
| | |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Copyright 2008-2009 Sun Microsystems, Inc. |
| | | */ |
| | | package org.opends.server.replication.common; |
| | | |
| | |
| | | public class RSInfo |
| | | { |
| | | // Server id of the RS |
| | | private short id = -1; |
| | | private int id = -1; |
| | | // Generation Id of the RS |
| | | private long generationId = -1; |
| | | // Group id of the RS |
| | |
| | | * @param generationId The generation id the RS is using |
| | | * @param groupId RS group id |
| | | */ |
| | | public RSInfo(short id, long generationId, byte groupId) |
| | | public RSInfo(int id, long generationId, byte groupId) |
| | | { |
| | | this.id = id; |
| | | this.generationId = generationId; |
| | |
| | | * Get the RS id. |
| | | * @return the RS id |
| | | */ |
| | | public short getId() |
| | | public int getId() |
| | | { |
| | | return id; |
| | | } |
| | |
| | | StringBuffer sb = new StringBuffer(); |
| | | sb.append("Id: "); |
| | | sb.append(id); |
| | | sb.append("\nGeneration id: "); |
| | | sb.append(" Generation id: "); |
| | | sb.append(generationId); |
| | | sb.append("\nGroup id: "); |
| | | sb.append(" Group id: "); |
| | | sb.append(groupId); |
| | | return sb.toString(); |
| | | } |
| | |
| | | * It is exchanged with the replication servers at connection establishment |
| | | * time. |
| | | */ |
| | | public class ServerState implements Iterable<Short> |
| | | public class ServerState implements Iterable<Integer> |
| | | { |
| | | private HashMap<Short, ChangeNumber> list; |
| | | private HashMap<Integer, ChangeNumber> list; |
| | | private boolean saved = true; |
| | | |
| | | /** |
| | |
| | | */ |
| | | public ServerState() |
| | | { |
| | | list = new HashMap<Short, ChangeNumber>(); |
| | | list = new HashMap<Integer, ChangeNumber>(); |
| | | } |
| | | |
| | | /** |
| | |
| | | { |
| | | try |
| | | { |
| | | list = new HashMap<Short, ChangeNumber>(); |
| | | list = new HashMap<Integer, ChangeNumber>(); |
| | | |
| | | while (endpos > pos) |
| | | { |
| | |
| | | */ |
| | | int length = getNextLength(in, pos); |
| | | String serverIdString = new String(in, pos, length, "UTF-8"); |
| | | short serverId = Short.valueOf(serverIdString); |
| | | int serverId = Integer.valueOf(serverIdString); |
| | | pos += length +1; |
| | | |
| | | /* |
| | |
| | | |
| | | synchronized(list) |
| | | { |
| | | Short id = changeNumber.getServerId(); |
| | | int id = changeNumber.getServerId(); |
| | | ChangeNumber oldCN = list.get(id); |
| | | if (oldCN == null || changeNumber.newer(oldCN)) |
| | | { |
| | |
| | | synchronized (list) |
| | | { |
| | | clear(); |
| | | for (Short id : serverState) { |
| | | for (Integer id : serverState) { |
| | | ChangeNumber maxChangeNumber = serverState.getMaxChangeNumber(id); |
| | | if (this.update(maxChangeNumber)) { |
| | | result = true; |
| | |
| | | |
| | | synchronized (list) |
| | | { |
| | | for (Short key : list.keySet()) |
| | | for (int key : list.keySet()) |
| | | { |
| | | ChangeNumber change = list.get(key); |
| | | Date date = new Date(change.getTime()); |
| | |
| | | |
| | | synchronized (list) |
| | | { |
| | | for (Short id : list.keySet()) |
| | | for (int id : list.keySet()) |
| | | { |
| | | ByteString value = ByteString.valueOf(list.get(id).toString()); |
| | | values.add(value); |
| | |
| | | |
| | | synchronized (list) |
| | | { |
| | | for (Short key : list.keySet()) |
| | | for (int key : list.keySet()) |
| | | { |
| | | ChangeNumber change = list.get(key); |
| | | buffer.append(change.toString()); |
| | |
| | | /** |
| | | * Get the largest ChangeNumber seen for a given LDAP server ID. |
| | | * |
| | | * @param serverId : the server ID |
| | | * @param serverId2 : the server ID |
| | | * @return the largest ChangeNumber seen |
| | | */ |
| | | public ChangeNumber getMaxChangeNumber(short serverId) |
| | | public ChangeNumber getMaxChangeNumber(int serverId2) |
| | | { |
| | | return list.get(serverId); |
| | | return list.get(serverId2); |
| | | } |
| | | |
| | | /** |
| | |
| | | { |
| | | int length = 0; |
| | | List<String> idList = new ArrayList<String>(list.size()); |
| | | for (short id : list.keySet()) |
| | | for (int id : list.keySet()) |
| | | { |
| | | String temp = String.valueOf(id); |
| | | idList.add(temp); |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public Iterator<Short> iterator() |
| | | public Iterator<Integer> iterator() |
| | | { |
| | | return list.keySet().iterator(); |
| | | } |
| | |
| | | ServerState newState = new ServerState(); |
| | | synchronized (list) |
| | | { |
| | | for (Short key : list.keySet()) |
| | | for (Integer key : list.keySet()) |
| | | { |
| | | ChangeNumber change = list.get(key); |
| | | Short id = change.getServerId(); |
| | | Integer id = change.getServerId(); |
| | | newState.list.put(id,change); |
| | | } |
| | | } |
| | |
| | | throw new IllegalArgumentException("Null server state(s)"); |
| | | |
| | | int diff = 0; |
| | | for (Short serverId : ss1.list.keySet()) |
| | | for (Integer serverId : ss1.list.keySet()) |
| | | { |
| | | ChangeNumber cn1 = ss1.list.get(serverId); |
| | | if (cn1 != null) |
| | |
| | | } else { |
| | | // ss2 does not have a change for this server id but ss1, so the |
| | | // server holding ss1 has every changes represented in cn1 in advance |
| | | // compared to server hodling ss2, add this amount |
| | | // compared to server holding ss2, add this amount |
| | | diff += cn1.getSeqnum(); |
| | | } |
| | | } |
| | |
| | | String serverId = token[1].substring(16,20); |
| | | String seqNumber = token[1].substring(20, 28); |
| | | |
| | | if (MultimasterReplication.isLocalServerId(Short.parseShort(serverId, 16))) |
| | | if (MultimasterReplication.isLocalServerId(Integer.parseInt(serverId, 16))) |
| | | return ByteString.valueOf(serverId + timestamp + seqNumber); |
| | | else |
| | | return (ByteString.valueOf("0")); |
| | |
| | | */ |
| | | private final RemotePendingChanges remotePendingChanges; |
| | | |
| | | private final short serverId; |
| | | private final int serverId; |
| | | |
| | | private final DN baseDn; |
| | | |
| | |
| | | throws ConfigException |
| | | { |
| | | super(configuration.getBaseDN().toNormalizedString(), |
| | | (short) configuration.getServerId()); |
| | | configuration.getServerId()); |
| | | |
| | | /** |
| | | * The time in milliseconds between heartbeats from the replication |
| | |
| | | |
| | | // Read the configuration parameters. |
| | | Set<String> replicationServers = configuration.getReplicationServer(); |
| | | serverId = (short) configuration.getServerId(); |
| | | serverId = configuration.getServerId(); |
| | | baseDn = configuration.getBaseDN(); |
| | | int window = configuration.getWindowSize(); |
| | | heartbeatInterval = configuration.getHeartbeatInterval(); |
| | |
| | | { |
| | | case IMPORT_ERROR_MESSAGE_BAD_REMOTE: |
| | | msg = NOTE_ERR_FULL_UPDATE_IMPORT_FRACTIONAL_BAD_REMOTE.get( |
| | | baseDn.toString(), Short.toString(ieContext.getImportSource())); |
| | | baseDn.toString(), Integer.toString(ieContext.getImportSource())); |
| | | break; |
| | | case IMPORT_ERROR_MESSAGE_REMOTE_IS_FRACTIONAL: |
| | | msg = NOTE_ERR_FULL_UPDATE_IMPORT_FRACTIONAL_REMOTE_IS_FRACTIONAL.get( |
| | | baseDn.toString(), Short.toString(ieContext.getImportSource())); |
| | | baseDn.toString(), Integer.toString(ieContext.getImportSource())); |
| | | break; |
| | | } |
| | | ieContext.setException( |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | protected void initializeRemote(short target, short requestorID, |
| | | protected void initializeRemote(int target, int requestorID, |
| | | Task initTask) throws DirectoryException |
| | | { |
| | | if ((target == RoutableMsg.ALL_SERVERS) && fractionalConfig.isFractional()) |
| | | { |
| | | Message msg = NOTE_ERR_FRACTIONAL_FORBIDDEN_FULL_UPDATE_FRACTIONAL.get( |
| | | baseDn.toString(), Short.toString(getServerId())); |
| | | baseDn.toString(), Integer.toString(getServerId())); |
| | | throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM, msg); |
| | | } else |
| | | { |
| | |
| | | { |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | Short serverId = fromChangeNumber.getServerId(); |
| | | Integer serverId = fromChangeNumber.getServerId(); |
| | | |
| | | String maxValueForId = "ffffffffffffffff" + |
| | | String.format("%04x", serverId) + "ffffffff"; |
| | |
| | | * @return The source as a short value |
| | | * @throws DirectoryException if the string is not valid |
| | | */ |
| | | public short decodeSource(String sourceString) |
| | | public int decodeSource(String sourceString) |
| | | throws DirectoryException |
| | | { |
| | | short source = 0; |
| | | int source = 0; |
| | | Throwable cause = null; |
| | | try |
| | | { |
| | | source = Integer.decode(sourceString).shortValue(); |
| | | source = Integer.decode(sourceString); |
| | | if ((source >= -1) && (source != serverId)) |
| | | { |
| | | // TODO Verifies serverID is in the domain |
| | |
| | | * @param serverId The serverID that should be checked. |
| | | * @return true if the serverID is local, false otherwise. |
| | | */ |
| | | public static boolean isLocalServerId(Short serverId) |
| | | public static boolean isLocalServerId(Integer serverId) |
| | | { |
| | | for (LDAPReplicationDomain domain : domains.values()) |
| | | { |
| | |
| | | private final InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | private final ByteString asn1BaseDn; |
| | | private final short serverId; |
| | | private final int serverId; |
| | | |
| | | private final ServerState state; |
| | | |
| | |
| | | * @param baseDn The baseDN for which the ServerState is created |
| | | * @param serverId The serverId |
| | | */ |
| | | public PersistentServerState(DN baseDn, short serverId) |
| | | public PersistentServerState(DN baseDn, int serverId) |
| | | { |
| | | this.baseDn = baseDn; |
| | | this.serverId = serverId; |
| | |
| | | * @param serverId The serverId. |
| | | * @param state The serverState. |
| | | */ |
| | | public PersistentServerState(DN baseDn, short serverId, ServerState state) |
| | | public PersistentServerState(DN baseDn, int serverId, ServerState state) |
| | | { |
| | | this.baseDn = baseDn; |
| | | this.serverId = serverId; |
| | |
| | | Integer replicaId = Integer.parseInt(temp, 16); |
| | | |
| | | // No need to take into account the subSeqNum |
| | | ChangeNumber cn = new ChangeNumber(timeStamp*1000, seqNum, |
| | | replicaId.shortValue()); |
| | | ChangeNumber cn = |
| | | new ChangeNumber(timeStamp*1000, seqNum, replicaId); |
| | | |
| | | this.update(cn); |
| | | } |
| | |
| | | * |
| | | * @return The largest ChangeNumber seen. |
| | | */ |
| | | public ChangeNumber getMaxChangeNumber(short serverID) |
| | | public ChangeNumber getMaxChangeNumber(int serverID) |
| | | { |
| | | return state.getMaxChangeNumber(serverID); |
| | | } |
| | |
| | | // The list of server ids that had errors for the sent matching update |
| | | // (corresponding to change number). Each server id of the list had one of the |
| | | // 3 possible errors (timeout/degraded or admin/replay error) |
| | | private List<Short> failedServers = new ArrayList<Short>(); |
| | | private List<Integer> failedServers = new ArrayList<Integer>(); |
| | | |
| | | /** |
| | | * Creates a new AckMsg from a ChangeNumber (no errors). |
| | |
| | | * @param failedServers The list of failed servers |
| | | */ |
| | | public AckMsg(ChangeNumber changeNumber, boolean hasTimeout, |
| | | boolean hasWrongStatus, boolean hasReplayError, List<Short> failedServers) |
| | | boolean hasWrongStatus, boolean hasReplayError, List<Integer> failedServers) |
| | | { |
| | | this.changeNumber = changeNumber; |
| | | this.hasTimeout = hasTimeout; |
| | |
| | | |
| | | /** |
| | | * Sets the list of failing servers for this message. |
| | | * @param failedServers The list of failing servers for this message. |
| | | * @param idList The list of failing servers for this message. |
| | | */ |
| | | public void setFailedServers(List<Short> failedServers) |
| | | public void setFailedServers(List<Integer> idList) |
| | | { |
| | | this.failedServers = failedServers; |
| | | this.failedServers = idList; |
| | | } |
| | | |
| | | /** |
| | |
| | | { |
| | | length = getNextLength(in, pos); |
| | | String serverIdString = new String(in, pos, length, "UTF-8"); |
| | | Short serverId = Short.valueOf(serverIdString); |
| | | Integer serverId = Integer.valueOf(serverIdString); |
| | | failedServers.add(serverId); |
| | | pos += length + 1; |
| | | } |
| | |
| | | oStream.write((hasReplayError ? (byte) 1 : (byte) 0)); |
| | | |
| | | /* Put the list of server ids */ |
| | | for (Short sid : failedServers) |
| | | for (Integer sid : failedServers) |
| | | { |
| | | byte[] byteServerId = |
| | | String.valueOf(sid.shortValue()).getBytes("UTF-8"); |
| | | byte[] byteServerId = String.valueOf(sid).getBytes("UTF-8"); |
| | | oStream.write(byteServerId); |
| | | oStream.write(0); |
| | | } |
| | |
| | | * Get the list of failed servers. |
| | | * @return the list of failed servers |
| | | */ |
| | | public List<Short> getFailedServers() |
| | | public List<Integer> getFailedServers() |
| | | { |
| | | return failedServers; |
| | | } |
| | |
| | | } |
| | | |
| | | /* encode the header in a byte[] large enough to also contain the mods */ |
| | | byte [] resultByteArray = encodeHeader(MSG_TYPE_ADD, bodyLength); |
| | | byte [] resultByteArray = encodeHeader(MSG_TYPE_ADD, bodyLength, |
| | | ProtocolVersion.REPLICATION_PROTOCOL_V3); |
| | | |
| | | int pos = resultByteArray.length - bodyLength; |
| | | |
| | |
| | | bodyLength += encodedEclIncludes.length + 1; |
| | | |
| | | /* encode the header in a byte[] large enough to also contain the mods */ |
| | | byte [] encodedMsg = encodeHeader(MSG_TYPE_ADD, bodyLength); |
| | | byte [] encodedMsg = encodeHeader(MSG_TYPE_ADD, bodyLength, |
| | | ProtocolVersion.REPLICATION_PROTOCOL_V4); |
| | | |
| | | int pos = encodedMsg.length - bodyLength; |
| | | if (byteParentId != null) |
| | |
| | | */ |
| | | public ChangeTimeHeartbeatMsg() |
| | | { |
| | | this.changeNumber = new ChangeNumber((long)0,0,(short)0); |
| | | this.changeNumber = new ChangeNumber((long)0,0,0); |
| | | } |
| | | |
| | | /** |
| | |
| | | @Override |
| | | public byte[] getBytes_V23() throws UnsupportedEncodingException |
| | | { |
| | | return encodeHeader(MSG_TYPE_DELETE, 0); |
| | | return encodeHeader(MSG_TYPE_DELETE, 0, |
| | | ProtocolVersion.REPLICATION_PROTOCOL_V3); |
| | | } |
| | | |
| | | /** |
| | |
| | | bodyLength += encodedEclIncludes.length + 1; |
| | | |
| | | /* encode the header in a byte[] large enough to also contain the mods */ |
| | | byte [] encodedMsg = encodeHeader(MSG_TYPE_DELETE, bodyLength); |
| | | byte [] encodedMsg = encodeHeader(MSG_TYPE_DELETE, bodyLength, |
| | | ProtocolVersion.REPLICATION_PROTOCOL_V4); |
| | | int pos = encodedMsg.length - bodyLength; |
| | | pos = addByteArray(byteEntryAttrLen, encodedMsg, pos); |
| | | pos = addByteArray(encodedEclIncludes, encodedMsg, pos); |
| | |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Copyright 2006-2009 Sun Microsystems, Inc. |
| | | */ |
| | | package org.opends.server.replication.protocol; |
| | | |
| | |
| | | /** |
| | | * Creates a message. |
| | | * |
| | | * @param sender The sender server of this message. |
| | | * @param destination The server or servers targetted by this message. |
| | | * @param serverID The sender server of this message. |
| | | * @param i The server or servers targetted by this message. |
| | | */ |
| | | public DoneMsg(short sender, short destination) |
| | | public DoneMsg(int serverID, int i) |
| | | { |
| | | super(sender, destination); |
| | | super(serverID, i); |
| | | } |
| | | |
| | | /** |
| | |
| | | // sender |
| | | int length = getNextLength(in, pos); |
| | | String senderString = new String(in, pos, length, "UTF-8"); |
| | | this.senderID = Short.valueOf(senderString); |
| | | this.senderID = Integer.valueOf(senderString); |
| | | pos += length +1; |
| | | |
| | | // destination |
| | | length = getNextLength(in, pos); |
| | | String destinationString = new String(in, pos, length, "UTF-8"); |
| | | this.destination = Short.valueOf(destinationString); |
| | | this.destination = Integer.valueOf(destinationString); |
| | | pos += length +1; |
| | | |
| | | } catch (UnsupportedEncodingException e) |
| | |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Copyright 2006-2009 Sun Microsystems, Inc. |
| | | */ |
| | | package org.opends.server.replication.protocol; |
| | | |
| | |
| | | * @param entryBytes The bytes of the entry. |
| | | */ |
| | | public EntryMsg( |
| | | short sender, |
| | | short destination, |
| | | int sender, |
| | | int destination, |
| | | byte[] entryBytes) |
| | | { |
| | | super(sender, destination); |
| | |
| | | /** |
| | | * Creates a new EntryMsg. |
| | | * |
| | | * @param sender The sender of this message. |
| | | * @param destination The destination of this message. |
| | | * @param serverID The sender of this message. |
| | | * @param i The destination of this message. |
| | | * @param entryBytes The bytes of the entry. |
| | | * @param pos The starting Position in the array. |
| | | * @param length Number of array elements to be copied. |
| | | */ |
| | | public EntryMsg( |
| | | short sender, |
| | | short destination, |
| | | int serverID, |
| | | int i, |
| | | byte[] entryBytes, |
| | | int pos, |
| | | int length) |
| | | { |
| | | super(sender, destination); |
| | | super(serverID, i); |
| | | this.entryByteArray = new byte[length]; |
| | | System.arraycopy(entryBytes, pos, this.entryByteArray, 0, length); |
| | | } |
| | |
| | | // sender |
| | | int length = getNextLength(in, pos); |
| | | String senderIDString = new String(in, pos, length, "UTF-8"); |
| | | this.senderID = Short.valueOf(senderIDString); |
| | | this.senderID = Integer.valueOf(senderIDString); |
| | | pos += length +1; |
| | | |
| | | // destination |
| | | length = getNextLength(in, pos); |
| | | String destinationString = new String(in, pos, length, "UTF-8"); |
| | | this.destination = Short.valueOf(destinationString); |
| | | this.destination = Integer.valueOf(destinationString); |
| | | pos += length +1; |
| | | |
| | | // entry |
| | |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Copyright 2006-2009 Sun Microsystems, Inc. |
| | | */ |
| | | package org.opends.server.replication.protocol; |
| | | import org.opends.messages.Message; |
| | |
| | | * @param destination The destination server or servers of this message. |
| | | * @param details The message containing the details of the error. |
| | | */ |
| | | public ErrorMsg(short sender, short destination, |
| | | public ErrorMsg(int sender, int destination, |
| | | Message details) |
| | | { |
| | | super(sender, destination); |
| | |
| | | /** |
| | | * Creates an ErrorMsg. |
| | | * |
| | | * @param destination replication server id |
| | | * @param i replication server id |
| | | * @param details details of the error |
| | | */ |
| | | public ErrorMsg(short destination, Message details) |
| | | public ErrorMsg(int i, Message details) |
| | | { |
| | | super((short)-2, destination); |
| | | super(-2, i); |
| | | this.msgID = details.getDescriptor().getId(); |
| | | this.details = details; |
| | | |
| | |
| | | // sender |
| | | int length = getNextLength(in, pos); |
| | | String senderString = new String(in, pos, length, "UTF-8"); |
| | | senderID = Short.valueOf(senderString); |
| | | senderID = Integer.valueOf(senderString); |
| | | pos += length +1; |
| | | |
| | | // destination |
| | | length = getNextLength(in, pos); |
| | | String serverIdString = new String(in, pos, length, "UTF-8"); |
| | | destination = Short.valueOf(serverIdString); |
| | | destination = Integer.valueOf(serverIdString); |
| | | pos += length +1; |
| | | |
| | | // MsgID |
| | |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Copyright 2006-2009 Sun Microsystems, Inc. |
| | | */ |
| | | package org.opends.server.replication.protocol; |
| | | |
| | |
| | | * |
| | | * @param baseDn The base DN of the replication domain. |
| | | * @param destination destination of this message |
| | | * @param senderID serverID of the server that will send this message |
| | | * @param serverID serverID of the server that will send this message |
| | | */ |
| | | public InitializeRequestMsg(String baseDn, short senderID, short destination) |
| | | public InitializeRequestMsg(String baseDn, int serverID, int destination) |
| | | { |
| | | super(senderID, destination); |
| | | super(serverID, destination); |
| | | this.baseDn = baseDn; |
| | | } |
| | | |
| | |
| | | // sender |
| | | length = getNextLength(in, pos); |
| | | String sourceServerIdString = new String(in, pos, length, "UTF-8"); |
| | | senderID = Short.valueOf(sourceServerIdString); |
| | | senderID = Integer.valueOf(sourceServerIdString); |
| | | pos += length +1; |
| | | |
| | | // destination |
| | | length = getNextLength(in, pos); |
| | | String destinationServerIdString = new String(in, pos, length, "UTF-8"); |
| | | destination = Short.valueOf(destinationServerIdString); |
| | | destination = Integer.valueOf(destinationServerIdString); |
| | | pos += length +1; |
| | | |
| | | |
| | |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Copyright 2006-2009 Sun Microsystems, Inc. |
| | | */ |
| | | package org.opends.server.replication.protocol; |
| | | |
| | |
| | | // to happen. It allows a server that previously sent an |
| | | // InitializeRequestMessage to know that the current message |
| | | // is related to its own request. |
| | | private short requestorID; |
| | | private int requestorID; |
| | | |
| | | /** |
| | | * Creates a InitializeDestinationMessage. |
| | | * |
| | | * @param baseDN The base DN for which the InitializeMessage is created. |
| | | * @param senderID The serverID of the server that sends this message. |
| | | * @param destination The destination of this message. |
| | | * @param requestorID The server that initiates this export. |
| | | * @param serverID The serverID of the server that sends this message. |
| | | * @param target The destination of this message. |
| | | * @param target2 The server that initiates this export. |
| | | * @param entryCount The count of entries that will be sent. |
| | | */ |
| | | public InitializeTargetMsg(String baseDN, short senderID, |
| | | short destination, short requestorID, long entryCount) |
| | | public InitializeTargetMsg(String baseDN, int serverID, |
| | | int target, int target2, long entryCount) |
| | | { |
| | | super(senderID, destination); |
| | | this.requestorID = requestorID; |
| | | super(serverID, target); |
| | | this.requestorID = target2; |
| | | this.baseDN = baseDN; |
| | | this.entryCount = entryCount; |
| | | } |
| | |
| | | // destination |
| | | int length = getNextLength(in, pos); |
| | | String destinationString = new String(in, pos, length, "UTF-8"); |
| | | this.destination = Short.valueOf(destinationString); |
| | | this.destination = Integer.valueOf(destinationString); |
| | | pos += length +1; |
| | | |
| | | // baseDn |
| | |
| | | // sender |
| | | length = getNextLength(in, pos); |
| | | String senderString = new String(in, pos, length, "UTF-8"); |
| | | senderID = Short.valueOf(senderString); |
| | | senderID = Integer.valueOf(senderString); |
| | | pos += length +1; |
| | | |
| | | // requestor |
| | | length = getNextLength(in, pos); |
| | | String requestorString = new String(in, pos, length, "UTF-8"); |
| | | requestorID = Short.valueOf(requestorString); |
| | | requestorID = Integer.valueOf(requestorString); |
| | | pos += length +1; |
| | | |
| | | // entryCount |
| | |
| | | * @param type the type of UpdateMsg to encode. |
| | | * @param additionalLength additional length needed to encode the remaining |
| | | * part of the UpdateMsg. |
| | | * @param version The ProtocolVersion to use when encoding. |
| | | * @return a byte array containing the common header and enough space to |
| | | * encode the remaining bytes of the UpdateMsg as was specified |
| | | * by the additionalLength. |
| | | * (byte array length = common header length + additionalLength) |
| | | * @throws UnsupportedEncodingException if UTF-8 is not supported. |
| | | */ |
| | | public byte[] encodeHeader(byte type, int additionalLength) |
| | | @Override |
| | | public byte[] encodeHeader(byte type, int additionalLength, short version) |
| | | throws UnsupportedEncodingException |
| | | { |
| | | byte[] byteDn = dn.getBytes("UTF-8"); |
| | |
| | | encodedMsg[0] = type; |
| | | |
| | | /* put the protocol version */ |
| | | encodedMsg[1] = (byte)ProtocolVersion.getCurrentVersion(); |
| | | encodedMsg[1] = (byte) version; |
| | | int pos = 2; |
| | | |
| | | /* Put the ChangeNumber */ |
| | |
| | | length += encodedMods.length + 1; |
| | | |
| | | /* encode the header in a byte[] large enough to also contain mods.. */ |
| | | byte[] encodedMsg = encodeHeader(MSG_TYPE_MODIFYDN, length); |
| | | byte[] encodedMsg = encodeHeader(MSG_TYPE_MODIFYDN, length, |
| | | ProtocolVersion.REPLICATION_PROTOCOL_V3); |
| | | int pos = encodedMsg.length - length; |
| | | |
| | | /* put the new RDN and a terminating 0 */ |
| | |
| | | bodyLength += encodedEclIncludes.length + 1; |
| | | |
| | | /* encode the header in a byte[] large enough to also contain mods.. */ |
| | | byte[] encodedMsg = encodeHeader(MSG_TYPE_MODIFYDN, bodyLength); |
| | | byte[] encodedMsg = encodeHeader(MSG_TYPE_MODIFYDN, bodyLength, |
| | | ProtocolVersion.REPLICATION_PROTOCOL_V4); |
| | | |
| | | int pos = encodedMsg.length - bodyLength; |
| | | |
| | |
| | | // Encoding V2 / V3 |
| | | |
| | | /* encode the header in a byte[] large enough to also contain mods */ |
| | | byte[] encodedMsg = encodeHeader(MSG_TYPE_MODIFY, encodedMods.length + 1); |
| | | byte[] encodedMsg = encodeHeader(MSG_TYPE_MODIFY, encodedMods.length + 1, |
| | | ProtocolVersion.REPLICATION_PROTOCOL_V3); |
| | | |
| | | /* add the mods */ |
| | | int pos = encodedMsg.length - (encodedMods.length + 1); |
| | |
| | | bodyLength += encodedEclIncludes.length + 1; |
| | | |
| | | /* encode the header in a byte[] large enough to also contain the mods */ |
| | | byte [] encodedMsg = encodeHeader(MSG_TYPE_MODIFY, bodyLength); |
| | | byte [] encodedMsg = encodeHeader(MSG_TYPE_MODIFY, bodyLength, |
| | | ProtocolVersion.REPLICATION_PROTOCOL_V4); |
| | | |
| | | int pos = encodedMsg.length - bodyLength; |
| | | pos = addByteArray(byteModsLen, encodedMsg, pos); |
| | |
| | | // This replication server DbState |
| | | ServerState replServerDbState; |
| | | // The data related to the LDAP servers connected to this RS |
| | | HashMap<Short, ServerData> ldapStates = |
| | | new HashMap<Short, ServerData>(); |
| | | HashMap<Integer, ServerData> ldapStates = |
| | | new HashMap<Integer, ServerData>(); |
| | | // The data related to the RS servers connected to this RS |
| | | HashMap<Short, ServerData> rsStates = |
| | | new HashMap<Short, ServerData>(); |
| | | HashMap<Integer, ServerData> rsStates = |
| | | new HashMap<Integer, ServerData>(); |
| | | } |
| | | |
| | | SubTopoMonitorData data = new SubTopoMonitorData(); |
| | |
| | | * @param sender The sender of this message. |
| | | * @param destination The destination of this message. |
| | | */ |
| | | public MonitorMsg(short sender, short destination) |
| | | public MonitorMsg(int sender, int destination) |
| | | { |
| | | super(sender, destination); |
| | | protocolVersion = ProtocolVersion.getCurrentVersion(); |
| | |
| | | * @param destination The destination of this message. |
| | | * @param replicationProtocol The protocol version to use. |
| | | */ |
| | | public MonitorMsg(short sender, short destination, |
| | | public MonitorMsg(int sender, int destination, |
| | | short replicationProtocol) |
| | | { |
| | | super(sender, destination); |
| | |
| | | * of the older missing change. null when none. |
| | | * @param isLDAP Specifies whether the server is a LS or a RS |
| | | */ |
| | | public void setServerState(short serverId, ServerState state, |
| | | public void setServerState(int serverId, ServerState state, |
| | | Long approxFirstMissingDate, boolean isLDAP) |
| | | { |
| | | if (data.ldapStates == null) |
| | | { |
| | | data.ldapStates = new HashMap<Short, ServerData>(); |
| | | data.ldapStates = new HashMap<Integer, ServerData>(); |
| | | } |
| | | if (data.rsStates == null) |
| | | { |
| | | data.rsStates = new HashMap<Short, ServerData>(); |
| | | data.rsStates = new HashMap<Integer, ServerData>(); |
| | | } |
| | | ServerData sd = new ServerData(); |
| | | sd.state = state; |
| | |
| | | * @param serverId The provided serverId. |
| | | * @return The state. |
| | | */ |
| | | public ServerState getLDAPServerState(short serverId) |
| | | public ServerState getLDAPServerState(int serverId) |
| | | { |
| | | return data.ldapStates.get(serverId).state; |
| | | } |
| | |
| | | * @param serverId The provided serverId. |
| | | * @return The state. |
| | | */ |
| | | public ServerState getRSServerState(short serverId) |
| | | public ServerState getRSServerState(int serverId) |
| | | { |
| | | return data.rsStates.get(serverId).state; |
| | | } |
| | |
| | | * @param serverId The provided serverId. |
| | | * @return The approximated state. |
| | | */ |
| | | public Long getLDAPApproxFirstMissingDate(short serverId) |
| | | public Long getLDAPApproxFirstMissingDate(int serverId) |
| | | { |
| | | return data.ldapStates.get(serverId).approxFirstMissingDate; |
| | | } |
| | |
| | | * @param serverId The provided serverId. |
| | | * @return The approximated state. |
| | | */ |
| | | public Long getRSApproxFirstMissingDate(short serverId) |
| | | public Long getRSApproxFirstMissingDate(int serverId) |
| | | { |
| | | return data.rsStates.get(serverId).approxFirstMissingDate; |
| | | } |
| | |
| | | // sender |
| | | int length = getNextLength(in, pos); |
| | | String senderIDString = new String(in, pos, length, "UTF-8"); |
| | | this.senderID = Short.valueOf(senderIDString); |
| | | this.senderID = Integer.valueOf(senderIDString); |
| | | pos += length +1; |
| | | |
| | | // destination |
| | | length = getNextLength(in, pos); |
| | | String destinationString = new String(in, pos, length, "UTF-8"); |
| | | this.destination = Short.valueOf(destinationString); |
| | | this.destination = Integer.valueOf(destinationString); |
| | | pos += length +1; |
| | | |
| | | reader.position(pos); |
| | |
| | | throw new DataFormatException("input is not a valid " + |
| | | this.getClass().getCanonicalName()); |
| | | |
| | | // sender |
| | | this.senderID = reader.getShort(); |
| | | /* |
| | | * V4 and above uses integers for its serverIds while V2 and V3 |
| | | * use shorts. |
| | | */ |
| | | if (version <= ProtocolVersion.REPLICATION_PROTOCOL_V3) |
| | | { |
| | | // sender |
| | | this.senderID = reader.getShort(); |
| | | |
| | | // destination |
| | | this.destination = reader.getShort(); |
| | | // destination |
| | | this.destination = reader.getShort(); |
| | | } |
| | | else |
| | | { |
| | | // sender |
| | | this.senderID = reader.getInt(); |
| | | |
| | | // destination |
| | | this.destination = reader.getInt(); |
| | | } |
| | | } |
| | | |
| | | |
| | |
| | | while(asn1Reader.hasNextElement()) |
| | | { |
| | | ServerState newState = new ServerState(); |
| | | short serverId = 0; |
| | | int serverId = 0; |
| | | Long outime = (long)0; |
| | | boolean isLDAPServer = false; |
| | | |
| | |
| | | /* put the type of the operation */ |
| | | byteBuilder.append(MSG_TYPE_REPL_SERVER_MONITOR); |
| | | |
| | | byteBuilder.append(senderID); |
| | | byteBuilder.append(destination); |
| | | /* |
| | | * V4 and above uses integers for its serverIds while V2 and V3 |
| | | * use shorts. |
| | | */ |
| | | if (protocolVersion >= ProtocolVersion.REPLICATION_PROTOCOL_V4) |
| | | { |
| | | byteBuilder.append(senderID); |
| | | byteBuilder.append(destination); |
| | | } |
| | | else |
| | | { |
| | | byteBuilder.append((short)senderID); |
| | | byteBuilder.append((short)destination); |
| | | } |
| | | } |
| | | |
| | | /* Put the serverStates ... */ |
| | |
| | | writer.writeEndSequence(); |
| | | |
| | | // then the LDAP server datas |
| | | Set<Short> servers = data.ldapStates.keySet(); |
| | | for (Short sid : servers) |
| | | Set<Integer> servers = data.ldapStates.keySet(); |
| | | for (Integer sid : servers) |
| | | { |
| | | ServerState statei = data.ldapStates.get(sid).state; |
| | | Long outime = data.ldapStates.get(sid).approxFirstMissingDate; |
| | |
| | | |
| | | // then the RS server datas |
| | | servers = data.rsStates.keySet(); |
| | | for (Short sid : servers) |
| | | for (Integer sid : servers) |
| | | { |
| | | ServerState statei = data.rsStates.get(sid).state; |
| | | Long outime = data.rsStates.get(sid).approxFirstMissingDate; |
| | |
| | | * Returns an iterator on the serverId of the connected LDAP servers. |
| | | * @return The iterator. |
| | | */ |
| | | public Iterator<Short> ldapIterator() |
| | | public Iterator<Integer> ldapIterator() |
| | | { |
| | | return data.ldapStates.keySet().iterator(); |
| | | } |
| | |
| | | * Returns an iterator on the serverId of the connected RS servers. |
| | | * @return The iterator. |
| | | */ |
| | | public Iterator<Short> rsIterator() |
| | | public Iterator<Integer> rsIterator() |
| | | { |
| | | return data.rsStates.keySet().iterator(); |
| | | } |
| | |
| | | stateS += "]"; |
| | | |
| | | stateS += "\nLDAPStates:["; |
| | | for (Short sid : data.ldapStates.keySet()) |
| | | for (Integer sid : data.ldapStates.keySet()) |
| | | { |
| | | ServerData sd = data.ldapStates.get(sid); |
| | | stateS += |
| | |
| | | } |
| | | |
| | | stateS += "\nRSStates:["; |
| | | for (Short sid : data.rsStates.keySet()) |
| | | for (Integer sid : data.rsStates.keySet()) |
| | | { |
| | | ServerData sd = data.rsStates.get(sid); |
| | | stateS += |
| | |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Copyright 2008-2009 Sun Microsystems, Inc. |
| | | */ |
| | | package org.opends.server.replication.protocol; |
| | | |
| | |
| | | /** |
| | | * Creates a message. |
| | | * |
| | | * @param sender The sender server of this message. |
| | | * @param serverID The sender server of this message. |
| | | * @param destination The server or servers targetted by this message. |
| | | */ |
| | | public MonitorRequestMsg(short sender, short destination) |
| | | public MonitorRequestMsg(int serverID, int destination) |
| | | { |
| | | super(sender, destination); |
| | | super(serverID, destination); |
| | | } |
| | | |
| | | /** |
| | |
| | | // sender |
| | | int length = getNextLength(in, pos); |
| | | String senderString = new String(in, pos, length, "UTF-8"); |
| | | this.senderID = Short.valueOf(senderString); |
| | | this.senderID = Integer.valueOf(senderString); |
| | | pos += length +1; |
| | | |
| | | // destination |
| | | length = getNextLength(in, pos); |
| | | String destinationString = new String(in, pos, length, "UTF-8"); |
| | | this.destination = Short.valueOf(destinationString); |
| | | this.destination = Integer.valueOf(destinationString); |
| | | pos += length +1; |
| | | |
| | | } catch (UnsupportedEncodingException e) |
| | |
| | | */ |
| | | public class ReplServerStartMsg extends StartMsg |
| | | { |
| | | private short serverId; |
| | | private Integer serverId; |
| | | private String serverURL; |
| | | private String baseDn = null; |
| | | private int windowSize; |
| | |
| | | * @param groupId The group id of the RS |
| | | * @param degradedStatusThreshold The degraded status threshold |
| | | */ |
| | | public ReplServerStartMsg(short serverId, String serverURL, String baseDn, |
| | | public ReplServerStartMsg(int serverId, String serverURL, String baseDn, |
| | | int windowSize, |
| | | ServerState serverState, |
| | | short protocolVersion, |
| | |
| | | */ |
| | | length = getNextLength(in, pos); |
| | | String serverIdString = new String(in, pos, length, "UTF-8"); |
| | | serverId = Short.valueOf(serverIdString); |
| | | serverId = Integer.valueOf(serverIdString); |
| | | pos += length +1; |
| | | |
| | | /* |
| | |
| | | * Get the Server Id. |
| | | * @return the server id |
| | | */ |
| | | public short getServerId() |
| | | public int getServerId() |
| | | { |
| | | return this.serverId; |
| | | } |
| | |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Copyright 2006-2009 Sun Microsystems, Inc. |
| | | */ |
| | | package org.opends.server.replication.protocol; |
| | | |
| | |
| | | /** |
| | | * Specifies that no server is identified. |
| | | */ |
| | | public static final short UNKNOWN_SERVER = -1; |
| | | public static final int UNKNOWN_SERVER = -1; |
| | | /** |
| | | * Specifies all servers in the replication domain. |
| | | */ |
| | | public static final short ALL_SERVERS = -2; |
| | | public static final int ALL_SERVERS = -2; |
| | | /** |
| | | * Inside a topology of servers in the same domain, it specifies |
| | | * the server that is the "closest" to the sender. |
| | | */ |
| | | public static final short THE_CLOSEST_SERVER = -3; |
| | | public static final int THE_CLOSEST_SERVER = -3; |
| | | |
| | | /** |
| | | * The destination server or servers of this message. |
| | | */ |
| | | protected short destination = UNKNOWN_SERVER; |
| | | protected int destination = UNKNOWN_SERVER; |
| | | /** |
| | | * The serverID of the server that sends this message. |
| | | */ |
| | | protected short senderID = UNKNOWN_SERVER; |
| | | protected int senderID = UNKNOWN_SERVER; |
| | | |
| | | /** |
| | | * Creates a routable message. |
| | | * @param senderID replication server id |
| | | * @param serverID replication server id |
| | | * @param destination replication server id |
| | | */ |
| | | public RoutableMsg(short senderID, short destination) |
| | | public RoutableMsg(int serverID, int destination) |
| | | { |
| | | this.senderID = senderID; |
| | | this.senderID = serverID; |
| | | this.destination = destination; |
| | | } |
| | | |
| | |
| | | * Get the destination. |
| | | * @return the destination |
| | | */ |
| | | public short getDestination() |
| | | public int getDestination() |
| | | { |
| | | return this.destination; |
| | | } |
| | |
| | | * Get the server ID of the server that sent this message. |
| | | * @return the server id |
| | | */ |
| | | public short getsenderID() |
| | | public int getsenderID() |
| | | { |
| | | return this.senderID; |
| | | } |
| | |
| | | */ |
| | | public class ServerStartMsg extends StartMsg |
| | | { |
| | | private short serverId; // Id of the LDAP server that sent this message |
| | | private int serverId; // Id of the LDAP server that sent this message |
| | | private String serverURL; |
| | | private String baseDn; |
| | | private int maxReceiveQueue; |
| | |
| | | * Server after being connected to a replication server for a given |
| | | * replication domain. |
| | | * |
| | | * @param serverId The serverId of the server for which the ServerStartMsg |
| | | * @param serverId2 The serverId of the server for which the ServerStartMsg |
| | | * is created. |
| | | * @param baseDn The base DN. |
| | | * @param windowSize The window size used by this server. |
| | |
| | | * after the start messages have been exchanged. |
| | | * @param groupId The group id of the DS for this DN |
| | | */ |
| | | public ServerStartMsg(short serverId, String baseDn, int windowSize, |
| | | public ServerStartMsg(int serverId2, String baseDn, int windowSize, |
| | | long heartbeatInterval, |
| | | ServerState serverState, |
| | | short protocolVersion, |
| | |
| | | { |
| | | super(protocolVersion, generationId); |
| | | |
| | | this.serverId = serverId; |
| | | this.serverId = serverId2; |
| | | this.baseDn = baseDn; |
| | | this.maxReceiveDelay = 0; |
| | | this.maxReceiveQueue = 0; |
| | |
| | | */ |
| | | length = getNextLength(in, pos); |
| | | String serverIdString = new String(in, pos, length, "UTF-8"); |
| | | serverId = Short.valueOf(serverIdString); |
| | | serverId = Integer.valueOf(serverIdString); |
| | | pos += length +1; |
| | | |
| | | /* |
| | |
| | | * Get the ServerID from the message. |
| | | * @return the server ID |
| | | */ |
| | | public short getServerId() |
| | | public int getServerId() |
| | | { |
| | | return serverId; |
| | | } |
| | |
| | | crossDomainServerState = ""; |
| | | firstDraftChangeNumber = -1; |
| | | lastDraftChangeNumber = -1; |
| | | changeNumber = new ChangeNumber((short)0,0,(short)0); |
| | | changeNumber = new ChangeNumber(0,0,0); |
| | | isPersistent = NON_PERSISTENT; |
| | | operationId = "-1"; |
| | | excludedServiceIDs = new ArrayList<String>(); |
| | |
| | | private List<RSInfo> rsList = new ArrayList<RSInfo>(); |
| | | |
| | | /** |
| | | * The protocolVersion that should be used when serializing this message. |
| | | */ |
| | | private final short protocolVersion; |
| | | |
| | | /** |
| | | * Creates a new changelogInfo message from its encoded form. |
| | | * |
| | | * @param in The byte array containing the encoded form of the message. |
| | |
| | | */ |
| | | public TopologyMsg(byte[] in, short version) throws DataFormatException |
| | | { |
| | | protocolVersion = ProtocolVersion.getCurrentVersion(); |
| | | decode(in, version); |
| | | } |
| | | |
| | |
| | | * |
| | | * @param dsList The list of currently connected DS servers ID. |
| | | * @param rsList The list of currently connected RS servers ID. |
| | | * @param version The protocol version to use to decode the msg. |
| | | */ |
| | | public TopologyMsg(List<DSInfo> dsList, List<RSInfo> rsList, short version) |
| | | { |
| | | if (dsList != null) // null means no info, let empty list from init time |
| | | this.dsList = dsList; |
| | | if (rsList != null) // null means no info, let empty list from init time |
| | | this.rsList = rsList; |
| | | this.protocolVersion = version; |
| | | } |
| | | |
| | | /** |
| | | * Creates a new message from a list of the currently connected servers. |
| | | * |
| | | * @param dsList The list of currently connected DS servers ID. |
| | | * @param rsList The list of currently connected RS servers ID. |
| | | */ |
| | | public TopologyMsg(List<DSInfo> dsList, List<RSInfo> rsList) |
| | | { |
| | |
| | | this.dsList = dsList; |
| | | if (rsList != null) // null means no info, let empty list from init time |
| | | this.rsList = rsList; |
| | | this.protocolVersion = ProtocolVersion.getCurrentVersion(); |
| | | } |
| | | |
| | | // ============ |
| | |
| | | public byte[] getBytes() |
| | | throws UnsupportedEncodingException |
| | | { |
| | | return getBytes(ProtocolVersion.getCurrentVersion()); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public byte[] getBytes(short version) |
| | | throws UnsupportedEncodingException |
| | | { |
| | | try |
| | | { |
| | | /** |
| | |
| | | oStream.write(0); |
| | | } |
| | | |
| | | if (protocolVersion >= ProtocolVersion.REPLICATION_PROTOCOL_V4) |
| | | if (version >= ProtocolVersion.REPLICATION_PROTOCOL_V4) |
| | | { |
| | | Set<String> attrs = dsInfo.getEclIncludes(); |
| | | oStream.write(attrs.size()); |
| | |
| | | /* Read DS id */ |
| | | int length = getNextLength(in, pos); |
| | | String serverIdString = new String(in, pos, length, "UTF-8"); |
| | | short dsId = Short.valueOf(serverIdString); |
| | | int dsId = Integer.valueOf(serverIdString); |
| | | pos += |
| | | length + 1; |
| | | |
| | |
| | | getNextLength(in, pos); |
| | | serverIdString = |
| | | new String(in, pos, length, "UTF-8"); |
| | | short rsId = Short.valueOf(serverIdString); |
| | | int rsId = Integer.valueOf(serverIdString); |
| | | pos += |
| | | length + 1; |
| | | |
| | |
| | | /* Read RS id */ |
| | | int length = getNextLength(in, pos); |
| | | String serverIdString = new String(in, pos, length, "UTF-8"); |
| | | short id = Short.valueOf(serverIdString); |
| | | int id = Integer.valueOf(serverIdString); |
| | | pos += |
| | | length + 1; |
| | | |
| | |
| | | * @param type the type of UpdateMsg to encode. |
| | | * @param additionalLength additional length needed to encode the remaining |
| | | * part of the UpdateMsg. |
| | | * @param version The ProtocolVersion to use when encoding. |
| | | * @return a byte array containing the common header and enough space to |
| | | * encode the remaining bytes of the UpdateMsg as was specified |
| | | * by the additionalLength. |
| | | * (byte array length = common header length + additionalLength) |
| | | * @throws UnsupportedEncodingException if UTF-8 is not supported. |
| | | */ |
| | | protected byte[] encodeHeader(byte type, int additionalLength) |
| | | protected byte[] encodeHeader(byte type, int additionalLength, short version) |
| | | throws UnsupportedEncodingException |
| | | { |
| | | byte[] changeNumberByte = |
| | |
| | | { |
| | | /* Encode the header in a byte[] large enough to also contain the payload */ |
| | | byte [] resultByteArray = |
| | | encodeHeader(MSG_TYPE_GENERIC_UPDATE, payload.length); |
| | | encodeHeader(MSG_TYPE_GENERIC_UPDATE, payload.length, |
| | | ProtocolVersion.getCurrentVersion()); |
| | | |
| | | int pos = resultByteArray.length - payload.length; |
| | | |
| | |
| | | ProtocolSession session, |
| | | int queueSize, |
| | | String replicationServerURL, |
| | | short replicationServerId, |
| | | int replicationServerId, |
| | | ReplicationServer replicationServer, |
| | | int rcvWindowSize) |
| | | { |
| | |
| | | // Prevent useless error message (full update status cannot lead to bad |
| | | // gen status) |
| | | Message message = NOTE_BAD_GEN_ID_IN_FULL_UPDATE.get( |
| | | Short.toString(replicationServerDomain. |
| | | Integer.toString(replicationServerDomain. |
| | | getReplicationServer().getServerId()), |
| | | getServiceId().toString(), |
| | | Short.toString(serverId), |
| | | Integer.toString(serverId), |
| | | Long.toString(generationId), |
| | | Long.toString(newGenId)); |
| | | logError(message); |
| | |
| | | if (newStatus == ServerStatus.INVALID_STATUS) |
| | | { |
| | | Message msg = ERR_RS_CANNOT_CHANGE_STATUS.get(getServiceId().toString(), |
| | | Short.toString(serverId), status.toString(), event.toString()); |
| | | Integer.toString(serverId), status.toString(), event.toString()); |
| | | logError(msg); |
| | | return; |
| | | } |
| | |
| | | if (newStatus == ServerStatus.INVALID_STATUS) |
| | | { |
| | | Message msg = ERR_RS_CANNOT_CHANGE_STATUS.get(getServiceId().toString(), |
| | | Short.toString(serverId), status.toString(), event.toString()); |
| | | Integer.toString(serverId), status.toString(), event.toString()); |
| | | logError(msg); |
| | | // Status analyzer must only change from NORMAL_STATUS to DEGRADED_STATUS |
| | | // and vice versa. We may are being trying to change the status while for |
| | |
| | | if (event == StatusMachineEvent.INVALID_EVENT) |
| | | { |
| | | Message msg = ERR_RS_INVALID_NEW_STATUS.get(reqStatus.toString(), |
| | | getServiceId().toString(), Short.toString(serverId)); |
| | | getServiceId().toString(), Integer.toString(serverId)); |
| | | logError(msg); |
| | | return ServerStatus.INVALID_STATUS; |
| | | } |
| | |
| | | if (newStatus == ServerStatus.INVALID_STATUS) |
| | | { |
| | | Message msg = ERR_RS_CANNOT_CHANGE_STATUS.get(getServiceId().toString(), |
| | | Short.toString(serverId), status.toString(), event.toString()); |
| | | Integer.toString(serverId), status.toString(), event.toString()); |
| | | logError(msg); |
| | | return ServerStatus.INVALID_STATUS; |
| | | } |
| | |
| | | public void registerIntoDomain() |
| | | { |
| | | // All-right, connected with new DS: store handler. |
| | | Map<Short, DataServerHandler> connectedDSs = |
| | | Map<Integer, DataServerHandler> connectedDSs = |
| | | replicationServerDomain.getConnectedDSs(); |
| | | connectedDSs.put(serverId, this); |
| | | |
| | |
| | | Message message = ERR_RS_INVALID_INIT_STATUS.get( |
| | | this.status.toString(), |
| | | getServiceId().toString(), |
| | | Short.toString(serverId)); |
| | | Integer.toString(serverId)); |
| | | throw new DirectoryException(ResultCode.OTHER, message); |
| | | } |
| | | this.refUrls = startSessionMsg.getReferralsURLs(); |
| | |
| | | { |
| | | Message message = NOTE_BAD_GENERATION_ID_FROM_DS.get( |
| | | getServiceId(), |
| | | Short.toString(serverId), |
| | | Integer.toString(serverId), |
| | | Long.toString(generationId), |
| | | Long.toString(localGenerationId)); |
| | | logError(message); |
| | |
| | | // it is not expected to connect to an empty RS |
| | | Message message = NOTE_BAD_GENERATION_ID_FROM_DS.get( |
| | | getServiceId(), |
| | | Short.toString(serverId), |
| | | Integer.toString(serverId), |
| | | Long.toString(generationId), |
| | | Long.toString(localGenerationId)); |
| | | logError(message); |
| | |
| | | private ReplicationDB db; |
| | | private ChangeNumber firstChange = null; |
| | | private ChangeNumber lastChange = null; |
| | | private short serverId; |
| | | private int serverId; |
| | | private String baseDn; |
| | | private DbMonitorProvider dbMonitor = new DbMonitorProvider(); |
| | | private boolean shutdown = false; |
| | |
| | | * @throws DatabaseException If a database problem happened |
| | | */ |
| | | public DbHandler( |
| | | short id, String baseDn, ReplicationServer replicationServer, |
| | | int id, String baseDn, ReplicationServer replicationServer, |
| | | ReplicationDbEnv dbenv, int queueSize) |
| | | throws DatabaseException |
| | | { |
| | |
| | | |
| | | latestTrimDate = TimeThread.getTime() - trimage; |
| | | |
| | | ChangeNumber trimDate = new ChangeNumber(latestTrimDate, |
| | | (short) 0, (short)0); |
| | | ChangeNumber trimDate = new ChangeNumber(latestTrimDate, 0, 0); |
| | | |
| | | // In case of deadlock detection by the Database, this thread can |
| | | // by aborted by a DeadlockException. This is a transient error and |
| | |
| | | * |
| | | * @return the serverId. |
| | | */ |
| | | public short getServerId() |
| | | public int getServerId() |
| | | { |
| | | return this.serverId; |
| | | } |
| | |
| | | ProtocolSession session, |
| | | int queueSize, |
| | | String replicationServerURL, |
| | | short replicationServerId, |
| | | int replicationServerId, |
| | | ReplicationServer replicationServer, |
| | | int rcvWindowSize) |
| | | { |
| | |
| | | */ |
| | | public ECLServerHandler( |
| | | String replicationServerURL, |
| | | short replicationServerId, |
| | | int replicationServerId, |
| | | ReplicationServer replicationServer, |
| | | StartECLSessionMsg startECLSessionMsg) |
| | | throws DirectoryException |
| | |
| | | public ECLServerWriter(ProtocolSession session, ECLServerHandler handler, |
| | | ReplicationServerDomain replicationServerDomain) |
| | | { |
| | | super(session, (short)-1, handler, replicationServerDomain); |
| | | super(session, -1, handler, replicationServerDomain); |
| | | |
| | | setName("Replication ECL Writer Thread for operation " + |
| | | handler.getOperationId()); |
| | |
| | | * value: a boolean true if we received the ack from the server, |
| | | * false otherwise. |
| | | */ |
| | | protected Map<Short,Boolean> expectedServersAckStatus = |
| | | new HashMap<Short,Boolean>(); |
| | | protected Map<Integer,Boolean> expectedServersAckStatus = |
| | | new HashMap<Integer,Boolean>(); |
| | | |
| | | /** |
| | | * Facility for monitoring: |
| | |
| | | * code can then call getTimeoutServers() method to now which servers did not |
| | | * respond in time. |
| | | */ |
| | | protected List<Short> serversInTimeout = null; |
| | | protected List<Integer> serversInTimeout = null; |
| | | |
| | | /** |
| | | * Creates a new ExpectedAcksInfo. |
| | |
| | | */ |
| | | protected ExpectedAcksInfo(ChangeNumber changeNumber, |
| | | ServerHandler requesterServerHandler, AssuredMode assuredMode, |
| | | List<Short> expectedServers) |
| | | List<Integer> expectedServers) |
| | | { |
| | | this.requesterServerHandler = requesterServerHandler; |
| | | this.assuredMode = assuredMode; |
| | | this.changeNumber = changeNumber; |
| | | |
| | | // Initialize list of servers we expect acks from |
| | | for (Short serverId : expectedServers) |
| | | for (Integer serverId : expectedServers) |
| | | { |
| | | expectedServersAckStatus.put(serverId, false); |
| | | } |
| | |
| | | * Gets the list of expected servers that did not respond in time. |
| | | * @return The list of expected servers that did not respond in time. |
| | | */ |
| | | public List<Short> getTimeoutServers() |
| | | public List<Integer> getTimeoutServers() |
| | | { |
| | | return serversInTimeout; |
| | | } |
| | |
| | | private ReplicationServerHandler replServerHandler; |
| | | private ReplicationServerDomain rsDomain; |
| | | // The id of the RS this DS is connected to |
| | | private short replicationServerId = -1; |
| | | private int replicationServerId = -1; |
| | | |
| | | // Server id of this DS |
| | | private short serverId = -1; |
| | | private int serverId = -1; |
| | | // Generation id of this DS |
| | | private long generationId = -1; |
| | | // Group id of the DS; |
| | |
| | | * @param eclInclude The list of entry attributes to be added to the ECL. |
| | | */ |
| | | public LightweightServerHandler(ReplicationServerHandler replServerHandler, |
| | | short replicationServerId, short serverId, long generationId, byte groupId, |
| | | int replicationServerId, int serverId, long generationId, byte groupId, |
| | | ServerStatus status, List<String> refUrls, boolean assuredFlag, |
| | | AssuredMode assuredMode, byte safeDataLevel, Set<String> eclInclude) |
| | | { |
| | |
| | | * Get the serverID associated with this LDAP server. |
| | | * @return The serverId. |
| | | */ |
| | | public short getServerId() |
| | | public int getServerId() |
| | | { |
| | | return Short.valueOf(serverId); |
| | | return serverId; |
| | | } |
| | | |
| | | /** |
| | |
| | | /** |
| | | * The serverID of the hosting replication server. |
| | | */ |
| | | protected short replicationServerId; |
| | | protected int replicationServerId; |
| | | /** |
| | | * Specifies the related replication server domain based on serviceId(baseDn). |
| | | */ |
| | |
| | | public MessageHandler( |
| | | int queueSize, |
| | | String replicationServerURL, |
| | | short replicationServerId, |
| | | int replicationServerId, |
| | | ReplicationServer replicationServer) |
| | | { |
| | | super("Message Handler"); |
| | |
| | | SortedSet<ReplicationIterator> iteratorSortedSet = |
| | | new TreeSet<ReplicationIterator>(comparator); |
| | | /* fill the lateQueue */ |
| | | for (short serverId : replicationServerDomain.getServers()) |
| | | for (int serverId : replicationServerDomain.getServers()) |
| | | { |
| | | ChangeNumber lastCsn = serverState.getMaxChangeNumber(serverId); |
| | | ReplicationIterator iterator = |
| | |
| | | try |
| | | { |
| | | // Build a list of candidates iterator (i.e. db i.e. server) |
| | | for (short serverId : replicationServerDomain.getServers()) |
| | | for (int serverId : replicationServerDomain.getServers()) |
| | | { |
| | | // get the last already sent CN from that server |
| | | ChangeNumber lastCsn = serverState.getMaxChangeNumber(serverId); |
| | |
| | | |
| | | |
| | | // For each LDAP server, its server state |
| | | private ConcurrentHashMap<Short, ServerState> LDAPStates = |
| | | new ConcurrentHashMap<Short, ServerState>(); |
| | | private ConcurrentHashMap<Integer, ServerState> LDAPStates = |
| | | new ConcurrentHashMap<Integer, ServerState>(); |
| | | |
| | | // A Map containing the ServerStates of each RS. |
| | | private ConcurrentHashMap<Short, ServerState> RSStates = |
| | | new ConcurrentHashMap<Short, ServerState>(); |
| | | private ConcurrentHashMap<Integer, ServerState> RSStates = |
| | | new ConcurrentHashMap<Integer, ServerState>(); |
| | | |
| | | // For each LDAP server, the last(max) CN it published |
| | | private ConcurrentHashMap<Short, ChangeNumber> maxCNs = |
| | | new ConcurrentHashMap<Short, ChangeNumber>(); |
| | | private ConcurrentHashMap<Integer, ChangeNumber> maxCNs = |
| | | new ConcurrentHashMap<Integer, ChangeNumber>(); |
| | | |
| | | // For each LDAP server, an approximation of the date of the first missing |
| | | // change |
| | | private ConcurrentHashMap<Short, Long> fmd = |
| | | new ConcurrentHashMap<Short, Long>(); |
| | | private ConcurrentHashMap<Integer, Long> fmd = |
| | | new ConcurrentHashMap<Integer, Long>(); |
| | | |
| | | private ConcurrentHashMap<Short, Long> missingChanges = |
| | | new ConcurrentHashMap<Short, Long>(); |
| | | private ConcurrentHashMap<Integer, Long> missingChanges = |
| | | new ConcurrentHashMap<Integer, Long>(); |
| | | |
| | | // For each RS server, an approximation of the date of the first missing |
| | | // change |
| | | private ConcurrentHashMap<Short, Long> fmRSDate = |
| | | new ConcurrentHashMap<Short, Long>(); |
| | | private ConcurrentHashMap<Integer, Long> fmRSDate = |
| | | new ConcurrentHashMap<Integer, Long>(); |
| | | |
| | | private ConcurrentHashMap<Short, Long> missingChangesRS = |
| | | new ConcurrentHashMap<Short, Long>(); |
| | | private ConcurrentHashMap<Integer, Long> missingChangesRS = |
| | | new ConcurrentHashMap<Integer, Long>(); |
| | | |
| | | |
| | | /** |
| | |
| | | * @param serverId The server ID. |
| | | * @return The delay |
| | | */ |
| | | public long getApproxDelay(short serverId) |
| | | public long getApproxDelay(int serverId) |
| | | { |
| | | Long afmd = fmd.get(serverId); |
| | | if ((afmd != null) && (afmd>0)) |
| | |
| | | * @param serverId The server ID. |
| | | * @return The date. |
| | | */ |
| | | public long getApproxFirstMissingDate(short serverId) |
| | | public long getApproxFirstMissingDate(int serverId) |
| | | { |
| | | Long res; |
| | | if ((res = fmd.get(serverId)) != null) |
| | |
| | | * @param serverId The server ID. |
| | | * @return The number of missing changes. |
| | | */ |
| | | public long getMissingChanges(short serverId) |
| | | public long getMissingChanges(int serverId) |
| | | { |
| | | Long res = missingChanges.get(serverId); |
| | | if (res==null) |
| | |
| | | * |
| | | * @return The number of missing changes. |
| | | */ |
| | | public long getMissingChangesRS(short serverId) |
| | | public long getMissingChangesRS(int serverId) |
| | | { |
| | | Long res = missingChangesRS.get(serverId); |
| | | if (res==null) |
| | |
| | | // Regarding each other LSj |
| | | // Sum the difference : max(LSj) - state(LSi) |
| | | |
| | | Iterator<Short> lsiStateItr = this.LDAPStates.keySet().iterator(); |
| | | Iterator<Integer> lsiStateItr = this.LDAPStates.keySet().iterator(); |
| | | while (lsiStateItr.hasNext()) |
| | | { |
| | | Short lsiSid = lsiStateItr.next(); |
| | | Integer lsiSid = lsiStateItr.next(); |
| | | ServerState lsiState = this.LDAPStates.get(lsiSid); |
| | | Long lsiMissingChanges = (long)0; |
| | | if (lsiState != null) |
| | | { |
| | | Iterator<Short> lsjMaxItr = this.maxCNs.keySet().iterator(); |
| | | Iterator<Integer> lsjMaxItr = this.maxCNs.keySet().iterator(); |
| | | while (lsjMaxItr.hasNext()) |
| | | { |
| | | Short lsjSid = lsjMaxItr.next(); |
| | | Integer lsjSid = lsjMaxItr.next(); |
| | | ChangeNumber lsjMaxCN = this.maxCNs.get(lsjSid); |
| | | ChangeNumber lsiLastCN = lsiState.getMaxChangeNumber(lsjSid); |
| | | |
| | |
| | | // Computes the missing changes counters for RS : |
| | | // Sum the difference of sequence numbers for each element in the States. |
| | | |
| | | for (short lsiSid : RSStates.keySet()) |
| | | for (int lsiSid : RSStates.keySet()) |
| | | { |
| | | ServerState lsiState = this.RSStates.get(lsiSid); |
| | | Long lsiMissingChanges = (long)0; |
| | | if (lsiState != null) |
| | | { |
| | | Iterator<Short> lsjMaxItr = this.maxCNs.keySet().iterator(); |
| | | Iterator<Integer> lsjMaxItr = this.maxCNs.keySet().iterator(); |
| | | while (lsjMaxItr.hasNext()) |
| | | { |
| | | Short lsjSid = lsjMaxItr.next(); |
| | | int lsjSid = lsjMaxItr.next(); |
| | | ChangeNumber lsjMaxCN = this.maxCNs.get(lsjSid); |
| | | ChangeNumber lsiLastCN = lsiState.getMaxChangeNumber(lsjSid); |
| | | |
| | |
| | | String mds = "Monitor data=\n"; |
| | | |
| | | // RS data |
| | | Iterator<Short> rsite = fmRSDate.keySet().iterator(); |
| | | Iterator<Integer> rsite = fmRSDate.keySet().iterator(); |
| | | while (rsite.hasNext()) |
| | | { |
| | | Short sid = rsite.next(); |
| | | Integer sid = rsite.next(); |
| | | mds += "\nfmRSDate(" + sid + ")=\t "+ "afmd=" + fmRSDate.get(sid); |
| | | } |
| | | |
| | | // maxCNs |
| | | Iterator<Short> itc = maxCNs.keySet().iterator(); |
| | | Iterator<Integer> itc = maxCNs.keySet().iterator(); |
| | | while (itc.hasNext()) |
| | | { |
| | | Short sid = itc.next(); |
| | | Integer sid = itc.next(); |
| | | ChangeNumber cn = maxCNs.get(sid); |
| | | mds += "\nmaxCNs(" + sid + ")= " + cn.toStringUI(); |
| | | } |
| | | |
| | | // LDAP data |
| | | Iterator<Short> lsite = LDAPStates.keySet().iterator(); |
| | | Iterator<Integer> lsite = LDAPStates.keySet().iterator(); |
| | | while (lsite.hasNext()) |
| | | { |
| | | Short sid = lsite.next(); |
| | | Integer sid = lsite.next(); |
| | | ServerState ss = LDAPStates.get(sid); |
| | | mds += "\nLSData(" + sid + ")=\t" + "state=[" + ss.toString() |
| | | + "] afmd=" + this.getApproxFirstMissingDate(sid); |
| | |
| | | rsite = RSStates.keySet().iterator(); |
| | | while (rsite.hasNext()) |
| | | { |
| | | Short sid = rsite.next(); |
| | | Integer sid = rsite.next(); |
| | | ServerState ss = RSStates.get(sid); |
| | | mds += "\nRSData(" + sid + ")=\t" + "state=[" + ss.toString() |
| | | + "] missingCount=" + missingChangesRS.get(sid); |
| | |
| | | */ |
| | | public void setMaxCNs(ServerState state) |
| | | { |
| | | Iterator<Short> it = state.iterator(); |
| | | Iterator<Integer> it = state.iterator(); |
| | | while (it.hasNext()) |
| | | { |
| | | short sid = it.next(); |
| | | int sid = it.next(); |
| | | ChangeNumber newCN = state.getMaxChangeNumber(sid); |
| | | setMaxCN(sid, newCN); |
| | | } |
| | |
| | | * @param serverId the provided serverId |
| | | * @param newCN the provided new CN |
| | | */ |
| | | public void setMaxCN(short serverId, ChangeNumber newCN) |
| | | public void setMaxCN(int serverId, ChangeNumber newCN) |
| | | { |
| | | if (newCN==null) return; |
| | | ChangeNumber currentMaxCN = maxCNs.get(serverId); |
| | |
| | | * @param serverId The server ID. |
| | | * @return The highest change number. |
| | | */ |
| | | public ChangeNumber getMaxCN(short serverId) |
| | | public ChangeNumber getMaxCN(int serverId) |
| | | { |
| | | return maxCNs.get(serverId); |
| | | } |
| | |
| | | * @param serverId The server ID. |
| | | * @return The server state. |
| | | */ |
| | | public ServerState getLDAPServerState(short serverId) |
| | | public ServerState getLDAPServerState(int serverId) |
| | | { |
| | | return LDAPStates.get(serverId); |
| | | } |
| | |
| | | * @param serverId The server ID. |
| | | * @param state The server state. |
| | | */ |
| | | public void setLDAPServerState(short serverId, ServerState state) |
| | | public void setLDAPServerState(int serverId, ServerState state) |
| | | { |
| | | LDAPStates.put(serverId, state); |
| | | } |
| | |
| | | * @param serverId The server ID. |
| | | * @param state The server state. |
| | | */ |
| | | public void setRSState(short serverId, ServerState state) |
| | | public void setRSState(int serverId, ServerState state) |
| | | { |
| | | RSStates.put(serverId, state); |
| | | } |
| | |
| | | * @param serverId The server ID. |
| | | * @param newFmd The first missing date. |
| | | */ |
| | | public void setFirstMissingDate(short serverId, Long newFmd) |
| | | public void setFirstMissingDate(int serverId, Long newFmd) |
| | | { |
| | | if (newFmd==null) return; |
| | | Long currentfmd = fmd.get(serverId); |
| | |
| | | * |
| | | * @return The iterator. |
| | | */ |
| | | public Iterator<Short> ldapIterator() |
| | | public Iterator<Integer> ldapIterator() |
| | | { |
| | | return LDAPStates.keySet().iterator(); |
| | | } |
| | |
| | | * |
| | | * @return The iterator. |
| | | */ |
| | | public Iterator<Short> rsIterator() |
| | | public Iterator<Integer> rsIterator() |
| | | { |
| | | return RSStates.keySet().iterator(); |
| | | } |
| | |
| | | * @param serverId The server ID. |
| | | * @return The server state. |
| | | */ |
| | | public ServerState getRSStates(short serverId) |
| | | public ServerState getRSStates(int serverId) |
| | | { |
| | | return RSStates.get(serverId); |
| | | } |
| | |
| | | * @param serverId The server ID. |
| | | * @return The date. |
| | | */ |
| | | public long getRSApproxFirstMissingDate(short serverId) |
| | | public long getRSApproxFirstMissingDate(int serverId) |
| | | { |
| | | Long res; |
| | | if ((res = fmRSDate.get(serverId)) != null) |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | protected byte[] encodeHeader(byte type, int additionalLength) |
| | | protected byte[] encodeHeader(byte type, int additionalLength, short version) |
| | | throws UnsupportedEncodingException |
| | | { |
| | | // Not called as only used by constructors using bytes |
| | |
| | | SearchOperation searchOperation) |
| | | { |
| | | // Walk through the servers |
| | | for (Short serverId : rsd.getServers()) |
| | | for (int serverId : rsd.getServers()) |
| | | { |
| | | if (exportConfig != null && exportConfig.isCancelled()) |
| | | { |
| | |
| | | private Database db = null; |
| | | private ReplicationDbEnv dbenv = null; |
| | | private ReplicationServer replicationServer; |
| | | private Short serverId; |
| | | private int serverId; |
| | | private String baseDn; |
| | | |
| | | // The maximum number of retries in case of DatabaseDeadlock Exception. |
| | |
| | | * @param dbenv The Db environment to use to create the db. |
| | | * @throws DatabaseException If a database problem happened. |
| | | */ |
| | | public ReplicationDB(Short serverId, String baseDn, |
| | | public ReplicationDB(int serverId, String baseDn, |
| | | ReplicationServer replicationServer, |
| | | ReplicationDbEnv dbenv) |
| | | throws DatabaseException |
| | |
| | | @Override |
| | | public String toString() |
| | | { |
| | | return serverId.toString() + baseDn.toString(); |
| | | return serverId + baseDn.toString(); |
| | | } |
| | | |
| | | /** |
| | |
| | | String[] str = stringData.split(FIELD_SEPARATOR, 2); |
| | | if (!str[0].equals(GENERATION_ID_TAG)) |
| | | { |
| | | short serverId = -1; |
| | | int serverId = -1; |
| | | try |
| | | { |
| | | // <serverId> |
| | | serverId = new Short(str[0]); |
| | | serverId = new Integer(str[0]); |
| | | } catch (NumberFormatException e) |
| | | { |
| | | // should never happen |
| | |
| | | * @return the Database. |
| | | * @throws DatabaseException in case of underlying Exception. |
| | | */ |
| | | public Database getOrAddDb(Short serverId, String baseDn, Long generationId) |
| | | public Database getOrAddDb(int serverId, String baseDn, Long generationId) |
| | | throws DatabaseException |
| | | { |
| | | if (debugEnabled()) |
| | |
| | | serverId + " " + baseDn + " " + generationId); |
| | | try |
| | | { |
| | | String stringId = serverId.toString() + FIELD_SEPARATOR + baseDn; |
| | | String stringId = serverId + FIELD_SEPARATOR + baseDn; |
| | | |
| | | // Opens the database for the changes received from this server |
| | | // on this domain. Create it if it does not already exist. |
| | |
| | | * @param serverId The serverId to remove from the Db. |
| | | * |
| | | */ |
| | | public void clearServerId(String baseDn, Short serverId) |
| | | public void clearServerId(String baseDn, int serverId) |
| | | { |
| | | if (debugEnabled()) |
| | | TRACER.debugInfo( |
| | |
| | | "clearServerId(baseDN=" + baseDn + ", serverId=" + serverId); |
| | | try |
| | | { |
| | | String stringId = serverId.toString() + FIELD_SEPARATOR + baseDn; |
| | | String stringId = serverId + FIELD_SEPARATOR + baseDn; |
| | | |
| | | // Deletes the record serverId/domain base Dn in the stateDb |
| | | byte[] byteId; |
| | |
| | | * @throws DatabaseException if a database problem happened. |
| | | */ |
| | | public ReplicationIterator( |
| | | short id, ReplicationDB db, ChangeNumber changeNumber, DbHandler dbh) |
| | | int id, ReplicationDB db, ChangeNumber changeNumber, DbHandler dbh) |
| | | throws Exception, DatabaseException |
| | | { |
| | | this.db = db; |
| | |
| | | BackupTaskListener, RestoreTaskListener, ImportTaskListener, |
| | | ExportTaskListener |
| | | { |
| | | private short serverId; |
| | | private int serverId; |
| | | private String serverURL; |
| | | |
| | | private ServerSocket listenSocket; |
| | |
| | | throws ConfigException |
| | | { |
| | | replicationPort = configuration.getReplicationPort(); |
| | | serverId = (short) configuration.getReplicationServerId(); |
| | | serverId = configuration.getReplicationServerId(); |
| | | replicationServers = configuration.getReplicationServer(); |
| | | if (replicationServers == null) |
| | | replicationServers = new ArrayList<String>(); |
| | |
| | | * DN given in parameter. |
| | | * @throws DatabaseException in case of underlying database problem. |
| | | */ |
| | | public DbHandler newDbHandler(short id, String baseDn) |
| | | public DbHandler newDbHandler(int id, String baseDn) |
| | | throws DatabaseException |
| | | { |
| | | return new DbHandler(id, baseDn, this, dbEnv, queueSize); |
| | |
| | | * @return The value of the serverId. |
| | | * |
| | | */ |
| | | public short getServerId() |
| | | public int getServerId() |
| | | { |
| | | return serverId; |
| | | } |
| | |
| | | |
| | | if (eligibleCN==null) |
| | | { |
| | | eligibleCN = new ChangeNumber(0,0,(short)0); |
| | | eligibleCN = new ChangeNumber(0, 0, 0); |
| | | } |
| | | |
| | | if (debugEnabled()) |
| | |
| | | * to this replication server. |
| | | * |
| | | */ |
| | | private final Map<Short, DataServerHandler> directoryServers = |
| | | new ConcurrentHashMap<Short, DataServerHandler>(); |
| | | private final Map<Integer, DataServerHandler> directoryServers = |
| | | new ConcurrentHashMap<Integer, DataServerHandler>(); |
| | | |
| | | /* |
| | | * This map contains one ServerHandler for each replication servers |
| | |
| | | * We add new TreeSet in the HashMap when a new replication server register |
| | | * to this replication server. |
| | | */ |
| | | private final Map<Short, ReplicationServerHandler> replicationServers = |
| | | new ConcurrentHashMap<Short, ReplicationServerHandler>(); |
| | | private final Map<Integer, ReplicationServerHandler> replicationServers = |
| | | new ConcurrentHashMap<Integer, ReplicationServerHandler>(); |
| | | |
| | | private final ConcurrentLinkedQueue<MessageHandler> otherHandlers = |
| | | new ConcurrentLinkedQueue<MessageHandler>(); |
| | |
| | | * This map contains the List of updates received from each |
| | | * LDAP server |
| | | */ |
| | | private final Map<Short, DbHandler> sourceDbHandlers = |
| | | new ConcurrentHashMap<Short, DbHandler>(); |
| | | private final Map<Integer, DbHandler> sourceDbHandlers = |
| | | new ConcurrentHashMap<Integer, DbHandler>(); |
| | | private ReplicationServer replicationServer; |
| | | |
| | | // GenerationId management |
| | |
| | | { |
| | | |
| | | ChangeNumber cn = update.getChangeNumber(); |
| | | short id = cn.getServerId(); |
| | | int id = cn.getServerId(); |
| | | sourceHandler.updateServerState(update); |
| | | sourceHandler.incrementInCount(); |
| | | |
| | |
| | | { |
| | | // Unknown assured mode: should never happen |
| | | Message errorMsg = ERR_RS_UNKNOWN_ASSURED_MODE.get( |
| | | Short.toString(replicationServer.getServerId()), |
| | | Integer.toString(replicationServer.getServerId()), |
| | | assuredMode.toString(), baseDn, update.toString()); |
| | | logError(errorMsg); |
| | | assuredMessage = false; |
| | |
| | | // Publish the messages to the source handler |
| | | dbHandler.add(update); |
| | | |
| | | List<Short> expectedServers = null; |
| | | List<Integer> expectedServers = null; |
| | | if (assuredMessage) |
| | | { |
| | | expectedServers = preparedAssuredInfo.expectedServers; |
| | |
| | | " for dn " + baseDn + ", update " + |
| | | update.getChangeNumber().toString() + |
| | | " will not be sent to replication server " + |
| | | Short.toString(handler.getServerId()) + " with generation id " + |
| | | Integer.toString(handler.getServerId()) + " with generation id " + |
| | | Long.toString(handler.getGenerationId()) + |
| | | " different from local " + |
| | | "generation id " + Long.toString(generationId)); |
| | |
| | | " for dn " + baseDn + ", update " + |
| | | update.getChangeNumber().toString() + |
| | | " will not be sent to directory server " + |
| | | Short.toString(handler.getServerId()) + " with generation id " + |
| | | Integer.toString(handler.getServerId()) + " with generation id " + |
| | | Long.toString(handler.getGenerationId()) + |
| | | " different from local " + |
| | | "generation id " + Long.toString(generationId)); |
| | |
| | | " for dn " + baseDn + ", update " + |
| | | update.getChangeNumber().toString() + |
| | | " will not be sent to directory server " + |
| | | Short.toString(handler.getServerId()) + |
| | | Integer.toString(handler.getServerId()) + |
| | | " as it is in full update"); |
| | | } |
| | | |
| | |
| | | * request. |
| | | * |
| | | */ |
| | | public List<Short> expectedServers = null; |
| | | public List<Integer> expectedServers = null; |
| | | |
| | | /** |
| | | * The constructed ExpectedAcksInfo object to be used when acks will be |
| | |
| | | ChangeNumber cn = update.getChangeNumber(); |
| | | byte groupId = replicationServer.getGroupId(); |
| | | byte sourceGroupId = sourceHandler.getGroupId(); |
| | | List<Short> expectedServers = new ArrayList<Short>(); |
| | | List<Short> wrongStatusServers = new ArrayList<Short>(); |
| | | List<Integer> expectedServers = new ArrayList<Integer>(); |
| | | List<Integer> wrongStatusServers = new ArrayList<Integer>(); |
| | | |
| | | if (sourceGroupId == groupId) |
| | | // Assured feature does not cross different group ids |
| | |
| | | { |
| | | // Should never happen |
| | | Message errorMsg = ERR_UNKNOWN_ASSURED_SAFE_DATA_LEVEL.get( |
| | | Short.toString(replicationServer.getServerId()), |
| | | Integer.toString(replicationServer.getServerId()), |
| | | Byte.toString(safeDataLevel), baseDn, update.toString()); |
| | | logError(errorMsg); |
| | | } else if (sourceGroupId != groupId) |
| | |
| | | } |
| | | } |
| | | |
| | | List<Short> expectedServers = new ArrayList<Short>(); |
| | | List<Integer> expectedServers = new ArrayList<Integer>(); |
| | | if (interestedInAcks) |
| | | { |
| | | if (sourceHandler.isDataServer()) |
| | |
| | | */ |
| | | MessageBuilder mb = new MessageBuilder(); |
| | | mb.append(ERR_RS_ERROR_SENDING_ACK.get( |
| | | Short.toString(replicationServer.getServerId()), |
| | | Short.toString(origServer.getServerId()), cn.toString(), baseDn)); |
| | | Integer.toString(replicationServer.getServerId()), |
| | | Integer.toString(origServer.getServerId()), |
| | | cn.toString(), baseDn)); |
| | | mb.append(stackTraceToSingleLineString(e)); |
| | | logError(mb.toMessage()); |
| | | stopServer(origServer); |
| | |
| | | ServerHandler origServer = expectedAcksInfo.getRequesterServer(); |
| | | if (debugEnabled()) |
| | | TRACER.debugInfo( |
| | | "In RS " + Short.toString(replicationServer.getServerId()) + |
| | | "In RS " + Integer.toString(replicationServer.getServerId()) + |
| | | " for " + baseDn + |
| | | ", sending timeout for assured update with change " + " number " + |
| | | cn.toString() + " to server id " + |
| | | Short.toString(origServer.getServerId())); |
| | | Integer.toString(origServer.getServerId())); |
| | | try |
| | | { |
| | | origServer.sendAck(finalAck); |
| | |
| | | */ |
| | | MessageBuilder mb = new MessageBuilder(); |
| | | mb.append(ERR_RS_ERROR_SENDING_ACK.get( |
| | | Short.toString(replicationServer.getServerId()), |
| | | Short.toString(origServer.getServerId()), cn.toString(), baseDn)); |
| | | Integer.toString(replicationServer.getServerId()), |
| | | Integer.toString(origServer.getServerId()), |
| | | cn.toString(), baseDn)); |
| | | mb.append(stackTraceToSingleLineString(e)); |
| | | logError(mb.toMessage()); |
| | | stopServer(origServer); |
| | |
| | | } |
| | | } |
| | | // retrieve expected servers in timeout to increment their counter |
| | | List<Short> serversInTimeout = expectedAcksInfo.getTimeoutServers(); |
| | | for (Short serverId : serversInTimeout) |
| | | List<Integer> serversInTimeout = expectedAcksInfo.getTimeoutServers(); |
| | | for (Integer serverId : serversInTimeout) |
| | | { |
| | | ServerHandler expectedServerInTimeout = |
| | | directoryServers.get(serverId); |
| | |
| | | * |
| | | * @param serverId the serverId to be checked. |
| | | */ |
| | | public void waitDisconnection(short serverId) |
| | | public void waitDisconnection(int serverId) |
| | | { |
| | | if (directoryServers.containsKey(serverId)) |
| | | { |
| | |
| | | * whatever directly connected of connected to another RS. |
| | | * @return a set containing the servers known by this replicationServer. |
| | | */ |
| | | public Set<Short> getServers() |
| | | public Set<Integer> getServers() |
| | | { |
| | | return sourceDbHandlers.keySet(); |
| | | } |
| | |
| | | * @return the created ReplicationIterator. Null when no DB is available |
| | | * for the provided server Id. |
| | | */ |
| | | public ReplicationIterator getChangelogIterator(short serverId, |
| | | public ReplicationIterator getChangelogIterator(int serverId, |
| | | ChangeNumber changeNumber) |
| | | { |
| | | DbHandler handler = sourceDbHandlers.get(serverId); |
| | |
| | | * @return the created ReplicationIterator. Null when no DB is available |
| | | * for the provided server Id. |
| | | */ |
| | | public ReplicationIterator getIterator(short serverId, |
| | | public ReplicationIterator getIterator(int serverId, |
| | | ChangeNumber changeNumber) |
| | | { |
| | | DbHandler handler = sourceDbHandlers.get(serverId); |
| | |
| | | * |
| | | * @throws DatabaseException If a database error happened. |
| | | */ |
| | | public void setDbHandler(short serverId, DbHandler dbHandler) |
| | | public void setDbHandler(int serverId, DbHandler dbHandler) |
| | | throws DatabaseException |
| | | { |
| | | synchronized (sourceDbHandlers) |
| | |
| | | |
| | | // Add the informations about the Replicas currently in |
| | | // the topology. |
| | | Iterator<Short> it = md.ldapIterator(); |
| | | Iterator<Integer> it = md.ldapIterator(); |
| | | while (it.hasNext()) |
| | | { |
| | | short replicaId = it.next(); |
| | | int replicaId = it.next(); |
| | | returnMsg.setServerState( |
| | | replicaId, md.getLDAPServerState(replicaId), |
| | | md.getApproxFirstMissingDate(replicaId), true); |
| | |
| | | it = md.rsIterator(); |
| | | while (it.hasNext()) |
| | | { |
| | | short replicaId = it.next(); |
| | | int replicaId = it.next(); |
| | | returnMsg.setServerState( |
| | | replicaId, md.getRSStates(replicaId), |
| | | md.getRSApproxFirstMissingDate(replicaId), false); |
| | |
| | | // We log the error. The requestor will detect a timeout or |
| | | // any other failure on the connection. |
| | | logError(ERR_CHANGELOG_ERROR_SENDING_MSG.get( |
| | | Short.toString((msg.getDestination())))); |
| | | Integer.toString((msg.getDestination())))); |
| | | } |
| | | } else if (msg instanceof MonitorMsg) |
| | | { |
| | |
| | | { |
| | | Message message = ERR_EXCEPTION_SENDING_TOPO_INFO.get( |
| | | baseDn.toString(), |
| | | "directory", Short.toString(handler.getServerId()), e.getMessage()); |
| | | "directory", Integer.toString(handler.getServerId()), |
| | | e.getMessage()); |
| | | logError(message); |
| | | } |
| | | } |
| | |
| | | { |
| | | Message message = ERR_EXCEPTION_SENDING_TOPO_INFO.get( |
| | | baseDn.toString(), |
| | | "replication", Short.toString(handler.getServerId()), |
| | | "replication", Integer.toString(handler.getServerId()), |
| | | e.getMessage()); |
| | | logError(message); |
| | | } |
| | |
| | | * that we must not include in the list DS list. |
| | | * @return A suitable TopologyMsg PDU to be sent to a peer DS |
| | | */ |
| | | public TopologyMsg createTopologyMsgForDS(short destDsId) |
| | | public TopologyMsg createTopologyMsgForDS(int destDsId) |
| | | { |
| | | List<DSInfo> dsInfos = new ArrayList<DSInfo>(); |
| | | List<RSInfo> rsInfos = new ArrayList<RSInfo>(); |
| | |
| | | { |
| | | logError(ERR_EXCEPTION_CHANGING_STATUS_AFTER_RESET_GEN_ID.get(baseDn. |
| | | toString(), |
| | | Short.toString(dsHandler.getServerId()), |
| | | Integer.toString(dsHandler.getServerId()), |
| | | e.getMessage())); |
| | | } |
| | | } |
| | |
| | | buildAndSendTopoInfoToRSs(); |
| | | |
| | | Message message = NOTE_DIRECTORY_SERVER_CHANGED_STATUS.get( |
| | | Short.toString(senderHandler.getServerId()), |
| | | Integer.toString(senderHandler.getServerId()), |
| | | baseDn.toString(), |
| | | newStatus.toString()); |
| | | logError(message); |
| | |
| | | { |
| | | logError(ERR_EXCEPTION_CHANGING_STATUS_FROM_STATUS_ANALYZER.get(baseDn. |
| | | toString(), |
| | | Short.toString(serverHandler.getServerId()), |
| | | Integer.toString(serverHandler.getServerId()), |
| | | e.getMessage())); |
| | | } |
| | | |
| | |
| | | * the state. |
| | | * @return Whether it is degraded or not. |
| | | */ |
| | | public boolean isDegradedDueToGenerationId(short serverId) |
| | | public boolean isDegradedDueToGenerationId(int serverId) |
| | | { |
| | | if (debugEnabled()) |
| | | TRACER.debugInfo( |
| | |
| | | { |
| | | Message message = NOTE_BAD_GENERATION_ID_FROM_RS.get( |
| | | baseDn, |
| | | Short.toString(handler.getServerId()), |
| | | Integer.toString(handler.getServerId()), |
| | | Long.toString(handler.getGenerationId()), |
| | | Long.toString(generationId)); |
| | | logError(message); |
| | |
| | | |
| | | for (ServerHandler directlsh : directoryServers.values()) |
| | | { |
| | | short serverID = directlsh.getServerId(); |
| | | int serverID = directlsh.getServerId(); |
| | | |
| | | // the state comes from the state stored in the SH |
| | | ServerState directlshState = directlsh.getServerState().duplicate(); |
| | |
| | | // - whatever they are directly or undirectly connected |
| | | ServerState dbServerState = getDbServerState(); |
| | | wrkMonitorData.setRSState(replicationServer.getServerId(), dbServerState); |
| | | Iterator<Short> it = dbServerState.iterator(); |
| | | Iterator<Integer> it = dbServerState.iterator(); |
| | | while (it.hasNext()) |
| | | { |
| | | short sid = it.next(); |
| | | int sid = it.next(); |
| | | ChangeNumber storedCN = dbServerState.getMaxChangeNumber(sid); |
| | | wrkMonitorData.setMaxCN(sid, storedCN); |
| | | } |
| | |
| | | // This is a response for an earlier request whose computing is |
| | | // already complete. |
| | | logError(NOTE_IGNORING_REMOTE_MONITOR_DATA.get( |
| | | Short.toString(msg.getsenderID()))); |
| | | Integer.toString(msg.getsenderID()))); |
| | | return; |
| | | } |
| | | // Here is the RS state : list <serverID, lastChangeNumber> |
| | |
| | | wrkMonitorData.setRSState(msg.getsenderID(), replServerState); |
| | | |
| | | // Store the remote LDAP servers states |
| | | Iterator<Short> lsidIterator = msg.ldapIterator(); |
| | | Iterator<Integer> lsidIterator = msg.ldapIterator(); |
| | | while (lsidIterator.hasNext()) |
| | | { |
| | | short sid = lsidIterator.next(); |
| | | int sid = lsidIterator.next(); |
| | | ServerState dsServerState = msg.getLDAPServerState(sid); |
| | | wrkMonitorData.setMaxCNs(dsServerState); |
| | | wrkMonitorData.setLDAPServerState(sid, dsServerState); |
| | |
| | | |
| | | // Process the latency reported by the remote RSi on its connections |
| | | // to the other RSes |
| | | Iterator<Short> rsidIterator = msg.rsIterator(); |
| | | Iterator<Integer> rsidIterator = msg.rsIterator(); |
| | | while (rsidIterator.hasNext()) |
| | | { |
| | | short rsid = rsidIterator.next(); |
| | | int rsid = rsidIterator.next(); |
| | | if (rsid == replicationServer.getServerId()) |
| | | { |
| | | // this is the latency of the remote RSi regarding the current RS |
| | | // let's update the fmd of my connected LS |
| | | for (ServerHandler connectedlsh : directoryServers.values()) |
| | | { |
| | | short connectedlsid = connectedlsh.getServerId(); |
| | | int connectedlsid = connectedlsh.getServerId(); |
| | | Long newfmd = msg.getRSApproxFirstMissingDate(rsid); |
| | | wrkMonitorData.setFirstMissingDate(connectedlsid, newfmd); |
| | | } |
| | |
| | | ReplicationServerHandler rsjHdr = replicationServers.get(rsid); |
| | | if (rsjHdr != null) |
| | | { |
| | | for (short remotelsid : rsjHdr.getConnectedDirectoryServerIds()) |
| | | for (int remotelsid : rsjHdr.getConnectedDirectoryServerIds()) |
| | | { |
| | | Long newfmd = msg.getRSApproxFirstMissingDate(rsid); |
| | | wrkMonitorData.setFirstMissingDate(remotelsid, newfmd); |
| | |
| | | * Get the map of connected DSs. |
| | | * @return The map of connected DSs |
| | | */ |
| | | public Map<Short, DataServerHandler> getConnectedDSs() |
| | | public Map<Integer, DataServerHandler> getConnectedDSs() |
| | | { |
| | | return directoryServers; |
| | | } |
| | |
| | | * Get the map of connected RSs. |
| | | * @return The map of connected RSs |
| | | */ |
| | | public Map<Short, ReplicationServerHandler> getConnectedRSs() |
| | | public Map<Integer, ReplicationServerHandler> getConnectedRSs() |
| | | { |
| | | return replicationServers; |
| | | } |
| | |
| | | // compute eligible CN |
| | | ServerState hbState = heartbeatState.duplicate(); |
| | | |
| | | Iterator<Short> it = hbState.iterator(); |
| | | Iterator<Integer> it = hbState.iterator(); |
| | | while (it.hasNext()) |
| | | { |
| | | short sid = it.next(); |
| | | int sid = it.next(); |
| | | ChangeNumber storedCN = hbState.getMaxChangeNumber(sid); |
| | | |
| | | // If the most recent UpdateMsg or CLHeartbeatMsg received is very old |
| | |
| | | |
| | | if (eligibleCN != null) |
| | | { |
| | | Iterator<Short> it = dbState.iterator(); |
| | | Iterator<Integer> it = dbState.iterator(); |
| | | while (it.hasNext()) |
| | | { |
| | | Short sid = it.next(); |
| | | int sid = it.next(); |
| | | DbHandler h = sourceDbHandlers.get(sid); |
| | | ChangeNumber dbCN = dbState.getMaxChangeNumber(sid); |
| | | try |
| | |
| | | for (DbHandler db : sourceDbHandlers.values()) |
| | | { |
| | | // Consider this producer (DS/db). |
| | | short sid = db.getServerId(); |
| | | int sid = db.getServerId(); |
| | | |
| | | ChangeNumber changelogLastCN = db.getLastChange(); |
| | | if (changelogLastCN != null) |
| | |
| | | |
| | | // Parses the dbState of the domain , server by server |
| | | ServerState dbState = this.getDbServerState(); |
| | | Iterator<Short> it = dbState.iterator(); |
| | | Iterator<Integer> it = dbState.iterator(); |
| | | while (it.hasNext()) |
| | | { |
| | | // for each server |
| | | Short sid = it.next(); |
| | | int sid = it.next(); |
| | | DbHandler h = sourceDbHandlers.get(sid); |
| | | |
| | | try |
| | |
| | | * this collection will contain as many elements as there are |
| | | * LDAP servers connected to the remote replication server. |
| | | */ |
| | | private final Map<Short, LightweightServerHandler> remoteDirectoryServers = |
| | | new ConcurrentHashMap<Short, LightweightServerHandler>(); |
| | | private final Map<Integer, LightweightServerHandler> remoteDirectoryServers = |
| | | new ConcurrentHashMap<Integer, LightweightServerHandler>(); |
| | | |
| | | /** |
| | | * Starts this handler based on a start message received from remote server. |
| | |
| | | ProtocolSession session, |
| | | int queueSize, |
| | | String replicationServerURL, |
| | | short replicationServerId, |
| | | int replicationServerId, |
| | | ReplicationServer replicationServer, |
| | | int rcvWindowSize) |
| | | { |
| | |
| | | // then we are just degrading the peer. |
| | | Message message = NOTE_BAD_GENERATION_ID_FROM_RS.get( |
| | | getServiceId(), |
| | | Short.toString(serverId), |
| | | Integer.toString(serverId), |
| | | Long.toString(generationId), |
| | | Long.toString(localGenerationId)); |
| | | logError(message); |
| | |
| | | // setGenerationId(generationId, false); |
| | | Message message = NOTE_BAD_GENERATION_ID_FROM_RS.get( |
| | | getServiceId(), |
| | | Short.toString(serverId), |
| | | Integer.toString(serverId), |
| | | Long.toString(generationId), |
| | | Long.toString(localGenerationId)); |
| | | logError(message); |
| | |
| | | { |
| | | // Alright, connected with new RS (either outgoing or incoming |
| | | // connection): store handler. |
| | | Map<Short, ReplicationServerHandler> connectedRSs = |
| | | Map<Integer, ReplicationServerHandler> connectedRSs = |
| | | replicationServerDomain.getConnectedRSs(); |
| | | connectedRSs.put(serverId, this); |
| | | } |
| | |
| | | // then we are just degrading the peer. |
| | | Message message = NOTE_BAD_GENERATION_ID_FROM_RS.get( |
| | | getServiceId(), |
| | | Short.toString(serverId), |
| | | Integer.toString(serverId), |
| | | Long.toString(generationId), |
| | | Long.toString(localGenerationId)); |
| | | logError(message); |
| | |
| | | // setGenerationId(generationId, false); |
| | | Message message = NOTE_BAD_GENERATION_ID_FROM_RS.get( |
| | | getServiceId(), |
| | | Short.toString(serverId), |
| | | Integer.toString(serverId), |
| | | Long.toString(generationId), |
| | | Long.toString(localGenerationId)); |
| | | logError(message); |
| | |
| | | * @return boolean True is the wanted server is connected to the server |
| | | * represented by this handler. |
| | | */ |
| | | public boolean isRemoteLDAPServer(short wantedServer) |
| | | public boolean isRemoteLDAPServer(int wantedServer) |
| | | { |
| | | synchronized (remoteDirectoryServers) |
| | | { |
| | |
| | | * Return a Set containing the servers known by this replicationServer. |
| | | * @return a set containing the servers known by this replicationServer. |
| | | */ |
| | | public Set<Short> getConnectedDirectoryServerIds() |
| | | public Set<Integer> getConnectedDirectoryServerIds() |
| | | { |
| | | synchronized (remoteDirectoryServers) |
| | | { |
| | |
| | | */ |
| | | public SafeDataExpectedAcksInfo(ChangeNumber changeNumber, |
| | | ServerHandler requesterServerHandler, byte safeDataLevel, |
| | | List<Short> expectedServers) |
| | | List<Integer> expectedServers) |
| | | { |
| | | super(changeNumber, requesterServerHandler, AssuredMode.SAFE_DATA_MODE, |
| | | expectedServers); |
| | |
| | | } |
| | | |
| | | // Get the ack status for the matching server |
| | | short ackingServerId = ackingServer.getServerId(); |
| | | int ackingServerId = ackingServer.getServerId(); |
| | | boolean ackReceived = expectedServersAckStatus.get(ackingServerId); |
| | | if (ackReceived) |
| | | { |
| | |
| | | // Fill collected errors info |
| | | ack.setHasTimeout(true); |
| | | // Tell wich servers did not send an ack in time |
| | | List<Short> failedServers = new ArrayList<Short>(); |
| | | Set<Short> serverIds = expectedServersAckStatus.keySet(); |
| | | serversInTimeout = new ArrayList<Short>(); // Use next loop to fill it |
| | | for (Short serverId : serverIds) |
| | | List<Integer> failedServers = new ArrayList<Integer>(); |
| | | Set<Integer> serverIds = expectedServersAckStatus.keySet(); |
| | | serversInTimeout = new ArrayList<Integer>(); // Use next loop to fill it |
| | | for (Integer serverId : serverIds) |
| | | { |
| | | boolean ackReceived = expectedServersAckStatus.get(serverId); |
| | | if (!ackReceived) |
| | |
| | | // The list of server ids that had errors for the sent matching update |
| | | // Each server id of the list had one of the |
| | | // 3 possible errors (timeout, wrong status or replay error) |
| | | private List<Short> failedServers = new ArrayList<Short>(); |
| | | private List<Integer> failedServers = new ArrayList<Integer>(); |
| | | |
| | | /** |
| | | * Number of servers we want an ack from and from which we received the ack. |
| | |
| | | * returning ack we gonna compute |
| | | */ |
| | | public SafeReadExpectedAcksInfo(ChangeNumber changeNumber, |
| | | ServerHandler requesterServerHandler, List<Short> expectedServers, |
| | | List<Short> wrongStatusServers) |
| | | ServerHandler requesterServerHandler, List<Integer> expectedServers, |
| | | List<Integer> wrongStatusServers) |
| | | { |
| | | super(changeNumber, requesterServerHandler, AssuredMode.SAFE_READ_MODE, |
| | | expectedServers); |
| | |
| | | public boolean processReceivedAck(ServerHandler ackingServer, AckMsg ackMsg) |
| | | { |
| | | // Get the ack status for the matching server |
| | | short ackingServerId = ackingServer.getServerId(); |
| | | int ackingServerId = ackingServer.getServerId(); |
| | | boolean ackReceived = expectedServersAckStatus.get(ackingServerId); |
| | | if (ackReceived) |
| | | { |
| | |
| | | ack.setHasTimeout(true); |
| | | |
| | | // Add servers that did not respond in time |
| | | Set<Short> serverIds = expectedServersAckStatus.keySet(); |
| | | serversInTimeout = new ArrayList<Short>(); // Use next loop to fill it |
| | | for (Short serverId : serverIds) |
| | | Set<Integer> serverIds = expectedServersAckStatus.keySet(); |
| | | serversInTimeout = new ArrayList<Integer>(); // Use next loop to fill it |
| | | for (int serverId : serverIds) |
| | | { |
| | | boolean ackReceived = expectedServersAckStatus.get(serverId); |
| | | if (!ackReceived) |
| | |
| | | /** |
| | | * The serverId of the remote server. |
| | | */ |
| | | protected short serverId; |
| | | protected int serverId; |
| | | /** |
| | | * The session opened with the remote server. |
| | | */ |
| | |
| | | ProtocolSession session, |
| | | int queueSize, |
| | | String replicationServerURL, |
| | | short replicationServerId, |
| | | int replicationServerId, |
| | | ReplicationServer replicationServer, |
| | | int rcvWindowSize) |
| | | { |
| | |
| | | * |
| | | * @return the ID of the server to which this object is linked |
| | | */ |
| | | public short getServerId() |
| | | public int getServerId() |
| | | { |
| | | return serverId; |
| | | } |
| | |
| | | // Timeout |
| | | Message message = NOTE_TIMEOUT_WHEN_CROSS_CONNECTION.get( |
| | | getServiceId(), |
| | | Short.toString(serverId), |
| | | Short.toString(replicationServerId)); |
| | | Integer.toString(serverId), |
| | | Integer.toString(replicationServerId)); |
| | | throw new DirectoryException(ResultCode.OTHER, message); |
| | | } |
| | | } |
| | |
| | | * The tracer object for the debug logger. |
| | | */ |
| | | private static final DebugTracer TRACER = getTracer(); |
| | | private short serverId; |
| | | private int serverId; |
| | | private ProtocolSession session; |
| | | private ServerHandler handler; |
| | | private ReplicationServerDomain replicationServerDomain; |
| | |
| | | * @param replicationServerDomain The ReplicationServerDomain for this server |
| | | * reader. |
| | | */ |
| | | public ServerReader(ProtocolSession session, short serverId, |
| | | public ServerReader(ProtocolSession session, int serverId, |
| | | ServerHandler handler, |
| | | ReplicationServerDomain replicationServerDomain) |
| | | { |
| | |
| | | replicationServerDomain.getGenerationId(); |
| | | if (dsStatus == ServerStatus.BAD_GEN_ID_STATUS) |
| | | logError(ERR_IGNORING_UPDATE_FROM_DS_BADGENID.get( |
| | | Short.toString(replicationServerDomain. |
| | | Integer.toString(replicationServerDomain. |
| | | getReplicationServer().getServerId()), |
| | | replicationServerDomain.getBaseDn(), |
| | | ((UpdateMsg) msg).getChangeNumber().toString(), |
| | | Short.toString(handler.getServerId()), |
| | | Integer.toString(handler.getServerId()), |
| | | Long.toString(referenceGenerationId), |
| | | Long.toString(handler.getGenerationId()))); |
| | | if (dsStatus == ServerStatus.FULL_UPDATE_STATUS) |
| | | logError(ERR_IGNORING_UPDATE_FROM_DS_FULLUP.get( |
| | | Short.toString(replicationServerDomain. |
| | | Integer.toString(replicationServerDomain. |
| | | getReplicationServer().getServerId()), |
| | | replicationServerDomain.getBaseDn(), |
| | | ((UpdateMsg) msg).getChangeNumber().toString(), |
| | | Short.toString(handler.getServerId()))); |
| | | Integer.toString(handler.getServerId()))); |
| | | filtered = true; |
| | | } |
| | | } else |
| | |
| | | if ((referenceGenerationId > 0) && |
| | | (referenceGenerationId != handler.getGenerationId())) |
| | | { |
| | | logError(ERR_IGNORING_UPDATE_FROM_RS.get( |
| | | Short.toString(replicationServerDomain.getReplicationServer(). |
| | | getServerId()), |
| | | replicationServerDomain.getBaseDn(), |
| | | ((UpdateMsg) msg).getChangeNumber().toString(), |
| | | Short.toString(handler.getServerId()), |
| | | Long.toString(referenceGenerationId), |
| | | Long.toString(handler.getGenerationId()))); |
| | | logError( |
| | | ERR_IGNORING_UPDATE_FROM_RS.get( |
| | | Integer.toString( |
| | | replicationServerDomain.getReplicationServer(). |
| | | getServerId()), |
| | | replicationServerDomain.getBaseDn(), |
| | | ((UpdateMsg) msg).getChangeNumber().toString(), |
| | | Integer.toString(handler.getServerId()), |
| | | Long.toString(referenceGenerationId), |
| | | Long.toString(handler.getGenerationId()))); |
| | | filtered = true; |
| | | } |
| | | } |
| | |
| | | errMessage = |
| | | ERR_RECEIVED_CHANGE_STATUS_NOT_FROM_DS.get( |
| | | replicationServerDomain.getBaseDn(), |
| | | Short.toString(handler.getServerId()), |
| | | Integer.toString(handler.getServerId()), |
| | | csMsg.toString()); |
| | | logError(errMessage); |
| | | } |
| | |
| | | this + " " + |
| | | stackTraceToSingleLineString(e) + " " + e.getLocalizedMessage()); |
| | | errMessage = NOTE_SERVER_DISCONNECT.get(handler.toString(), |
| | | Short.toString(replicationServerDomain. |
| | | Integer.toString(replicationServerDomain. |
| | | getReplicationServer().getServerId())); |
| | | logError(errMessage); |
| | | } |
| | |
| | | * @param replicationServerDomain The ReplicationServerDomain of this |
| | | * ServerWriter. |
| | | */ |
| | | public ServerWriter(ProtocolSession session, short serverId, |
| | | public ServerWriter(ProtocolSession session, int serverId, |
| | | ServerHandler handler, |
| | | ReplicationServerDomain replicationServerDomain) |
| | | { |
| | |
| | | replicationServerDomain.getGenerationId(); |
| | | if (dsStatus == ServerStatus.BAD_GEN_ID_STATUS) |
| | | logError(ERR_IGNORING_UPDATE_TO_DS_BADGENID.get( |
| | | Short.toString(replicationServerDomain.getReplicationServer(). |
| | | Integer.toString(replicationServerDomain.getReplicationServer(). |
| | | getServerId()), |
| | | replicationServerDomain.getBaseDn(), |
| | | update.getChangeNumber().toString(), |
| | | Short.toString(handler.getServerId()), |
| | | Integer.toString(handler.getServerId()), |
| | | Long.toString(handler.getGenerationId()), |
| | | Long.toString(referenceGenerationId))); |
| | | if (dsStatus == ServerStatus.FULL_UPDATE_STATUS) |
| | | logError(ERR_IGNORING_UPDATE_TO_DS_FULLUP.get( |
| | | Short.toString(replicationServerDomain.getReplicationServer(). |
| | | Integer.toString(replicationServerDomain.getReplicationServer(). |
| | | getServerId()), |
| | | replicationServerDomain.getBaseDn(), |
| | | update.getChangeNumber().toString(), |
| | | Short.toString(handler.getServerId()))); |
| | | Integer.toString(handler.getServerId()))); |
| | | continue; |
| | | } |
| | | } else |
| | |
| | | (referenceGenerationId == -1) || (handler.getGenerationId() == -1)) |
| | | { |
| | | logError(ERR_IGNORING_UPDATE_TO_RS.get( |
| | | Short.toString(replicationServerDomain.getReplicationServer(). |
| | | Integer.toString(replicationServerDomain.getReplicationServer(). |
| | | getServerId()), |
| | | replicationServerDomain.getBaseDn(), |
| | | update.getChangeNumber().toString(), |
| | | Short.toString(handler.getServerId()), |
| | | Integer.toString(handler.getServerId()), |
| | | Long.toString(handler.getGenerationId()), |
| | | Long.toString(referenceGenerationId))); |
| | | continue; |
| | |
| | | * be removed, just ignore the exception and let the thread die as well |
| | | */ |
| | | errMessage = NOTE_SERVER_DISCONNECT.get(handler.toString(), |
| | | Short.toString(replicationServerDomain. |
| | | Integer.toString(replicationServerDomain. |
| | | getReplicationServer().getServerId())); |
| | | logError(errMessage); |
| | | } |
| | |
| | | * be removed, just ignore the exception and let the thread die as well |
| | | */ |
| | | errMessage = NOTE_SERVER_DISCONNECT.get(handler.toString(), |
| | | Short.toString(replicationServerDomain. |
| | | Integer.toString(replicationServerDomain. |
| | | getReplicationServer().getServerId())); |
| | | logError(errMessage); |
| | | } |
| | |
| | | { |
| | | TRACER.debugInfo("Status analyzer for dn " + |
| | | replicationServerDomain.getBaseDn().toString() + " DS " + |
| | | Short.toString(serverHandler.getServerId()) + " has " + nChanges + |
| | | Integer.toString(serverHandler.getServerId()) + " has " + nChanges + |
| | | " message(s) in writer queue. This is in RS " + |
| | | replicationServerDomain.getReplicationServer().getServerId()); |
| | | } |
| | |
| | | * The time in milliseconds between heartbeats. |
| | | */ |
| | | private long heartbeatInterval; |
| | | private short serverId; |
| | | private int serverId; |
| | | |
| | | /** |
| | | * Set this to stop the thread. |
| | |
| | | * @param session The session on which heartbeats are to be sent. |
| | | * @param heartbeatInterval The interval between heartbeats sent |
| | | * (in milliseconds). |
| | | * @param serverId The serverId of the sender domain. |
| | | * @param serverId2 The serverId of the sender domain. |
| | | */ |
| | | public CTHeartbeatPublisherThread(String threadName, ProtocolSession session, |
| | | long heartbeatInterval, short serverId) |
| | | long heartbeatInterval, int serverId2) |
| | | { |
| | | super(threadName); |
| | | this.session = session; |
| | | this.heartbeatInterval = heartbeatInterval; |
| | | this.serverId = serverId; |
| | | this.serverId = serverId2; |
| | | } |
| | | |
| | | /** |
| | |
| | | private ProtocolSession session = null; |
| | | private final ServerState state; |
| | | private final String baseDn; |
| | | private final short serverId; |
| | | private final int serverId; |
| | | private Semaphore sendWindow; |
| | | private int maxSendWindow; |
| | | private int rcvWindow = 100; |
| | |
| | | // The group id of the RS we are connected to |
| | | private byte rsGroupId = (byte) -1; |
| | | // The server id of the RS we are connected to |
| | | private short rsServerId = -1; |
| | | private Integer rsServerId = -1; |
| | | // The server URL of the RS we are connected to |
| | | private String rsServerUrl = null; |
| | | // Our replication domain |
| | |
| | | * when negotiating the session with the replicationServer. |
| | | * @param baseDn The base DN that should be used by this broker |
| | | * when negotiating the session with the replicationServer. |
| | | * @param serverId The server ID that should be used by this broker |
| | | * @param serverID2 The server ID that should be used by this broker |
| | | * when negotiating the session with the replicationServer. |
| | | * @param window The size of the send and receive window to use. |
| | | * @param generationId The generationId for the server associated to the |
| | |
| | | * or zero if no CN heartbeat shoud be sent. |
| | | */ |
| | | public ReplicationBroker(ReplicationDomain replicationDomain, |
| | | ServerState state, String baseDn, short serverId, int window, |
| | | ServerState state, String baseDn, int serverID2, int window, |
| | | long generationId, long heartbeatInterval, |
| | | ReplSessionSecurity replSessionSecurity, byte groupId, |
| | | long changeTimeHeartbeatInterval) |
| | | { |
| | | this.domain = replicationDomain; |
| | | this.baseDn = baseDn; |
| | | this.serverId = serverId; |
| | | this.serverId = serverID2; |
| | | this.state = state; |
| | | this.protocolVersion = ProtocolVersion.getCurrentVersion(); |
| | | this.replSessionSecurity = replSessionSecurity; |
| | |
| | | * Gets the server id of the RS we are connected to. |
| | | * @return The server id of the RS we are connected to |
| | | */ |
| | | public short getRsServerId() |
| | | public Integer getRsServerId() |
| | | { |
| | | return rsServerId; |
| | | } |
| | |
| | | * Gets the server id. |
| | | * @return The server id |
| | | */ |
| | | public short getServerId() |
| | | public int getServerId() |
| | | { |
| | | return serverId; |
| | | } |
| | |
| | | // right group id arrives... |
| | | Message message = |
| | | WARN_CONNECTED_TO_SERVER_WITH_WRONG_GROUP_ID.get( |
| | | Byte.toString(groupId), Short.toString(rsServerId), |
| | | Byte.toString(groupId), Integer.toString(rsServerId), |
| | | bestServer, Byte.toString(getRsGroupId()), |
| | | baseDn.toString(), Short.toString(serverId)); |
| | | baseDn.toString(), Integer.toString(serverId)); |
| | | logError(message); |
| | | startSameGroupIdPoller(); |
| | | } |
| | |
| | | // inform administrator |
| | | Message message = NOTE_NEW_SERVER_WITH_SAME_GROUP_ID.get( |
| | | Byte.toString(groupId), baseDn.toString(), |
| | | Short.toString(serverId)); |
| | | Integer.toString(serverId)); |
| | | logError(message); |
| | | // Do not log connection error |
| | | newServerWithSameGroupId = true; |
| | |
| | | Message message = |
| | | NOTE_NOW_FOUND_SAME_GENERATION_CHANGELOG.get( |
| | | baseDn.toString(), |
| | | Short.toString(rsServerId), |
| | | Integer.toString(rsServerId), |
| | | replicationServer, |
| | | Short.toString(serverId), |
| | | Integer.toString(serverId), |
| | | Long.toString(this.getGenerationID())); |
| | | logError(message); |
| | | } else |
| | |
| | | if (debugEnabled()) |
| | | { |
| | | TRACER.debugInfo("RB for dn " + baseDn + |
| | | " and with server id " + Short.toString(serverId) + " computed " + |
| | | " and with server id " + Integer.toString(serverId) + " computed " + |
| | | Integer.toString(nChanges) + " changes late."); |
| | | } |
| | | |
| | |
| | | * @param myState The local server state. |
| | | * @param rsInfos The list of available replication servers and their |
| | | * associated information (choice will be made among them). |
| | | * @param serverId The server id for the suffix we are working for. |
| | | * @param serverId2 The server id for the suffix we are working for. |
| | | * @param baseDn The suffix for which we are working for. |
| | | * @param groupId The groupId we prefer being connected to if possible |
| | | * @return The computed best replication server. |
| | | */ |
| | | public static String computeBestReplicationServer(ServerState myState, |
| | | HashMap<String, ServerInfo> rsInfos, short serverId, String baseDn, |
| | | HashMap<String, ServerInfo> rsInfos, int serverId2, String baseDn, |
| | | byte groupId) |
| | | { |
| | | /* |
| | |
| | | if (sameGroupIdRsInfos.size() > 0) |
| | | { |
| | | return searchForBestReplicationServer(myState, sameGroupIdRsInfos, |
| | | serverId, baseDn); |
| | | serverId2, baseDn); |
| | | } else |
| | | { |
| | | return searchForBestReplicationServer(myState, rsInfos, |
| | | serverId, baseDn); |
| | | serverId2, baseDn); |
| | | } |
| | | } |
| | | |
| | |
| | | * @param myState The local server state. |
| | | * @param rsInfos The list of available replication servers and their |
| | | * associated information (choice will be made among them). |
| | | * @param serverId The server id for the suffix we are working for. |
| | | * @param serverId2 The server id for the suffix we are working for. |
| | | * @param baseDn The suffix for which we are working for. |
| | | * @return The computed best replication server. |
| | | */ |
| | | private static String searchForBestReplicationServer(ServerState myState, |
| | | HashMap<String, ServerInfo> rsInfos, short serverId, String baseDn) |
| | | HashMap<String, ServerInfo> rsInfos, int serverId2, String baseDn) |
| | | { |
| | | /* |
| | | * Find replication servers who are up to date (or more up to date than us, |
| | |
| | | /* |
| | | * Start loop to differenciate up to date servers from late ones. |
| | | */ |
| | | ChangeNumber myChangeNumber = myState.getMaxChangeNumber(serverId); |
| | | ChangeNumber myChangeNumber = myState.getMaxChangeNumber(serverId2); |
| | | if (myChangeNumber == null) |
| | | { |
| | | myChangeNumber = new ChangeNumber(0, 0, serverId); |
| | | myChangeNumber = new ChangeNumber(0, 0, serverId2); |
| | | } |
| | | for (String repServer : rsInfos.keySet()) |
| | | { |
| | | |
| | | ServerState rsState = rsInfos.get(repServer).getServerState(); |
| | | ChangeNumber rsChangeNumber = rsState.getMaxChangeNumber(serverId); |
| | | ChangeNumber rsChangeNumber = rsState.getMaxChangeNumber(serverId2); |
| | | if (rsChangeNumber == null) |
| | | { |
| | | rsChangeNumber = new ChangeNumber(0, 0, serverId); |
| | | rsChangeNumber = new ChangeNumber(0, 0, serverId2); |
| | | } |
| | | |
| | | // Store state in right list |
| | |
| | | */ |
| | | |
| | | Message message = NOTE_FOUND_CHANGELOGS_WITH_MY_CHANGES.get( |
| | | upToDateServers.size(), baseDn, Short.toString(serverId)); |
| | | upToDateServers.size(), baseDn, Integer.toString(serverId2)); |
| | | logError(message); |
| | | |
| | | /* |
| | |
| | | for (ServerState curState : upToDateServers.values()) |
| | | { |
| | | |
| | | Iterator<Short> it = curState.iterator(); |
| | | Iterator<Integer> it = curState.iterator(); |
| | | while (it.hasNext()) |
| | | { |
| | | Short sId = it.next(); |
| | | Integer sId = it.next(); |
| | | ChangeNumber curSidCn = curState.getMaxChangeNumber(sId); |
| | | if (curSidCn == null) |
| | | { |
| | |
| | | */ |
| | | long shift = -1L; |
| | | ServerState curState = upToDateServers.get(upServer); |
| | | Iterator<Short> it = curState.iterator(); |
| | | Iterator<Integer> it = curState.iterator(); |
| | | while (it.hasNext()) |
| | | { |
| | | Short sId = it.next(); |
| | | Integer sId = it.next(); |
| | | ChangeNumber curSidCn = curState.getMaxChangeNumber(sId); |
| | | if (curSidCn == null) |
| | | { |
| | |
| | | * (this is the most up to date regarding our server id). |
| | | */ |
| | | ServerState curState = lateOnes.get(lateServer); |
| | | ChangeNumber ourSidCn = curState.getMaxChangeNumber(serverId); |
| | | ChangeNumber ourSidCn = curState.getMaxChangeNumber(serverId2); |
| | | if (ourSidCn == null) |
| | | { |
| | | ourSidCn = new ChangeNumber(0, 0, serverId); |
| | | ourSidCn = new ChangeNumber(0, 0, serverId2); |
| | | } |
| | | // Cannot be negative as our Cn for our server id is strictly |
| | | // greater than those of the servers in late server list |
| | |
| | | */ |
| | | Message message = |
| | | NOTE_DISCONNECTED_FROM_CHANGELOG.get(replicationServer, |
| | | Short.toString(rsServerId), baseDn.toString(), |
| | | Short.toString(serverId)); |
| | | Integer.toString(rsServerId), baseDn.toString(), |
| | | Integer.toString(serverId)); |
| | | logError(message); |
| | | } |
| | | this.reStart(failingSession); |
| | |
| | | // id. |
| | | Message message = NOTE_NEW_SERVER_WITH_SAME_GROUP_ID.get( |
| | | Byte.toString(groupId), baseDn.toString(), |
| | | Short.toString(serverId)); |
| | | Integer.toString(serverId)); |
| | | logError(message); |
| | | try |
| | | { |
| | |
| | | { |
| | | Message message = ERR_EXCEPTION_SENDING_CS.get( |
| | | baseDn, |
| | | Short.toString(serverId), |
| | | Integer.toString(serverId), |
| | | ex.getLocalizedMessage() + stackTraceToSingleLineString(ex)); |
| | | logError(message); |
| | | } |
| | |
| | | * Full Initialization of a replica can be triggered by LDAP clients |
| | | * by creating InitializeTasks or InitializeTargetTask. |
| | | * Full initialization can also by triggered from the ReplicationDomain |
| | | * implementation using methods {@link #initializeRemote(short)} |
| | | * or {@link #initializeFromRemote(short)}. |
| | | * implementation using methods {@link #initializeRemote(int)} |
| | | * or {@link #initializeFromRemote(int)}. |
| | | * <p> |
| | | * At shutdown time, the {@link #stopDomain()} method should be called to |
| | | * cleanly stop the replication service. |
| | |
| | | * Replication Service. |
| | | * Each Domain must use a unique ServerID. |
| | | */ |
| | | private final short serverID; |
| | | private final int serverID; |
| | | |
| | | /** |
| | | * The ReplicationBroker that is used by this ReplicationDomain to |
| | |
| | | // that have not been successfully acknowledged (either because of timeout, |
| | | // wrong status or error at replay) for a particular server (DS or RS). String |
| | | // format: <server id>:<number of failed updates> |
| | | private Map<Short,Integer> assuredSrServerNotAcknowledgedUpdates = |
| | | new HashMap<Short,Integer>(); |
| | | private Map<Integer, Integer> assuredSrServerNotAcknowledgedUpdates = |
| | | new HashMap<Integer,Integer>(); |
| | | // Number of updates received in Assured Mode, Safe Read request |
| | | private AtomicInteger assuredSrReceivedUpdates = new AtomicInteger(0); |
| | | // Number of updates received in Assured Mode, Safe Read request that we have |
| | |
| | | // Multiple values allowed: number of updates sent in Assured Mode, Safe Data, |
| | | // that have not been successfully acknowledged because of timeout for a |
| | | // particular RS. String format: <server id>:<number of failed updates> |
| | | private Map<Short,Integer> assuredSdServerTimeoutUpdates = |
| | | new HashMap<Short,Integer>(); |
| | | private Map<Integer, Integer> assuredSdServerTimeoutUpdates = |
| | | new HashMap<Integer,Integer>(); |
| | | |
| | | /* Status related monitoring fields */ |
| | | |
| | |
| | | * A Map containing of the ServerStates of all the replicas in the topology |
| | | * as seen by the ReplicationServer the last time it was polled. |
| | | */ |
| | | private Map<Short, ServerState> replicaStates = |
| | | new HashMap<Short, ServerState>(); |
| | | private HashMap<Integer, ServerState> replicaStates = |
| | | new HashMap<Integer, ServerState>(); |
| | | |
| | | Set<String> cfgEclIncludes = new HashSet<String>(); |
| | | Set<String> eClIncludes = new HashSet<String>(); |
| | |
| | | * This identifier should be different for each server that |
| | | * is participating to a given Replication Domain. |
| | | */ |
| | | public ReplicationDomain(String serviceID, short serverID) |
| | | public ReplicationDomain(String serviceID, int serverID) |
| | | { |
| | | this.serviceID = serviceID; |
| | | this.serverID = serverID; |
| | |
| | | * is participating to a given Replication Domain. |
| | | * @param serverState The serverState to use |
| | | */ |
| | | public ReplicationDomain(String serviceID, short serverID, |
| | | public ReplicationDomain(String serviceID, int serverID, |
| | | ServerState serverState) |
| | | { |
| | | this.serviceID = serviceID; |
| | |
| | | if (!isValidInitialStatus(initStatus)) |
| | | { |
| | | Message msg = ERR_DS_INVALID_INIT_STATUS.get(initStatus.toString(), |
| | | serviceID, Short.toString(serverID)); |
| | | serviceID, Integer.toString(serverID)); |
| | | logError(msg); |
| | | } else |
| | | { |
| | |
| | | if (event == StatusMachineEvent.INVALID_EVENT) |
| | | { |
| | | Message msg = ERR_DS_INVALID_REQUESTED_STATUS.get(reqStatus.toString(), |
| | | serviceID, Short.toString(serverID)); |
| | | serviceID, Integer.toString(serverID)); |
| | | logError(msg); |
| | | return; |
| | | } |
| | |
| | | * Get the server ID. |
| | | * @return The server ID. |
| | | */ |
| | | public short getServerId() |
| | | public int getServerId() |
| | | { |
| | | return serverID; |
| | | } |
| | |
| | | * Gets the States of all the Replicas currently in the |
| | | * Topology. |
| | | * When this method is called, a Monitoring message will be sent |
| | | * to the Replication to which this domain is currently connected |
| | | * to the Replication Server to which this domain is currently connected |
| | | * so that it computes a table containing information about |
| | | * all Directory Servers in the topology. |
| | | * This Computation involves communications will all the servers |
| | |
| | | * |
| | | * @return The States of all Replicas in the topology (except us) |
| | | */ |
| | | public Map<Short, ServerState> getReplicaStates() |
| | | public Map<Integer, ServerState> getReplicaStates() |
| | | { |
| | | // publish Monitor Request Message to the Replication Server |
| | | broker.publish(new MonitorRequestMsg(serverID, broker.getRsServerId())); |
| | |
| | | * @return The server ID of the Replication Server to which the domain |
| | | * is currently connected. |
| | | */ |
| | | public short getRsServerId() |
| | | public int getRsServerId() |
| | | { |
| | | return broker.getRsServerId(); |
| | | } |
| | |
| | | { |
| | | // This is the response to a MonitorRequest that was sent earlier |
| | | // build the replicaStates Map. |
| | | replicaStates = new HashMap<Short, ServerState>(); |
| | | replicaStates = new HashMap<Integer, ServerState>(); |
| | | MonitorMsg monitorMsg = (MonitorMsg) msg; |
| | | Iterator<Short> it = monitorMsg.ldapIterator(); |
| | | Iterator<Integer> it = monitorMsg.ldapIterator(); |
| | | while (it.hasNext()) |
| | | { |
| | | short serverId = it.next(); |
| | | int serverId = it.next(); |
| | | replicaStates.put( |
| | | serverId, monitorMsg.getLDAPServerState(serverId)); |
| | | } |
| | |
| | | * passed server, or creates an initial value of 1 error for it if the server |
| | | * is not yet present in the map. |
| | | * @param errorList |
| | | * @param serverId |
| | | * @param sid |
| | | */ |
| | | private void updateAssuredErrorsByServer(Map<Short,Integer> errorsByServer, |
| | | Short serverId) |
| | | private void updateAssuredErrorsByServer(Map<Integer,Integer> errorsByServer, |
| | | Integer sid) |
| | | { |
| | | synchronized (errorsByServer) |
| | | { |
| | | Integer serverErrCount = errorsByServer.get(serverId); |
| | | Integer serverErrCount = errorsByServer.get(sid); |
| | | if (serverErrCount == null) |
| | | { |
| | | // Server not present in list, create an entry with an |
| | | // initial number of errors set to 1 |
| | | errorsByServer.put(serverId, 1); |
| | | errorsByServer.put(sid, 1); |
| | | } else |
| | | { |
| | | // Server already present in list, just increment number of |
| | | // errors for the server |
| | | int val = serverErrCount.intValue(); |
| | | val++; |
| | | errorsByServer.put(serverId, val); |
| | | errorsByServer.put(sid, val); |
| | | } |
| | | } |
| | | } |
| | |
| | | { |
| | | // Some problems detected: message not correclty reached every requested |
| | | // servers. Log problem |
| | | Message errorMsg = NOTE_DS_RECEIVED_ACK_ERROR.get(serviceID, |
| | | Short.toString(serverID), update.toString(), ack.errorsToString()); |
| | | Message errorMsg = NOTE_DS_RECEIVED_ACK_ERROR.get( |
| | | serviceID, Integer.toString(serverID), |
| | | update.toString(), ack.errorsToString()); |
| | | logError(errorMsg); |
| | | |
| | | List<Short> failedServers = ack.getFailedServers(); |
| | | List<Integer> failedServers = ack.getFailedServers(); |
| | | |
| | | // Increment assured replication monitoring counters |
| | | switch (updateAssuredMode) |
| | |
| | | assuredSrWrongStatusUpdates.incrementAndGet(); |
| | | if (failedServers != null) // This should always be the case ! |
| | | { |
| | | for(Short sid : failedServers) |
| | | for(Integer sid : failedServers) |
| | | { |
| | | updateAssuredErrorsByServer( |
| | | assuredSrServerNotAcknowledgedUpdates, sid); |
| | |
| | | assuredSdTimeoutUpdates.incrementAndGet(); |
| | | if (failedServers != null) // This should always be the case ! |
| | | { |
| | | for(Short sid : failedServers) |
| | | for(Integer sid : failedServers) |
| | | { |
| | | updateAssuredErrorsByServer( |
| | | assuredSdServerTimeoutUpdates, sid); |
| | |
| | | private class ExportThread extends DirectoryThread |
| | | { |
| | | // Id of server that will receive updates |
| | | private short target; |
| | | private int target; |
| | | |
| | | /** |
| | | * Constructor for the ExportThread. |
| | | * |
| | | * @param target Id of server that will receive updates |
| | | * @param i Id of server that will receive updates |
| | | */ |
| | | public ExportThread(short target) |
| | | public ExportThread(int i) |
| | | { |
| | | super("Export thread " + serverID); |
| | | this.target = target; |
| | | this.target = i; |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | protected class IEContext |
| | | { |
| | | // Theprivate task that initiated the operation. |
| | | // The private task that initiated the operation. |
| | | Task initializeTask; |
| | | // The destination in the case of an export |
| | | short exportTarget = RoutableMsg.UNKNOWN_SERVER; |
| | | int exportTarget = RoutableMsg.UNKNOWN_SERVER; |
| | | // The source in the case of an import |
| | | short importSource = RoutableMsg.UNKNOWN_SERVER; |
| | | int importSource = RoutableMsg.UNKNOWN_SERVER; |
| | | |
| | | // The total entry count expected to be processed |
| | | long entryCount = 0; |
| | |
| | | * Gets the server id of the exporting server. |
| | | * @return the server id of the exporting server. |
| | | */ |
| | | public short getExportTarget() |
| | | public int getExportTarget() |
| | | { |
| | | return exportTarget; |
| | | } |
| | |
| | | * Gets the server id of the importing server. |
| | | * @return the server id of the importing server. |
| | | */ |
| | | public short getImportSource() |
| | | public int getImportSource() |
| | | { |
| | | return importSource; |
| | | } |
| | |
| | | * @return The source as a short value |
| | | * @throws DirectoryException if the string is not valid |
| | | */ |
| | | public short decodeTarget(String targetString) |
| | | public int decodeTarget(String targetString) |
| | | throws DirectoryException |
| | | { |
| | | short target = 0; |
| | | int target = 0; |
| | | Throwable cause; |
| | | if (targetString.equalsIgnoreCase("all")) |
| | | { |
| | |
| | | // So should be a serverID |
| | | try |
| | | { |
| | | target = Integer.decode(targetString).shortValue(); |
| | | target = Integer.decode(targetString); |
| | | if (target >= 0) |
| | | { |
| | | // FIXME Could we check now that it is a know server in the domain ? |
| | |
| | | * @throws DirectoryException If it was not possible to publish the |
| | | * Initialization message to the Topology. |
| | | */ |
| | | public void initializeRemote(short target, Task initTask) |
| | | public void initializeRemote(int target, Task initTask) |
| | | throws DirectoryException |
| | | { |
| | | initializeRemote(target, serverID, initTask); |
| | |
| | | * server that requests the initialization. |
| | | * |
| | | * @param target The target that should be initialized. |
| | | * @param requestorID The server that initiated the export. |
| | | * @param target2 The server that initiated the export. |
| | | * @param initTask The task that triggers this initialization and that should |
| | | * be updated with its progress. |
| | | * |
| | | * @exception DirectoryException When an error occurs. |
| | | */ |
| | | protected void initializeRemote(short target, short requestorID, |
| | | protected void initializeRemote(int target, int target2, |
| | | Task initTask) throws DirectoryException |
| | | { |
| | | Message msg = NOTE_FULL_UPDATE_ENGAGED_FOR_REMOTE_START.get( |
| | | Short.toString(serverID), |
| | | Integer.toString(serverID), |
| | | serviceID, |
| | | Short.toString(requestorID)); |
| | | Integer.toString(target2)); |
| | | logError(msg); |
| | | |
| | | boolean contextAcquired=false; |
| | |
| | | |
| | | // Send start message to the peer |
| | | InitializeTargetMsg initializeMessage = new InitializeTargetMsg( |
| | | serviceID, serverID, target, requestorID, entryCount); |
| | | serviceID, serverID, target, target2, entryCount); |
| | | |
| | | broker.publish(initializeMessage); |
| | | |
| | |
| | | } |
| | | |
| | | msg = NOTE_FULL_UPDATE_ENGAGED_FOR_REMOTE_END.get( |
| | | Short.toString(serverID), |
| | | Integer.toString(serverID), |
| | | serviceID, |
| | | Short.toString(requestorID)); |
| | | Integer.toString(target2)); |
| | | logError(msg); |
| | | } |
| | | |
| | |
| | | * @throws DirectoryException If it was not possible to publish the |
| | | * Initialization message to the Topology. |
| | | */ |
| | | public void initializeFromRemote(short source) |
| | | public void initializeFromRemote(int source) |
| | | throws DirectoryException |
| | | { |
| | | initializeFromRemote(source, null); |
| | |
| | | * @throws DirectoryException If it was not possible to publish the |
| | | * Initialization message to the Topology. |
| | | */ |
| | | public void initializeRemote(short target) throws DirectoryException |
| | | public void initializeRemote(int target) throws DirectoryException |
| | | { |
| | | initializeRemote(target, null); |
| | | } |
| | |
| | | * @throws DirectoryException If it was not possible to publish the |
| | | * Initialization message to the Topology. |
| | | */ |
| | | public void initializeFromRemote(short source, Task initTask) |
| | | public void initializeFromRemote(int source, Task initTask) |
| | | throws DirectoryException |
| | | { |
| | | if (debugEnabled()) |
| | |
| | | DirectoryException de = null; |
| | | |
| | | Message msg = NOTE_FULL_UPDATE_ENGAGED_FROM_REMOTE_START.get( |
| | | Short.toString(serverID), |
| | | Integer.toString(serverID), |
| | | serviceID, |
| | | Long.toString(initializeMessage.getRequestorID())); |
| | | logError(msg); |
| | |
| | | } |
| | | |
| | | msg = NOTE_FULL_UPDATE_ENGAGED_FROM_REMOTE_END.get( |
| | | Short.toString(serverID), |
| | | Integer.toString(serverID), |
| | | serviceID, |
| | | Long.toString(initializeMessage.getRequestorID())); |
| | | logError(msg); |
| | |
| | | if (newStatus == ServerStatus.INVALID_STATUS) |
| | | { |
| | | Message msg = ERR_DS_CANNOT_CHANGE_STATUS.get(serviceID, |
| | | Short.toString(serverID), status.toString(), event.toString()); |
| | | Integer.toString(serverID), status.toString(), event.toString()); |
| | | logError(msg); |
| | | return; |
| | | } |
| | |
| | | * @throws DirectoryException When the generation ID of the Replication |
| | | * Servers is not the expected value. |
| | | */ |
| | | private void checkGenerationID(long generationID) throws DirectoryException |
| | | private void checkGenerationID(long generationID) |
| | | throws DirectoryException |
| | | { |
| | | boolean flag = false; |
| | | boolean allset = true; |
| | | |
| | | for (int i = 0; i< 10; i++) |
| | | { |
| | | allset = true; |
| | | for (RSInfo rsInfo : getRsList()) |
| | | { |
| | | if (rsInfo.getGenerationId() == generationID) |
| | | { |
| | | flag = true; |
| | | break; |
| | | } |
| | | else |
| | | if (rsInfo.getGenerationId() != generationID) |
| | | { |
| | | try |
| | | { |
| | |
| | | } catch (InterruptedException e) |
| | | { |
| | | } |
| | | allset = false; |
| | | break; |
| | | } |
| | | } |
| | | if (flag) |
| | | if (allset) |
| | | { |
| | | break; |
| | | } |
| | | } |
| | | |
| | | if (!flag) |
| | | if (!allset) |
| | | { |
| | | ResultCode resultCode = ResultCode.OTHER; |
| | | Message message = ERR_RESET_GENERATION_ID_FAILED.get(serviceID); |
| | |
| | | * @return The number of updates sent in assured safe read mode that have not |
| | | * been acknowledged per server. |
| | | */ |
| | | public Map<Short, Integer> getAssuredSrServerNotAcknowledgedUpdates() |
| | | public Map<Integer, Integer> getAssuredSrServerNotAcknowledgedUpdates() |
| | | { |
| | | // Clone a snapshot with synchronized section to have a consistent view in |
| | | // monitoring |
| | | Map<Short, Integer> snapshot = new HashMap<Short, Integer>(); |
| | | Map<Integer, Integer> snapshot = new HashMap<Integer, Integer>(); |
| | | synchronized(assuredSrServerNotAcknowledgedUpdates) |
| | | { |
| | | Set<Short> keySet = assuredSrServerNotAcknowledgedUpdates.keySet(); |
| | | for (Short serverId : keySet) |
| | | Set<Integer> keySet = assuredSrServerNotAcknowledgedUpdates.keySet(); |
| | | for (Integer serverId : keySet) |
| | | { |
| | | Integer i = assuredSrServerNotAcknowledgedUpdates.get(serverId); |
| | | snapshot.put(serverId, i); |
| | |
| | | * @return The number of updates sent in assured safe data mode that have not |
| | | * been acknowledged due to timeout error per server. |
| | | */ |
| | | public Map<Short, Integer> getAssuredSdServerTimeoutUpdates() |
| | | public Map<Integer, Integer> getAssuredSdServerTimeoutUpdates() |
| | | { |
| | | // Clone a snapshot with synchronized section to have a consistent view in |
| | | // monitoring |
| | | Map<Short, Integer> snapshot = new HashMap<Short, Integer>(); |
| | | Map<Integer, Integer> snapshot = new HashMap<Integer, Integer>(); |
| | | synchronized(assuredSdServerTimeoutUpdates) |
| | | { |
| | | Set<Short> keySet = assuredSdServerTimeoutUpdates.keySet(); |
| | | for (Short serverId : keySet) |
| | | Set<Integer> keySet = assuredSdServerTimeoutUpdates.keySet(); |
| | | for (Integer serverId : keySet) |
| | | { |
| | | Integer i = assuredSdServerTimeoutUpdates.get(serverId); |
| | | snapshot.put(serverId, i); |
| | |
| | | assuredSrTimeoutUpdates = new AtomicInteger(0); |
| | | assuredSrWrongStatusUpdates = new AtomicInteger(0); |
| | | assuredSrReplayErrorUpdates = new AtomicInteger(0); |
| | | assuredSrServerNotAcknowledgedUpdates = new HashMap<Short,Integer>(); |
| | | assuredSrServerNotAcknowledgedUpdates = new HashMap<Integer,Integer>(); |
| | | assuredSrReceivedUpdates = new AtomicInteger(0); |
| | | assuredSrReceivedUpdatesAcked = new AtomicInteger(0); |
| | | assuredSrReceivedUpdatesNotAcked = new AtomicInteger(0); |
| | | assuredSdSentUpdates = new AtomicInteger(0); |
| | | assuredSdAcknowledgedUpdates = new AtomicInteger(0); |
| | | assuredSdTimeoutUpdates = new AtomicInteger(0); |
| | | assuredSdServerTimeoutUpdates = new HashMap<Short,Integer>(); |
| | | assuredSdServerTimeoutUpdates = new HashMap<Integer,Integer>(); |
| | | } |
| | | |
| | | /* |
| | |
| | | // -> replay error occured |
| | | ackMsg.setHasReplayError(true); |
| | | // -> replay error occured in our server |
| | | List<Short> idList = new ArrayList<Short>(); |
| | | List<Integer> idList = new ArrayList<Integer>(); |
| | | idList.add(serverID); |
| | | ackMsg.setFailedServers(idList); |
| | | } |
| | |
| | | } else if (assuredMode != AssuredMode.SAFE_DATA_MODE) |
| | | { |
| | | Message errorMsg = ERR_DS_UNKNOWN_ASSURED_MODE.get( |
| | | Short.toString(serverID), msgAssuredMode.toString(), serviceID, |
| | | Integer.toString(serverID), msgAssuredMode.toString(), serviceID, |
| | | msg.toString()); |
| | | logError(errorMsg); |
| | | } else |
| | |
| | | final String ATTR_ASS_SR_SRV = "assured-sr-server-not-acknowledged-updates"; |
| | | type = DirectoryServer.getDefaultAttributeType(ATTR_ASS_SR_SRV); |
| | | builder = new AttributeBuilder(type, ATTR_ASS_SR_SRV); |
| | | Map<Short, Integer> srSrvNotAckUps = |
| | | Map<Integer, Integer> srSrvNotAckUps = |
| | | domain.getAssuredSrServerNotAcknowledgedUpdates(); |
| | | if (srSrvNotAckUps.size() > 0) |
| | | { |
| | | for (Short serverId : srSrvNotAckUps.keySet()) |
| | | for (Integer serverId : srSrvNotAckUps.keySet()) |
| | | { |
| | | String str = serverId + ":" + srSrvNotAckUps.get(serverId); |
| | | builder.add(AttributeValues.create(type, str)); |
| | |
| | | final String ATTR_ASS_SD_SRV = "assured-sd-server-timeout-updates"; |
| | | type = DirectoryServer.getDefaultAttributeType(ATTR_ASS_SD_SRV); |
| | | builder = new AttributeBuilder(type, ATTR_ASS_SD_SRV); |
| | | Map<Short, Integer> sdSrvTimUps = |
| | | Map<Integer, Integer> sdSrvTimUps = |
| | | domain.getAssuredSdServerTimeoutUpdates(); |
| | | if (sdSrvTimUps.size() > 0) |
| | | { |
| | | for (Short serverId : sdSrvTimUps.keySet()) |
| | | for (Integer serverId : sdSrvTimUps.keySet()) |
| | | { |
| | | String str = serverId + ":" + sdSrvTimUps.get(serverId); |
| | | builder.add(AttributeValues.create(type, str)); |
| | |
| | | // Config properties |
| | | private String domainString = null; |
| | | private LDAPReplicationDomain domain = null; |
| | | private short target; |
| | | private int target; |
| | | private long total; |
| | | |
| | | /** |
| | |
| | | private static final DebugTracer TRACER = getTracer(); |
| | | |
| | | private String domainString = null; |
| | | private short source; |
| | | private int source; |
| | | private LDAPReplicationDomain domain = null; |
| | | private TaskState initState; |
| | | |
| | |
| | | attributeType = |
| | | DirectoryServer.getDefaultAttributeType("replicaidentifier"); |
| | | a = Attributes.create(attributeType, |
| | | Short.toString(changeNumber.getServerId())); |
| | | Integer.toString(changeNumber.getServerId())); |
| | | attrList = new ArrayList<Attribute>(1); |
| | | attrList.add(a); |
| | | if(attributeType.isOperational()) |
| | |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Copyright 2007-2008 Sun Microsystems, Inc. |
| | | * Copyright 2007-2009 Sun Microsystems, Inc. |
| | | */ |
| | | package org.opends.server.replication; |
| | | |
| | |
| | | LDAPReplicationDomain domain = null; |
| | | DN baseDn = DN.decode(TEST_ROOT_DN_STRING); |
| | | SynchronizationProvider replicationPlugin = null; |
| | | short brokerId = 2; |
| | | short serverId = 1; |
| | | short replServerId = 81; |
| | | int brokerId = 2; |
| | | int serverId = 1; |
| | | int replServerId = 81; |
| | | int AddSequenceLength = 30; |
| | | |
| | | |
| | |
| | | LDAPReplicationDomain domain = null; |
| | | DN baseDn = DN.decode(TEST_ROOT_DN_STRING); |
| | | SynchronizationProvider replicationPlugin = null; |
| | | short brokerId = 2; |
| | | short serverId = 1; |
| | | short replServerId = 82; |
| | | int brokerId = 2; |
| | | int serverId = 1; |
| | | int replServerId = 82; |
| | | |
| | | cleanDB(); |
| | | |
| | |
| | | LDAPReplicationDomain domain = null; |
| | | DN baseDn = DN.decode(TEST_ROOT_DN_STRING); |
| | | SynchronizationProvider replicationPlugin = null; |
| | | short brokerId = 2; |
| | | short serverId = 1; |
| | | short replServerId = 83; |
| | | int brokerId = 2; |
| | | int serverId = 1; |
| | | int replServerId = 83; |
| | | int AddSequenceLength = 30; |
| | | |
| | | cleanDB(); |
| | |
| | | LDAPReplicationDomain domain = null; |
| | | DN baseDn = DN.decode(TEST_ROOT_DN_STRING); |
| | | SynchronizationProvider replicationPlugin = null; |
| | | short brokerId = 2; |
| | | short serverId = 1; |
| | | short replServerId = 84; |
| | | int brokerId = 2; |
| | | int serverId = 1; |
| | | int replServerId = 84; |
| | | int AddSequenceLength = 30; |
| | | |
| | | cleanDB(); |
| | |
| | | // *********************************************** |
| | | // First set of test are in the cookie mode |
| | | // *********************************************** |
| | | |
| | | // Test that private backend is excluded from ECL |
| | | ECLOnPrivateBackend();replicationServer.clearDb(); |
| | | |
| | | |
| | | // Test remote API (ECL through replication protocol) with empty ECL |
| | | ECLRemoteEmpty();replicationServer.clearDb(); |
| | | |
| | | |
| | | // Test with empty changelog |
| | | ECLEmpty();replicationServer.clearDb(); |
| | | |
| | | // Test all types of ops. |
| | | |
| | | // Test all types of ops. |
| | | ECLAllOps(); // Do not clean the db for the next test |
| | | |
| | | // First and last should be ok whenever a request has been done or not |
| | |
| | | ECLRemoteNonEmpty();replicationServer.clearDb(); |
| | | |
| | | // Test with a mix of domains, a mix of DSes |
| | | ECLTwoDomains(); |
| | | ECLTwoDomains(); |
| | | // changelogDb required NOT empty for the next test |
| | | |
| | | |
| | | // Test ECL after changelog triming |
| | | ECLAfterChangelogTrim();replicationServer.clearDb(); |
| | | |
| | | |
| | | // Persistent search with changesOnly request |
| | | ECLPsearch(true, false);replicationServer.clearDb(); |
| | | |
| | | // Persistent search with init values request |
| | | ECLPsearch(false, false);replicationServer.clearDb(); |
| | | |
| | | |
| | | // Simultaneous psearches |
| | | ECLSimultaneousPsearches();replicationServer.clearDb(); |
| | | |
| | | // Test eligible count method. |
| | | ECLGetEligibleCountTest();replicationServer.clearDb(); |
| | | |
| | | |
| | | // TODO:ECL Test SEARCH abandon and check everything shutdown and cleaned |
| | | // TODO:ECL Test PSEARCH abandon and check everything shutdown and cleaned |
| | | // TODO:ECL Test invalid DN in cookie returns UNWILLING + message |
| | | // TODO:ECL Test the attributes list and values returned in ECL entries |
| | | // TODO:ECL Test search -s base, -s one |
| | | |
| | | // Test directly from the java obect that the changeTimeHeartbeatState |
| | | |
| | | // Test directly from the java obect that the changeTimeHeartbeatState |
| | | // stored are ok. |
| | | ChangeTimeHeartbeatTest();replicationServer.clearDb(); |
| | | |
| | | |
| | | // Test the different forms of filter that are parsed in order to |
| | | // optimize the request. |
| | | ECLFilterTest(); |
| | |
| | | // *********************************************** |
| | | // Second set of test are in the draft compat mode |
| | | // *********************************************** |
| | | |
| | | // Empty replication changelog |
| | | ECLCompatEmpty(); |
| | | |
| | | // Request from an invalid draft change number |
| | | ECLCompatBadSeqnum(); |
| | | |
| | | |
| | | // Write changes and read ECL from start |
| | | int ts = ECLCompatWriteReadAllOps(1); |
| | | |
| | | // Write additional changes and read ECL from a provided draft change number |
| | | ts = ECLCompatWriteReadAllOps(5); |
| | | |
| | | |
| | | // Test request from a provided change number |
| | | ECLCompatReadFrom(6); |
| | | |
| | |
| | | // Test first and last draft changenumber |
| | | ECLCompatTestLimits(1,8); |
| | | |
| | | // Test first and last draft changenumber, a dd a new change, do not |
| | | // Test first and last draft changenumber, a dd a new change, do not |
| | | // search again the ECL, but search fro first and last |
| | | ECLCompatTestLimitsAndAdd(1,8, ts); |
| | | |
| | | // Test DraftCNDb is purged when replication change log is purged |
| | | ECLPurgeDraftCNDbAfterChangelogClear(); |
| | | |
| | | |
| | | // Test first and last are updated |
| | | ECLCompatTestLimits(0,0); |
| | | |
| | |
| | | |
| | | // Persistent search in init + changes mode |
| | | ECLPsearch(false, true); |
| | | |
| | | |
| | | // Test Filter on replication csn |
| | | // TODO: test with optimization when code done. |
| | | ECLFilterOnReplicationCsn();replicationServer.clearDb(); |
| | | |
| | | |
| | | // Test simultaneous persistent searches in draft compat mode. |
| | | ECLSimultaneousPsearches();replicationServer.clearDb(); |
| | | |
| | | |
| | | // *********************************************** |
| | | // Entry attributes |
| | | // *********************************************** |
| | |
| | | ReplicationBroker server2 = null; |
| | | ReplicationBroker server3 = null; |
| | | |
| | | try |
| | | try |
| | | { |
| | | // Create 3 ECL broker |
| | | server1 = openReplicationSession( |
| | | DN.decode("cn=changelog"), (short)1111, |
| | | DN.decode("cn=changelog"), 1111, |
| | | 100, replicationServerPort, 1000, false); |
| | | assertTrue(server1.isConnected()); |
| | | server2 = openReplicationSession( |
| | | DN.decode("cn=changelog"), (short)2222, |
| | | DN.decode("cn=changelog"), 2222, |
| | | 100, replicationServerPort,1000, false); |
| | | assertTrue(server2.isConnected()); |
| | | server3 = openReplicationSession( |
| | | DN.decode("cn=changelog"), (short)3333, |
| | | DN.decode("cn=changelog"), 3333, |
| | | 100, replicationServerPort,1000, false); |
| | | assertTrue(server3.isConnected()); |
| | | |
| | | // Test broker1 receives only Done |
| | | ReplicationMsg msg; |
| | | int msgc=0; |
| | | do |
| | | do |
| | | { |
| | | msg = server1.receive(); |
| | | msgc++; |
| | |
| | | |
| | | // Test broker2 receives only Done |
| | | msgc=0; |
| | | do |
| | | do |
| | | { |
| | | msg = server2.receive(); |
| | | msgc++; |
| | |
| | | |
| | | // Test broker3 receives only Done |
| | | msgc=0; |
| | | do |
| | | do |
| | | { |
| | | msg = server3.receive(); |
| | | msgc++; |
| | |
| | | server1.stop(); |
| | | server2.stop(); |
| | | server3.stop(); |
| | | debugInfo(tn, "Ending test successfully\n\n"); |
| | | debugInfo(tn, "Ending test successfully\n\n"); |
| | | } |
| | | catch(Exception e) |
| | | { |
| | | fail("Ending test " + tn + " with exception:" |
| | | + stackTraceToSingleLineString(e)); |
| | | + stackTraceToSingleLineString(e)); |
| | | } |
| | | } |
| | | |
| | |
| | | ReplicationBroker server02 = null; |
| | | ReplicationBroker serverECL = null; |
| | | |
| | | try |
| | | try |
| | | { |
| | | // create 2 reguler brokers on the 2 suffixes |
| | | server01 = openReplicationSession( |
| | | DN.decode(TEST_ROOT_DN_STRING), (short) 1201, |
| | | DN.decode(TEST_ROOT_DN_STRING), 1201, |
| | | 100, replicationServerPort, |
| | | 1000, true); |
| | | |
| | | server02 = openReplicationSession( |
| | | DN.decode(TEST_ROOT_DN_STRING2), (short) 1202, |
| | | DN.decode(TEST_ROOT_DN_STRING2), 1202, |
| | | 100, replicationServerPort, |
| | | 1000, true, EMPTY_DN_GENID); |
| | | |
| | | // create and publish 1 change on each suffix |
| | | long time = TimeThread.getTime(); |
| | | int ts = 1; |
| | | ChangeNumber cn1 = new ChangeNumber(time, ts++, (short)1201); |
| | | ChangeNumber cn1 = new ChangeNumber(time, ts++, 1201); |
| | | DeleteMsg delMsg1 = |
| | | new DeleteMsg("o=" + tn + "1," + TEST_ROOT_DN_STRING, cn1, "ECLBasicMsg1uid"); |
| | | server01.publish(delMsg1); |
| | | debugInfo(tn, "publishes:" + delMsg1); |
| | | |
| | | ChangeNumber cn2 = new ChangeNumber(time, ts++, (short)1202); |
| | | ChangeNumber cn2 = new ChangeNumber(time, ts++, 1202); |
| | | DeleteMsg delMsg2 = |
| | | new DeleteMsg("o=" + tn + "2," + TEST_ROOT_DN_STRING2, cn2, "ECLBasicMsg2uid"); |
| | | server02.publish(delMsg2); |
| | |
| | | |
| | | // open ECL broker |
| | | serverECL = openReplicationSession( |
| | | DN.decode("cn=changelog"), (short)10, |
| | | DN.decode("cn=changelog"), 10, |
| | | 100, replicationServerPort, 1000, false); |
| | | assertTrue(serverECL.isConnected()); |
| | | |
| | |
| | | catch(Exception e) |
| | | { |
| | | fail("Ending test " + tn + " with exception:" |
| | | + stackTraceToSingleLineString(e)); |
| | | + stackTraceToSingleLineString(e)); |
| | | } |
| | | } |
| | | |
| | |
| | | catch(LDAPException e) |
| | | { |
| | | fail("Ending test " + tn + " with exception e=" |
| | | + stackTraceToSingleLineString(e)); |
| | | + stackTraceToSingleLineString(e)); |
| | | } |
| | | } |
| | | |
| | |
| | | private ArrayList<Control> createControls(String cookie) |
| | | { |
| | | ExternalChangelogRequestControl control = |
| | | new ExternalChangelogRequestControl(true, |
| | | new ExternalChangelogRequestControl(true, |
| | | new MultiDomainServerState(cookie)); |
| | | ArrayList<Control> controls = new ArrayList<Control>(0); |
| | | controls.add(control); |
| | |
| | | try |
| | | { |
| | | ReplicationBroker server01 = openReplicationSession( |
| | | DN.decode(TEST_ROOT_DN_STRING), (short) 1201, |
| | | DN.decode(TEST_ROOT_DN_STRING), 1201, |
| | | 100, replicationServerPort, |
| | | 1000, true); |
| | | |
| | | // create and publish 1 change on each suffix |
| | | long time = TimeThread.getTime(); |
| | | int ts = 1; |
| | | ChangeNumber cn1 = new ChangeNumber(time, ts++, (short)1201); |
| | | ChangeNumber cn1 = new ChangeNumber(time, ts++, 1201); |
| | | DeleteMsg delMsg1 = |
| | | new DeleteMsg("o=" + tn + "1," + TEST_ROOT_DN_STRING, cn1, "ECLBasicMsg1uid"); |
| | | server01.publish(delMsg1); |
| | |
| | | SortedSet<String> replServers = new TreeSet<String>(); |
| | | replServers.add("localhost:"+replicationServerPort); |
| | | DomainFakeCfg domainConf = |
| | | new DomainFakeCfg(baseDn2, (short) 1602, replServers); |
| | | new DomainFakeCfg(baseDn2, 1602, replServers); |
| | | LDAPReplicationDomain domain2 = MultimasterReplication.createNewDomain(domainConf); |
| | | SynchronizationProvider replicationPlugin = new MultimasterReplication(); |
| | | replicationPlugin.completeSynchronizationProvider(); |
| | |
| | | // Search on ECL from start on all suffixes |
| | | String cookie = ""; |
| | | ExternalChangelogRequestControl control = |
| | | new ExternalChangelogRequestControl(true, |
| | | new ExternalChangelogRequestControl(true, |
| | | new MultiDomainServerState(cookie)); |
| | | ArrayList<Control> controls = new ArrayList<Control>(0); |
| | | controls.add(control); |
| | |
| | | InternalSearchOperation searchOp = connection.processSearch( |
| | | ByteString.valueOf("cn=changelog"), |
| | | SearchScope.WHOLE_SUBTREE, |
| | | DereferencePolicy.NEVER_DEREF_ALIASES, |
| | | DereferencePolicy.NEVER_DEREF_ALIASES, |
| | | 0, // Size limit |
| | | 0, // Time limit |
| | | false, // Types only |
| | |
| | | for (SearchResultEntry resultEntry : entries) |
| | | { |
| | | i++; |
| | | // Expect |
| | | // Expect |
| | | debugInfo(tn, "Entry returned when test2 is public =" + |
| | | resultEntry.toLDIFString()); |
| | | |
| | | |
| | | // Test entry attributes |
| | | //if (i==2) |
| | | //{ |
| | | // checkPossibleValues(resultEntry,"targetobjectclass","top","organization"); |
| | | // checkPossibleValues(resultEntry,"targetobjectclass","top","organization"); |
| | | //} |
| | | } |
| | | } |
| | |
| | | searchOp = connection.processSearch( |
| | | ByteString.valueOf("cn=changelog"), |
| | | SearchScope.WHOLE_SUBTREE, |
| | | DereferencePolicy.NEVER_DEREF_ALIASES, |
| | | DereferencePolicy.NEVER_DEREF_ALIASES, |
| | | 0, // Size limit |
| | | 0, // Time limit |
| | | false, // Types only |
| | |
| | | attributes, |
| | | controls, |
| | | null); |
| | | |
| | | |
| | | // Expect success and only entry from o=test returned |
| | | assertEquals(searchOp.getResultCode(), ResultCode.SUCCESS, |
| | | searchOp.getErrorMessage().toString() + searchOp.getAdditionalLogMessage()); |
| | |
| | | if (entries != null) |
| | | for (SearchResultEntry resultEntry : entries) |
| | | { |
| | | // Expect |
| | | // Expect |
| | | debugInfo(tn, "Entry returned when test2 is private =" |
| | | + resultEntry.toLDIFString()); |
| | | } |
| | |
| | | assertTrue(expectedLastCookie.equalsTo(new MultiDomainServerState(lastCookie)), |
| | | " Expected last cookie attribute value:" + expectedLastCookie + |
| | | " Read from server: " + lastCookie + " are equal :"); |
| | | |
| | | |
| | | // Cleaning |
| | | if (domain2 != null) |
| | | MultimasterReplication.deleteDomain(baseDn2); |
| | | if (replicationPlugin != null) |
| | | DirectoryServer.deregisterSynchronizationProvider(replicationPlugin); |
| | | removeTestBackend2(backend2); |
| | | |
| | | |
| | | server01.stop(); |
| | | } |
| | | catch(Exception e) |
| | | { |
| | | fail("Ending test " + tn + " with exception:" |
| | | + stackTraceToSingleLineString(e)); |
| | | + stackTraceToSingleLineString(e)); |
| | | } |
| | | debugInfo(tn, "Ending test successfully"); |
| | | } |
| | |
| | | /** |
| | | * From embebbded ECL |
| | | * Search ECL with 4 messages on 2 suffixes from 2 brokers |
| | | * |
| | | * |
| | | */ |
| | | private void ECLTwoDomains() |
| | | { |
| | |
| | | |
| | | // -- |
| | | ReplicationBroker s1test = openReplicationSession( |
| | | DN.decode(TEST_ROOT_DN_STRING), (short) 1201, |
| | | DN.decode(TEST_ROOT_DN_STRING), 1201, |
| | | 100, replicationServerPort, |
| | | 1000, true); |
| | | |
| | | ReplicationBroker s2test2 = openReplicationSession( |
| | | DN.decode(TEST_ROOT_DN_STRING2), (short) 1202, |
| | | DN.decode(TEST_ROOT_DN_STRING2), 1202, |
| | | 100, replicationServerPort, |
| | | 1000, true, EMPTY_DN_GENID); |
| | | sleep(500); |
| | |
| | | |
| | | // Changes are : |
| | | // s1 s2 |
| | | // o=test msg1/msg4 |
| | | // o=test msg1/msg4 |
| | | // o=test2 msg2/msg2 |
| | | String cookie= ""; |
| | | |
| | |
| | | attributes.add("*"); |
| | | |
| | | debugInfo(tn, "Search with cookie=" + cookie + "\""); |
| | | InternalSearchOperation searchOp = |
| | | InternalSearchOperation searchOp = |
| | | connection.processSearch( |
| | | ByteString.valueOf("cn=changelog"), |
| | | SearchScope.WHOLE_SUBTREE, |
| | | DereferencePolicy.NEVER_DEREF_ALIASES, |
| | | DereferencePolicy.NEVER_DEREF_ALIASES, |
| | | 0, // Size limit |
| | | 0, // Time limit |
| | | false, // Types only |
| | |
| | | attributes.add("*"); |
| | | |
| | | ExternalChangelogRequestControl control = |
| | | new ExternalChangelogRequestControl(true, |
| | | new ExternalChangelogRequestControl(true, |
| | | new MultiDomainServerState(cookie)); |
| | | ArrayList<Control> controls = new ArrayList<Control>(0); |
| | | controls.add(control); |
| | |
| | | searchOp = connection.processSearch( |
| | | ByteString.valueOf("cn=changelog"), |
| | | SearchScope.WHOLE_SUBTREE, |
| | | DereferencePolicy.NEVER_DEREF_ALIASES, |
| | | DereferencePolicy.NEVER_DEREF_ALIASES, |
| | | 0, // Size limit |
| | | 0, // Time limit |
| | | false, // Types only |
| | |
| | | // o=test2 msg3 msg2 |
| | | |
| | | control = |
| | | new ExternalChangelogRequestControl(true, |
| | | new ExternalChangelogRequestControl(true, |
| | | new MultiDomainServerState(cookie)); |
| | | controls = new ArrayList<Control>(0); |
| | | controls.add(control); |
| | |
| | | searchOp = connection.processSearch( |
| | | ByteString.valueOf("cn=changelog"), |
| | | SearchScope.WHOLE_SUBTREE, |
| | | DereferencePolicy.NEVER_DEREF_ALIASES, |
| | | DereferencePolicy.NEVER_DEREF_ALIASES, |
| | | 0, // Size limit |
| | | 0, // Time limit |
| | | false, // Types only |
| | |
| | | cookie=""; |
| | | |
| | | control = |
| | | new ExternalChangelogRequestControl(true, |
| | | new ExternalChangelogRequestControl(true, |
| | | new MultiDomainServerState(cookie)); |
| | | controls = new ArrayList<Control>(0); |
| | | controls.add(control); |
| | | |
| | | debugInfo(tn, "Search with cookie=" + cookie + "\" and filter on domain=" + |
| | | debugInfo(tn, "Search with cookie=" + cookie + "\" and filter on domain=" + |
| | | "(targetDN=*direct*,o=test)"); |
| | | searchOp = connection.processSearch( |
| | | ByteString.valueOf("cn=changelog"), |
| | | SearchScope.WHOLE_SUBTREE, |
| | | DereferencePolicy.NEVER_DEREF_ALIASES, |
| | | DereferencePolicy.NEVER_DEREF_ALIASES, |
| | | 0, // Size limit |
| | | 0, // Time limit |
| | | false, // Types only |
| | |
| | | // |
| | | // -- |
| | | ReplicationBroker s1test2 = openReplicationSession( |
| | | DN.decode(TEST_ROOT_DN_STRING2), (short) 1203, |
| | | DN.decode(TEST_ROOT_DN_STRING2), 1203, |
| | | 100, replicationServerPort, |
| | | 1000, true, EMPTY_DN_GENID); |
| | | |
| | | ReplicationBroker s2test = openReplicationSession( |
| | | DN.decode(TEST_ROOT_DN_STRING), (short) 1204, |
| | | DN.decode(TEST_ROOT_DN_STRING), 1204, |
| | | 100, replicationServerPort, |
| | | 1000, true); |
| | | sleep(500); |
| | |
| | | assertTrue(expectedLastCookie.equalsTo(new MultiDomainServerState(lastCookie)), |
| | | " Expected last cookie attribute value:" + expectedLastCookie + |
| | | " Read from server: " + lastCookie + " are equal :"); |
| | | |
| | | |
| | | s1test.stop(); |
| | | s1test2.stop(); |
| | | s2test.stop(); |
| | |
| | | catch(Exception e) |
| | | { |
| | | fail("Ending test " + tn + "with exception:\n" |
| | | + stackTraceToSingleLineString(e)); |
| | | + stackTraceToSingleLineString(e)); |
| | | } |
| | | debugInfo(tn, "Ending test successfully"); |
| | | } |
| | |
| | | attributes.add("*"); |
| | | |
| | | debugInfo(tn, "Search with cookie=" + cookie + "\""); |
| | | InternalSearchOperation searchOp = |
| | | InternalSearchOperation searchOp = |
| | | connection.processSearch( |
| | | ByteString.valueOf("cn=changelog"), |
| | | SearchScope.WHOLE_SUBTREE, |
| | | DereferencePolicy.NEVER_DEREF_ALIASES, |
| | | DereferencePolicy.NEVER_DEREF_ALIASES, |
| | | 0, // Size limit |
| | | 0, // Time limit |
| | | false, // Types only |
| | |
| | | // Test from last cookie |
| | | // search on 'cn=changelog' |
| | | debugInfo(tn, "Search with cookie=" + cookie + "\""); |
| | | searchOp = |
| | | searchOp = |
| | | connection.processSearch( |
| | | ByteString.valueOf("cn=changelog"), |
| | | SearchScope.WHOLE_SUBTREE, |
| | | DereferencePolicy.NEVER_DEREF_ALIASES, |
| | | DereferencePolicy.NEVER_DEREF_ALIASES, |
| | | 0, // Size limit |
| | | 0, // Time limit |
| | | false, // Types only |
| | |
| | | } |
| | | } |
| | | assertEquals(searchOp.getResultCode(), ResultCode.SUCCESS); |
| | | assertEquals(searchOp.getSearchEntries().size(), 0); |
| | | assertEquals(searchOp.getSearchEntries().size(), 0); |
| | | } |
| | | catch(Exception e) |
| | | { |
| | | fail("Ending test " + tn + "with exception:\n" |
| | | + stackTraceToSingleLineString(e)); |
| | | + stackTraceToSingleLineString(e)); |
| | | } |
| | | debugInfo(tn, "Ending test successfully"); |
| | | } |
| | | |
| | | |
| | | |
| | | private String readLastCookie(String tn) |
| | | { |
| | | String cookie = ""; |
| | |
| | | |
| | | try |
| | | { |
| | | InternalSearchOperation searchOp = |
| | | InternalSearchOperation searchOp = |
| | | connection.processSearch( |
| | | ByteString.valueOf(""), |
| | | SearchScope.BASE_OBJECT, |
| | | DereferencePolicy.NEVER_DEREF_ALIASES, |
| | | DereferencePolicy.NEVER_DEREF_ALIASES, |
| | | 0, // Size limit |
| | | 0, // Time limit |
| | | false, // Types only |
| | |
| | | catch(Exception e) |
| | | { |
| | | fail("Ending test " + tn + " with exception:\n" |
| | | + stackTraceToSingleLineString(e)); |
| | | + stackTraceToSingleLineString(e)); |
| | | } |
| | | return cookie; |
| | | } |
| | | |
| | | |
| | | // simple update to be received |
| | | private void ECLAllOps() |
| | | { |
| | |
| | | |
| | | // Creates broker on o=test |
| | | ReplicationBroker server01 = openReplicationSession( |
| | | DN.decode(TEST_ROOT_DN_STRING), (short) 1201, |
| | | DN.decode(TEST_ROOT_DN_STRING), 1201, |
| | | 100, replicationServerPort, |
| | | 1000, true); |
| | | int ts = 1; |
| | | |
| | | // Creates broker on o=test2 |
| | | ReplicationBroker server02 = openReplicationSession( |
| | | DN.decode(TEST_ROOT_DN_STRING2), (short) 1202, |
| | | DN.decode(TEST_ROOT_DN_STRING2), 1202, |
| | | 100, replicationServerPort, |
| | | 1000, true); |
| | | 1000, true); |
| | | |
| | | String user1entryUUID = "11111111-1111-1111-1111-111111111111"; |
| | | String baseUUID = "22222222-2222-2222-2222-222222222222"; |
| | | |
| | | |
| | | // Publish DEL |
| | | ChangeNumber cn1 = new ChangeNumber(TimeThread.getTime(), ts++, (short)1201); |
| | | ChangeNumber cn1 = new ChangeNumber(TimeThread.getTime(), ts++, 1201); |
| | | DeleteMsg delMsg = |
| | | new DeleteMsg("uid="+tn+"1," + TEST_ROOT_DN_STRING, cn1, tn+"uuid1"); |
| | | server01.publish(delMsg); |
| | | debugInfo(tn, " publishes " + delMsg.getChangeNumber()); |
| | | |
| | | // Publish ADD |
| | | ChangeNumber cn2 = new ChangeNumber(TimeThread.getTime(), ts++, (short)1201); |
| | | ChangeNumber cn2 = new ChangeNumber(TimeThread.getTime(), ts++, 1201); |
| | | String lentry = new String("dn: uid="+tn+"2," + TEST_ROOT_DN_STRING + "\n" |
| | | + "objectClass: top\n" + "objectClass: domain\n" |
| | | + "entryUUID: "+user1entryUUID+"\n"); |
| | | Entry entry = TestCaseUtils.entryFromLdifString(lentry); |
| | | AddMsg addMsg = new AddMsg( |
| | | cn2, |
| | | cn2, |
| | | "uid="+tn+"2," + TEST_ROOT_DN_STRING, |
| | | user1entryUUID, |
| | | baseUUID, |
| | | entry.getObjectClassAttribute(), |
| | | entry.getAttributes(), |
| | | user1entryUUID, |
| | | baseUUID, |
| | | entry.getObjectClassAttribute(), |
| | | entry.getAttributes(), |
| | | new ArrayList<Attribute>()); |
| | | server01.publish(addMsg); |
| | | debugInfo(tn, " publishes " + addMsg.getChangeNumber()); |
| | | |
| | | // Publish DEL |
| | | /* |
| | | ChangeNumber cn12 = new ChangeNumber(TimeThread.getTime(), ts++, (short)1202); |
| | | ChangeNumber cn12 = new ChangeNumber(TimeThread.getTime(), ts++, 1202); |
| | | DeleteMsg delMsg2 = |
| | | new DeleteMsg("uid="+tn+"12," + TEST_ROOT_DN_STRING2, cn12, tn+"uuid12"); |
| | | server02.publish(delMsg2); |
| | |
| | | */ |
| | | |
| | | // Publish MOD |
| | | ChangeNumber cn3 = new ChangeNumber(TimeThread.getTime(), ts++, (short)1201); |
| | | ChangeNumber cn3 = new ChangeNumber(TimeThread.getTime(), ts++, 1201); |
| | | Attribute attr1 = Attributes.create("description", "new value"); |
| | | Modification mod1 = new Modification(ModificationType.REPLACE, attr1); |
| | | List<Modification> mods = new ArrayList<Modification>(); |
| | |
| | | |
| | | // Publish modDN |
| | | DN newSuperior = DN.decode(TEST_ROOT_DN_STRING2); |
| | | ChangeNumber cn4 = new ChangeNumber(TimeThread.getTime(), ts++, (short)1201); |
| | | ChangeNumber cn4 = new ChangeNumber(TimeThread.getTime(), ts++, 1201); |
| | | ModifyDNOperationBasis op = new ModifyDNOperationBasis(connection, 1, 1, null, |
| | | DN.decode("uid="+tn+"4," + TEST_ROOT_DN_STRING), // entryDN |
| | | RDN.decode("uid="+tn+"new4"), // new rdn |
| | |
| | | attributes.add("*"); |
| | | |
| | | ExternalChangelogRequestControl control = |
| | | new ExternalChangelogRequestControl(true, |
| | | new ExternalChangelogRequestControl(true, |
| | | new MultiDomainServerState()); |
| | | ArrayList<Control> controls = new ArrayList<Control>(0); |
| | | controls.add(control); |
| | | |
| | | debugInfo(tn, "Search with cookie=" + cookie + "\" filter=" + |
| | | debugInfo(tn, "Search with cookie=" + cookie + "\" filter=" + |
| | | "(targetdn=*"+tn+"*,o=test)"); |
| | | InternalSearchOperation searchOp = |
| | | InternalSearchOperation searchOp = |
| | | connection.processSearch( |
| | | ByteString.valueOf("cn=changelog"), |
| | | SearchScope.WHOLE_SUBTREE, |
| | | DereferencePolicy.NEVER_DEREF_ALIASES, |
| | | DereferencePolicy.NEVER_DEREF_ALIASES, |
| | | 0, // Size limit |
| | | 0, // Time limit |
| | | false, // Types only |
| | |
| | | String cookie2 = "o=test:"+cn2.toString()+";o=test2:;"; |
| | | String cookie3 = "o=test:"+cn3.toString()+";o=test2:;"; |
| | | String cookie4 = "o=test:"+cn4.toString()+";o=test2:;"; |
| | | |
| | | |
| | | assertEquals(searchOp.getSearchEntries().size(), 4); |
| | | LinkedList<SearchResultEntry> entries = searchOp.getSearchEntries(); |
| | | if (entries != null) |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | // Test the response control with ldapsearch tool |
| | | String result = ldapsearch("cn=changelog"); |
| | | debugInfo(tn, "Entries:" + result); |
| | |
| | | assertTrue(ctrlList.get(1).equals(cookie2)); |
| | | assertTrue(ctrlList.get(2).equals(cookie3)); |
| | | assertTrue(ctrlList.get(3).equals(cookie4)); |
| | | |
| | | |
| | | server01.stop(); |
| | | if (server02 != null) |
| | | server02.stop(); |
| | |
| | | catch(Exception e) |
| | | { |
| | | fail("Ending test " + tn + " with exception:\n" |
| | | + stackTraceToSingleLineString(e)); |
| | | + stackTraceToSingleLineString(e)); |
| | | } |
| | | debugInfo(tn, "Ending test with success"); |
| | | } |
| | |
| | | String encodedValue = av.toString(); |
| | | assertTrue(encodedValue.equalsIgnoreCase(expectedValue), |
| | | "In entry " + entry + " attr <" + attrName + "> equals " + |
| | | av + " instead of expected value " + expectedValue); |
| | | av + " instead of expected value " + expectedValue); |
| | | } |
| | | catch(Exception e) |
| | | { |
| | | assertTrue(false, |
| | | "In entry " + entry + " attr <" + attrName + "> equals " + |
| | | av + " instead of expected value " + expectedValue); |
| | | av + " instead of expected value " + expectedValue); |
| | | } |
| | | } |
| | | |
| | | |
| | | private static String getAttributeValue(Entry entry, String attrName) |
| | | { |
| | | AttributeValue av = null; |
| | |
| | | return null; |
| | | } |
| | | |
| | | private static void checkPossibleValues(Entry entry, String attrName, |
| | | private static void checkPossibleValues(Entry entry, String attrName, |
| | | String expectedValue1, String expectedValue2) |
| | | { |
| | | AttributeValue av = null; |
| | |
| | | encodedValue.equalsIgnoreCase(expectedValue2)), |
| | | "In entry " + entry + " attr <" + attrName + "> equals " + |
| | | av + " instead of one of the expected values " + expectedValue1 |
| | | + " or " + expectedValue2); |
| | | + " or " + expectedValue2); |
| | | } |
| | | catch(Exception e) |
| | | { |
| | | assertTrue(false, |
| | | "In entry " + entry + " attr <" + attrName + "> equals " + |
| | | av + " instead of one of the expected values " + expectedValue1 |
| | | + " or " + expectedValue2); |
| | | + " or " + expectedValue2); |
| | | } |
| | | } |
| | | |
| | | private static void checkValues(Entry entry, String attrName, |
| | | private static void checkValues(Entry entry, String attrName, |
| | | Set<String> expectedValues) |
| | | { |
| | | AttributeValue av = null; |
| | |
| | | */ |
| | | private void ECLPsearch(boolean changesOnly, boolean compatMode) |
| | | { |
| | | String tn = "ECLPsearch_" + String.valueOf(changesOnly) + "_" + |
| | | String tn = "ECLPsearch_" + String.valueOf(changesOnly) + "_" + |
| | | String.valueOf(compatMode); |
| | | debugInfo(tn, "Starting test \n\n"); |
| | | Socket s =null; |
| | |
| | | { |
| | | // Create broker on suffix |
| | | ReplicationBroker server01 = openReplicationSession( |
| | | DN.decode(TEST_ROOT_DN_STRING), (short) 1201, |
| | | DN.decode(TEST_ROOT_DN_STRING), 1201, |
| | | 100, replicationServerPort, |
| | | 1000, true); |
| | | int ts = 1; |
| | | |
| | | // Produce update on this suffix |
| | | ChangeNumber cn = new ChangeNumber(TimeThread.getTime(), ts++, (short)1201); |
| | | ChangeNumber cn = new ChangeNumber(TimeThread.getTime(), ts++, 1201); |
| | | DeleteMsg delMsg = |
| | | new DeleteMsg("uid=" + tn + "1," + TEST_ROOT_DN_STRING, cn, |
| | | new DeleteMsg("uid=" + tn + "1," + TEST_ROOT_DN_STRING, cn, |
| | | "11111111-1112-1113-1114-111111111114"); |
| | | debugInfo(tn, " publishing " + delMsg.getChangeNumber()); |
| | | server01.publish(delMsg); |
| | |
| | | { |
| | | while ((searchEntries<1) && (message = r.readMessage()) != null) |
| | | { |
| | | debugInfo(tn, "Init search Result=" + |
| | | debugInfo(tn, "Init search Result=" + |
| | | message.getProtocolOpType() + message + " " + searchEntries); |
| | | switch (message.getProtocolOpType()) |
| | | { |
| | |
| | | } |
| | | catch(Exception e) |
| | | { |
| | | fail("init search failed with e=" + stackTraceToSingleLineString(e)); |
| | | fail("init search failed with e=" + stackTraceToSingleLineString(e)); |
| | | } |
| | | debugInfo(tn, "INIT search done with success. searchEntries=" |
| | | + searchEntries + " #searchesDone="+ searchesDone); |
| | | } |
| | | |
| | | // Produces change 2 |
| | | cn = new ChangeNumber(TimeThread.getTime(), ts++, (short)1201); |
| | | cn = new ChangeNumber(TimeThread.getTime(), ts++, 1201); |
| | | String expectedDn = "uid=" + tn + "2," + TEST_ROOT_DN_STRING; |
| | | delMsg = new DeleteMsg(expectedDn, cn, |
| | | "11111111-1112-1113-1114-111111111115"); |
| | |
| | | message = null; |
| | | while ((searchEntries<1) && (message = r.readMessage()) != null) |
| | | { |
| | | debugInfo(tn, "psearch search Result=" + |
| | | debugInfo(tn, "psearch search Result=" + |
| | | message.getProtocolOpType() + message); |
| | | switch (message.getProtocolOpType()) |
| | | { |
| | |
| | | searchResultDone = null; |
| | | while ((searchesDone==0) && (message = r.readMessage()) != null) |
| | | { |
| | | debugInfo(tn, "ACI test : message returned " + |
| | | debugInfo(tn, "ACI test : message returned " + |
| | | message.getProtocolOpType() + message); |
| | | switch (message.getProtocolOpType()) |
| | | { |
| | |
| | | |
| | | case LDAPConstants.OP_TYPE_SEARCH_RESULT_DONE: |
| | | searchResultDone = message.getSearchResultDoneProtocolOp(); |
| | | assertEquals(searchResultDone.getResultCode(), |
| | | assertEquals(searchResultDone.getResultCode(), |
| | | ResultCode.SUCCESS.getIntValue()); |
| | | // assertEquals(InvocationCounterPlugin.waitForPostResponse(), 1); |
| | | searchesDone++; |
| | |
| | | assertTrue(searchesDone==1); |
| | | // but returning no entry |
| | | assertEquals(searchEntries,0, "Bad search entry# in ACI test of " + tn); |
| | | } |
| | | } |
| | | |
| | | try { s.close(); } catch (Exception e) {}; |
| | | sleep(1000); |
| | |
| | | { |
| | | // Create broker on o=test |
| | | ReplicationBroker server01 = openReplicationSession( |
| | | DN.decode(TEST_ROOT_DN_STRING), (short) 1201, |
| | | DN.decode(TEST_ROOT_DN_STRING), 1201, |
| | | 100, replicationServerPort, |
| | | 1000, true); |
| | | int ts = 1; |
| | | |
| | | // Create broker on o=test2 |
| | | ReplicationBroker server02 = openReplicationSession( |
| | | DN.decode(TEST_ROOT_DN_STRING2), (short) 1202, |
| | | DN.decode(TEST_ROOT_DN_STRING2), 1202, |
| | | 100, replicationServerPort, |
| | | 1000, true, EMPTY_DN_GENID); |
| | | |
| | | // Produce update 1 |
| | | ChangeNumber cn1 = |
| | | new ChangeNumber(TimeThread.getTime(), ts++, (short)1201); |
| | | ChangeNumber cn1 = |
| | | new ChangeNumber(TimeThread.getTime(), ts++, 1201); |
| | | DeleteMsg delMsg1 = |
| | | new DeleteMsg("uid=" + tn + "1," + TEST_ROOT_DN_STRING, cn1, |
| | | new DeleteMsg("uid=" + tn + "1," + TEST_ROOT_DN_STRING, cn1, |
| | | "11111111-1111-1111-1111-111111111111"); |
| | | debugInfo(tn, " publishing " + delMsg1); |
| | | server01.publish(delMsg1); |
| | | this.sleep(500); // let's be sure the message is in the RS |
| | | |
| | | // Produce update 2 |
| | | ChangeNumber cn2 = |
| | | new ChangeNumber(TimeThread.getTime(), ts++, (short)1202); |
| | | ChangeNumber cn2 = |
| | | new ChangeNumber(TimeThread.getTime(), ts++, 1202); |
| | | DeleteMsg delMsg2 = |
| | | new DeleteMsg("uid=" + tn + "2," + TEST_ROOT_DN_STRING2, cn2, |
| | | new DeleteMsg("uid=" + tn + "2," + TEST_ROOT_DN_STRING2, cn2, |
| | | "22222222-2222-2222-2222-222222222222"); |
| | | debugInfo(tn, " publishing " + delMsg2); |
| | | server02.publish(delMsg2); |
| | | this.sleep(500); // let's be sure the message is in the RS |
| | | |
| | | // Produce update 3 |
| | | ChangeNumber cn3 = |
| | | new ChangeNumber(TimeThread.getTime(), ts++, (short)1202); |
| | | ChangeNumber cn3 = |
| | | new ChangeNumber(TimeThread.getTime(), ts++, 1202); |
| | | DeleteMsg delMsg3 = |
| | | new DeleteMsg("uid=" + tn + "3," + TEST_ROOT_DN_STRING2, cn3, |
| | | new DeleteMsg("uid=" + tn + "3," + TEST_ROOT_DN_STRING2, cn3, |
| | | "33333333-3333-3333-3333-333333333333"); |
| | | debugInfo(tn, " publishing " + delMsg3); |
| | | server02.publish(delMsg3); |
| | |
| | | { |
| | | while ((searchEntries<1) && (message = r1.readMessage()) != null) |
| | | { |
| | | debugInfo(tn, "Search1 Result=" + |
| | | debugInfo(tn, "Search1 Result=" + |
| | | message.getProtocolOpType() + " " + message); |
| | | switch (message.getProtocolOpType()) |
| | | { |
| | |
| | | } |
| | | catch(Exception e) |
| | | { |
| | | fail("Search1 failed with e=" + stackTraceToSingleLineString(e)); |
| | | fail("Search1 failed with e=" + stackTraceToSingleLineString(e)); |
| | | } |
| | | debugInfo(tn, "Search1 done with success. searchEntries=" |
| | | + searchEntries + " #searchesDone="+ searchesDone); |
| | | |
| | | |
| | | searchEntries = 0; |
| | | message = null; |
| | | try |
| | |
| | | + " expected to return change " + cn2 + " & " + cn3); |
| | | while ((searchEntries<2) && (message = r2.readMessage()) != null) |
| | | { |
| | | debugInfo(tn, "Search 2 Result=" + |
| | | debugInfo(tn, "Search 2 Result=" + |
| | | message.getProtocolOpType() + message); |
| | | switch (message.getProtocolOpType()) |
| | | { |
| | |
| | | } |
| | | catch(Exception e) |
| | | { |
| | | fail("Search2 failed with e=" + stackTraceToSingleLineString(e)); |
| | | fail("Search2 failed with e=" + stackTraceToSingleLineString(e)); |
| | | } |
| | | debugInfo(tn, "Search2 done with success. searchEntries=" |
| | | + searchEntries + " #searchesDone="+ searchesDone); |
| | | |
| | | |
| | | |
| | | searchEntries = 0; |
| | | message = null; |
| | | try |
| | |
| | | + " expected to return change top + " + cn1 + " & " + cn2 + " & " + cn3); |
| | | while ((searchEntries<4) && (message = r3.readMessage()) != null) |
| | | { |
| | | debugInfo(tn, "Search3 Result=" + |
| | | debugInfo(tn, "Search3 Result=" + |
| | | message.getProtocolOpType() + " " + message); |
| | | |
| | | switch (message.getProtocolOpType()) |
| | |
| | | } |
| | | catch(Exception e) |
| | | { |
| | | fail("Search3 failed with e=" + stackTraceToSingleLineString(e)); |
| | | fail("Search3 failed with e=" + stackTraceToSingleLineString(e)); |
| | | } |
| | | debugInfo(tn, "Search3 done with success. searchEntries=" |
| | | + searchEntries + " #searchesDone="+ searchesDone); |
| | |
| | | } |
| | | |
| | | // Produces additional change |
| | | ChangeNumber cn11 = new ChangeNumber(TimeThread.getTime(), 11, (short)1201); |
| | | ChangeNumber cn11 = new ChangeNumber(TimeThread.getTime(), 11, 1201); |
| | | String expectedDn11 = "uid=" + tn + "11," + TEST_ROOT_DN_STRING; |
| | | DeleteMsg delMsg11 = new DeleteMsg(expectedDn11, cn11, |
| | | "44444444-4444-4444-4444-444444444444"); |
| | |
| | | debugInfo(tn, delMsg11.getChangeNumber() + " published additionally "); |
| | | |
| | | // Produces additional change |
| | | ChangeNumber cn12 = new ChangeNumber(TimeThread.getTime(), 12, (short)1202); |
| | | ChangeNumber cn12 = new ChangeNumber(TimeThread.getTime(), 12, 1202); |
| | | String expectedDn12 = "uid=" + tn + "12," + TEST_ROOT_DN_STRING2; |
| | | DeleteMsg delMsg12 = new DeleteMsg(expectedDn12, cn12, |
| | | "55555555-5555-5555-5555-555555555555"); |
| | |
| | | debugInfo(tn, delMsg12.getChangeNumber() + " published additionally "); |
| | | |
| | | // Produces additional change |
| | | ChangeNumber cn13 = new ChangeNumber(TimeThread.getTime(), 13, (short)1202); |
| | | ChangeNumber cn13 = new ChangeNumber(TimeThread.getTime(), 13, 1202); |
| | | String expectedDn13 = "uid=" + tn + "13," + TEST_ROOT_DN_STRING2; |
| | | DeleteMsg delMsg13 = new DeleteMsg(expectedDn13, cn13, |
| | | "66666666-6666-6666-6666-666666666666"); |
| | |
| | | message = null; |
| | | while ((searchEntries<1) && (message = r1.readMessage()) != null) |
| | | { |
| | | debugInfo(tn, "Search 11 Result=" + |
| | | debugInfo(tn, "Search 11 Result=" + |
| | | message.getProtocolOpType() + " " + message); |
| | | switch (message.getProtocolOpType()) |
| | | { |
| | |
| | | message = null; |
| | | while ((searchEntries<2) && (message = r2.readMessage()) != null) |
| | | { |
| | | debugInfo(tn, "psearch search 12 Result=" + |
| | | debugInfo(tn, "psearch search 12 Result=" + |
| | | message.getProtocolOpType() + " " + message); |
| | | switch (message.getProtocolOpType()) |
| | | { |
| | |
| | | message = null; |
| | | while ((searchEntries<3) && (message = r3.readMessage()) != null) |
| | | { |
| | | debugInfo(tn, "psearch search 13 Result=" + |
| | | debugInfo(tn, "psearch search 13 Result=" + |
| | | message.getProtocolOpType() + " " + message); |
| | | switch (message.getProtocolOpType()) |
| | | { |
| | |
| | | private void bindAsManager(LDAPWriter w, org.opends.server.tools.LDAPReader r) |
| | | throws IOException, LDAPException, ASN1Exception, InterruptedException |
| | | { |
| | | bindAsWhoEver(w, r, |
| | | bindAsWhoEver(w, r, |
| | | "cn=Directory Manager", "password", LDAPResultCode.SUCCESS); |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | /** |
| | | * Utility - log debug message - highlight it is from the test and not |
| | | * Utility - log debug message - highlight it is from the test and not |
| | | * from the server code. Makes easier to observe the test steps. |
| | | */ |
| | | private void debugInfo(String tn, String s) |
| | |
| | | |
| | | // -- |
| | | ReplicationBroker s1test = openReplicationSession( |
| | | DN.decode(TEST_ROOT_DN_STRING), (short) 1201, |
| | | DN.decode(TEST_ROOT_DN_STRING), 1201, |
| | | 100, replicationServerPort, |
| | | 1000, true); |
| | | |
| | | ReplicationBroker s2test2 = openReplicationSession( |
| | | DN.decode(TEST_ROOT_DN_STRING2), (short) 1202, |
| | | DN.decode(TEST_ROOT_DN_STRING2), 1202, |
| | | 100, replicationServerPort, |
| | | 1000, true, EMPTY_DN_GENID); |
| | | sleep(500); |
| | |
| | | |
| | | // -- |
| | | ReplicationBroker s1test2 = openReplicationSession( |
| | | DN.decode(TEST_ROOT_DN_STRING2), (short) 1203, |
| | | DN.decode(TEST_ROOT_DN_STRING2), 1203, |
| | | 100, replicationServerPort, |
| | | 1000, true, EMPTY_DN_GENID); |
| | | |
| | | ReplicationBroker s2test = openReplicationSession( |
| | | DN.decode(TEST_ROOT_DN_STRING), (short) 1204, |
| | | DN.decode(TEST_ROOT_DN_STRING), 1204, |
| | | 100, replicationServerPort, |
| | | 1000, true); |
| | | sleep(500); |
| | |
| | | catch(Exception e) |
| | | { |
| | | fail("Ending test " + tn + " with exception:" |
| | | + stackTraceToSingleLineString(e)); |
| | | + stackTraceToSingleLineString(e)); |
| | | } |
| | | debugInfo(tn, "Ending test successfully"); |
| | | } |
| | |
| | | catch(LDAPException e) |
| | | { |
| | | fail("Ending test " + tn + " with exception=" |
| | | + stackTraceToSingleLineString(e)); |
| | | + stackTraceToSingleLineString(e)); |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | // Creates broker on o=test |
| | | ReplicationBroker server01 = openReplicationSession( |
| | | DN.decode(TEST_ROOT_DN_STRING), (short) 1201, |
| | | DN.decode(TEST_ROOT_DN_STRING), 1201, |
| | | 100, replicationServerPort, |
| | | 1000, true); |
| | | |
| | |
| | | |
| | | |
| | | // Publish DEL |
| | | ChangeNumber cn1 = new ChangeNumber(TimeThread.getTime(), ts++, (short)1201); |
| | | ChangeNumber cn1 = new ChangeNumber(TimeThread.getTime(), ts++, 1201); |
| | | DeleteMsg delMsg = |
| | | new DeleteMsg("uid="+tn+"1," + TEST_ROOT_DN_STRING, cn1, |
| | | new DeleteMsg("uid="+tn+"1," + TEST_ROOT_DN_STRING, cn1, |
| | | user1entryUUID); |
| | | server01.publish(delMsg); |
| | | debugInfo(tn, " publishes " + delMsg.getChangeNumber()); |
| | | |
| | | // Publish ADD |
| | | gblCN = new ChangeNumber(TimeThread.getTime(), ts++, (short)1201); |
| | | gblCN = new ChangeNumber(TimeThread.getTime(), ts++, 1201); |
| | | String lentry = new String( |
| | | "dn: uid="+tn+"2," + TEST_ROOT_DN_STRING + "\n" |
| | | + "objectClass: top\n" |
| | | + "objectClass: top\n" |
| | | + "objectClass: domain\n" |
| | | + "entryUUID: "+user1entryUUID+"\n"); |
| | | Entry entry = TestCaseUtils.entryFromLdifString(lentry); |
| | | AddMsg addMsg = new AddMsg( |
| | | gblCN, |
| | | gblCN, |
| | | "uid="+tn+"2," + TEST_ROOT_DN_STRING, |
| | | user1entryUUID, |
| | | baseUUID, |
| | | entry.getObjectClassAttribute(), |
| | | entry.getAttributes(), |
| | | user1entryUUID, |
| | | baseUUID, |
| | | entry.getObjectClassAttribute(), |
| | | entry.getAttributes(), |
| | | new ArrayList<Attribute>()); |
| | | server01.publish(addMsg); |
| | | debugInfo(tn, " publishes " + addMsg.getChangeNumber()); |
| | | |
| | | // Publish MOD |
| | | ChangeNumber cn3 = new ChangeNumber(TimeThread.getTime(), ts++, (short)1201); |
| | | ChangeNumber cn3 = new ChangeNumber(TimeThread.getTime(), ts++, 1201); |
| | | Attribute attr1 = Attributes.create("description", "new value"); |
| | | Modification mod1 = new Modification(ModificationType.REPLACE, attr1); |
| | | List<Modification> mods = new ArrayList<Modification>(); |
| | |
| | | debugInfo(tn, " publishes " + modMsg.getChangeNumber()); |
| | | |
| | | // Publish modDN |
| | | ChangeNumber cn4 = new ChangeNumber(TimeThread.getTime(), ts++, (short)1201); |
| | | ChangeNumber cn4 = new ChangeNumber(TimeThread.getTime(), ts++, 1201); |
| | | ModifyDNOperationBasis op = new ModifyDNOperationBasis(connection, 1, 1, null, |
| | | DN.decode("uid="+tn+"4," + TEST_ROOT_DN_STRING), // entryDN |
| | | RDN.decode("uid="+tn+"new4"), // new rdn |
| | |
| | | |
| | | String filter = "(targetdn=*"+tn.toLowerCase()+"*,o=test)"; |
| | | debugInfo(tn, " Search: " + filter); |
| | | InternalSearchOperation searchOp = |
| | | InternalSearchOperation searchOp = |
| | | connection.processSearch( |
| | | ByteString.valueOf("cn=changelog"), |
| | | SearchScope.WHOLE_SUBTREE, |
| | | DereferencePolicy.NEVER_DEREF_ALIASES, |
| | | DereferencePolicy.NEVER_DEREF_ALIASES, |
| | | 0, // Size limit |
| | | 0, // Time limit |
| | | false, // Types only |
| | |
| | | checkValue(resultEntry,"changetype","modrdn"); |
| | | checkValue(resultEntry,"changelogcookie","o=test:"+cn4.toString()+";o=test2:;"); |
| | | checkValue(resultEntry,"targetentryuuid",user1entryUUID); |
| | | checkValue(resultEntry,"newrdn","uid="+tn+"new4"); |
| | | checkValue(resultEntry,"newrdn","uid="+tn+"new4"); |
| | | checkValue(resultEntry,"newsuperior",TEST_ROOT_DN_STRING2); |
| | | checkValue(resultEntry,"deleteoldrdn","true"); |
| | | checkValue(resultEntry,"changenumber",String.valueOf(firstDraftChangeNumber+3)); |
| | |
| | | filter = "(&(targetdn=*"+tn.toLowerCase()+"*,o=test)(&(changenumber>="+ |
| | | firstDraftChangeNumber+")(changenumber<="+(firstDraftChangeNumber+3)+")))"; |
| | | debugInfo(tn, " Search: " + filter); |
| | | searchOp = |
| | | searchOp = |
| | | connection.processSearch( |
| | | ByteString.valueOf("cn=changelog"), |
| | | SearchScope.WHOLE_SUBTREE, |
| | | DereferencePolicy.NEVER_DEREF_ALIASES, |
| | | DereferencePolicy.NEVER_DEREF_ALIASES, |
| | | 0, // Size limit |
| | | 0, // Time limit |
| | | false, // Types only |
| | |
| | | checkValue(resultEntry,"changetype","modrdn"); |
| | | checkValue(resultEntry,"changelogcookie","o=test:"+cn4.toString()+";o=test2:;"); |
| | | checkValue(resultEntry,"targetentryuuid",user1entryUUID); |
| | | checkValue(resultEntry,"newrdn","uid="+tn+"new4"); |
| | | checkValue(resultEntry,"newrdn","uid="+tn+"new4"); |
| | | checkValue(resultEntry,"newsuperior",TEST_ROOT_DN_STRING2); |
| | | checkValue(resultEntry,"deleteoldrdn","true"); |
| | | checkValue(resultEntry,"changenumber",String.valueOf(firstDraftChangeNumber+3)); |
| | |
| | | catch(Exception e) |
| | | { |
| | | fail("Ending test " + tn + " with exception:" |
| | | + stackTraceToSingleLineString(e)); |
| | | + stackTraceToSingleLineString(e)); |
| | | } |
| | | debugInfo(tn, "Ending test with success"); |
| | | return ts; |
| | |
| | | |
| | | // Creates broker on o=test |
| | | ReplicationBroker server01 = openReplicationSession( |
| | | DN.decode(TEST_ROOT_DN_STRING), (short) 1201, |
| | | DN.decode(TEST_ROOT_DN_STRING), 1201, |
| | | 100, replicationServerPort, |
| | | 1000, true); |
| | | |
| | |
| | | |
| | | String filter = "(changenumber="+firstDraftChangeNumber+")"; |
| | | debugInfo(tn, " Search: " + filter); |
| | | InternalSearchOperation searchOp = |
| | | InternalSearchOperation searchOp = |
| | | connection.processSearch( |
| | | ByteString.valueOf("cn=changelog"), |
| | | SearchScope.WHOLE_SUBTREE, |
| | | DereferencePolicy.NEVER_DEREF_ALIASES, |
| | | DereferencePolicy.NEVER_DEREF_ALIASES, |
| | | 0, // Size limit |
| | | 0, // Time limit |
| | | false, // Types only |
| | |
| | | catch(Exception e) |
| | | { |
| | | fail("Ending test " + tn + " with exception:\n" |
| | | + stackTraceToSingleLineString(e)); |
| | | + stackTraceToSingleLineString(e)); |
| | | } |
| | | debugInfo(tn, "Ending test with success"); |
| | | } |
| | |
| | | |
| | | String filter = "(&(changenumber>="+firstDraftChangeNumber+")(changenumber<="+lastDraftChangeNumber+"))"; |
| | | debugInfo(tn, " Search: " + filter); |
| | | InternalSearchOperation searchOp = |
| | | InternalSearchOperation searchOp = |
| | | connection.processSearch( |
| | | ByteString.valueOf("cn=changelog"), |
| | | SearchScope.WHOLE_SUBTREE, |
| | | DereferencePolicy.NEVER_DEREF_ALIASES, |
| | | DereferencePolicy.NEVER_DEREF_ALIASES, |
| | | 0, // Size limit |
| | | 0, // Time limit |
| | | false, // Types only |
| | |
| | | |
| | | // test success |
| | | assertEquals(searchOp.getResultCode(), ResultCode.SUCCESS, |
| | | searchOp.getErrorMessage().toString()); |
| | | assertEquals(searchOp.getSearchEntries().size(), |
| | | searchOp.getErrorMessage().toString()); |
| | | assertEquals(searchOp.getSearchEntries().size(), |
| | | lastDraftChangeNumber-firstDraftChangeNumber+1); |
| | | } |
| | | catch(Exception e) |
| | | { |
| | | fail("Ending test " + tn + " with exception:\n" |
| | | + stackTraceToSingleLineString(e)); |
| | | + stackTraceToSingleLineString(e)); |
| | | } |
| | | debugInfo(tn, "Ending test with success"); |
| | | } |
| | |
| | | |
| | | String filter = "(changenumber=1000)"; |
| | | debugInfo(tn, " Search: " + filter); |
| | | InternalSearchOperation searchOp = |
| | | InternalSearchOperation searchOp = |
| | | connection.processSearch( |
| | | ByteString.valueOf("cn=changelog"), |
| | | SearchScope.WHOLE_SUBTREE, |
| | | DereferencePolicy.NEVER_DEREF_ALIASES, |
| | | DereferencePolicy.NEVER_DEREF_ALIASES, |
| | | 0, // Size limit |
| | | 0, // Time limit |
| | | false, // Types only |
| | |
| | | sleep(500); |
| | | |
| | | // test success and no entries returned |
| | | assertEquals(searchOp.getResultCode(), ResultCode.SUCCESS, |
| | | searchOp.getErrorMessage().toString()); |
| | | assertEquals(searchOp.getResultCode(), ResultCode.SUCCESS, |
| | | searchOp.getErrorMessage().toString()); |
| | | assertEquals(searchOp.getSearchEntries().size(), 0); |
| | | } |
| | | catch(Exception e) |
| | | { |
| | | fail("Ending test "+tn+" with exception:\n" |
| | | + stackTraceToSingleLineString(e)); |
| | | + stackTraceToSingleLineString(e)); |
| | | } |
| | | debugInfo(tn, "Ending test with success"); |
| | | } |
| | |
| | | |
| | | String filter = "(replicationcsn="+this.gblCN+")"; |
| | | debugInfo(tn, " Search: " + filter); |
| | | InternalSearchOperation searchOp = |
| | | InternalSearchOperation searchOp = |
| | | connection.processSearch( |
| | | ByteString.valueOf("cn=changelog"), |
| | | SearchScope.WHOLE_SUBTREE, |
| | | DereferencePolicy.NEVER_DEREF_ALIASES, |
| | | DereferencePolicy.NEVER_DEREF_ALIASES, |
| | | 0, // Size limit |
| | | 0, // Time limit |
| | | false, // Types only |
| | |
| | | sleep(500); |
| | | |
| | | // test success and no entries returned |
| | | assertEquals(searchOp.getResultCode(), ResultCode.SUCCESS, |
| | | searchOp.getErrorMessage().toString()); |
| | | assertEquals(searchOp.getResultCode(), ResultCode.SUCCESS, |
| | | searchOp.getErrorMessage().toString()); |
| | | assertEquals(searchOp.getSearchEntries().size(), 1); |
| | | |
| | | |
| | | LinkedList<SearchResultEntry> entries = searchOp.getSearchEntries(); |
| | | assertEquals(searchOp.getSearchEntries().size(), 1); |
| | | if (entries != null) |
| | |
| | | catch(Exception e) |
| | | { |
| | | fail("Ending test "+tn+" with exception:\n" |
| | | + stackTraceToSingleLineString(e)); |
| | | + stackTraceToSingleLineString(e)); |
| | | } |
| | | debugInfo(tn, "Ending test with success"); |
| | | } |
| | |
| | | assertEquals(startCLmsg.getLastDraftChangeNumber(),8); |
| | | |
| | | // |
| | | ChangeNumberGenerator gen = new ChangeNumberGenerator((short) 1, 0); |
| | | ChangeNumber changeNumber1 = gen.newChangeNumber(); |
| | | ChangeNumberGenerator gen = new ChangeNumberGenerator( 1, 0); |
| | | ChangeNumber changeNumber1 = gen.newChangeNumber(); |
| | | ECLSearchOperation.evaluateFilter(startCLmsg, |
| | | SearchFilter.createFilterFromString("(replicationcsn="+changeNumber1+")")); |
| | | assertEquals(startCLmsg.getFirstDraftChangeNumber(),-1); |
| | | assertEquals(startCLmsg.getLastDraftChangeNumber(),-1); |
| | | assertEquals(startCLmsg.getChangeNumber(), changeNumber1); |
| | | |
| | | |
| | | |
| | | } |
| | | catch(Exception e) |
| | | { |
| | |
| | | } |
| | | debugInfo(tn, "Ending test with success"); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Put a short purge delay to the draftCNDB, clear the changelogDB, |
| | | * expect the draftCNDb to be purged accordingly. |
| | |
| | | attributes.add("+"); |
| | | |
| | | debugInfo(tn, " Search: rootDSE"); |
| | | InternalSearchOperation searchOp = |
| | | InternalSearchOperation searchOp = |
| | | connection.processSearch( |
| | | ByteString.valueOf(""), |
| | | SearchScope.BASE_OBJECT, |
| | | DereferencePolicy.NEVER_DEREF_ALIASES, |
| | | DereferencePolicy.NEVER_DEREF_ALIASES, |
| | | 0, // Size limit |
| | | 0, // Time limit |
| | | false, // Types only |
| | |
| | | sleep(500); |
| | | |
| | | // test success and no entries returned |
| | | assertEquals(searchOp.getResultCode(), ResultCode.SUCCESS, |
| | | searchOp.getErrorMessage().toString()); |
| | | assertEquals(searchOp.getResultCode(), ResultCode.SUCCESS, |
| | | searchOp.getErrorMessage().toString()); |
| | | assertEquals(searchOp.getSearchEntries().size(), 1); |
| | | |
| | | LinkedList<SearchResultEntry> entries = searchOp.getSearchEntries(); |
| | |
| | | i++; |
| | | debugInfo(tn, "Result entry returned:" + resultEntry.toLDIFString()); |
| | | ldifWriter.writeEntry(resultEntry); |
| | | checkValue(resultEntry,"firstchangenumber", |
| | | checkValue(resultEntry,"firstchangenumber", |
| | | String.valueOf(expectedFirst)); |
| | | checkValue(resultEntry,"lastchangenumber", |
| | | checkValue(resultEntry,"lastchangenumber", |
| | | String.valueOf(expectedLast)); |
| | | } |
| | | } |
| | |
| | | try |
| | | { |
| | | ECLCompatTestLimits(expectedFirst, expectedLast); |
| | | |
| | | |
| | | // Creates broker on o=test |
| | | ReplicationBroker server01 = openReplicationSession( |
| | | DN.decode(TEST_ROOT_DN_STRING), (short) 1201, |
| | | DN.decode(TEST_ROOT_DN_STRING), 1201, |
| | | 100, replicationServerPort, |
| | | 1000, true); |
| | | |
| | | String user1entryUUID = "11111111-1112-1113-1114-111111111115"; |
| | | |
| | | // Publish DEL |
| | | ChangeNumber cn1 = new ChangeNumber(TimeThread.getTime(), ts++, (short)1201); |
| | | ChangeNumber cn1 = new ChangeNumber(TimeThread.getTime(), ts++, 1201); |
| | | DeleteMsg delMsg = |
| | | new DeleteMsg("uid="+tn+"1," + TEST_ROOT_DN_STRING, cn1, |
| | | user1entryUUID); |
| | | server01.publish(delMsg); |
| | | debugInfo(tn, " publishes " + delMsg.getChangeNumber()); |
| | | |
| | | |
| | | ECLCompatTestLimits(expectedFirst, expectedLast+1); |
| | | |
| | | |
| | | server01.stop(); |
| | | } |
| | | catch(Exception e) |
| | |
| | | ReplicationServerDomain rsdtest = |
| | | replicationServer.getReplicationServerDomain(TEST_ROOT_DN_STRING, false); |
| | | long count = rsdtest.getEligibleCount( |
| | | new ServerState(), |
| | | new ChangeNumber(TimeThread.getTime(), 1, (short)1201)); |
| | | new ServerState(), |
| | | new ChangeNumber(TimeThread.getTime(), 1, 1201)); |
| | | assertEquals(count, 0); |
| | | |
| | | |
| | | // Creates broker on o=test |
| | | ReplicationBroker server01 = openReplicationSession( |
| | | DN.decode(TEST_ROOT_DN_STRING), (short) 1201, |
| | | DN.decode(TEST_ROOT_DN_STRING), 1201, |
| | | 100, replicationServerPort, |
| | | 1000, true); |
| | | |
| | | // Publish 1 message |
| | | ChangeNumber cn1 = new ChangeNumber(TimeThread.getTime(), 1, (short)1201); |
| | | ChangeNumber cn1 = new ChangeNumber(TimeThread.getTime(), 1, 1201); |
| | | DeleteMsg delMsg = |
| | | new DeleteMsg("uid="+tn+"1," + TEST_ROOT_DN_STRING, cn1, |
| | | new DeleteMsg("uid="+tn+"1," + TEST_ROOT_DN_STRING, cn1, |
| | | user1entryUUID); |
| | | server01.publish(delMsg); |
| | | debugInfo(tn, " publishes " + delMsg.getChangeNumber()); |
| | | sleep(300); |
| | | |
| | | count = rsdtest.getEligibleCount( |
| | | new ServerState(), |
| | | new ChangeNumber(TimeThread.getTime(), 1, (short)1201)); |
| | | new ServerState(), |
| | | new ChangeNumber(TimeThread.getTime(), 1, 1201)); |
| | | assertEquals(count, 1); |
| | | |
| | | |
| | | // Publish 1 message |
| | | ChangeNumber cn2 = new ChangeNumber(TimeThread.getTime(), 2, (short)1201); |
| | | ChangeNumber cn2 = new ChangeNumber(TimeThread.getTime(), 2, 1201); |
| | | delMsg = |
| | | new DeleteMsg("uid="+tn+"1," + TEST_ROOT_DN_STRING, cn2, |
| | | new DeleteMsg("uid="+tn+"1," + TEST_ROOT_DN_STRING, cn2, |
| | | user1entryUUID); |
| | | server01.publish(delMsg); |
| | | debugInfo(tn, " publishes " + delMsg.getChangeNumber()); |
| | | sleep(300); |
| | | |
| | | count = rsdtest.getEligibleCount( |
| | | new ServerState(), |
| | | new ChangeNumber(TimeThread.getTime(), 1, (short)1201)); |
| | | new ServerState(), |
| | | new ChangeNumber(TimeThread.getTime(), 1, 1201)); |
| | | assertEquals(count, 2); |
| | | |
| | | count = rsdtest.getEligibleCount( |
| | |
| | | |
| | | count = rsdtest.getEligibleCount(ss, cn2); |
| | | assertEquals(count, 1); |
| | | |
| | | |
| | | ss.update(cn2); |
| | | count = rsdtest.getEligibleCount(ss, |
| | | new ChangeNumber(TimeThread.getTime(), 4, (short)1201)); |
| | | count = rsdtest.getEligibleCount(ss, |
| | | new ChangeNumber(TimeThread.getTime(), 4, 1201)); |
| | | assertEquals(count, 0); |
| | | |
| | | // Publish 1 message |
| | | ChangeNumber cn3 = new ChangeNumber(TimeThread.getTime(), 3, (short)1201); |
| | | ChangeNumber cn3 = new ChangeNumber(TimeThread.getTime(), 3, 1201); |
| | | delMsg = |
| | | new DeleteMsg("uid="+tn+"1," + TEST_ROOT_DN_STRING, cn3, |
| | | new DeleteMsg("uid="+tn+"1," + TEST_ROOT_DN_STRING, cn3, |
| | | user1entryUUID); |
| | | server01.publish(delMsg); |
| | | debugInfo(tn, " publishes " + delMsg.getChangeNumber()); |
| | | sleep(300); |
| | | |
| | | ss.update(cn2); |
| | | count = rsdtest.getEligibleCount(ss, |
| | | new ChangeNumber(TimeThread.getTime(), 4, (short)1201)); |
| | | count = rsdtest.getEligibleCount(ss, |
| | | new ChangeNumber(TimeThread.getTime(), 4, 1201)); |
| | | assertEquals(count, 1); |
| | | |
| | | |
| | | |
| | | |
| | | server01.stop(); |
| | | |
| | | |
| | | } |
| | | catch(Exception e) |
| | | { |
| | |
| | | Set<String> attrList = new HashSet<String>(); |
| | | attrList.add(new String("cn")); |
| | | ReplicationBroker server01 = openReplicationSession( |
| | | DN.decode(TEST_ROOT_DN_STRING2), (short) 1206, |
| | | DN.decode(TEST_ROOT_DN_STRING2), (short) 1206, |
| | | 100, replicationServerPort, |
| | | 1000, true, -1 , domain21); |
| | | |
| | |
| | | + "sn: Jensen\n" |
| | | + "uid: fiona\n" |
| | | + "telephonenumber: 12121212"); |
| | | |
| | | |
| | | Entry uentry1 = TestCaseUtils.entryFromLdifString(lentry); |
| | | addEntry(uentry1); |
| | | |
| | |
| | | ModifyOperationBasis modOpBasis = |
| | | new ModifyOperationBasis(connection, 1, 1, null, uentry1.getDN(), mods); |
| | | modOpBasis.run(); |
| | | |
| | | |
| | | builder = new AttributeBuilder("telephonenumber"); |
| | | builder.add("555555"); |
| | | mod = |
| | |
| | | modOpBasis = |
| | | new ModifyOperationBasis(connection, 1, 1, null, uentry2.getDN(), mods); |
| | | modOpBasis.run(); |
| | | |
| | | |
| | | ModifyDNOperationBasis modDNOp = new ModifyDNOperationBasis(connection, |
| | | InternalClientConnection.nextOperationID(), |
| | | InternalClientConnection.nextOperationID(), |
| | | InternalClientConnection.nextMessageID(), |
| | | null, |
| | | DN.decode("cn=Robert Hue," + TEST_ROOT_DN_STRING3), |
| | |
| | | modDNOp.getErrorMessage().toString() + modDNOp.getAdditionalLogMessage()); |
| | | |
| | | DeleteOperationBasis delOp = new DeleteOperationBasis(connection, |
| | | InternalClientConnection.nextOperationID(), |
| | | InternalClientConnection.nextMessageID(), null, |
| | | InternalClientConnection.nextOperationID(), |
| | | InternalClientConnection.nextMessageID(), null, |
| | | DN.decode("cn=Robert Hue2," + TEST_ROOT_DN_STRING3)); |
| | | delOp.run(); |
| | | assertEquals(delOp.getResultCode(), ResultCode.SUCCESS, |
| | |
| | | // Search on ECL from start on all suffixes |
| | | String cookie = ""; |
| | | ExternalChangelogRequestControl control = |
| | | new ExternalChangelogRequestControl(true, |
| | | new ExternalChangelogRequestControl(true, |
| | | new MultiDomainServerState(cookie)); |
| | | ArrayList<Control> controls = new ArrayList<Control>(0); |
| | | controls.add(control); |
| | |
| | | InternalSearchOperation searchOp = connection.processSearch( |
| | | ByteString.valueOf("cn=changelog"), |
| | | SearchScope.WHOLE_SUBTREE, |
| | | DereferencePolicy.NEVER_DEREF_ALIASES, |
| | | DereferencePolicy.NEVER_DEREF_ALIASES, |
| | | 0, // Size limit |
| | | 0, // Time limit |
| | | false, // Types only |
| | |
| | | { |
| | | for (SearchResultEntry resultEntry : entries) |
| | | { |
| | | // Expect |
| | | // Expect |
| | | debugInfo(tn, "Entry returned =" + resultEntry.toLDIFString()); |
| | | |
| | | |
| | | String targetdn = getAttributeValue(resultEntry, "targetdn"); |
| | | if ((targetdn.endsWith("cn=robert hue,o=test3")) |
| | | ||(targetdn.endsWith("cn=robert hue2,o=test3"))) |
| | |
| | | if (replicationPlugin2 != null) |
| | | DirectoryServer.deregisterSynchronizationProvider(replicationPlugin2); |
| | | removeTestBackend2(backend2); |
| | | |
| | | |
| | | if (domain3 != null) |
| | | MultimasterReplication.deleteDomain(baseDn3); |
| | | if (replicationPlugin3 != null) |
| | | DirectoryServer.deregisterSynchronizationProvider(replicationPlugin3); |
| | | removeTestBackend2(backend3); |
| | | |
| | | |
| | | } |
| | | catch(Exception e) |
| | | { |
| | |
| | | } |
| | | finally |
| | | { |
| | | |
| | | |
| | | } |
| | | debugInfo(tn, "Ending test with success"); |
| | | } |
| | | } |
| | | } |
| | |
| | | private static final String testName = "generationIdTest"; |
| | | |
| | | private static final int WINDOW_SIZE = 10; |
| | | private static final short server1ID = 1; |
| | | private static final short server2ID = 2; |
| | | private static final short server3ID = 3; |
| | | private static final short changelog1ID = 11; |
| | | private static final short changelog2ID = 12; |
| | | private static final short changelog3ID = 13; |
| | | private static final int server1ID = 1; |
| | | private static final int server2ID = 2; |
| | | private static final int server3ID = 3; |
| | | private static final int changelog1ID = 11; |
| | | private static final int changelog2ID = 12; |
| | | private static final int changelog3ID = 13; |
| | | |
| | | private DN baseDn; |
| | | private ReplicationBroker broker2 = null; |
| | |
| | | return entries; |
| | | } |
| | | |
| | | private int receiveImport(ReplicationBroker broker, short serverID, |
| | | private int receiveImport(ReplicationBroker broker, int serverID, |
| | | String[] updatedEntries) |
| | | { |
| | | // Expect the broker to receive the entries |
| | |
| | | * server to the other replication servers in the test. |
| | | * @return The new created replication server. |
| | | */ |
| | | private ReplicationServer createReplicationServer(short changelogId, |
| | | private ReplicationServer createReplicationServer(int changelogId, |
| | | boolean all, String testCase) |
| | | { |
| | | SortedSet<String> servers = null; |
| | |
| | | * replication Server ID. |
| | | * @param changelogID |
| | | */ |
| | | private void connectServer1ToChangelog(short changelogID) |
| | | private void connectServer1ToChangelog(int changelogID) |
| | | { |
| | | // Connect DS to the replicationServer |
| | | try |
| | |
| | | /* |
| | | * Disconnect DS from the replicationServer |
| | | */ |
| | | private void disconnectFromReplServer(short changelogID) |
| | | private void disconnectFromReplServer(int changelogID) |
| | | { |
| | | try |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | private int getChangelogPort(short changelogID) |
| | | private int getChangelogPort(int changelogID) |
| | | { |
| | | if (replServerPort[changelogID] == 0) |
| | | { |
| | |
| | | * Create a Change number generator to generate new changenumbers |
| | | * when we need to send operation messages to the replicationServer. |
| | | */ |
| | | ChangeNumberGenerator gen = new ChangeNumberGenerator((short) 2, 0); |
| | | ChangeNumberGenerator gen = new ChangeNumberGenerator(2, 0); |
| | | |
| | | user1entryUUID = "33333333-3333-3333-3333-333333333333"; |
| | | user1dn = "uid=user1,ou=People," + baseDnStr; |
| | |
| | | boolean ssShutdownRequested = false; |
| | | protected String[] updatedEntries; |
| | | boolean externalDS = false; |
| | | private static final short server1ID = 1; |
| | | private static final short server2ID = 2; |
| | | private static final short server3ID = 3; |
| | | private static final short changelog1ID = 8; |
| | | private static final short changelog2ID = 9; |
| | | private static final short changelog3ID = 10; |
| | | private static final int server1ID = 1; |
| | | private static final int server2ID = 2; |
| | | private static final int server3ID = 3; |
| | | private static final int changelog1ID = 8; |
| | | private static final int changelog2ID = 9; |
| | | private static final int changelog3ID = 10; |
| | | |
| | | private static final String EXAMPLE_DN = "dc=example,dc=com"; |
| | | |
| | |
| | | * @param requestorID The initiator server. |
| | | */ |
| | | private void makeBrokerPublishEntries(ReplicationBroker broker, |
| | | short senderID, short destinationServerID, short requestorID) |
| | | int senderID, int destinationServerID, int requestorID) |
| | | { |
| | | // Send entries |
| | | try |
| | |
| | | } |
| | | } |
| | | |
| | | void receiveUpdatedEntries(ReplicationBroker broker, short serverID, |
| | | void receiveUpdatedEntries(ReplicationBroker broker, int serverID, |
| | | String[] updatedEntries) |
| | | { |
| | | // Expect the broker to receive the entries |
| | |
| | | * @param changelogId The serverID of the replicationServer to create. |
| | | * @return The new replicationServer. |
| | | */ |
| | | private ReplicationServer createChangelogServer(short changelogId, String testCase) |
| | | private ReplicationServer createChangelogServer(int changelogId, String testCase) |
| | | { |
| | | SortedSet<String> servers = null; |
| | | servers = new TreeSet<String>(); |
| | |
| | | * replication Server ID. |
| | | * @param changelogID |
| | | */ |
| | | private void connectServer1ToChangelog(short changelogID) |
| | | private void connectServer1ToChangelog(int changelogID) |
| | | { |
| | | // Connect DS to the replicationServer |
| | | try |
| | |
| | | } |
| | | } |
| | | |
| | | private int getChangelogPort(short changelogID) |
| | | private int getChangelogPort(int changelogID) |
| | | { |
| | | if (replServerPort[changelogID] == 0) |
| | | { |
| | |
| | | |
| | | // Now tests error in the middle of an import |
| | | // S2 sends init request |
| | | ErrorMsg msg = |
| | | new ErrorMsg(server1ID, (short) 1, Message.EMPTY); |
| | | ErrorMsg msg = new ErrorMsg(server1ID, 1, Message.EMPTY); |
| | | server2.publish(msg); |
| | | |
| | | waitTaskState(taskInit, TaskState.STOPPED_BY_ERROR, |
| | |
| | | assertNotNull(DirectoryServer.getConfigEntry(repDomainEntry.getDN()), |
| | | "Unable to add the synchronized server"); |
| | | |
| | | ReplicationBroker broker = openReplicationSession(baseDn, (short) 12, |
| | | ReplicationBroker broker = openReplicationSession(baseDn, 12, |
| | | WINDOW_SIZE, replServerPort, 1000, true); |
| | | |
| | | try { |
| | |
| | | * does not exist, take the 'empty backend' generationID. |
| | | */ |
| | | protected ReplicationBroker openReplicationSession( |
| | | final DN baseDn, short serverId, int window_size, |
| | | final DN baseDn, int serverId, int window_size, |
| | | int port, int timeout, boolean emptyOldChanges) |
| | | throws Exception, SocketException |
| | | { |
| | |
| | | * providing the generationId. |
| | | */ |
| | | protected ReplicationBroker openReplicationSession( |
| | | final DN baseDn, short serverId, int window_size, |
| | | final DN baseDn, int serverId, int window_size, |
| | | int port, int timeout, boolean emptyOldChanges, |
| | | long generationId) |
| | | throws Exception, SocketException |
| | |
| | | * providing the generationId. |
| | | */ |
| | | protected ReplicationBroker openReplicationSession( |
| | | final DN baseDn, short serverId, int window_size, |
| | | final DN baseDn, int serverId, int window_size, |
| | | int port, int timeout, boolean emptyOldChanges, |
| | | long generationId, ReplicationDomain replicationDomain) |
| | | throws Exception, SocketException |
| | |
| | | } |
| | | |
| | | /** |
| | | * Open an ECL replicationServer session to the local ReplicationServer |
| | | * Open an ECL replicationServer session to the local ReplicationServer |
| | | protected ReplicationBroker openECLReplicationSession( |
| | | int window_size, int port, int timeout, boolean emptyOldChanges, |
| | | Short serverId) |
| | |
| | | * |
| | | */ |
| | | protected ReplicationBroker openReplicationSession( |
| | | final DN baseDn, short serverId, int window_size, |
| | | final DN baseDn, int serverId, int window_size, |
| | | int port, int timeout, ServerState state) |
| | | throws Exception, SocketException |
| | | { |
| | |
| | | * starting with a given ServerState. |
| | | */ |
| | | protected ReplicationBroker openReplicationSession( |
| | | final DN baseDn, short serverId, int window_size, |
| | | final DN baseDn, int serverId, int window_size, |
| | | int port, int timeout, ServerState state, long generationId) |
| | | throws Exception, SocketException |
| | | { |
| | |
| | | * |
| | | */ |
| | | protected ReplicationBroker openReplicationSession( |
| | | final DN baseDn, short serverId, int window_size, |
| | | final DN baseDn, int serverId, int window_size, |
| | | int port, int timeout, int maxSendQueue, int maxRcvQueue, |
| | | boolean emptyOldChanges) |
| | | throws Exception, SocketException |
| | |
| | | } |
| | | |
| | | protected ReplicationBroker openReplicationSession( |
| | | final DN baseDn, short serverId, int window_size, |
| | | final DN baseDn, int serverId, int window_size, |
| | | int port, int timeout, int maxSendQueue, int maxRcvQueue, |
| | | boolean emptyOldChanges, long generationId) |
| | | throws Exception, SocketException |
| | |
| | | final DN baseDn = DN.decode("cn=schema"); |
| | | |
| | | ReplicationBroker broker = |
| | | openReplicationSession(baseDn, (short) 2, 100, replServerPort, 5000, true); |
| | | openReplicationSession(baseDn, 2, 100, replServerPort, 5000, true); |
| | | |
| | | try |
| | | { |
| | |
| | | final DN baseDn = DN.decode("cn=schema"); |
| | | |
| | | ReplicationBroker broker = |
| | | openReplicationSession(baseDn, (short) 2, 100, replServerPort, 5000, true); |
| | | openReplicationSession(baseDn, 2, 100, replServerPort, 5000, true); |
| | | |
| | | try |
| | | { |
| | | ChangeNumberGenerator gen = new ChangeNumberGenerator((short) 2, 0); |
| | | ChangeNumberGenerator gen = new ChangeNumberGenerator( 2, 0); |
| | | |
| | | ModifyMsg modMsg = new ModifyMsg(gen.newChangeNumber(), |
| | | baseDn, rcvdMods, "cn=schema"); |
| | |
| | | final DN baseDn = DN.decode("cn=schema"); |
| | | |
| | | ReplicationBroker broker = |
| | | openReplicationSession(baseDn, (short) 3, 100, replServerPort, 5000, true); |
| | | openReplicationSession(baseDn, 3, 100, replServerPort, 5000, true); |
| | | |
| | | try |
| | | { |
| | |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Copyright 2006-2009 Sun Microsystems, Inc. |
| | | */ |
| | | |
| | | package org.opends.server.replication; |
| | |
| | | final int TOTAL_MESSAGES = 1000; |
| | | |
| | | ReplicationBroker broker = |
| | | openReplicationSession(baseDn, (short) 18, 100, replServerPort, 5000, true); |
| | | openReplicationSession(baseDn, 18, 100, replServerPort, 5000, true); |
| | | Monitor monitor = new Monitor("stress test monitor"); |
| | | DirectoryServer.registerMonitorProvider(monitor); |
| | | |
| | |
| | | import java.net.ServerSocket; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.concurrent.locks.Lock; |
| | | |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.messages.Message; |
| | |
| | | private Entry domain2; |
| | | private Entry domain3; |
| | | |
| | | Short domainSid = 55; |
| | | int domainSid = 55; |
| | | |
| | | /** |
| | | * Set up the environment for performing the tests in this Class. |
| | |
| | | * This must use a different serverId to that of the directory server. |
| | | */ |
| | | ReplicationBroker broker = |
| | | openReplicationSession(baseDn, (short)2, 100, replServerPort, 1000, true); |
| | | openReplicationSession(baseDn, 2, 100, replServerPort, 1000, true); |
| | | |
| | | |
| | | /* |
| | | * Create a Change number generator to generate new changenumbers |
| | | * when we need to send operation messages to the replicationServer. |
| | | */ |
| | | ChangeNumberGenerator gen = new ChangeNumberGenerator((short) 2, 0); |
| | | ChangeNumberGenerator gen = new ChangeNumberGenerator(2, 0); |
| | | |
| | | |
| | | // Disable the directory server receive status. |
| | |
| | | * This must use a different serverId to that of the directory server. |
| | | */ |
| | | ReplicationBroker broker = |
| | | openReplicationSession(baseDn, (short)2, 100, replServerPort, 1000, true); |
| | | openReplicationSession(baseDn, 2, 100, replServerPort, 1000, true); |
| | | |
| | | |
| | | /* |
| | | * Create a Change number generator to generate new changenumbers |
| | | * when we need to send operation messages to the replicationServer. |
| | | */ |
| | | ChangeNumberGenerator gen = new ChangeNumberGenerator((short) 2, 0); |
| | | ChangeNumberGenerator gen = new ChangeNumberGenerator( 2, 0); |
| | | |
| | | |
| | | // Create and publish an update message to add an entry. |
| | |
| | | * This must use a different serverId to that of the directory server. |
| | | */ |
| | | ReplicationBroker broker = |
| | | openReplicationSession(baseDn, (short)2, 100, replServerPort, 1000, true); |
| | | openReplicationSession(baseDn, 2, 100, replServerPort, 1000, true); |
| | | |
| | | // Add the first test entry. |
| | | TestCaseUtils.addEntry( |
| | |
| | | attrs.get(0).iterator().next().getValue().toString(); |
| | | |
| | | // A change on a first server. |
| | | ChangeNumber t1 = new ChangeNumber(1, (short) 0, (short) 3); |
| | | ChangeNumber t1 = new ChangeNumber(1, 0, 3); |
| | | |
| | | // A change on a second server. |
| | | ChangeNumber t2 = new ChangeNumber(2, (short) 0, (short) 4); |
| | | ChangeNumber t2 = new ChangeNumber(2, 0, 4); |
| | | |
| | | // Simulate the ordering t2:replace:B followed by t1:add:A that |
| | | updateMonitorCount(baseDn, monitorAttr); |
| | |
| | | // Simulate the ordering t2:delete:displayname followed by |
| | | // t1:replace:displayname |
| | | // A change on a first server. |
| | | t1 = new ChangeNumber(3, (short) 0, (short) 3); |
| | | t1 = new ChangeNumber(3, 0, 3); |
| | | |
| | | // A change on a second server. |
| | | t2 = new ChangeNumber(4, (short) 0, (short) 4); |
| | | t2 = new ChangeNumber(4, 0, 4); |
| | | |
| | | // Simulate the ordering t2:delete:displayname followed by t1:replace:A |
| | | updateMonitorCount(baseDn, monitorAttr); |
| | |
| | | * This must use a serverId different from the LDAP server ID |
| | | */ |
| | | ReplicationBroker broker = |
| | | openReplicationSession(baseDn, (short)2, 100, replServerPort, 1000, true); |
| | | openReplicationSession(baseDn, 2, 100, replServerPort, 1000, true); |
| | | |
| | | /* |
| | | * Create a Change number generator to generate new changenumbers |
| | | * when we need to send operations messages to the replicationServer. |
| | | */ |
| | | ChangeNumberGenerator gen = new ChangeNumberGenerator((short) 2, 0); |
| | | ChangeNumberGenerator gen = new ChangeNumberGenerator( 2, 0); |
| | | |
| | | /* |
| | | * Test that the conflict resolution code is able to find entries |
| | |
| | | final DN baseDn = DN.decode("ou=People," + TEST_ROOT_DN_STRING); |
| | | |
| | | ReplicationBroker broker = |
| | | openReplicationSession(baseDn, (short) 27, 100, replServerPort, 2000, true); |
| | | openReplicationSession(baseDn, 27, 100, replServerPort, 2000, true); |
| | | |
| | | try { |
| | | ChangeNumberGenerator gen = new ChangeNumberGenerator((short) 27, 0); |
| | | ChangeNumberGenerator gen = new ChangeNumberGenerator( 27, 0); |
| | | |
| | | /* |
| | | * Test that operations done on this server are sent to the |
| | |
| | | |
| | | Thread.sleep(2000); |
| | | ReplicationBroker broker = |
| | | openReplicationSession(baseDn, (short) 11, 100, replServerPort, 1000, true); |
| | | openReplicationSession(baseDn, 11, 100, replServerPort, 1000, true); |
| | | try |
| | | { |
| | | ChangeNumberGenerator gen = new ChangeNumberGenerator((short) 11, 0); |
| | | ChangeNumberGenerator gen = new ChangeNumberGenerator( 11, 0); |
| | | |
| | | // Create a test entry. |
| | | String personLdif = "dn: uid=user.2,ou=People," + TEST_ROOT_DN_STRING + "\n" |
| | |
| | | @Test(enabled=true) |
| | | public void CNGeneratorAdjust() throws Exception |
| | | { |
| | | short serverId = 88; |
| | | int serverId = 88; |
| | | logError(Message.raw(Category.SYNC, Severity.INFORMATION, |
| | | "Starting synchronization test : CNGeneratorAdjust")); |
| | | |
| | |
| | | public void adjustTest() |
| | | { |
| | | ChangeNumberGenerator generator = |
| | | new ChangeNumberGenerator((short)5, TimeThread.getTime()); |
| | | new ChangeNumberGenerator(5, TimeThread.getTime()); |
| | | |
| | | ChangeNumber cn = generator.newChangeNumber(); |
| | | |
| | | ChangeNumber cn1 = |
| | | new ChangeNumber(cn.getTime() + 5000, cn.getSeqnum(), (short) 6); |
| | | new ChangeNumber(cn.getTime() + 5000, cn.getSeqnum(), 6); |
| | | generator.adjust(cn1); |
| | | |
| | | ChangeNumber cn2 = generator.newChangeNumber(); |
| | |
| | | public void adjustSameMilliTest() |
| | | { |
| | | ChangeNumberGenerator generator = |
| | | new ChangeNumberGenerator((short)5, TimeThread.getTime()); |
| | | new ChangeNumberGenerator(5, TimeThread.getTime()); |
| | | |
| | | ChangeNumber cn = generator.newChangeNumber(); |
| | | |
| | | ChangeNumber cn1 = |
| | | new ChangeNumber(cn.getTime(), cn.getSeqnum() + 10, (short) 6); |
| | | new ChangeNumber(cn.getTime(), cn.getSeqnum() + 10, 6); |
| | | generator.adjust(cn1); |
| | | |
| | | ChangeNumber cn2 = generator.newChangeNumber(); |
| | |
| | | public void adjustRollingSeqnum() |
| | | { |
| | | ServerState state = new ServerState(); |
| | | ChangeNumber cn1 = new ChangeNumber(TimeThread.getTime(), Integer.MAX_VALUE, (short) 5); |
| | | ChangeNumber cn1 = new ChangeNumber(TimeThread.getTime(), Integer.MAX_VALUE, 5); |
| | | state.update(cn1); |
| | | |
| | | ChangeNumberGenerator generator = new ChangeNumberGenerator((short)5, state); |
| | | ChangeNumberGenerator generator = new ChangeNumberGenerator(5, state); |
| | | |
| | | ChangeNumber cn2 = generator.newChangeNumber(); |
| | | |
| | |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Copyright 2006-2009 Sun Microsystems, Inc. |
| | | */ |
| | | package org.opends.server.replication.common; |
| | | |
| | |
| | | */ |
| | | @DataProvider(name = "changeNumberData") |
| | | public Object[][] createConstructorData() { |
| | | long time = 0x12ABC; |
| | | return new Object[][] { |
| | | {1, (short) 0, (short) 1}, |
| | | {TimeThread.getTime(), (short) 123, (short) 45} |
| | | {1, 0, 1, "0000000000000001000100000000"}, |
| | | {time, 123, 45, "0000000000012abc002d0000007b"}, |
| | | {time, 123456789, 32767, "0000000000012abc7fff075bcd15"}, |
| | | {time, 123456789, 32768, "0000000000012abc8000075bcd15"}, |
| | | {time, 123456789, 65000, "0000000000012abcfde8075bcd15"}, |
| | | {time, 123, 45678, "0000000000012abcb26e0000007b"} |
| | | }; |
| | | } |
| | | |
| | |
| | | * Test ChangeNumber constructor |
| | | */ |
| | | @Test(dataProvider = "changeNumberData") |
| | | public void CreateChangeNumber(long time, int seq, short id) |
| | | public void CreateChangeNumber(long time, int seq, int id, String str) |
| | | throws Exception |
| | | { |
| | | // Create 2 ChangeNumber with the same data and check equality |
| | | new ChangeNumber(time,seq,id); |
| | | ChangeNumber cn = new ChangeNumber(time,seq,id); |
| | | assertEquals(cn.toString(), str); |
| | | |
| | | new ChangeNumber(time,seq,id); |
| | | new ChangeNumber(time+1,seq,id) ; |
| | | new ChangeNumber(time,seq+1,id) ; |
| | | new ChangeNumber(time,seq,(short)(id+1)); |
| | | assertTrue(true); |
| | | new ChangeNumber(time,seq,id+1); |
| | | } |
| | | |
| | | /** |
| | | * Test toString and constructor from String |
| | | */ |
| | | @Test(dataProvider = "changeNumberData") |
| | | public void ChangeNumberEncodeDecode(long time, int seq, short id) |
| | | public void ChangeNumberEncodeDecode(long time, int seq, int id, String str) |
| | | throws Exception |
| | | { |
| | | // Create 2 ChangeNumber with the same data and check equality |
| | |
| | | |
| | | assertEquals(cn, cn2, |
| | | "The encoding/decoding of ChangeNumber is not reversible"); |
| | | assertEquals(cn2.toString(), str, |
| | | "The encoding/decoding of ChangeNumber is not reversible for toString()"); |
| | | } |
| | | |
| | | /** |
| | |
| | | public Object[][] createChangeNumberData() { |
| | | |
| | | long time[] = {1, TimeThread.getTime()} ; |
| | | short seq[] = {(short)0, (short) 123} ; |
| | | short id [] = {(short)1, (short) 45} ; |
| | | int seq[] = {0, 123} ; |
| | | int id [] = {1, 45} ; |
| | | |
| | | Object[][] obj = new Object[time.length][5]; |
| | | for (int i=0; i<time.length; i++) |
| | |
| | | obj[i][1] = new ChangeNumber(time[i],seq[i],id[i]); |
| | | obj[i][2] = new ChangeNumber(time[i]+1,seq[i],id[i]); |
| | | obj[i][3] = new ChangeNumber(time[i],seq[i]+1,id[i]); |
| | | obj[i][4] = new ChangeNumber(time[i],seq[i],(short)(id[i]+1)); |
| | | obj[i][4] = new ChangeNumber(time[i],seq[i],id[i]+1); |
| | | } |
| | | return obj; |
| | | } |
| | |
| | | |
| | | // Generated the ChangeNumberGenerator object |
| | | ChangeNumberGenerator cng = |
| | | new ChangeNumberGenerator((short) 0, TimeThread.getTime()); |
| | | new ChangeNumberGenerator( 0, TimeThread.getTime()); |
| | | |
| | | // Generate 2 changeNumbers and check that they are differents |
| | | CN1 = cng.newChangeNumber(); |
| | |
| | | ChangeNumber CN1; |
| | | ChangeNumber CN2; |
| | | |
| | | CN1 = new ChangeNumber((long)0, 3, (short)0); |
| | | CN1 = new ChangeNumber((long)0, 3, 0); |
| | | |
| | | // 3-0 = 3 |
| | | CN2 = new ChangeNumber((long)0, 0, (short)0); |
| | | CN2 = new ChangeNumber((long)0, 0, 0); |
| | | assertEquals(ChangeNumber.diffSeqNum(CN1, CN2), 3); |
| | | |
| | | // 3-1 = 2 |
| | | CN2 = new ChangeNumber((long)0, 1, (short)0); |
| | | CN2 = new ChangeNumber((long)0, 1, 0); |
| | | assertEquals(ChangeNumber.diffSeqNum(CN1, CN2), 2); |
| | | |
| | | // 3-3 = 0 |
| | | CN2 = new ChangeNumber((long)0, 3, (short)0); |
| | | CN2 = new ChangeNumber((long)0, 3, 0); |
| | | assertEquals(ChangeNumber.diffSeqNum(CN1, CN2), 0); |
| | | |
| | | // 3-4 = 0 (CN1 must be newer otherwise 0 should be returned) |
| | | CN2 = new ChangeNumber((long)0, 4, (short)0); |
| | | CN2 = new ChangeNumber((long)0, 4, 0); |
| | | assertEquals(ChangeNumber.diffSeqNum(CN1, CN2), 0); |
| | | |
| | | CN1 = new ChangeNumber((long)0, 0, (short)0); |
| | | CN1 = new ChangeNumber((long)0, 0, 0); |
| | | |
| | | // 0-0 = 0 |
| | | CN2 = new ChangeNumber((long)0, 0, (short)0); |
| | | CN2 = new ChangeNumber((long)0, 0, 0); |
| | | assertEquals(ChangeNumber.diffSeqNum(CN1, CN2), 0); |
| | | |
| | | // 0-1 = 0 (CN1 must be newer otherwise 0 should be returned) |
| | | CN2 = new ChangeNumber((long)0, 1, (short)0); |
| | | CN2 = new ChangeNumber((long)0, 1, 0); |
| | | assertEquals(ChangeNumber.diffSeqNum(CN1, CN2), 0); |
| | | |
| | | CN1 = new ChangeNumber((long)0, 5, (short)0); |
| | | CN2 = new ChangeNumber((long)0, 2, (short)0); |
| | | CN1 = new ChangeNumber((long)0, 5, 0); |
| | | CN2 = new ChangeNumber((long)0, 2, 0); |
| | | |
| | | // 5-null = 5 |
| | | assertEquals(ChangeNumber.diffSeqNum(CN1, null), 5); |
| | |
| | | // null-null = 0 |
| | | assertEquals(ChangeNumber.diffSeqNum(null, null), 0); |
| | | |
| | | CN1 = new ChangeNumber((long)1111111, 2, (short)0); |
| | | CN2 = new ChangeNumber((long)3333333, 4, (short)0); |
| | | CN1 = new ChangeNumber((long)1111111, 2, 0); |
| | | CN2 = new ChangeNumber((long)3333333, 4, 0); |
| | | |
| | | // CN1 older than CN2 -> 0 |
| | | assertEquals(ChangeNumber.diffSeqNum(CN1, CN2), 0); |
| | | |
| | | CN1 = new ChangeNumber((long)3333333, 1, (short)0); |
| | | CN2 = new ChangeNumber((long)1111111, Integer.MAX_VALUE-1, (short)0); |
| | | CN1 = new ChangeNumber((long)3333333, 1, 0); |
| | | CN2 = new ChangeNumber((long)1111111, Integer.MAX_VALUE-1, 0); |
| | | |
| | | // CN1 seqnum looped |
| | | assertEquals(ChangeNumber.diffSeqNum(CN1, CN2), 3); |
| | |
| | | @DataProvider(name = "changeNumberData") |
| | | public Object[][] createChangeNumberData() { |
| | | return new Object[][] { |
| | | {new ChangeNumber(1, (short) 0, (short) 1)}, |
| | | {new ChangeNumber(TimeThread.getTime(), (short) 123, (short) 45)} |
| | | {new ChangeNumber(1, 0, 1)}, |
| | | {new ChangeNumber(TimeThread.getTime(), 123, 45)} |
| | | }; |
| | | } |
| | | |
| | |
| | | ChangeNumber cn1, cn2, cn3; |
| | | cn1 = new ChangeNumber(cn.getTime()+1,cn.getSeqnum(),cn.getServerId()); |
| | | cn2 = new ChangeNumber(cn1.getTime(),cn1.getSeqnum()+1,cn1.getServerId()); |
| | | cn3 = new ChangeNumber(cn2.getTime(),cn2.getSeqnum(),(short)(cn2.getServerId()+1)); |
| | | cn3 = new ChangeNumber(cn2.getTime(),cn2.getSeqnum(),(cn2.getServerId()+1)); |
| | | |
| | | assertTrue(serverState.update(cn1)) ; |
| | | assertTrue(serverState.update(cn2)) ; |
| | |
| | | { |
| | | ChangeNumber cn1, cn3; |
| | | cn1 = new ChangeNumber(cn.getTime()+1,cn.getSeqnum(),cn.getServerId()); |
| | | cn3 = new ChangeNumber(cn1.getTime(),cn1.getSeqnum(),(short)(cn1.getServerId()+1)); |
| | | cn3 = new ChangeNumber(cn1.getTime(),cn1.getSeqnum(),(cn1.getServerId()+1)); |
| | | |
| | | ServerState state1 = new ServerState(); |
| | | state1.update(cn1); |
| | |
| | | * The port of the replicationServer. |
| | | */ |
| | | private int replServerPort; |
| | | private final byte RS_SERVER_ID = (byte) 90; |
| | | private final int RS_SERVER_ID = 90; |
| | | // Sleep time of the RS, before sending an ack |
| | | private static final long NO_TIMEOUT_RS_SLEEP_TIME = 2000; |
| | | private final String testName = this.getClass().getSimpleName(); |
| | |
| | | |
| | | // Parameters given at constructor time |
| | | private final int port; |
| | | private short serverId = -1; |
| | | private int serverId = -1; |
| | | boolean isAssured = false; // Default value for config |
| | | AssuredMode assuredMode = AssuredMode.SAFE_DATA_MODE; // Default value for config |
| | | byte safeDataLevel = (byte) 1; // Default value for config |
| | |
| | | // The assured boolean means: |
| | | // - true: SR mode |
| | | // - false: not assured |
| | | public FakeReplicationServer(byte groupId, int port, short serverId, boolean assured) |
| | | public FakeReplicationServer(byte groupId, int port, int serverId, boolean assured) |
| | | { |
| | | |
| | | this.groupId = groupId; |
| | |
| | | } |
| | | |
| | | // Constructor for RS receiving updates in SD assured mode |
| | | public FakeReplicationServer(byte groupId, int port, short serverId, int safeDataLevel) |
| | | public FakeReplicationServer(byte groupId, int port, int serverId, int safeDataLevel) |
| | | { |
| | | this.groupId = groupId; |
| | | this.port = port; |
| | |
| | | public void start(int scenario) |
| | | { |
| | | |
| | | gen = new ChangeNumberGenerator((short)3, 0L); |
| | | gen = new ChangeNumberGenerator(3, 0L); |
| | | |
| | | // Store expected test case |
| | | this.scenario = scenario; |
| | |
| | | // Send an ack with errors: |
| | | // - replay error |
| | | // - server 10 error, server 20 error |
| | | List<Short> serversInError = new ArrayList<Short>(); |
| | | serversInError.add((short)10); |
| | | serversInError.add((short)20); |
| | | List<Integer> serversInError = new ArrayList<Integer>(); |
| | | serversInError.add(10); |
| | | serversInError.add(20); |
| | | AckMsg ackMsg = new AckMsg(updateMsg.getChangeNumber(), false, false, true, serversInError); |
| | | session.publish(ackMsg); |
| | | |
| | |
| | | // - wrong status error |
| | | // - replay error |
| | | // - server 10 error, server 20 error, server 30 error |
| | | serversInError = new ArrayList<Short>(); |
| | | serversInError.add((short)10); |
| | | serversInError.add((short)20); |
| | | serversInError.add((short)30); |
| | | serversInError = new ArrayList<Integer>(); |
| | | serversInError.add(10); |
| | | serversInError.add(20); |
| | | serversInError.add(30); |
| | | ackMsg = new AckMsg(updateMsg.getChangeNumber(), true, true, true, serversInError); |
| | | session.publish(ackMsg); |
| | | |
| | |
| | | // Send an ack with errors: |
| | | // - timeout error |
| | | // - server 10 error |
| | | List<Short> serversInError = new ArrayList<Short>(); |
| | | serversInError.add((short)10); |
| | | List<Integer> serversInError = new ArrayList<Integer>(); |
| | | serversInError.add(10); |
| | | AckMsg ackMsg = new AckMsg(updateMsg.getChangeNumber(), true, false, false, serversInError); |
| | | session.publish(ackMsg); |
| | | |
| | |
| | | // Send an ack with errors: |
| | | // - timeout error |
| | | // - server 10 error, server 20 error |
| | | serversInError = new ArrayList<Short>(); |
| | | serversInError.add((short)10); |
| | | serversInError.add((short)20); |
| | | serversInError = new ArrayList<Integer>(); |
| | | serversInError.add(10); |
| | | serversInError.add(20); |
| | | ackMsg = new AckMsg(updateMsg.getChangeNumber(), true, false, false, serversInError); |
| | | session.publish(ackMsg); |
| | | |
| | |
| | | assertEquals(getMonitorAttrValue(baseDn, "assured-sr-timeout-updates"), 0); |
| | | assertEquals(getMonitorAttrValue(baseDn, "assured-sr-wrong-status-updates"), 0); |
| | | assertEquals(getMonitorAttrValue(baseDn, "assured-sr-replay-error-updates"), 0); |
| | | Map<Short, Integer> errorsByServer = getErrorsByServers(baseDn, AssuredMode.SAFE_READ_MODE); |
| | | Map<Integer, Integer> errorsByServer = getErrorsByServers(baseDn, AssuredMode.SAFE_READ_MODE); |
| | | assertTrue(errorsByServer.isEmpty()); |
| | | assertEquals(getMonitorAttrValue(baseDn, "assured-sr-received-updates"), 0); |
| | | assertEquals(getMonitorAttrValue(baseDn, "assured-sr-received-updates-acked"), 0); |
| | |
| | | errorsByServer = getErrorsByServers(baseDn, AssuredMode.SAFE_DATA_MODE); |
| | | // errors by server list for sd mode should be [[rsId:1]] |
| | | assertEquals(errorsByServer.size(), 1); |
| | | Integer nError = errorsByServer.get((short)RS_SERVER_ID); |
| | | Integer nError = errorsByServer.get(RS_SERVER_ID); |
| | | assertNotNull(nError); |
| | | assertEquals(nError.intValue(), 1); |
| | | } else |
| | |
| | | assertEquals(getMonitorAttrValue(baseDn, "assured-sr-timeout-updates"), 0); |
| | | assertEquals(getMonitorAttrValue(baseDn, "assured-sr-wrong-status-updates"), 0); |
| | | assertEquals(getMonitorAttrValue(baseDn, "assured-sr-replay-error-updates"), 0); |
| | | Map<Short, Integer> errorsByServer = getErrorsByServers(baseDn, AssuredMode.SAFE_READ_MODE); |
| | | Map<Integer, Integer> errorsByServer = getErrorsByServers(baseDn, AssuredMode.SAFE_READ_MODE); |
| | | assertTrue(errorsByServer.isEmpty()); |
| | | assertEquals(getMonitorAttrValue(baseDn, "assured-sr-received-updates"), 0); |
| | | assertEquals(getMonitorAttrValue(baseDn, "assured-sr-received-updates-acked"), 0); |
| | |
| | | assertEquals(getMonitorAttrValue(baseDn, "assured-sr-timeout-updates"), 1); |
| | | assertEquals(getMonitorAttrValue(baseDn, "assured-sr-wrong-status-updates"), 0); |
| | | assertEquals(getMonitorAttrValue(baseDn, "assured-sr-replay-error-updates"), 0); |
| | | Map<Short, Integer> errorsByServer = getErrorsByServers(baseDn, AssuredMode.SAFE_READ_MODE); |
| | | Map<Integer, Integer> errorsByServer = getErrorsByServers(baseDn, AssuredMode.SAFE_READ_MODE); |
| | | // errors by server list for sr mode should be [[rsId:1]] |
| | | assertEquals(errorsByServer.size(), 1); |
| | | Integer nError = errorsByServer.get((short)RS_SERVER_ID); |
| | | Integer nError = errorsByServer.get(RS_SERVER_ID); |
| | | assertNotNull(nError); |
| | | assertEquals(nError.intValue(), 1); |
| | | assertEquals(getMonitorAttrValue(baseDn, "assured-sr-received-updates"), 0); |
| | |
| | | assertEquals(getMonitorAttrValue(baseDn, "assured-sr-timeout-updates"), 0); |
| | | assertEquals(getMonitorAttrValue(baseDn, "assured-sr-wrong-status-updates"), 0); |
| | | assertEquals(getMonitorAttrValue(baseDn, "assured-sr-replay-error-updates"), 0); |
| | | Map<Short, Integer> errorsByServer = getErrorsByServers(baseDn, AssuredMode.SAFE_READ_MODE); |
| | | Map<Integer, Integer> errorsByServer = getErrorsByServers(baseDn, AssuredMode.SAFE_READ_MODE); |
| | | assertTrue(errorsByServer.isEmpty()); |
| | | assertEquals(getMonitorAttrValue(baseDn, "assured-sr-received-updates"), 0); |
| | | assertEquals(getMonitorAttrValue(baseDn, "assured-sr-received-updates-acked"), 0); |
| | |
| | | assertEquals(getMonitorAttrValue(baseDn, "assured-sr-timeout-updates"), 0); |
| | | assertEquals(getMonitorAttrValue(baseDn, "assured-sr-wrong-status-updates"), 0); |
| | | assertEquals(getMonitorAttrValue(baseDn, "assured-sr-replay-error-updates"), 0); |
| | | Map<Short, Integer> errorsByServer = getErrorsByServers(baseDn, AssuredMode.SAFE_READ_MODE); |
| | | Map<Integer, Integer> errorsByServer = getErrorsByServers(baseDn, AssuredMode.SAFE_READ_MODE); |
| | | assertTrue(errorsByServer.isEmpty()); |
| | | assertEquals(getMonitorAttrValue(baseDn, "assured-sr-received-updates"), 0); |
| | | assertEquals(getMonitorAttrValue(baseDn, "assured-sr-received-updates-acked"), 0); |
| | |
| | | assertEquals(getMonitorAttrValue(baseDn, "assured-sr-timeout-updates"), 0); |
| | | assertEquals(getMonitorAttrValue(baseDn, "assured-sr-wrong-status-updates"), 0); |
| | | assertEquals(getMonitorAttrValue(baseDn, "assured-sr-replay-error-updates"), 0); |
| | | Map<Short, Integer> errorsByServer = getErrorsByServers(baseDn, AssuredMode.SAFE_READ_MODE); |
| | | Map<Integer, Integer> errorsByServer = getErrorsByServers(baseDn, AssuredMode.SAFE_READ_MODE); |
| | | assertTrue(errorsByServer.isEmpty()); |
| | | assertEquals(getMonitorAttrValue(baseDn, "assured-sr-received-updates"), 0); |
| | | assertEquals(getMonitorAttrValue(baseDn, "assured-sr-received-updates-acked"), 0); |
| | |
| | | assertEquals(getMonitorAttrValue(baseDn, "assured-sr-timeout-updates"), 0); |
| | | assertEquals(getMonitorAttrValue(baseDn, "assured-sr-wrong-status-updates"), 0); |
| | | assertEquals(getMonitorAttrValue(baseDn, "assured-sr-replay-error-updates"), 0); |
| | | Map<Short, Integer> errorsByServer = getErrorsByServers(baseDn, AssuredMode.SAFE_READ_MODE); |
| | | Map<Integer, Integer> errorsByServer = getErrorsByServers(baseDn, AssuredMode.SAFE_READ_MODE); |
| | | assertTrue(errorsByServer.isEmpty()); |
| | | assertEquals(getMonitorAttrValue(baseDn, "assured-sr-received-updates"), 1); |
| | | assertEquals(getMonitorAttrValue(baseDn, "assured-sr-received-updates-acked"), 1); |
| | |
| | | assertEquals(getMonitorAttrValue(baseDn, "assured-sr-timeout-updates"), 0); |
| | | assertEquals(getMonitorAttrValue(baseDn, "assured-sr-wrong-status-updates"), 0); |
| | | assertEquals(getMonitorAttrValue(baseDn, "assured-sr-replay-error-updates"), 0); |
| | | Map<Short, Integer> errorsByServer = getErrorsByServers(baseDn, AssuredMode.SAFE_READ_MODE); |
| | | Map<Integer, Integer> errorsByServer = getErrorsByServers(baseDn, AssuredMode.SAFE_READ_MODE); |
| | | assertTrue(errorsByServer.isEmpty()); |
| | | assertEquals(getMonitorAttrValue(baseDn, "assured-sr-received-updates"), 0); |
| | | assertEquals(getMonitorAttrValue(baseDn, "assured-sr-received-updates-acked"), 0); |
| | |
| | | errorsByServer = getErrorsByServers(baseDn, AssuredMode.SAFE_DATA_MODE); |
| | | // errors by server list for sd mode should be [[10:1]] |
| | | assertEquals(errorsByServer.size(), 1); |
| | | Integer nError = errorsByServer.get((short)10); |
| | | Integer nError = errorsByServer.get(10); |
| | | assertNotNull(nError); |
| | | assertEquals(nError.intValue(), 1); |
| | | |
| | |
| | | errorsByServer = getErrorsByServers(baseDn, AssuredMode.SAFE_DATA_MODE); |
| | | // errors by server list for sd mode should be [[10:2],[20:1]] |
| | | assertEquals(errorsByServer.size(), 2); |
| | | nError = errorsByServer.get((short)10); |
| | | nError = errorsByServer.get(10); |
| | | assertNotNull(nError); |
| | | assertEquals(nError.intValue(), 2); |
| | | nError = errorsByServer.get((short)20); |
| | | nError = errorsByServer.get(20); |
| | | assertNotNull(nError); |
| | | assertEquals(nError.intValue(), 1); |
| | | |
| | |
| | | errorsByServer = getErrorsByServers(baseDn, AssuredMode.SAFE_DATA_MODE); |
| | | // errors by server list for sd mode should be [[10:2],[20:1],[rsId:1]] |
| | | assertEquals(errorsByServer.size(), 3); |
| | | nError = errorsByServer.get((short)10); |
| | | nError = errorsByServer.get(10); |
| | | assertNotNull(nError); |
| | | assertEquals(nError.intValue(), 2); |
| | | nError = errorsByServer.get((short)20); |
| | | nError = errorsByServer.get(20); |
| | | assertNotNull(nError); |
| | | assertEquals(nError.intValue(), 1); |
| | | nError = errorsByServer.get((short)RS_SERVER_ID); |
| | | nError = errorsByServer.get(RS_SERVER_ID); |
| | | assertNotNull(nError); |
| | | assertEquals(nError.intValue(), 1); |
| | | |
| | |
| | | assertEquals(getMonitorAttrValue(baseDn, "assured-sr-timeout-updates"), 0); |
| | | assertEquals(getMonitorAttrValue(baseDn, "assured-sr-wrong-status-updates"), 0); |
| | | assertEquals(getMonitorAttrValue(baseDn, "assured-sr-replay-error-updates"), 1); |
| | | Map<Short, Integer> errorsByServer = getErrorsByServers(baseDn, AssuredMode.SAFE_READ_MODE); |
| | | Map<Integer, Integer> errorsByServer = getErrorsByServers(baseDn, AssuredMode.SAFE_READ_MODE); |
| | | // errors by server list for sr mode should be [[10:1],[20:1]] |
| | | assertEquals(errorsByServer.size(), 2); |
| | | Integer nError = errorsByServer.get((short)10); |
| | | Integer nError = errorsByServer.get(10); |
| | | assertNotNull(nError); |
| | | assertEquals(nError.intValue(), 1); |
| | | nError = errorsByServer.get((short)20); |
| | | nError = errorsByServer.get(20); |
| | | assertNotNull(nError); |
| | | assertEquals(nError.intValue(), 1); |
| | | assertEquals(getMonitorAttrValue(baseDn, "assured-sr-received-updates"), 0); |
| | |
| | | errorsByServer = getErrorsByServers(baseDn, AssuredMode.SAFE_READ_MODE); |
| | | // errors by server list for sr mode should be [[10:2],[20:2],[30:1]] |
| | | assertEquals(errorsByServer.size(), 3); |
| | | nError = errorsByServer.get((short)10); |
| | | nError = errorsByServer.get(10); |
| | | assertNotNull(nError); |
| | | assertEquals(nError.intValue(), 2); |
| | | nError = errorsByServer.get((short)20); |
| | | nError = errorsByServer.get(20); |
| | | assertNotNull(nError); |
| | | assertEquals(nError.intValue(), 2); |
| | | nError = errorsByServer.get((short)30); |
| | | nError = errorsByServer.get(30); |
| | | assertNotNull(nError); |
| | | assertEquals(nError.intValue(), 1); |
| | | assertEquals(getMonitorAttrValue(baseDn, "assured-sr-received-updates"), 0); |
| | |
| | | errorsByServer = getErrorsByServers(baseDn, AssuredMode.SAFE_READ_MODE); |
| | | // errors by server list for sr mode should be [[10:2],[20:2],[30:1],[rsId:1]] |
| | | assertEquals(errorsByServer.size(), 4); |
| | | nError = errorsByServer.get((short)10); |
| | | nError = errorsByServer.get(10); |
| | | assertNotNull(nError); |
| | | assertEquals(nError.intValue(), 2); |
| | | nError = errorsByServer.get((short)20); |
| | | nError = errorsByServer.get(20); |
| | | assertNotNull(nError); |
| | | assertEquals(nError.intValue(), 2); |
| | | nError = errorsByServer.get((short)30); |
| | | nError = errorsByServer.get(30); |
| | | assertNotNull(nError); |
| | | assertEquals(nError.intValue(), 1); |
| | | nError = errorsByServer.get((short)RS_SERVER_ID); |
| | | nError = errorsByServer.get(RS_SERVER_ID); |
| | | assertNotNull(nError); |
| | | assertEquals(nError.intValue(), 1); |
| | | assertEquals(getMonitorAttrValue(baseDn, "assured-sr-received-updates"), 0); |
| | |
| | | * - assured-sr-server-not-acknowledged-updates in SR mode |
| | | * - assured-sd-server-timeout-updates in SD mode |
| | | */ |
| | | protected Map<Short,Integer> getErrorsByServers(DN baseDn, |
| | | protected Map<Integer,Integer> getErrorsByServers(DN baseDn, |
| | | AssuredMode assuredMode) throws Exception |
| | | { |
| | | /* |
| | |
| | | |
| | | List<Attribute> attrs = entry.getAttribute(assuredAttr); |
| | | |
| | | Map<Short,Integer> resultMap = new HashMap<Short,Integer>(); |
| | | Map<Integer,Integer> resultMap = new HashMap<Integer,Integer>(); |
| | | if ( (attrs == null) || (attrs.isEmpty()) ) |
| | | return resultMap; // Empty map |
| | | |
| | |
| | | String token = strtok.nextToken(); |
| | | if (token != null) |
| | | { |
| | | Short serverId = Short.valueOf(token); |
| | | int serverId = Integer.valueOf(token); |
| | | token = strtok.nextToken(); |
| | | if (token != null) |
| | | { |
| | |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Copyright 2006-2009 Sun Microsystems, Inc. |
| | | */ |
| | | package org.opends.server.replication.plugin; |
| | | |
| | |
| | | AttributeValue att2 = AttributeValues.create(type, "value"); |
| | | AttributeValue att3 = AttributeValues.create(type, "again"); |
| | | |
| | | ChangeNumber del1 = new ChangeNumber(1, (short) 0, (short) 1); |
| | | ChangeNumber del2 = new ChangeNumber(1, (short) 1, (short) 1); |
| | | ChangeNumber del3 = new ChangeNumber(1, (short) 0, (short) 2); |
| | | ChangeNumber del1 = new ChangeNumber(1, 0, 1); |
| | | ChangeNumber del2 = new ChangeNumber(1, 1, 1); |
| | | ChangeNumber del3 = new ChangeNumber(1, 0, 2); |
| | | |
| | | ChangeNumber upd1 = new ChangeNumber(TimeThread.getTime(), |
| | | (short) 123, (short) 45); |
| | | ChangeNumber upd2 = new ChangeNumber(TimeThread.getTime() + 1000, |
| | | (short) 123, (short) 45); |
| | | ChangeNumber upd3 = new ChangeNumber(TimeThread.getTime(), |
| | | (short) 321, (short) 54); |
| | | ChangeNumber upd1 = new ChangeNumber(TimeThread.getTime(), 123, 45); |
| | | ChangeNumber upd2 = new ChangeNumber(TimeThread.getTime() + 1000, 123, 45); |
| | | ChangeNumber upd3 = new ChangeNumber(TimeThread.getTime(), 321, 54); |
| | | |
| | | return new Object[][] |
| | | { |
| | |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Copyright 2008-2009 Sun Microsystems, Inc. |
| | | */ |
| | | package org.opends.server.replication.plugin; |
| | | |
| | |
| | | debugInfo("Starting " + testCase); |
| | | |
| | | // definitions for server ids |
| | | short myId1 = 1; |
| | | short myId2 = 2; |
| | | short myId3 = 3; |
| | | int myId1 = 1; |
| | | int myId2 = 2; |
| | | int myId3 = 3; |
| | | |
| | | // definitions for server names |
| | | final String WINNER = "winner"; |
| | |
| | | debugInfo("Starting " + testCase); |
| | | |
| | | // definitions for server ids |
| | | short myId1 = 1; |
| | | short myId2 = 2; |
| | | short myId3 = 3; |
| | | int myId1 = 1; |
| | | int myId2 = 2; |
| | | int myId3 = 3; |
| | | // definitions for server names |
| | | final String WINNER = "winner"; |
| | | |
| | |
| | | debugInfo("Starting " + testCase); |
| | | |
| | | // definitions for server ids |
| | | short myId1 = 1; |
| | | short myId2 = 2; |
| | | short myId3 = 3; |
| | | int myId1 = 1; |
| | | int myId2 = 2; |
| | | int myId3 = 3; |
| | | |
| | | // definitions for server names |
| | | final String WINNER = "winner"; |
| | |
| | | debugInfo("Starting " + testCase); |
| | | |
| | | // definitions for server ids |
| | | short myId1 = 1; |
| | | short myId2 = 2; |
| | | short myId3 = 3; |
| | | int myId1 = 1; |
| | | int myId2 = 2; |
| | | int myId3 = 3; |
| | | // definitions for server names |
| | | final String WINNER = "winner"; |
| | | |
| | |
| | | debugInfo("Starting " + testCase); |
| | | |
| | | // definitions for server ids |
| | | short myId1 = 1; |
| | | short myId2 = 2; |
| | | short myId3 = 3; |
| | | int myId1 = 1; |
| | | int myId2 = 2; |
| | | int myId3 = 3; |
| | | // definitions for server names |
| | | final String WINNER = "winner"; |
| | | final String LOOSER1 = "looser1"; |
| | |
| | | debugInfo("Starting " + testCase); |
| | | |
| | | // definitions for server ids |
| | | short myId1 = 1; |
| | | short myId2 = 2; |
| | | short myId3 = 3; |
| | | int myId1 = 1; |
| | | int myId2 = 2; |
| | | int myId3 = 3; |
| | | // definitions for server names |
| | | final String WINNER = "winner"; |
| | | final String LOOSER1 = "looser1"; |
| | |
| | | debugInfo("Starting " + testCase); |
| | | |
| | | // definitions for server ids |
| | | short myId1 = 1; |
| | | short myId2 = 2; |
| | | short myId3 = 3; |
| | | int myId1 = 1; |
| | | int myId2 = 2; |
| | | int myId3 = 3; |
| | | // definitions for server names |
| | | final String WINNER = "winner"; |
| | | final String LOOSER1 = "looser1"; |
| | |
| | | debugInfo("Starting " + testCase); |
| | | |
| | | // definitions for server ids |
| | | short myId1 = 1; |
| | | short myId2 = 2; |
| | | short myId3 = 3; |
| | | int myId1 = 1; |
| | | int myId2 = 2; |
| | | int myId3 = 3; |
| | | // definitions for server names |
| | | final String WINNER = "winner"; |
| | | final String LOOSER1 = "looser1"; |
| | |
| | | debugInfo("Starting " + testCase); |
| | | |
| | | // definitions for server ids |
| | | short myId1 = 1; |
| | | short myId2 = 2; |
| | | short myId3 = 3; |
| | | int myId1 = 1; |
| | | int myId2 = 2; |
| | | int myId3 = 3; |
| | | // definitions for server names |
| | | final String WINNER = "winner"; |
| | | final String LOOSER1 = "looser1"; |
| | |
| | | debugInfo("Starting " + testCase); |
| | | |
| | | // definitions for server ids |
| | | short myId1 = 1; |
| | | short myId2 = 2; |
| | | short myId3 = 3; |
| | | int myId1 = 1; |
| | | int myId2 = 2; |
| | | int myId3 = 3; |
| | | // definitions for server names |
| | | final String WINNER = "winner"; |
| | | |
| | |
| | | debugInfo("Starting " + testCase); |
| | | |
| | | // definitions for server ids |
| | | short myId1 = 1; |
| | | short myId2 = 2; |
| | | short myId3 = 3; |
| | | int myId1 = 1; |
| | | int myId2 = 2; |
| | | int myId3 = 3; |
| | | // definitions for server names |
| | | final String WINNER = "winner"; |
| | | final String LOOSER1 = "looser1"; |
| | |
| | | debugInfo("Starting " + testCase); |
| | | |
| | | // definitions for server ids |
| | | short myId1 = 1; |
| | | short myId2 = 2; |
| | | short myId3 = 3; |
| | | int myId1 = 1; |
| | | int myId2 = 2; |
| | | int myId3 = 3; |
| | | // definitions for server names |
| | | final String WINNER = "winner"; |
| | | final String LOOSER1 = "looser1"; |
| | |
| | | debugInfo("Starting " + testCase); |
| | | |
| | | // definitions for server ids |
| | | short myId1 = 1; |
| | | short myId2 = 2; |
| | | short myId3 = 3; |
| | | int myId1 = 1; |
| | | int myId2 = 2; |
| | | int myId3 = 3; |
| | | |
| | | // definitions for server names |
| | | final String WINNER = "winner"; |
| | |
| | | private FakeReplicationDomain replicationDomain = null; |
| | | |
| | | // Ids of servers |
| | | private static final short DS1_ID = 1; // fractional domain |
| | | private static final short DS2_ID = 2; // fake domain |
| | | private static final short RS_ID = 91; // replication server |
| | | private static final int DS1_ID = 1; // fractional domain |
| | | private static final int DS2_ID = 2; // fake domain |
| | | private static final int RS_ID = 91; // replication server |
| | | |
| | | private final String testName = this.getClass().getSimpleName(); |
| | | |
| | |
| | | |
| | | public FakeReplicationDomain( |
| | | String serviceID, |
| | | short serverID, |
| | | int serverID, |
| | | Collection<String> replicationServers, |
| | | int window, |
| | | long heartbeatInterval, |
| | |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Copyright 2008-2009 Sun Microsystems, Inc. |
| | | */ |
| | | package org.opends.server.replication.plugin; |
| | | |
| | |
| | | */ |
| | | public class GroupIdHandshakeTest extends ReplicationTestCase |
| | | { |
| | | private static final short DS1_ID = 1; |
| | | private static final short DS2_ID = 2; |
| | | private static final short RS1_ID = 61; |
| | | private static final short RS2_ID = 62; |
| | | private static final short RS3_ID = 63; |
| | | private static final int DS1_ID = 1; |
| | | private static final int DS2_ID = 2; |
| | | private static final int RS1_ID = 61; |
| | | private static final int RS2_ID = 62; |
| | | private static final int RS3_ID = 63; |
| | | private int rs1Port = -1; |
| | | private int rs2Port = -1; |
| | | private int rs3Port = -1; |
| | |
| | | * replication server. Waits for connection to be ok up to secTimeout seconds |
| | | * before failing. |
| | | */ |
| | | private void checkConnection(int secTimeout, short dsId, short rsId, String msg) |
| | | private void checkConnection(int secTimeout, int dsId, int rsId, String msg) |
| | | { |
| | | |
| | | int rsPort = -1; |
| | |
| | | /** |
| | | * Creates a new ReplicationServer. |
| | | */ |
| | | private ReplicationServer createReplicationServer(short serverId, |
| | | private ReplicationServer createReplicationServer(int serverId, |
| | | int groupId, String testCase) |
| | | { |
| | | SortedSet<String> replServers = new TreeSet<String>(); |
| | |
| | | /** |
| | | * Creates a new ReplicationDomain. |
| | | */ |
| | | private LDAPReplicationDomain createReplicationDomain(short serverId, |
| | | private LDAPReplicationDomain createReplicationDomain(int serverId, |
| | | int groupId, String testCase) |
| | | { |
| | | |
| | |
| | | "Change GID of RS3 to 1 and RS1 to 3, DS1 should reconnect to RS3 with GID=1"); |
| | | checkConnection(30, DS2_ID, RS3_ID, |
| | | "Change GID of RS3 to 1 and RS1 to 3, DS2 should reconnect to RS3 with GID=1"); |
| | | |
| | | |
| | | /** |
| | | * Change group id of DS1 and DS2 to 3 : they should reconnect to RS1 |
| | | */ |
| | | domainConfWithNewGid = new DomainFakeCfg(baseDn, DS1_ID, replServers, 3); |
| | | rd1.applyConfigurationChange(domainConfWithNewGid); |
| | | rd1.applyConfigurationChange(domainConfWithNewGid); |
| | | domainConfWithNewGid = new DomainFakeCfg(baseDn, DS2_ID, replServers, 3); |
| | | rd2.applyConfigurationChange(domainConfWithNewGid); |
| | | checkConnection(30, DS1_ID, RS1_ID, |
| | |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Copyright 2008-2009 Sun Microsystems, Inc. |
| | | */ |
| | | package org.opends.server.replication.plugin; |
| | | |
| | |
| | | HistoricalCsnOrderingMatchingRule r = |
| | | new HistoricalCsnOrderingMatchingRule(); |
| | | |
| | | ChangeNumber del1 = new ChangeNumber(1, (short) 0, (short) 1); |
| | | ChangeNumber del2 = new ChangeNumber(1, (short) 1, (short) 1); |
| | | ChangeNumber del1 = new ChangeNumber(1, 0, 1); |
| | | ChangeNumber del2 = new ChangeNumber(1, 1, 1); |
| | | |
| | | ByteString v1 = ByteString.valueOf("a"+":"+del1.toString()); |
| | | ByteString v2 = ByteString.valueOf("a"+":"+del2.toString()); |
| | |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Copyright 2008-2009 Sun Microsystems, Inc. |
| | | */ |
| | | |
| | | package org.opends.server.replication.plugin; |
| | |
| | | * This must use a different serverId to that of the directory server. |
| | | */ |
| | | ReplicationBroker broker = |
| | | openReplicationSession(baseDn, (short)2, 100, replServerPort, 1000, true); |
| | | openReplicationSession(baseDn, 2, 100, replServerPort, 1000, true); |
| | | |
| | | |
| | | // Clear the backend and create top entrye |
| | |
| | | attrs.get(0).iterator().next().getValue().toString(); |
| | | |
| | | // A change on a first server. |
| | | ChangeNumber t1 = new ChangeNumber(1, (short) 0, (short) 3); |
| | | ChangeNumber t1 = new ChangeNumber(1, 0, 3); |
| | | |
| | | // A change on a second server. |
| | | ChangeNumber t2 = new ChangeNumber(2, (short) 0, (short) 4); |
| | | ChangeNumber t2 = new ChangeNumber(2, 0, 4); |
| | | |
| | | // Simulate the ordering t1:add:A followed by t2:add:B that would |
| | | // happen on one server. |
| | |
| | | // Simulate the reverse ordering t2:add:B followed by t1:add:A that |
| | | // would happen on the other server. |
| | | |
| | | t1 = new ChangeNumber(3, (short) 0, (short) 3); |
| | | t2 = new ChangeNumber(4, (short) 0, (short) 4); |
| | | t1 = new ChangeNumber(3, 0, 3); |
| | | t2 = new ChangeNumber(4, 0, 4); |
| | | |
| | | // Replay an add of a value B at time t2 on a second server. |
| | | attr = Attributes.create(attrType.getNormalizedPrimaryName(), "B"); |
| | |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Copyright 2008-2009 Sun Microsystems, Inc. |
| | | */ |
| | | package org.opends.server.replication.plugin; |
| | | |
| | |
| | | LDAPReplicationDomain domain = null; |
| | | DN baseDn = DN.decode(TEST_ROOT_DN_STRING); |
| | | SynchronizationProvider replicationPlugin = null; |
| | | short serverId = 1; |
| | | int serverId = 1; |
| | | |
| | | try |
| | | { |
| | |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Copyright 2006-2009 Sun Microsystems, Inc. |
| | | */ |
| | | package org.opends.server.replication.plugin; |
| | | |
| | |
| | | |
| | | InternalClientConnection connection = |
| | | InternalClientConnection.getRootConnection(); |
| | | ChangeNumber t = new ChangeNumber(date, (short) 0, (short) 0); |
| | | ChangeNumber t = new ChangeNumber(date, 0, 0); |
| | | |
| | | List<Modification> mods = new ArrayList<Modification>(); |
| | | mods.add(mod); |
| | |
| | | * Create a Change number generator to generate new ChangeNumbers |
| | | * when we need to send operations messages to the replicationServer. |
| | | */ |
| | | ChangeNumberGenerator gen = new ChangeNumberGenerator((short) 201, 0); |
| | | ChangeNumberGenerator gen = new ChangeNumberGenerator(201, 0); |
| | | |
| | | String parentUUID = getEntryUUID(DN.decode(TEST_ROOT_DN_STRING)); |
| | | |
| | |
| | | DN baseDn = DN.decode(dn); |
| | | ServerState origState = new ServerState(); |
| | | PersistentServerState state = |
| | | new PersistentServerState(baseDn, (short) 1, origState); |
| | | new PersistentServerState(baseDn, 1, origState); |
| | | ChangeNumberGenerator gen1 = |
| | | new ChangeNumberGenerator((short) 1, origState); |
| | | new ChangeNumberGenerator( 1, origState); |
| | | ChangeNumberGenerator gen2 = |
| | | new ChangeNumberGenerator((short) 2, origState); |
| | | new ChangeNumberGenerator( 2, origState); |
| | | |
| | | ChangeNumber cn1 = gen1.newChangeNumber(); |
| | | ChangeNumber cn2 = gen2.newChangeNumber(); |
| | |
| | | |
| | | state.save(); |
| | | |
| | | PersistentServerState stateSaved = new PersistentServerState(baseDn, (short) 1); |
| | | ChangeNumber cn1Saved = stateSaved.getMaxChangeNumber((short) 1); |
| | | ChangeNumber cn2Saved = stateSaved.getMaxChangeNumber((short) 2); |
| | | PersistentServerState stateSaved = new PersistentServerState(baseDn, 1); |
| | | ChangeNumber cn1Saved = stateSaved.getMaxChangeNumber( 1); |
| | | ChangeNumber cn2Saved = stateSaved.getMaxChangeNumber( 2); |
| | | |
| | | assertEquals(cn1Saved, cn1, |
| | | "cn1 has not been saved or loaded correctly for " + dn); |
| | |
| | | "cn2 has not been saved or loaded correctly for " + dn); |
| | | |
| | | state.clear(); |
| | | stateSaved = new PersistentServerState(baseDn, (short) 1); |
| | | cn1Saved = stateSaved.getMaxChangeNumber((short) 1); |
| | | stateSaved = new PersistentServerState(baseDn, 1); |
| | | cn1Saved = stateSaved.getMaxChangeNumber( 1); |
| | | assertEquals(cn1Saved, null, |
| | | "cn1 has not been saved after clear for " + dn); |
| | | |
| | |
| | | assertTrue(replDomain.getGenerationID() == 1225361491); |
| | | |
| | | ServerState state = replDomain.getServerState(); |
| | | assertTrue(state.getMaxChangeNumber((short) 1). |
| | | assertTrue(state.getMaxChangeNumber( 1). |
| | | compareTo(new ChangeNumber("0000011d4d42b240000100000000")) == 0); |
| | | assertTrue(state.getMaxChangeNumber((short) 3). |
| | | assertTrue(state.getMaxChangeNumber( 3). |
| | | compareTo(new ChangeNumber("0000011d9a991110000300000000")) == 0); |
| | | |
| | | } |
| | |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Copyright 2006-2009 Sun Microsystems, Inc. |
| | | */ |
| | | package org.opends.server.replication.plugin; |
| | | |
| | |
| | | @Test(sequential = true) |
| | | public class ReplicationServerFailoverTest extends ReplicationTestCase |
| | | { |
| | | private static final short DS1_ID = 1; |
| | | private static final short DS2_ID = 2; |
| | | private static final short RS1_ID = 31; |
| | | private static final short RS2_ID = 32; |
| | | private static final int DS1_ID = 1; |
| | | private static final int DS2_ID = 2; |
| | | private static final int RS1_ID = 31; |
| | | private static final int RS2_ID = 32; |
| | | private int rs1Port = -1; |
| | | private int rs2Port = -1; |
| | | private LDAPReplicationDomain rd1 = null; |
| | |
| | | // Start DS1 |
| | | DN baseDn = DN.decode(TEST_ROOT_DN_STRING); |
| | | rd1 = createReplicationDomain(baseDn, DS1_ID); |
| | | |
| | | |
| | | // Wait a bit so that connections are performed |
| | | sleep(2000); |
| | | |
| | |
| | | rd1 = createReplicationDomain(baseDn, DS1_ID); |
| | | // Start DS2 |
| | | rd2 = createReplicationDomain(baseDn, DS2_ID); |
| | | |
| | | |
| | | // Wait a bit so that connections are performed |
| | | sleep(3000); |
| | | |
| | |
| | | * replication server. Waits for connection to be ok up to secTimeout seconds |
| | | * before failing. |
| | | */ |
| | | private void checkConnection(int secTimeout, short dsId, short rsId, String msg) |
| | | private void checkConnection(int secTimeout, int dsId, int rsId, String msg) |
| | | { |
| | | |
| | | int rsPort = -1; |
| | |
| | | /** |
| | | * Creates a new ReplicationServer. |
| | | */ |
| | | private ReplicationServer createReplicationServer(short serverId, |
| | | private ReplicationServer createReplicationServer(int serverId, |
| | | String suffix) |
| | | { |
| | | SortedSet<String> replServers = new TreeSet<String>(); |
| | |
| | | /** |
| | | * Creates a new ReplicationDomain. |
| | | */ |
| | | private LDAPReplicationDomain createReplicationDomain(DN baseDn, short serverId) |
| | | private LDAPReplicationDomain createReplicationDomain(DN baseDn, int serverId) |
| | | { |
| | | |
| | | SortedSet<String> replServers = new TreeSet<String>(); |
| | |
| | | |
| | | private static final String EXAMPLE_DN = "dc=example,dc=com"; // Server id definitions |
| | | |
| | | private static final short DS1_ID = 1; |
| | | private static final short DS2_ID = 2; |
| | | private static final short DS3_ID = 3; |
| | | private static final short RS1_ID = 41; |
| | | private static final int DS1_ID = 1; |
| | | private static final int DS2_ID = 2; |
| | | private static final int DS3_ID = 3; |
| | | private static final int RS1_ID = 41; |
| | | private int rs1Port = -1; |
| | | private LDAPReplicationDomain ds1 = null; |
| | | private ReplicationBroker ds2 = null; |
| | |
| | | * replication server. Waits for connection to be ok up to secTimeout seconds |
| | | * before failing. |
| | | */ |
| | | private void checkConnection(int secTimeout, short dsId) |
| | | private void checkConnection(int secTimeout, int dsId) |
| | | { |
| | | |
| | | ReplicationBroker rb = null; |
| | |
| | | * server |
| | | */ |
| | | @SuppressWarnings("unchecked") |
| | | private LDAPReplicationDomain createReplicationDomain(short dsId) |
| | | private LDAPReplicationDomain createReplicationDomain(int dsId) |
| | | { |
| | | try |
| | | { |
| | |
| | | * Create and connect a replication broker to the replication server with |
| | | * the given state and generation id (uses passed window for received changes) |
| | | */ |
| | | private ReplicationBroker createReplicationBroker(short dsId, |
| | | private ReplicationBroker createReplicationBroker(int dsId, |
| | | ServerState state, long generationId, int window) |
| | | throws Exception, SocketException |
| | | { |
| | |
| | | * Create and connect a replication broker to the replication server with |
| | | * the given state and generation id (uses 100 as window for received changes) |
| | | */ |
| | | private ReplicationBroker createReplicationBroker(short dsId, |
| | | private ReplicationBroker createReplicationBroker(int dsId, |
| | | ServerState state, long generationId) |
| | | throws Exception, SocketException |
| | | { |
| | |
| | | { |
| | | |
| | | private ReplicationBroker rb = null; |
| | | private short serverId = -1; |
| | | private int serverId = -1; |
| | | private long userId = 0; |
| | | private short destId = -1; // Server id of server to initialize |
| | | private int destId = -1; // Server id of server to initialize |
| | | private long nEntries = -1; // Number of entries to send to dest |
| | | private boolean createReader = false; |
| | | |
| | |
| | | /** |
| | | * Creates a broker initializer with a reader |
| | | */ |
| | | public BrokerInitializer(ReplicationBroker rb, short serverId) |
| | | public BrokerInitializer(ReplicationBroker rb, int serverId) |
| | | { |
| | | this(rb, serverId, true); |
| | | } |
| | |
| | | /** |
| | | * Creates a broker initializer. Also creates a reader according to request |
| | | */ |
| | | public BrokerInitializer(ReplicationBroker rb, short serverId, |
| | | public BrokerInitializer(ReplicationBroker rb, int serverId, |
| | | boolean createReader) |
| | | { |
| | | this.rb = rb; |
| | |
| | | /** |
| | | * Initializes a full update session by sending InitializeTargetMsg |
| | | */ |
| | | public void initFullUpdate(short destId, long nEntries) |
| | | public void initFullUpdate(int destId, long nEntries) |
| | | { |
| | | // Also create reader ? |
| | | if (createReader) |
| | |
| | | { |
| | | |
| | | private ReplicationBroker rb = null; |
| | | private short serverId = -1; |
| | | private int serverId = -1; |
| | | private long userId = 0; |
| | | private AtomicBoolean shutdown = new AtomicBoolean(false); |
| | | // The writer starts suspended |
| | |
| | | private BrokerReader reader = null; |
| | | |
| | | /* Creates a broker writer with a reader */ |
| | | public BrokerWriter(ReplicationBroker rb, short serverId) |
| | | public BrokerWriter(ReplicationBroker rb, int serverId) |
| | | { |
| | | this(rb, serverId, true); |
| | | } |
| | | |
| | | /* Creates a broker writer. Also creates a reader according to request */ |
| | | public BrokerWriter(ReplicationBroker rb, short serverId, |
| | | public BrokerWriter(ReplicationBroker rb, int serverId, |
| | | boolean createReader) |
| | | { |
| | | super("BrokerWriter for broker " + serverId); |
| | |
| | | { |
| | | |
| | | private ReplicationBroker rb = null; |
| | | private short serverId = -1; |
| | | private int serverId = -1; |
| | | private boolean shutdown = false; |
| | | private ReplicationMsg lastMsg = null; |
| | | |
| | | public BrokerReader(ReplicationBroker rb, short serverId) |
| | | public BrokerReader(ReplicationBroker rb, int serverId) |
| | | { |
| | | super("BrokerReader for broker " + serverId); |
| | | this.rb = rb; |
| | |
| | | public class TopologyViewTest extends ReplicationTestCase |
| | | { |
| | | // Server id definitions |
| | | private static final short DS1_ID = 1; |
| | | private static final short DS2_ID = 2; |
| | | private static final short DS3_ID = 3; |
| | | private static final short DS4_ID = 4; |
| | | private static final short DS5_ID = 5; |
| | | private static final short DS6_ID = 6; |
| | | private static final short RS1_ID = 51; |
| | | private static final short RS2_ID = 52; |
| | | private static final short RS3_ID = 53; |
| | | private static final int DS1_ID = 1; |
| | | private static final int DS2_ID = 2; |
| | | private static final int DS3_ID = 3; |
| | | private static final int DS4_ID = 4; |
| | | private static final int DS5_ID = 5; |
| | | private static final int DS6_ID = 6; |
| | | private static final int RS1_ID = 51; |
| | | private static final int RS2_ID = 52; |
| | | private static final int RS3_ID = 53; |
| | | |
| | | // Group id definitions |
| | | private static final int DS1_GID = 1; |
| | |
| | | } |
| | | } |
| | | |
| | | private void debugInfo(String message, Exception e) |
| | | { |
| | | debugInfo(message + stackTraceToSingleLineString(e)); |
| | | } |
| | | |
| | | private void initTest() |
| | | { |
| | | rs1Port = -1; |
| | |
| | | * replication server. Waits for connection to be ok up to secTimeout seconds |
| | | * before failing. |
| | | */ |
| | | private void checkConnection(int secTimeout, short dsId, short rsId) |
| | | private void checkConnection(int secTimeout, int dsId, int rsId) |
| | | { |
| | | int rsPort = -1; |
| | | LDAPReplicationDomain rd = null; |
| | |
| | | * Creates the list of servers to represent the RS topology excluding the |
| | | * RS whose id is passed. |
| | | */ |
| | | private SortedSet<String> createRSListExceptOne(short rsIdToExclude) |
| | | private SortedSet<String> createRSListExceptOne(int rsIdToExclude) |
| | | { |
| | | SortedSet<String> replServers = new TreeSet<String>(); |
| | | |
| | |
| | | /** |
| | | * Creates a new ReplicationServer. |
| | | */ |
| | | private ReplicationServer createReplicationServer(short rsId, String testCase) |
| | | private ReplicationServer createReplicationServer(int rsId, String testCase) |
| | | { |
| | | try |
| | | { |
| | |
| | | * Creates and starts a new ReplicationDomain with the correct list of |
| | | * know RSs according to DS id |
| | | */ |
| | | private LDAPReplicationDomain createReplicationDomain(short dsId) |
| | | private LDAPReplicationDomain createReplicationDomain(int dsId) |
| | | { |
| | | try |
| | | { |
| | |
| | | rd1 = createReplicationDomain(DS1_ID); |
| | | checkConnection(30, DS1_ID, RS1_ID); |
| | | theoricalTopoView = createTheoreticalTopoViewForStep(STEP_1); |
| | | checkTopoView(new short[] {DS1_ID}, theoricalTopoView); |
| | | checkTopoView(new int[] {DS1_ID}, theoricalTopoView); |
| | | |
| | | /** |
| | | * DS2 starts and connects to RS1 (check topo view in DS1,DS2) |
| | |
| | | checkConnection(30, DS1_ID, RS1_ID); |
| | | checkConnection(30, DS2_ID, RS1_ID); |
| | | theoricalTopoView = createTheoreticalTopoViewForStep(STEP_2); |
| | | checkTopoView(new short[] {DS1_ID, DS2_ID}, theoricalTopoView); |
| | | checkTopoView(new int[] {DS1_ID, DS2_ID}, theoricalTopoView); |
| | | |
| | | /** |
| | | * RS2 starts (check topo view in DS1,DS2) |
| | |
| | | checkConnection(30, DS1_ID, RS1_ID); |
| | | checkConnection(30, DS2_ID, RS1_ID); |
| | | theoricalTopoView = createTheoreticalTopoViewForStep(STEP_3); |
| | | checkTopoView(new short[] {DS1_ID, DS2_ID}, theoricalTopoView); |
| | | checkTopoView(new int[] {DS1_ID, DS2_ID}, theoricalTopoView); |
| | | |
| | | /** |
| | | * DS3 starts and connects to RS2 (check topo view in DS1,DS2,DS3) |
| | |
| | | checkConnection(30, DS2_ID, RS1_ID); |
| | | checkConnection(30, DS3_ID, RS2_ID); |
| | | theoricalTopoView = createTheoreticalTopoViewForStep(STEP_4); |
| | | checkTopoView(new short[] {DS1_ID, DS2_ID, DS3_ID}, theoricalTopoView); |
| | | checkTopoView(new int[] {DS1_ID, DS2_ID, DS3_ID}, theoricalTopoView); |
| | | |
| | | /** |
| | | * DS4 starts and connects to RS2 (check topo view in DS1,DS2,DS3,DS4) |
| | |
| | | checkConnection(30, DS3_ID, RS2_ID); |
| | | checkConnection(30, DS4_ID, RS2_ID); |
| | | theoricalTopoView = createTheoreticalTopoViewForStep(STEP_5); |
| | | checkTopoView(new short[] {DS1_ID, DS2_ID, DS3_ID, DS4_ID}, |
| | | checkTopoView(new int[] {DS1_ID, DS2_ID, DS3_ID, DS4_ID}, |
| | | theoricalTopoView); |
| | | |
| | | /** |
| | |
| | | checkConnection(30, DS4_ID, RS2_ID); |
| | | checkConnection(30, DS5_ID, RS2_ID); |
| | | theoricalTopoView = createTheoreticalTopoViewForStep(STEP_6); |
| | | checkTopoView(new short[] {DS1_ID, DS2_ID, DS3_ID, DS4_ID, DS5_ID}, |
| | | checkTopoView(new int[] {DS1_ID, DS2_ID, DS3_ID, DS4_ID, DS5_ID}, |
| | | theoricalTopoView); |
| | | |
| | | /** |
| | |
| | | checkConnection(30, DS4_ID, RS2_ID); |
| | | checkConnection(30, DS5_ID, RS3_ID); |
| | | theoricalTopoView = createTheoreticalTopoViewForStep(STEP_7); |
| | | checkTopoView(new short[] {DS1_ID, DS2_ID, DS3_ID, DS4_ID, DS5_ID}, |
| | | checkTopoView(new int[] {DS1_ID, DS2_ID, DS3_ID, DS4_ID, DS5_ID}, |
| | | theoricalTopoView); |
| | | |
| | | |
| | |
| | | checkConnection(30, DS5_ID, RS3_ID); |
| | | checkConnection(30, DS6_ID, RS3_ID); |
| | | theoricalTopoView = createTheoreticalTopoViewForStep(STEP_8); |
| | | checkTopoView(new short[] {DS1_ID, DS2_ID, DS3_ID, DS4_ID, DS5_ID, DS6_ID}, |
| | | checkTopoView(new int[] {DS1_ID, DS2_ID, DS3_ID, DS4_ID, DS5_ID, DS6_ID}, |
| | | theoricalTopoView); |
| | | |
| | | |
| | |
| | | checkConnection(30, DS5_ID, RS3_ID); |
| | | assertFalse(rd6.isConnected()); |
| | | theoricalTopoView = createTheoreticalTopoViewForStep(STEP_9); |
| | | checkTopoView(new short[] {DS1_ID, DS2_ID, DS3_ID, DS4_ID, DS5_ID}, |
| | | checkTopoView(new int[] {DS1_ID, DS2_ID, DS3_ID, DS4_ID, DS5_ID}, |
| | | theoricalTopoView); |
| | | |
| | | |
| | |
| | | checkConnection(30, DS5_ID, RS3_ID); |
| | | checkConnection(30, DS6_ID, RS3_ID); |
| | | theoricalTopoView = createTheoreticalTopoViewForStep(STEP_10); |
| | | checkTopoView(new short[] {DS1_ID, DS2_ID, DS3_ID, DS4_ID, DS5_ID, DS6_ID}, |
| | | checkTopoView(new int[] {DS1_ID, DS2_ID, DS3_ID, DS4_ID, DS5_ID, DS6_ID}, |
| | | theoricalTopoView); |
| | | |
| | | |
| | |
| | | checkConnection(30, DS5_ID, RS2_ID); |
| | | checkConnection(30, DS6_ID, RS2_ID); |
| | | theoricalTopoView = createTheoreticalTopoViewForStep(STEP_11); |
| | | checkTopoView(new short[] {DS1_ID, DS2_ID, DS3_ID, DS4_ID, DS5_ID, DS6_ID}, |
| | | checkTopoView(new int[] {DS1_ID, DS2_ID, DS3_ID, DS4_ID, DS5_ID, DS6_ID}, |
| | | theoricalTopoView); |
| | | |
| | | |
| | |
| | | checkConnection(30, DS5_ID, RS3_ID); |
| | | checkConnection(30, DS6_ID, RS3_ID); |
| | | theoricalTopoView = createTheoreticalTopoViewForStep(STEP_12); |
| | | checkTopoView(new short[] {DS1_ID, DS2_ID, DS3_ID, DS4_ID, DS5_ID, DS6_ID}, |
| | | checkTopoView(new int[] {DS1_ID, DS2_ID, DS3_ID, DS4_ID, DS5_ID, DS6_ID}, |
| | | theoricalTopoView); |
| | | |
| | | |
| | |
| | | checkConnection(30, DS5_ID, RS3_ID); |
| | | checkConnection(30, DS6_ID, RS3_ID); |
| | | theoricalTopoView = createTheoreticalTopoViewForStep(STEP_13); |
| | | checkTopoView(new short[] {DS1_ID, DS2_ID, DS5_ID, DS6_ID}, |
| | | checkTopoView(new int[] {DS1_ID, DS2_ID, DS5_ID, DS6_ID}, |
| | | theoricalTopoView); |
| | | |
| | | } finally |
| | |
| | | /** |
| | | * Creates RSInfo for the passed RS |
| | | */ |
| | | private RSInfo createRSInfo(short rsId) |
| | | private RSInfo createRSInfo(int rsId) |
| | | { |
| | | int groupId = -1; |
| | | switch (rsId) |
| | |
| | | /** |
| | | * Creates DSInfo for the passed DS, connected to the passed RS |
| | | */ |
| | | private DSInfo createDSInfo(short dsId, short rsId) |
| | | private DSInfo createDSInfo(int dsId, int rsId) |
| | | { |
| | | ServerStatus status = ServerStatus.NORMAL_STATUS; |
| | | |
| | |
| | | AssuredType assuredType = null; |
| | | int assuredSdLevel = -100; |
| | | SortedSet<String> refUrls = null; |
| | | SortedSet<String> attrs = null; |
| | | SortedSet<String> attrs = new TreeSet<String>(); |
| | | |
| | | switch (dsId) |
| | | { |
| | |
| | | * with the theoretical topology view that every body should have at the time |
| | | * this method is called. |
| | | */ |
| | | private void checkTopoView(short[] dsIdList, TopoView theoricalTopoView) |
| | | private void checkTopoView(int[] dsIdList, TopoView theoricalTopoView) |
| | | { |
| | | for(short currentDsId : dsIdList) |
| | | for(int currentDsId : dsIdList) |
| | | { |
| | | LDAPReplicationDomain rd = null; |
| | | |
| | |
| | | { |
| | | dsList.add(aDsInfo); |
| | | } |
| | | short dsId = rd.getServerId(); |
| | | short rsId = rd.getRsServerId(); |
| | | int dsId = rd.getServerId(); |
| | | int rsId = rd.getRsServerId(); |
| | | ServerStatus status = rd.getStatus(); |
| | | boolean assuredFlag = rd.isAssured(); |
| | | AssuredMode assuredMode = rd.getAssuredMode(); |
| | |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Copyright 2006-2009 Sun Microsystems, Inc. |
| | | */ |
| | | package org.opends.server.replication.plugin; |
| | | |
| | |
| | | AttributeValue att2 = AttributeValues.create(type, "value"); |
| | | AttributeValue att3 = AttributeValues.create(type, "again"); |
| | | |
| | | ChangeNumber del1 = new ChangeNumber(1, (short) 0, (short) 1); |
| | | ChangeNumber del2 = new ChangeNumber(1, (short) 1, (short) 1); |
| | | ChangeNumber del3 = new ChangeNumber(1, (short) 0, (short) 2); |
| | | ChangeNumber del1 = new ChangeNumber(1, 0, 1); |
| | | ChangeNumber del2 = new ChangeNumber(1, 1, 1); |
| | | ChangeNumber del3 = new ChangeNumber(1, 0, 2); |
| | | |
| | | ChangeNumber upd1 = new ChangeNumber(TimeThread.getTime(), |
| | | (short) 123, (short) 45); |
| | | ChangeNumber upd2 = new ChangeNumber(TimeThread.getTime()+ 1000, |
| | | (short) 123, (short) 45); |
| | | ChangeNumber upd3 = new ChangeNumber(TimeThread.getTime(), |
| | | (short) 321, (short) 54); |
| | | ChangeNumber upd1 = new ChangeNumber(TimeThread.getTime(), 123, 45); |
| | | ChangeNumber upd2 = new ChangeNumber(TimeThread.getTime()+ 1000, 123, 45); |
| | | ChangeNumber upd3 = new ChangeNumber(TimeThread.getTime(), 321, 54); |
| | | |
| | | return new Object[][] { |
| | | {att1,null,null}, |
| | |
| | | |
| | | package org.opends.server.replication.protocol; |
| | | |
| | | import java.io.UnsupportedEncodingException; |
| | | import java.math.BigInteger; |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.HashSet; |
| | | import java.util.List; |
| | | import java.util.zip.DataFormatException; |
| | | |
| | | import org.opends.server.core.AddOperationBasis; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.core.ModifyDNOperationBasis; |
| | |
| | | import org.opends.server.replication.ReplicationTestCase; |
| | | import org.opends.server.replication.common.AssuredMode; |
| | | import org.opends.server.replication.common.ChangeNumber; |
| | | import org.opends.server.replication.common.DSInfo; |
| | | import org.opends.server.replication.common.RSInfo; |
| | | import org.opends.server.replication.common.ServerState; |
| | | import org.opends.server.replication.common.ServerStatus; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeBuilder; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.Attributes; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.Modification; |
| | | import org.opends.server.types.ModificationType; |
| | | import org.opends.server.types.ObjectClass; |
| | |
| | | { |
| | | String baseDN = "o=test"; |
| | | ServerState state = new ServerState(); |
| | | state.update(new ChangeNumber((long)0, 0,(short)0)); |
| | | Object[] set1 = new Object[] {(short)1, baseDN, 0, "localhost:8989", state, 0L, (byte)0, 0}; |
| | | state.update(new ChangeNumber((long)0, 0,0)); |
| | | Object[] set1 = new Object[] {1, baseDN, 0, "localhost:8989", state, 0L, (byte)0, 0}; |
| | | |
| | | baseDN = "dc=example,dc=com"; |
| | | state = new ServerState(); |
| | | state.update(new ChangeNumber((long)75, 5,(short)263)); |
| | | Object[] set2 = new Object[] {(short)16, baseDN, 100, "anotherHost:1025", state, 1245L, (byte)25, 3456}; |
| | | state.update(new ChangeNumber((long)75, 5,263)); |
| | | Object[] set2 = new Object[] {16, baseDN, 100, "anotherHost:1025", state, 1245L, (byte)25, 3456}; |
| | | |
| | | return new Object [][] { set1, set2 }; |
| | | } |
| | |
| | | * using protocol VLAST and V2 are working. |
| | | */ |
| | | @Test(dataProvider="createReplServerStartData") |
| | | public void replServerStartMsgTestVLASTV2(short serverId, String baseDN, int window, |
| | | public void replServerStartMsgTestVLASTV2(int serverId, String baseDN, int window, |
| | | String url, ServerState state, long genId, byte groupId, int degTh) throws Exception |
| | | { |
| | | // TODO: replServerStartMsgTestV3V2 as soon as V3 will have any incompatibility with V2 |
| | | } |
| | | |
| | | @Test(dataProvider="createReplServerStartData") |
| | | public void replServerStartMsgTestVLASTV1(short serverId, String baseDN, int window, |
| | | public void replServerStartMsgTestVLASTV1(int serverId, String baseDN, int window, |
| | | String url, ServerState state, long genId, byte groupId, int degTh) throws Exception |
| | | { |
| | | // Create VLAST message |
| | |
| | | assertEquals(msg.getServerURL(), newMsg.getServerURL()); |
| | | assertEquals(msg.getBaseDn(), newMsg.getBaseDn()); |
| | | assertEquals(msg.getWindowSize(), newMsg.getWindowSize()); |
| | | assertEquals(msg.getServerState().getMaxChangeNumber((short)1), |
| | | newMsg.getServerState().getMaxChangeNumber((short)1)); |
| | | assertEquals(msg.getServerState().getMaxChangeNumber(1), |
| | | newMsg.getServerState().getMaxChangeNumber(1)); |
| | | assertEquals(msg.getSSLEncryption(), newMsg.getSSLEncryption()); |
| | | |
| | | // Check default value for only post V1 fields |
| | |
| | | assertEquals(msg.getServerURL(), vlastMsg.getServerURL()); |
| | | assertEquals(msg.getBaseDn(), vlastMsg.getBaseDn()); |
| | | assertEquals(msg.getWindowSize(), vlastMsg.getWindowSize()); |
| | | assertEquals(msg.getServerState().getMaxChangeNumber((short)1), |
| | | vlastMsg.getServerState().getMaxChangeNumber((short)1)); |
| | | assertEquals(msg.getServerState().getMaxChangeNumber(1), |
| | | vlastMsg.getServerState().getMaxChangeNumber(1)); |
| | | assertEquals(msg.getSSLEncryption(), vlastMsg.getSSLEncryption()); |
| | | assertEquals(msg.getGroupId(), vlastMsg.getGroupId()); |
| | | assertEquals(msg.getDegradedStatusThreshold(), vlastMsg.getDegradedStatusThreshold()); |
| | | } |
| | | |
| | | @DataProvider(name = "createAddData") |
| | | public Object[][] createAddData() |
| | | public Object[][] createAddData() |
| | | { |
| | | // Entry attributes |
| | | Attribute eattr1 = Attributes.create("description", "eav description"); |
| | |
| | | new HashMap<AttributeType,List<Attribute>>(); |
| | | opList.put(attr.getAttributeType(), operationalAttributes); |
| | | |
| | | ChangeNumber cn = new ChangeNumber(TimeThread.getTime(), |
| | | (short) 123, (short) 45); |
| | | ChangeNumber cn = new ChangeNumber(TimeThread.getTime(), 123, 45); |
| | | |
| | | AddMsg msg = new AddMsg(cn, rawDN, "thisIsaUniqueID", "parentUniqueId", |
| | | objectClass, userAttributes, |
| | |
| | | List<Attribute> entryAttrList = new ArrayList<Attribute>(); |
| | | entryAttrList.add(eattr1); |
| | | entryAttrList.add(eattr2); |
| | | |
| | | |
| | | return new Object[][] { |
| | | {"dc=example,dc=com", false, AssuredMode.SAFE_DATA_MODE, (byte)0, null}, |
| | | {"dc=delete,dc=an,dc=entry,dc=with,dc=a,dc=long dn", true, AssuredMode.SAFE_READ_MODE, (byte)1, entryAttrList}, |
| | |
| | | byte safeDataLevel, List<Attribute> entryAttrList) |
| | | throws Exception |
| | | { |
| | | ChangeNumber cn = new ChangeNumber(TimeThread.getTime(), |
| | | (short) 123, (short) 45); |
| | | ChangeNumber cn = new ChangeNumber(TimeThread.getTime(), 123, 45); |
| | | DeleteMsg msg = new DeleteMsg(rawDN, cn, "thisIsaUniqueID"); |
| | | |
| | | msg.setAssured(isAssured); |
| | |
| | | assertEquals(msg.isAssured(), vlastMsg.isAssured()); |
| | | assertEquals(msg.getAssuredMode(), vlastMsg.getAssuredMode()); |
| | | assertEquals(msg.getSafeDataLevel(), vlastMsg.getSafeDataLevel()); |
| | | |
| | | |
| | | // Get ECL entry attributes |
| | | ArrayList<RawAttribute> genAttrList = vlastMsg.getEclIncludes(); |
| | | if (entryAttrList==null) |
| | |
| | | */ |
| | | @DataProvider(name = "createModifyData") |
| | | public Object[][] createModifyData() { |
| | | ChangeNumber cn1 = new ChangeNumber(1, (short) 0, (short) 1); |
| | | ChangeNumber cn2 = new ChangeNumber(TimeThread.getTime(), |
| | | (short) 123, (short) 45); |
| | | ChangeNumber cn1 = new ChangeNumber(1, 0, 1); |
| | | ChangeNumber cn2 = new ChangeNumber(TimeThread.getTime(), 123, 45); |
| | | |
| | | AttributeType type = DirectoryServer.getAttributeType("description"); |
| | | |
| | |
| | | |
| | | assertEquals(opFromOrigVlast.getClass(), ModifyOperationBasis.class); |
| | | assertEquals(opFromV1.getClass(), ModifyOperationBasis.class); |
| | | |
| | | |
| | | ModifyOperationBasis modOpBasisFromOrigVlast = (ModifyOperationBasis) opFromOrigVlast; |
| | | ModifyOperationBasis genModOpBasisFromV1 = (ModifyOperationBasis) opFromV1; |
| | | |
| | |
| | | genModOpBasisFromV1.getAttachment(SYNCHROCONTEXT)); |
| | | List<Modification> modsvlast = modOpBasisFromOrigVlast.getModifications(); |
| | | List<Modification> modsv1 = genModOpBasisFromV1.getModifications(); |
| | | |
| | | |
| | | assertEquals(modsvlast, modsv1); |
| | | |
| | | // Check default value for only VLAST fields |
| | |
| | | { |
| | | newv1Msg.setEclIncludes(entryAttrList); |
| | | } |
| | | |
| | | |
| | | // Serialize in VLAST msg |
| | | ModifyMsg generatedVlastMsg = (ModifyMsg)ReplicationMsg.generateMsg( |
| | | newv1Msg.getBytes(), ProtocolVersion.REPLICATION_PROTOCOL_V1); |
| | |
| | | modOpBasisFromOrigVlast = (ModifyOperationBasis) opFromOrigVlast; |
| | | ModifyOperationBasis modOpBasisFromGeneratedVlast = (ModifyOperationBasis) opFromGeneratedVlastMsg; |
| | | |
| | | assertEquals(modOpBasisFromOrigVlast.getRawEntryDN(), |
| | | assertEquals(modOpBasisFromOrigVlast.getRawEntryDN(), |
| | | modOpBasisFromGeneratedVlast.getRawEntryDN()); |
| | | assertEquals( modOpBasisFromOrigVlast.getAttachment(SYNCHROCONTEXT), |
| | | modOpBasisFromGeneratedVlast.getAttachment(SYNCHROCONTEXT)); |
| | | assertEquals(modOpBasisFromOrigVlast.getModifications(), |
| | | assertEquals(modOpBasisFromOrigVlast.getModifications(), |
| | | modOpBasisFromGeneratedVlast.getModifications()); |
| | | } |
| | | |
| | |
| | | throws Exception |
| | | { |
| | | // Create VLAST message |
| | | ChangeNumber cn = new ChangeNumber(TimeThread.getTime(), |
| | | (short) 596, (short) 13); |
| | | ChangeNumber cn = new ChangeNumber(TimeThread.getTime(), 596, 13); |
| | | ModifyDNMsg msg = new ModifyDNMsg(rawDN, cn, uid, |
| | | newParentUid, deleteOldRdn, |
| | | newSuperior, newRdn, mods); |
| | |
| | | i++; |
| | | } |
| | | } |
| | | |
| | | |
| | | // Create a modDn operation from each message to compare mods (kept encoded in messages) |
| | | op = msg.createOperation(connection); |
| | | generatedOperation = vlastMsg.createOperation(connection); |
| | |
| | | genModDnOpBasis.getAttachment(SYNCHROCONTEXT)); |
| | | assertEquals(modDnOpBasis.getModifications(), genModDnOpBasis.getModifications()); |
| | | } |
| | | |
| | | private static byte[] hexStringToByteArray(String s) |
| | | { |
| | | int len = s.length(); |
| | | byte[] data = new byte[len / 2]; |
| | | for (int i = 0; i < len; i += 2) |
| | | { |
| | | data[i / 2] = |
| | | (byte) ((Character.digit(s.charAt(i), 16) << 4) |
| | | + Character.digit(s.charAt(i+1), 16)); |
| | | } |
| | | return data; |
| | | } |
| | | |
| | | @DataProvider(name = "createOldUpdateData") |
| | | public Object[][] createOldUpdateData() |
| | | { |
| | | return new Object[][] { |
| | | {"1603303030303030303030303030303030313030303130303030303030300064633" + |
| | | "d746573740066616b65756e69717565696400000200301f0a0102301a040b646573" + |
| | | "6372697074696f6e310b04096e65772076616c756500", |
| | | ModifyMsg.class, new ChangeNumber(1, (short) 0, (short) 1), "dc=test" }, |
| | | {"1803303030303031323366313238343132303030326430303030303037620064633" + |
| | | "d636f6d00756e69717565696400000201", |
| | | DeleteMsg.class, new ChangeNumber(0x123f1284120L,123,45), "dc=com"}, |
| | | {"1803303030303031323366313238343132303030326430303030303037620064633" + |
| | | "d64656c6574652c64633d616e2c64633d656e7472792c64633d776974682c64633d" + |
| | | "612c64633d6c6f6e6720646e00756e69717565696400000201", |
| | | DeleteMsg.class, new ChangeNumber(0x123f1284120L,123,45), |
| | | "dc=delete,dc=an,dc=entry,dc=with,dc=a,dc=long dn"}, |
| | | {"1903303030303031323366313238613762333030326430303030303037620064633" + |
| | | "d746573742c64633d636f6d00756e6971756569640000020164633d6e6577006463" + |
| | | "3d6368616e6765006e6577706172656e7449640000301f0a0102301a040b6465736" + |
| | | "372697074696f6e310b04096e65772076616c756500", |
| | | ModifyDNMsg.class, new ChangeNumber(0x123f128a7b3L,123,45), "dc=test,dc=com"}, |
| | | {"1703303030303031323366313239333431323030326430303030303037620064633" + |
| | | "d6578616d706c652c64633d636f6d0074686973497361556e697175654944000002" + |
| | | "00706172656e74556e69717565496400301d040b6f626a656374436c617373310e0" + |
| | | "40c6f7267616e697a6174696f6e300a04016f31050403636f6d301c040c63726561" + |
| | | "746f72736e616d65310c040a64633d63726561746f72", |
| | | AddMsg.class, new ChangeNumber(0x123f1293412L,123,45), "dc=example,dc=com"} |
| | | }; |
| | | } |
| | | |
| | | /** |
| | | * The goal of this test is to verify that we keep the compatibility with |
| | | * older version of the replication protocol when doing new developments. |
| | | * |
| | | * This test checks that the current code is able to decode |
| | | * ReplicationMessages formatted by the older versions of the code |
| | | * and is able to format PDU in the same way. |
| | | * |
| | | * The data provider generates arguments containing a pre-formatted |
| | | * UpdateMsg and the corresponding data. |
| | | * |
| | | */ |
| | | @Test(dataProvider = "createOldUpdateData") |
| | | public void createOldUpdate( |
| | | String encodedString, Class<?> msgType, ChangeNumber cn, String dn) |
| | | throws UnsupportedEncodingException, DataFormatException, |
| | | NotSupportedOldVersionPDUException, DirectoryException |
| | | { |
| | | LDAPUpdateMsg msg = (LDAPUpdateMsg) ReplicationMsg.generateMsg( |
| | | hexStringToByteArray(encodedString), ProtocolVersion.REPLICATION_PROTOCOL_V3); |
| | | assertEquals(msg.getDn(), dn); |
| | | assertEquals(msg.getChangeNumber(), cn); |
| | | assertEquals(msg.getClass(), msgType); |
| | | BigInteger bi = new BigInteger(msg.getBytes(ProtocolVersion.REPLICATION_PROTOCOL_V3)); |
| | | assertEquals(bi.toString(16), encodedString); |
| | | } |
| | | |
| | | @DataProvider(name = "createOldServerStartData") |
| | | public Object[][] createOldServerStartData() |
| | | { |
| | | return new Object[][] { |
| | | {"140431323438001f6f3d74657374003136006675726f6e0030003000" + |
| | | "300030003130300031303000747275650032363300303030303030303030303030303034" + |
| | | "623031303730303030303030350000", |
| | | 16, "o=test", (byte) 31,} |
| | | }; |
| | | } |
| | | |
| | | @Test(dataProvider = "createOldServerStartData") |
| | | public void oldServerStartPDUs( |
| | | String oldPdu, int serverId, String dn, byte groupId) throws Exception |
| | | { |
| | | // This test only checks serverId dn and groupId |
| | | // It would be nice to complete it with checks for ServerState and other |
| | | // parameters |
| | | ServerStartMsg msg = new ServerStartMsg(hexStringToByteArray(oldPdu)); |
| | | 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_V4)); |
| | | assertEquals(bi.toString(16), oldPdu); |
| | | } |
| | | |
| | | @DataProvider(name = "createOldReplServerStartData") |
| | | public Object[][] createOldReplServerStartData() |
| | | { |
| | | return new Object[][] { |
| | | {"15033132343500196f3d7465737400313600616e6f74686572486f73" + |
| | | "743a31303235003130300074727565003334353600323633003030303030303030303030" + |
| | | "30303034623031303730303030303030350000", |
| | | 16, "o=test", (byte) 25} |
| | | }; |
| | | } |
| | | @Test(dataProvider = "createOldReplServerStartData") |
| | | public void oldReplServerStartPDUs( |
| | | String oldPdu, int serverId, String dn, byte groupId) throws Exception |
| | | { |
| | | // This is a ServerStartMSg with ServerId=16, baseDn=o=test and groupID=31 |
| | | // For now this test only checks those parameters. |
| | | // It would be nice to complete it with checks for ServerState and other |
| | | // parameters. |
| | | ReplServerStartMsg msg = new ReplServerStartMsg(hexStringToByteArray(oldPdu)); |
| | | assertEquals(msg.getServerId(), serverId); |
| | | assertEquals(msg.getBaseDn(), dn); |
| | | assertEquals(msg.getGroupId(), groupId); |
| | | BigInteger bi = new BigInteger(msg.getBytes(ProtocolVersion.REPLICATION_PROTOCOL_V3)); |
| | | assertEquals(bi.toString(16), oldPdu); |
| | | } |
| | | |
| | | @DataProvider(name = "createoldAckMsgData") |
| | | public Object[][] createoldAckMsgData() |
| | | { |
| | | ArrayList<Integer> fservers4 = new ArrayList<Integer>(); |
| | | fservers4.add(new Integer(100)); |
| | | fservers4.add(new Integer(2000)); |
| | | fservers4.add(new Integer(30000)); |
| | | |
| | | return new Object[][] { |
| | | {"05303030303031323366316535383832383030326430303030303037" + |
| | | "6200010101313030003230303000333030303000", |
| | | new ChangeNumber(0x123f1e58828L, 123, 45), true, fservers4 } |
| | | }; |
| | | } |
| | | @Test(dataProvider = "createoldAckMsgData") |
| | | public void oldAckMsgPDUs(String oldPdu, ChangeNumber cn, |
| | | boolean hasTimeout, ArrayList<Integer> failedServers) throws Exception |
| | | { |
| | | AckMsg msg = new AckMsg(hexStringToByteArray(oldPdu)); |
| | | assertEquals(msg.getChangeNumber(), cn); |
| | | assertEquals(msg.hasTimeout(), hasTimeout); |
| | | assertEquals(msg.getFailedServers(), failedServers); |
| | | // We use V4 here because these PDU have not changed since 2.0. |
| | | //BigInteger bi = new BigInteger(msg.getBytes(ProtocolVersion.REPLICATION_PROTOCOL_V4)); |
| | | //assertEquals(bi.toString(16), oldPdu); |
| | | } |
| | | |
| | | @DataProvider(name = "createStartSessionData") |
| | | public Object[][] createStartSessionData() |
| | | { |
| | | return new Object[][] { |
| | | {"1b010102016c6461703a2f2f6c6461702e69706c616e65742e636f6d2f6f3d74657" + |
| | | "3743f3f7375623f28736e3d4a656e73656e29006c646170733a2f2f6c6461702e69" + |
| | | "706c616e65742e636f6d3a343034312f7569643d626a656e73656e2c6f753d50656" + |
| | | "f706c652c6f3d746573743f636e2c6d61696c2c74656c6570686f6e654e756d62657200", |
| | | ServerStatus.NORMAL_STATUS, true, AssuredMode.SAFE_DATA_MODE, (byte)1 }, |
| | | { "1b0200017b6c6461703a2f2f6c6461702e6578616d706c652e636f6d2f6f3d7465" + |
| | | "73743f6f626a656374436c6173733f6f6e65006c6461703a2f2f686f73742e6578" + |
| | | "616d706c652e636f6d2f6f753d70656f706c652c6f3d746573743f3f3f28736e3d612a2900", |
| | | ServerStatus.DEGRADED_STATUS, false, AssuredMode.SAFE_READ_MODE, (byte)123 } |
| | | }; |
| | | } |
| | | |
| | | @Test(dataProvider = "createStartSessionData") |
| | | public void oldStartSessionPDUs(String pdu, ServerStatus status, |
| | | boolean assured, AssuredMode assuredMode, byte level) |
| | | throws Exception |
| | | { |
| | | StartSessionMsg msg = new StartSessionMsg(hexStringToByteArray(pdu), |
| | | ProtocolVersion.REPLICATION_PROTOCOL_V3); |
| | | assertEquals(msg.getStatus(), status); |
| | | assertEquals(msg.isAssured(), assured); |
| | | assertEquals(msg.getAssuredMode(), assuredMode); |
| | | assertEquals(msg.getSafeDataLevel(), level); |
| | | BigInteger bi = new BigInteger(msg.getBytes(ProtocolVersion.REPLICATION_PROTOCOL_V3)); |
| | | assertEquals(bi.toString(16), pdu); |
| | | } |
| | | |
| | | @DataProvider(name="createTopologyData") |
| | | public Object [][] createTopologyData() throws Exception |
| | | { |
| | | List<String> urls1 = new ArrayList<String>(); |
| | | urls1.add("ldap://ldap.iplanet.com/o=test??sub?(sn=Jensen)"); |
| | | urls1.add("ldaps://ldap.iplanet.com:4041/uid=bjensen,ou=People,o=test?cn,mail,telephoneNumber"); |
| | | |
| | | List<String> urls2 = new ArrayList<String>(); |
| | | |
| | | List<String> urls3 = new ArrayList<String>(); |
| | | urls3.add("ldaps://host:port/dc=foo??sub?(sn=One Entry)"); |
| | | |
| | | List<String> urls4 = new ArrayList<String>(); |
| | | 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, |
| | | false, AssuredMode.SAFE_DATA_MODE, (byte)12, (byte)132, urls1, new HashSet<String>()); |
| | | |
| | | DSInfo dsInfo2 = new DSInfo(-436, 493, (long)-227896, ServerStatus.DEGRADED_STATUS, |
| | | true, AssuredMode.SAFE_READ_MODE, (byte)-7, (byte)-265, urls2, new HashSet<String>()); |
| | | |
| | | DSInfo dsInfo3 = new DSInfo(2436, 591, (long)0, ServerStatus.NORMAL_STATUS, |
| | | false, AssuredMode.SAFE_READ_MODE, (byte)17, (byte)0, urls3, new HashSet<String>()); |
| | | |
| | | DSInfo dsInfo4 = new DSInfo(415, 146, (long)0, ServerStatus.BAD_GEN_ID_STATUS, |
| | | true, AssuredMode.SAFE_DATA_MODE, (byte)2, (byte)15, urls4, new HashSet<String>()); |
| | | |
| | | List<DSInfo> dsList1 = new ArrayList<DSInfo>(); |
| | | dsList1.add(dsInfo1); |
| | | |
| | | List<DSInfo> dsList2 = new ArrayList<DSInfo>(); |
| | | |
| | | List<DSInfo> dsList3 = new ArrayList<DSInfo>(); |
| | | dsList3.add(dsInfo2); |
| | | |
| | | List<DSInfo> dsList4 = new ArrayList<DSInfo>(); |
| | | dsList4.add(dsInfo4); |
| | | dsList4.add(dsInfo3); |
| | | dsList4.add(dsInfo2); |
| | | dsList4.add(dsInfo1); |
| | | |
| | | RSInfo rsInfo1 = new RSInfo((short)4527, (long)45316, (byte)103); |
| | | |
| | | RSInfo rsInfo2 = new RSInfo((short)4527, (long)0, (byte)0); |
| | | |
| | | RSInfo rsInfo3 = new RSInfo((short)0, (long)-21113, (byte)98); |
| | | |
| | | List<RSInfo> rsList1 = new ArrayList<RSInfo>(); |
| | | rsList1.add(rsInfo1); |
| | | |
| | | List<RSInfo> rsList2 = new ArrayList<RSInfo>(); |
| | | rsList2.add(rsInfo1); |
| | | rsList2.add(rsInfo2); |
| | | rsList2.add(rsInfo3); |
| | | |
| | | return new Object [][] { |
| | | {"1a01313300323600313534363331000300020c84026c6461703a2f2f6c6461702e697" + |
| | | "06c616e65742e636f6d2f6f3d746573743f3f7375623f28736e3d4a656e73656e2900" + |
| | | "6c646170733a2f2f6c6461702e69706c616e65742e636f6d3a343034312f7569643d6" + |
| | | "26a656e73656e2c6f753d50656f706c652c6f3d746573743f636e2c6d61696c2c7465" + |
| | | "6c6570686f6e654e756d6265720001343532370034353331360067",dsList1, rsList1}, |
| | | {"1a0003343532370034353331360067343532370030000030002d32313131330062", dsList2, rsList2}, |
| | | {"1a012d34333600343933002d32323738393600020101f9f70001343532370034353331360067", dsList3, rsList1}, |
| | | {"1a012d34333600343933002d32323738393600020101f9f70000", dsList3, new ArrayList<RSInfo>()}, |
| | | {"1a0001343532370034353331360067", new ArrayList<DSInfo>(), rsList1}, |
| | | {"1a0000", new ArrayList<DSInfo>(), new ArrayList<RSInfo>()}, |
| | | {"1a0434313500313436003000040102020f026c646170733a2f2f686f73743a706f727" + |
| | | "42f64633d666f6f626172313f3f7375623f28736e3d416e6f7468657220456e747279" + |
| | | "203129006c646170733a2f2f686f73743a706f72742f64633d666f6f626172323f3f7" + |
| | | "375623f28736e3d416e6f7468657220456e7472792032290032343336003539310030" + |
| | | "000100011100016c646170733a2f2f686f73743a706f72742f64633d666f6f3f3f737" + |
| | | "5623f28736e3d4f6e6520456e74727929002d34333600343933002d32323738393600" + |
| | | "020101f9f700313300323600313534363331000300020c84026c6461703a2f2f6c646" + |
| | | "1702e69706c616e65742e636f6d2f6f3d746573743f3f7375623f28736e3d4a656e73" + |
| | | "656e29006c646170733a2f2f6c6461702e69706c616e65742e636f6d3a343034312f7" + |
| | | "569643d626a656e73656e2c6f753d50656f706c652c6f3d746573743f636e2c6d6169" + |
| | | "6c2c74656c6570686f6e654e756d62657200033435323700343533313600673435323" + |
| | | "70030000030002d32313131330062", dsList4, rsList2} |
| | | }; |
| | | } |
| | | |
| | | @Test(dataProvider = "createTopologyData") |
| | | public void oldTopologyPDUs(String oldPdu, List<DSInfo> dsList, List<RSInfo> rsList) |
| | | throws Exception |
| | | { |
| | | TopologyMsg msg = new TopologyMsg(hexStringToByteArray(oldPdu), |
| | | ProtocolVersion.REPLICATION_PROTOCOL_V3); |
| | | assertEquals(msg.getDsList(), dsList); |
| | | assertEquals(msg.getRsList(), rsList); |
| | | BigInteger bi = new BigInteger(msg.getBytes(ProtocolVersion.REPLICATION_PROTOCOL_V3)); |
| | | assertEquals(bi.toString(16), oldPdu); |
| | | } |
| | | } |
| | |
| | | */ |
| | | @DataProvider(name = "createModifyData") |
| | | public Object[][] createModifyData() { |
| | | ChangeNumber cn1 = new ChangeNumber(1, (short) 0, (short) 1); |
| | | ChangeNumber cn2 = new ChangeNumber(TimeThread.getTime(), |
| | | (short) 123, (short) 45); |
| | | ChangeNumber cn1 = new ChangeNumber(1, 0, 1); |
| | | ChangeNumber cn2 = new ChangeNumber(TimeThread.getTime(), 123, 45); |
| | | ChangeNumber cn3 = new ChangeNumber(TimeThread.getTime(), 67894123, 45678); |
| | | |
| | | AttributeType type = DirectoryServer.getAttributeType("description"); |
| | | |
| | |
| | | { cn2, "dc=test with several values", mods3, false, AssuredMode.SAFE_READ_MODE, (byte)3, null}, |
| | | { cn2, "dc=test with long mod", mods4, true, AssuredMode.SAFE_READ_MODE, (byte)120, eclIncludes}, |
| | | { cn2, "dc=testDsaOperation", mods5, true, AssuredMode.SAFE_DATA_MODE, (byte)99, null}, |
| | | { cn3, "dc=serverIdLargerThan32767", mods1, true, AssuredMode.SAFE_READ_MODE, (byte)1, null}, |
| | | }; |
| | | } |
| | | |
| | |
| | | i++; |
| | | } |
| | | } |
| | | |
| | | |
| | | Operation op = msg.createOperation(connection); |
| | | Operation generatedOperation = generatedMsg.createOperation(connection); |
| | | |
| | |
| | | * Build some data for the DeleteMsg test below. |
| | | */ |
| | | @DataProvider(name = "createDeleteData") |
| | | public Object[][] createDeleteData() |
| | | public Object[][] createDeleteData() |
| | | { |
| | | |
| | | // Entry attributes |
| | |
| | | DeleteOperationBasis opBasis = |
| | | new DeleteOperationBasis(connection, 1, 1,null, DN.decode(rawDN)); |
| | | LocalBackendDeleteOperation op = new LocalBackendDeleteOperation(opBasis); |
| | | ChangeNumber cn = new ChangeNumber(TimeThread.getTime(), |
| | | (short) 123, (short) 45); |
| | | ChangeNumber cn = new ChangeNumber(TimeThread.getTime(),123, 45); |
| | | op.setAttachment(SYNCHROCONTEXT, new DeleteContext(cn, "uniqueid")); |
| | | DeleteMsg msg = new DeleteMsg(op); |
| | | |
| | | |
| | | // Set ECL entry attributes |
| | | if (entryAttrList != null) |
| | | { |
| | |
| | | i++; |
| | | } |
| | | } |
| | | |
| | | |
| | | Operation generatedOperation = generatedMsg.createOperation(connection); |
| | | |
| | | assertEquals(generatedOperation.getClass(), DeleteOperationBasis.class); |
| | |
| | | DN.decode(rawDN), RDN.decode(newRdn), deleteOldRdn, |
| | | (newSuperior.length() != 0 ? DN.decode(newSuperior) : null)); |
| | | |
| | | ChangeNumber cn = new ChangeNumber(TimeThread.getTime(), |
| | | (short) 123, (short) 45); |
| | | ChangeNumber cn = new ChangeNumber(TimeThread.getTime(), 123, 45); |
| | | op.setAttachment(SYNCHROCONTEXT, |
| | | new ModifyDnContext(cn, "uniqueid", "newparentId")); |
| | | LocalBackendModifyDNOperation localOp = |
| | |
| | | i++; |
| | | } |
| | | } |
| | | |
| | | |
| | | Operation oriOp = msg.createOperation(connection); |
| | | Operation generatedOperation = generatedMsg.createOperation(connection); |
| | | |
| | |
| | | } |
| | | |
| | | @DataProvider(name = "createAddData") |
| | | public Object[][] createAddData() |
| | | public Object[][] createAddData() |
| | | { |
| | | |
| | | // Entry attributes |
| | |
| | | new HashMap<AttributeType,List<Attribute>>(); |
| | | opList.put(attr.getAttributeType(), operationalAttributes); |
| | | |
| | | ChangeNumber cn = new ChangeNumber(TimeThread.getTime(), |
| | | (short) 123, (short) 45); |
| | | ChangeNumber cn = new ChangeNumber(TimeThread.getTime(), 123, 45); |
| | | |
| | | AddMsg msg = new AddMsg(cn, rawDN, "thisIsaUniqueID", "parentUniqueId", |
| | | objectClass, userAttributes, |
| | |
| | | i++; |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | // Create an new Add Operation from the current addMsg |
| | | InternalClientConnection connection = |
| | |
| | | */ |
| | | @DataProvider(name = "createAckData") |
| | | public Object[][] createAckData() { |
| | | ChangeNumber cn1 = new ChangeNumber(1, (short) 0, (short) 1); |
| | | ChangeNumber cn2 = new ChangeNumber(TimeThread.getTime(), |
| | | (short) 123, (short) 45); |
| | | ChangeNumber cn1 = new ChangeNumber(1, 0, 1); |
| | | ChangeNumber cn2 = new ChangeNumber(TimeThread.getTime(), 123, 45); |
| | | ChangeNumber cn3 = new ChangeNumber(TimeThread.getTime(), 1234567, 45678); |
| | | |
| | | ArrayList<Short> fservers1 = new ArrayList<Short>(); |
| | | fservers1.add(new Short((short)12345)); |
| | | fservers1.add(new Short((short)-12345)); |
| | | fservers1.add(new Short((short)31657)); |
| | | fservers1.add(new Short((short)-28456)); |
| | | fservers1.add(new Short((short)0)); |
| | | ArrayList<Short> fservers2 = new ArrayList<Short>(); |
| | | ArrayList<Short> fservers3 = new ArrayList<Short>(); |
| | | fservers3.add(new Short((short)0)); |
| | | ArrayList<Short> fservers4 = new ArrayList<Short>(); |
| | | fservers4.add(new Short((short)100)); |
| | | fservers4.add(new Short((short)2000)); |
| | | fservers4.add(new Short((short)30000)); |
| | | fservers4.add(new Short((short)-100)); |
| | | fservers4.add(new Short((short)-2000)); |
| | | fservers4.add(new Short((short)-30000)); |
| | | ArrayList<Integer> fservers1 = new ArrayList<Integer>(); |
| | | fservers1.add(new Integer(12345)); |
| | | fservers1.add(new Integer(-12345)); |
| | | fservers1.add(new Integer(31657)); |
| | | fservers1.add(new Integer(-28456)); |
| | | fservers1.add(new Integer(0)); |
| | | ArrayList<Integer> fservers2 = new ArrayList<Integer>(); |
| | | ArrayList<Integer> fservers3 = new ArrayList<Integer>(); |
| | | fservers3.add(new Integer(0)); |
| | | ArrayList<Integer> fservers4 = new ArrayList<Integer>(); |
| | | fservers4.add(new Integer(100)); |
| | | fservers4.add(new Integer(2000)); |
| | | fservers4.add(new Integer(30000)); |
| | | fservers4.add(new Integer(-100)); |
| | | fservers4.add(new Integer(-2000)); |
| | | fservers4.add(new Integer(-30000)); |
| | | |
| | | return new Object[][] { |
| | | {cn1, true, false, false, fservers1}, |
| | |
| | | {cn1, true, true, false, fservers1}, |
| | | {cn2, false, true, true, fservers2}, |
| | | {cn1, true, false, true, fservers3}, |
| | | {cn2, true, true, true, fservers4} |
| | | {cn2, true, true, true, fservers4}, |
| | | {cn3, true, true, true, fservers4} |
| | | }; |
| | | } |
| | | |
| | | @Test(enabled=true,dataProvider = "createAckData") |
| | | public void ackMsgTest(ChangeNumber cn, boolean hasTimeout, boolean hasWrongStatus, |
| | | boolean hasReplayError, List<Short> failedServers) |
| | | boolean hasReplayError, List<Integer> failedServers) |
| | | throws Exception |
| | | { |
| | | AckMsg msg1, msg2 ; |
| | | |
| | | // Consctructor test (with ChangeNumber) |
| | | // Chech that retrieved CN is OK |
| | | // Constructor test (with ChangeNumber) |
| | | // Check that retrieved CN is OK |
| | | msg1 = new AckMsg(cn); |
| | | assertEquals(msg1.getChangeNumber().compareTo(cn), 0); |
| | | |
| | |
| | | assertTrue(msg1.hasReplayError() == hasReplayError); |
| | | assertEquals(msg1.getFailedServers(), failedServers); |
| | | |
| | | // Consctructor test (with byte[]) |
| | | // Constructor test (with byte[]) |
| | | msg2 = new AckMsg(msg1.getBytes()); |
| | | assertEquals(msg2.getChangeNumber().compareTo(cn), 0); |
| | | assertTrue(msg1.hasTimeout() == msg2.hasTimeout()); |
| | |
| | | DeleteOperationBasis opBasis = |
| | | new DeleteOperationBasis(connection, 1, 1,null, DN.decode("cn=t1")); |
| | | LocalBackendDeleteOperation op = new LocalBackendDeleteOperation(opBasis); |
| | | ChangeNumber cn = new ChangeNumber(TimeThread.getTime(), |
| | | (short) 123, (short) 45); |
| | | ChangeNumber cn = new ChangeNumber(TimeThread.getTime(), 123, 45); |
| | | op.setAttachment(SYNCHROCONTEXT, new DeleteContext(cn, "uniqueid")); |
| | | DeleteMsg delmsg = new DeleteMsg(op); |
| | | int draftcn = 21; |
| | |
| | | DeleteMsg delmsg2 = (DeleteMsg)msg1.getUpdateMsg(); |
| | | assertTrue(delmsg.compareTo(delmsg2)==0); |
| | | |
| | | // Consctructor test (with byte[]) |
| | | // Constructor test (with byte[]) |
| | | ECLUpdateMsg msg2 = new ECLUpdateMsg(msg1.getBytes()); |
| | | assertTrue(msg2.getCookie().equalsTo(msg2.getCookie())); |
| | | assertTrue(msg2.getCookie().equalsTo(cookie)); |
| | |
| | | assertTrue(msg2.getServiceId().equalsIgnoreCase(serviceId)); |
| | | assertTrue(msg2.getDraftChangeNumber()==(msg1.getDraftChangeNumber())); |
| | | assertTrue(msg2.getDraftChangeNumber()==draftcn); |
| | | |
| | | |
| | | DeleteMsg delmsg1 = (DeleteMsg)msg1.getUpdateMsg(); |
| | | delmsg2 = (DeleteMsg)msg2.getUpdateMsg(); |
| | | assertTrue(delmsg2.compareTo(delmsg)==0); |
| | |
| | | { |
| | | String baseDN = TEST_ROOT_DN_STRING; |
| | | ServerState state = new ServerState(); |
| | | state.update(new ChangeNumber((long)0, 0,(short)0)); |
| | | Object[] set1 = new Object[] {(short)1, baseDN, 0, state, 0L, false, (byte)0}; |
| | | state.update(new ChangeNumber((long)0, 0,0)); |
| | | Object[] set1 = new Object[] {1, baseDN, 0, state, 0L, false, (byte)0}; |
| | | |
| | | state = new ServerState(); |
| | | state.update(new ChangeNumber((long)75, 5,(short)263)); |
| | | Object[] set2 = new Object[] {(short)16, baseDN, 100, state, 1248L, true, (byte)31}; |
| | | state.update(new ChangeNumber((long)75, 5,263)); |
| | | Object[] set2 = new Object[] {16, baseDN, 100, state, 1248L, true, (byte)31}; |
| | | |
| | | return new Object [][] { set1, set2 }; |
| | | state = new ServerState(); |
| | | state.update(new ChangeNumber((long)75, 98573895,45263)); |
| | | Object[] set3 = new Object[] {16, baseDN, 100, state, 1248L, true, (byte)31}; |
| | | |
| | | return new Object [][] { set1, set2, set3 }; |
| | | } |
| | | |
| | | /** |
| | |
| | | * by checking that : msg == new ServerStartMsg(msg.getBytes()). |
| | | */ |
| | | @Test(enabled=true,dataProvider="createServerStartData") |
| | | public void serverStartMsgTest(short serverId, String baseDN, int window, |
| | | public void serverStartMsgTest(int serverId, String baseDN, int window, |
| | | ServerState state, long genId, boolean sslEncryption, byte groupId) throws Exception |
| | | { |
| | | ServerStartMsg msg = new ServerStartMsg( |
| | |
| | | assertEquals(msg.getWindowSize(), newMsg.getWindowSize()); |
| | | assertEquals(msg.getHeartbeatInterval(), newMsg.getHeartbeatInterval()); |
| | | assertEquals(msg.getSSLEncryption(), newMsg.getSSLEncryption()); |
| | | assertEquals(msg.getServerState().getMaxChangeNumber((short)1), |
| | | newMsg.getServerState().getMaxChangeNumber((short)1)); |
| | | assertEquals(msg.getServerState().getMaxChangeNumber(1), |
| | | newMsg.getServerState().getMaxChangeNumber(1)); |
| | | assertEquals(msg.getVersion(), newMsg.getVersion()); |
| | | assertEquals(msg.getGenerationId(), newMsg.getGenerationId()); |
| | | assertTrue(msg.getGroupId() == newMsg.getGroupId()); |
| | |
| | | { |
| | | String baseDN = TEST_ROOT_DN_STRING; |
| | | ServerState state = new ServerState(); |
| | | state.update(new ChangeNumber((long)0, 0,(short)0)); |
| | | Object[] set1 = new Object[] {(short)1, baseDN, 0, "localhost:8989", state, 0L, (byte)0, 0}; |
| | | state.update(new ChangeNumber((long)0, 0,0)); |
| | | Object[] set1 = new Object[] {1, baseDN, 0, "localhost:8989", state, 0L, (byte)0, 0}; |
| | | |
| | | state = new ServerState(); |
| | | state.update(new ChangeNumber((long)75, 5,(short)263)); |
| | | Object[] set2 = new Object[] {(short)16, baseDN, 100, "anotherHost:1025", state, 1245L, (byte)25, 3456}; |
| | | state.update(new ChangeNumber((long)75, 5,263)); |
| | | Object[] set2 = new Object[] {16, baseDN, 100, "anotherHost:1025", state, 1245L, (byte)25, 3456}; |
| | | |
| | | return new Object [][] { set1, set2 }; |
| | | state = new ServerState(); |
| | | state.update(new ChangeNumber((long)75, 5, 45263)); |
| | | Object[] set3 = new Object[] {16, baseDN, 100, "anotherHost:1025", state, 1245L, (byte)25, 3456}; |
| | | |
| | | return new Object [][] { set1, set2, set3 }; |
| | | } |
| | | |
| | | /** |
| | |
| | | * by checking that : msg == new ReplServerStartMsg(msg.getBytes()). |
| | | */ |
| | | @Test(enabled=true,dataProvider="createReplServerStartData") |
| | | public void replServerStartMsgTest(short serverId, String baseDN, int window, |
| | | public void replServerStartMsgTest(int serverId, String baseDN, int window, |
| | | String url, ServerState state, long genId, byte groupId, int degTh) throws Exception |
| | | { |
| | | ReplServerStartMsg msg = new ReplServerStartMsg(serverId, |
| | |
| | | assertEquals(msg.getServerURL(), newMsg.getServerURL()); |
| | | assertEquals(msg.getBaseDn(), newMsg.getBaseDn()); |
| | | assertEquals(msg.getWindowSize(), newMsg.getWindowSize()); |
| | | assertEquals(msg.getServerState().getMaxChangeNumber((short)1), |
| | | newMsg.getServerState().getMaxChangeNumber((short)1)); |
| | | assertEquals(msg.getServerState().getMaxChangeNumber(1), |
| | | newMsg.getServerState().getMaxChangeNumber(1)); |
| | | assertEquals(msg.getVersion(), newMsg.getVersion()); |
| | | assertEquals(msg.getGenerationId(), newMsg.getGenerationId()); |
| | | assertEquals(msg.getSSLEncryption(), newMsg.getSSLEncryption()); |
| | |
| | | urls4.add("ldaps://host:port/dc=foobar1??sub?(sn=Another Entry 1)"); |
| | | urls4.add("ldaps://host:port/dc=foobar2??sub?(sn=Another Entry 2)"); |
| | | |
| | | |
| | | Set<String> a1 = new HashSet<String>(); |
| | | Set<String> a2 = new HashSet<String>(); |
| | | a2.add("dc"); |
| | |
| | | a3.add("dc"); |
| | | a3.add("uid"); |
| | | Set<String> a4 = new HashSet<String>(); |
| | | |
| | | DSInfo dsInfo1 = new DSInfo((short)13, (short)26, (long)154631, ServerStatus.FULL_UPDATE_STATUS, |
| | | |
| | | DSInfo dsInfo1 = new DSInfo(13, 26, (long)154631, ServerStatus.FULL_UPDATE_STATUS, |
| | | false, AssuredMode.SAFE_DATA_MODE, (byte)12, (byte)132, urls1, a1); |
| | | |
| | | DSInfo dsInfo2 = new DSInfo((short)-436, (short)493, (long)-227896, ServerStatus.DEGRADED_STATUS, |
| | | DSInfo dsInfo2 = new DSInfo(-436, 493, (long)-227896, ServerStatus.DEGRADED_STATUS, |
| | | true, AssuredMode.SAFE_READ_MODE, (byte)-7, (byte)-265, urls2, a2); |
| | | |
| | | DSInfo dsInfo3 = new DSInfo((short)2436, (short)591, (long)0, ServerStatus.NORMAL_STATUS, |
| | | DSInfo dsInfo3 = new DSInfo(2436, 591, (long)0, ServerStatus.NORMAL_STATUS, |
| | | false, AssuredMode.SAFE_READ_MODE, (byte)17, (byte)0, urls3, a3); |
| | | |
| | | DSInfo dsInfo4 = new DSInfo((short)415, (short)146, (long)0, ServerStatus.BAD_GEN_ID_STATUS, |
| | | DSInfo dsInfo4 = new DSInfo(415, 146, (long)0, ServerStatus.BAD_GEN_ID_STATUS, |
| | | true, AssuredMode.SAFE_DATA_MODE, (byte)2, (byte)15, urls4, a4); |
| | | |
| | | DSInfo dsInfo5 = new DSInfo(452436, 45591, (long)0, ServerStatus.NORMAL_STATUS, |
| | | false, AssuredMode.SAFE_READ_MODE, (byte)17, (byte)0, urls3, a1); |
| | | |
| | | List<DSInfo> dsList1 = new ArrayList<DSInfo>(); |
| | | dsList1.add(dsInfo1); |
| | | |
| | |
| | | dsList3.add(dsInfo2); |
| | | |
| | | List<DSInfo> dsList4 = new ArrayList<DSInfo>(); |
| | | dsList4.add(dsInfo5); |
| | | dsList4.add(dsInfo4); |
| | | dsList4.add(dsInfo3); |
| | | dsList4.add(dsInfo2); |
| | | dsList4.add(dsInfo1); |
| | | |
| | | RSInfo rsInfo1 = new RSInfo((short)4527, (long)45316, (byte)103); |
| | | RSInfo rsInfo1 = new RSInfo(4527, (long)45316, (byte)103); |
| | | |
| | | RSInfo rsInfo2 = new RSInfo((short)4527, (long)0, (byte)0); |
| | | RSInfo rsInfo2 = new RSInfo(4527, (long)0, (byte)0); |
| | | |
| | | RSInfo rsInfo3 = new RSInfo((short)0, (long)-21113, (byte)98); |
| | | RSInfo rsInfo3 = new RSInfo(0, (long)-21113, (byte)98); |
| | | |
| | | RSInfo rsInfo4 = new RSInfo(45678, (long)-21113, (byte)98); |
| | | |
| | | List<RSInfo> rsList1 = new ArrayList<RSInfo>(); |
| | | rsList1.add(rsInfo1); |
| | |
| | | rsList2.add(rsInfo1); |
| | | rsList2.add(rsInfo2); |
| | | rsList2.add(rsInfo3); |
| | | rsList2.add(rsInfo4); |
| | | |
| | | return new Object [][] { |
| | | {dsList1, rsList1, a1}, |
| | |
| | | @Test |
| | | public void monitorRequestMsgTest() throws Exception |
| | | { |
| | | MonitorRequestMsg msg = new MonitorRequestMsg((short)1,(short)2); |
| | | MonitorRequestMsg msg = new MonitorRequestMsg(1,2); |
| | | MonitorRequestMsg newMsg = new MonitorRequestMsg(msg.getBytes()); |
| | | assertEquals(newMsg.getDestination(), 2); |
| | | assertEquals(newMsg.getsenderID(), 1); |
| | |
| | | @Test() |
| | | public void monitorMsgTest() throws Exception |
| | | { |
| | | short sender = 2; |
| | | short dest = 3; |
| | | int sender = 2; |
| | | int dest = 3; |
| | | |
| | | // RS State |
| | | ServerState rsState = new ServerState(); |
| | | ChangeNumber rscn1 = new ChangeNumber(1, (short) 1, (short) 1); |
| | | ChangeNumber rscn2 = new ChangeNumber(1, (short) 1, (short) 2); |
| | | ChangeNumber rscn1 = new ChangeNumber(1, 1, 1); |
| | | ChangeNumber rscn2 = new ChangeNumber(1, 1, 45678); |
| | | rsState.update(rscn1); |
| | | rsState.update(rscn2); |
| | | |
| | | // LS1 state |
| | | ServerState s1 = new ServerState(); |
| | | short sid1 = 111; |
| | | ChangeNumber cn1 = new ChangeNumber(1, (short) 1, sid1); |
| | | int sid1 = 111; |
| | | ChangeNumber cn1 = new ChangeNumber(1, 1, sid1); |
| | | s1.update(cn1); |
| | | |
| | | // LS2 state |
| | | ServerState s2 = new ServerState(); |
| | | short sid2 = 222; |
| | | int sid2 = 222; |
| | | Long now = ((Integer)10).longValue(); |
| | | ChangeNumber cn2 = new ChangeNumber(now, |
| | | (short) 123, sid2); |
| | | ChangeNumber cn2 = new ChangeNumber(now, 123, sid2); |
| | | s2.update(cn2); |
| | | |
| | | // LS3 state |
| | | ServerState s3 = new ServerState(); |
| | | short sid3 = 333; |
| | | ChangeNumber cn3 = new ChangeNumber(now, |
| | | (short) 123, sid3); |
| | | int sid3 = 56789; |
| | | ChangeNumber cn3 = new ChangeNumber(now, 123, sid3); |
| | | s3.update(cn3); |
| | | |
| | | MonitorMsg msg = |
| | |
| | | assertEquals(newMsg.getReplServerDbState().toString(), |
| | | msg.getReplServerDbState().toString()); |
| | | |
| | | Iterator<Short> it = newMsg.ldapIterator(); |
| | | Iterator<Integer> it = newMsg.ldapIterator(); |
| | | while (it.hasNext()) |
| | | { |
| | | short sid = it.next(); |
| | | int sid = it.next(); |
| | | ServerState s = newMsg.getLDAPServerState(sid); |
| | | if (sid == sid1) |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | Iterator<Short> it2 = newMsg.rsIterator(); |
| | | Iterator<Integer> it2 = newMsg.rsIterator(); |
| | | while (it2.hasNext()) |
| | | { |
| | | short sid = it2.next(); |
| | | int sid = it2.next(); |
| | | ServerState s = newMsg.getRSServerState(sid); |
| | | if (sid == sid3) |
| | | { |
| | |
| | | "ds-task-class-name: org.opends.server.replication.api.InitializeTask\n" + |
| | | "ds-task-initialize-domain-dn: " + TEST_ROOT_DN_STRING + "\n" + |
| | | "ds-task-initialize-source: 1\n"); |
| | | short sender = 1; |
| | | short target = 2; |
| | | int sender = 1; |
| | | int target = 45678; |
| | | byte[] entry = taskInitFromS2.getBytes(); |
| | | EntryMsg msg = new EntryMsg(sender, target, entry); |
| | | EntryMsg newMsg = new EntryMsg(msg.getBytes()); |
| | |
| | | @Test() |
| | | public void initializeRequestMsgTest() throws Exception |
| | | { |
| | | short sender = 1; |
| | | short target = 2; |
| | | int sender = 1; |
| | | int target = 56789; |
| | | InitializeRequestMsg msg = new InitializeRequestMsg( |
| | | TEST_ROOT_DN_STRING, sender, target); |
| | | InitializeRequestMsg newMsg = new InitializeRequestMsg(msg.getBytes()); |
| | |
| | | @Test() |
| | | public void initializeTargetMsgTest() throws Exception |
| | | { |
| | | short senderID = 1; |
| | | short targetID = 2; |
| | | short requestorID = 3; |
| | | int senderID = 45678; |
| | | int targetID = 2; |
| | | int requestorID = 3; |
| | | long entryCount = 4; |
| | | |
| | | InitializeTargetMsg msg = new InitializeTargetMsg( |
| | |
| | | @Test() |
| | | public void doneMsgTest() throws Exception |
| | | { |
| | | DoneMsg msg = new DoneMsg((short)1, (short)2); |
| | | DoneMsg msg = new DoneMsg(1, 2); |
| | | DoneMsg newMsg = new DoneMsg(msg.getBytes()); |
| | | assertEquals(msg.getsenderID(), newMsg.getsenderID()); |
| | | assertEquals(msg.getDestination(), newMsg.getDestination()); |
| | |
| | | @Test() |
| | | public void errorMsgTest() throws Exception |
| | | { |
| | | ErrorMsg msg = new ErrorMsg((short)1, (short)2, Message.raw("details")); |
| | | ErrorMsg msg = new ErrorMsg(1, 2, Message.raw("details")); |
| | | ErrorMsg newMsg = new ErrorMsg(msg.getBytes()); |
| | | assertEquals(msg.getsenderID(), newMsg.getsenderID()); |
| | | assertEquals(msg.getDestination(), newMsg.getDestination()); |
| | |
| | | final String test = "string used for test"; |
| | | UpdateMsg msg = |
| | | new UpdateMsg( |
| | | new ChangeNumber((long) 1, 2 , (short)3), |
| | | new ChangeNumber((long) 1, 2 , 39123), |
| | | test.getBytes()); |
| | | UpdateMsg newMsg = new UpdateMsg(msg.getBytes()); |
| | | assertEquals(test.getBytes(), newMsg.getPayload()); |
| | |
| | | * by checking that : msg == new ServerStartMsg(msg.getBytes()). |
| | | */ |
| | | @Test(enabled=true,dataProvider="createServerStartData") |
| | | public void startECLMsgTest(short serverId, String baseDN, int window, |
| | | public void startECLMsgTest(int serverId, String baseDN, int window, |
| | | ServerState state, long genId, boolean sslEncryption, byte groupId) throws Exception |
| | | { |
| | | ServerStartECLMsg msg = new ServerStartECLMsg(baseDN, |
| | |
| | | assertEquals(msg.getWindowSize(), newMsg.getWindowSize()); |
| | | assertEquals(msg.getHeartbeatInterval(), newMsg.getHeartbeatInterval()); |
| | | assertEquals(msg.getSSLEncryption(), newMsg.getSSLEncryption()); |
| | | assertEquals(msg.getServerState().getMaxChangeNumber((short)1), |
| | | newMsg.getServerState().getMaxChangeNumber((short)1)); |
| | | assertEquals(msg.getServerState().getMaxChangeNumber(1), |
| | | newMsg.getServerState().getMaxChangeNumber(1)); |
| | | assertEquals(msg.getVersion(), newMsg.getVersion()); |
| | | assertEquals(msg.getGenerationId(), newMsg.getGenerationId()); |
| | | assertTrue(msg.getGroupId() == newMsg.getGroupId()); |
| | |
| | | throws Exception |
| | | { |
| | | // data |
| | | ChangeNumber changeNumber = new ChangeNumber(TimeThread.getTime(), |
| | | (short) 123, (short) 45); |
| | | ChangeNumber changeNumber = new ChangeNumber(TimeThread.getTime(), 123, 45); |
| | | String generalizedState = new String("fakegenstate"); |
| | | ServerState state = new ServerState(); |
| | | assertTrue(state.update(new ChangeNumber((long)75, 5,(short)263))); |
| | | assertTrue(state.update(new ChangeNumber((long)75, 5,263))); |
| | | short mode = 3; |
| | | int firstDraftChangeNumber = 13; |
| | | int lastDraftChangeNumber = 14; |
| | |
| | | assertTrue(dn1found); |
| | | assertTrue(dn2found); |
| | | } |
| | | |
| | | |
| | | int perfRep = 100000; |
| | | |
| | | |
| | |
| | | long setentryattr = 0; |
| | | long buildnew = 0; |
| | | long t1,t2,t3,t31,t4,t5,t6 = 0; |
| | | |
| | | |
| | | HashMap<ObjectClass, String> objectClassList = new HashMap<ObjectClass, String>(); |
| | | objectClassList.put(DirectoryServer.getObjectClass("organization"), |
| | | "organization"); |
| | |
| | | generatedMsg.setEclIncludes(entryAttrList); |
| | | t31 = System.nanoTime(); |
| | | setentryattr += (t31 - t3); |
| | | |
| | | |
| | | // encode msg |
| | | generatedMsg.encode(); |
| | | t4 = System.nanoTime(); |
| | |
| | | } |
| | | |
| | | System.out.println( |
| | | "addMsgPerfs " |
| | | + "createop\t" |
| | | + "createmsgfromop\t" |
| | | "addMsgPerfs " |
| | | + "createop\t" |
| | | + "createmsgfromop\t" |
| | | + "setentryattr\t" |
| | | + "encodemsg\t" |
| | | + "encodemsg\t" |
| | | + "getbytes\t" |
| | | + "buildnew\t"); |
| | | |
| | | System.out.println( |
| | | "addMsgPerfs " |
| | | + createop/perfRep/1000.0 + " μs \t" |
| | | + createmsgfromop/perfRep/1000.0 + " μs \t" |
| | | "addMsgPerfs " |
| | | + createop/perfRep/1000.0 + " μs \t" |
| | | + createmsgfromop/perfRep/1000.0 + " μs \t" |
| | | + setentryattr/perfRep/1000.0 + " μs \t" |
| | | + encodemsg/perfRep/1000.0 + " μs \t" |
| | | + encodemsg/perfRep/1000.0 + " μs \t" |
| | | + getbytes/perfRep/1000.0 + " μs \t" |
| | | + buildnew/perfRep/1000.0 + " μs \t"); |
| | | } |
| | | } |
| | | |
| | | @Test(enabled=false,dataProvider = "createModifyData") |
| | | public void modMsgPerfs(ChangeNumber changeNumber, |
| | |
| | | long setentryattr = 0; |
| | | long buildnew = 0; |
| | | long t1,t2,t3,t31,t4,t5,t6 = 0; |
| | | |
| | | |
| | | ChangeNumber cn = new ChangeNumber(TimeThread.getTime(), |
| | | (short) 123, (short) 45); |
| | | DN dn = DN.decode(rawdn); |
| | | |
| | | |
| | | for (int i=1;i<perfRep;i++) |
| | | { |
| | | t1 = System.nanoTime(); |
| | |
| | | // generatedMsg.setEntryAttributes(entryAttrList); |
| | | t31 = System.nanoTime(); |
| | | setentryattr += (t31 - t3); |
| | | |
| | | |
| | | // encode msg |
| | | generatedMsg.encode(); |
| | | t4 = System.nanoTime(); |
| | |
| | | } |
| | | |
| | | System.out.println( |
| | | "modMsgPerfs " |
| | | + "createop\t" |
| | | + "createmsgfromop\t" |
| | | "modMsgPerfs " |
| | | + "createop\t" |
| | | + "createmsgfromop\t" |
| | | + "setentryattr\t" |
| | | + "encodemsg\t" |
| | | + "encodemsg\t" |
| | | + "getbytes\t" |
| | | + "buildnew\t"); |
| | | |
| | | System.out.println( |
| | | "modMsgPerfs " |
| | | + createop/perfRep/1000.0 + " μs \t" |
| | | + createmsgfromop/perfRep/1000.0 + " μs \t" |
| | | "modMsgPerfs " |
| | | + createop/perfRep/1000.0 + " μs \t" |
| | | + createmsgfromop/perfRep/1000.0 + " μs \t" |
| | | + setentryattr/perfRep/1000.0 + " μs \t" |
| | | + encodemsg/perfRep/1000.0 + " μs \t" |
| | | + encodemsg/perfRep/1000.0 + " μs \t" |
| | | + getbytes/perfRep/1000.0 + " μs \t" |
| | | + buildnew/perfRep/1000.0 + " μs \t"); |
| | | } |
| | | } |
| | | |
| | | @Test(enabled=false,dataProvider = "createDeleteData") |
| | | public void deleteMsgPerfs(String rawDN, List<Attribute> entryAttrList) |
| | |
| | | { |
| | | InternalClientConnection connection = |
| | | InternalClientConnection.getRootConnection(); |
| | | |
| | | |
| | | long createop = 0; |
| | | long createmsgfromop = 0; |
| | | long encodemsg = 0; |
| | |
| | | long setentryattr = 0; |
| | | long buildnew = 0; |
| | | long t1,t2,t3,t31,t4,t5,t6 = 0; |
| | | |
| | | |
| | | for (int i=1;i<perfRep;i++) |
| | | { |
| | | t1 = System.nanoTime(); |
| | |
| | | //generatedMsg.setEntryAttributes(entryAttrList); |
| | | t31 = System.nanoTime(); |
| | | setentryattr += (t31 - t3); |
| | | |
| | | |
| | | // encode msg |
| | | generatedMsg.encode(); |
| | | t4 = System.nanoTime(); |
| | |
| | | } |
| | | |
| | | System.out.println( |
| | | "deleteMsgPerfs " |
| | | + "createop\t" |
| | | + "createmsgfromop\t" |
| | | "deleteMsgPerfs " |
| | | + "createop\t" |
| | | + "createmsgfromop\t" |
| | | + "setentryattr\t" |
| | | + "encodemsg\t" |
| | | + "encodemsg\t" |
| | | + "getbytes\t" |
| | | + "buildnew\t"); |
| | | |
| | | System.out.println( |
| | | "deleteMsgPerfs " |
| | | + createop/perfRep/1000.0 + " μs \t" |
| | | + createmsgfromop/perfRep/1000.0 + " μs \t" |
| | | "deleteMsgPerfs " |
| | | + createop/perfRep/1000.0 + " μs \t" |
| | | + createmsgfromop/perfRep/1000.0 + " μs \t" |
| | | + setentryattr/perfRep/1000.0 + " μs \t" |
| | | + encodemsg/perfRep/1000.0 + " μs \t" |
| | | + encodemsg/perfRep/1000.0 + " μs \t" |
| | | + getbytes/perfRep/1000.0 + " μs \t" |
| | | + buildnew/perfRep/1000.0 + " μs \t"); |
| | | } |
| | |
| | | private int rs2Port = -1; |
| | | private int rs3Port = -1; |
| | | private int rs4Port = -1; |
| | | private static final short FDS1_ID = 1; |
| | | private static final short FDS2_ID = 2; |
| | | private static final short FDS3_ID = 3; |
| | | private static final short FDS4_ID = 4; |
| | | private static final short FDS5_ID = 5; |
| | | private static final short FDS6_ID = 6; |
| | | private static final short FDS7_ID = 7; |
| | | private static final short FDS8_ID = 8; |
| | | private static final short FDS9_ID = 9; |
| | | private static final short FDS10_ID = 10; |
| | | private static final short FDS11_ID = 11; |
| | | private static final short FDS12_ID = 12; |
| | | private static final short FRS1_ID = 51; |
| | | private static final short FRS2_ID = 52; |
| | | private static final short FRS3_ID = 53; |
| | | private static final short DS_FRS2_ID = FRS2_ID + 10; |
| | | private static final short RS1_ID = 101; |
| | | private static final short RS2_ID = 102; |
| | | private static final short RS3_ID = 103; |
| | | private static final short RS4_ID = 104; |
| | | private static final int FDS1_ID = 1; |
| | | private static final int FDS2_ID = 2; |
| | | private static final int FDS3_ID = 3; |
| | | private static final int FDS4_ID = 4; |
| | | private static final int FDS5_ID = 5; |
| | | private static final int FDS6_ID = 6; |
| | | private static final int FDS7_ID = 7; |
| | | private static final int FDS8_ID = 8; |
| | | private static final int FDS9_ID = 9; |
| | | private static final int FDS10_ID = 10; |
| | | private static final int FDS11_ID = 11; |
| | | private static final int FDS12_ID = 12; |
| | | private static final int FRS1_ID = 51; |
| | | private static final int FRS2_ID = 52; |
| | | private static final int FRS3_ID = 53; |
| | | private static final int DS_FRS2_ID = FRS2_ID + 10; |
| | | private static final int RS1_ID = 101; |
| | | private static final int RS2_ID = 102; |
| | | private static final int RS3_ID = 103; |
| | | private static final int RS4_ID = 104; |
| | | private FakeReplicationDomain fakeRd1 = null; |
| | | private FakeReplicationDomain fakeRd2 = null; |
| | | private FakeReplicationDomain fakeRd3 = null; |
| | |
| | | * Creates and connects a new fake replication domain, using the passed scenario |
| | | * (no server state constructor version) |
| | | */ |
| | | private FakeReplicationDomain createFakeReplicationDomain(short serverId, |
| | | int groupId, short rsId, long generationId, boolean assured, |
| | | private FakeReplicationDomain createFakeReplicationDomain(int serverId, |
| | | int groupId, int rsId, long generationId, boolean assured, |
| | | AssuredMode assuredMode, int safeDataLevel, long assuredTimeout, |
| | | int scenario) |
| | | { |
| | |
| | | /** |
| | | * Creates and connects a new fake replication domain, using the passed scenario. |
| | | */ |
| | | private FakeReplicationDomain createFakeReplicationDomain(short serverId, |
| | | int groupId, short rsId, long generationId, boolean assured, |
| | | private FakeReplicationDomain createFakeReplicationDomain(int serverId, |
| | | int groupId, int rsId, long generationId, boolean assured, |
| | | AssuredMode assuredMode, int safeDataLevel, long assuredTimeout, |
| | | int scenario, ServerState serverState) |
| | | { |
| | |
| | | * service uses the default window value. If false, we only start publish |
| | | * service and use the passed window value |
| | | */ |
| | | private FakeReplicationDomain createFakeReplicationDomain(short serverId, |
| | | int groupId, short rsId, long generationId, boolean assured, |
| | | private FakeReplicationDomain createFakeReplicationDomain(int serverId, |
| | | int groupId, int rsId, long generationId, boolean assured, |
| | | AssuredMode assuredMode, int safeDataLevel, long assuredTimeout, |
| | | int scenario, ServerState serverState, boolean startListen, int window) |
| | | { |
| | |
| | | /** |
| | | * Creates and connects a new fake replication server, using the passed scenario. |
| | | */ |
| | | private FakeReplicationServer createFakeReplicationServer(short serverId, |
| | | int groupId, short rsId, long generationId, boolean assured, |
| | | private FakeReplicationServer createFakeReplicationServer(int serverId, |
| | | int groupId, int rsId, long generationId, boolean assured, |
| | | AssuredMode assuredMode, int safeDataLevel, ServerState serverState, int scenario) |
| | | { |
| | | try |
| | |
| | | /** |
| | | * Creates a new real replication server (one which is to be tested). |
| | | */ |
| | | private ReplicationServer createReplicationServer(short serverId, |
| | | private ReplicationServer createReplicationServer(int serverId, |
| | | int groupId, long assuredTimeout, String testCase) |
| | | { |
| | | SortedSet<String> replServers = new TreeSet<String>(); |
| | |
| | | */ |
| | | public FakeReplicationDomain( |
| | | String serviceID, |
| | | short serverID, |
| | | int serverID, |
| | | long generationId, |
| | | byte groupId, |
| | | boolean assured, |
| | |
| | | |
| | | // Parameters given at constructor time |
| | | private int port; |
| | | private short serverId = -1; |
| | | private int serverId = -1; |
| | | boolean isAssured = false; // Default value for config |
| | | AssuredMode assuredMode = AssuredMode.SAFE_DATA_MODE; // Default value for config |
| | | byte safeDataLevel = (byte) 1; // Default value for config |
| | |
| | | * @param baseDn the basedn we connect with, to the real RS |
| | | * @param generationId the generation id we use at connection to real RS |
| | | */ |
| | | public FakeReplicationServer(int port, short serverId, boolean assured, |
| | | public FakeReplicationServer(int port, int serverId, boolean assured, |
| | | AssuredMode assuredMode, int safeDataLevel, |
| | | byte groupId, String baseDn, long generationId) |
| | | { |
| | |
| | | this.assuredMode = assuredMode; |
| | | this.safeDataLevel = (byte) safeDataLevel; |
| | | |
| | | gen = new ChangeNumberGenerator((short)(serverId + 10), 0L); |
| | | gen = new ChangeNumberGenerator(serverId + 10, 0L); |
| | | } |
| | | |
| | | /* |
| | |
| | | // Send the ack with timeout error from a virtual DS with id (ours + 10) |
| | | AckMsg ackMsg = new AckMsg(updateMsg.getChangeNumber()); |
| | | ackMsg.setHasTimeout(true); |
| | | List<Short> failedServers = new ArrayList<Short>(); |
| | | failedServers.add((short)(serverId + 10)); |
| | | List<Integer> failedServers = new ArrayList<Integer>(); |
| | | failedServers.add(serverId + 10); |
| | | ackMsg.setFailedServers(failedServers); |
| | | session.publish(ackMsg); |
| | | ackReplied = true; |
| | |
| | | // Send the ack with wrong status error from a virtual DS with id (ours + 10) |
| | | AckMsg ackMsg = new AckMsg(updateMsg.getChangeNumber()); |
| | | ackMsg.setHasWrongStatus(true); |
| | | List<Short> failedServers = new ArrayList<Short>(); |
| | | failedServers.add((short)(serverId + 10)); |
| | | List<Integer> failedServers = new ArrayList<Integer>(); |
| | | failedServers.add((serverId + 10)); |
| | | ackMsg.setFailedServers(failedServers); |
| | | session.publish(ackMsg); |
| | | ackReplied = true; |
| | |
| | | // Send the ack with replay error from a virtual DS with id (ours + 10) |
| | | AckMsg ackMsg = new AckMsg(updateMsg.getChangeNumber()); |
| | | ackMsg.setHasReplayError(true); |
| | | List<Short> failedServers = new ArrayList<Short>(); |
| | | failedServers.add((short)(serverId + 10)); |
| | | List<Integer> failedServers = new ArrayList<Integer>(); |
| | | failedServers.add((serverId + 10)); |
| | | ackMsg.setFailedServers(failedServers); |
| | | session.publish(ackMsg); |
| | | ackReplied = true; |
| | |
| | | // Keep track of monitoring values for incremental test step |
| | | int acknowledgedUpdates = fakeRd1.getAssuredSdAcknowledgedUpdates(); |
| | | int timeoutUpdates = fakeRd1.getAssuredSdTimeoutUpdates(); |
| | | Map<Short,Integer> serverErrors = fakeRd1.getAssuredSdServerTimeoutUpdates(); |
| | | Map<Integer,Integer> serverErrors = fakeRd1.getAssuredSdServerTimeoutUpdates(); |
| | | // Compute the list of servers that are elligible for receiving an assured update |
| | | List<Short> elligibleServers = computeElligibleServersSafeData(fakeRs1Gid, fakeRs1GenId, fakeRs2Gid, fakeRs2GenId, fakeRs3Gid, fakeRs3GenId); |
| | | List<Integer> elligibleServers = computeElligibleServersSafeData(fakeRs1Gid, fakeRs1GenId, fakeRs2Gid, fakeRs2GenId, fakeRs3Gid, fakeRs3GenId); |
| | | // Compute the list of servers that are elligible for receiving an assured update and that are expected to effectively ack the update |
| | | List<Short> expectedServers = computeExpectedServersSafeData(fakeRs1Gid, fakeRs1GenId, fakeRs1Scen, fakeRs2Gid, fakeRs2GenId, fakeRs2Scen, fakeRs3Gid, fakeRs3GenId, fakeRs3Scen); |
| | | List<Integer> expectedServers = computeExpectedServersSafeData(fakeRs1Gid, fakeRs1GenId, fakeRs1Scen, fakeRs2Gid, fakeRs2GenId, fakeRs2Scen, fakeRs3Gid, fakeRs3GenId, fakeRs3Scen); |
| | | |
| | | // Send update |
| | | long startTime = System.currentTimeMillis(); |
| | |
| | | // Check that the DSs and the fake RSs of the topology have received/acked what is expected according to the |
| | | // test step (the number of updates) |
| | | // -1 for a gen id means no need to test the matching fake RS |
| | | private void checkWhatHasBeenReceivedSafeData(int nSentUpdates, boolean otherFakeDS, long otherFakeDsGenId, long fakeRs1GenId, long fakeRs2GenId, long fakeRs3GenId, List<Short> expectedServers) |
| | | private void checkWhatHasBeenReceivedSafeData(int nSentUpdates, boolean otherFakeDS, long otherFakeDsGenId, long fakeRs1GenId, long fakeRs2GenId, long fakeRs3GenId, List<Integer> expectedServers) |
| | | { |
| | | |
| | | // We should not receive our own update |
| | |
| | | * Check the time the sending of the safe data assured update took and the monitoring |
| | | * values according to the test configuration |
| | | */ |
| | | private void checkTimeAndMonitoringSafeData(int nSentUpdates, int prevNAckUpdates, int prevNTimeoutUpdates, Map<Short,Integer> prevNServerErrors, long sendUpdateTime, |
| | | int nWishedServers, List<Short> elligibleServers, List<Short> expectedServers) |
| | | private void checkTimeAndMonitoringSafeData(int nSentUpdates, int prevNAckUpdates, int prevNTimeoutUpdates, Map<Integer,Integer> prevNServerErrors, long sendUpdateTime, |
| | | int nWishedServers, List<Integer> elligibleServers, List<Integer> expectedServers) |
| | | { |
| | | assertEquals(fakeRd1.getAssuredSdSentUpdates(), nSentUpdates); |
| | | if (elligibleServers.size() >= nWishedServers) // Enough elligible servers |
| | |
| | | assertEquals(fakeRd1.getAssuredSdAcknowledgedUpdates(), prevNAckUpdates); |
| | | assertEquals(fakeRd1.getAssuredSdTimeoutUpdates(), prevNTimeoutUpdates + 1); |
| | | // Check that the servers that are elligible but not expected have been added in the error by server list |
| | | List<Short> expectedServersInError = computeExpectedServersInError(elligibleServers, expectedServers); |
| | | List<Integer> expectedServersInError = computeExpectedServersInError(elligibleServers, expectedServers); |
| | | checkServerErrors(fakeRd1.getAssuredSdServerTimeoutUpdates(), prevNServerErrors, expectedServersInError); |
| | | } |
| | | } else // Not enough elligible servers |
| | |
| | | assertEquals(fakeRd1.getAssuredSdAcknowledgedUpdates(), prevNAckUpdates); |
| | | assertEquals(fakeRd1.getAssuredSdTimeoutUpdates(), prevNTimeoutUpdates + 1); |
| | | // Check that the servers that are elligible but not expected have been added in the error by server list |
| | | List<Short> expectedServersInError = computeExpectedServersInError(elligibleServers, expectedServers); |
| | | List<Integer> expectedServersInError = computeExpectedServersInError(elligibleServers, expectedServers); |
| | | checkServerErrors(fakeRd1.getAssuredSdServerTimeoutUpdates(), prevNServerErrors, expectedServersInError); |
| | | } |
| | | } else |
| | |
| | | |
| | | // Compute a list of servers that are elligibles but that are not able to return an ack |
| | | // (those in elligibleServers that are not in expectedServers). Result may of course be an empty list |
| | | private List<Short> computeExpectedServersInError(List<Short> elligibleServers, List<Short> expectedServers) |
| | | private List<Integer> computeExpectedServersInError(List<Integer> elligibleServers, List<Integer> expectedServers) |
| | | { |
| | | List<Short> expectedServersInError = new ArrayList<Short>(); |
| | | for (Short serverId : elligibleServers) |
| | | List<Integer> expectedServersInError = new ArrayList<Integer>(); |
| | | for (Integer serverId : elligibleServers) |
| | | { |
| | | if (!expectedServers.contains(serverId)) |
| | | expectedServersInError.add(serverId); |
| | |
| | | // - if expectedServersInError is not null and not empty, each server id in measuredServerErrors should have the value it has |
| | | // in prevServerErrors + 1, or 1 if it was not in prevServerErrors |
| | | // - if expectedServersInError is null or empty, both map should be equal |
| | | private void checkServerErrors(Map<Short,Integer> measuredServerErrors, Map<Short,Integer> prevServerErrors, List<Short> expectedServersInError) |
| | | private void checkServerErrors(Map<Integer,Integer> measuredServerErrors, Map<Integer,Integer> prevServerErrors, List<Integer> expectedServersInError) |
| | | { |
| | | if (expectedServersInError != null) |
| | | { |
| | | // Adding an error to each server in expectedServersInError, with prevServerErrors as basis, should give the |
| | | // same map as measuredServerErrors |
| | | for (Short serverId : expectedServersInError) |
| | | for (Integer serverId : expectedServersInError) |
| | | { |
| | | Integer prevInt = prevServerErrors.get(serverId); |
| | | if (prevInt == null) |
| | |
| | | |
| | | // Maps should be the same |
| | | assertEquals(measuredServerErrors.size(), prevServerErrors.size()); |
| | | Set<Short> measuredKeySet = measuredServerErrors.keySet(); |
| | | for (Short serverId : measuredKeySet) |
| | | Set<Integer> measuredKeySet = measuredServerErrors.keySet(); |
| | | for (Integer serverId : measuredKeySet) |
| | | { |
| | | Integer measuredInt = measuredServerErrors.get(serverId); |
| | | assertNotNull(measuredInt); |
| | |
| | | |
| | | // Compute the list of servers that are elligible for receiving a safe data assured update |
| | | // according to their group id and generation id. If -1 is used, the server is out of scope |
| | | private List<Short> computeElligibleServersSafeData(int fakeRs1Gid, long fakeRs1GenId, int fakeRs2Gid, long fakeRs2GenId, int fakeRs3Gid, long fakeRs3GenId) |
| | | private List<Integer> computeElligibleServersSafeData(int fakeRs1Gid, long fakeRs1GenId, int fakeRs2Gid, long fakeRs2GenId, int fakeRs3Gid, long fakeRs3GenId) |
| | | { |
| | | List<Short> elligibleServers = new ArrayList<Short>(); |
| | | List<Integer> elligibleServers = new ArrayList<Integer>(); |
| | | if (areGroupAndGenerationIdOk(fakeRs1Gid, fakeRs1GenId)) |
| | | { |
| | | elligibleServers.add(FRS1_ID); |
| | |
| | | |
| | | // Compute the list of servers that are elligible for receiving a safe data assured update and that are expected to effectively ack the update |
| | | // If -1 is used, the server is out of scope |
| | | private List<Short> computeExpectedServersSafeData(int fakeRs1Gid, long fakeRs1GenId, int fakeRs1Scen, int fakeRs2Gid, long fakeRs2GenId, int fakeRs2Scen, int fakeRs3Gid, long fakeRs3GenId, int fakeRs3Scen) |
| | | private List<Integer> computeExpectedServersSafeData(int fakeRs1Gid, long fakeRs1GenId, int fakeRs1Scen, int fakeRs2Gid, long fakeRs2GenId, int fakeRs2Scen, int fakeRs3Gid, long fakeRs3GenId, int fakeRs3Scen) |
| | | { |
| | | List<Short> exptectedServers = new ArrayList<Short>(); |
| | | List<Integer> exptectedServers = new ArrayList<Integer>(); |
| | | if (areGroupAndGenerationIdOk(fakeRs1Gid, fakeRs1GenId)) |
| | | { |
| | | if (fakeRs1Scen == REPLY_OK_RS_SCENARIO) |
| | |
| | | assertEquals(fakeRd1.getAssuredSrReplayErrorUpdates(), 0); |
| | | |
| | | // Check for servers in error list |
| | | Map<Short, Integer> expectedErrors = new HashMap<Short, Integer>(); |
| | | Map<Integer, Integer> expectedErrors = new HashMap<Integer, Integer>(); |
| | | if (shouldSeeDsIdInError) |
| | | expectedErrors.put(FDS3_ID, 1); |
| | | if (shouldSeeRsIdInError) |
| | |
| | | /** |
| | | * Check that the passed server error lists are equivalent |
| | | */ |
| | | private void checkServerErrorListsAreEqual(Map<Short, Integer> list1, Map<Short, Integer> list2) |
| | | private void checkServerErrorListsAreEqual(Map<Integer, Integer> list1, Map<Integer, Integer> list2) |
| | | { |
| | | assertNotNull(list1); |
| | | assertNotNull(list2); |
| | | assertEquals(list1.size(), list2.size()); |
| | | for (Short s : list1.keySet()) |
| | | for (int s : list1.keySet()) |
| | | { |
| | | assertEquals(list1.get(s), list2.get(s)); |
| | | } |
| | |
| | | assertEquals(fakeRd1.getAssuredSrTimeoutUpdates(), 1); |
| | | assertEquals(fakeRd1.getAssuredSrWrongStatusUpdates(), 0); |
| | | assertEquals(fakeRd1.getAssuredSrReplayErrorUpdates(), 0); |
| | | Map<Short, Integer> failedServer = fakeRd1.getAssuredSrServerNotAcknowledgedUpdates(); |
| | | Map<Integer, Integer> failedServer = fakeRd1.getAssuredSrServerNotAcknowledgedUpdates(); |
| | | assertEquals(failedServer.size(), 1); |
| | | Integer nError = failedServer.get(FDS2_ID); |
| | | assertNotNull(nError); |
| | |
| | | assertEquals(fakeRd1.getAssuredSrTimeoutUpdates(), 4); |
| | | assertEquals(fakeRd1.getAssuredSrWrongStatusUpdates(), 0); |
| | | assertEquals(fakeRd1.getAssuredSrReplayErrorUpdates(), 0); |
| | | Map<Short, Integer> failedServer = fakeRd1.getAssuredSrServerNotAcknowledgedUpdates(); |
| | | Map<Integer, Integer> failedServer = fakeRd1.getAssuredSrServerNotAcknowledgedUpdates(); |
| | | assertEquals(failedServer.size(), 1); |
| | | Integer nError = failedServer.get(FDS2_ID); |
| | | assertNotNull(nError); |
| | |
| | | |
| | | dbEnv = new ReplicationDbEnv(path, replicationServer); |
| | | |
| | | handler = new DbHandler((short) 1, TEST_ROOT_DN_STRING, |
| | | handler = new DbHandler(1, TEST_ROOT_DN_STRING, |
| | | replicationServer, dbEnv, 5000); |
| | | |
| | | ChangeNumberGenerator gen = new ChangeNumberGenerator((short) 1, 0); |
| | | ChangeNumberGenerator gen = new ChangeNumberGenerator( 1, 0); |
| | | ChangeNumber changeNumber1 = gen.newChangeNumber(); |
| | | ChangeNumber changeNumber2 = gen.newChangeNumber(); |
| | | ChangeNumber changeNumber3 = gen.newChangeNumber(); |
| | |
| | | } |
| | | assertNotNull(ec); |
| | | assert(ec.getLocalizedMessage().equals("ChangeNumber not available")); |
| | | |
| | | |
| | | //-- |
| | | // Iterator tests with db only populated |
| | | Thread.sleep(1000); // let the time for flush to happen |
| | |
| | | } |
| | | assertNotNull(ec); |
| | | assert(ec.getLocalizedMessage().equals("ChangeNumber not available")); |
| | | |
| | | |
| | | // Test first and last |
| | | assertEquals(changeNumber1, handler.getFirstChange()); |
| | | assertEquals(changeNumber3, handler.getLastChange()); |
| | |
| | | } |
| | | assertNotNull(ec); |
| | | assert(ec.getLocalizedMessage().equals("ChangeNumber not available")); |
| | | |
| | | |
| | | handler.setPurgeDelay(1); |
| | | |
| | | boolean purged = false; |
| | |
| | | dbEnv = new ReplicationDbEnv(path, replicationServer); |
| | | |
| | | handler = |
| | | new DbHandler((short) 1, TEST_ROOT_DN_STRING, |
| | | new DbHandler( 1, TEST_ROOT_DN_STRING, |
| | | replicationServer, dbEnv, 5000); |
| | | |
| | | // Creates changes added to the dbHandler |
| | | ChangeNumberGenerator gen = new ChangeNumberGenerator((short) 1, 0); |
| | | ChangeNumberGenerator gen = new ChangeNumberGenerator( 1, 0); |
| | | ChangeNumber changeNumber1 = gen.newChangeNumber(); |
| | | ChangeNumber changeNumber2 = gen.newChangeNumber(); |
| | | ChangeNumber changeNumber3 = gen.newChangeNumber(); |
| | |
| | | int sn1 = 3; |
| | | int sn2 = 4; |
| | | int sn3 = 5; |
| | | |
| | | |
| | | String value1 = "value1"; |
| | | String value2 = "value2"; |
| | | String value3 = "value3"; |
| | | |
| | | |
| | | String serviceID1 = "serviceID1"; |
| | | String serviceID2 = "serviceID2"; |
| | | String serviceID3 = "serviceID3"; |
| | | |
| | | ChangeNumberGenerator gen = new ChangeNumberGenerator((short) 1, 0); |
| | | ChangeNumberGenerator gen = new ChangeNumberGenerator( 1, 0); |
| | | ChangeNumber changeNumber1 = gen.newChangeNumber(); |
| | | ChangeNumber changeNumber2 = gen.newChangeNumber(); |
| | | ChangeNumber changeNumber3 = gen.newChangeNumber(); |
| | |
| | | int firstkey = handler.getFirstKey(); |
| | | assertEquals(firstkey, sn1); |
| | | assertEquals(handler.getLastKey(), sn3); |
| | | |
| | | |
| | | DraftCNDBCursor dbc = handler.getReadCursor(firstkey); |
| | | assertEquals(dbc.currentChangeNumber(), changeNumber1); |
| | | assertEquals(dbc.currentServiceID(), serviceID1); |
| | | assertEquals(dbc.currentValue(), value1); |
| | | assertTrue(dbc.toString().length() != 0); |
| | | |
| | | |
| | | assertTrue(dbc.next()); |
| | | |
| | | |
| | | assertEquals(dbc.currentChangeNumber(), changeNumber2); |
| | | assertEquals(dbc.currentServiceID(), serviceID2); |
| | | assertEquals(dbc.currentValue(), value2); |
| | | |
| | | |
| | | assertTrue(dbc.next()); |
| | | |
| | | |
| | | assertEquals(dbc.currentChangeNumber(), changeNumber3); |
| | | assertEquals(dbc.currentServiceID(), serviceID3); |
| | | assertEquals(dbc.currentValue(), value3); |
| | | |
| | | |
| | | assertFalse(dbc.next()); |
| | | |
| | | |
| | | handler.releaseReadCursor(dbc); |
| | | |
| | | handler.setPurgeDelay(100); |
| | |
| | | } |
| | | assertEquals(handler.getFirstKey(), 0); |
| | | assertEquals(handler.getLastKey(), 0); |
| | | |
| | | |
| | | |
| | | |
| | | } finally |
| | | { |
| | | if (handler != null) |
| | |
| | | |
| | | // |
| | | assertTrue(handler.count()==0); |
| | | |
| | | |
| | | // Prepare data to be stored in the db |
| | | int sn1 = 3; |
| | | int sn2 = 4; |
| | | int sn3 = 5; |
| | | |
| | | |
| | | String value1 = "value1"; |
| | | String value2 = "value2"; |
| | | String value3 = "value3"; |
| | | |
| | | |
| | | String serviceID1 = "serviceID1"; |
| | | String serviceID2 = "serviceID2"; |
| | | String serviceID3 = "serviceID3"; |
| | | |
| | | ChangeNumberGenerator gen = new ChangeNumberGenerator((short) 1, 0); |
| | | ChangeNumberGenerator gen = new ChangeNumberGenerator( 1, 0); |
| | | ChangeNumber changeNumber1 = gen.newChangeNumber(); |
| | | ChangeNumber changeNumber2 = gen.newChangeNumber(); |
| | | ChangeNumber changeNumber3 = gen.newChangeNumber(); |
| | |
| | | // Checks |
| | | assertEquals(handler.getFirstKey(), sn1); |
| | | assertEquals(handler.getLastKey(), sn3); |
| | | |
| | | |
| | | assertEquals(handler.count(), 3, "Db count"); |
| | | |
| | | assertEquals(handler.getValue(sn1),value1); |
| | |
| | | private static final String testName = "monitorTest"; |
| | | |
| | | private static final int WINDOW_SIZE = 10; |
| | | private static final short server1ID = 1; |
| | | private static final short server2ID = 2; |
| | | private static final short server3ID = 3; |
| | | private static final short server4ID = 4; |
| | | private static final short changelog1ID = 21; |
| | | private static final short changelog2ID = 22; |
| | | private static final short changelog3ID = 23; |
| | | private static final int server1ID = 1; |
| | | private static final int server2ID = 2; |
| | | private static final int server3ID = 3; |
| | | private static final int server4ID = 4; |
| | | private static final int changelog1ID = 21; |
| | | private static final int changelog2ID = 22; |
| | | private static final int changelog3ID = 23; |
| | | |
| | | private DN baseDn; |
| | | private ReplicationBroker broker2 = null; |
| | |
| | | * server to the other replication servers in the test. |
| | | * @return The new created replication server. |
| | | */ |
| | | private ReplicationServer createReplicationServer(short changelogId, |
| | | private ReplicationServer createReplicationServer(int changelogId, |
| | | boolean all, String suffix) |
| | | { |
| | | SortedSet<String> servers = null; |
| | |
| | | * replication Server ID. |
| | | * @param changelogID |
| | | */ |
| | | private void connectServer1ToChangelog(short changelogID) |
| | | private void connectServer1ToChangelog(int changelogID) |
| | | { |
| | | // Connect DS to the replicationServer |
| | | try |
| | |
| | | /* |
| | | * Disconnect DS from the replicationServer |
| | | */ |
| | | private void disconnectFromReplServer(short changelogID) |
| | | private void disconnectFromReplServer(int changelogID) |
| | | { |
| | | try |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | private int getChangelogPort(short changelogID) |
| | | private int getChangelogPort(int changelogID) |
| | | { |
| | | if (replServerPort[changelogID] == 0) |
| | | { |
| | |
| | | + "userPassword: password\n" + "initials: AA\n"); |
| | | } |
| | | |
| | | static protected ReplicationMsg createAddMsg(short serverId) |
| | | static protected ReplicationMsg createAddMsg(int serverId) |
| | | { |
| | | Entry personWithUUIDEntry = null; |
| | | String user1entryUUID; |
| | |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Copyright 2006-2009 Sun Microsystems, Inc. |
| | | */ |
| | | package org.opends.server.replication.server; |
| | | |
| | |
| | | replicationServer.applyConfigurationChange(newconf); |
| | | |
| | | ReplicationBroker broker = openReplicationSession( |
| | | DN.decode(TEST_ROOT_DN_STRING), (short) 1, 10, newReplicationServerPort, |
| | | DN.decode(TEST_ROOT_DN_STRING), 1, 10, newReplicationServerPort, |
| | | 1000, false); |
| | | |
| | | // check that the sendWindow is not null to make sure that the |
| | |
| | | * Open a sender session and a receiver session to the replicationServer |
| | | */ |
| | | server1 = openReplicationSession( |
| | | DN.decode(TEST_ROOT_DN_STRING), (short) 1, 100, replicationServerPort, |
| | | DN.decode(TEST_ROOT_DN_STRING), 1, 100, replicationServerPort, |
| | | 1000, true); |
| | | server2 = openReplicationSession( |
| | | DN.decode(TEST_ROOT_DN_STRING), (short) 2, 100, replicationServerPort, |
| | | DN.decode(TEST_ROOT_DN_STRING), 2, 100, replicationServerPort, |
| | | 1000, true); |
| | | |
| | | assertTrue(server1.isConnected()); |
| | |
| | | * with current time sequence 1 and with current time + 2 sequence 2 |
| | | */ |
| | | long time = TimeThread.getTime(); |
| | | firstChangeNumberServer1 = new ChangeNumber(time, 1, (short) 1); |
| | | secondChangeNumberServer1 = new ChangeNumber(time + 2, 2, (short) 1); |
| | | firstChangeNumberServer1 = new ChangeNumber(time, 1, 1); |
| | | secondChangeNumberServer1 = new ChangeNumber(time + 2, 2, 1); |
| | | |
| | | /* |
| | | * Create change numbers for the messages sent from server 2 |
| | | * with current time sequence 1 and with current time + 3 sequence 2 |
| | | */ |
| | | firstChangeNumberServer2 = new ChangeNumber(time+ 1, 1, (short) 2); |
| | | secondChangeNumberServer2 = new ChangeNumber(time + 3, 2, (short) 2); |
| | | firstChangeNumberServer2 = new ChangeNumber(time+ 1, 1, 2); |
| | | secondChangeNumberServer2 = new ChangeNumber(time + 3, 2, 2); |
| | | |
| | | /* |
| | | * Create a ChangeNumber between firstChangeNumberServer1 and |
| | |
| | | * ReplicationServer to make sure that the ReplicationServer is |
| | | * able to accept such clients. |
| | | */ |
| | | unknownChangeNumberServer1 = new ChangeNumber(time+1, 1, (short) 1); |
| | | unknownChangeNumberServer1 = new ChangeNumber(time+1, 1, 1); |
| | | |
| | | /* |
| | | * Send and receive a Delete Msg from server 1 to server 2 |
| | |
| | | |
| | | try { |
| | | broker = |
| | | openReplicationSession(DN.decode(TEST_ROOT_DN_STRING), (short) 3, |
| | | openReplicationSession(DN.decode(TEST_ROOT_DN_STRING), 3, |
| | | 100, replicationServerPort, 1000, false); |
| | | |
| | | assertTrue(broker.isConnected()); |
| | |
| | | */ |
| | | try { |
| | | broker = |
| | | openReplicationSession(DN.decode(TEST_ROOT_DN_STRING), (short) 3, |
| | | openReplicationSession(DN.decode(TEST_ROOT_DN_STRING), 3, |
| | | 100, replicationServerPort, 5000, state); |
| | | |
| | | assertTrue(broker.isConnected()); |
| | |
| | | int CLIENT_THREADS = 3; // number of threads that will try to read |
| | | // the messages |
| | | ChangeNumberGenerator gen = |
| | | new ChangeNumberGenerator((short)5 , (long) 0); |
| | | new ChangeNumberGenerator(5 , (long) 0); |
| | | |
| | | BrokerReader client[] = new BrokerReader[CLIENT_THREADS]; |
| | | ReplicationBroker clientBroker[] = new ReplicationBroker[CLIENT_THREADS]; |
| | |
| | | * Open a sender session |
| | | */ |
| | | server = openReplicationSession( |
| | | DN.decode(TEST_ROOT_DN_STRING), (short) 5, 100, replicationServerPort, |
| | | DN.decode(TEST_ROOT_DN_STRING), 5, 100, replicationServerPort, |
| | | 100000, 1000, 0, false); |
| | | |
| | | assertTrue(server.isConnected()); |
| | |
| | | for (int i =0; i< CLIENT_THREADS; i++) |
| | | { |
| | | clientBroker[i] = openReplicationSession( |
| | | DN.decode(TEST_ROOT_DN_STRING), (short) (100+i), 100, replicationServerPort, |
| | | DN.decode(TEST_ROOT_DN_STRING), (100+i), 100, replicationServerPort, |
| | | 1000, true); |
| | | assertTrue(clientBroker[i].isConnected()); |
| | | client[i] = new BrokerReader(clientBroker[i], TOTAL_MSG); |
| | |
| | | */ |
| | | for (int i = 0; i< THREADS; i++) |
| | | { |
| | | short serverId = (short) (10+i); |
| | | int serverId = 10 + i; |
| | | ChangeNumberGenerator gen = |
| | | new ChangeNumberGenerator(serverId , (long) 0); |
| | | broker[i] = |
| | |
| | | ReplicationServer[] changelogs = new ReplicationServer[2]; |
| | | int[] changelogPorts = new int[2]; |
| | | int[] changelogIds = new int[2]; |
| | | short[] brokerIds = new short[2]; |
| | | int[] brokerIds = new int[2]; |
| | | ServerSocket socket = null; |
| | | |
| | | // Find 2 free ports |
| | |
| | | socket = TestCaseUtils.bindFreePort(); |
| | | changelogPorts[i] = socket.getLocalPort(); |
| | | changelogIds[i] = i + 80; |
| | | brokerIds[i] = (short) (100+i); |
| | | brokerIds[i] = 100 + i; |
| | | if ((itest==0) || (i ==0)) |
| | | socket.close(); |
| | | } |
| | |
| | | { |
| | | // send a ServerStartMsg with an empty ServerState. |
| | | ServerStartMsg msg = |
| | | new ServerStartMsg((short) 1723, TEST_ROOT_DN_STRING, |
| | | new ServerStartMsg( 1723, TEST_ROOT_DN_STRING, |
| | | WINDOW, (long) 5000, new ServerState(), |
| | | ProtocolVersion.getCurrentVersion(), 0, sslEncryption, (byte)-1); |
| | | session.publish(msg); |
| | |
| | | // received. |
| | | DN baseDn = DN.decode(TEST_ROOT_DN_STRING); |
| | | msg = new ServerStartMsg( |
| | | (short) 1724, TEST_ROOT_DN_STRING, |
| | | 1724, TEST_ROOT_DN_STRING, |
| | | WINDOW, (long) 5000, replServerState, |
| | | ProtocolVersion.getCurrentVersion(), |
| | | ReplicationTestCase.getGenerationId(baseDn), |
| | |
| | | try |
| | | { |
| | | server1 = openReplicationSession( |
| | | DN.decode(TEST_ROOT_DN_STRING), (short) 1, 100, |
| | | DN.decode(TEST_ROOT_DN_STRING), 1, 100, |
| | | replicationServerPort, |
| | | 1000, true); |
| | | server2 = openReplicationSession( |
| | | DN.decode("dc=domain2,dc=com"), (short) 2, 100, |
| | | DN.decode("dc=domain2,dc=com"), 2, 100, |
| | | replicationServerPort, |
| | | 1000, true); |
| | | |
| | |
| | | assertTrue(server2.isConnected()); |
| | | |
| | | debugInfo("Publish changes"); |
| | | List<UpdateMsg> msgs = createChanges(TEST_ROOT_DN_STRING, (short) 1); |
| | | List<UpdateMsg> msgs = createChanges(TEST_ROOT_DN_STRING, 1); |
| | | for (UpdateMsg msg : msgs) |
| | | { |
| | | server1.publish(msg); |
| | | } |
| | | List<UpdateMsg> msgs2 = createChanges("dc=domain2,dc=com", (short) 2); |
| | | List<UpdateMsg> msgs2 = createChanges("dc=domain2,dc=com", 2); |
| | | for (UpdateMsg msg : msgs2) |
| | | { |
| | | server2.publish(msg); |
| | |
| | | "ds-task-export-include-branch: "+suffix+",dc=replicationChanges"); |
| | | } |
| | | |
| | | private List<UpdateMsg> createChanges(String suffix, short serverId) |
| | | private List<UpdateMsg> createChanges(String suffix, int serverId) |
| | | { |
| | | List<UpdateMsg> l = new ArrayList<UpdateMsg>(); |
| | | long time = TimeThread.getTime(); |
| | |
| | | debugInfo("Create broker"); |
| | | |
| | | server1 = openReplicationSession( |
| | | DN.decode(TEST_ROOT_DN_STRING), (short) 1, 100, replicationServerPort, |
| | | DN.decode(TEST_ROOT_DN_STRING), 1, 100, replicationServerPort, |
| | | 1000, true); |
| | | |
| | | assertTrue(server1.isConnected()); |
| | | |
| | | debugInfo("Publish changes"); |
| | | List<UpdateMsg> msgs = createChanges(TEST_ROOT_DN_STRING, (short)1); |
| | | List<UpdateMsg> msgs = createChanges(TEST_ROOT_DN_STRING, 1); |
| | | for(UpdateMsg msg : msgs ) |
| | | { |
| | | server1.publish(msg); |
| | |
| | | ReplicationServer[] changelogs = new ReplicationServer[2]; |
| | | int[] changelogPorts = new int[2]; |
| | | int[] changelogIds = new int[2]; |
| | | short[] brokerIds = new short[2]; |
| | | int[] brokerIds = new int[2]; |
| | | ServerSocket socket = null; |
| | | |
| | | // Find 2 free ports |
| | |
| | | socket = TestCaseUtils.bindFreePort(); |
| | | changelogPorts[i] = socket.getLocalPort(); |
| | | changelogIds[i] = i + 90; |
| | | brokerIds[i] = (short) (100+i); |
| | | brokerIds[i] = 100+i; |
| | | socket.close(); |
| | | } |
| | | |
| | |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Copyright 2006-2009 Sun Microsystems, Inc. |
| | | */ |
| | | package org.opends.server.replication.server; |
| | | |
| | |
| | | @DataProvider(name = "updateMessageData") |
| | | public Object[][] createUpdateMessageData() { |
| | | |
| | | ChangeNumber cn1 = new ChangeNumber(1, (short) 0, (short) 1); |
| | | ChangeNumber cn2 = new ChangeNumber(TimeThread.getTime(), |
| | | (short) 123, (short) 45); |
| | | ChangeNumber cn1 = new ChangeNumber(1, 0, 1); |
| | | ChangeNumber cn2 = new ChangeNumber(TimeThread.getTime(), 123, 45); |
| | | |
| | | // |
| | | // Create the update message |
| | |
| | | |
| | | public FakeReplicationDomain( |
| | | String serviceID, |
| | | short serverID, |
| | | int serverID, |
| | | Collection<String> replicationServers, |
| | | int window, |
| | | long heartbeatInterval, |
| | |
| | | |
| | | public FakeReplicationDomain( |
| | | String serviceID, |
| | | short serverID, |
| | | int serverID, |
| | | Collection<String> replicationServers, |
| | | int window, |
| | | long heartbeatInterval, |
| | |
| | | |
| | | public FakeStressReplicationDomain( |
| | | String serviceID, |
| | | short serverID, |
| | | int serverID, |
| | | Collection<String> replicationServers, |
| | | int window, |
| | | long heartbeatInterval, |
| | |
| | | |
| | | public FakeStressReplicationDomain( |
| | | String serviceID, |
| | | short serverID, |
| | | int serverID, |
| | | Collection<String> replicationServers, |
| | | int window, |
| | | long heartbeatInterval, |
| | |
| | | import org.opends.server.replication.protocol.UpdateMsg; |
| | | import org.opends.server.replication.server.ReplServerFakeConfiguration; |
| | | import org.opends.server.replication.server.ReplicationServer; |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | /** |
| | |
| | | public class ReplicationDomainTest extends ReplicationTestCase |
| | | { |
| | | /** |
| | | * Create ChangeNumber Data |
| | | */ |
| | | @DataProvider(name = "publishAndReceiveData") |
| | | public Object[][] createpublishAndReceiveData() |
| | | { |
| | | return new Object[][] { |
| | | {1, 2, 3, 4}, |
| | | {1, 2, 1, 2}, |
| | | {1, 2, 45891, 45672}, |
| | | {45610, 45720, 1, 2}, |
| | | {45610, 45720, 45891, 45672} |
| | | }; |
| | | } |
| | | |
| | | /** |
| | | * Test that a ReplicationDomain is able to publish and receive UpdateMsg. |
| | | * Also test the ReplicationDomain.resetReplicationLog() method. |
| | | */ |
| | | @Test(enabled=true) |
| | | public void publishAndReceive() throws Exception |
| | | @Test(dataProvider = "publishAndReceiveData", enabled=true) |
| | | public void publishAndReceive( |
| | | int replServerID1, int replServerID2, |
| | | int domain1ServerId, int domain2ServerId) |
| | | throws Exception |
| | | { |
| | | String testService = "test"; |
| | | ReplicationServer replServer1 = null; |
| | | ReplicationServer replServer2 = null; |
| | | int replServerID1 = 10; |
| | | int replServerID2 = 20; |
| | | FakeReplicationDomain domain1 = null; |
| | | FakeReplicationDomain domain2 = null; |
| | | short domain1ServerId = 1; |
| | | short domain2ServerId = 2; |
| | | |
| | | try |
| | | { |
| | |
| | | for (RSInfo replServerInfo : replServers) |
| | | { |
| | | // The generation Id of the remote should be 1 |
| | | assertTrue(replServerInfo.getGenerationId() == 1); |
| | | assertEquals(replServerInfo.getGenerationId(), 1); |
| | | } |
| | | |
| | | for (DSInfo serverInfo : domain1.getReplicasList()) |
| | | { |
| | | assertTrue(serverInfo.getStatus() == ServerStatus.NORMAL_STATUS); |
| | | assertEquals(serverInfo.getStatus(), ServerStatus.NORMAL_STATUS); |
| | | } |
| | | |
| | | domain1.setGenerationID(2); |
| | |
| | | } |
| | | else |
| | | throw e; |
| | | } |
| | | } |
| | | } |
| | | Map<Short, ServerState> states1 = domain1.getReplicaStates(); |
| | | Map<Integer, ServerState> states1 = domain1.getReplicaStates(); |
| | | ServerState state2 = states1.get(domain2ServerId); |
| | | assertNotNull(state2, "getReplicaStates is not showing DS2"); |
| | | |
| | | Map<Short, ServerState> states2 = domain2.getReplicaStates(); |
| | | Map<Integer, ServerState> states2 = domain2.getReplicaStates(); |
| | | ServerState state1 = states2.get(domain1ServerId); |
| | | assertNotNull(state1, "getReplicaStates is not showing DS1"); |
| | | |
| | |
| | | finally |
| | | { |
| | | if (domain1 != null) |
| | | domain1.disableService(); |
| | | domain1.stopDomain(); |
| | | |
| | | if (domain2 != null) |
| | | domain2.disableService(); |
| | | domain2.stopDomain(); |
| | | |
| | | if (replServer1 != null) |
| | | replServer1.remove(); |
| | |
| | | ReplicationServer replServer1 = null; |
| | | int replServerID1 = 10; |
| | | FakeReplicationDomain domain1 = null; |
| | | short domain1ServerId = 1; |
| | | int domain1ServerId = 1; |
| | | |
| | | try |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | @DataProvider(name = "exportAndImportData") |
| | | public Object[][] createExportAndimportData() |
| | | { |
| | | return new Object[][] { |
| | | {1, 2}, |
| | | {45610, 45720} |
| | | }; |
| | | } |
| | | |
| | | /** |
| | | * Test that a ReplicationDomain is able to export and import its database |
| | | * When there is only one replication server. |
| | | */ |
| | | @Test(enabled=true) |
| | | public void exportAndImport() throws Exception |
| | | @Test(dataProvider = "exportAndImportData", enabled=true) |
| | | public void exportAndImport(int serverId1, int serverId2) throws Exception |
| | | { |
| | | final int ENTRYCOUNT=5000; |
| | | String testService = "test"; |
| | |
| | | } |
| | | String exportedData=exportedDataBuilder.toString(); |
| | | domain1 = new FakeReplicationDomain( |
| | | testService, (short) 1, servers, |
| | | testService, serverId1, servers, |
| | | 100, 0, exportedData, null, ENTRYCOUNT); |
| | | |
| | | StringBuilder importedData = new StringBuilder(); |
| | | domain2 = new FakeReplicationDomain( |
| | | testService, (short) 2, servers, 100, 0, |
| | | testService, serverId2, servers, 100, 0, |
| | | null, importedData, 0); |
| | | |
| | | /* |
| | |
| | | |
| | | BlockingQueue<UpdateMsg> rcvQueue1 = new LinkedBlockingQueue<UpdateMsg>(); |
| | | domain1 = new FakeStressReplicationDomain( |
| | | testService, (short) 2, servers, 100, 1000, rcvQueue1); |
| | | testService, 2, servers, 100, 1000, rcvQueue1); |
| | | |
| | | System.out.println("waiting"); |
| | | Thread.sleep(1000000000); |
| | |
| | | |
| | | BlockingQueue<UpdateMsg> rcvQueue1 = new LinkedBlockingQueue<UpdateMsg>(); |
| | | domain1 = new FakeStressReplicationDomain( |
| | | testService, (short) 1, servers, 100, 100000, rcvQueue1); |
| | | testService, 1, servers, 100, 100000, rcvQueue1); |
| | | /* |
| | | * Trigger a total update from domain1 to domain2. |
| | | * Check that the exported data is correctly received on domain2. |