@Test public void testGetNonExistingDirEntries() throws Exception { assertNull(metadataCache.getDirEntries("do not exist", 0, 100)); }
protected DirectoryEntries getDirEntries(String path, int offset, int count) { if (path.isEmpty() || !enabled) { return null; } writeLock.lock(); try { MetadataCacheEntry entry = cache.get(path); if (entry != null && entry.getDirectoryEntries() != null) { long currentTimeS = System.currentTimeMillis() / 1000; if (entry.getDirectoryEntriesTimeoutS() >= currentTimeS) { DirectoryEntries.Builder result; if (offset == 0 && count >= entry.getDirectoryEntries().getEntriesCount()) { if (Logging.isDebug()) { Logging.logMessage(Logging.LEVEL_DEBUG, Category.misc, this, "MetadataCache getDirEntries() hit: %s [%s]", path, cache.size()); } result = entry.getDirectoryEntries().toBuilder(); } else { if (Logging.isDebug()) { Logging.logMessage(Logging.LEVEL_DEBUG, Category.misc, this, "MetadataCache getDirectoryEntries() hit (partial copy): " + "%s [%s] offset: %s", path, cache.size(), offset); } result = DirectoryEntries.newBuilder(); for (int i = offset; i < offset + count; i++) { result.addEntries(entry.getDirectoryEntries().getEntries(i)); } } return result.build(); } else { if (Logging.isDebug()) { Logging.logMessage(Logging.LEVEL_DEBUG, Category.misc, this, "MetadataCache entry expired: %s", path); } if (entry.getTimeoutS() < currentTimeS) { cache.remove(path); pathIndex.remove(path); } return null; } } } finally { writeLock.unlock(); } if (Logging.isDebug()) { Logging.logMessage(Logging.LEVEL_DEBUG, Category.misc, this, "MetadataCache getDirectoryEntries() miss: %s", path); } return null; }
MetadataCache { protected DirectoryEntries getDirEntries(String path, int offset, int count) { if (path.isEmpty() || !enabled) { return null; } writeLock.lock(); try { MetadataCacheEntry entry = cache.get(path); if (entry != null && entry.getDirectoryEntries() != null) { long currentTimeS = System.currentTimeMillis() / 1000; if (entry.getDirectoryEntriesTimeoutS() >= currentTimeS) { DirectoryEntries.Builder result; if (offset == 0 && count >= entry.getDirectoryEntries().getEntriesCount()) { if (Logging.isDebug()) { Logging.logMessage(Logging.LEVEL_DEBUG, Category.misc, this, "MetadataCache getDirEntries() hit: %s [%s]", path, cache.size()); } result = entry.getDirectoryEntries().toBuilder(); } else { if (Logging.isDebug()) { Logging.logMessage(Logging.LEVEL_DEBUG, Category.misc, this, "MetadataCache getDirectoryEntries() hit (partial copy): " + "%s [%s] offset: %s", path, cache.size(), offset); } result = DirectoryEntries.newBuilder(); for (int i = offset; i < offset + count; i++) { result.addEntries(entry.getDirectoryEntries().getEntries(i)); } } return result.build(); } else { if (Logging.isDebug()) { Logging.logMessage(Logging.LEVEL_DEBUG, Category.misc, this, "MetadataCache entry expired: %s", path); } if (entry.getTimeoutS() < currentTimeS) { cache.remove(path); pathIndex.remove(path); } return null; } } } finally { writeLock.unlock(); } if (Logging.isDebug()) { Logging.logMessage(Logging.LEVEL_DEBUG, Category.misc, this, "MetadataCache getDirectoryEntries() miss: %s", path); } return null; } }
MetadataCache { protected DirectoryEntries getDirEntries(String path, int offset, int count) { if (path.isEmpty() || !enabled) { return null; } writeLock.lock(); try { MetadataCacheEntry entry = cache.get(path); if (entry != null && entry.getDirectoryEntries() != null) { long currentTimeS = System.currentTimeMillis() / 1000; if (entry.getDirectoryEntriesTimeoutS() >= currentTimeS) { DirectoryEntries.Builder result; if (offset == 0 && count >= entry.getDirectoryEntries().getEntriesCount()) { if (Logging.isDebug()) { Logging.logMessage(Logging.LEVEL_DEBUG, Category.misc, this, "MetadataCache getDirEntries() hit: %s [%s]", path, cache.size()); } result = entry.getDirectoryEntries().toBuilder(); } else { if (Logging.isDebug()) { Logging.logMessage(Logging.LEVEL_DEBUG, Category.misc, this, "MetadataCache getDirectoryEntries() hit (partial copy): " + "%s [%s] offset: %s", path, cache.size(), offset); } result = DirectoryEntries.newBuilder(); for (int i = offset; i < offset + count; i++) { result.addEntries(entry.getDirectoryEntries().getEntries(i)); } } return result.build(); } else { if (Logging.isDebug()) { Logging.logMessage(Logging.LEVEL_DEBUG, Category.misc, this, "MetadataCache entry expired: %s", path); } if (entry.getTimeoutS() < currentTimeS) { cache.remove(path); pathIndex.remove(path); } return null; } } } finally { writeLock.unlock(); } if (Logging.isDebug()) { Logging.logMessage(Logging.LEVEL_DEBUG, Category.misc, this, "MetadataCache getDirectoryEntries() miss: %s", path); } return null; } protected  MetadataCache(long maxNumberOfEntries, long ttlS); }
MetadataCache { protected DirectoryEntries getDirEntries(String path, int offset, int count) { if (path.isEmpty() || !enabled) { return null; } writeLock.lock(); try { MetadataCacheEntry entry = cache.get(path); if (entry != null && entry.getDirectoryEntries() != null) { long currentTimeS = System.currentTimeMillis() / 1000; if (entry.getDirectoryEntriesTimeoutS() >= currentTimeS) { DirectoryEntries.Builder result; if (offset == 0 && count >= entry.getDirectoryEntries().getEntriesCount()) { if (Logging.isDebug()) { Logging.logMessage(Logging.LEVEL_DEBUG, Category.misc, this, "MetadataCache getDirEntries() hit: %s [%s]", path, cache.size()); } result = entry.getDirectoryEntries().toBuilder(); } else { if (Logging.isDebug()) { Logging.logMessage(Logging.LEVEL_DEBUG, Category.misc, this, "MetadataCache getDirectoryEntries() hit (partial copy): " + "%s [%s] offset: %s", path, cache.size(), offset); } result = DirectoryEntries.newBuilder(); for (int i = offset; i < offset + count; i++) { result.addEntries(entry.getDirectoryEntries().getEntries(i)); } } return result.build(); } else { if (Logging.isDebug()) { Logging.logMessage(Logging.LEVEL_DEBUG, Category.misc, this, "MetadataCache entry expired: %s", path); } if (entry.getTimeoutS() < currentTimeS) { cache.remove(path); pathIndex.remove(path); } return null; } } } finally { writeLock.unlock(); } if (Logging.isDebug()) { Logging.logMessage(Logging.LEVEL_DEBUG, Category.misc, this, "MetadataCache getDirectoryEntries() miss: %s", path); } return null; } protected  MetadataCache(long maxNumberOfEntries, long ttlS);  }
MetadataCache { protected DirectoryEntries getDirEntries(String path, int offset, int count) { if (path.isEmpty() || !enabled) { return null; } writeLock.lock(); try { MetadataCacheEntry entry = cache.get(path); if (entry != null && entry.getDirectoryEntries() != null) { long currentTimeS = System.currentTimeMillis() / 1000; if (entry.getDirectoryEntriesTimeoutS() >= currentTimeS) { DirectoryEntries.Builder result; if (offset == 0 && count >= entry.getDirectoryEntries().getEntriesCount()) { if (Logging.isDebug()) { Logging.logMessage(Logging.LEVEL_DEBUG, Category.misc, this, "MetadataCache getDirEntries() hit: %s [%s]", path, cache.size()); } result = entry.getDirectoryEntries().toBuilder(); } else { if (Logging.isDebug()) { Logging.logMessage(Logging.LEVEL_DEBUG, Category.misc, this, "MetadataCache getDirectoryEntries() hit (partial copy): " + "%s [%s] offset: %s", path, cache.size(), offset); } result = DirectoryEntries.newBuilder(); for (int i = offset; i < offset + count; i++) { result.addEntries(entry.getDirectoryEntries().getEntries(i)); } } return result.build(); } else { if (Logging.isDebug()) { Logging.logMessage(Logging.LEVEL_DEBUG, Category.misc, this, "MetadataCache entry expired: %s", path); } if (entry.getTimeoutS() < currentTimeS) { cache.remove(path); pathIndex.remove(path); } return null; } } } finally { writeLock.unlock(); } if (Logging.isDebug()) { Logging.logMessage(Logging.LEVEL_DEBUG, Category.misc, this, "MetadataCache getDirectoryEntries() miss: %s", path); } return null; } protected  MetadataCache(long maxNumberOfEntries, long ttlS);   }