use of com.netflix.eureka.cluster.protocol.ReplicationList 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.ReplicationList in project eureka by Netflix.
the class PeerReplicationResourceTest method testRegisterBatching.
@Test
public void testRegisterBatching() throws Exception {
ReplicationList replicationList = new ReplicationList(newReplicationInstanceOf(Action.Register, instanceInfo));
Response response = peerReplicationResource.batchReplication(replicationList);
assertStatusOkReply(response);
verify(applicationResource, times(1)).addInstance(instanceInfo, "true");
}
use of com.netflix.eureka.cluster.protocol.ReplicationList in project eureka by Netflix.
the class PeerReplicationResourceTest method testStatusUpdate.
@Test
public void testStatusUpdate() throws Exception {
when(instanceResource.statusUpdate(anyString(), anyString(), anyString())).thenReturn(Response.ok().build());
ReplicationInstance replicationInstance = newReplicationInstanceOf(Action.StatusUpdate, instanceInfo);
Response response = peerReplicationResource.batchReplication(new ReplicationList(replicationInstance));
assertStatusOkReply(response);
verify(instanceResource, times(1)).statusUpdate(replicationInstance.getStatus(), "true", Long.toString(replicationInstance.getLastDirtyTimestamp()));
}
use of com.netflix.eureka.cluster.protocol.ReplicationList in project eureka by Netflix.
the class PeerEurekaNodeTest method expectSingleBatchRequest.
private ReplicationInstance expectSingleBatchRequest() throws InterruptedException {
HandledRequest handledRequest = httpReplicationClient.nextHandledRequest(30, TimeUnit.SECONDS);
assertThat(handledRequest, is(notNullValue()));
assertThat(handledRequest.getRequestType(), is(equalTo(RequestType.Batch)));
Object data = handledRequest.getData();
assertThat(data, is(instanceOf(ReplicationList.class)));
List<ReplicationInstance> replications = ((ReplicationList) data).getReplicationList();
assertThat(replications.size(), is(equalTo(1)));
return replications.get(0);
}
use of com.netflix.eureka.cluster.protocol.ReplicationList in project eureka by Netflix.
the class EurekaCodecCompatibilityTest method testBatchRequestEncoding.
@Test
public void testBatchRequestEncoding() throws Exception {
InstanceInfo instance = InstanceInfoGenerator.takeOne();
List<ReplicationInstance> replicationInstances = new ArrayList<>();
replicationInstances.add(new ReplicationInstance(instance.getAppName(), instance.getId(), System.currentTimeMillis(), null, instance.getStatus().name(), instance, Action.Register));
final ReplicationList replicationList = new ReplicationList(replicationInstances);
Action2 codingAction = new Action2() {
@Override
public void call(EncoderWrapper encodingCodec, DecoderWrapper decodingCodec) throws IOException {
String encodedString = encodingCodec.encode(replicationList);
ReplicationList decodedValue = decodingCodec.decode(encodedString, ReplicationList.class);
assertThat(decodedValue.getReplicationList().size(), is(equalTo(1)));
}
};
// In replication channel we use JSON only
List<CodecWrapper> jsonCodes = Arrays.asList(new CodecWrappers.JacksonJson(), new CodecWrappers.LegacyJacksonJson());
verifyAllPairs(codingAction, ReplicationList.class, jsonCodes);
}
Aggregations