Skip to content

Commit

Permalink
[ONOS-6401] Implement dynamically computed timeouts for NettyMessagin…
Browse files Browse the repository at this point in the history
…gManager

Change-Id: Ie2673603a2251983c9e0a166020b4feec041e84c
  • Loading branch information
Jordan Halterman committed Jun 26, 2017
1 parent f37e360 commit f7c7f6f
Show file tree
Hide file tree
Showing 5 changed files with 528 additions and 250 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,19 @@ public InternalMessage(int preamble,
Endpoint sender,
String type,
byte[] payload) {
this(preamble, time, id, sender, type, payload, Status.OK);
this(preamble, time, id, sender, type, payload, null);
}

public InternalMessage(int preamble,
HybridLogicalTime time,
long id,
Endpoint sender,
byte[] payload,
Status status) {
this(preamble, time, id, sender, "", payload, status);
}

InternalMessage(int preamble,
HybridLogicalTime time,
long id,
Endpoint sender,
Expand All @@ -124,6 +133,14 @@ public InternalMessage(int preamble,
this.status = status;
}

public boolean isRequest() {
return status == null;
}

public boolean isReply() {
return status != null;
}

public HybridLogicalTime time() {
return time;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,20 @@ protected void decode(
senderPort = buffer.readInt();
checkpoint(DecoderState.READ_MESSAGE_TYPE_LENGTH);
case READ_MESSAGE_TYPE_LENGTH:
messageTypeLength = buffer.readInt();
messageTypeLength = buffer.readShort();
checkpoint(DecoderState.READ_MESSAGE_TYPE);
case READ_MESSAGE_TYPE:
byte[] messageTypeBytes = new byte[messageTypeLength];
buffer.readBytes(messageTypeBytes);
messageType = new String(messageTypeBytes, Charsets.UTF_8);
checkpoint(DecoderState.READ_MESSAGE_STATUS);
case READ_MESSAGE_STATUS:
status = Status.forId(buffer.readInt());
int statusId = buffer.readByte();
if (statusId == -1) {
status = null;
} else {
status = Status.forId(statusId);
}
checkpoint(DecoderState.READ_CONTENT_LENGTH);
case READ_CONTENT_LENGTH:
contentLength = buffer.readInt();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,18 @@ protected void encode(
byte[] messageTypeBytes = message.type().getBytes(Charsets.UTF_8);

// write length of message type
out.writeInt(messageTypeBytes.length);
out.writeShort(messageTypeBytes.length);

// write message type bytes
out.writeBytes(messageTypeBytes);

// write message status value
out.writeInt(message.status().id());
InternalMessage.Status status = message.status();
if (status == null) {
out.writeByte(-1);
} else {
out.writeByte(status.id());
}

byte[] payload = message.payload();

Expand Down

0 comments on commit f7c7f6f

Please sign in to comment.