Search in sources :

Example 6 with AtomicOutputStream

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);
}
Also used : BufferInputStream(backtype.storm.utils.BufferInputStream) ExpiredCallback(com.alibaba.jstorm.utils.ExpiredCallback) AtomicOutputStream(com.alibaba.jstorm.blobstore.AtomicOutputStream) IOException(java.io.IOException)

Example 7 with AtomicOutputStream

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);
    }
}
Also used : LocalFsBlobStore(com.alibaba.jstorm.blobstore.LocalFsBlobStore) AtomicOutputStream(com.alibaba.jstorm.blobstore.AtomicOutputStream) NimbusInfo(backtype.storm.nimbus.NimbusInfo)

Example 8 with AtomicOutputStream

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;
}
Also used : AtomicOutputStream(com.alibaba.jstorm.blobstore.AtomicOutputStream)

Aggregations

AtomicOutputStream (com.alibaba.jstorm.blobstore.AtomicOutputStream)8 IOException (java.io.IOException)4 TException (org.apache.thrift.TException)3 NimbusInfo (backtype.storm.nimbus.NimbusInfo)2 LocalFsBlobStore (com.alibaba.jstorm.blobstore.LocalFsBlobStore)2 BufferInputStream (backtype.storm.utils.BufferInputStream)1 ExpiredCallback (com.alibaba.jstorm.utils.ExpiredCallback)1