use of com.alipay.sofa.rpc.listener.ChannelListener in project sofa-rpc by sofastack.
the class ServerConfigTest method testAll.
@Test
public void testAll() {
ServerConfig config = new ServerConfig();
config.setProtocol("bolt").setHost("127.0.0.2").setPort(54321).setContextPath("/").setIoThreads(4).setThreadPoolType("fixed").setCoreThreads(20).setMaxThreads(200).setTelnet(false).setQueueType("priority").setQueues(1024).setAliveTime(30000).setPreStartCore(true).setAccepts(30000).setPayload(10 * 1024 * 1024).setSerialization("protobuf").setDispatcher("message").setParameters(Collections.singletonMap("app", "app")).setVirtualHost("192.168.1.1").setVirtualPort(12345).setOnConnect(Arrays.<ChannelListener>asList(new ChannelListener() {
@Override
public void onConnected(AbstractChannel channel) {
}
@Override
public void onDisconnected(AbstractChannel channel) {
}
})).setEpoll(true).setDaemon(false).setAdaptivePort(true).setTransport("netty").setAutoStart(true).setStopTimeout(10000).setKeepAlive(true);
Assert.assertEquals("bolt", config.getProtocol());
Assert.assertEquals("127.0.0.2", config.getHost());
Assert.assertEquals(54321, config.getPort());
Assert.assertEquals("/", config.getContextPath());
Assert.assertEquals(4, config.getIoThreads());
Assert.assertEquals("fixed", config.getThreadPoolType());
Assert.assertEquals(20, config.getCoreThreads());
Assert.assertEquals(200, config.getMaxThreads());
Assert.assertEquals(false, config.isTelnet());
Assert.assertEquals("priority", config.getQueueType());
Assert.assertEquals(1024, config.getQueues());
Assert.assertEquals(30000, config.getAliveTime());
Assert.assertEquals(true, config.isPreStartCore());
Assert.assertEquals(30000, config.getAccepts());
Assert.assertEquals(10 * 1024 * 1024, config.getPayload());
Assert.assertEquals("protobuf", config.getSerialization());
Assert.assertEquals("message", config.getDispatcher());
Assert.assertEquals(1, config.getParameters().size());
Assert.assertEquals("app", config.getParameters().get("app"));
Assert.assertEquals("192.168.1.1", config.getVirtualHost());
Assert.assertEquals(12345, (int) config.getVirtualPort());
Assert.assertEquals(1, config.getOnConnect().size());
Assert.assertEquals(true, config.isEpoll());
Assert.assertEquals(false, config.isDaemon());
Assert.assertEquals(true, config.isAdaptivePort());
Assert.assertEquals("netty", config.getTransport());
Assert.assertEquals(true, config.isAutoStart());
Assert.assertEquals(10000, config.getStopTimeout());
Assert.assertEquals(true, config.isKeepAlive());
Assert.assertTrue(config.toString().contains("bolt"));
}
use of com.alipay.sofa.rpc.listener.ChannelListener in project sofa-rpc by sofastack.
the class ClientTransportConfigTest method testAll.
@Test
public void testAll() {
ClientTransportConfig config = new ClientTransportConfig();
config.setProviderInfo(ProviderHelper.toProviderInfo("127.0.0.1"));
config.setContainer("xxx");
config.setChannelListeners(Collections.<ChannelListener>singletonList(new ChannelListener() {
@Override
public void onConnected(AbstractChannel channel) {
}
@Override
public void onDisconnected(AbstractChannel channel) {
}
}));
config.setConnectionNum(22);
config.setConnectTimeout(3333);
config.setConsumerConfig(new ConsumerConfig());
config.setDisconnectTimeout(4444);
config.setInvokeTimeout(5555);
config.setPayload(666666);
config.setUseEpoll(true);
Assert.assertNotNull(config.getConsumerConfig());
Assert.assertNotNull(config.getProviderInfo());
Assert.assertNotNull(config.getChannelListeners());
Assert.assertEquals("xxx", config.getContainer());
Assert.assertEquals(22, config.getConnectionNum());
Assert.assertEquals(3333, config.getConnectTimeout());
Assert.assertEquals(4444, config.getDisconnectTimeout());
Assert.assertEquals(5555, config.getInvokeTimeout());
Assert.assertEquals(666666, config.getPayload());
Assert.assertTrue(config.isUseEpoll());
}
Aggregations