Search in sources :

Example 11 with SettableBlobMeta

use of org.apache.storm.generated.SettableBlobMeta in project storm by apache.

the class LocalFsBlobStore method getBlobMeta.

@Override
public ReadableBlobMeta getBlobMeta(String key, Subject who) throws AuthorizationException, KeyNotFoundException {
    validateKey(key);
    if (!checkForBlobOrDownload(key)) {
        checkForBlobUpdate(key);
    }
    SettableBlobMeta meta = getStoredBlobMeta(key);
    _aclHandler.validateUserCanReadMeta(meta.get_acl(), who, key);
    ReadableBlobMeta rbm = new ReadableBlobMeta();
    rbm.set_settable(meta);
    try {
        LocalFsBlobStoreFile pf = fbs.read(DATA_PREFIX + key);
        rbm.set_version(pf.getModTime());
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
    return rbm;
}
Also used : ReadableBlobMeta(org.apache.storm.generated.ReadableBlobMeta) IOException(java.io.IOException) SettableBlobMeta(org.apache.storm.generated.SettableBlobMeta)

Example 12 with SettableBlobMeta

use of org.apache.storm.generated.SettableBlobMeta in project storm by apache.

the class LocalFsBlobStore method getBlob.

@Override
public InputStreamWithMeta getBlob(String key, Subject who) throws AuthorizationException, KeyNotFoundException {
    validateKey(key);
    if (!checkForBlobOrDownload(key)) {
        checkForBlobUpdate(key);
    }
    SettableBlobMeta meta = getStoredBlobMeta(key);
    _aclHandler.hasPermissions(meta.get_acl(), READ, who, key);
    try {
        return new BlobStoreFileInputStream(fbs.read(DATA_PREFIX + key));
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}
Also used : IOException(java.io.IOException) SettableBlobMeta(org.apache.storm.generated.SettableBlobMeta)

Example 13 with SettableBlobMeta

use of org.apache.storm.generated.SettableBlobMeta in project storm by apache.

the class LocalFsBlobStore method deleteBlob.

@Override
public void deleteBlob(String key, Subject who) throws AuthorizationException, KeyNotFoundException {
    validateKey(key);
    checkForBlobOrDownload(key);
    SettableBlobMeta meta = getStoredBlobMeta(key);
    _aclHandler.hasPermissions(meta.get_acl(), WRITE, who, key);
    try {
        fbs.deleteKey(DATA_PREFIX + key);
        fbs.deleteKey(META_PREFIX + key);
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}
Also used : IOException(java.io.IOException) SettableBlobMeta(org.apache.storm.generated.SettableBlobMeta)

Example 14 with SettableBlobMeta

use of org.apache.storm.generated.SettableBlobMeta in project storm by apache.

the class Nimbus method setupStormCode.

private void setupStormCode(Map<String, Object> conf, String topoId, String tmpJarLocation, Map<String, Object> topoConf, StormTopology topology) throws Exception {
    Subject subject = getSubject();
    IStormClusterState clusterState = stormClusterState;
    BlobStore store = blobStore;
    String jarKey = ConfigUtils.masterStormJarKey(topoId);
    String codeKey = ConfigUtils.masterStormCodeKey(topoId);
    String confKey = ConfigUtils.masterStormConfKey(topoId);
    NimbusInfo hostPortInfo = nimbusHostPortInfo;
    if (tmpJarLocation != null) {
        //in local mode there is no jar
        try (FileInputStream fin = new FileInputStream(tmpJarLocation)) {
            store.createBlob(jarKey, fin, new SettableBlobMeta(BlobStoreAclHandler.DEFAULT), subject);
        }
        if (store instanceof LocalFsBlobStore) {
            clusterState.setupBlobstore(jarKey, hostPortInfo, getVersionForKey(jarKey, hostPortInfo, conf));
        }
    }
    store.createBlob(confKey, Utils.toCompressedJsonConf(topoConf), new SettableBlobMeta(BlobStoreAclHandler.DEFAULT), subject);
    if (store instanceof LocalFsBlobStore) {
        clusterState.setupBlobstore(confKey, hostPortInfo, getVersionForKey(confKey, hostPortInfo, conf));
    }
    store.createBlob(codeKey, Utils.serialize(topology), new SettableBlobMeta(BlobStoreAclHandler.DEFAULT), subject);
    if (store instanceof LocalFsBlobStore) {
        clusterState.setupBlobstore(codeKey, hostPortInfo, getVersionForKey(codeKey, hostPortInfo, conf));
    }
}
Also used : LocalFsBlobStore(org.apache.storm.blobstore.LocalFsBlobStore) IStormClusterState(org.apache.storm.cluster.IStormClusterState) SettableBlobMeta(org.apache.storm.generated.SettableBlobMeta) Subject(javax.security.auth.Subject) BlobStore(org.apache.storm.blobstore.BlobStore) LocalFsBlobStore(org.apache.storm.blobstore.LocalFsBlobStore) FileInputStream(java.io.FileInputStream) NimbusInfo(org.apache.storm.nimbus.NimbusInfo)

Example 15 with SettableBlobMeta

use of org.apache.storm.generated.SettableBlobMeta in project storm by apache.

the class Blobstore method setAclCli.

private static void setAclCli(String[] args) throws Exception {
    Map<String, Object> cl = CLI.opt("s", "set", Collections.emptyList(), new AsAclParser()).arg("key", CLI.FIRST_WINS).parse(args);
    final String key = (String) cl.get("key");
    final List<AccessControl> setAcl = (List<AccessControl>) cl.get("s");
    ClientBlobStore.withConfiguredClient(new ClientBlobStore.WithBlobstore() {

        @Override
        public void run(ClientBlobStore blobStore) throws Exception {
            ReadableBlobMeta meta = blobStore.getBlobMeta(key);
            List<AccessControl> acl = meta.get_settable().get_acl();
            List<AccessControl> newAcl;
            if (setAcl != null && !setAcl.isEmpty()) {
                newAcl = setAcl;
            } else {
                newAcl = acl;
            }
            SettableBlobMeta newMeta = new SettableBlobMeta(newAcl);
            LOG.info("Setting ACL for {} to {}", key, generateAccessControlsInfo(newAcl));
            blobStore.setBlobMeta(key, newMeta);
        }
    });
}
Also used : ClientBlobStore(org.apache.storm.blobstore.ClientBlobStore) ReadableBlobMeta(org.apache.storm.generated.ReadableBlobMeta) AccessControl(org.apache.storm.generated.AccessControl) IOException(java.io.IOException) AuthorizationException(org.apache.storm.generated.AuthorizationException) KeyNotFoundException(org.apache.storm.generated.KeyNotFoundException) ArrayList(java.util.ArrayList) List(java.util.List) SettableBlobMeta(org.apache.storm.generated.SettableBlobMeta)

Aggregations

SettableBlobMeta (org.apache.storm.generated.SettableBlobMeta)38 IOException (java.io.IOException)16 Test (org.junit.Test)12 ReadableBlobMeta (org.apache.storm.generated.ReadableBlobMeta)10 AccessControl (org.apache.storm.generated.AccessControl)8 File (java.io.File)6 AtomicOutputStream (org.apache.storm.blobstore.AtomicOutputStream)5 Subject (javax.security.auth.Subject)4 BlobStoreFile (org.apache.storm.blobstore.BlobStoreFile)4 FileInputStream (java.io.FileInputStream)3 OutputStream (java.io.OutputStream)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 List (java.util.List)2 Map (java.util.Map)2 FileSystem (org.apache.hadoop.fs.FileSystem)2 BufferedInputStream (java.io.BufferedInputStream)1 LinkedList (java.util.LinkedList)1 Path (org.apache.hadoop.fs.Path)1 BlobStore (org.apache.storm.blobstore.BlobStore)1