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;
}
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);
}
}
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);
}
}
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));
}
}
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);
}
});
}
Aggregations