public boolean renew(final String appName, final String id, final boolean isReplication) { if (super.renew(appName, id, isReplication)) { replicateToPeers(Action.Heartbeat, appName, id, null, null, isReplication); return true; } return false; }
@Override public boolean statusUpdate(final String appName, final String id, final InstanceStatus newStatus, String lastDirtyTimestamp, final boolean isReplication) { if (super.statusUpdate(appName, id, newStatus, lastDirtyTimestamp, isReplication)) { replicateToPeers(Action.StatusUpdate, appName, id, null, newStatus, isReplication); return true; } return false; }
@Override public boolean deleteStatusOverride(String appName, String id, InstanceStatus newStatus, String lastDirtyTimestamp, boolean isReplication) { if (super.deleteStatusOverride(appName, id, newStatus, lastDirtyTimestamp, isReplication)) { replicateToPeers(Action.DeleteStatusOverride, appName, id, null, null, isReplication); return true; } return false; }
@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)); }
@Override public boolean cancel(final String appName, final String id, final boolean isReplication) { if (super.cancel(appName, id, isReplication)) { replicateToPeers(Action.Cancel, appName, id, null, null, isReplication); synchronized (lock) { if (this.expectedNumberOfClientsSendingRenews > 0) { // Since the client wants to cancel it, reduce the number of clients to send renews this.expectedNumberOfClientsSendingRenews = this.expectedNumberOfClientsSendingRenews - 1; updateRenewsPerMinThreshold(); } } return true; } return false; }
@Override public boolean isLeaseExpirationEnabled() { if (!isSelfPreservationModeEnabled()) { // The self preservation mode is disabled, hence allowing the instances to expire. return true; } return numberOfRenewsPerMinThreshold > 0 && getNumOfRenewsInLastMin() > numberOfRenewsPerMinThreshold; }
@Override public void run() { try { long compensationTimeMs = getCompensationTimeMs(); logger.info("Running the evict task with compensationTime {}ms", compensationTimeMs); evict(compensationTimeMs); } catch (Throwable e) { logger.error("Could not run the evict task", e); } }
/** * Get the compressed information about the applications. * * @param key * the key for which the compressed cached information needs to * be obtained. * @return compressed payload which contains information about the * applications. */ public byte[] getGZIP(Key key) { Value payload = getValue(key, shouldUseReadOnlyResponseCache); if (payload == null) { return null; } return payload.getGzipped(); }
public boolean shouldAllowAccess() { return shouldAllowAccess(true); }
public Key cloneWithoutRegions() { return new Key(entityType, entityName, requestType, requestVersion, eurekaAccept); }
/** * Returns applications including instances from all remote regions. <br/> * Same as calling {@link #getApplicationsFromMultipleRegions(String[])} with a <code>null</code> argument. */ public Applications getApplicationsFromAllRemoteRegions() { return getApplicationsFromMultipleRegions(allKnownRemoteRegions); }
@Override public synchronized void initializedResponseCache() { if (responseCache == null) { responseCache = new ResponseCacheImpl(serverConfig, serverCodecs, this); } }
/** * Evicts everything in the instance registry that has expired, if expiry is enabled. * * @see com.netflix.eureka.lease.LeaseManager#evict() */ @Override public void evict() { evict(0l); }
/** * Gets the {@link InstanceInfo} information. * * @param appName the application name for which the information is requested. * @param id the unique identifier of the instance. * @return the information about the instance. */ @Override public InstanceInfo getInstanceByAppAndId(String appName, String id) { return this.getInstanceByAppAndId(appName, id, true); }
@Override public void execute() { for (int j = 0; j < 45; j++) { registry.renew(LOCAL_REGION_APP_NAME, LOCAL_REGION_INSTANCE_1_HOSTNAME + j, false); } } };
@Override protected PeerAwareInstanceRegistryImpl makePeerAwareInstanceRegistry(EurekaServerConfig serverConfig, EurekaClientConfig clientConfig, ServerCodecs serverCodecs, EurekaClient eurekaClient) { return new TestAwsInstanceRegistry(serverConfig, clientConfig, serverCodecs, eurekaClient); }
@Override protected DataCenterInfo getDataCenterInfo() { return getAmazonInfo(LOCAL_REGION_INSTANCE_1_HOSTNAME); }
@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)); }
/** * Returns applications including instances from local region only. <br/> * Same as calling {@link #getApplicationsFromMultipleRegions(String[])} with an empty array. */ @Override public Applications getApplicationsFromLocalRegionOnly() { return getApplicationsFromMultipleRegions(EMPTY_STR_ARRAY); }