mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

Jean-Noel Rouvignac
23.17.2014 88cfe5045d77d433ce02b0ef10ee84c9d4fb15e2
refs
author Jean-Noel Rouvignac <jean-noel.rouvignac@forgerock.com>
Friday, May 23, 2014 17:17 +0200
committer Jean-Noel Rouvignac <jean-noel.rouvignac@forgerock.com>
Friday, May 23, 2014 17:17 +0200
commit88cfe5045d77d433ce02b0ef10ee84c9d4fb15e2
tree 3cad1189a37c5715ef38d4497c81a5d270324311 tree | zip | gz
parent bef73d94160ab49b47eed6d8fa17f0532d182b07 view | diff
(CR-3599) Convert all protocols message to use ByteArrayBuilder + ByteArrayScanner

The downside of this change is that now there could be superfluous byte array copies when appending to a ByteArrayBuilder while code before was building the final byte array once after the final size was known.
If this proves to be a performance hit, it could be optimized later by building the final byte array on the call to ByteArrayBuilder.toByteArray().

Since OpenDJ 2.8 will introduce a protocol version change, it could be a good time to further cleanup the protocol by always encoding ints, longs, CSNs and booleans in their most compact representations. It should also be possible to remove zero terminated madness for anything else than strings.



ByteArrayBuilder.java, ByteArrayScanner.java:
Changed existing code to exactly match legacy behaviour.
Added methods to simplify protocol (de)serialization.
In ByteArrayBuilder ctor, set the default byte array size to 256 to avoid too copying byte arrays too many times initially.

ByteArrayTest.java:
Added tests for new functionalities.
Increased coverage.


AckMsg.java:
In errorsToString(), used List.toString().

MonitorMsg.java:
In ctor, used setServerState().

ReplicationMsg.java:
Removed now unused methods getNextLength() and addByteArray().

StartSessionMsg.java:
Removed ctor only called from tests.

ReplicationServerTest.java:
Consequence of removing a ctor for StartSessionMsg.

NotAssuredUpdateMsg.java:
Extracted methods getRealUpdateMsgBytes(), findNthZeroByte(),


ServerState.java:
Moved ctor code to ByteArrayScanner.nextServerState() + removed getNextLength().
Moved getBytes() code to ByteArrayBuilder.append(ServerState) + removed addByteArray().
Added method getServerIdToCSNMap().

ServerStateTest.java:
Consequence of the change to ServerState class.


ReplicationData.java: REMOVED, not used anymore

ReplicationDB.java:
Consequence of removing ReplicationData.
Removed dead methods getPreviousCSN() and getRegularRecord().


*Msg.java:
Inlined a few methods (getBytes_V1() for example) to make the code clearer.

