当前位置: 首页>>代码示例>>Java>>正文


Java SocketConnector.setWorkerTimeout方法代码示例

本文整理汇总了Java中org.apache.mina.transport.socket.nio.SocketConnector.setWorkerTimeout方法的典型用法代码示例。如果您正苦于以下问题:Java SocketConnector.setWorkerTimeout方法的具体用法?Java SocketConnector.setWorkerTimeout怎么用?Java SocketConnector.setWorkerTimeout使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.mina.transport.socket.nio.SocketConnector的用法示例。


在下文中一共展示了SocketConnector.setWorkerTimeout方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: connectFederation

import org.apache.mina.transport.socket.nio.SocketConnector; //导入方法依赖的package包/类
/**
 * Create a connection to federation listener.
 */
private static IoSession connectFederation (Router router,
                                            EwafURI uri,
                                            IoHandler listener)
{
  SocketConnector connector = new SocketConnector (1, router.executor ());
  SocketConnectorConfig connectorConfig = new SocketConnectorConfig ();
  
  connector.setWorkerTimeout (0);
  
  connectorConfig.setThreadModel (ThreadModel.MANUAL);
  connectorConfig.setConnectTimeout (20);
  
  connectorConfig.getFilterChain ().addLast   
    ("codec", FederationFrameCodec.FILTER);
  
  ConnectFuture future = 
    connector.connect (new InetSocketAddress (uri.host, uri.port),
                       listener, connectorConfig);
  
  future.join ();
  
  return future.getSession ();
}
 
开发者ID:luv,项目名称:avis_zmqprx,代码行数:27,代码来源:JUTestFederation.java

示例2: SimpleClient

import org.apache.mina.transport.socket.nio.SocketConnector; //导入方法依赖的package包/类
public SimpleClient (String clientName, String hostname, int port)
  throws IOException
{
  this.clientName = clientName;
  
  SocketConnector connector = new SocketConnector ();

  /* Change the worker timeout to 1 second to make the I/O thread
   * quit soon when there's no connection to manage. */
  connector.setWorkerTimeout (1);
  
  SocketConnectorConfig cfg = new SocketConnectorConfig ();
  cfg.setConnectTimeout (10);
  
  cfg.getFilterChain ().addLast ("codec", ClientFrameCodec.FILTER);
  ConnectFuture future =
    connector.connect (new InetSocketAddress (hostname, port),
                       this, cfg);
                                   
  future.join ();
  clientSession = future.getSession ();
}
 
开发者ID:luv,项目名称:avis_zmqprx,代码行数:23,代码来源:SimpleClient.java

示例3: testProducerShutdownTestingWithMock

import org.apache.mina.transport.socket.nio.SocketConnector; //导入方法依赖的package包/类
@Test
public void testProducerShutdownTestingWithMock() throws Exception {
    MockEndpoint mock = getMockEndpoint("mock:result");
    mock.expectedBodiesReceived("Hello World");

    // create our mock and record expected behavior = that worker timeout should be set to 0
    SocketConnector mockConnector = createMock(SocketConnector.class);
    mockConnector.setWorkerTimeout(0);
    replay(mockConnector);

    // normal camel code to get a producer
    Endpoint endpoint = context.getEndpoint("mina:tcp://localhost:{{port}}?textline=true&sync=false");
    Exchange exchange = endpoint.createExchange();
    Producer producer = endpoint.createProducer();
    producer.start();

    // set input and execute it
    exchange.getIn().setBody("Hello World");
    producer.process(exchange);

    // insert our mock instead of real MINA IoConnector
    Field field = producer.getClass().getDeclaredField("connector");
    field.setAccessible(true);
    field.set(producer, mockConnector);

    // stop using our mock
    producer.stop();

    verify(mockConnector);

    assertMockEndpointsSatisfied();
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:33,代码来源:MinaProducerShutdownMockTest.java

示例4: connectFederationTLS

import org.apache.mina.transport.socket.nio.SocketConnector; //导入方法依赖的package包/类
/**
 * Create a connection to federation listener.
 */
private static IoSession connectFederationTLS (Router router,
                                               EwafURI uri,
                                               IoHandler listener)
  throws Exception
{
  SocketConnector connector = new SocketConnector (1, router.executor ());
  SocketConnectorConfig connectorConfig = new SocketConnectorConfig ();
  
  connector.setWorkerTimeout (0);
  
  connectorConfig.setThreadModel (ThreadModel.MANUAL);
  connectorConfig.setConnectTimeout (20);
  
  SSLFilter filter = new SSLFilter (defaultSSLContext ());
  
  filter.setUseClientMode (true);
  
  connectorConfig.getFilterChain ().addFirst ("ssl", filter);   
  
  connectorConfig.getFilterChain ().addLast   
    ("codec", FederationFrameCodec.FILTER);
  
  ConnectFuture future = 
    connector.connect (new InetSocketAddress (uri.host, uri.port),
                       listener, connectorConfig);
  
  future.join ();
  
  return future.getSession ();
}
 
开发者ID:luv,项目名称:avis_zmqprx,代码行数:34,代码来源:JUTestFederationTLS.java

示例5: Fuzz

import org.apache.mina.transport.socket.nio.SocketConnector; //导入方法依赖的package包/类
public Fuzz (String host)
{
  executor = newCachedThreadPool ();
  
  // connector
  connector = new SocketConnector (1, executor);
  connector.setWorkerTimeout (0);
  
  remoteAddress = new InetSocketAddress (host, 2917);
  
  random = new Random (hashCode ());
}
 
开发者ID:luv,项目名称:avis_zmqprx,代码行数:13,代码来源:Fuzz.java

示例6: AcceptorConnectorSetup

import org.apache.mina.transport.socket.nio.SocketConnector; //导入方法依赖的package包/类
public AcceptorConnectorSetup ()
  throws IOException
{
  executor = newCachedThreadPool ();
  
  // listener
  acceptor = new SocketAcceptor (1, executor);
  acceptorConfig = new SocketAcceptorConfig ();
  
  acceptorConfig.setReuseAddress (true);
  acceptorConfig.setThreadModel (ThreadModel.MANUAL);
  
  DefaultIoFilterChainBuilder filterChainBuilder =
    acceptorConfig.getFilterChain ();

  filterChainBuilder.addLast ("codec", ClientFrameCodec.FILTER);
  
  // connector
  connector = new SocketConnector (1, executor);
  connectorConfig = new SocketConnectorConfig ();
  
  connector.setWorkerTimeout (0);
  
  connectorConfig.setThreadModel (ThreadModel.MANUAL);
  connectorConfig.setConnectTimeout (20);
  
  connectorConfig.getFilterChain ().addLast   
    ("codec", ClientFrameCodec.FILTER);
}
 
开发者ID:luv,项目名称:avis_zmqprx,代码行数:30,代码来源:AcceptorConnectorSetup.java


注:本文中的org.apache.mina.transport.socket.nio.SocketConnector.setWorkerTimeout方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。