@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; }
protected static void copyBlobStoreKeys(BlobStore bsFrom, Subject whoFrom, BlobStore bsTo, Subject whoTo) throws AuthorizationException, KeyAlreadyExistsException, IOException, KeyNotFoundException { Iterable<String> lfsKeys = () -> bsFrom.listKeys(); for(String key : lfsKeys) { ReadableBlobMeta readable_meta = bsFrom.getBlobMeta(key, whoFrom); SettableBlobMeta meta = readable_meta.get_settable(); InputStream in = bsFrom.getBlob(key, whoFrom); System.out.println("COPYING BLOB " + key + " FROM " + bsFrom + " TO " + bsTo); bsTo.createBlob(key, in, meta, whoTo); System.out.println("DONE CREATING BLOB " + key); } }
public java.lang.Object getFieldValue(_Fields field) { switch (field) { case SETTABLE: return get_settable(); case VERSION: return get_version(); } throw new java.lang.IllegalStateException(); }
public void setFieldValue(_Fields field, java.lang.Object value) { switch (field) { case SETTABLE: if (value == null) { unset_settable(); } else { set_settable((SettableBlobMeta)value); } break; case VERSION: if (value == null) { unset_version(); } else { set_version((java.lang.Long)value); } break; } }
/** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ public boolean isSet(_Fields field) { if (field == null) { throw new java.lang.IllegalArgumentException(); } switch (field) { case SETTABLE: return is_set_settable(); case VERSION: return is_set_version(); } throw new java.lang.IllegalStateException(); }
@Override public ReadableBlobMeta getBlobMeta(String key) throws AuthorizationException, KeyNotFoundException { ReadableBlobMeta reableMeta = null; if (allBlobs.containsKey(key)) { reableMeta = new ReadableBlobMeta(); reableMeta.set_settable(allBlobs.get(key)); } return reableMeta; }
public ReadableBlobMeta deepCopy() { return new ReadableBlobMeta(this); }
public void validate() throws org.apache.storm.thrift.TException { // check for required fields if (!is_set_settable()) { throw new org.apache.storm.thrift.protocol.TProtocolException("Required field 'settable' is unset! Struct:" + toString()); } if (!is_set_version()) { throw new org.apache.storm.thrift.protocol.TProtocolException("Required field 'version' is unset! Struct:" + toString()); } // check for sub-struct validity if (settable != null) { settable.validate(); } }
public static long nimbusVersionOfBlob(String key, ClientBlobStore cb) throws AuthorizationException, KeyNotFoundException { long nimbusBlobVersion = 0; ReadableBlobMeta metadata = cb.getBlobMeta(key); nimbusBlobVersion = metadata.get_version(); return nimbusBlobVersion; }
public boolean equals(ReadableBlobMeta that) { if (that == null) return false; if (this == that) return true; boolean this_present_settable = true && this.is_set_settable(); boolean that_present_settable = true && that.is_set_settable(); if (this_present_settable || that_present_settable) { if (!(this_present_settable && that_present_settable)) return false; if (!this.settable.equals(that.settable)) return false; } boolean this_present_version = true; boolean that_present_version = true; if (this_present_version || that_present_version) { if (!(this_present_version && that_present_version)) return false; if (this.version != that.version) return false; } return true; }
@Override public boolean equals(java.lang.Object that) { if (that == null) return false; if (that instanceof ReadableBlobMeta) return this.equals((ReadableBlobMeta)that); return false; }
@Test(expected = AuthorizationException.class) public void testFailAcls() throws Exception { Map<String, Object> conf = new HashMap(); // set clean time really high so doesn't kick in conf.put(DaemonConfig.SUPERVISOR_LOCALIZER_CACHE_CLEANUP_INTERVAL_MS, 60 * 60 * 1000); // enable blobstore acl validation conf.put(Config.STORM_BLOBSTORE_ACL_VALIDATION_ENABLED, true); String topo1 = "topo1"; String key1 = "key1"; TestLocalizer 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(1)); File user1Dir = localizer.getLocalUserFileCacheDir(user1); assertTrue("failed to create user dir", user1Dir.mkdirs()); LocalAssignment topo1Assignment = new LocalAssignment(topo1, Collections.emptyList()); topo1Assignment.set_owner(user1); PortAndAssignment topo1Pna = new PortAndAssignmentImpl(1, topo1Assignment); // This should throw AuthorizationException because auth failed localizer.getBlob(new LocalResource(key1, false, false), topo1Pna, null); }
public void setFieldValue(_Fields field, Object value) { switch (field) { case SETTABLE: if (value == null) { unset_settable(); } else { set_settable((SettableBlobMeta)value); } break; case VERSION: if (value == null) { unset_version(); } else { set_version((Long)value); } break; } }
when(mockBlobStore.getBlobMeta(contains(expectedBlobKeyForArtifact))).thenReturn(new ReadableBlobMeta());
public void validate() throws org.apache.thrift.TException { // check for required fields if (!is_set_settable()) { throw new org.apache.thrift.protocol.TProtocolException("Required field 'settable' is unset! Struct:" + toString()); } if (!is_set_version()) { throw new org.apache.thrift.protocol.TProtocolException("Required field 'version' is unset! Struct:" + toString()); } // check for sub-struct validity if (settable != null) { settable.validate(); } }
@Override public int compareTo(ReadableBlobMeta other) { if (!getClass().equals(other.getClass())) { return getClass().getName().compareTo(other.getClass().getName()); } int lastComparison = 0; lastComparison = java.lang.Boolean.valueOf(is_set_settable()).compareTo(other.is_set_settable()); if (lastComparison != 0) { return lastComparison; } if (is_set_settable()) { lastComparison = org.apache.storm.thrift.TBaseHelper.compareTo(this.settable, other.settable); if (lastComparison != 0) { return lastComparison; } } lastComparison = java.lang.Boolean.valueOf(is_set_version()).compareTo(other.is_set_version()); if (lastComparison != 0) { return lastComparison; } if (is_set_version()) { lastComparison = org.apache.storm.thrift.TBaseHelper.compareTo(this.version, other.version); if (lastComparison != 0) { return lastComparison; } } return 0; }
@Override public long getRemoteVersion(ClientBlobStore store) throws KeyNotFoundException, AuthorizationException { if (isLocalMode && type == TopologyBlobType.TOPO_JAR) { LOG.debug("REMOTE VERSION LOCAL JAR {}", LOCAL_MODE_JAR_VERSION); return LOCAL_MODE_JAR_VERSION; } return store.getBlobMeta(type.getKey(topologyId)).get_version(); }
@Override public int hashCode() { int hashCode = 1; hashCode = hashCode * 8191 + ((is_set_settable()) ? 131071 : 524287); if (is_set_settable()) hashCode = hashCode * 8191 + settable.hashCode(); hashCode = hashCode * 8191 + org.apache.storm.thrift.TBaseHelper.hashCode(version); return hashCode; }
@Override public boolean equals(Object that) { if (that == null) return false; if (that instanceof ReadableBlobMeta) return this.equals((ReadableBlobMeta)that); return false; }
@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; }