use of com.netflix.eureka.cluster.protocol.ReplicationListResponse in project eureka by Netflix.
the class ReplicationTaskProcessor method process.
@Override
public ProcessingResult process(List<ReplicationTask> tasks) {
ReplicationList list = createReplicationListOf(tasks);
try {
EurekaHttpResponse<ReplicationListResponse> response = replicationClient.submitBatchUpdates(list);
int statusCode = response.getStatusCode();
if (!isSuccess(statusCode)) {
if (statusCode == 503) {
logger.warn("Server busy (503) HTTP status code received from the peer {}; rescheduling tasks after delay", peerId);
return ProcessingResult.Congestion;
} else {
// Unexpected error returned from the server. This should ideally never happen.
logger.error("Batch update failure with HTTP status code {}; discarding {} replication tasks", statusCode, tasks.size());
return ProcessingResult.PermanentError;
}
} else {
handleBatchResponse(tasks, response.getEntity().getResponseList());
}
} catch (Throwable e) {
if (isNetworkConnectException(e)) {
logNetworkErrorSample(null, e);
return ProcessingResult.TransientError;
} else {
logger.error("Not re-trying this exception because it does not seem to be a network exception", e);
return ProcessingResult.PermanentError;
}
}
return ProcessingResult.Success;
}
use of com.netflix.eureka.cluster.protocol.ReplicationListResponse 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