Search in sources :

Example 11 with GetBlobOptionsBuilder

use of com.github.ambry.router.GetBlobOptionsBuilder in project ambry by linkedin.

the class ServerTestUtil method checkBlobId.

private static void checkBlobId(Router router, BlobId blobId, byte[] data) throws Exception {
    GetBlobResult result = router.getBlob(blobId.getID(), new GetBlobOptionsBuilder().build()).get(20, TimeUnit.SECONDS);
    ReadableStreamChannel blob = result.getBlobDataChannel();
    assertEquals("Size does not match that of data", data.length, result.getBlobInfo().getBlobProperties().getBlobSize());
    RetainingAsyncWritableChannel channel = new RetainingAsyncWritableChannel();
    blob.readInto(channel, null).get(1, TimeUnit.SECONDS);
    try (InputStream is = channel.consumeContentAsInputStream()) {
        assertArrayEquals(data, Utils.readBytesFromStream(is, (int) channel.getBytesWritten()));
    }
}
Also used : GetBlobOptionsBuilder(com.github.ambry.router.GetBlobOptionsBuilder) GetBlobResult(com.github.ambry.router.GetBlobResult) ReadableStreamChannel(com.github.ambry.router.ReadableStreamChannel) ByteBufferReadableStreamChannel(com.github.ambry.commons.ByteBufferReadableStreamChannel) RetainingAsyncWritableChannel(com.github.ambry.commons.RetainingAsyncWritableChannel) NettyByteBufDataInputStream(com.github.ambry.utils.NettyByteBufDataInputStream) PutMessageFormatInputStream(com.github.ambry.messageformat.PutMessageFormatInputStream) ByteBufferInputStream(com.github.ambry.utils.ByteBufferInputStream) DataInputStream(java.io.DataInputStream) CrcInputStream(com.github.ambry.utils.CrcInputStream) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream)

Aggregations

GetBlobOptionsBuilder (com.github.ambry.router.GetBlobOptionsBuilder)11 GetBlobResult (com.github.ambry.router.GetBlobResult)6 RouterException (com.github.ambry.router.RouterException)4 ExecutionException (java.util.concurrent.ExecutionException)3 BlobId (com.github.ambry.commons.BlobId)2 ByteBufferReadableStreamChannel (com.github.ambry.commons.ByteBufferReadableStreamChannel)2 RestResponseChannel (com.github.ambry.rest.RestResponseChannel)2 ReadableStreamChannel (com.github.ambry.router.ReadableStreamChannel)2 IOException (java.io.IOException)2 Histogram (com.codahale.metrics.Histogram)1 AccountService (com.github.ambry.account.AccountService)1 AccountStatsStore (com.github.ambry.accountstats.AccountStatsStore)1 ClusterMap (com.github.ambry.clustermap.ClusterMap)1 Callback (com.github.ambry.commons.Callback)1 ReadableStreamChannelInputStream (com.github.ambry.commons.ReadableStreamChannelInputStream)1 RetainingAsyncWritableChannel (com.github.ambry.commons.RetainingAsyncWritableChannel)1 FrontendConfig (com.github.ambry.config.FrontendConfig)1 BlobInfo (com.github.ambry.messageformat.BlobInfo)1 PutMessageFormatInputStream (com.github.ambry.messageformat.PutMessageFormatInputStream)1 NamedBlobDb (com.github.ambry.named.NamedBlobDb)1