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;
}
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));
}
}
Aggregations