HDDS-1492. Generated chunk size name too long. Contributed by Shashikannt Banerjee. (#1084)

This commit is contained in:
Shashikant Banerjee 2019-07-16 18:01:13 +05:30
parent 1502e6a22f
commit d21eccf8ba
2 changed files with 6 additions and 14 deletions

View File

@ -29,7 +29,6 @@
import org.apache.hadoop.ozone.common.ChecksumData; import org.apache.hadoop.ozone.common.ChecksumData;
import org.apache.hadoop.ozone.common.OzoneChecksumException; import org.apache.hadoop.ozone.common.OzoneChecksumException;
import org.apache.ratis.thirdparty.com.google.protobuf.ByteString; import org.apache.ratis.thirdparty.com.google.protobuf.ByteString;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.hadoop.hdds.scm.XceiverClientManager; import org.apache.hadoop.hdds.scm.XceiverClientManager;
import org.apache.hadoop.hdds.scm.XceiverClientSpi; import org.apache.hadoop.hdds.scm.XceiverClientSpi;
import org.apache.hadoop.hdds.protocol.datanode.proto.ContainerProtos.ChecksumType; import org.apache.hadoop.hdds.protocol.datanode.proto.ContainerProtos.ChecksumType;
@ -44,7 +43,6 @@
import java.io.OutputStream; import java.io.OutputStream;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.util.Collections; import java.util.Collections;
import java.util.UUID;
import java.util.List; import java.util.List;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Map; import java.util.Map;
@ -81,14 +79,12 @@ public class BlockOutputStream extends OutputStream {
LoggerFactory.getLogger(BlockOutputStream.class); LoggerFactory.getLogger(BlockOutputStream.class);
private volatile BlockID blockID; private volatile BlockID blockID;
private final String key;
private final BlockData.Builder containerBlockData; private final BlockData.Builder containerBlockData;
private XceiverClientManager xceiverClientManager; private XceiverClientManager xceiverClientManager;
private XceiverClientSpi xceiverClient; private XceiverClientSpi xceiverClient;
private final ContainerProtos.ChecksumType checksumType; private final ContainerProtos.ChecksumType checksumType;
private final int bytesPerChecksum; private final int bytesPerChecksum;
private final String streamId;
private int chunkIndex; private int chunkIndex;
private int chunkSize; private int chunkSize;
private final long streamBufferFlushSize; private final long streamBufferFlushSize;
@ -125,7 +121,6 @@ public class BlockOutputStream extends OutputStream {
* Creates a new BlockOutputStream. * Creates a new BlockOutputStream.
* *
* @param blockID block ID * @param blockID block ID
* @param key chunk key
* @param xceiverClientManager client manager that controls client * @param xceiverClientManager client manager that controls client
* @param pipeline pipeline where block will be written * @param pipeline pipeline where block will be written
* @param chunkSize chunk size * @param chunkSize chunk size
@ -137,14 +132,13 @@ public class BlockOutputStream extends OutputStream {
* @param bytesPerChecksum Bytes per checksum * @param bytesPerChecksum Bytes per checksum
*/ */
@SuppressWarnings("parameternumber") @SuppressWarnings("parameternumber")
public BlockOutputStream(BlockID blockID, String key, public BlockOutputStream(BlockID blockID,
XceiverClientManager xceiverClientManager, Pipeline pipeline, XceiverClientManager xceiverClientManager, Pipeline pipeline,
int chunkSize, long streamBufferFlushSize, int chunkSize, long streamBufferFlushSize, long streamBufferMaxSize,
long streamBufferMaxSize, long watchTimeout, BufferPool bufferPool, long watchTimeout, BufferPool bufferPool, ChecksumType checksumType,
ChecksumType checksumType, int bytesPerChecksum) int bytesPerChecksum)
throws IOException { throws IOException {
this.blockID = blockID; this.blockID = blockID;
this.key = key;
this.chunkSize = chunkSize; this.chunkSize = chunkSize;
KeyValue keyValue = KeyValue keyValue =
KeyValue.newBuilder().setKey("TYPE").setValue("KEY").build(); KeyValue.newBuilder().setKey("TYPE").setValue("KEY").build();
@ -153,7 +147,6 @@ public BlockOutputStream(BlockID blockID, String key,
.addMetadata(keyValue); .addMetadata(keyValue);
this.xceiverClientManager = xceiverClientManager; this.xceiverClientManager = xceiverClientManager;
this.xceiverClient = xceiverClientManager.acquireClient(pipeline); this.xceiverClient = xceiverClientManager.acquireClient(pipeline);
this.streamId = UUID.randomUUID().toString();
this.chunkIndex = 0; this.chunkIndex = 0;
this.streamBufferFlushSize = streamBufferFlushSize; this.streamBufferFlushSize = streamBufferFlushSize;
this.streamBufferMaxSize = streamBufferMaxSize; this.streamBufferMaxSize = streamBufferMaxSize;
@ -598,8 +591,7 @@ private void writeChunkToContainer(ByteBuffer chunk) throws IOException {
Checksum checksum = new Checksum(checksumType, bytesPerChecksum); Checksum checksum = new Checksum(checksumType, bytesPerChecksum);
ChecksumData checksumData = checksum.computeChecksum(chunk); ChecksumData checksumData = checksum.computeChecksum(chunk);
ChunkInfo chunkInfo = ChunkInfo.newBuilder() ChunkInfo chunkInfo = ChunkInfo.newBuilder()
.setChunkName(DigestUtils.md5Hex(key) + "_stream_" + streamId + .setChunkName(blockID.getLocalID() + "_chunk_" + ++chunkIndex)
"_chunk_" + ++chunkIndex)
.setOffset(0) .setOffset(0)
.setLen(effectiveChunkSize) .setLen(effectiveChunkSize)
.setChecksumData(checksumData.getProtoBufMessage()) .setChecksumData(checksumData.getProtoBufMessage())

View File

@ -108,7 +108,7 @@ private void checkStream() throws IOException {
UserGroupInformation.getCurrentUser().addToken(getToken()); UserGroupInformation.getCurrentUser().addToken(getToken());
} }
this.outputStream = this.outputStream =
new BlockOutputStream(blockID, key, xceiverClientManager, new BlockOutputStream(blockID, xceiverClientManager,
pipeline, chunkSize, streamBufferFlushSize, pipeline, chunkSize, streamBufferFlushSize,
streamBufferMaxSize, watchTimeout, bufferPool, checksumType, streamBufferMaxSize, watchTimeout, bufferPool, checksumType,
bytesPerChecksum); bytesPerChecksum);