-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor eureka related classes to separate module
- Loading branch information
Showing
30 changed files
with
3,247 additions
and
449 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
zuul-core/src/main/java/com/netflix/netty/common/status/ServerStatus.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. | ||
|
@@ -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(); | ||
} | ||
} |
Oops, something went wrong.