use of com.netflix.eureka.cluster.protocol.ReplicationInstance 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);
}
use of com.netflix.eureka.cluster.protocol.ReplicationInstance 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.ReplicationInstance 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.ReplicationInstance in project eureka by Netflix.
the class PeerEurekaNodeTest method testCancelBatchReplication.
@Test
public void testCancelBatchReplication() throws Exception {
createPeerEurekaNode().cancel(instanceInfo.getAppName(), instanceInfo.getId());
ReplicationInstance replicationInstance = expectSingleBatchRequest();
assertThat(replicationInstance.getAction(), is(equalTo(Action.Cancel)));
}
use of com.netflix.eureka.cluster.protocol.ReplicationInstance in project eureka by Netflix.
the class PeerEurekaNodeTest method testHeartbeatBatchReplication.
@Test
public void testHeartbeatBatchReplication() throws Throwable {
createPeerEurekaNode().heartbeat(instanceInfo.getAppName(), instanceInfo.getId(), instanceInfo, null, false);
ReplicationInstance replicationInstance = expectSingleBatchRequest();
assertThat(replicationInstance.getAction(), is(equalTo(Action.Heartbeat)));
}
Aggregations