use of com.github.ambry.router.ChunkInfo in project ambry by linkedin.
the class PostBlobHandlerTest method uploadChunksViaRouter.
// stitchedUploadTest() helpers
/**
* Upload chunks using the router directly.
* @param creationTimeMs the creation time to set for the chunks.
* @param container the {@link Container} to create the chunks in.
* @param chunkSizes the sizes for each chunk to upload.
* @return a list of {@link ChunkInfo} objects that contains metadata about each chunk uploaded.
*/
private List<ChunkInfo> uploadChunksViaRouter(long creationTimeMs, Container container, int... chunkSizes) throws Exception {
long blobTtlSecs = TimeUnit.DAYS.toSeconds(1);
List<ChunkInfo> chunks = new ArrayList<>();
for (int chunkSize : chunkSizes) {
byte[] content = TestUtils.getRandomBytes(chunkSize);
BlobProperties blobProperties = new BlobProperties(-1, SERVICE_ID, OWNER_ID, CONTENT_TYPE, !container.isCacheable(), blobTtlSecs, creationTimeMs, container.getParentAccountId(), container.getId(), container.isEncrypted(), null, null, null);
String blobId = router.putBlob(blobProperties, null, new ByteBufferReadableStreamChannel(ByteBuffer.wrap(content)), new PutBlobOptionsBuilder().chunkUpload(true).build()).get(TIMEOUT_SECS, TimeUnit.SECONDS);
chunks.add(new ChunkInfo(blobId, chunkSize, Utils.addSecondsToEpochTime(creationTimeMs, blobTtlSecs)));
}
return chunks;
}
Aggregations