Package org.apache.mina.transport.socket.nio

Examples of org.apache.mina.transport.socket.nio.SocketConnectorConfig


        if (!Boolean.getBoolean("amqj.enablePooledAllocator"))
        {
            org.apache.mina.common.ByteBuffer.setAllocator(new SimpleByteBufferAllocator());
        }

        SocketConnectorConfig cfg = (SocketConnectorConfig) _socketConnector.getDefaultConfig();
        String s = "";
                    StackTraceElement[] trace = Thread.currentThread().getStackTrace();
            for(StackTraceElement elt : trace)
            {
                if(elt.getClassName().contains("Test"))
                {
                    s = elt.getClassName();
                    break;
                }
            }
        cfg.setThreadModel(ExecutorThreadModel.getInstance("MINANetworkDriver(Client)-"+s));

        SocketSessionConfig scfg = (SocketSessionConfig) cfg.getSessionConfig();
        scfg.setTcpNoDelay((config != null) ? config.getTcpNoDelay() true);
        scfg.setSendBufferSize((config != null) ? config.getSendBufferSize() : DEFAULT_BUFFER_SIZE);
        scfg.setReceiveBufferSize((config != null) ? config.getReceiveBufferSize() : DEFAULT_BUFFER_SIZE);

        // Don't have the connector's worker thread wait around for other
View Full Code Here


        IoAcceptor acceptor = new SocketAcceptor();
        SocketAddress address = new InetSocketAddress(connectUri.getHost(), connectUri.getPort());
        IoConnector connector = new SocketConnector();

        // TODO customize the config via URI
        SocketConnectorConfig config = new SocketConnectorConfig();
        configureCodecFactory(config, parameters);
        return new MinaEndpoint(uri, this, address, acceptor, connector, config);
    }
