Search in sources :

Example 1 with BeginDownloadResult

use of backtype.storm.generated.BeginDownloadResult in project jstorm by alibaba.

the class ServiceHandler method beginBlobDownload.

@Override
public BeginDownloadResult beginBlobDownload(String key) throws TException {
    InputStreamWithMeta is = data.getBlobStore().getBlob(key);
    String sessionId = UUID.randomUUID().toString();
    BeginDownloadResult result = null;
    try {
        result = new BeginDownloadResult(is.getVersion(), sessionId);
        result.set_data_size(is.getFileLength());
        int bufferSize = JStormUtils.parseInt(data.getConf().get(Config.STORM_BLOBSTORE_INPUTSTREAM_BUFFER_SIZE_BYTES), 65536);
        BufferInputStream bufferedIS = new BufferInputStream(is, bufferSize);
        data.getBlobDownloaders().put(sessionId, bufferedIS);
    } catch (IOException e) {
        LOG.error("beginBlobDownload error", e);
        throw new TException(e);
    }
    return result;
}
Also used : BufferInputStream(backtype.storm.utils.BufferInputStream) TException(org.apache.thrift.TException) InputStreamWithMeta(com.alibaba.jstorm.blobstore.InputStreamWithMeta) BeginDownloadResult(backtype.storm.generated.BeginDownloadResult) IOException(java.io.IOException)

Aggregations

BeginDownloadResult (backtype.storm.generated.BeginDownloadResult)1 BufferInputStream (backtype.storm.utils.BufferInputStream)1 InputStreamWithMeta (com.alibaba.jstorm.blobstore.InputStreamWithMeta)1 IOException (java.io.IOException)1 TException (org.apache.thrift.TException)1