use of com.netflix.eureka.cluster.protocol.ReplicationList 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 (maybeReadTimeOut(e)) {
logger.error("It seems to be a socket read timeout exception, it will retry later. if it continues to happen and some eureka node occupied all the cpu time, you should set property 'eureka.server.peer-node-read-timeout-ms' to a bigger value", e);
// read timeout exception is more Congestion then TransientError, return Congestion for longer delay
return ProcessingResult.Congestion;
} else 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.ReplicationList in project eureka by Netflix.
the class PeerReplicationResourceTest method testCancelBatching.
@Test
public void testCancelBatching() throws Exception {
when(instanceResource.cancelLease(anyString())).thenReturn(Response.ok().build());
ReplicationList replicationList = new ReplicationList(newReplicationInstanceOf(Action.Cancel, instanceInfo));
Response response = peerReplicationResource.batchReplication(replicationList);
assertStatusOkReply(response);
verify(instanceResource, times(1)).cancelLease("true");
}
use of com.netflix.eureka.cluster.protocol.ReplicationList in project eureka by Netflix.
the class PeerReplicationResourceTest method testDeleteStatusOverride.
@Test
public void testDeleteStatusOverride() throws Exception {
when(instanceResource.deleteStatusUpdate(anyString(), anyString(), anyString())).thenReturn(Response.ok().build());
ReplicationInstance replicationInstance = newReplicationInstanceOf(Action.DeleteStatusOverride, instanceInfo);
Response response = peerReplicationResource.batchReplication(new ReplicationList(replicationInstance));
assertStatusOkReply(response);
verify(instanceResource, times(1)).deleteStatusUpdate("true", replicationInstance.getStatus(), Long.toString(replicationInstance.getLastDirtyTimestamp()));
}
use of com.netflix.eureka.cluster.protocol.ReplicationList in project eureka by Netflix.
the class PeerReplicationResourceTest method testHeartbeat.
@Test
public void testHeartbeat() throws Exception {
when(instanceResource.renewLease(anyString(), anyString(), anyString(), anyString())).thenReturn(Response.ok().build());
ReplicationInstance replicationInstance = newReplicationInstanceOf(Action.Heartbeat, instanceInfo);
Response response = peerReplicationResource.batchReplication(new ReplicationList(replicationInstance));
assertStatusOkReply(response);
verify(instanceResource, times(1)).renewLease("true", replicationInstance.getOverriddenStatus(), instanceInfo.getStatus().name(), Long.toString(replicationInstance.getLastDirtyTimestamp()));
}
use of com.netflix.eureka.cluster.protocol.ReplicationList in project eureka by Netflix.
the class PeerReplicationResourceTest method testConflictResponseReturnsTheInstanceInfoInTheResponseEntity.
@Test
public void testConflictResponseReturnsTheInstanceInfoInTheResponseEntity() throws Exception {
when(instanceResource.renewLease(anyString(), anyString(), anyString(), anyString())).thenReturn(Response.status(Status.CONFLICT).entity(instanceInfo).build());
ReplicationInstance replicationInstance = newReplicationInstanceOf(Action.Heartbeat, instanceInfo);
Response response = peerReplicationResource.batchReplication(new ReplicationList(replicationInstance));
assertStatusIsConflict(response);
assertResponseEntityExist(response);
}
Aggregations