use of com.navercorp.pinpoint.rpc.Future in project pinpoint by naver.
the class RequestManagerTest method testRemoveMessageFuture.
@Test
public void testRemoveMessageFuture() throws Exception {
HashedWheelTimer timer = getTimer();
RequestManager requestManager = new RequestManager(timer, 3000);
try {
RequestPacket packet = new RequestPacket(1, new byte[0]);
DefaultFuture future = requestManager.register(packet, 2000);
future.setFailure(new RuntimeException());
Future nullFuture = requestManager.removeMessageFuture(packet.getRequestId());
Assert.assertNull(nullFuture);
} finally {
requestManager.close();
timer.stop();
}
}
use of com.navercorp.pinpoint.rpc.Future in project pinpoint by naver.
the class RequestManagerTest method testRegisterRequest.
@Test
public void testRegisterRequest() throws Exception {
HashedWheelTimer timer = getTimer();
RequestManager requestManager = new RequestManager(timer, 3000);
try {
RequestPacket packet = new RequestPacket(new byte[0]);
final Future future = requestManager.register(packet, 50);
TestAwaitUtils.await(new TestAwaitTaskUtils() {
@Override
public boolean checkCompleted() {
return future.isReady();
}
}, 10, 200);
Assert.assertTrue(future.isReady());
Assert.assertFalse(future.isSuccess());
Assert.assertTrue(future.getCause().getMessage().contains("timeout"));
logger.debug(future.getCause().getMessage());
} finally {
requestManager.close();
timer.stop();
}
}
use of com.navercorp.pinpoint.rpc.Future in project pinpoint by naver.
the class PinpointClientFactoryTest method throwWriteBufferFullExceptionTest.
@Test(expected = PinpointSocketException.class)
@Ignore
public void throwWriteBufferFullExceptionTest() {
TestPinpointServerAcceptor testPinpointServerAcceptor = new TestPinpointServerAcceptor();
int bindPort = testPinpointServerAcceptor.bind();
int defaultWriteBufferHighWaterMark = clientFactory.getWriteBufferHighWaterMark();
int defaultWriteBufferLowWaterMark = clientFactory.getWriteBufferLowWaterMark();
try {
clientFactory.setWriteBufferHighWaterMark(2);
clientFactory.setWriteBufferLowWaterMark(1);
PinpointClient client = clientFactory.connect("127.0.0.1", bindPort);
List<Future> futureList = new ArrayList();
for (int i = 0; i < 30; i++) {
Future<ResponseMessage> requestFuture = client.request(new byte[20]);
futureList.add(requestFuture);
}
for (Future future : futureList) {
future.getResult();
}
PinpointRPCTestUtils.close(client);
} finally {
clientFactory.setWriteBufferHighWaterMark(defaultWriteBufferHighWaterMark);
clientFactory.setWriteBufferLowWaterMark(defaultWriteBufferLowWaterMark);
testPinpointServerAcceptor.close();
}
}
use of com.navercorp.pinpoint.rpc.Future in project pinpoint by naver.
the class ReconnectTest method scheduledConnectStateTest.
@Test
public void scheduledConnectStateTest() {
int availableTcpPort = SocketUtils.findAvailableTcpPort(47000);
PinpointClient client = clientFactory.scheduledConnect("localhost", availableTcpPort);
client.send(new byte[10]);
try {
Future future = client.sendAsync(new byte[10]);
future.await();
future.getResult();
Assert.fail();
} catch (PinpointSocketException e) {
}
try {
client.sendSync(new byte[10]);
Assert.fail();
} catch (PinpointSocketException e) {
}
try {
PinpointRPCTestUtils.request(client, new byte[10]);
Assert.fail();
} catch (PinpointSocketException e) {
}
PinpointRPCTestUtils.close(client);
}
use of com.navercorp.pinpoint.rpc.Future in project pinpoint by naver.
the class TcpDataSender method doSend.
private void doSend(byte[] copy) {
Future write = this.client.sendAsync(copy);
write.setListener(writeFailFutureListener);
}
Aggregations