Class PropertiesInstanceConfig
- java.lang.Object
-
- com.netflix.appinfo.AbstractInstanceConfig
-
- com.netflix.appinfo.PropertiesInstanceConfig
-
- All Implemented Interfaces:
EurekaInstanceConfig
- Direct Known Subclasses:
CloudInstanceConfig,MyDataCenterInstanceConfig
public abstract class PropertiesInstanceConfig extends AbstractInstanceConfig implements EurekaInstanceConfig
A properties basedInstanceInfoconfiguration.The information required for registration with eureka server is provided in a configuration file.The configuration file is searched for in the classpath with the name specified by the property eureka.client.props and with the suffix .properties. If the property is not specified, eureka-client.properties is assumed as the default.The properties that are looked up uses the namespace passed on to this class.
If the eureka.environment property is specified, additionally eureka-client-
.properties is loaded in addition to eureka-client.properties.
-
-
Field Summary
Fields Modifier and Type Field Description protected com.netflix.config.DynamicPropertyFactoryconfigInstanceprotected java.lang.Stringnamespace-
Fields inherited from class com.netflix.appinfo.AbstractInstanceConfig
DEFAULT_NAMESPACE
-
-
Constructor Summary
Constructors Constructor Description PropertiesInstanceConfig()PropertiesInstanceConfig(java.lang.String namespace)PropertiesInstanceConfig(java.lang.String namespace, DataCenterInfo info)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.StringgetAppGroupName()Get the name of the application group to be registered with eureka.java.lang.StringgetAppname()Get the name of the application to be registered with eureka.java.lang.StringgetASGName()Gets theAWS autoscaling group nameassociated with this instance.java.lang.String[]getDefaultAddressResolutionOrder()An instance's network addresses should be fully expressed in it'sDataCenterInfo.java.lang.StringgetHealthCheckUrl()Gets the absolute health check pageURLfor this instance.java.lang.StringgetHealthCheckUrlPath()Gets the relative health checkURLPath for this instance.java.lang.StringgetHomePageUrl()Gets the absolute home pageURLfor this instance.java.lang.StringgetHomePageUrlPath()Gets the relative home pageURLPath for this instance.java.lang.StringgetInstanceId()Get the unique Id (within the scope of the appName) of this instance to be registered with eureka.java.lang.StringgetIpAddress()Get the IPAdress of the instance.intgetLeaseExpirationDurationInSeconds()Indicates the time in seconds that the eureka server waits since it received the last heartbeat before it can remove this instance from its view and there by disallowing traffic to this instance.intgetLeaseRenewalIntervalInSeconds()Indicates how often (in seconds) the eureka client needs to send heartbeats to eureka server to indicate that it is still alive.java.util.Map<java.lang.String,java.lang.String>getMetadataMap()Gets the metadata map associated with the instance.java.lang.StringgetNamespace()Get the namespace used to find properties.intgetNonSecurePort()Get thenon-secureport on which the instance should receive traffic.java.lang.StringgetSecureHealthCheckUrl()Gets the absolute secure health check pageURLfor this instance.intgetSecurePort()Get theSecure porton which the instance should receive traffic.booleangetSecurePortEnabled()Indicates whether thesecureport should be enabled for traffic or not.java.lang.StringgetSecureVirtualHostName()Gets the secure virtual host name defined for this instance.java.lang.StringgetStatusPageUrl()Gets the absolute status pageURLfor this instance.java.lang.StringgetStatusPageUrlPath()Gets the relative status pageURLPath for this instance.java.lang.StringgetVirtualHostName()Gets the virtual host name defined for this instance.booleanisInstanceEnabledOnit()Indicates whether the instance should be enabled for taking traffic as soon as it is registered with eureka.booleanisNonSecurePortEnabled()Indicates whether thenon-secureport should be enabled for traffic or not.booleanshouldBroadcastPublicIpv4Addr()Indicates if the public ipv4 address of the instance should be advertised.-
Methods inherited from class com.netflix.appinfo.AbstractInstanceConfig
getDataCenterInfo, getHostName
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.netflix.appinfo.EurekaInstanceConfig
getDataCenterInfo, getHostName
-
-
-
-
Constructor Detail
-
PropertiesInstanceConfig
public PropertiesInstanceConfig()
-
PropertiesInstanceConfig
public PropertiesInstanceConfig(java.lang.String namespace)
-
PropertiesInstanceConfig
public PropertiesInstanceConfig(java.lang.String namespace, DataCenterInfo info)
-
-
Method Detail
-
isInstanceEnabledOnit
public boolean isInstanceEnabledOnit()
Description copied from interface:EurekaInstanceConfigIndicates whether the instance should be enabled for taking traffic as soon as it is registered with eureka. Sometimes the application might need to do some pre-processing before it is ready to take traffic. :( public API typos are the worst. I think this was meant to be "OnInit".- Specified by:
isInstanceEnabledOnitin interfaceEurekaInstanceConfig- Overrides:
isInstanceEnabledOnitin classAbstractInstanceConfig- Returns:
- true to immediately start taking traffic, false otherwise.
-
getNonSecurePort
public int getNonSecurePort()
Description copied from interface:EurekaInstanceConfigGet thenon-secureport on which the instance should receive traffic.- Specified by:
getNonSecurePortin interfaceEurekaInstanceConfig- Overrides:
getNonSecurePortin classAbstractInstanceConfig- Returns:
- the non-secure port on which the instance should receive traffic.
-
getSecurePort
public int getSecurePort()
Description copied from interface:EurekaInstanceConfigGet theSecure porton which the instance should receive traffic.- Specified by:
getSecurePortin interfaceEurekaInstanceConfig- Overrides:
getSecurePortin classAbstractInstanceConfig- Returns:
- the secure port on which the instance should receive traffic.
-
isNonSecurePortEnabled
public boolean isNonSecurePortEnabled()
Description copied from interface:EurekaInstanceConfigIndicates whether thenon-secureport should be enabled for traffic or not.- Specified by:
isNonSecurePortEnabledin interfaceEurekaInstanceConfig- Overrides:
isNonSecurePortEnabledin classAbstractInstanceConfig- Returns:
- true if the
non-secureport is enabled, false otherwise.
-
getSecurePortEnabled
public boolean getSecurePortEnabled()
Description copied from interface:EurekaInstanceConfigIndicates whether thesecureport should be enabled for traffic or not.- Specified by:
getSecurePortEnabledin interfaceEurekaInstanceConfig- Overrides:
getSecurePortEnabledin classAbstractInstanceConfig- Returns:
- true if the
secureport is enabled, false otherwise.
-
getLeaseRenewalIntervalInSeconds
public int getLeaseRenewalIntervalInSeconds()
Description copied from interface:EurekaInstanceConfigIndicates how often (in seconds) the eureka client needs to send heartbeats to eureka server to indicate that it is still alive. If the heartbeats are not received for the period specified inEurekaInstanceConfig.getLeaseExpirationDurationInSeconds(), eureka server will remove the instance from its view, there by disallowing traffic to this instance.Note that the instance could still not take traffic if it implements
HealthCheckCallbackand then decides to make itself unavailable.- Specified by:
getLeaseRenewalIntervalInSecondsin interfaceEurekaInstanceConfig- Overrides:
getLeaseRenewalIntervalInSecondsin classAbstractInstanceConfig- Returns:
- time in seconds
-
getLeaseExpirationDurationInSeconds
public int getLeaseExpirationDurationInSeconds()
Description copied from interface:EurekaInstanceConfigIndicates the time in seconds that the eureka server waits since it received the last heartbeat before it can remove this instance from its view and there by disallowing traffic to this instance.Setting this value too long could mean that the traffic could be routed to the instance even though the instance is not alive. Setting this value too small could mean, the instance may be taken out of traffic because of temporary network glitches.This value to be set to atleast higher than the value specified in
EurekaInstanceConfig.getLeaseRenewalIntervalInSeconds().- Specified by:
getLeaseExpirationDurationInSecondsin interfaceEurekaInstanceConfig- Overrides:
getLeaseExpirationDurationInSecondsin classAbstractInstanceConfig- Returns:
- value indicating time in seconds.
-
getVirtualHostName
public java.lang.String getVirtualHostName()
Description copied from interface:EurekaInstanceConfigGets the virtual host name defined for this instance.This is typically the way other instance would find this instance by using the virtual host name.Think of this as similar to the fully qualified domain name, that the users of your services will need to find this instance.
- Specified by:
getVirtualHostNamein interfaceEurekaInstanceConfig- Overrides:
getVirtualHostNamein classAbstractInstanceConfig- Returns:
- the string indicating the virtual host name which the clients use to call this service.
-
getSecureVirtualHostName
public java.lang.String getSecureVirtualHostName()
Description copied from interface:EurekaInstanceConfigGets the secure virtual host name defined for this instance.This is typically the way other instance would find this instance by using the secure virtual host name.Think of this as similar to the fully qualified domain name, that the users of your services will need to find this instance.
- Specified by:
getSecureVirtualHostNamein interfaceEurekaInstanceConfig- Overrides:
getSecureVirtualHostNamein classAbstractInstanceConfig- Returns:
- the string indicating the secure virtual host name which the clients use to call this service.
-
getASGName
public java.lang.String getASGName()
Description copied from interface:EurekaInstanceConfigGets theAWS autoscaling group nameassociated with this instance. This information is specifically used in an AWS environment to automatically put an instance out of service after the instance is launched and it has been disabled for traffic..- Specified by:
getASGNamein interfaceEurekaInstanceConfig- Overrides:
getASGNamein classAbstractInstanceConfig- Returns:
- the autoscaling group name associated with this instance.
-
getMetadataMap
public java.util.Map<java.lang.String,java.lang.String> getMetadataMap()
Gets the metadata map associated with the instance. The properties that will be looked up for this will benamespace + ".metadata".For instance, if the given namespace is
eureka.appinfo, the metadata keys are searched under the namespaceeureka.appinfo.metadata.- Specified by:
getMetadataMapin interfaceEurekaInstanceConfig- Overrides:
getMetadataMapin classAbstractInstanceConfig- Returns:
- Map containing application-specific metadata.
-
getInstanceId
public java.lang.String getInstanceId()
Description copied from interface:EurekaInstanceConfigGet the unique Id (within the scope of the appName) of this instance to be registered with eureka.- Specified by:
getInstanceIdin interfaceEurekaInstanceConfig- Returns:
- the (appname scoped) unique id for this instance
-
getAppname
public java.lang.String getAppname()
Description copied from interface:EurekaInstanceConfigGet the name of the application to be registered with eureka.- Specified by:
getAppnamein interfaceEurekaInstanceConfig- Returns:
- string denoting the name.
-
getAppGroupName
public java.lang.String getAppGroupName()
Description copied from interface:EurekaInstanceConfigGet the name of the application group to be registered with eureka.- Specified by:
getAppGroupNamein interfaceEurekaInstanceConfig- Returns:
- string denoting the name.
-
getIpAddress
public java.lang.String getIpAddress()
Description copied from interface:EurekaInstanceConfigGet the IPAdress of the instance. This information is for academic purposes only as the communication from other instances primarily happen using the information supplied inEurekaInstanceConfig.getHostName(boolean).- Specified by:
getIpAddressin interfaceEurekaInstanceConfig- Overrides:
getIpAddressin classAbstractInstanceConfig- Returns:
- the ip address of this instance.
-
getStatusPageUrlPath
public java.lang.String getStatusPageUrlPath()
Description copied from interface:EurekaInstanceConfigGets the relative status pageURLPath for this instance. The status page URL is then constructed out of theEurekaInstanceConfig.getHostName(boolean)and the type of communication - secure or unsecure as specified inEurekaInstanceConfig.getSecurePort()andEurekaInstanceConfig.getNonSecurePort().It is normally used for informational purposes for other services to find about the status of this instance. Users can provide a simple
HTMLindicating what is the current status of the instance.- Specified by:
getStatusPageUrlPathin interfaceEurekaInstanceConfig- Returns:
- - relative
URLthat specifies the status page.
-
getStatusPageUrl
public java.lang.String getStatusPageUrl()
Description copied from interface:EurekaInstanceConfigGets the absolute status pageURLfor this instance. The users can provide theEurekaInstanceConfig.getStatusPageUrlPath()if the status page resides in the same instance talking to eureka, else in the cases where the instance is a proxy for some other server, users can provide the fullURL. If the fullURLis provided it takes precedence.* It is normally used for informational purposes for other services to find about the status of this instance. Users can provide a simple
HTMLindicating what is the current status of the instance. . The fullURLshould follow the format http://${eureka.hostname}:7001/ where the value ${eureka.hostname} is replaced at runtime.- Specified by:
getStatusPageUrlin interfaceEurekaInstanceConfig- Returns:
- absolute status page URL of this instance.
-
getHomePageUrlPath
public java.lang.String getHomePageUrlPath()
Description copied from interface:EurekaInstanceConfigGets the relative home pageURLPath for this instance. The home page URL is then constructed out of theEurekaInstanceConfig.getHostName(boolean)and the type of communication - secure or unsecure as specified inEurekaInstanceConfig.getSecurePort()andEurekaInstanceConfig.getNonSecurePort().It is normally used for informational purposes for other services to use it as a landing page.
- Specified by:
getHomePageUrlPathin interfaceEurekaInstanceConfig- Returns:
- relative
URLthat specifies the home page.
-
getHomePageUrl
public java.lang.String getHomePageUrl()
Description copied from interface:EurekaInstanceConfigGets the absolute home pageURLfor this instance. The users can provide theEurekaInstanceConfig.getHomePageUrlPath()if the home page resides in the same instance talking to eureka, else in the cases where the instance is a proxy for some other server, users can provide the fullURL. If the fullURLis provided it takes precedence.It is normally used for informational purposes for other services to use it as a landing page. The full
URLshould follow the format http://${eureka.hostname}:7001/ where the value ${eureka.hostname} is replaced at runtime.- Specified by:
getHomePageUrlin interfaceEurekaInstanceConfig- Returns:
- absolute home page URL of this instance.
-
getHealthCheckUrlPath
public java.lang.String getHealthCheckUrlPath()
Description copied from interface:EurekaInstanceConfigGets the relative health checkURLPath for this instance. The health check page URL is then constructed out of theEurekaInstanceConfig.getHostName(boolean)and the type of communication - secure or unsecure as specified inEurekaInstanceConfig.getSecurePort()andEurekaInstanceConfig.getNonSecurePort().It is normally used for making educated decisions based on the health of the instance - for example, it can be used to determine whether to proceed deployments to an entire farm or stop the deployments without causing further damage.
- Specified by:
getHealthCheckUrlPathin interfaceEurekaInstanceConfig- Returns:
- - relative
URLthat specifies the health check page.
-
getHealthCheckUrl
public java.lang.String getHealthCheckUrl()
Description copied from interface:EurekaInstanceConfigGets the absolute health check pageURLfor this instance. The users can provide theEurekaInstanceConfig.getHealthCheckUrlPath()if the health check page resides in the same instance talking to eureka, else in the cases where the instance is a proxy for some other server, users can provide the fullURL. If the fullURLis provided it takes precedence.It is normally used for making educated decisions based on the health of the instance - for example, it can be used to determine whether to proceed deployments to an entire farm or stop the deployments without causing further damage. The full
URLshould follow the format http://${eureka.hostname}:7001/ where the value ${eureka.hostname} is replaced at runtime.- Specified by:
getHealthCheckUrlin interfaceEurekaInstanceConfig- Returns:
- absolute health check page URL of this instance.
-
getSecureHealthCheckUrl
public java.lang.String getSecureHealthCheckUrl()
Description copied from interface:EurekaInstanceConfigGets the absolute secure health check pageURLfor this instance. The users can provide theEurekaInstanceConfig.getSecureHealthCheckUrl()if the health check page resides in the same instance talking to eureka, else in the cases where the instance is a proxy for some other server, users can provide the fullURL. If the fullURLis provided it takes precedence.It is normally used for making educated decisions based on the health of the instance - for example, it can be used to determine whether to proceed deployments to an entire farm or stop the deployments without causing further damage. The full
URLshould follow the format http://${eureka.hostname}:7001/ where the value ${eureka.hostname} is replaced at runtime.- Specified by:
getSecureHealthCheckUrlin interfaceEurekaInstanceConfig- Returns:
- absolute health check page URL of this instance.
-
getDefaultAddressResolutionOrder
public java.lang.String[] getDefaultAddressResolutionOrder()
Description copied from interface:EurekaInstanceConfigAn instance's network addresses should be fully expressed in it'sDataCenterInfo. For example for instances in AWS, this will include the publicHostname, publicIp, privateHostname and privateIp, when available. TheInstanceInfowill further express a "default address", which is a field that can be configured by the registering instance to advertise it's default address. This configuration allowed for the expression of an ordered list of fields that can be used to resolve the default address. The exact field values will depend on the implementation details of the corresponding implementing DataCenterInfo types.- Specified by:
getDefaultAddressResolutionOrderin interfaceEurekaInstanceConfig- Returns:
- an ordered list of fields that should be used to preferentially resolve this instance's default address, empty String[] for default.
-
shouldBroadcastPublicIpv4Addr
public boolean shouldBroadcastPublicIpv4Addr()
Indicates if the public ipv4 address of the instance should be advertised.- Overrides:
shouldBroadcastPublicIpv4Addrin classAbstractInstanceConfig- Returns:
- true if the public ipv4 address of the instance should be advertised, false otherwise .
-
getNamespace
public java.lang.String getNamespace()
Description copied from interface:EurekaInstanceConfigGet the namespace used to find properties.- Specified by:
getNamespacein interfaceEurekaInstanceConfig- Returns:
- the namespace used to find properties.
-
-