@Test public void isChangedメソッドでキャッシュ無効化時間が登録済みのキャッシュと同じ場合falseを返すこと() throws Exception { String nodeId = "node_VVVVVVVVV1"; Map<String, Object> schemaToCache = new HashMap<String, Object>(); schemaToCache.put("SchemaCacheTestKey001", "testValue"); Long now = new Date().getTime(); schemaToCache.put("disabledTime", now); MockMemcachedClient mockMemcachedClient = new MockMemcachedClient(); PowerMockito.spy(UserDataSchemaCache.class); PowerMockito.when(UserDataSchemaCache.class, "getMcdClient").thenReturn(mockMemcachedClient); PowerMockito.spy(DcCoreConfig.class); PowerMockito.when(DcCoreConfig.class, "isSchemaCacheEnabled").thenReturn(true); UserDataSchemaCache.cache(nodeId, schemaToCache); Map<String, Object> schemaToCacheNew = new HashMap<String, Object>(); schemaToCacheNew.put("SchemaCacheTestKey002", "testValue"); schemaToCacheNew.put("disabledTime", now); assertThat(UserDataSchemaCache.isChanged(nodeId, schemaToCacheNew)).isFalse(); }
@SuppressWarnings("unchecked") public static boolean isChanged(String nodeId, Map<String, Object> cache) { if (!DcCoreConfig.isSchemaCacheEnabled()) { return false; } Map<String, Object> latestCache = null; try { latestCache = getMcdClient().get(cacheKey(nodeId), Map.class); } catch (MemcachedClientException e) { log.info("Failed to get latest UserDataSchemaCache."); } if (latestCache == null) { return true; } long disabledTime = 0; if (cache.containsKey("disabledTime")) { disabledTime = (Long) cache.get("disabledTime"); } long latestDisabledTime = 0; if (latestCache.containsKey("disabledTime")) { latestDisabledTime = (Long) latestCache.get("disabledTime"); } if (disabledTime != latestDisabledTime) { return true; } return false; }
UserDataSchemaCache { @SuppressWarnings("unchecked") public static boolean isChanged(String nodeId, Map<String, Object> cache) { if (!DcCoreConfig.isSchemaCacheEnabled()) { return false; } Map<String, Object> latestCache = null; try { latestCache = getMcdClient().get(cacheKey(nodeId), Map.class); } catch (MemcachedClientException e) { log.info("Failed to get latest UserDataSchemaCache."); } if (latestCache == null) { return true; } long disabledTime = 0; if (cache.containsKey("disabledTime")) { disabledTime = (Long) cache.get("disabledTime"); } long latestDisabledTime = 0; if (latestCache.containsKey("disabledTime")) { latestDisabledTime = (Long) latestCache.get("disabledTime"); } if (disabledTime != latestDisabledTime) { return true; } return false; } }
UserDataSchemaCache { @SuppressWarnings("unchecked") public static boolean isChanged(String nodeId, Map<String, Object> cache) { if (!DcCoreConfig.isSchemaCacheEnabled()) { return false; } Map<String, Object> latestCache = null; try { latestCache = getMcdClient().get(cacheKey(nodeId), Map.class); } catch (MemcachedClientException e) { log.info("Failed to get latest UserDataSchemaCache."); } if (latestCache == null) { return true; } long disabledTime = 0; if (cache.containsKey("disabledTime")) { disabledTime = (Long) cache.get("disabledTime"); } long latestDisabledTime = 0; if (latestCache.containsKey("disabledTime")) { latestDisabledTime = (Long) latestCache.get("disabledTime"); } if (disabledTime != latestDisabledTime) { return true; } return false; } private  UserDataSchemaCache(); }
UserDataSchemaCache { @SuppressWarnings("unchecked") public static boolean isChanged(String nodeId, Map<String, Object> cache) { if (!DcCoreConfig.isSchemaCacheEnabled()) { return false; } Map<String, Object> latestCache = null; try { latestCache = getMcdClient().get(cacheKey(nodeId), Map.class); } catch (MemcachedClientException e) { log.info("Failed to get latest UserDataSchemaCache."); } if (latestCache == null) { return true; } long disabledTime = 0; if (cache.containsKey("disabledTime")) { disabledTime = (Long) cache.get("disabledTime"); } long latestDisabledTime = 0; if (latestCache.containsKey("disabledTime")) { latestDisabledTime = (Long) latestCache.get("disabledTime"); } if (disabledTime != latestDisabledTime) { return true; } return false; } private  UserDataSchemaCache(); static Map<String, Object> get(String nodeId); static void cache(String nodeId, Map<String, Object> schema); static void clear(String nodeId); static void disable(String nodeId); static boolean isDisabled(Map<String, Object> cache); @SuppressWarnings("unchecked") static boolean isChanged(String nodeId, Map<String, Object> cache); }
UserDataSchemaCache { @SuppressWarnings("unchecked") public static boolean isChanged(String nodeId, Map<String, Object> cache) { if (!DcCoreConfig.isSchemaCacheEnabled()) { return false; } Map<String, Object> latestCache = null; try { latestCache = getMcdClient().get(cacheKey(nodeId), Map.class); } catch (MemcachedClientException e) { log.info("Failed to get latest UserDataSchemaCache."); } if (latestCache == null) { return true; } long disabledTime = 0; if (cache.containsKey("disabledTime")) { disabledTime = (Long) cache.get("disabledTime"); } long latestDisabledTime = 0; if (latestCache.containsKey("disabledTime")) { latestDisabledTime = (Long) latestCache.get("disabledTime"); } if (disabledTime != latestDisabledTime) { return true; } return false; } private  UserDataSchemaCache(); static Map<String, Object> get(String nodeId); static void cache(String nodeId, Map<String, Object> schema); static void clear(String nodeId); static void disable(String nodeId); static boolean isDisabled(Map<String, Object> cache); @SuppressWarnings("unchecked") static boolean isChanged(String nodeId, Map<String, Object> cache);  }