Search in sources :

Example 16 with DataCenterInfo

use of com.netflix.appinfo.DataCenterInfo in project eureka by Netflix.

the class ApplicationsTest method shuffleVirtualHostNameMapLastInstanceTest.

/**
     * Test that instancesMap in Application and shuffleVirtualHostNameMap in Applications are
     * correctly updated when the last instance is removed from an application and shuffleInstances
     * has been run.
     */
@Test
public void shuffleVirtualHostNameMapLastInstanceTest() {
    DataCenterInfo myDCI = new DataCenterInfo() {

        public DataCenterInfo.Name getName() {
            return DataCenterInfo.Name.MyOwn;
        }
    };
    InstanceInfo instanceInfo = InstanceInfo.Builder.newBuilder().setAppName("test").setVIPAddress("test.testname:1").setDataCenterInfo(myDCI).setHostName("test.hostname").build();
    Application application = new Application("TestApp");
    application.addInstance(instanceInfo);
    Applications applications = new Applications();
    applications.addApplication(application);
    applications.shuffleInstances(true);
    List<InstanceInfo> testApp = applications.getInstancesByVirtualHostName("test.testname:1");
    assertEquals(Iterables.getOnlyElement(testApp), application.getByInstanceId("test.hostname"));
    application.removeInstance(instanceInfo);
    applications.shuffleInstances(true);
    testApp = applications.getInstancesByVirtualHostName("test.testname:1");
    assertNull(application.getByInstanceId("test.hostname"));
    assertTrue(testApp.isEmpty());
}
Also used : DataCenterInfo(com.netflix.appinfo.DataCenterInfo) InstanceInfo(com.netflix.appinfo.InstanceInfo) Test(org.junit.Test)

Aggregations

DataCenterInfo (com.netflix.appinfo.DataCenterInfo)16 InstanceInfo (com.netflix.appinfo.InstanceInfo)10 AmazonInfo (com.netflix.appinfo.AmazonInfo)5 Test (org.junit.Test)5 ApplicationInfoManager (com.netflix.appinfo.ApplicationInfoManager)2 MyDataCenterInstanceConfig (com.netflix.appinfo.MyDataCenterInstanceConfig)2 UniqueIdentifier (com.netflix.appinfo.UniqueIdentifier)2 Before (org.junit.Before)2 HealthCheckHandler (com.netflix.appinfo.HealthCheckHandler)1 InstanceStatus (com.netflix.appinfo.InstanceInfo.InstanceStatus)1 LeaseInfo (com.netflix.appinfo.LeaseInfo)1 RefreshableInstanceConfig (com.netflix.appinfo.RefreshableInstanceConfig)1 Applications (com.netflix.discovery.shared.Applications)1 AwsEndpoint (com.netflix.discovery.shared.resolver.aws.AwsEndpoint)1 EurekaEntityFunctions.copyApplications (com.netflix.discovery.util.EurekaEntityFunctions.copyApplications)1 EurekaEntityFunctions.mergeApplications (com.netflix.discovery.util.EurekaEntityFunctions.mergeApplications)1 EurekaEntityFunctions.toApplications (com.netflix.discovery.util.EurekaEntityFunctions.toApplications)1 InstanceInfoGenerator (com.netflix.discovery.util.InstanceInfoGenerator)1 Map (java.util.Map)1 Consumes (javax.ws.rs.Consumes)1