Package com.netflix.appinfo
Class ApplicationInfoManager
- java.lang.Object
-
- com.netflix.appinfo.ApplicationInfoManager
-
@Singleton public class ApplicationInfoManager extends java.lang.ObjectThe class that initializes information required for registration with Eureka Server and to be discovered by other components.The information required for registration is provided by the user by passing the configuration defined by the contract in
EurekaInstanceConfig}.AWS clients can either use or extendCloudInstanceConfig. Other non-AWS clients can use or extend eitherMyDataCenterInstanceConfigor very basicAbstractInstanceConfig.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceApplicationInfoManager.InstanceStatusMapperstatic classApplicationInfoManager.OptionalArgsstatic interfaceApplicationInfoManager.StatusChangeListener
-
Field Summary
Fields Modifier and Type Field Description protected java.util.Map<java.lang.String,ApplicationInfoManager.StatusChangeListener>listeners
-
Constructor Summary
Constructors Constructor Description ApplicationInfoManager(EurekaInstanceConfig config)Deprecated.ApplicationInfoManager(EurekaInstanceConfig config, ApplicationInfoManager.OptionalArgs optionalArgs)ApplicationInfoManager(EurekaInstanceConfig config, InstanceInfo instanceInfo)ApplicationInfoManager(EurekaInstanceConfig config, InstanceInfo instanceInfo, ApplicationInfoManager.OptionalArgs optionalArgs)public for DI use.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description EurekaInstanceConfiggetEurekaInstanceConfig()InstanceInfogetInfo()Gets the information about this instance that is registered with eureka.static ApplicationInfoManagergetInstance()Deprecated.please use DI insteadvoidinitComponent(EurekaInstanceConfig config)voidrefreshDataCenterInfoIfRequired()Refetches the hostname to check if it has changed.voidrefreshLeaseInfoIfRequired()voidregisterAppMetadata(java.util.Map<java.lang.String,java.lang.String> appMetadata)Register user-specific instance meta data.voidregisterStatusChangeListener(ApplicationInfoManager.StatusChangeListener listener)voidsetInstanceStatus(InstanceInfo.InstanceStatus status)Set the status of this instance.voidsetInstanceStatus(InstanceInfo.InstanceStatus expectedStatus, InstanceInfo.InstanceStatus updateStatus)Set the status of this instance only if the current status equals expected status in order to avoid concurrent modification.voidunregisterStatusChangeListener(java.lang.String listenerId)
-
-
-
Field Detail
-
listeners
protected final java.util.Map<java.lang.String,ApplicationInfoManager.StatusChangeListener> listeners
-
-
Constructor Detail
-
ApplicationInfoManager
@Inject public ApplicationInfoManager(EurekaInstanceConfig config, InstanceInfo instanceInfo, ApplicationInfoManager.OptionalArgs optionalArgs)
public for DI use. This class should be in singleton scope so do not create explicitly. Either use DI or create this explicitly using one of the other public constructors.
-
ApplicationInfoManager
public ApplicationInfoManager(EurekaInstanceConfig config, ApplicationInfoManager.OptionalArgs optionalArgs)
-
ApplicationInfoManager
public ApplicationInfoManager(EurekaInstanceConfig config, InstanceInfo instanceInfo)
-
ApplicationInfoManager
@Deprecated public ApplicationInfoManager(EurekaInstanceConfig config)
Deprecated.
-
-
Method Detail
-
getInstance
@Deprecated public static ApplicationInfoManager getInstance()
Deprecated.please use DI instead
-
initComponent
public void initComponent(EurekaInstanceConfig config)
-
getInfo
public InstanceInfo getInfo()
Gets the information about this instance that is registered with eureka.- Returns:
- information about this instance that is registered with eureka.
-
getEurekaInstanceConfig
public EurekaInstanceConfig getEurekaInstanceConfig()
-
registerAppMetadata
public void registerAppMetadata(java.util.Map<java.lang.String,java.lang.String> appMetadata)
Register user-specific instance meta data. Application can send any other additional meta data that need to be accessed for other reasons.The data will be periodically sent to the eureka server. Please Note that metadata added via this method is not guaranteed to be submitted to the eureka servers upon initial registration, and may be submitted as an update at a subsequent time. If you want guaranteed metadata for initial registration, please use the mechanism described inEurekaInstanceConfig.getMetadataMap()- Parameters:
appMetadata- application specific meta data.
-
setInstanceStatus
public void setInstanceStatus(InstanceInfo.InstanceStatus status)
Set the status of this instance. Application can use this to indicate whether it is ready to receive traffic. Setting the status here also notifies all registered listeners of a status change event.- Parameters:
status- Status of the instance
-
setInstanceStatus
public void setInstanceStatus(InstanceInfo.InstanceStatus expectedStatus, InstanceInfo.InstanceStatus updateStatus)
Set the status of this instance only if the current status equals expected status in order to avoid concurrent modification. Application can use this to indicate whether it is ready to receive traffic. Setting the status here also notifies all registered listeners of a status change event.- Parameters:
expectedStatus- expected current Status of the instanceupdateStatus- Status of the instance to be set
-
registerStatusChangeListener
public void registerStatusChangeListener(ApplicationInfoManager.StatusChangeListener listener)
-
unregisterStatusChangeListener
public void unregisterStatusChangeListener(java.lang.String listenerId)
-
refreshDataCenterInfoIfRequired
public void refreshDataCenterInfoIfRequired()
Refetches the hostname to check if it has changed. If it has, the entireDataCenterInfois refetched and passed on to the eureka server on next heartbeat. seeInstanceInfo.getHostName()for explanation on why the hostname is used as the default address
-
refreshLeaseInfoIfRequired
public void refreshLeaseInfoIfRequired()
-
-