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.Jersey2EurekaBootStrap
Extension 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 void
cleanupApps()
Cleans out all the registered applications inside of Eureka.long
getHeartbeatCount()
Returns the count of heartbeat renewals in Eureka.com.netflix.discovery.shared.Application
getRegisteredApplication(String appId)
Returns anApplication
with given appId if found from Eureka.boolean
isApplicationRegistered(String appId)
Checks to see if a given app is registered in Eureka.void
registerApplication(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
-
cleanupApps
public void cleanupApps()
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 anApplication
with 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 theMeasuredRate
which returns the value from theAtomicLong
lastBucket
. When renews happen, the increment happens on tehAtomicLong
currentBucket
field 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
-
-