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
afdb5a31
Commit
afdb5a31
authored
Aug 18, 2014
by
Spencer Gibb
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'publish-eureka-events'
parents
1f63ea91
f8c0282f
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
37 additions
and
10 deletions
+37
-10
EurekaInstanceRegisteredEvent.java
...m/netflix/eureka/event/EurekaInstanceRegisteredEvent.java
+4
-5
EurekaInstanceRenewedEvent.java
...form/netflix/eureka/event/EurekaInstanceRenewedEvent.java
+4
-1
LeaseManagerMessageBroker.java
...tform/netflix/eureka/event/LeaseManagerMessageBroker.java
+29
-4
No files found.
spring-platform-netflix-core/src/main/java/org/springframework/platform/netflix/eureka/event/EurekaInstanceRegisteredEvent.java
View file @
afdb5a31
package
org
.
springframework
.
platform
.
netflix
.
eureka
.
event
;
package
org
.
springframework
.
platform
.
netflix
.
eureka
.
event
;
import
com.netflix.appinfo.InstanceInfo
;
import
lombok.Data
;
import
lombok.Data
;
import
org.springframework.context.ApplicationEvent
;
import
org.springframework.context.ApplicationEvent
;
...
@@ -8,15 +9,13 @@ import org.springframework.context.ApplicationEvent;
...
@@ -8,15 +9,13 @@ import org.springframework.context.ApplicationEvent;
*/
*/
@Data
@Data
public
class
EurekaInstanceRegisteredEvent
extends
ApplicationEvent
{
public
class
EurekaInstanceRegisteredEvent
extends
ApplicationEvent
{
private
String
appName
;
private
InstanceInfo
instanceInfo
;
private
String
vip
;
private
int
leaseDuration
;
private
int
leaseDuration
;
boolean
replication
;
boolean
replication
;
public
EurekaInstanceRegisteredEvent
(
Object
source
,
String
appName
,
String
vip
,
int
leaseDuration
,
boolean
replication
)
{
public
EurekaInstanceRegisteredEvent
(
Object
source
,
InstanceInfo
instanceInfo
,
int
leaseDuration
,
boolean
replication
)
{
super
(
source
);
super
(
source
);
this
.
appName
=
appName
;
this
.
instanceInfo
=
instanceInfo
;
this
.
vip
=
vip
;
this
.
leaseDuration
=
leaseDuration
;
this
.
leaseDuration
=
leaseDuration
;
this
.
replication
=
replication
;
this
.
replication
=
replication
;
}
}
...
...
spring-platform-netflix-core/src/main/java/org/springframework/platform/netflix/eureka/event/EurekaInstanceRenewedEvent.java
View file @
afdb5a31
package
org
.
springframework
.
platform
.
netflix
.
eureka
.
event
;
package
org
.
springframework
.
platform
.
netflix
.
eureka
.
event
;
import
com.netflix.appinfo.InstanceInfo
;
import
lombok.Data
;
import
lombok.Data
;
import
org.springframework.context.ApplicationEvent
;
import
org.springframework.context.ApplicationEvent
;
...
@@ -10,12 +11,14 @@ import org.springframework.context.ApplicationEvent;
...
@@ -10,12 +11,14 @@ import org.springframework.context.ApplicationEvent;
public
class
EurekaInstanceRenewedEvent
extends
ApplicationEvent
{
public
class
EurekaInstanceRenewedEvent
extends
ApplicationEvent
{
private
String
appName
;
private
String
appName
;
private
String
serverId
;
private
String
serverId
;
private
InstanceInfo
instanceInfo
;
boolean
replication
;
boolean
replication
;
public
EurekaInstanceRenewedEvent
(
Object
source
,
String
appName
,
String
serverId
,
boolean
replication
)
{
public
EurekaInstanceRenewedEvent
(
Object
source
,
String
appName
,
String
serverId
,
InstanceInfo
instanceInfo
,
boolean
replication
)
{
super
(
source
);
super
(
source
);
this
.
appName
=
appName
;
this
.
appName
=
appName
;
this
.
serverId
=
serverId
;
this
.
serverId
=
serverId
;
this
.
instanceInfo
=
instanceInfo
;
this
.
replication
=
replication
;
this
.
replication
=
replication
;
}
}
}
}
spring-platform-netflix-core/src/main/java/org/springframework/platform/netflix/eureka/event/LeaseManagerMessageBroker.java
View file @
afdb5a31
package
org
.
springframework
.
platform
.
netflix
.
eureka
.
event
;
package
org
.
springframework
.
platform
.
netflix
.
eureka
.
event
;
import
com.google.common.base.Optional
;
import
com.google.common.base.Predicate
;
import
com.netflix.appinfo.InstanceInfo
;
import
com.netflix.appinfo.InstanceInfo
;
import
com.netflix.discovery.DiscoveryManager
;
import
com.netflix.discovery.shared.Application
;
import
com.netflix.eureka.PeerAwareInstanceRegistry
;
import
com.netflix.eureka.lease.LeaseManager
;
import
com.netflix.eureka.lease.LeaseManager
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.ApplicationContext
;
import
org.springframework.context.ApplicationContext
;
import
javax.annotation.Nullable
;
import
java.util.List
;
import
static
com
.
google
.
common
.
collect
.
Iterables
.*;
/**
/**
* @author Spencer Gibb
* @author Spencer Gibb
*/
*/
...
@@ -21,8 +31,7 @@ public class LeaseManagerMessageBroker implements LeaseManager<InstanceInfo> {
...
@@ -21,8 +31,7 @@ public class LeaseManagerMessageBroker implements LeaseManager<InstanceInfo> {
logger
.
debug
(
"register {}, vip {}, leaseDuration {}, isReplication {}"
,
logger
.
debug
(
"register {}, vip {}, leaseDuration {}, isReplication {}"
,
info
.
getAppName
(),
info
.
getVIPAddress
(),
leaseDuration
,
isReplication
);
info
.
getAppName
(),
info
.
getVIPAddress
(),
leaseDuration
,
isReplication
);
//TODO: what to publish from info (whole object?)
//TODO: what to publish from info (whole object?)
ctxt
.
publishEvent
(
new
EurekaInstanceRegisteredEvent
(
this
,
info
.
getAppName
(),
ctxt
.
publishEvent
(
new
EurekaInstanceRegisteredEvent
(
this
,
info
,
leaseDuration
,
isReplication
));
info
.
getVIPAddress
(),
leaseDuration
,
isReplication
));
}
}
@Override
@Override
...
@@ -33,9 +42,25 @@ public class LeaseManagerMessageBroker implements LeaseManager<InstanceInfo> {
...
@@ -33,9 +42,25 @@ public class LeaseManagerMessageBroker implements LeaseManager<InstanceInfo> {
}
}
@Override
@Override
public
boolean
renew
(
String
appName
,
String
serverId
,
boolean
isReplication
)
{
public
boolean
renew
(
final
String
appName
,
final
String
serverId
,
boolean
isReplication
)
{
logger
.
debug
(
"renew {}, serverId {}, isReplication {}"
,
appName
,
serverId
,
isReplication
);
logger
.
debug
(
"renew {}, serverId {}, isReplication {}"
,
appName
,
serverId
,
isReplication
);
ctxt
.
publishEvent
(
new
EurekaInstanceRenewedEvent
(
this
,
appName
,
serverId
,
isReplication
));
List
<
Application
>
applications
=
PeerAwareInstanceRegistry
.
getInstance
().
getSortedApplications
();
Optional
<
Application
>
app
=
tryFind
(
applications
,
new
Predicate
<
Application
>()
{
@Override
public
boolean
apply
(
@Nullable
Application
input
)
{
return
input
.
getName
().
equals
(
appName
);
}
});
if
(
app
.
isPresent
())
{
Optional
<
InstanceInfo
>
info
=
tryFind
(
app
.
get
().
getInstances
(),
new
Predicate
<
InstanceInfo
>()
{
@Override
public
boolean
apply
(
@Nullable
InstanceInfo
input
)
{
return
input
.
getHostName
().
equals
(
serverId
);
}
});
ctxt
.
publishEvent
(
new
EurekaInstanceRenewedEvent
(
this
,
appName
,
serverId
,
info
.
orNull
(),
isReplication
));
}
return
false
;
return
false
;
}
}
...
...
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