Search in sources :

Example 21 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 22 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 23 with SettableBlobMeta

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

the class LocalizerTest method testFailAcls.

@Test(expected = AuthorizationException.class)
public void testFailAcls() throws Exception {
    Map conf = new HashMap();
    // set clean time really high so doesn't kick in
    conf.put(Config.SUPERVISOR_LOCALIZER_CACHE_CLEANUP_INTERVAL_MS, 60 * 60 * 1000);
    String topo1 = "topo1";
    String key1 = "key1";
    Localizer localizer = new TestLocalizer(conf, baseDir.toString());
    ReadableBlobMeta rbm = new ReadableBlobMeta();
    // set acl so user doesn't have read access
    AccessControl acl = new AccessControl(AccessControlType.USER, BlobStoreAclHandler.ADMIN);
    acl.set_name(user1);
    rbm.set_settable(new SettableBlobMeta(Arrays.asList(acl)));
    when(mockblobstore.getBlobMeta(anyString())).thenReturn(rbm);
    when(mockblobstore.getBlob(key1)).thenReturn(new TestInputStreamWithMeta());
    File user1Dir = localizer.getLocalUserFileCacheDir(user1);
    assertTrue("failed to create user dir", user1Dir.mkdirs());
    // This should throw AuthorizationException because auth failed
    localizer.getBlob(new LocalResource(key1, false), user1, topo1, user1Dir);
}
Also used : ReadableBlobMeta(org.apache.storm.generated.ReadableBlobMeta) SettableBlobMeta(org.apache.storm.generated.SettableBlobMeta) File(java.io.File) AccessControl(org.apache.storm.generated.AccessControl) Test(org.junit.Test)

Example 24 with SettableBlobMeta

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

the class HdfsBlobStore method updateBlob.

@Override
public AtomicOutputStream updateBlob(String key, Subject who) throws AuthorizationException, KeyNotFoundException {
    who = checkAndGetSubject(who);
    SettableBlobMeta meta = getStoredBlobMeta(key);
    validateKey(key);
    _aclHandler.hasPermissions(meta.get_acl(), WRITE, who, key);
    try {
        BlobStoreFile dataFile = _hbs.write(DATA_PREFIX + key, false);
        dataFile.setMetadata(meta);
        return new BlobStoreFileOutputStream(dataFile);
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}
Also used : BlobStoreFile(org.apache.storm.blobstore.BlobStoreFile) IOException(java.io.IOException) SettableBlobMeta(org.apache.storm.generated.SettableBlobMeta)

Example 25 with SettableBlobMeta

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

the class HdfsBlobStore method getBlobMeta.

@Override
public ReadableBlobMeta getBlobMeta(String key, Subject who) throws AuthorizationException, KeyNotFoundException {
    who = checkAndGetSubject(who);
    validateKey(key);
    SettableBlobMeta meta = getStoredBlobMeta(key);
    _aclHandler.validateUserCanReadMeta(meta.get_acl(), who, key);
    ReadableBlobMeta rbm = new ReadableBlobMeta();
    rbm.set_settable(meta);
    try {
        BlobStoreFile pf = _hbs.read(DATA_PREFIX + key);
        rbm.set_version(pf.getModTime());
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
    return rbm;
}
Also used : BlobStoreFile(org.apache.storm.blobstore.BlobStoreFile) ReadableBlobMeta(org.apache.storm.generated.ReadableBlobMeta) 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