use of com.netflix.discovery.DefaultEurekaClientConfig in project riposte by Nike-Inc.
the class EurekaHandler method register.
public void register() {
if (isEurekaDisabled()) {
logger.info("Eureka is disabled, skipping instance's eureka registration.");
return;
}
if (!registered.compareAndSet(false, true)) {
logger.info("Eureka handler already registered, skipping registration.");
return;
}
EurekaInstanceConfig eurekaInstanceConfig = createEurekaInstanceConfig();
initDiscoveryManager(eurekaInstanceConfig, new DefaultEurekaClientConfig(eurekaClientNamespace));
setEurekaInstanceStatus(InstanceInfo.InstanceStatus.UP);
}
use of com.netflix.discovery.DefaultEurekaClientConfig in project eureka by Netflix.
the class ResponseCacheTest method setUp.
@Override
@Before
public void setUp() throws Exception {
super.setUp();
// create a new registry that is sync'ed up with the default registry in the AbstractTester,
// but disable transparent fetch to the remote for gets
EurekaServerConfig serverConfig = spy(new DefaultEurekaServerConfig());
doReturn(true).when(serverConfig).disableTransparentFallbackToOtherRegion();
testRegistry = new PeerAwareInstanceRegistryImpl(serverConfig, new DefaultEurekaClientConfig(), new DefaultServerCodecs(serverConfig), client);
testRegistry.init(serverContext.getPeerEurekaNodes());
testRegistry.syncUp();
}
use of com.netflix.discovery.DefaultEurekaClientConfig in project eureka by Netflix.
the class ExampleEurekaService method main.
public static void main(String[] args) {
DynamicPropertyFactory configInstance = com.netflix.config.DynamicPropertyFactory.getInstance();
ApplicationInfoManager applicationInfoManager = initializeApplicationInfoManager(new MyDataCenterInstanceConfig());
EurekaClient eurekaClient = initializeEurekaClient(applicationInfoManager, new DefaultEurekaClientConfig());
ExampleServiceBase exampleServiceBase = new ExampleServiceBase(applicationInfoManager, eurekaClient, configInstance);
try {
exampleServiceBase.start();
} finally {
// the stop calls shutdown on eurekaClient
exampleServiceBase.stop();
}
}
use of com.netflix.discovery.DefaultEurekaClientConfig in project eureka by Netflix.
the class DiscoveryClientResource method setupInjector.
public static EurekaClient setupInjector(InstanceInfo clientInstanceInfo) {
DefaultEurekaClientConfig config = new DefaultEurekaClientConfig();
// setup config in advance, used in initialize converter
DiscoveryManager.getInstance().setEurekaClientConfig(config);
EurekaClient client = new DiscoveryClient(clientInstanceInfo, config);
ApplicationInfoManager.getInstance().initComponent(new MyDataCenterInstanceConfig());
return client;
}
use of com.netflix.discovery.DefaultEurekaClientConfig in project eureka by Netflix.
the class DiscoveryClientResource method createEurekaClientConfig.
private EurekaClientConfig createEurekaClientConfig() throws Exception {
// Cluster connectivity
URI serviceURI;
if (portResolverCallable != null) {
serviceURI = new URI("http://localhost:" + portResolverCallable.call() + "/eureka/v2/");
} else if (eurekaHttpServer != null) {
serviceURI = eurekaHttpServer.getServiceURI();
} else {
throw new IllegalStateException("Either port or EurekaHttpServer must be configured");
}
if (userName != null) {
serviceURI = UriBuilder.fromUri(serviceURI).userInfo(userName + ':' + password).build();
}
bindProperty(EUREKA_TEST_NAMESPACE + "serviceUrl.default", serviceURI.toString());
if (remoteRegions != null && !remoteRegions.isEmpty()) {
StringBuilder regions = new StringBuilder();
for (String region : remoteRegions) {
regions.append(',').append(region);
}
bindProperty(EUREKA_TEST_NAMESPACE + "fetchRemoteRegionsRegistry", regions.substring(1));
}
// Registration
bindProperty(EUREKA_TEST_NAMESPACE + "registration.enabled", Boolean.toString(registrationEnabled));
bindProperty(EUREKA_TEST_NAMESPACE + "appinfo.initial.replicate.time", Integer.toString(0));
bindProperty(EUREKA_TEST_NAMESPACE + "appinfo.replicate.interval", Integer.toString(1));
// Registry fetch
bindProperty(EUREKA_TEST_NAMESPACE + "shouldFetchRegistry", Boolean.toString(registryFetchEnabled));
bindProperty(EUREKA_TEST_NAMESPACE + "client.refresh.interval", Integer.toString(1));
if (vipFetch != null) {
bindProperty(EUREKA_TEST_NAMESPACE + "registryRefreshSingleVipAddress", vipFetch);
}
return new DefaultEurekaClientConfig(EUREKA_TEST_NAMESPACE);
}
Aggregations