com.netflix.karyon.server.eureka
Class AsyncHealthCheckInvocationStrategy

java.lang.Object
  extended by com.netflix.karyon.server.eureka.AsyncHealthCheckInvocationStrategy
All Implemented Interfaces:
HealthCheckInvocationStrategy

public class AsyncHealthCheckInvocationStrategy
extends java.lang.Object
implements HealthCheckInvocationStrategy

An implementation of HealthCheckInvocationStrategy that calls the underlying HealthCheckHandler asynchronously. If the underlying handler takes more time than configured in the property PropertyNames.HEALTH_CHECK_TIMEOUT_MILLIS, this handler will throw a TimeoutException. The timeout is retrieved using archaius's dynamic properties and hence can be changed at runtime. The default timeout value is as configured by the propertyPropertyNames.HEALTH_CHECK_TIMEOUT_DEFAULT_MILLIS milliseconds.

Threading model

This class uses exactly one thread to perform the health check. There is no queue used for any concurrent health check requests. Any concurrent health check requests blocks (for the configured timeout) and wait for the single execution to finish after which the same result is returned. This is useful in providing an SLA for the healthcheck and does not create a queuing point which may result in unnecessary tuning and memory overheads.


Field Summary
protected static org.slf4j.Logger logger
           
 
Constructor Summary
AsyncHealthCheckInvocationStrategy(HealthCheckHandler healthCheckHandler)
           
 
Method Summary
 HealthCheckHandler getHandler()
          Returns the instance of HealthCheckHandler associated with this strategy.
 int invokeCheck()
          Invokes the handler associated with this strategy and returns the response.
 void start()
           
 void stop()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected static final org.slf4j.Logger logger
Constructor Detail

AsyncHealthCheckInvocationStrategy

@Inject
public AsyncHealthCheckInvocationStrategy(HealthCheckHandler healthCheckHandler)
Method Detail

start

@PostConstruct
public void start()

invokeCheck

public int invokeCheck()
                throws java.util.concurrent.TimeoutException
Description copied from interface: HealthCheckInvocationStrategy
Invokes the handler associated with this strategy and returns the response. This method may block waiting for results.
If this strategy supports timeouts, this call must not wait more than the timeout value.

Specified by:
invokeCheck in interface HealthCheckInvocationStrategy
Returns:
The health check result.
Throws:
java.util.concurrent.TimeoutException - If the healthcheck did not return after the stipulated time (governed entirely by this strategy implementation)

getHandler

public HealthCheckHandler getHandler()
Description copied from interface: HealthCheckInvocationStrategy
Returns the instance of HealthCheckHandler associated with this strategy.

Specified by:
getHandler in interface HealthCheckInvocationStrategy
Returns:
The instance of HealthCheckHandler associated with this strategy.

stop

public void stop()
          throws java.lang.InterruptedException
Throws:
java.lang.InterruptedException