use of com.netflix.eureka.cluster.protocol.ReplicationInstanceResponse 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.ReplicationInstanceResponse 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.ReplicationInstanceResponse in project eureka by Netflix.
the class EurekaCodecCompatibilityTest method testBatchResponseEncoding.
@Test
public void testBatchResponseEncoding() throws Exception {
List<ReplicationInstanceResponse> responseList = new ArrayList<>();
responseList.add(new ReplicationInstanceResponse(200, InstanceInfoGenerator.takeOne()));
final ReplicationListResponse replicationListResponse = new ReplicationListResponse(responseList);
Action2 codingAction = new Action2() {
@Override
public void call(EncoderWrapper encodingCodec, DecoderWrapper decodingCodec) throws IOException {
String encodedString = encodingCodec.encode(replicationListResponse);
ReplicationListResponse decodedValue = decodingCodec.decode(encodedString, ReplicationListResponse.class);
assertThat(decodedValue.getResponseList().size(), is(equalTo(1)));
}
};
// In replication channel we use JSON only
List<CodecWrapper> jsonCodes = Arrays.asList(new CodecWrappers.JacksonJson(), new CodecWrappers.LegacyJacksonJson());
verifyAllPairs(codingAction, ReplicationListResponse.class, jsonCodes);
}
use of com.netflix.eureka.cluster.protocol.ReplicationInstanceResponse in project eureka by Netflix.
the class TestableHttpReplicationClient method submitBatchUpdates.
@Override
public EurekaHttpResponse<ReplicationListResponse> submitBatchUpdates(ReplicationList replicationList) {
if (networkFailureCounter.get() < networkFailuresRepeatCount) {
networkFailureCounter.incrementAndGet();
throw new RuntimeException(new IOException("simulated network failure"));
}
if (processingDelayMs > 0) {
try {
Thread.sleep(processingDelayMs);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}
List<ReplicationInstanceResponse> responseList = new ArrayList<>();
responseList.add(new ReplicationInstanceResponse(batchStatusCode, instanceInfoFromPeer));
ReplicationListResponse replicationListResponse = new ReplicationListResponse(responseList);
handledRequests.add(new HandledRequest(RequestType.Batch, replicationList));
int statusCode = networkStatusCodes[callCounter.getAndIncrement()];
return anEurekaHttpResponse(statusCode, replicationListResponse).type(MediaType.APPLICATION_JSON_TYPE).build();
}
Aggregations