Java Code Examples for com.alipay.remoting.Connection#addInvokeFuture()
The following examples show how to use
com.alipay.remoting.Connection#addInvokeFuture() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ScheduledDisconnectStrategyTest.java From sofa-bolt with Apache License 2.0 | 6 votes |
@Test public void testCloseFreshSelectConnections_bySystemSetting() throws RemotingException, InterruptedException { System.setProperty(Configs.RETRY_DETECT_PERIOD, "500"); System.setProperty(Configs.CONN_MONITOR_INITIAL_DELAY, "2000"); System.setProperty(Configs.CONN_MONITOR_PERIOD, "100"); System.setProperty(Configs.CONN_THRESHOLD, "0"); doInit(true, false); String addr = "127.0.0.1:" + port + "?zone=RZONE&_CONNECTIONNUM=1"; Url url = addressParser.parse(addr); final Connection connection = client.getConnection(url, 1000); connection.addInvokeFuture(new DefaultInvokeFuture(1, null, null, RpcCommandType.REQUEST, null)); Thread.sleep(2100); Assert.assertTrue(0 == clientDisConnectProcessor.getDisConnectTimes()); Assert.assertEquals(1, clientConnectProcessor.getConnectTimes()); connection.removeInvokeFuture(1); /* Monitor task sleep 500ms*/ Thread.sleep(100); Assert.assertTrue(0 <= clientDisConnectProcessor.getDisConnectTimes()); Thread.sleep(500); Assert.assertTrue(0 <= clientDisConnectProcessor.getDisConnectTimes()); }
Example 2
Source File: ScheduledDisconnectStrategyTest.java From sofa-bolt with Apache License 2.0 | 6 votes |
@Test public void testCloseFreshSelectConnections_byUserSetting() throws RemotingException, InterruptedException { System.setProperty(Configs.RETRY_DETECT_PERIOD, "500"); System.setProperty(Configs.CONN_MONITOR_INITIAL_DELAY, "2000"); System.setProperty(Configs.CONN_MONITOR_PERIOD, "100"); System.setProperty(Configs.CONN_THRESHOLD, "0"); doInit(false, true); String addr = "127.0.0.1:" + port + "?zone=RZONE&_CONNECTIONNUM=1"; Url url = addressParser.parse(addr); final Connection connection = client.getConnection(url, 1000); connection.addInvokeFuture(new DefaultInvokeFuture(1, null, null, RpcCommandType.REQUEST, null)); Thread.sleep(2100); Assert.assertTrue(0 == clientDisConnectProcessor.getDisConnectTimes()); Assert.assertEquals(1, clientConnectProcessor.getConnectTimes()); connection.removeInvokeFuture(1); /* Monitor task sleep 500ms*/ Thread.sleep(100); Assert.assertEquals(1, clientDisConnectProcessor.getDisConnectTimes()); Thread.sleep(500); Assert.assertTrue(0 <= clientDisConnectProcessor.getDisConnectTimes()); }
Example 3
Source File: ConnectionUtil.java From sofa-bolt with Apache License 2.0 | 4 votes |
public static void addIdGroupCallbackMapping(Integer id, InvokeFuture callback, Channel channel) { Connection connection = getConnectionFromChannel(channel); if (connection != null) { connection.addInvokeFuture(callback); } }