Skip to content

Commit

Permalink
Issue pravega#3624: Fix backward compatibility issue with WireCommand…
Browse files Browse the repository at this point in the history
…s. (pravega#3640)

* Removes unneeded requestId on AppendBlock.

Signed-off-by: Tom Kaitchuck <[email protected]>
  • Loading branch information
tkaitchuck authored and fpj committed Apr 18, 2019
1 parent a0ed24e commit cb253c8
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ protected void encode(ChannelHandlerContext ctx, Object msg, ByteBuf out) throws
bytesLeftInBlock = currentBlockSize;
segmentBeingAppendedTo = append.segment;
writerIdPerformingAppends = append.writerId;
writeMessage(new AppendBlock(append.getRequestId(), session.id), out);
writeMessage(new AppendBlock(session.id), out);
if (ctx != null) {
ctx.executor().schedule(new BlockTimeouter(ctx.channel(), currentBlockSize),
blockSizeSupplier.getBatchTimeout(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -524,34 +524,29 @@ public static final class AppendBlock implements WireCommand {
final WireCommandType type = WireCommandType.APPEND_BLOCK;
final UUID writerId;
final ByteBuf data;
final long requestId;

AppendBlock(long requestId, UUID writerId) {
AppendBlock(UUID writerId) {
this.writerId = writerId;
this.data = Unpooled.EMPTY_BUFFER; // Populated on read path
this.requestId = requestId;
}

AppendBlock(long requestId, UUID writerId, ByteBuf data) {
AppendBlock(UUID writerId, ByteBuf data) {
this.writerId = writerId;
this.data = data;
this.requestId = requestId;
}

@Override
public void writeFields(DataOutput out) throws IOException {
out.writeLong(writerId.getMostSignificantBits());
out.writeLong(writerId.getLeastSignificantBits());
out.writeLong(requestId);
// Data not written, as it should be null.
}

public static WireCommand readFrom(ByteBufInputStream in, int length) throws IOException {
UUID writerId = new UUID(in.readLong(), in.readLong());
byte[] data = new byte[length - Long.BYTES * 3];
long requestId = (in.available() >= Long.BYTES) ? in.readLong() : -1L;
byte[] data = new byte[length - Long.BYTES * 2];
in.readFully(data);
return new AppendBlock(requestId, writerId, wrappedBuffer(data));
return new AppendBlock(writerId, wrappedBuffer(data));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public void testAppendSetup() throws IOException {

@Test
public void testAppendBlock() throws IOException {
testCommand(new WireCommands.AppendBlock(l, uuid));
testCommand(new WireCommands.AppendBlock(uuid));
}

@Test
Expand Down

0 comments on commit cb253c8

Please sign in to comment.