Package org.kiwiproject.eureka
Class EmbeddedEurekaBootstrap
- java.lang.Object
-
- com.netflix.eureka.EurekaBootStrap
-
- com.netflix.eureka.Jersey2EurekaBootStrap
-
- org.kiwiproject.eureka.EmbeddedEurekaBootstrap
-
- All Implemented Interfaces:
EventListener,javax.servlet.ServletContextListener
public class EmbeddedEurekaBootstrap extends com.netflix.eureka.Jersey2EurekaBootStrapExtension of Eureka's bootstrap but with added accessors to validate internal Eureka data.
-
-
Constructor Summary
Constructors Constructor Description EmbeddedEurekaBootstrap(com.netflix.discovery.DiscoveryClient client)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclearRegisteredApps()Cleans out all the registered applications inside of Eureka.longgetHeartbeatCount()Returns the count of heartbeat renewals in Eureka.com.netflix.discovery.shared.ApplicationgetRegisteredApplication(String appId)Returns anApplicationwith given appId if found from Eureka.booleanisApplicationRegistered(String appId)Checks to see if a given app is registered in Eureka.voidregisterApplication(String appName, String instanceId, String vipAddress, String status)Loads an application instance in Eureka for later retrieval.List<com.netflix.discovery.shared.Application>registeredApplications()Returns a list of all the registered applications in Eureka.
-
-
-
Method Detail
-
clearRegisteredApps
public void clearRegisteredApps()
Cleans out all the registered applications inside of Eureka.
-
registeredApplications
public List<com.netflix.discovery.shared.Application> registeredApplications()
Returns a list of all the registered applications in Eureka.- Returns:
- list of registered applications.
-
isApplicationRegistered
public boolean isApplicationRegistered(String appId)
Checks to see if a given app is registered in Eureka.- Parameters:
appId- the id of the app to check.- Returns:
- true if registered, false otherwise.
-
getRegisteredApplication
public com.netflix.discovery.shared.Application getRegisteredApplication(String appId)
Returns anApplicationwith given appId if found from Eureka.- Parameters:
appId- the id of the app to check.- Returns:
- the registered application if found, otherwise null.
-
getHeartbeatCount
public long getHeartbeatCount()
Returns the count of heartbeat renewals in Eureka.- Returns:
- the number of heartbeats sent to Eureka
- Implementation Note:
- This requires reflection hacks due to the way Eureka stores the renews and what is visible from
this class. I don't like it, but it is what it is. The
getNumOfRenewsInLastMin()method callsgetCount()on theMeasuredRatewhich returns the value from theAtomicLonglastBucket. When renews happen, the increment happens on tehAtomicLongcurrentBucketfield which is not publicly accessible.
-
registerApplication
public void registerApplication(String appName, String instanceId, String vipAddress, String status)
Loads an application instance in Eureka for later retrieval.- Parameters:
appName- the application nameinstanceId- the instance idvipAddress- the VIP address of the instancestatus- the status of the instance
-
-