Skip to content

Commit

Permalink
IGNITE-11058 Reduce the size of discovery pending message history - F…
Browse files Browse the repository at this point in the history
…ixes apache#6161.

Signed-off-by: Alexey Goncharuk <alexey.goncharuk@gmail.com>
(cherry picked from commit 01e601d)
  • Loading branch information
antonovsergey93 committed Feb 22, 2019
1 parent 9af34f6 commit 627919f
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2238,6 +2238,8 @@ private class EnsuredMessageHistory {
void add(TcpDiscoveryAbstractMessage msg) {
assert spi.ensured(msg) && msg.verified() : msg;

assert U.hasDeclaredAnnotation(msg, TcpDiscoveryRedirectToClient.class) : msg;

if (msg instanceof TcpDiscoveryNodeAddedMessage) {
TcpDiscoveryNodeAddedMessage addedMsg =
new TcpDiscoveryNodeAddedMessage((TcpDiscoveryNodeAddedMessage)msg);
Expand Down Expand Up @@ -2299,6 +2301,14 @@ else if (msg instanceof TcpDiscoveryNodeLeftMessage)
clearClientAddFinished(msg.creatorNodeId());
else if (msg instanceof TcpDiscoveryNodeFailedMessage)
clearClientAddFinished(((TcpDiscoveryNodeFailedMessage)msg).failedNodeId());
else if (msg instanceof TcpDiscoveryCustomEventMessage) {
TcpDiscoveryCustomEventMessage msg0 = (TcpDiscoveryCustomEventMessage)msg;

msg = new TcpDiscoveryCustomEventMessage(msg0);

// We shoulgn't store deserialized message in the queue because of msg is transient.
((TcpDiscoveryCustomEventMessage)msg).clearMessage();
}

synchronized (msgs) {
msgs.add(msg);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,24 @@ public TcpDiscoveryCustomEventMessage(UUID creatorNodeId, @Nullable DiscoverySpi
this.msgBytes = msgBytes;
}

/**
* Copy constructor.
* @param msg Message.
*/
public TcpDiscoveryCustomEventMessage(TcpDiscoveryCustomEventMessage msg) {
super(msg);

this.msgBytes = msg.msgBytes;
this.msg = msg.msg;
}

/**
* Clear deserialized form of wrapped message.
*/
public void clearMessage() {
msg = null;
}

/**
* @return Serialized message.
*/
Expand Down

0 comments on commit 627919f

Please sign in to comment.