forked from Netflix/eureka
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/master' into contrib/jersey2
- Loading branch information
Showing
57 changed files
with
1,908 additions
and
1,137 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
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 @@ | ||
This is a version of eureka-client that has been ported to use Archaius 2.x as the backing configuration system. Please note that this client is still work in progress. This client is also only java8 compatible (as Archaius 2.x is only java8 compatible). |
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
68 changes: 68 additions & 0 deletions
68
eureka-client-archaius2/src/main/java/com/netflix/appinfo/Archaius2AmazonInfoConfig.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,68 @@ | ||
package com.netflix.appinfo; | ||
|
||
import com.netflix.archaius.api.Config; | ||
import com.netflix.archaius.api.annotations.ConfigurationSource; | ||
import com.netflix.discovery.CommonConstants; | ||
|
||
import javax.inject.Inject; | ||
import javax.inject.Singleton; | ||
|
||
import static com.netflix.appinfo.PropertyBasedAmazonInfoConfigConstants.*; | ||
|
||
/** | ||
* @author David Liu | ||
*/ | ||
@Singleton | ||
@ConfigurationSource(CommonConstants.CONFIG_FILE_NAME) | ||
public class Archaius2AmazonInfoConfig implements AmazonInfoConfig { | ||
|
||
private final Config config; | ||
private final String namespace; | ||
|
||
@Inject | ||
public Archaius2AmazonInfoConfig(Config config) { | ||
this(config, CommonConstants.DEFAULT_CONFIG_NAMESPACE); | ||
} | ||
|
||
|
||
public Archaius2AmazonInfoConfig(Config config, String namespace) { | ||
this.namespace = namespace; | ||
this.config = config.getPrefixedView(namespace); | ||
} | ||
|
||
|
||
@Override | ||
public String getNamespace() { | ||
return namespace; | ||
} | ||
|
||
@Override | ||
public boolean shouldLogAmazonMetadataErrors() { | ||
return config.getBoolean(LOG_METADATA_ERROR_KEY, false); | ||
} | ||
|
||
@Override | ||
public int getReadTimeout() { | ||
return config.getInteger(READ_TIMEOUT_KEY, Values.DEFAULT_READ_TIMEOUT); | ||
} | ||
|
||
@Override | ||
public int getConnectTimeout() { | ||
return config.getInteger(CONNECT_TIMEOUT_KEY, Values.DEFAULT_CONNECT_TIMEOUT); | ||
} | ||
|
||
@Override | ||
public int getNumRetries() { | ||
return config.getInteger(NUM_RETRIES_KEY, Values.DEFAULT_NUM_RETRIES); | ||
} | ||
|
||
@Override | ||
public boolean shouldFailFastOnFirstLoad() { | ||
return config.getBoolean(FAIL_FAST_ON_FIRST_LOAD_KEY, true); | ||
} | ||
|
||
@Override | ||
public boolean shouldValidateInstanceId() { | ||
return config.getBoolean(SHOULD_VALIDATE_INSTANCE_ID_KEY, true); | ||
} | ||
} |
87 changes: 87 additions & 0 deletions
87
...-client-archaius2/src/main/java/com/netflix/appinfo/Ec2EurekaArchaius2InstanceConfig.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,87 @@ | ||
package com.netflix.appinfo; | ||
|
||
import javax.inject.Inject; | ||
import javax.inject.Singleton; | ||
|
||
import com.netflix.discovery.CommonConstants; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import com.netflix.appinfo.AmazonInfo.MetaDataKey; | ||
import com.netflix.archaius.api.Config; | ||
|
||
/** | ||
* When running in EC2 add the following override binding. | ||
* | ||
* bind(EurekaInstanceConfig.class).to(KaryonEc2EurekaInstanceConfig.class); | ||
* | ||
* | ||
* @author elandau | ||
* | ||
*/ | ||
@Singleton | ||
public class Ec2EurekaArchaius2InstanceConfig extends EurekaArchaius2InstanceConfig { | ||
private static final Logger LOG = LoggerFactory.getLogger(Ec2EurekaArchaius2InstanceConfig.class); | ||
|
||
private static final String[] DEFAULT_AWS_ADDRESS_RESOLUTION_ORDER = new String[] { | ||
MetaDataKey.publicHostname.name(), | ||
MetaDataKey.localIpv4.name() | ||
}; | ||
|
||
private final AmazonInfoConfig amazonInfoConfig; | ||
private final RefreshableAmazonInfoProvider amazonInfoHolder; | ||
|
||
@Inject | ||
public Ec2EurekaArchaius2InstanceConfig(Config config, AmazonInfoConfig amazonInfoConfig) { | ||
this(config, amazonInfoConfig, CommonConstants.DEFAULT_CONFIG_NAMESPACE); | ||
} | ||
|
||
public Ec2EurekaArchaius2InstanceConfig(Config config, AmazonInfoConfig amazonInfoConfig, String namespace) { | ||
super(config, namespace); | ||
this.amazonInfoConfig = amazonInfoConfig; | ||
|
||
RefreshableAmazonInfoProvider.FallbackAddressProvider fallbackAddressProvider = | ||
new RefreshableAmazonInfoProvider.FallbackAddressProvider() { | ||
@Override | ||
public String getFallbackIp() { | ||
return Ec2EurekaArchaius2InstanceConfig.super.getIpAddress(); | ||
} | ||
|
||
@Override | ||
public String getFallbackHostname() { | ||
return Ec2EurekaArchaius2InstanceConfig.super.getHostName(false); | ||
} | ||
}; | ||
this.amazonInfoHolder = new RefreshableAmazonInfoProvider(amazonInfoConfig, fallbackAddressProvider); | ||
} | ||
|
||
@Override | ||
public String getHostName(boolean refresh) { | ||
if (refresh) { | ||
amazonInfoHolder.refresh(); | ||
} | ||
return amazonInfoHolder.get().get(MetaDataKey.publicHostname); | ||
} | ||
|
||
@Override | ||
public DataCenterInfo getDataCenterInfo() { | ||
return amazonInfoHolder.get(); | ||
} | ||
|
||
@Override | ||
public String[] getDefaultAddressResolutionOrder() { | ||
String[] order = super.getDefaultAddressResolutionOrder(); | ||
return (order.length == 0) ? DEFAULT_AWS_ADDRESS_RESOLUTION_ORDER : order; | ||
} | ||
|
||
/** | ||
* @deprecated 2016-09-07 | ||
* | ||
* Refresh instance info - currently only used when in AWS cloud | ||
* as a public ip can change whenever an EIP is associated or dissociated. | ||
*/ | ||
@Deprecated | ||
public synchronized void refreshAmazonInfo() { | ||
amazonInfoHolder.refresh(); | ||
} | ||
} |
Oops, something went wrong.