Search in sources :

Example 1 with ReplicationListResponse

use of com.netflix.eureka.cluster.protocol.ReplicationListResponse in project eureka by Netflix.

the class PeerReplicationResourceTest method assertStatusOkReply.

private static void assertStatusOkReply(Response httpResponse) {
    ReplicationListResponse entity = (ReplicationListResponse) httpResponse.getEntity();
    assertThat(entity, is(notNullValue()));
    ReplicationInstanceResponse replicationResponse = entity.getResponseList().get(0);
    assertThat(replicationResponse.getStatusCode(), is(equalTo(200)));
}
Also used : ReplicationListResponse(com.netflix.eureka.cluster.protocol.ReplicationListResponse) ReplicationInstanceResponse(com.netflix.eureka.cluster.protocol.ReplicationInstanceResponse)

Example 2 with ReplicationListResponse

use of com.netflix.eureka.cluster.protocol.ReplicationListResponse in project eureka by Netflix.

the class EurekaClientServerRestIntegrationTest method testBatch.

@Test
public void testBatch() throws Exception {
    InstanceInfo instanceInfo = instanceInfoIt.next();
    ReplicationInstance replicationInstance = ReplicationInstance.replicationInstance().withAction(Action.Register).withAppName(instanceInfo.getAppName()).withId(instanceInfo.getId()).withInstanceInfo(instanceInfo).withLastDirtyTimestamp(System.currentTimeMillis()).withStatus(instanceInfo.getStatus().name()).build();
    EurekaHttpResponse<ReplicationListResponse> httpResponse = jerseyReplicationClient.submitBatchUpdates(new ReplicationList(replicationInstance));
    assertThat(httpResponse.getStatusCode(), is(equalTo(200)));
    List<ReplicationInstanceResponse> replicationListResponse = httpResponse.getEntity().getResponseList();
    assertThat(replicationListResponse.size(), is(equalTo(1)));
    assertThat(replicationListResponse.get(0).getStatusCode(), is(equalTo(200)));
}
Also used : ReplicationListResponse(com.netflix.eureka.cluster.protocol.ReplicationListResponse) ReplicationInstance(com.netflix.eureka.cluster.protocol.ReplicationInstance) ReplicationInstanceResponse(com.netflix.eureka.cluster.protocol.ReplicationInstanceResponse) ReplicationList(com.netflix.eureka.cluster.protocol.ReplicationList) InstanceInfo(com.netflix.appinfo.InstanceInfo) Test(org.junit.Test)

Example 3 with ReplicationListResponse

use of com.netflix.eureka.cluster.protocol.ReplicationListResponse in project eureka by Netflix.

the class PeerReplicationResourceTest method assertResponseEntityExist.

private static void assertResponseEntityExist(Response httpResponse) {
    ReplicationListResponse entity = (ReplicationListResponse) httpResponse.getEntity();
    assertThat(entity, is(notNullValue()));
    ReplicationInstanceResponse replicationResponse = entity.getResponseList().get(0);
    assertThat(replicationResponse.getResponseEntity(), is(notNullValue()));
}
Also used : ReplicationListResponse(com.netflix.eureka.cluster.protocol.ReplicationListResponse) ReplicationInstanceResponse(com.netflix.eureka.cluster.protocol.ReplicationInstanceResponse)

Example 4 with ReplicationListResponse

use of com.netflix.eureka.cluster.protocol.ReplicationListResponse in project eureka by Netflix.

the class Jersey2ReplicationClient method submitBatchUpdates.

@Override
public EurekaHttpResponse<ReplicationListResponse> submitBatchUpdates(ReplicationList replicationList) {
    Response response = null;
    try {
        response = jerseyClient.target(serviceUrl).path(PeerEurekaNode.BATCH_URL_PATH).request(MediaType.APPLICATION_JSON_TYPE).post(Entity.json(replicationList));
        if (!isSuccess(response.getStatus())) {
            return anEurekaHttpResponse(response.getStatus(), ReplicationListResponse.class).build();
        }
        ReplicationListResponse batchResponse = response.readEntity(ReplicationListResponse.class);
        return anEurekaHttpResponse(response.getStatus(), batchResponse).type(MediaType.APPLICATION_JSON_TYPE).build();
    } finally {
        if (response != null) {
            response.close();
        }
    }
}
Also used : EurekaHttpResponse(com.netflix.discovery.shared.transport.EurekaHttpResponse) EurekaHttpResponse.anEurekaHttpResponse(com.netflix.discovery.shared.transport.EurekaHttpResponse.anEurekaHttpResponse) ReplicationListResponse(com.netflix.eureka.cluster.protocol.ReplicationListResponse) Response(javax.ws.rs.core.Response) ReplicationListResponse(com.netflix.eureka.cluster.protocol.ReplicationListResponse)

Example 5 with ReplicationListResponse

use of com.netflix.eureka.cluster.protocol.ReplicationListResponse in project eureka by Netflix.

the class JerseyReplicationClient method submitBatchUpdates.

@Override
public EurekaHttpResponse<ReplicationListResponse> submitBatchUpdates(ReplicationList replicationList) {
    ClientResponse response = null;
    try {
        response = jerseyApacheClient.resource(serviceUrl).path(PeerEurekaNode.BATCH_URL_PATH).accept(MediaType.APPLICATION_JSON_TYPE).type(MediaType.APPLICATION_JSON_TYPE).post(ClientResponse.class, replicationList);
        if (!isSuccess(response.getStatus())) {
            return anEurekaHttpResponse(response.getStatus(), ReplicationListResponse.class).build();
        }
        ReplicationListResponse batchResponse = response.getEntity(ReplicationListResponse.class);
        return anEurekaHttpResponse(response.getStatus(), batchResponse).type(MediaType.APPLICATION_JSON_TYPE).build();
    } finally {
        if (response != null) {
            response.close();
        }
    }
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) ReplicationListResponse(com.netflix.eureka.cluster.protocol.ReplicationListResponse)

Aggregations

ReplicationListResponse (com.netflix.eureka.cluster.protocol.ReplicationListResponse)9 ReplicationInstanceResponse (com.netflix.eureka.cluster.protocol.ReplicationInstanceResponse)6 ReplicationList (com.netflix.eureka.cluster.protocol.ReplicationList)2 ArrayList (java.util.ArrayList)2 Test (org.junit.Test)2 InstanceInfo (com.netflix.appinfo.InstanceInfo)1 CodecWrapper (com.netflix.discovery.converters.wrappers.CodecWrapper)1 CodecWrappers (com.netflix.discovery.converters.wrappers.CodecWrappers)1 DecoderWrapper (com.netflix.discovery.converters.wrappers.DecoderWrapper)1 EncoderWrapper (com.netflix.discovery.converters.wrappers.EncoderWrapper)1 EurekaHttpResponse (com.netflix.discovery.shared.transport.EurekaHttpResponse)1 EurekaHttpResponse.anEurekaHttpResponse (com.netflix.discovery.shared.transport.EurekaHttpResponse.anEurekaHttpResponse)1 ReplicationInstance (com.netflix.eureka.cluster.protocol.ReplicationInstance)1 ClientResponse (com.sun.jersey.api.client.ClientResponse)1 IOException (java.io.IOException)1 SocketTimeoutException (java.net.SocketTimeoutException)1 Response (javax.ws.rs.core.Response)1