Search in sources :

Example 1 with InputStreamWithMeta

use of com.alibaba.jstorm.blobstore.InputStreamWithMeta 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;
    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)

Example 2 with InputStreamWithMeta

use of com.alibaba.jstorm.blobstore.InputStreamWithMeta in project jstorm by alibaba.

the class ServiceHandler method backupBlob.

private void backupBlob(String oldKey, String newKey, String topologyId) throws Exception {
    LOG.info("Backing topology {} blob key {} to {}", topologyId, oldKey, newKey);
    StormClusterState clusterState = data.getStormClusterState();
    BlobStore blobStore = data.getBlobStore();
    NimbusInfo nimbusInfo = data.getNimbusHostPortInfo();
    InputStreamWithMeta oldStream = blobStore.getBlob(oldKey);
    BlobStoreUtils.cleanup_key(newKey, blobStore, clusterState);
    blobStore.createBlob(newKey, oldStream, new SettableBlobMeta());
    if (blobStore instanceof LocalFsBlobStore) {
        clusterState.setup_blobstore(newKey, nimbusInfo, BlobStoreUtils.getVersionForKey(newKey, nimbusInfo, conf));
    }
}
Also used : StormClusterState(com.alibaba.jstorm.cluster.StormClusterState) LocalFsBlobStore(com.alibaba.jstorm.blobstore.LocalFsBlobStore) InputStreamWithMeta(com.alibaba.jstorm.blobstore.InputStreamWithMeta) SettableBlobMeta(backtype.storm.generated.SettableBlobMeta) BlobStore(com.alibaba.jstorm.blobstore.BlobStore) LocalFsBlobStore(com.alibaba.jstorm.blobstore.LocalFsBlobStore) NimbusInfo(backtype.storm.nimbus.NimbusInfo)

Aggregations

InputStreamWithMeta (com.alibaba.jstorm.blobstore.InputStreamWithMeta)2 BeginDownloadResult (backtype.storm.generated.BeginDownloadResult)1 SettableBlobMeta (backtype.storm.generated.SettableBlobMeta)1 NimbusInfo (backtype.storm.nimbus.NimbusInfo)1 BufferInputStream (backtype.storm.utils.BufferInputStream)1 BlobStore (com.alibaba.jstorm.blobstore.BlobStore)1 LocalFsBlobStore (com.alibaba.jstorm.blobstore.LocalFsBlobStore)1 StormClusterState (com.alibaba.jstorm.cluster.StormClusterState)1 IOException (java.io.IOException)1 TException (org.apache.thrift.TException)1