class CloudEurekaClient extends DiscoveryClient {

	private static final Log log = LogFactory.getLog(CloudEurekaClient.class);

	private final AtomicLong cacheRefreshedCount = new AtomicLong(0);

	private final ApplicationEventPublisher publisher;

	private final Field eurekaTransportField;

	private final ApplicationInfoManager applicationInfoManager;

	private final AtomicReference<EurekaHttpClient> eurekaHttpClient = new AtomicReference<>();

	public CloudEurekaClient(ApplicationInfoManager applicationInfoManager, EurekaClientConfig config,
			TransportClientFactories transportClientFactories, ApplicationEventPublisher publisher) {
		this(applicationInfoManager, config, transportClientFactories, null, publisher);
	}

	public CloudEurekaClient(ApplicationInfoManager applicationInfoManager, EurekaClientConfig config,
			TransportClientFactories transportClientFactories, AbstractDiscoveryClientOptionalArgs<?> args,
			ApplicationEventPublisher publisher) {
		super(applicationInfoManager, config, transportClientFactories, args);
		this.applicationInfoManager = applicationInfoManager;
		this.publisher = publisher;
		this.eurekaTransportField = ReflectionUtils.findField(DiscoveryClient.class, "eurekaTransport");
		ReflectionUtils.makeAccessible(this.eurekaTransportField);
	}

	public ApplicationInfoManager getApplicationInfoManager() {
		return applicationInfoManager;
	}

	public void cancelOverrideStatus(InstanceInfo info) {
		getEurekaHttpClient().deleteStatusOverride(info.getAppName(), info.getId(), info);
	}

	public InstanceInfo getInstanceInfo(String appname, String instanceId) {
		EurekaHttpResponse<InstanceInfo> response = getEurekaHttpClient().getInstance(appname, instanceId);
		HttpStatus httpStatus = HttpStatus.valueOf(response.getStatusCode());
		if (httpStatus.is2xxSuccessful() && response.getEntity() != null) {
			return response.getEntity();
		}
		return null;
	}

	EurekaHttpClient getEurekaHttpClient() {<FILL_FUNCTION_BODY>}

	public void setStatus(InstanceStatus newStatus, InstanceInfo info) {
		getEurekaHttpClient().statusUpdate(info.getAppName(), info.getId(), newStatus, info);
	}

	@Override
	protected void onCacheRefreshed() {
		super.onCacheRefreshed();

		if (this.cacheRefreshedCount != null) { // might be called during construction and
			// will be null
			long newCount = this.cacheRefreshedCount.incrementAndGet();
			log.trace("onCacheRefreshed called with count: " + newCount);
			this.publisher.publishEvent(new HeartbeatEvent(this, newCount));
		}
	}

}

		if (this.eurekaHttpClient.get() == null) {
			try {
				Object eurekaTransport = this.eurekaTransportField.get(this);
				Field registrationClientField = ReflectionUtils.findField(eurekaTransport.getClass(),
						"registrationClient");
				ReflectionUtils.makeAccessible(registrationClientField);
				this.eurekaHttpClient.compareAndSet(null,
						(EurekaHttpClient) registrationClientField.get(eurekaTransport));
			}
			catch (IllegalAccessException e) {
				log.error("error getting EurekaHttpClient", e);
			}
		}
		return this.eurekaHttpClient.get();
	
