Search in sources :

Example 31 with Application

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

the class BackUpRegistryTest method setupBackupMock.

private void setupBackupMock() {
    Application localApp = createLocalApps();
    Applications localApps = new Applications();
    localApps.addApplication(localApp);
    backupRegistry.setLocalRegionApps(localApps);
    Application remoteApp = createRemoteApps();
    Applications remoteApps = new Applications();
    remoteApps.addApplication(remoteApp);
    backupRegistry.getRemoteRegionVsApps().put(REMOTE_REGION, remoteApps);
}
Also used : Applications(com.netflix.discovery.shared.Applications) Application(com.netflix.discovery.shared.Application)

Example 32 with Application

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

the class BackUpRegistryTest method testRemoteEnabledAndQueried.

@Test
public void testRemoteEnabledAndQueried() throws Exception {
    setUp(true);
    Applications applications = client.getApplicationsForARegion(REMOTE_REGION);
    List<Application> registeredApplications = applications.getRegisteredApplications();
    Assert.assertNotNull("Remote region apps not found.", registeredApplications);
    Assert.assertEquals("Remote apps size not as expected.", 1, registeredApplications.size());
    Assert.assertEquals("Remote region apps not present.", REMOTE_REGION_APP_NAME, registeredApplications.get(0).getName());
}
Also used : Applications(com.netflix.discovery.shared.Applications) Application(com.netflix.discovery.shared.Application) Test(org.junit.Test)

Example 33 with Application

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

the class BaseDiscoveryClientTester method createRemoteAppsDelta.

protected static List<Application> createRemoteAppsDelta() {
    Application myapp1 = new Application(REMOTE_REGION_APP1_NAME);
    InstanceInfo instanceInfo1 = createInstance(REMOTE_REGION_APP1_NAME, ALL_REGIONS_VIP1_ADDR, REMOTE_REGION_APP1_INSTANCE2_HOSTNAME, REMOTE_ZONE);
    instanceInfo1.setActionType(InstanceInfo.ActionType.ADDED);
    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_INSTANCE2_HOSTNAME, REMOTE_ZONE);
    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 34 with Application

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

the class AbstractJerseyEurekaHttpClient method getApplication.

@Override
public EurekaHttpResponse<Application> getApplication(String appName) {
    String urlPath = "apps/" + appName;
    ClientResponse response = null;
    try {
        Builder requestBuilder = jerseyClient.resource(serviceUrl).path(urlPath).getRequestBuilder();
        addExtraHeaders(requestBuilder);
        response = requestBuilder.accept(MediaType.APPLICATION_JSON_TYPE).get(ClientResponse.class);
        Application application = null;
        if (response.getStatus() == Status.OK.getStatusCode() && response.hasEntity()) {
            application = response.getEntity(Application.class);
        }
        return anEurekaHttpResponse(response.getStatus(), Application.class).headers(headersOf(response)).entity(application).build();
    } finally {
        if (logger.isDebugEnabled()) {
            logger.debug("Jersey HTTP GET {}/{}; statusCode={}", serviceUrl, urlPath, response == null ? "N/A" : response.getStatus());
        }
        if (response != null) {
            response.close();
        }
    }
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) EurekaHttpResponseBuilder(com.netflix.discovery.shared.transport.EurekaHttpResponse.EurekaHttpResponseBuilder) Builder(com.sun.jersey.api.client.WebResource.Builder) Application(com.netflix.discovery.shared.Application)

Example 35 with Application

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

the class EurekaCodecCompatibilityTest method testApplicationEncodeDecode.

@Test
public void testApplicationEncodeDecode() throws Exception {
    final Application application = new Application("testApp");
    application.addInstance(infoIterator.next());
    application.addInstance(infoIterator.next());
    Action2 codingAction = new Action2() {

        @Override
        public void call(EncoderWrapper encodingCodec, DecoderWrapper decodingCodec) throws IOException {
            String encodedString = encodingCodec.encode(application);
            Application decodedValue = decodingCodec.decode(encodedString, Application.class);
            assertThat(EurekaEntityComparators.equal(application, decodedValue), is(true));
        }
    };
    verifyAllPairs(codingAction, Application.class, availableJsonWrappers);
    verifyAllPairs(codingAction, Application.class, availableXmlWrappers);
}
Also used : DecoderWrapper(com.netflix.discovery.converters.wrappers.DecoderWrapper) Application(com.netflix.discovery.shared.Application) EncoderWrapper(com.netflix.discovery.converters.wrappers.EncoderWrapper) Test(org.junit.Test)

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