Skip to content

HDDS-5963. Implement ListBlock command.#2829

Closed
ChenSammi wants to merge 2 commits intoapache:masterfrom
ChenSammi:HDDS-5963
Closed

HDDS-5963. Implement ListBlock command.#2829
ChenSammi wants to merge 2 commits intoapache:masterfrom
ChenSammi:HDDS-5963

Conversation

@ChenSammi
Copy link
Contributor

Copy link
Contributor

@adoroszlai adoroszlai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @ChenSammi for working on this.

I think we should require container token for ListBlock operation:

public static boolean requireContainerToken(
ContainerProtos.Type cmdType) {
switch (cmdType) {
case CloseContainer:
case CreateContainer:
case DeleteContainer:
case ReadContainer:
case UpdateContainer:
return true;
default:
return false;
}
}

Comment on lines +402 to +417
private ContainerCommandRequestProto getPutBlockRequest(
ContainerCommandRequestProto writeChunkRequest) {
ContainerProtos.BlockData.Builder block =
ContainerProtos.BlockData.newBuilder()
.setSize(writeChunkRequest.getWriteChunk().getChunkData().getLen())
.setBlockID(writeChunkRequest.getWriteChunk().getBlockID())
.addChunks(writeChunkRequest.getWriteChunk().getChunkData());
return ContainerCommandRequestProto.newBuilder()
.setContainerID(writeChunkRequest.getContainerID())
.setCmdType(ContainerProtos.Type.PutBlock)
.setDatanodeUuid(writeChunkRequest.getDatanodeUuid())
.setPutBlock(ContainerProtos.PutBlockRequestProto.newBuilder()
.setBlockData(block.build())
.build())
.build();
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please reuse existing code from ContainerTestHelper:

/**
* Returns the PutBlockRequest for test purpose.
* @param pipeline - pipeline.
* @param writeRequest - Write Chunk Request.
* @return - Request
*/
public static ContainerCommandRequestProto getPutBlockRequest(
Pipeline pipeline, ContainerProtos.WriteChunkRequestProto writeRequest)
throws IOException {
return getPutBlockRequest(pipeline, null, writeRequest);
}
/**
* Returns the PutBlockRequest for test purpose.
* @param pipeline - pipeline.
* @param token - token.
* @param writeRequest - Write Chunk Request.
* @return - Request
*/
public static ContainerCommandRequestProto getPutBlockRequest(
Pipeline pipeline, String token,
ContainerProtos.WriteChunkRequestProto writeRequest)
throws IOException {
Builder builder = newPutBlockRequestBuilder(pipeline, writeRequest);
if (!Strings.isNullOrEmpty(token)) {
builder.setEncodedToken(token);
}
return builder.build();
}
public static Builder newPutBlockRequestBuilder(Pipeline pipeline,
ContainerProtos.WriteChunkRequestProtoOrBuilder writeRequest)
throws IOException {
LOG.trace("putBlock: {} to pipeline={}",
writeRequest.getBlockID(), pipeline);
ContainerProtos.PutBlockRequestProto.Builder putRequest =
ContainerProtos.PutBlockRequestProto.newBuilder();
BlockData blockData = new BlockData(
BlockID.getFromProtobuf(writeRequest.getBlockID()));
List<ContainerProtos.ChunkInfo> newList = new LinkedList<>();
newList.add(writeRequest.getChunkData());
blockData.setChunks(newList);
blockData.setBlockCommitSequenceId(0);
putRequest.setBlockData(blockData.getProtoBufMessage());
Builder request =
ContainerCommandRequestProto.newBuilder();
request.setCmdType(ContainerProtos.Type.PutBlock);
request.setContainerID(blockData.getContainerID());
request.setPutBlock(putRequest);
request.setDatanodeUuid(pipeline.getFirstNode().getUuidString());
return request;
}

@adoroszlai
Copy link
Contributor

/pending

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Marking this issue as un-mergeable as requested.

Please use /ready comment when it's resolved.

Please note that the PR will be closed after 21 days of inactivity from now. (But can be re-opened anytime later...)

/pending

@cchenax
Copy link
Contributor

cchenax commented Mar 18, 2022

because of I can not commit code the sammi's pr, So I take this pr,I take the new one.@adoroszlai
this pr #3212

@adoroszlai adoroszlai closed this Mar 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

Comments