View Full Code Here

    }
  }
 
  private void doConnect() {
    SocketConnector connector = new SocketConnector();
    SocketConnectorConfig config = new SocketConnectorConfig();
    SocketSessionConfig sessionConf =
      (SocketSessionConfig) config.getSessionConfig();
    sessionConf.setTcpNoDelay(true);
    while (true) {
      ConnectFuture future = connector.connect(new InetSocketAddress(server, port), ioHandlerWrapper, config);
      future.join();
      if (future.isConnected()) {
View Full Code Here

      this.connectorIFX = connectorIFX;
    }
   
    @Override
    public void run() {
      SocketConnectorConfig cfg = new SocketConnectorConfig();
      cfg.setThreadModel(ThreadModel.MANUAL);
      cfg.getFilterChain().addLast("codec", new ProtocolCodecFilter(new IFXProtocolCodecFactory(bufferLimit)));
      //cfg.getFilterChain().addLast("logger", new LoggingFilter());
      SocketConnector connector = new SocketConnector();
      ClientSessionHandler sessionHandler = new ClientSessionHandler(connectorIFX);
     
      try {
View Full Code Here

      this.connectorISO = connectorISO;
    }
   
    @Override
    public void run() {
      SocketConnectorConfig cfg = new SocketConnectorConfig();
      cfg.setThreadModel(ThreadModel.MANUAL);
      cfg.getFilterChain().addLast("codec", new ProtocolCodecFilter(new ISOProtocolCodecFactory(bufferLimit)));
      //cfg.getFilterChain().addLast("logger", new LoggingFilter());
      SocketConnector connector = new SocketConnector();
      ClientSessionHandler sessionHandler = new ClientSessionHandler(connectorISO);
     
      try {
View Full Code Here

        } else {
            // set thread pool.
            connector = new SocketConnector(Constants.DEFAULT_IO_THREADS,
                                            Executors.newCachedThreadPool(new NamedThreadFactory("MinaClientWorker", true)));
            // config
            SocketConnectorConfig cfg = (SocketConnectorConfig) connector.getDefaultConfig();
            cfg.setThreadModel(ThreadModel.MANUAL);
            cfg.getSessionConfig().setTcpNoDelay(true);
            cfg.getSessionConfig().setKeepAlive(true);
            int timeout = getTimeout();
            cfg.setConnectTimeout(timeout < 1000 ? 1 : timeout / 1000);
            // set codec.
            connector.getFilterChain().addLast("codec", new ProtocolCodecFilter(new MinaCodecAdapter(getCodec(), getUrl(), this)));
            connectors.put(connectorKey, connector);
        }
    }
View Full Code Here

        boolean textline = getAndRemoveParameter(parameters, "textline", Boolean.class, false);
        String encoding = getAndRemoveParameter(parameters, "encoding", String.class);
        String codec = getAndRemoveParameter(parameters, "codec", String.class);

        // connector config
        SocketConnectorConfig connectorConfig = new SocketConnectorConfig();
        configureSocketCodecFactory("MinaProducer", connectorConfig, textline, encoding, codec);
        if (minaLogger) {
            connectorConfig.getFilterChain().addLast("logger", new LoggingFilter());
        }
        // set connect timeout to mina in seconds
        long connectTimeout = timeout > 0 ? timeout : DEFAULT_CONNECT_TIMEOUT;
        connectorConfig.setConnectTimeout((int)(connectTimeout / 1000));

        // acceptor connectorConfig
        SocketAcceptorConfig acceptorConfig = new SocketAcceptorConfig();
        configureSocketCodecFactory("MinaConsumer", acceptorConfig, textline, encoding, codec);
        acceptorConfig.setReuseAddress(true);
View Full Code Here

        config.setThreadModel(ThreadModel.MANUAL);
    }


    public synchronized SocketConnectorConfig configureSocketSessionConfig() throws IOException {
        SocketConnectorConfig config = new SocketConnectorConfig();
        configureSocketSessionConfig(config.getSessionConfig());
        configureProtocol(config, false);
        return config;
    }
View Full Code Here

        IoConnector connector = new SocketConnector(processorCount,
                getCamelContext().getExecutorServiceStrategy().newDefaultThreadPool(this, "MinaSocketConnector"));
        SocketAddress address = new InetSocketAddress(configuration.getHost(), configuration.getPort());

        // connector config
        SocketConnectorConfig connectorConfig = new SocketConnectorConfig();
        // must use manual thread model according to Mina documentation
        connectorConfig.setThreadModel(ThreadModel.MANUAL);
        configureCodecFactory("MinaProducer", connectorConfig, configuration);
        connectorConfig.getFilterChain().addLast("threadPool",
                new ExecutorFilter(getCamelContext().getExecutorServiceStrategy().newDefaultThreadPool(this, "MinaThreadPool")));
        if (minaLogger) {
            connectorConfig.getFilterChain().addLast("logger", new LoggingFilter());
        }
        appendIoFiltersToChain(filters, connectorConfig.getFilterChain());

        // set connect timeout to mina in seconds
        connectorConfig.setConnectTimeout((int) (timeout / 1000));

        // acceptor connectorConfig
        SocketAcceptorConfig acceptorConfig = new SocketAcceptorConfig();
        // must use manual thread model according to Mina documentation
        acceptorConfig.setThreadModel(ThreadModel.MANUAL);
View Full Code Here

  private boolean reconnect() {
    try {
      Logger.println("Attempting to connect to LS");
      SocketConnector conn = new SocketConnector();
      SocketConnectorConfig config = new SocketConnectorConfig();
      ((SocketSessionConfig) config.getSessionConfig())
          .setKeepAlive(true);
      ((SocketSessionConfig) config.getSessionConfig())
          .setTcpNoDelay(true);
      ConnectFuture future = conn.connect(new InetSocketAddress(
          Config.LS_IP, Config.LS_PORT), connectionHandler, config);
      future.join(3000);
      if (future.isConnected()) {
View Full Code Here

TOP

Related Classes of org.apache.mina.transport.socket.nio.SocketConnectorConfig

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.