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)));
}
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)));
}
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()));
}
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();
}
}
}
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();
}
}
}
Aggregations