@Serializer(value="com.netflix.discovery.converters.EntityBodyConverter") public class Applications extends java.lang.Object
Note that the registry information is fetched from eureka server as specified
in EurekaClientConfig.getRegistryFetchIntervalSeconds()
. Once the
information is fetched it is shuffled and also filtered for instances with
InstanceInfo.InstanceStatus.UP
status as specified by the configuration
EurekaClientConfig.shouldFilterOnlyUpInstances()
.
Constructor and Description |
---|
Applications()
Create a new, empty Eureka application list.
|
Applications(java.lang.String appsHashCode,
java.lang.Long versionDelta,
java.util.List<Application> registeredApplications)
Note that appsHashCode and versionDelta key names are formatted in a
custom/configurable way.
|
Modifier and Type | Method and Description |
---|---|
void |
addApplication(Application app)
Add the application to the list.
|
java.lang.String |
getAppsHashCode()
Used by the eureka server.
|
java.util.List<InstanceInfo> |
getInstancesBySecureVirtualHostName(java.lang.String secureVirtualHostName)
Gets the list of secure instances associated to a virtual host
name.
|
java.util.List<InstanceInfo> |
getInstancesByVirtualHostName(java.lang.String virtualHostName)
Gets the list of instances associated to a virtual host name.
|
java.util.concurrent.atomic.AtomicLong |
getNextIndex(java.lang.String virtualHostname,
boolean secure)
Gets the next round-robin index for the given virtual host name.
|
java.lang.String |
getReconcileHashCode()
Gets the hash code for this applications instance.
|
static java.lang.String |
getReconcileHashCode(java.util.Map<java.lang.String,java.util.concurrent.atomic.AtomicInteger> instanceCountMap)
Gets the reconciliation hashcode.
|
java.util.List<Application> |
getRegisteredApplications()
Gets the list of all registered applications from eureka.
|
Application |
getRegisteredApplications(java.lang.String appName)
Gets the registered application for the given
application name.
|
java.lang.Long |
getVersion()
Deprecated.
|
void |
populateInstanceCountMap(java.util.Map<java.lang.String,java.util.concurrent.atomic.AtomicInteger> instanceCountMap)
Populates the provided instance count map.
|
void |
removeApplication(Application app)
Remove the application from the list.
|
void |
setAppsHashCode(java.lang.String hashCode)
Used by the eureka server.
|
void |
setVersion(java.lang.Long version)
Deprecated.
|
void |
shuffleAndIndexInstances(java.util.Map<java.lang.String,Applications> remoteRegionsRegistry,
EurekaClientConfig clientConfig,
InstanceRegionChecker instanceRegionChecker)
Shuffles a whole region so that the instances will not always be returned
in the same order.
|
void |
shuffleInstances(boolean filterUpInstances)
Shuffles the provided instances so that they will not always be returned
in the same order.
|
int |
size() |
public Applications()
public Applications(java.lang.String appsHashCode, java.lang.Long versionDelta, java.util.List<Application> registeredApplications)
public void addApplication(Application app)
app
- the application to be added.public java.util.List<Application> getRegisteredApplications()
public Application getRegisteredApplications(java.lang.String appName)
appName
- the application name for which the result need to be fetched.public java.util.List<InstanceInfo> getInstancesByVirtualHostName(java.lang.String virtualHostName)
virtualHostName
- the virtual hostname for which the instances need to be
returned.public java.util.List<InstanceInfo> getInstancesBySecureVirtualHostName(java.lang.String secureVirtualHostName)
secureVirtualHostName
- the virtual hostname for which the secure instances need to be
returned.public int size()
@Deprecated public void setVersion(java.lang.Long version)
@Deprecated public java.lang.Long getVersion()
public void setAppsHashCode(java.lang.String hashCode)
hashCode
- the hash code to assign for this app collectionpublic java.lang.String getAppsHashCode()
public java.lang.String getReconcileHashCode()
public void populateInstanceCountMap(java.util.Map<java.lang.String,java.util.concurrent.atomic.AtomicInteger> instanceCountMap)
instanceCountMap
- the map to populatepublic static java.lang.String getReconcileHashCode(java.util.Map<java.lang.String,java.util.concurrent.atomic.AtomicInteger> instanceCountMap)
instanceCountMap
- the instance count map to use for generating the hashpublic void shuffleInstances(boolean filterUpInstances)
filterUpInstances
- whether to return only UP instancespublic void shuffleAndIndexInstances(java.util.Map<java.lang.String,Applications> remoteRegionsRegistry, EurekaClientConfig clientConfig, InstanceRegionChecker instanceRegionChecker)
remoteRegionsRegistry
- the map of remote region names to their registriesclientConfig
- the EurekaClientConfig
, whose settings will be used to
determine whether to filter to only UP instancesinstanceRegionChecker
- the instance region checkerpublic java.util.concurrent.atomic.AtomicLong getNextIndex(java.lang.String virtualHostname, boolean secure)
virtualHostname
- the virtual host name.secure
- indicates whether it is a secure request or a non-secure
request.public void removeApplication(Application app)
app
- the application