Search in sources :

Example 6 with ChunkInfo

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;
}
Also used : ChunkInfo(com.github.ambry.router.ChunkInfo) ByteBufferReadableStreamChannel(com.github.ambry.commons.ByteBufferReadableStreamChannel) PutBlobOptionsBuilder(com.github.ambry.router.PutBlobOptionsBuilder) BlobProperties(com.github.ambry.messageformat.BlobProperties) ArrayList(java.util.ArrayList)

Aggregations

ByteBufferReadableStreamChannel (com.github.ambry.commons.ByteBufferReadableStreamChannel)6 BlobProperties (com.github.ambry.messageformat.BlobProperties)6 ChunkInfo (com.github.ambry.router.ChunkInfo)6 PutBlobOptionsBuilder (com.github.ambry.router.PutBlobOptionsBuilder)6 ArrayList (java.util.ArrayList)6 MetricRegistry (com.codahale.metrics.MetricRegistry)4 Account (com.github.ambry.account.Account)4 AccountBuilder (com.github.ambry.account.AccountBuilder)4 Container (com.github.ambry.account.Container)4 ContainerBuilder (com.github.ambry.account.ContainerBuilder)4 InMemAccountService (com.github.ambry.account.InMemAccountService)4 ClusterMap (com.github.ambry.clustermap.ClusterMap)4 MockClusterMap (com.github.ambry.clustermap.MockClusterMap)4 FrontendConfig (com.github.ambry.config.FrontendConfig)4 VerifiableProperties (com.github.ambry.config.VerifiableProperties)4 QuotaTestUtils (com.github.ambry.quota.QuotaTestUtils)4 MockRestResponseChannel (com.github.ambry.rest.MockRestResponseChannel)4 RequestPath (com.github.ambry.rest.RequestPath)4 RestMethod (com.github.ambry.rest.RestMethod)4 RestRequest (com.github.ambry.rest.RestRequest)4