@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; }
/** * Gets the {@link InstanceInfo} information. * * @param appName the application name for which the information is requested. * @param id the unique identifier of the instance. * @param includeRemoteRegions true, if we need to include applications from remote regions * as indicated by the region {@link URL} by this property * {@link EurekaServerConfig#getRemoteRegionUrls()}, false otherwise * @return the information about the instance. */ @Override public InstanceInfo getInstanceByAppAndId(String appName, String id, boolean includeRemoteRegions) { Map<String, Lease<InstanceInfo>> leaseMap = registry.get(appName); Lease<InstanceInfo> lease = null; if (leaseMap != null) { lease = leaseMap.get(id); } if (lease != null && (!isLeaseExpirationEnabled() || !lease.isExpired())) { return decorateInstanceInfo(lease); } else if (includeRemoteRegions) { for (RemoteRegionRegistry remoteRegistry : this.regionNameVSRemoteRegistry.values()) { Application application = remoteRegistry.getApplication(appName); if (application != null) { return application.getByInstanceId(id); } } } return null; }
@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; }
/** * Get all applications in this instance registry, falling back to other regions if allowed in the Eureka config. * * @return the list of all known applications * * @see com.netflix.discovery.shared.LookupService#getApplications() */ public Applications getApplications() { boolean disableTransparentFallback = serverConfig.disableTransparentFallbackToOtherRegion(); if (disableTransparentFallback) { return getApplicationsFromLocalRegionOnly(); } else { return getApplicationsFromAllRemoteRegions(); // Behavior of falling back to remote region can be disabled. } }
if (isRemoteRegionRequested) { tracer = serializeAllAppsWithRemoteRegionTimer.start(); payload = getPayLoad(key, registry.getApplicationsFromMultipleRegions(key.getRegions())); } else { tracer = serializeAllAppsTimer.start(); payload = getPayLoad(key, registry.getApplications()); versionDeltaWithRegionsLegacy.incrementAndGet(); payload = getPayLoad(key, registry.getApplicationDeltasFromMultipleRegions(key.getRegions())); } else { tracer = serializeDeltaAppsTimer.start(); versionDelta.incrementAndGet(); versionDeltaLegacy.incrementAndGet(); payload = getPayLoad(key, registry.getApplicationDeltas()); payload = getPayLoad(key, registry.getApplication(key.getName()));
apps.addApplication(app); app.addInstance(new InstanceInfo(decorateInstanceInfo(lease))); if (null != remoteAppsDelta) { for (Application application : remoteAppsDelta.getRegisteredApplications()) { if (shouldFetchFromRemoteRegistry(application.getName(), remoteRegion)) { Application appInstanceTillNow = apps.getRegisteredApplications(application.getName()); Applications allApps = getApplicationsFromMultipleRegions(remoteRegions); apps.setAppsHashCode(allApps.getReconcileHashCode()); return apps;
apps.addApplication(app); app.addInstance(new InstanceInfo(decorateInstanceInfo(lease))); Applications allAppsInLocalRegion = getApplications(false); Applications allApps = getApplications(!disableTransparentFallback); apps.setAppsHashCode(allApps.getReconcileHashCode()); return apps;
app = new Application(lease.getHolder().getAppName()); app.addInstance(decorateInstanceInfo(lease)); Applications remoteApps = remoteRegistry.getApplications(); for (Application application : remoteApps.getRegisteredApplications()) { if (shouldFetchFromRemoteRegistry(application.getName(), remoteRegion)) { logger.info("Application {} fetched from the remote region {}", application.getName(), remoteRegion);
/** * 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); }
/** * Get application information. * * @param appName The name of the application * @param includeRemoteRegion true, if we need to include applications from remote regions * as indicated by the region {@link URL} by this property * {@link EurekaServerConfig#getRemoteRegionUrls()}, false otherwise * @return the application */ @Override public Application getApplication(String appName, boolean includeRemoteRegion) { Application app = null; Map<String, Lease<InstanceInfo>> leaseMap = registry.get(appName); if (leaseMap != null && leaseMap.size() > 0) { for (Entry<String, Lease<InstanceInfo>> entry : leaseMap.entrySet()) { if (app == null) { app = new Application(appName); } app.addInstance(decorateInstanceInfo(entry.getValue())); } } else if (includeRemoteRegion) { for (RemoteRegionRegistry remoteRegistry : this.regionNameVSRemoteRegistry.values()) { Application application = remoteRegistry.getApplication(appName); if (application != null) { return application; } } } return app; }
/** * Returns the given app that is in this instance only, falling back to other regions transparently only * if specified in this client configuration. * * @param appName the application name of the application * @return the application * * @see com.netflix.discovery.shared.LookupService#getApplication(java.lang.String) */ @Override public Application getApplication(String appName) { boolean disableTransparentFallback = serverConfig.disableTransparentFallbackToOtherRegion(); return this.getApplication(appName, !disableTransparentFallback); }
key.getEntityType(), key.getName(), key.getVersion(), key.getType()); Applications toReturn = new Applications(); Applications applications = registry.getApplications(); for (Application application : applications.getRegisteredApplications()) { Application appToAdd = null;
if (isRemoteRegionRequested) { tracer = serializeAllAppsWithRemoteRegionTimer.start(); payload = getPayLoad(key, registry.getApplicationsFromMultipleRegions(key.getRegions())); } else { tracer = serializeAllAppsTimer.start(); payload = getPayLoad(key, registry.getApplications()); versionDeltaWithRegionsLegacy.incrementAndGet(); payload = getPayLoad(key, registry.getApplicationDeltasFromMultipleRegions(key.getRegions())); } else { tracer = serializeDeltaAppsTimer.start(); versionDelta.incrementAndGet(); versionDeltaLegacy.incrementAndGet(); payload = getPayLoad(key, registry.getApplicationDeltas()); payload = getPayLoad(key, registry.getApplication(key.getName()));
apps.addApplication(app); app.addInstance(new InstanceInfo(decorateInstanceInfo(lease))); if (null != remoteAppsDelta) { for (Application application : remoteAppsDelta.getRegisteredApplications()) { if (shouldFetchFromRemoteRegistry(application.getName(), remoteRegion)) { Application appInstanceTillNow = apps.getRegisteredApplications(application.getName()); Applications allApps = getApplicationsFromMultipleRegions(remoteRegions); apps.setAppsHashCode(allApps.getReconcileHashCode()); return apps;
/** * Get all applications in this instance registry, falling back to other regions if allowed in the Eureka config. * * @return the list of all known applications * * @see com.netflix.discovery.shared.LookupService#getApplications() */ public Applications getApplications() { boolean disableTransparentFallback = serverConfig.disableTransparentFallbackToOtherRegion(); if (disableTransparentFallback) { return getApplicationsFromLocalRegionOnly(); } else { return getApplicationsFromAllRemoteRegions(); // Behavior of falling back to remote region can be disabled. } }
apps.addApplication(app); app.addInstance(new InstanceInfo(decorateInstanceInfo(lease))); Applications allAppsInLocalRegion = getApplications(false); Applications allApps = getApplications(!disableTransparentFallback); apps.setAppsHashCode(allApps.getReconcileHashCode()); return apps;
app = new Application(lease.getHolder().getAppName()); app.addInstance(decorateInstanceInfo(lease)); Applications remoteApps = remoteRegistry.getApplications(); for (Application application : remoteApps.getRegisteredApplications()) { if (shouldFetchFromRemoteRegistry(application.getName(), remoteRegion)) { logger.info("Application {} fetched from the remote region {}", application.getName(), remoteRegion);
@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); } }
app.addInstance(decorateInstanceInfo(lease));
/** * Returns the given app that is in this instance only, falling back to other regions transparently only * if specified in this client configuration. * * @param appName the application name of the application * @return the application * * @see com.netflix.discovery.shared.LookupService#getApplication(java.lang.String) */ @Override public Application getApplication(String appName) { boolean disableTransparentFallback = serverConfig.disableTransparentFallbackToOtherRegion(); return this.getApplication(appName, !disableTransparentFallback); }