use of com.alibaba.jstorm.blobstore.AtomicOutputStream in project jstorm by alibaba.
the class ServiceHandler method cancelBlobUpload.
@Override
public void cancelBlobUpload(String session) throws TException {
AtomicOutputStream os = (AtomicOutputStream) data.getBlobUploaders().get(session);
if (os == null) {
throw new TException("Blob for session " + session + " does not exist (or timed out)");
}
try {
os.cancel();
} catch (IOException e) {
LOG.error("AtomicOutputStream cancel failed when finishBlobUpload for session {}", session);
}
LOG.info("Canceling uploading blob for session {}. Closing session.", session);
data.getBlobUploaders().remove(session);
}
use of com.alibaba.jstorm.blobstore.AtomicOutputStream in project jstorm by alibaba.
the class ServiceHandler method beginCreateBlob.
@Override
public String beginCreateBlob(String blobKey, SettableBlobMeta meta) throws KeyAlreadyExistsException {
String sessionId = UUID.randomUUID().toString();
AtomicOutputStream out = data.getBlobStore().createBlob(blobKey, meta);
data.getBlobUploaders().put(sessionId, out);
LOG.info("Created blob for {} with session id {}", blobKey, sessionId);
return sessionId;
}
use of com.alibaba.jstorm.blobstore.AtomicOutputStream in project jstorm by alibaba.
the class ServiceHandler method finishBlobUpload.
@Override
public void finishBlobUpload(String session) throws TException {
AtomicOutputStream os = (AtomicOutputStream) data.getBlobUploaders().get(session);
if (os == null) {
throw new TException("Blob for session " + session + " does not exist (or timed out)");
}
try {
os.close();
} catch (IOException e) {
LOG.error("AtomicOutputStream close failed when finishBlobUpload for session {}", session);
}
LOG.info("Finished uploading blob for session {}. Closing session.", session);
data.getBlobUploaders().remove(session);
}
use of com.alibaba.jstorm.blobstore.AtomicOutputStream in project jstorm by alibaba.
the class ServiceHandler method uploadBlobChunk.
@Override
public void uploadBlobChunk(String session, ByteBuffer chunk) throws TException {
AtomicOutputStream os = (AtomicOutputStream) data.getBlobUploaders().get(session);
if (os == null) {
throw new TException("Blob for session " + session + " does not exist (or timed out)");
}
byte[] chunkArray = chunk.array();
int remaining = chunk.remaining();
int arrayOffset = chunk.arrayOffset();
int position = chunk.position();
try {
os.write(chunkArray, (arrayOffset + position), remaining);
data.getBlobUploaders().put(session, os);
} catch (IOException e) {
LOG.error("Blob upload failed", e);
throw new TException(e);
}
}
use of com.alibaba.jstorm.blobstore.AtomicOutputStream in project jstorm by alibaba.
the class StormConfig method write_nimbus_topology_code.
public static void write_nimbus_topology_code(String topologyId, byte[] data, NimbusData nimbusData) throws Exception {
String codeKey = master_stormcode_key(topologyId);
AtomicOutputStream out = nimbusData.getBlobStore().updateBlob(codeKey);
out.write(data);
out.close();
if (nimbusData.getBlobStore() instanceof LocalFsBlobStore) {
NimbusInfo nimbusInfo = nimbusData.getNimbusHostPortInfo();
int versionForKey = BlobStoreUtils.getVersionForKey(codeKey, nimbusInfo, nimbusData.getConf());
nimbusData.getStormClusterState().setup_blobstore(codeKey, nimbusInfo, versionForKey);
}
}
Aggregations