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
ee067ed3
Unverified
Commit
ee067ed3
authored
Oct 23, 2017
by
Spencer Gibb
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'raiRaiyan-gh-2303'
parents
d7c13ada
b57dedb7
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
52 additions
and
3 deletions
+52
-3
CloudEurekaInstanceConfig.java
...ework/cloud/netflix/eureka/CloudEurekaInstanceConfig.java
+1
-0
EurekaClientAutoConfiguration.java
...k/cloud/netflix/eureka/EurekaClientAutoConfiguration.java
+9
-0
EurekaAutoServiceRegistration.java
...eureka/serviceregistry/EurekaAutoServiceRegistration.java
+10
-3
EurekaRegistration.java
...ud/netflix/eureka/serviceregistry/EurekaRegistration.java
+8
-0
EurekaClientAutoConfigurationTests.java
...ud/netflix/eureka/EurekaClientAutoConfigurationTests.java
+24
-0
No files found.
spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/CloudEurekaInstanceConfig.java
View file @
ee067ed3
...
...
@@ -24,5 +24,6 @@ import com.netflix.appinfo.InstanceInfo;
*/
public
interface
CloudEurekaInstanceConfig
extends
EurekaInstanceConfig
{
void
setNonSecurePort
(
int
port
);
void
setSecurePort
(
int
securePort
);
InstanceInfo
.
InstanceStatus
getInitialStatus
();
}
spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/EurekaClientAutoConfiguration.java
View file @
ee067ed3
...
...
@@ -126,13 +126,21 @@ public class EurekaClientAutoConfiguration {
String
hostname
=
eurekaPropertyResolver
.
getProperty
(
"hostname"
);
boolean
preferIpAddress
=
Boolean
.
parseBoolean
(
eurekaPropertyResolver
.
getProperty
(
"preferIpAddress"
));
boolean
isSecurePortEnabled
=
Boolean
.
parseBoolean
(
eurekaPropertyResolver
.
getProperty
(
"securePortEnabled"
));
int
nonSecurePort
=
Integer
.
valueOf
(
propertyResolver
.
getProperty
(
"server.port"
,
propertyResolver
.
getProperty
(
"port"
,
"8080"
)));
int
managementPort
=
Integer
.
valueOf
(
propertyResolver
.
getProperty
(
"management.port"
,
String
.
valueOf
(
nonSecurePort
)));
String
managementContextPath
=
propertyResolver
.
getProperty
(
"management.contextPath"
,
propertyResolver
.
getProperty
(
"server.contextPath"
,
"/"
));
EurekaInstanceConfigBean
instance
=
new
EurekaInstanceConfigBean
(
inetUtils
);
instance
.
setNonSecurePort
(
nonSecurePort
);
instance
.
setInstanceId
(
getDefaultInstanceId
(
propertyResolver
));
instance
.
setPreferIpAddress
(
preferIpAddress
);
if
(
isSecurePortEnabled
)
{
int
securePort
=
Integer
.
valueOf
(
propertyResolver
.
getProperty
(
"server.port"
,
propertyResolver
.
getProperty
(
"port"
,
"8080"
)));
instance
.
setSecurePort
(
securePort
);
}
if
(
managementPort
!=
nonSecurePort
&&
managementPort
!=
0
)
{
if
(
StringUtils
.
hasText
(
hostname
))
{
instance
.
setHostname
(
hostname
);
...
...
@@ -148,6 +156,7 @@ public class EurekaClientAutoConfiguration {
if
(
StringUtils
.
hasText
(
healthCheckUrlPath
))
{
instance
.
setHealthCheckUrlPath
(
healthCheckUrlPath
);
}
String
scheme
=
instance
.
getSecurePortEnabled
()
?
"https"
:
"http"
;
URL
base
=
new
URL
(
scheme
,
instance
.
getHostname
(),
managementPort
,
managementContextPath
);
instance
.
setStatusPageUrl
(
new
URL
(
base
,
StringUtils
.
trimLeadingCharacter
(
instance
.
getStatusPageUrlPath
(),
'/'
)).
toString
());
...
...
spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/serviceregistry/EurekaAutoServiceRegistration.java
View file @
ee067ed3
...
...
@@ -36,6 +36,7 @@ import org.springframework.core.Ordered;
* @author Spencer Gibb
* @author Jon Schneider
* @author Jakub Narloch
* @author raiyan
*/
public
class
EurekaAutoServiceRegistration
implements
AutoServiceRegistration
,
SmartLifecycle
,
Ordered
{
...
...
@@ -61,9 +62,15 @@ public class EurekaAutoServiceRegistration implements AutoServiceRegistration, S
@Override
public
void
start
()
{
// only set the port if the nonSecurePort is 0 and this.port != 0
if
(
this
.
port
.
get
()
!=
0
&&
this
.
registration
.
getNonSecurePort
()
==
0
)
{
this
.
registration
.
setNonSecurePort
(
this
.
port
.
get
());
// only set the port if the nonSecurePort or securePort is 0 and this.port != 0
if
(
this
.
port
.
get
()
!=
0
)
{
if
(
this
.
registration
.
getNonSecurePort
()
==
0
)
{
this
.
registration
.
setNonSecurePort
(
this
.
port
.
get
());
}
if
(
this
.
registration
.
getSecurePort
()
==
0
&&
this
.
registration
.
isSecure
())
{
this
.
registration
.
setSecurePort
(
this
.
port
.
get
());
}
}
// only initialize if nonSecurePort is greater than 0 and it isn't already running
...
...
spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/serviceregistry/EurekaRegistration.java
View file @
ee067ed3
...
...
@@ -193,6 +193,14 @@ public class EurekaRegistration implements Registration, Closeable {
return
this
.
instanceConfig
.
getNonSecurePort
();
}
public
void
setSecurePort
(
int
port
)
{
this
.
instanceConfig
.
setSecurePort
(
port
);
}
public
int
getSecurePort
()
{
return
this
.
instanceConfig
.
getSecurePort
();
}
@Override
public
void
close
()
throws
IOException
{
this
.
eurekaClient
.
shutdown
();
...
...
spring-cloud-netflix-eureka-client/src/test/java/org/springframework/cloud/netflix/eureka/EurekaClientAutoConfigurationTests.java
View file @
ee067ed3
...
...
@@ -92,6 +92,23 @@ public class EurekaClientAutoConfigurationTests {
}
@Test
public
void
securePortPeriods
()
{
testSecurePort
(
"server.port"
);
}
@Test
public
void
securePortUnderscores
()
{
testSecurePort
(
"SERVER_PORT"
);
}
@Test
public
void
securePort
()
{
testSecurePort
(
"PORT"
);
assertEquals
(
"eurekaClient"
,
this
.
context
.
getBeanDefinition
(
"eurekaClient"
).
getFactoryMethodName
());
}
@Test
public
void
managementPort
()
{
EnvironmentTestUtils
.
addEnvironment
(
this
.
context
,
"server.port=8989"
,
"management.port=9999"
);
...
...
@@ -331,6 +348,13 @@ public class EurekaClientAutoConfigurationTests {
assertEquals
(
8888
,
getInstanceConfig
().
getNonSecurePort
());
}
private
void
testSecurePort
(
String
propName
)
{
EnvironmentTestUtils
.
addEnvironment
(
this
.
context
,
"eureka.instance.securePortEnabled=true"
);
addEnvironment
(
this
.
context
,
propName
+
":8443"
);
setupContext
();
assertEquals
(
8443
,
getInstanceConfig
().
getSecurePort
());
}
private
EurekaInstanceConfigBean
getInstanceConfig
()
{
return
this
.
context
.
getBean
(
EurekaInstanceConfigBean
.
class
);
}
...
...
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