Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
spring-cloud-netflix
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
openSource
spring-cloud-netflix
Commits
9149319b
Commit
9149319b
authored
Jul 10, 2015
by
Spencer Gibb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
implement getHostName where refresh==true
parent
aa63b072
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
8 deletions
+18
-8
EurekaInstanceConfigBean.java
...mework/cloud/netflix/eureka/EurekaInstanceConfigBean.java
+18
-8
No files found.
spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/eureka/EurekaInstanceConfigBean.java
View file @
9149319b
...
...
@@ -47,7 +47,7 @@ public class EurekaInstanceConfigBean implements EurekaInstanceConfig {
@Getter
(
AccessLevel
.
PRIVATE
)
@Setter
(
AccessLevel
.
PRIVATE
)
private
String
[]
hostInfo
=
initHostInfo
();
private
HostInfo
hostInfo
=
initHostInfo
();
@Value
(
"${spring.application.name:unknown}"
)
private
String
appname
=
"unknown"
;
...
...
@@ -79,7 +79,7 @@ public class EurekaInstanceConfigBean implements EurekaInstanceConfig {
private
DataCenterInfo
dataCenterInfo
=
new
IdentifyingDataCenterInfo
();
private
String
ipAddress
=
this
.
hostInfo
[
0
]
;
private
String
ipAddress
=
this
.
hostInfo
.
ipAddress
;
private
String
statusPageUrlPath
=
"/info"
;
...
...
@@ -97,14 +97,14 @@ public class EurekaInstanceConfigBean implements EurekaInstanceConfig {
private
String
namespace
=
"eureka"
;
private
String
hostname
=
this
.
hostInfo
[
1
]
;
private
String
hostname
=
this
.
hostInfo
.
hostname
;
private
boolean
preferIpAddress
=
false
;
private
InstanceStatus
initialStatus
=
InstanceStatus
.
UP
;
public
String
getHostname
()
{
return
this
.
preferIpAddress
?
this
.
ipAddress
:
this
.
hostname
;
return
getHostName
(
false
)
;
}
@Override
...
...
@@ -112,11 +112,11 @@ public class EurekaInstanceConfigBean implements EurekaInstanceConfig {
return
this
.
securePortEnabled
;
}
private
String
[]
initHostInfo
()
{
String
[]
info
=
new
String
[
2
]
;
private
HostInfo
initHostInfo
()
{
HostInfo
info
=
new
HostInfo
()
;
try
{
info
[
0
]
=
InetAddress
.
getLocalHost
().
getHostAddress
();
info
[
1
]
=
InetAddress
.
getLocalHost
().
getHostName
();
info
.
ipAddress
=
InetAddress
.
getLocalHost
().
getHostAddress
();
info
.
hostname
=
InetAddress
.
getLocalHost
().
getHostName
();
}
catch
(
UnknownHostException
ex
)
{
logger
.
error
(
"Cannot get host info"
,
ex
);
...
...
@@ -126,9 +126,19 @@ public class EurekaInstanceConfigBean implements EurekaInstanceConfig {
@Override
public
String
getHostName
(
boolean
refresh
)
{
if
(
refresh
)
{
this
.
hostInfo
=
initHostInfo
();
this
.
ipAddress
=
this
.
hostInfo
.
ipAddress
;
this
.
hostname
=
this
.
hostInfo
.
hostname
;
}
return
this
.
preferIpAddress
?
this
.
ipAddress
:
this
.
hostname
;
}
private
final
class
HostInfo
{
private
String
ipAddress
;
private
String
hostname
;
}
private
final
class
IdentifyingDataCenterInfo
implements
DataCenterInfo
,
UniqueIdentifier
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment