issue 3640 : Refactor Replication code to make it more generic
It contains three minor changes :
- a reload() method for ServerState.
- minor change in the EntryMsg code allowing non-ascii content
- implements the read() method in ReplInputStream()
| | |
| | | } |
| | | |
| | | /** |
| | | * Replace the Server State with another ServerState. |
| | | * |
| | | * @param serverState The ServerState. |
| | | * |
| | | * @return a boolean indicating if the update was meaningful. |
| | | */ |
| | | public boolean reload(ServerState serverState) { |
| | | if (serverState == null) { |
| | | return false; |
| | | } |
| | | |
| | | boolean result = false; |
| | | |
| | | clear(); |
| | | for (Short id : serverState) { |
| | | ChangeNumber maxChangeNumber = getMaxChangeNumber(id); |
| | | if (update(maxChangeNumber)) { |
| | | result = true; |
| | | } |
| | | } |
| | | |
| | | return (result); |
| | | } |
| | | |
| | | /** |
| | | * return a Set of String usable as a textual representation of |
| | | * a Server state. |
| | | * format : time seqnum id |
| | |
| | | pos += length +1; |
| | | |
| | | // entry |
| | | length = getNextLength(in, pos); |
| | | length = in.length - (pos + 1); |
| | | this.entryByteArray = new byte[length]; |
| | | for (int i=0; i<length; i++) |
| | | { |
| | |
| | | public int read() |
| | | throws IOException |
| | | { |
| | | // This method is not supposed to be called to make an LDIF import |
| | | // for replication. |
| | | throw new IOException("Not implemented"); |
| | | } |
| | | if (closed) { |
| | | return -1; |
| | | } |
| | | |
| | | byte[] b = new byte[1]; |
| | | |
| | | if (read(b, 0, 1) == 0) { |
| | | throw new IOException(); |
| | | } |
| | | |
| | | return ((int)b[0]); |
| | | } |
| | | } |