Search in sources :

Example 6 with SettableBlobMeta

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

the class ClientBlobStoreTest method validatedBlobAcls.

private void validatedBlobAcls(String testKey) throws KeyNotFoundException, AuthorizationException {
    ReadableBlobMeta blobMeta = client.getBlobMeta(testKey);
    Assert.assertNotNull("The blob" + testKey + "does not have any readable blobMeta.", blobMeta);
    SettableBlobMeta settableBlob = blobMeta.get_settable();
    Assert.assertNotNull("The blob" + testKey + "does not have any settable blobMeta.", settableBlob);
}
Also used : ReadableBlobMeta(org.apache.storm.generated.ReadableBlobMeta) SettableBlobMeta(org.apache.storm.generated.SettableBlobMeta)

Example 7 with SettableBlobMeta

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

the class ClientBlobStoreTest method testDuplicateACLsForCreate.

@Test(expected = AuthorizationException.class)
public void testDuplicateACLsForCreate() throws Exception {
    SettableBlobMeta meta = new SettableBlobMeta();
    AccessControl submitterAcl = BlobStoreAclHandler.parseAccessControl("u:tester:rwa");
    meta.add_to_acl(submitterAcl);
    AccessControl duplicateAcl = BlobStoreAclHandler.parseAccessControl("u:tester:r--");
    meta.add_to_acl(duplicateAcl);
    String testKey = "testDuplicateACLsBlobKey";
    client.createBlob(testKey, meta);
}
Also used : SettableBlobMeta(org.apache.storm.generated.SettableBlobMeta) AccessControl(org.apache.storm.generated.AccessControl) Test(org.junit.Test)

Example 8 with SettableBlobMeta

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

the class BlobStoreAPIWordCountTopology method createBlobWithContent.

// Equivalent create command on command line
// storm blobstore create --file blacklist.txt --acl o::rwa key
private static void createBlobWithContent(String blobKey, ClientBlobStore clientBlobStore, File file) throws AuthorizationException, KeyAlreadyExistsException, IOException, KeyNotFoundException {
    String stringBlobACL = "o::rwa";
    AccessControl blobACL = BlobStoreAclHandler.parseAccessControl(stringBlobACL);
    List<AccessControl> acls = new LinkedList<AccessControl>();
    // more ACLs can be added here
    acls.add(blobACL);
    SettableBlobMeta settableBlobMeta = new SettableBlobMeta(acls);
    AtomicOutputStream blobStream = clientBlobStore.createBlob(blobKey, settableBlobMeta);
    blobStream.write(readFile(file).toString().getBytes());
    blobStream.close();
}
Also used : AtomicOutputStream(org.apache.storm.blobstore.AtomicOutputStream) SettableBlobMeta(org.apache.storm.generated.SettableBlobMeta) AccessControl(org.apache.storm.generated.AccessControl) LinkedList(java.util.LinkedList)

Example 9 with SettableBlobMeta

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

the class HdfsBlobStore method setBlobMeta.

@Override
public void setBlobMeta(String key, SettableBlobMeta meta, Subject who) throws AuthorizationException, KeyNotFoundException {
    if (meta.get_replication_factor() <= 0) {
        meta.set_replication_factor((int) conf.get(Config.STORM_BLOBSTORE_REPLICATION_FACTOR));
    }
    who = checkAndGetSubject(who);
    validateKey(key);
    _aclHandler.normalizeSettableBlobMeta(key, meta, who, ADMIN);
    BlobStoreAclHandler.validateSettableACLs(key, meta.get_acl());
    SettableBlobMeta orig = getStoredBlobMeta(key);
    _aclHandler.hasPermissions(orig.get_acl(), ADMIN, who, key);
    BlobStoreFileOutputStream mOut = null;
    writeMetadata(key, meta);
}
Also used : SettableBlobMeta(org.apache.storm.generated.SettableBlobMeta)

Example 10 with SettableBlobMeta

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

the class HdfsBlobStore method getBlobReplication.

@Override
public int getBlobReplication(String key, Subject who) throws AuthorizationException, KeyNotFoundException {
    who = checkAndGetSubject(who);
    validateKey(key);
    SettableBlobMeta meta = getStoredBlobMeta(key);
    _aclHandler.hasAnyPermissions(meta.get_acl(), READ | WRITE | ADMIN, who, key);
    try {
        return _hbs.getBlobReplication(DATA_PREFIX + key);
    } catch (IOException exp) {
        throw new RuntimeException(exp);
    }
}
Also used : IOException(java.io.IOException) 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