/** Static method that provides null check for retryCache */ public static CacheEntry waitForCompletion(RetryCache cache) { if (skipRetryCache()) { return null; } return cache != null ? cache .waitForCompletion(newEntry(cache.expirationTime)) : null; }
RetryCacheMetrics(RetryCache retryCache) { name = "RetryCache."+ retryCache.getCacheName(); registry = new MetricsRegistry(name); if (LOG.isDebugEnabled()) { LOG.debug("Initialized "+ registry); } }
public static void clear(RetryCache cache) { if (cache != null) { cache.set.clear(); cache.incrCacheClearedCounter(); } } }
@Override // ClientProtocol public void unsetErasureCodingPolicy(String src) throws IOException { checkNNStartup(); final CacheEntry cacheEntry = RetryCache.waitForCompletion(retryCache); if (cacheEntry != null && cacheEntry.isSuccess()) { return; } boolean success = false; try { namesystem.unsetErasureCodingPolicy(src, cacheEntry != null); success = true; } finally { RetryCache.setState(cacheEntry, success); } }
void addCacheEntry(byte[] clientId, int callId) { if (retryCache != null) { retryCache.addCacheEntry(clientId, callId); } }
void addCacheEntryWithPayload(byte[] clientId, int callId, Object payload) { if (retryCache != null) { retryCache.addCacheEntryWithPayload(clientId, callId, payload); } }
@VisibleForTesting static RetryCache initRetryCache(Configuration conf) { boolean enable = conf.getBoolean(DFS_NAMENODE_ENABLE_RETRY_CACHE_KEY, DFS_NAMENODE_ENABLE_RETRY_CACHE_DEFAULT); LOG.info("Retry cache on namenode is " + (enable ? "enabled" : "disabled")); if (enable) { float heapPercent = conf.getFloat( DFS_NAMENODE_RETRY_CACHE_HEAP_PERCENT_KEY, DFS_NAMENODE_RETRY_CACHE_HEAP_PERCENT_DEFAULT); long entryExpiryMillis = conf.getLong( DFS_NAMENODE_RETRY_CACHE_EXPIRYTIME_MILLIS_KEY, DFS_NAMENODE_RETRY_CACHE_EXPIRYTIME_MILLIS_DEFAULT); LOG.info("Retry cache will use " + heapPercent + " of total heap and retry cache entry expiry time is " + entryExpiryMillis + " millis"); long entryExpiryNanos = entryExpiryMillis * 1000 * 1000; return new RetryCache("NameNodeRetryCache", heapPercent, entryExpiryNanos); } return null; }
@Override // ClientProtocol public boolean saveNamespace(long timeWindow, long txGap) throws IOException { checkNNStartup(); CacheEntry cacheEntry = RetryCache.waitForCompletion(retryCache); if (cacheEntry != null && cacheEntry.isSuccess()) { return true; // Return previous response } boolean success = false; try { namesystem.saveNamespace(timeWindow, txGap); success = true; } finally { RetryCache.setState(cacheEntry, success); } return true; }
void addCacheEntry(byte[] clientId, int callId) { if (retryCache != null) { retryCache.addCacheEntry(clientId, callId); } }
void addCacheEntryWithPayload(byte[] clientId, int callId, Object payload) { if (retryCache != null) { retryCache.addCacheEntryWithPayload(clientId, callId, payload); } }
@VisibleForTesting static RetryCache initRetryCache(Configuration conf) { boolean enable = conf.getBoolean(DFS_NAMENODE_ENABLE_RETRY_CACHE_KEY, DFS_NAMENODE_ENABLE_RETRY_CACHE_DEFAULT); LOG.info("Retry cache on namenode is " + (enable ? "enabled" : "disabled")); if (enable) { float heapPercent = conf.getFloat( DFS_NAMENODE_RETRY_CACHE_HEAP_PERCENT_KEY, DFS_NAMENODE_RETRY_CACHE_HEAP_PERCENT_DEFAULT); long entryExpiryMillis = conf.getLong( DFS_NAMENODE_RETRY_CACHE_EXPIRYTIME_MILLIS_KEY, DFS_NAMENODE_RETRY_CACHE_EXPIRYTIME_MILLIS_DEFAULT); LOG.info("Retry cache will use " + heapPercent + " of total heap and retry cache entry expiry time is " + entryExpiryMillis + " millis"); long entryExpiryNanos = entryExpiryMillis * 1000 * 1000; return new RetryCache("NameNodeRetryCache", heapPercent, entryExpiryNanos); } return null; }
@Override // ClientProtocol public void setErasureCodingPolicy(String src, String ecPolicyName) throws IOException { checkNNStartup(); final CacheEntry cacheEntry = RetryCache.waitForCompletion(retryCache); if (cacheEntry != null && cacheEntry.isSuccess()) { return; } boolean success = false; try { if (ecPolicyName == null) { ecPolicyName = defaultECPolicyName; LOG.trace("No policy name is specified, " + "set the default policy name instead"); } LOG.trace("Set erasure coding policy " + ecPolicyName + " on " + src); namesystem.setErasureCodingPolicy(src, ecPolicyName, cacheEntry != null); success = true; } finally { RetryCache.setState(cacheEntry, success); } }
/** Static method that provides null check for retryCache */ public static CacheEntryWithPayload waitForCompletion(RetryCache cache, Object payload) { if (skipRetryCache()) { return null; } return (CacheEntryWithPayload) (cache != null ? cache .waitForCompletion(newEntry(payload, cache.expirationTime)) : null); }
RetryCacheMetrics(RetryCache retryCache) { name = "RetryCache."+ retryCache.getCacheName(); registry = new MetricsRegistry(name); if (LOG.isDebugEnabled()) { LOG.debug("Initialized "+ registry); } }
public static void clear(RetryCache cache) { if (cache != null) { cache.set.clear(); cache.incrCacheClearedCounter(); } } }
void addCacheEntry(byte[] clientId, int callId) { if (retryCache != null) { retryCache.addCacheEntry(clientId, callId); } }
void addCacheEntryWithPayload(byte[] clientId, int callId, Object payload) { if (retryCache != null) { retryCache.addCacheEntryWithPayload(clientId, callId, payload); } }
@VisibleForTesting static RetryCache initRetryCache(Configuration conf) { boolean enable = conf.getBoolean(DFS_NAMENODE_ENABLE_RETRY_CACHE_KEY, DFS_NAMENODE_ENABLE_RETRY_CACHE_DEFAULT); LOG.info("Retry cache on namenode is " + (enable ? "enabled" : "disabled")); if (enable) { float heapPercent = conf.getFloat( DFS_NAMENODE_RETRY_CACHE_HEAP_PERCENT_KEY, DFS_NAMENODE_RETRY_CACHE_HEAP_PERCENT_DEFAULT); long entryExpiryMillis = conf.getLong( DFS_NAMENODE_RETRY_CACHE_EXPIRYTIME_MILLIS_KEY, DFS_NAMENODE_RETRY_CACHE_EXPIRYTIME_MILLIS_DEFAULT); LOG.info("Retry cache will use " + heapPercent + " of total heap and retry cache entry expiry time is " + entryExpiryMillis + " millis"); long entryExpiryNanos = entryExpiryMillis * 1000 * 1000; return new RetryCache("NameNodeRetryCache", heapPercent, entryExpiryNanos); } return null; }
@Override public void removeErasureCodingPolicy(String ecPolicyName) throws IOException { checkNNStartup(); namesystem.checkSuperuserPrivilege(); final CacheEntry cacheEntry = RetryCache.waitForCompletion(retryCache); if (cacheEntry != null && cacheEntry.isSuccess()) { return; } boolean success = false; try { namesystem.removeErasureCodingPolicy(ecPolicyName, cacheEntry != null); success = true; } finally { RetryCache.setState(cacheEntry, success); } }
/** Static method that provides null check for retryCache */ public static CacheEntryWithPayload waitForCompletion(RetryCache cache, Object payload) { if (skipRetryCache()) { return null; } return (CacheEntryWithPayload) (cache != null ? cache .waitForCompletion(newEntry(payload, cache.expirationTime)) : null); }