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
dd97b6a4
Commit
dd97b6a4
authored
Oct 07, 2016
by
Bartłomiej Słota
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#1376 Register and cancel event sending fix
parent
ba3923d7
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
50 additions
and
16 deletions
+50
-16
InstanceRegistry.java
...amework/cloud/netflix/eureka/server/InstanceRegistry.java
+50
-16
No files found.
spring-cloud-netflix-eureka-server/src/main/java/org/springframework/cloud/netflix/eureka/server/InstanceRegistry.java
View file @
dd97b6a4
...
...
@@ -18,6 +18,7 @@ package org.springframework.cloud.netflix.eureka.server;
import
java.util.List
;
import
com.netflix.eureka.lease.Lease
;
import
org.springframework.beans.BeansException
;
import
org.springframework.cloud.netflix.eureka.server.event.EurekaInstanceCanceledEvent
;
import
org.springframework.cloud.netflix.eureka.server.event.EurekaInstanceRegisteredEvent
;
...
...
@@ -78,27 +79,23 @@ public class InstanceRegistry extends PeerAwareInstanceRegistryImpl
@Override
public
void
register
(
InstanceInfo
info
,
int
leaseDuration
,
boolean
isReplication
)
{
if
(
log
.
isDebugEnabled
())
{
log
.
debug
(
"register "
+
info
.
getAppName
()
+
", vip "
+
info
.
getVIPAddress
()
+
", leaseDuration "
+
leaseDuration
+
", isReplication "
+
isReplication
);
}
// TODO: what to publish from info (whole object?)
this
.
ctxt
.
publishEvent
(
new
EurekaInstanceRegisteredEvent
(
this
,
info
,
leaseDuration
,
isReplication
));
logRegistration
(
info
,
isReplication
,
leaseDuration
);
publishEurekaInstanceRegisteredEvent
(
info
,
leaseDuration
,
isReplication
);
super
.
register
(
info
,
leaseDuration
,
isReplication
);
}
@Override
public
boolean
cancel
(
String
appName
,
String
serverId
,
boolean
isReplication
)
{
if
(
log
.
isDebugEnabled
())
{
log
.
debug
(
"cancel "
+
appName
+
" serverId "
+
serverId
+
", isReplication {}"
+
isReplication
);
}
this
.
ctxt
.
publishEvent
(
new
EurekaInstanceCanceledEvent
(
this
,
appName
,
serverId
,
isReplication
));
public
void
register
(
final
InstanceInfo
info
,
final
boolean
isReplication
)
{
final
int
instanceLeaseDuration
=
resolveInstanceLeaseDuration
(
info
);
logRegistration
(
info
,
isReplication
,
instanceLeaseDuration
);
publishEurekaInstanceRegisteredEvent
(
info
,
instanceLeaseDuration
,
isReplication
);
super
.
register
(
info
,
isReplication
);
}
@Override
public
boolean
cancel
(
String
appName
,
String
serverId
,
boolean
isReplication
)
{
logCancelation
(
appName
,
serverId
,
isReplication
);
publishEurekaInstanceCanceledEvent
(
appName
,
serverId
,
isReplication
);
return
super
.
cancel
(
appName
,
serverId
,
isReplication
);
}
...
...
@@ -126,4 +123,41 @@ public class InstanceRegistry extends PeerAwareInstanceRegistryImpl
}
return
super
.
renew
(
appName
,
serverId
,
isReplication
);
}
@Override
protected
boolean
internalCancel
(
String
appName
,
String
id
,
boolean
isReplication
)
{
logCancelation
(
appName
,
id
,
isReplication
);
publishEurekaInstanceCanceledEvent
(
appName
,
id
,
isReplication
);
return
super
.
internalCancel
(
appName
,
id
,
isReplication
);
}
private
void
logRegistration
(
InstanceInfo
info
,
boolean
isReplication
,
int
instanceLeaseDuration
)
{
if
(
log
.
isDebugEnabled
())
{
log
.
debug
(
"register "
+
info
.
getAppName
()
+
", vip "
+
info
.
getVIPAddress
()
+
", leaseDuration "
+
instanceLeaseDuration
+
", isReplication "
+
isReplication
);
}
}
private
void
logCancelation
(
String
appName
,
String
serverId
,
boolean
isReplication
)
{
if
(
log
.
isDebugEnabled
())
{
log
.
debug
(
"cancel "
+
appName
+
" serverId "
+
serverId
+
", isReplication "
+
isReplication
);
}
}
private
void
publishEurekaInstanceRegisteredEvent
(
InstanceInfo
info
,
int
leaseDuration
,
boolean
isReplication
)
{
// TODO: what to publish from info (whole object?)
this
.
ctxt
.
publishEvent
(
new
EurekaInstanceRegisteredEvent
(
this
,
info
,
leaseDuration
,
isReplication
));
}
private
void
publishEurekaInstanceCanceledEvent
(
String
appName
,
String
serverId
,
boolean
isReplication
)
{
this
.
ctxt
.
publishEvent
(
new
EurekaInstanceCanceledEvent
(
this
,
appName
,
serverId
,
isReplication
));
}
private
int
resolveInstanceLeaseDuration
(
final
InstanceInfo
info
)
{
int
leaseDuration
=
Lease
.
DEFAULT_DURATION_IN_SECS
;
if
(
info
.
getLeaseInfo
()
!=
null
&&
info
.
getLeaseInfo
().
getDurationInSecs
()
>
0
)
{
leaseDuration
=
info
.
getLeaseInfo
().
getDurationInSecs
();
}
return
leaseDuration
;
}
}
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