*.java:
Removed comments paraphrasing the code.
Removed now unnecessary exception handling + declarations for UnsupportedEncodingExceptions.
Added final keywords.
Reduced visibility of class members.
Fixed javadocs.
1 files deleted
39 files modified
5930 ■■■■ changed files
opends/src/server/org/opends/server/replication/common/ServerState.java 130 ●●●●● diff | view | raw | blame | history
opends/src/server/org/opends/server/replication/plugin/LDAPReplicationDomain.java 13 ●●●●● diff | view | raw | blame | history
opends/src/server/org/opends/server/replication/protocol/AckMsg.java 137 ●●●● diff | view | raw | blame | history
opends/src/server/org/opends/server/replication/protocol/AddMsg.java 240 ●●●● diff | view | raw | blame | history
opends/src/server/org/opends/server/replication/protocol/ByteArrayBuilder.java 114 ●●●● diff | view | raw | blame | history
opends/src/server/org/opends/server/replication/protocol/ByteArrayScanner.java 151 ●●●●● diff | view | raw | blame | history
opends/src/server/org/opends/server/replication/protocol/ChangeStatusMsg.java 53 ●●●●● diff | view | raw | blame | history
opends/src/server/org/opends/server/replication/protocol/DeleteMsg.java 127 ●●●● diff | view | raw | blame | history
opends/src/server/org/opends/server/replication/protocol/DoneMsg.java 68 ●●●● diff | view | raw | blame | history
opends/src/server/org/opends/server/replication/protocol/ECLUpdateMsg.java 86 ●●●● diff | view | raw | blame | history
opends/src/server/org/opends/server/replication/protocol/EntryMsg.java 128 ●●●● diff | view | raw | blame | history
opends/src/server/org/opends/server/replication/protocol/ErrorMsg.java 163 ●●●●● diff | view | raw | blame | history
opends/src/server/org/opends/server/replication/protocol/HeartbeatMsg.java 21 ●●●● diff | view | raw | blame | history
opends/src/server/org/opends/server/replication/protocol/InitializeRcvAckMsg.java 90 ●●●● diff | view | raw | blame | history
opends/src/server/org/opends/server/replication/protocol/InitializeRequestMsg.java 111 ●●●● diff | view | raw | blame | history
opends/src/server/org/opends/server/replication/protocol/InitializeTargetMsg.java 143 ●●●● diff | view | raw | blame | history
opends/src/server/org/opends/server/replication/protocol/LDAPUpdateMsg.java 364 ●●●● diff | view | raw | blame | history
opends/src/server/org/opends/server/replication/protocol/ModifyDNMsg.java 387 ●●●● diff | view | raw | blame | history
opends/src/server/org/opends/server/replication/protocol/ModifyMsg.java 166 ●●●● diff | view | raw | blame | history
opends/src/server/org/opends/server/replication/protocol/MonitorMsg.java 199 ●●●●● diff | view | raw | blame | history
opends/src/server/org/opends/server/replication/protocol/MonitorRequestMsg.java 76 ●●●● diff | view | raw | blame | history
opends/src/server/org/opends/server/replication/protocol/ReplServerStartDSMsg.java 207 ●●●● diff | view | raw | blame | history
opends/src/server/org/opends/server/replication/protocol/ReplServerStartMsg.java 344 ●●●● diff | view | raw | blame | history
opends/src/server/org/opends/server/replication/protocol/ReplicationMsg.java 64 ●●●●● diff | view | raw | blame | history
opends/src/server/org/opends/server/replication/protocol/ResetGenerationIdMsg.java 61 ●●●● diff | view | raw | blame | history
opends/src/server/org/opends/server/replication/protocol/ServerStartECLMsg.java 194 ●●●● diff | view | raw | blame | history
opends/src/server/org/opends/server/replication/protocol/ServerStartMsg.java 228 ●●●● diff | view | raw | blame | history
opends/src/server/org/opends/server/replication/protocol/StartECLSessionMsg.java 156 ●●●● diff | view | raw | blame | history
opends/src/server/org/opends/server/replication/protocol/StartMsg.java 224 ●●●● diff | view | raw | blame | history
opends/src/server/org/opends/server/replication/protocol/StartSessionMsg.java 131 ●●●● diff | view | raw | blame | history
opends/src/server/org/opends/server/replication/protocol/TopologyMsg.java 388 ●●●●● diff | view | raw | blame | history
opends/src/server/org/opends/server/replication/protocol/UpdateMsg.java 201 ●●●● diff | view | raw | blame | history
opends/src/server/org/opends/server/replication/protocol/WindowMsg.java 69 ●●●● diff | view | raw | blame | history
opends/src/server/org/opends/server/replication/server/NotAssuredUpdateMsg.java 255 ●●●●● diff | view | raw | blame | history
opends/src/server/org/opends/server/replication/server/changelog/file/FileReplicaDB.java 16 ●●●●● diff | view | raw | blame | history
opends/src/server/org/opends/server/replication/server/changelog/je/ReplicationDB.java 138 ●●●● diff | view | raw | blame | history
opends/src/server/org/opends/server/replication/server/changelog/je/ReplicationData.java 80 ●●●●● diff | view | raw | blame | history
opends/tests/unit-tests-testng/src/server/org/opends/server/replication/common/ServerStateTest.java 7 ●●●● diff | view | raw | blame | history
opends/tests/unit-tests-testng/src/server/org/opends/server/replication/protocol/ByteArrayTest.java 193 ●●●●● diff | view | raw | blame | history
opends/tests/unit-tests-testng/src/server/org/opends/server/replication/server/ReplicationServerTest.java 7 ●●●●● diff | view | raw | blame | history