Skip to content

Commit

Permalink
Refactor eureka related classes to separate module
Browse files Browse the repository at this point in the history
  • Loading branch information
asafalima committed Jan 31, 2020
1 parent 0362066 commit 3c15f57
Show file tree
Hide file tree
Showing 30 changed files with 3,247 additions and 449 deletions.
1 change: 1 addition & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
rootProject.name='zuul'

include 'zuul-core'
include 'zuul-eureka'
include 'zuul-sample'
3 changes: 0 additions & 3 deletions zuul-core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ apply plugin: "groovy"
apply plugin: "com.google.osdetector"

dependencies {

compile "log4j:log4j:1.2.17"
compile "commons-io:commons-io:2.4"
compile "commons-fileupload:commons-fileupload:1.3"
Expand All @@ -26,8 +25,6 @@ dependencies {
compile "com.netflix.ribbon:ribbon-core:${versions_ribbon}"
compile "com.netflix.ribbon:ribbon-httpclient:${versions_ribbon}"
compile "com.netflix.ribbon:ribbon-loadbalancer:${versions_ribbon}"
compile "com.netflix.ribbon:ribbon-eureka:${versions_ribbon}"
compile "com.netflix.eureka:eureka-client:1.9.4"
compile "io.reactivex:rxjava:1.2.1"

compile "io.netty:netty-common:${versions_netty}"
Expand Down
100 changes: 14 additions & 86 deletions zuul-core/dependencies.lock
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,9 @@
"requested": "4.2.2"
},
"com.netflix.archaius:archaius-core": {
"locked": "0.7.6",
"locked": "0.7.5",
"requested": "0.7.5"
},
"com.netflix.eureka:eureka-client": {
"locked": "1.9.4",
"requested": "1.9.4"
},
"com.netflix.governator:governator": {
"locked": "1.17.10",
"requested": "1.+"
Expand All @@ -64,10 +60,6 @@
"locked": "2.2.4",
"requested": "2.2.4"
},
"com.netflix.ribbon:ribbon-eureka": {
"locked": "2.2.4",
"requested": "2.2.4"
},
"com.netflix.ribbon:ribbon-httpclient": {
"locked": "2.2.4",
"requested": "2.2.4"
Expand All @@ -77,7 +69,7 @@
"requested": "2.2.4"
},
"com.netflix.servo:servo-core": {
"locked": "0.12.21",
"locked": "0.10.1",
"requested": "0.7.2"
},
"com.netflix.spectator:spectator-api": {
Expand Down Expand Up @@ -226,10 +218,6 @@
"locked": "0.7.5",
"requested": "0.7.5"
},
"com.netflix.eureka:eureka-client": {
"locked": "1.9.4",
"requested": "1.9.4"
},
"com.netflix.governator:governator": {
"locked": "1.17.10",
"requested": "1.+"
Expand All @@ -250,10 +238,6 @@
"locked": "2.2.4",
"requested": "2.2.4"
},
"com.netflix.ribbon:ribbon-eureka": {
"locked": "2.2.4",
"requested": "2.2.4"
},
"com.netflix.ribbon:ribbon-httpclient": {
"locked": "2.2.4",
"requested": "2.2.4"
Expand Down Expand Up @@ -409,13 +393,9 @@
"requested": "4.2.2"
},
"com.netflix.archaius:archaius-core": {
"locked": "0.7.6",
"locked": "0.7.5",
"requested": "0.7.5"
},
"com.netflix.eureka:eureka-client": {
"locked": "1.9.4",
"requested": "1.9.4"
},
"com.netflix.governator:governator": {
"locked": "1.17.10",
"requested": "1.+"
Expand All @@ -436,10 +416,6 @@
"locked": "2.2.4",
"requested": "2.2.4"
},
"com.netflix.ribbon:ribbon-eureka": {
"locked": "2.2.4",
"requested": "2.2.4"
},
"com.netflix.ribbon:ribbon-httpclient": {
"locked": "2.2.4",
"requested": "2.2.4"
Expand All @@ -449,7 +425,7 @@
"requested": "2.2.4"
},
"com.netflix.servo:servo-core": {
"locked": "0.12.21",
"locked": "0.10.1",
"requested": "0.7.2"
},
"com.netflix.spectator:spectator-api": {
Expand Down Expand Up @@ -599,13 +575,9 @@
"requested": "4.2.2"
},
"com.netflix.archaius:archaius-core": {
"locked": "0.7.6",
"locked": "0.7.5",
"requested": "0.7.5"
},
"com.netflix.eureka:eureka-client": {
"locked": "1.9.4",
"requested": "1.9.4"
},
"com.netflix.governator:governator": {
"locked": "1.17.10",
"requested": "1.+"
Expand All @@ -626,10 +598,6 @@
"locked": "2.2.4",
"requested": "2.2.4"
},
"com.netflix.ribbon:ribbon-eureka": {
"locked": "2.2.4",
"requested": "2.2.4"
},
"com.netflix.ribbon:ribbon-httpclient": {
"locked": "2.2.4",
"requested": "2.2.4"
Expand All @@ -639,7 +607,7 @@
"requested": "2.2.4"
},
"com.netflix.servo:servo-core": {
"locked": "0.12.21",
"locked": "0.10.1",
"requested": "0.7.2"
},
"com.netflix.spectator:spectator-api": {
Expand Down Expand Up @@ -789,13 +757,9 @@
"requested": "4.2.2"
},
"com.netflix.archaius:archaius-core": {
"locked": "0.7.6",
"locked": "0.7.5",
"requested": "0.7.5"
},
"com.netflix.eureka:eureka-client": {
"locked": "1.9.4",
"requested": "1.9.4"
},
"com.netflix.governator:governator": {
"locked": "1.17.10",
"requested": "1.+"
Expand All @@ -816,10 +780,6 @@
"locked": "2.2.4",
"requested": "2.2.4"
},
"com.netflix.ribbon:ribbon-eureka": {
"locked": "2.2.4",
"requested": "2.2.4"
},
"com.netflix.ribbon:ribbon-httpclient": {
"locked": "2.2.4",
"requested": "2.2.4"
Expand All @@ -829,7 +789,7 @@
"requested": "2.2.4"
},
"com.netflix.servo:servo-core": {
"locked": "0.12.21",
"locked": "0.10.1",
"requested": "0.7.2"
},
"com.netflix.spectator:spectator-api": {
Expand Down Expand Up @@ -979,13 +939,9 @@
"requested": "4.2.2"
},
"com.netflix.archaius:archaius-core": {
"locked": "0.7.6",
"locked": "0.7.5",
"requested": "0.7.5"
},
"com.netflix.eureka:eureka-client": {
"locked": "1.9.4",
"requested": "1.9.4"
},
"com.netflix.governator:governator": {
"locked": "1.17.10",
"requested": "1.+"
Expand All @@ -1010,10 +966,6 @@
"locked": "2.2.4",
"requested": "2.2.4"
},
"com.netflix.ribbon:ribbon-eureka": {
"locked": "2.2.4",
"requested": "2.2.4"
},
"com.netflix.ribbon:ribbon-httpclient": {
"locked": "2.2.4",
"requested": "2.2.4"
Expand All @@ -1023,7 +975,7 @@
"requested": "2.2.4"
},
"com.netflix.servo:servo-core": {
"locked": "0.12.21",
"locked": "0.10.1",
"requested": "0.7.2"
},
"com.netflix.spectator:spectator-api": {
Expand Down Expand Up @@ -1172,10 +1124,6 @@
"locked": "0.7.5",
"requested": "0.7.5"
},
"com.netflix.eureka:eureka-client": {
"locked": "1.9.4",
"requested": "1.9.4"
},
"com.netflix.governator:governator": {
"locked": "1.17.10",
"requested": "1.+"
Expand All @@ -1200,10 +1148,6 @@
"locked": "2.2.4",
"requested": "2.2.4"
},
"com.netflix.ribbon:ribbon-eureka": {
"locked": "2.2.4",
"requested": "2.2.4"
},
"com.netflix.ribbon:ribbon-httpclient": {
"locked": "2.2.4",
"requested": "2.2.4"
Expand Down Expand Up @@ -1359,13 +1303,9 @@
"requested": "4.2.2"
},
"com.netflix.archaius:archaius-core": {
"locked": "0.7.6",
"locked": "0.7.5",
"requested": "0.7.5"
},
"com.netflix.eureka:eureka-client": {
"locked": "1.9.4",
"requested": "1.9.4"
},
"com.netflix.governator:governator": {
"locked": "1.17.10",
"requested": "1.+"
Expand All @@ -1390,10 +1330,6 @@
"locked": "2.2.4",
"requested": "2.2.4"
},
"com.netflix.ribbon:ribbon-eureka": {
"locked": "2.2.4",
"requested": "2.2.4"
},
"com.netflix.ribbon:ribbon-httpclient": {
"locked": "2.2.4",
"requested": "2.2.4"
Expand All @@ -1403,7 +1339,7 @@
"requested": "2.2.4"
},
"com.netflix.servo:servo-core": {
"locked": "0.12.21",
"locked": "0.10.1",
"requested": "0.7.2"
},
"com.netflix.spectator:spectator-api": {
Expand Down Expand Up @@ -1557,13 +1493,9 @@
"requested": "4.2.2"
},
"com.netflix.archaius:archaius-core": {
"locked": "0.7.6",
"locked": "0.7.5",
"requested": "0.7.5"
},
"com.netflix.eureka:eureka-client": {
"locked": "1.9.4",
"requested": "1.9.4"
},
"com.netflix.governator:governator": {
"locked": "1.17.10",
"requested": "1.+"
Expand All @@ -1588,10 +1520,6 @@
"locked": "2.2.4",
"requested": "2.2.4"
},
"com.netflix.ribbon:ribbon-eureka": {
"locked": "2.2.4",
"requested": "2.2.4"
},
"com.netflix.ribbon:ribbon-httpclient": {
"locked": "2.2.4",
"requested": "2.2.4"
Expand All @@ -1601,7 +1529,7 @@
"requested": "2.2.4"
},
"com.netflix.servo:servo-core": {
"locked": "0.12.21",
"locked": "0.10.1",
"requested": "0.7.2"
},
"com.netflix.spectator:spectator-api": {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.netflix.netty.common.status;

public enum ServerStatus {
UP,
DOWN
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2018 Netflix, Inc.
* Copyright 2020 Netflix, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -16,66 +16,8 @@

package com.netflix.netty.common.status;

import com.netflix.appinfo.ApplicationInfoManager;
import com.netflix.appinfo.InstanceInfo;
import com.netflix.discovery.DiscoveryClient;
public interface ServerStatusManager {

import javax.inject.Inject;
import javax.inject.Singleton;
void localStatus(ServerStatus status);

import static com.netflix.appinfo.InstanceInfo.InstanceStatus.UNKNOWN;
import static com.netflix.appinfo.InstanceInfo.InstanceStatus.UP;

/**
* User: [email protected]
* Date: 7/6/17
* Time: 3:37 PM
*/
@Singleton
public class ServerStatusManager
{
private final ApplicationInfoManager applicationInfoManager;
private final DiscoveryClient discoveryClient;

@Inject
public ServerStatusManager(ApplicationInfoManager applicationInfoManager, DiscoveryClient discoveryClient)
{
this.applicationInfoManager = applicationInfoManager;
this.discoveryClient = discoveryClient;
}

public InstanceInfo.InstanceStatus status() {

// NOTE: when debugging this locally, found to my surprise that when the instance is maked OUT_OF_SERVICE remotely
// in Discovery, although the StatusChangeEvent does get fired, the _local_ InstanceStatus (ie.
// applicationInfoManager.getInfo().getStatus()) does not get changed to reflect that.
// So that's why I'm doing this little dance here of looking at both remote and local statuses.

InstanceInfo.InstanceStatus local = localStatus();
InstanceInfo.InstanceStatus remote = remoteStatus();

if (local == UP && remote != UNKNOWN) {
return remote;
}
else {
return local;
}
}

public InstanceInfo.InstanceStatus localStatus() {
return applicationInfoManager.getInfo().getStatus();
}

public InstanceInfo.InstanceStatus remoteStatus() {
return discoveryClient.getInstanceRemoteStatus();
}

public void localStatus(InstanceInfo.InstanceStatus status) {
applicationInfoManager.setInstanceStatus(status);
}

public int health() {
// TODO
throw new UnsupportedOperationException();
}
}
Loading

0 comments on commit 3c15f57

Please sign in to comment.