@Test public void testGetXAttrSize() throws Exception { metadataCache.updateXAttrs("foobar", getDummyXattrs()); metadataCache.updateXAttr("foobar", "aNewXattr", "0123456789"); Tupel<Integer, Boolean> tupel = metadataCache.getXAttrSize("foobar", "aNewXattr"); assertEquals(10, tupel.getFirst().intValue()); assertTrue(tupel.getSecond()); }
protected Tupel<Integer, Boolean> getXAttrSize(String path, String name) { boolean xattrCached = false; writeLock.lock(); try { MetadataCacheEntry entry = cache.get(path); long currentTimeS = System.currentTimeMillis() / 1000; if (entry != null && entry.getXattrs() != null) { if (entry.getXattrTimeoutS() >= currentTimeS) { xattrCached = true; for (XAttr xattr : entry.getXattrs().getXattrsList()) { if (xattr.getName().equals(name)) { if (Logging.isDebug()) { Logging.logMessage(Logging.LEVEL_DEBUG, Category.misc, this, "MetadataCache getXattrSize() hit: %s [%s]", path, cache.size()); } return new Tupel<Integer, Boolean>(xattr.getValue().length(), xattrCached); } } } else { if (Logging.isDebug()) { Logging.logMessage(Logging.LEVEL_DEBUG, Category.misc, this, "MetadataCache getXattrSize() expired: %s", path); } if (entry.getTimeoutS() < currentTimeS) { cache.remove(path); pathIndex.remove(path); } } } } finally { writeLock.unlock(); } if (Logging.isDebug()) { Logging.logMessage(Logging.LEVEL_DEBUG, Category.misc, this, "MetadataCache getXattrSize() miss: %s [%s]", path, cache.size()); } return new Tupel<Integer, Boolean>(0, xattrCached); }
MetadataCache { protected Tupel<Integer, Boolean> getXAttrSize(String path, String name) { boolean xattrCached = false; writeLock.lock(); try { MetadataCacheEntry entry = cache.get(path); long currentTimeS = System.currentTimeMillis() / 1000; if (entry != null && entry.getXattrs() != null) { if (entry.getXattrTimeoutS() >= currentTimeS) { xattrCached = true; for (XAttr xattr : entry.getXattrs().getXattrsList()) { if (xattr.getName().equals(name)) { if (Logging.isDebug()) { Logging.logMessage(Logging.LEVEL_DEBUG, Category.misc, this, "MetadataCache getXattrSize() hit: %s [%s]", path, cache.size()); } return new Tupel<Integer, Boolean>(xattr.getValue().length(), xattrCached); } } } else { if (Logging.isDebug()) { Logging.logMessage(Logging.LEVEL_DEBUG, Category.misc, this, "MetadataCache getXattrSize() expired: %s", path); } if (entry.getTimeoutS() < currentTimeS) { cache.remove(path); pathIndex.remove(path); } } } } finally { writeLock.unlock(); } if (Logging.isDebug()) { Logging.logMessage(Logging.LEVEL_DEBUG, Category.misc, this, "MetadataCache getXattrSize() miss: %s [%s]", path, cache.size()); } return new Tupel<Integer, Boolean>(0, xattrCached); } }
MetadataCache { protected Tupel<Integer, Boolean> getXAttrSize(String path, String name) { boolean xattrCached = false; writeLock.lock(); try { MetadataCacheEntry entry = cache.get(path); long currentTimeS = System.currentTimeMillis() / 1000; if (entry != null && entry.getXattrs() != null) { if (entry.getXattrTimeoutS() >= currentTimeS) { xattrCached = true; for (XAttr xattr : entry.getXattrs().getXattrsList()) { if (xattr.getName().equals(name)) { if (Logging.isDebug()) { Logging.logMessage(Logging.LEVEL_DEBUG, Category.misc, this, "MetadataCache getXattrSize() hit: %s [%s]", path, cache.size()); } return new Tupel<Integer, Boolean>(xattr.getValue().length(), xattrCached); } } } else { if (Logging.isDebug()) { Logging.logMessage(Logging.LEVEL_DEBUG, Category.misc, this, "MetadataCache getXattrSize() expired: %s", path); } if (entry.getTimeoutS() < currentTimeS) { cache.remove(path); pathIndex.remove(path); } } } } finally { writeLock.unlock(); } if (Logging.isDebug()) { Logging.logMessage(Logging.LEVEL_DEBUG, Category.misc, this, "MetadataCache getXattrSize() miss: %s [%s]", path, cache.size()); } return new Tupel<Integer, Boolean>(0, xattrCached); } protected  MetadataCache(long maxNumberOfEntries, long ttlS); }
MetadataCache { protected Tupel<Integer, Boolean> getXAttrSize(String path, String name) { boolean xattrCached = false; writeLock.lock(); try { MetadataCacheEntry entry = cache.get(path); long currentTimeS = System.currentTimeMillis() / 1000; if (entry != null && entry.getXattrs() != null) { if (entry.getXattrTimeoutS() >= currentTimeS) { xattrCached = true; for (XAttr xattr : entry.getXattrs().getXattrsList()) { if (xattr.getName().equals(name)) { if (Logging.isDebug()) { Logging.logMessage(Logging.LEVEL_DEBUG, Category.misc, this, "MetadataCache getXattrSize() hit: %s [%s]", path, cache.size()); } return new Tupel<Integer, Boolean>(xattr.getValue().length(), xattrCached); } } } else { if (Logging.isDebug()) { Logging.logMessage(Logging.LEVEL_DEBUG, Category.misc, this, "MetadataCache getXattrSize() expired: %s", path); } if (entry.getTimeoutS() < currentTimeS) { cache.remove(path); pathIndex.remove(path); } } } } finally { writeLock.unlock(); } if (Logging.isDebug()) { Logging.logMessage(Logging.LEVEL_DEBUG, Category.misc, this, "MetadataCache getXattrSize() miss: %s [%s]", path, cache.size()); } return new Tupel<Integer, Boolean>(0, xattrCached); } protected  MetadataCache(long maxNumberOfEntries, long ttlS);  }
MetadataCache { protected Tupel<Integer, Boolean> getXAttrSize(String path, String name) { boolean xattrCached = false; writeLock.lock(); try { MetadataCacheEntry entry = cache.get(path); long currentTimeS = System.currentTimeMillis() / 1000; if (entry != null && entry.getXattrs() != null) { if (entry.getXattrTimeoutS() >= currentTimeS) { xattrCached = true; for (XAttr xattr : entry.getXattrs().getXattrsList()) { if (xattr.getName().equals(name)) { if (Logging.isDebug()) { Logging.logMessage(Logging.LEVEL_DEBUG, Category.misc, this, "MetadataCache getXattrSize() hit: %s [%s]", path, cache.size()); } return new Tupel<Integer, Boolean>(xattr.getValue().length(), xattrCached); } } } else { if (Logging.isDebug()) { Logging.logMessage(Logging.LEVEL_DEBUG, Category.misc, this, "MetadataCache getXattrSize() expired: %s", path); } if (entry.getTimeoutS() < currentTimeS) { cache.remove(path); pathIndex.remove(path); } } } } finally { writeLock.unlock(); } if (Logging.isDebug()) { Logging.logMessage(Logging.LEVEL_DEBUG, Category.misc, this, "MetadataCache getXattrSize() miss: %s [%s]", path, cache.size()); } return new Tupel<Integer, Boolean>(0, xattrCached); } protected  MetadataCache(long maxNumberOfEntries, long ttlS);   }