use of com.alibaba.jstorm.blobstore.AtomicOutputStream in project jstorm by alibaba.
the class NimbusData method mkBlobCacheMap.
public void mkBlobCacheMap() {
ExpiredCallback<Object, Object> expiredCallback = new ExpiredCallback<Object, Object>() {
@Override
public void expire(Object key, Object val) {
try {
LOG.debug("Close blob file " + String.valueOf(key));
if (val != null) {
if (val instanceof AtomicOutputStream) {
AtomicOutputStream stream = (AtomicOutputStream) val;
stream.cancel();
stream.close();
} else if (val instanceof BufferInputStream) {
BufferInputStream is = (BufferInputStream) val;
is.close();
}
}
} catch (IOException e) {
LOG.error(e.getMessage(), e);
}
}
};
int expiration_secs = JStormUtils.parseInt(conf.get(Config.NIMBUS_FILE_COPY_EXPIRATION_SECS), 30);
blobUploaders = new TimeCacheMap<Object, Object>(expiration_secs, expiredCallback);
blobDownloaders = new TimeCacheMap<Object, Object>(expiration_secs, expiredCallback);
blobListers = new TimeCacheMap<Object, Object>(expiration_secs, null);
}
use of com.alibaba.jstorm.blobstore.AtomicOutputStream in project jstorm by alibaba.
the class StormConfig method write_nimbus_topology_conf.
public static void write_nimbus_topology_conf(String topologyId, Map topoConf, NimbusData data) throws Exception {
String confKey = master_stormconf_key(topologyId);
AtomicOutputStream out = data.getBlobStore().updateBlob(confKey);
out.write(Utils.serialize(topoConf));
out.close();
if (data.getBlobStore() instanceof LocalFsBlobStore) {
NimbusInfo nimbusInfo = data.getNimbusHostPortInfo();
int versionForKey = BlobStoreUtils.getVersionForKey(confKey, nimbusInfo, data.getConf());
data.getStormClusterState().setup_blobstore(confKey, nimbusInfo, versionForKey);
}
}
use of com.alibaba.jstorm.blobstore.AtomicOutputStream in project jstorm by alibaba.
the class ServiceHandler method beginUpdateBlob.
@Override
public String beginUpdateBlob(String blobKey) throws KeyNotFoundException {
String sessionId = UUID.randomUUID().toString();
AtomicOutputStream out = data.getBlobStore().updateBlob(blobKey);
data.getBlobUploaders().put(sessionId, out);
LOG.info("Created upload session for {} with id {}", blobKey, sessionId);
return sessionId;
}
Aggregations