use of com.netflix.appinfo.MyDataCenterInfo in project spring-cloud-netflix by spring-cloud.
the class EurekaControllerTests method setup.
@Before
public void setup() throws Exception {
PeerEurekaNodes peerEurekaNodes = mock(PeerEurekaNodes.class);
when(peerEurekaNodes.getPeerNodesView()).thenReturn(Collections.<PeerEurekaNode>emptyList());
InstanceInfo instanceInfo = InstanceInfo.Builder.newBuilder().setAppName("test").setDataCenterInfo(new MyDataCenterInfo(DataCenterInfo.Name.MyOwn)).build();
this.infoManager = mock(ApplicationInfoManager.class);
this.original = ApplicationInfoManager.getInstance();
setInstance(this.infoManager);
when(this.infoManager.getInfo()).thenReturn(instanceInfo);
Application myapp = new Application("myapp");
myapp.addInstance(InstanceInfo.Builder.newBuilder().setAppName("myapp").setDataCenterInfo(new MyDataCenterInfo(DataCenterInfo.Name.MyOwn)).setInstanceId("myapp:1").build());
ArrayList<Application> applications = new ArrayList<>();
applications.add(myapp);
PeerAwareInstanceRegistry registry = mock(PeerAwareInstanceRegistry.class);
when(registry.getSortedApplications()).thenReturn(applications);
EurekaServerContext serverContext = mock(EurekaServerContext.class);
EurekaServerContextHolder.initialize(serverContext);
when(serverContext.getRegistry()).thenReturn(registry);
when(serverContext.getPeerEurekaNodes()).thenReturn(peerEurekaNodes);
when(serverContext.getApplicationInfoManager()).thenReturn(this.infoManager);
}
use of com.netflix.appinfo.MyDataCenterInfo in project eureka by Netflix.
the class ResolverUtilsTest method testInstanceInfoToEndpoint.
@Test
public void testInstanceInfoToEndpoint() throws Exception {
EurekaClientConfig clientConfig = mock(EurekaClientConfig.class);
when(clientConfig.getEurekaServerURLContext()).thenReturn("/eureka");
when(clientConfig.getRegion()).thenReturn("region");
EurekaTransportConfig transportConfig = mock(EurekaTransportConfig.class);
when(transportConfig.applicationsResolverUseIp()).thenReturn(false);
AmazonInfo amazonInfo = AmazonInfo.Builder.newBuilder().addMetadata(AmazonInfo.MetaDataKey.availabilityZone, "us-east-1c").build();
InstanceInfo instanceWithAWSInfo = InstanceInfo.Builder.newBuilder().setAppName("appName").setHostName("hostName").setPort(8080).setDataCenterInfo(amazonInfo).build();
AwsEndpoint awsEndpoint = ResolverUtils.instanceInfoToEndpoint(clientConfig, transportConfig, instanceWithAWSInfo);
assertEquals("zone not equals.", "us-east-1c", awsEndpoint.getZone());
MyDataCenterInfo myDataCenterInfo = new MyDataCenterInfo(DataCenterInfo.Name.MyOwn);
InstanceInfo instanceWithMyDataInfo = InstanceInfo.Builder.newBuilder().setAppName("appName").setHostName("hostName").setPort(8080).setDataCenterInfo(myDataCenterInfo).add("zone", "us-east-1c").build();
awsEndpoint = ResolverUtils.instanceInfoToEndpoint(clientConfig, transportConfig, instanceWithMyDataInfo);
assertEquals("zone not equals.", "us-east-1c", awsEndpoint.getZone());
}
use of com.netflix.appinfo.MyDataCenterInfo in project eureka by Netflix.
the class EurekaCodecCompatibilityTest method testInstanceInfoFullEncodeMiniDecodeJacksonWithMyOwnDataCenterInfo.
@Test
public void testInstanceInfoFullEncodeMiniDecodeJacksonWithMyOwnDataCenterInfo() throws Exception {
final InstanceInfo base = infoIterator.next();
final InstanceInfo instanceInfo = new InstanceInfo.Builder(base).setDataCenterInfo(new MyDataCenterInfo(DataCenterInfo.Name.MyOwn)).build();
Action2 codingAction = new Action2() {
@Override
public void call(EncoderWrapper encodingCodec, DecoderWrapper decodingCodec) throws IOException {
String encodedString = encodingCodec.encode(instanceInfo);
InstanceInfo decodedValue = decodingCodec.decode(encodedString, InstanceInfo.class);
assertThat(EurekaEntityComparators.equalMini(instanceInfo, decodedValue), is(true));
}
};
verifyForPair(codingAction, InstanceInfo.class, new CodecWrappers.JacksonJson(), new CodecWrappers.JacksonJsonMini());
}
use of com.netflix.appinfo.MyDataCenterInfo in project ribbon by Netflix.
the class LoadBalancerTestUtils method getDummyInstanceInfo.
static List<InstanceInfo> getDummyInstanceInfo(String appName, String host, String ipAddr, int port) {
List<InstanceInfo> list = new ArrayList<InstanceInfo>();
InstanceInfo info = InstanceInfo.Builder.newBuilder().setAppName(appName).setHostName(host).setIPAddr(ipAddr).setPort(port).setDataCenterInfo(new MyDataCenterInfo(DataCenterInfo.Name.MyOwn)).build();
list.add(info);
return list;
}
use of com.netflix.appinfo.MyDataCenterInfo in project eureka by Netflix.
the class ConfigClusterResolverTest method setUp.
@Before
public void setUp() {
when(clientConfig.shouldUseDnsForFetchingServiceUrls()).thenReturn(false);
when(clientConfig.getRegion()).thenReturn("us-east-1");
when(clientConfig.getAvailabilityZones("us-east-1")).thenReturn(new String[] { "us-east-1c", "us-east-1d", "us-east-1e" });
when(clientConfig.getEurekaServerServiceUrls("us-east-1c")).thenReturn(endpointsC);
when(clientConfig.getEurekaServerServiceUrls("us-east-1d")).thenReturn(endpointsD);
when(clientConfig.getEurekaServerServiceUrls("us-east-1e")).thenReturn(endpointsWithBasicAuth);
InstanceInfo instanceInfo = new InstanceInfo.Builder(InstanceInfoGenerator.takeOne()).setDataCenterInfo(new MyDataCenterInfo(DataCenterInfo.Name.MyOwn)).build();
resolver = new ConfigClusterResolver(clientConfig, instanceInfo);
}
Aggregations