public Key cloneWithoutRegions() { return new Key(entityType, entityName, requestType, requestVersion, eurekaAccept); }
/** * Invalidate the cache of a particular application. * * @param appName the application name of the application. */ @Override public void invalidate(String appName, @Nullable String vipAddress, @Nullable String secureVipAddress) { for (Key.KeyType type : Key.KeyType.values()) { for (Version v : Version.values()) { invalidate( new Key(Key.EntityType.Application, appName, type, v, EurekaAccept.full), new Key(Key.EntityType.Application, appName, type, v, EurekaAccept.compact), new Key(Key.EntityType.Application, ALL_APPS, type, v, EurekaAccept.full), new Key(Key.EntityType.Application, ALL_APPS, type, v, EurekaAccept.compact), new Key(Key.EntityType.Application, ALL_APPS_DELTA, type, v, EurekaAccept.full), new Key(Key.EntityType.Application, ALL_APPS_DELTA, type, v, EurekaAccept.compact) ); if (null != vipAddress) { invalidate(new Key(Key.EntityType.VIP, vipAddress, type, v, EurekaAccept.full)); } if (null != secureVipAddress) { invalidate(new Key(Key.EntityType.SVIP, secureVipAddress, type, v, EurekaAccept.full)); } } } }
protected Response getVipResponse(String version, String entityName, String acceptHeader, EurekaAccept eurekaAccept, Key.EntityType entityType) { if (!registry.shouldAllowAccess(false)) { return Response.status(Response.Status.FORBIDDEN).build(); } CurrentRequestVersion.set(Version.toEnum(version)); Key.KeyType keyType = Key.KeyType.JSON; if (acceptHeader == null || !acceptHeader.contains("json")) { keyType = Key.KeyType.XML; } Key cacheKey = new Key( entityType, entityName, keyType, CurrentRequestVersion.get(), eurekaAccept ); String payLoad = responseCache.get(cacheKey); if (payLoad != null) { logger.debug("Found: {}", entityName); return Response.ok(payLoad).build(); } else { logger.debug("Not Found: {}", entityName); return Response.status(Response.Status.NOT_FOUND).build(); } } }
Key cacheKey = new Key( Key.EntityType.Application, appName,
Key cacheKey = new Key(Key.EntityType.Application, ResponseCacheImpl.ALL_APPS, keyType, CurrentRequestVersion.get(), EurekaAccept.fromString(eurekaAccept), regions
Key cacheKey = new Key(Key.EntityType.Application, ResponseCacheImpl.ALL_APPS_DELTA, keyType, CurrentRequestVersion.get(), EurekaAccept.fromString(eurekaAccept), regions
@Test public void testInvalidateWithRemoteRegion() throws Exception { ResponseCacheImpl cache = (ResponseCacheImpl) testRegistry.getResponseCache(); Key key = new Key( Key.EntityType.Application, REMOTE_REGION_APP_NAME, Key.KeyType.JSON, Version.V1, EurekaAccept.full, new String[]{REMOTE_REGION} ); Assert.assertNotNull("Cache get returned null.", cache.get(key, false)); testRegistry.cancel(REMOTE_REGION_APP_NAME, REMOTE_REGION_INSTANCE_1_HOSTNAME, true); Assert.assertNull("Cache after invalidate did not return null.", cache.get(key)); }
@Test public void testInvalidate() throws Exception { ResponseCacheImpl cache = (ResponseCacheImpl) testRegistry.getResponseCache(); Key key = new Key(Key.EntityType.Application, REMOTE_REGION_APP_NAME, Key.KeyType.JSON, Version.V1, EurekaAccept.full); String response = cache.get(key, false); Assert.assertNotNull("Cache get returned null.", response); testRegistry.cancel(REMOTE_REGION_APP_NAME, REMOTE_REGION_INSTANCE_1_HOSTNAME, true); Assert.assertNull("Cache after invalidate did not return null for write view.", cache.get(key, true)); }
@Test public void testInvalidateWithMultipleRemoteRegions() throws Exception { ResponseCacheImpl cache = (ResponseCacheImpl) testRegistry.getResponseCache(); Key key1 = new Key( Key.EntityType.Application, REMOTE_REGION_APP_NAME, Key.KeyType.JSON, Version.V1, EurekaAccept.full, new String[]{REMOTE_REGION, "myregion2"} ); Key key2 = new Key( Key.EntityType.Application, REMOTE_REGION_APP_NAME, Key.KeyType.JSON, Version.V1, EurekaAccept.full, new String[]{REMOTE_REGION} ); Assert.assertNotNull("Cache get returned null.", cache.get(key1, false)); Assert.assertNotNull("Cache get returned null.", cache.get(key2, false)); testRegistry.cancel(REMOTE_REGION_APP_NAME, REMOTE_REGION_INSTANCE_1_HOSTNAME, true); Assert.assertNull("Cache after invalidate did not return null.", cache.get(key1, true)); Assert.assertNull("Cache after invalidate did not return null.", cache.get(key2, true)); } }
public Key cloneWithoutRegions() { return new Key(entityType, entityName, requestType, requestVersion, eurekaAccept); }
/** * Invalidate the cache of a particular application. * * @param appName the application name of the application. */ @Override public void invalidate(String appName, @Nullable String vipAddress, @Nullable String secureVipAddress) { for (Key.KeyType type : Key.KeyType.values()) { for (Version v : Version.values()) { invalidate( new Key(Key.EntityType.Application, appName, type, v, EurekaAccept.full), new Key(Key.EntityType.Application, appName, type, v, EurekaAccept.compact), new Key(Key.EntityType.Application, ALL_APPS, type, v, EurekaAccept.full), new Key(Key.EntityType.Application, ALL_APPS, type, v, EurekaAccept.compact), new Key(Key.EntityType.Application, ALL_APPS_DELTA, type, v, EurekaAccept.full), new Key(Key.EntityType.Application, ALL_APPS_DELTA, type, v, EurekaAccept.compact) ); if (null != vipAddress) { invalidate(new Key(Key.EntityType.VIP, vipAddress, type, v, EurekaAccept.full)); } if (null != secureVipAddress) { invalidate(new Key(Key.EntityType.SVIP, secureVipAddress, type, v, EurekaAccept.full)); } } } }
protected Response getVipResponse(String version, String entityName, String acceptHeader, EurekaAccept eurekaAccept, Key.EntityType entityType) { if (!registry.shouldAllowAccess(false)) { return Response.status(Response.Status.FORBIDDEN).build(); } CurrentRequestVersion.set(Version.toEnum(version)); Key.KeyType keyType = Key.KeyType.JSON; if (acceptHeader == null || !acceptHeader.contains("json")) { keyType = Key.KeyType.XML; } Key cacheKey = new Key( entityType, entityName, keyType, CurrentRequestVersion.get(), eurekaAccept ); String payLoad = responseCache.get(cacheKey); if (payLoad != null) { logger.debug("Found: {}", entityName); return Response.ok(payLoad).build(); } else { logger.debug("Not Found: {}", entityName); return Response.status(Response.Status.NOT_FOUND).build(); } } }
Key cacheKey = new Key( Key.EntityType.Application, appName,
Key cacheKey = new Key(Key.EntityType.Application, ResponseCacheImpl.ALL_APPS, keyType, CurrentRequestVersion.get(), EurekaAccept.fromString(eurekaAccept), regions
Key cacheKey = new Key(Key.EntityType.Application, ResponseCacheImpl.ALL_APPS_DELTA, keyType, CurrentRequestVersion.get(), EurekaAccept.fromString(eurekaAccept), regions