<methods>public void <init>(com.netflix.appinfo.ApplicationInfoManager, com.netflix.discovery.EurekaClientConfig, TransportClientFactories#RAW) ,public void <init>(com.netflix.appinfo.ApplicationInfoManager, com.netflix.discovery.EurekaClientConfig, TransportClientFactories#RAW, AbstractDiscoveryClientOptionalArgs#RAW) ,public void <init>(com.netflix.appinfo.ApplicationInfoManager, com.netflix.discovery.EurekaClientConfig, TransportClientFactories#RAW, AbstractDiscoveryClientOptionalArgs#RAW, com.netflix.discovery.shared.resolver.EndpointRandomizer) ,public Set<java.lang.String> getAllKnownRegions() ,public com.netflix.discovery.shared.Application getApplication(java.lang.String) ,public com.netflix.appinfo.ApplicationInfoManager getApplicationInfoManager() ,public com.netflix.discovery.shared.Applications getApplications() ,public com.netflix.discovery.shared.Applications getApplications(java.lang.String) ,public com.netflix.discovery.shared.Applications getApplicationsForARegion(java.lang.String) ,public List<java.lang.String> getDiscoveryServiceUrls(java.lang.String) ,public static Set<java.lang.String> getEC2DiscoveryUrlsFromZone(java.lang.String, com.netflix.discovery.endpoint.EndpointUtils.DiscoveryUrlType) ,public com.netflix.discovery.EurekaClientConfig getEurekaClientConfig() ,public static List<java.lang.String> getEurekaServiceUrlsFromConfig(java.lang.String, boolean) ,public com.netflix.appinfo.HealthCheckHandler getHealthCheckHandler() ,public com.netflix.appinfo.InstanceInfo.InstanceStatus getInstanceRemoteStatus() ,public List<com.netflix.appinfo.InstanceInfo> getInstancesById(java.lang.String) ,public List<com.netflix.appinfo.InstanceInfo> getInstancesByVipAddress(java.lang.String, boolean) ,public List<com.netflix.appinfo.InstanceInfo> getInstancesByVipAddress(java.lang.String, boolean, java.lang.String) ,public List<com.netflix.appinfo.InstanceInfo> getInstancesByVipAddressAndAppName(java.lang.String, java.lang.String, boolean) ,public long getLastSuccessfulHeartbeatTimePeriod() ,public long getLastSuccessfulRegistryFetchTimePeriod() ,public com.netflix.appinfo.InstanceInfo getNextServerFromEureka(java.lang.String, boolean) ,public static java.lang.String getRegion() ,public List<java.lang.String> getServiceUrlsFromConfig(java.lang.String, boolean) ,public List<java.lang.String> getServiceUrlsFromDNS(java.lang.String, boolean) ,public com.netflix.discovery.DiscoveryClient.Stats getStats() ,public static java.lang.String getZone(com.netflix.appinfo.InstanceInfo) ,public int localRegistrySize() ,public void registerEventListener(com.netflix.discovery.EurekaEventListener) ,public void registerHealthCheck(com.netflix.appinfo.HealthCheckHandler) ,public void registerHealthCheckCallback(com.netflix.appinfo.HealthCheckCallback) ,public synchronized void shutdown() ,public boolean unregisterEventListener(com.netflix.discovery.EurekaEventListener) <variables>private static final java.lang.String COMMA_STRING,private final com.netflix.servo.monitor.Timer FETCH_REGISTRY_TIMER,public static final java.lang.String HTTP_X_DISCOVERY_ALLOW_REDIRECT,private static final java.lang.String PREFIX,private final com.netflix.servo.monitor.Counter RECONCILE_HASH_CODES_MISMATCH,private final com.netflix.servo.monitor.Counter REREGISTER_COUNTER,private static final java.lang.String VALUE_DELIMITER,private java.lang.String appPathIdentifier,private final com.netflix.appinfo.ApplicationInfoManager applicationInfoManager,private final Provider<com.netflix.discovery.BackupRegistry> backupRegistryProvider,private final java.util.concurrent.ThreadPoolExecutor cacheRefreshExecutor,private com.netflix.discovery.TimedSupervisorTask cacheRefreshTask,protected final com.netflix.discovery.EurekaClientConfig clientConfig,private final com.netflix.discovery.shared.resolver.EndpointRandomizer endpointRandomizer,private final com.netflix.discovery.DiscoveryClient.EurekaTransport eurekaTransport,private final CopyOnWriteArraySet<com.netflix.discovery.EurekaEventListener> eventListeners,private final java.util.concurrent.atomic.AtomicLong fetchRegistryGeneration,private final java.util.concurrent.locks.Lock fetchRegistryUpdateLock,private final Provider<com.netflix.appinfo.HealthCheckCallback> healthCheckCallbackProvider,private final Provider<com.netflix.appinfo.HealthCheckHandler> healthCheckHandlerProvider,private final AtomicReference<com.netflix.appinfo.HealthCheckHandler> healthCheckHandlerRef,private final java.util.concurrent.ThreadPoolExecutor heartbeatExecutor,private final com.netflix.discovery.util.ThresholdLevelsMetric heartbeatStalenessMonitor,private com.netflix.discovery.TimedSupervisorTask heartbeatTask,private final int initRegistrySize,private final long initTimestampMs,private final com.netflix.appinfo.InstanceInfo instanceInfo,private com.netflix.discovery.InstanceInfoReplicator instanceInfoReplicator,private final com.netflix.discovery.InstanceRegionChecker instanceRegionChecker,private final java.util.concurrent.atomic.AtomicBoolean isShutdown,private volatile com.netflix.appinfo.InstanceInfo.InstanceStatus lastRemoteInstanceStatus,private volatile long lastSuccessfulHeartbeatTimestamp,private volatile long lastSuccessfulRegistryFetchTimestamp,private final AtomicReference<com.netflix.discovery.shared.Applications> localRegionApps,private static final org.slf4j.Logger logger,private final com.netflix.discovery.PreRegistrationHandler preRegistrationHandler,private volatile int registrySize,private final com.netflix.discovery.util.ThresholdLevelsMetric registryStalenessMonitor,private volatile Map<java.lang.String,com.netflix.discovery.shared.Applications> remoteRegionVsApps,private final AtomicReference<java.lang.String[]> remoteRegionsRef,private final AtomicReference<java.lang.String> remoteRegionsToFetch,private final java.util.concurrent.ScheduledExecutorService scheduler,private static com.netflix.discovery.EurekaClientConfig staticClientConfig,private final com.netflix.discovery.DiscoveryClient.Stats stats,private com.netflix.appinfo.ApplicationInfoManager.StatusChangeListener statusChangeListener,protected final TransportClientFactories#RAW transportClientFactories,protected final com.netflix.discovery.shared.transport.EurekaTransportConfig transportConfig,private final com.netflix.discovery.endpoint.EndpointUtils.ServiceUrlRandomizer urlRandomizer