Search in sources :

Example 11 with Application

use of com.netflix.discovery.shared.Application in project eureka by Netflix.

the class BackUpRegistryTest method testRemoteEnabledButLocalOnlyQueried.

@Test
public void testRemoteEnabledButLocalOnlyQueried() throws Exception {
    setUp(true);
    Applications applications = client.getApplications();
    List<Application> registeredApplications = applications.getRegisteredApplications();
    Assert.assertNotNull("Local region apps not found.", registeredApplications);
    // Remote region comes with no instances.
    Assert.assertEquals("Local apps size not as expected.", 2, registeredApplications.size());
    Application localRegionApp = null;
    Application remoteRegionApp = null;
    for (Application registeredApplication : registeredApplications) {
        if (registeredApplication.getName().equals(LOCAL_REGION_APP_NAME)) {
            localRegionApp = registeredApplication;
        } else if (registeredApplication.getName().equals(REMOTE_REGION_APP_NAME)) {
            remoteRegionApp = registeredApplication;
        }
    }
    Assert.assertNotNull("Local region apps not present.", localRegionApp);
    Assert.assertTrue("Remote region instances returned for local query.", null == remoteRegionApp || remoteRegionApp.getInstances().isEmpty());
}
Also used : Applications(com.netflix.discovery.shared.Applications) Application(com.netflix.discovery.shared.Application) Test(org.junit.Test)

Example 12 with Application

use of com.netflix.discovery.shared.Application in project eureka by Netflix.

the class BaseDiscoveryClientTester method createLocalApps.

protected static List<Application> createLocalApps() {
    Application myapp1 = new Application(LOCAL_REGION_APP1_NAME);
    InstanceInfo instanceInfo1 = createInstance(LOCAL_REGION_APP1_NAME, ALL_REGIONS_VIP1_ADDR, LOCAL_REGION_APP1_INSTANCE1_HOSTNAME, null);
    myapp1.addInstance(instanceInfo1);
    Application myapp2 = new Application(LOCAL_REGION_APP2_NAME);
    InstanceInfo instanceInfo2 = createInstance(LOCAL_REGION_APP2_NAME, ALL_REGIONS_VIP2_ADDR, LOCAL_REGION_APP2_INSTANCE1_HOSTNAME, null);
    myapp2.addInstance(instanceInfo2);
    return Arrays.asList(myapp1, myapp2);
}
Also used : Application(com.netflix.discovery.shared.Application) InstanceInfo(com.netflix.appinfo.InstanceInfo)

Example 13 with Application

use of com.netflix.discovery.shared.Application in project eureka by Netflix.

the class BaseDiscoveryClientTester method createRemoteApps.

protected static List<Application> createRemoteApps() {
    Application myapp1 = new Application(REMOTE_REGION_APP1_NAME);
    InstanceInfo instanceInfo1 = createInstance(REMOTE_REGION_APP1_NAME, ALL_REGIONS_VIP1_ADDR, REMOTE_REGION_APP1_INSTANCE1_HOSTNAME, REMOTE_ZONE);
    myapp1.addInstance(instanceInfo1);
    Application myapp2 = new Application(REMOTE_REGION_APP2_NAME);
    InstanceInfo instanceInfo2 = createInstance(REMOTE_REGION_APP2_NAME, ALL_REGIONS_VIP2_ADDR, REMOTE_REGION_APP2_INSTANCE1_HOSTNAME, REMOTE_ZONE);
    myapp2.addInstance(instanceInfo2);
    return Arrays.asList(myapp1, myapp2);
}
Also used : Application(com.netflix.discovery.shared.Application) InstanceInfo(com.netflix.appinfo.InstanceInfo)

Example 14 with Application

use of com.netflix.discovery.shared.Application in project eureka by Netflix.

the class BaseDiscoveryClientTester method createLocalAppsDelta.

protected static List<Application> createLocalAppsDelta() {
    Application myapp1 = new Application(LOCAL_REGION_APP1_NAME);
    InstanceInfo instanceInfo1 = createInstance(LOCAL_REGION_APP1_NAME, ALL_REGIONS_VIP1_ADDR, LOCAL_REGION_APP1_INSTANCE2_HOSTNAME, null);
    instanceInfo1.setActionType(InstanceInfo.ActionType.ADDED);
    myapp1.addInstance(instanceInfo1);
    Application myapp2 = new Application(LOCAL_REGION_APP2_NAME);
    InstanceInfo instanceInfo2 = createInstance(LOCAL_REGION_APP2_NAME, ALL_REGIONS_VIP2_ADDR, LOCAL_REGION_APP2_INSTANCE2_HOSTNAME, null);
    instanceInfo2.setActionType(InstanceInfo.ActionType.ADDED);
    myapp2.addInstance(instanceInfo2);
    return Arrays.asList(myapp1, myapp2);
}
Also used : Application(com.netflix.discovery.shared.Application) InstanceInfo(com.netflix.appinfo.InstanceInfo)

Example 15 with Application

use of com.netflix.discovery.shared.Application in project eureka by Netflix.

the class BaseDiscoveryClientTester method addLocalAppDelta.

protected void addLocalAppDelta() {
    Application myappDelta = new Application(LOCAL_REGION_APP3_NAME);
    InstanceInfo instanceInfo = createInstance(LOCAL_REGION_APP3_NAME, ALL_REGIONS_VIP3_ADDR, LOCAL_REGION_APP3_INSTANCE1_HOSTNAME, null);
    instanceInfo.setActionType(InstanceInfo.ActionType.ADDED);
    myappDelta.addInstance(instanceInfo);
    mockLocalEurekaServer.addLocalRegionAppsDelta(LOCAL_REGION_APP3_NAME, myappDelta);
}
Also used : Application(com.netflix.discovery.shared.Application) InstanceInfo(com.netflix.appinfo.InstanceInfo)

Aggregations

Application (com.netflix.discovery.shared.Application)60 InstanceInfo (com.netflix.appinfo.InstanceInfo)35 Applications (com.netflix.discovery.shared.Applications)25 Test (org.junit.Test)18 DecoderWrapper (com.netflix.discovery.converters.wrappers.DecoderWrapper)7 HashMap (java.util.HashMap)7 Response (javax.ws.rs.core.Response)7 CodecWrappers (com.netflix.discovery.converters.wrappers.CodecWrappers)6 Lease (com.netflix.eureka.lease.Lease)4 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)4 ByteArrayInputStream (java.io.ByteArrayInputStream)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3 InputStream (java.io.InputStream)3 ArrayList (java.util.ArrayList)3 EurekaHttpResponseBuilder (com.netflix.discovery.shared.transport.EurekaHttpResponse.EurekaHttpResponseBuilder)2 PeerEurekaNode (com.netflix.eureka.cluster.PeerEurekaNode)2 Map (java.util.Map)2 ConcurrentMap (java.util.concurrent.ConcurrentMap)2 JsonMappingException (com.fasterxml.jackson.databind.JsonMappingException)1 ApplicationInfoManager (com.netflix.appinfo.ApplicationInfoManager)1