Package org.xsocket.connection

Examples of org.xsocket.connection.NonBlockingConnectionPool


      };
     
      IServer server = new Server(dh);
      server.start();
     
      NonBlockingConnectionPool pool = new NonBlockingConnectionPool();
             
        for (int i = 0; i < 1000; i++) {
            HttpClientConnection httpCon = new HttpClientConnection(pool.getNonBlockingConnection("localhost", server.getLocalPort()));
            IHttpResponse resp = httpCon.call(new GetRequest("http://localhost:" + server.getLocalPort() + "/"));
       
            InputStream in = Channels.newInputStream(resp.getBlockingBody());
            in.close();
               
            httpCon.close();
        }
       
        pool.close();
  }
View Full Code Here


   */
  public HttpClient(SSLContext sslCtx, IHttpRequestHandler... interceptors) {
      this.sslCtx = sslCtx;

      if (sslCtx != null) {
      pool = new NonBlockingConnectionPool(sslCtx);
      isSSLSupported = true;
    } else {
      pool = new NonBlockingConnectionPool();
      isSSLSupported = false;
   
   
   
    proxyHandler.setSSLContext(sslCtx);
View Full Code Here

    };
    IServer server = new Server(dh);
    server.start();
   
   
    NonBlockingConnectionPool pool = new NonBlockingConnectionPool();
   
    for (int i = 0; i < 5; i++) {
     
      INonBlockingConnection con = pool.getNonBlockingConnection("localhost", server.getLocalPort());
      HttpClientConnection httpCon = new HttpClientConnection(con);
     
      IHttpResponse response =  httpCon.call(new GetRequest("http://localhost:" + server.getLocalPort()+ "/"));
      Assert.assertEquals(200, response.getStatus());
      Assert.assertEquals("12", response.getBody().readString());
    }
   
    QAUtil.sleep(1000);
    Assert.assertEquals(5, pool.getNumActive());
    Assert.assertEquals(0, pool.getNumIdle());
    Assert.assertEquals(0, pool.getNumDestroyed());
   
   
    INonBlockingConnection con = pool.getNonBlockingConnection("localhost", server.getLocalPort());
    HttpClientConnection httpCon = new HttpClientConnection(con);
    IHttpResponse response =  httpCon.call(new GetRequest("http://localhost:" + server.getLocalPort()+ "/"));
   
    Assert.assertEquals(200, response.getStatus());
    Assert.assertEquals("12", response.getBody().readString());
    httpCon.close();
   
    QAUtil.sleep(1000);
    con = pool.getNonBlockingConnection("localhost", server.getLocalPort());
    httpCon = new HttpClientConnection(con);
    response =  httpCon.call(new GetRequest("http://localhost:" + server.getLocalPort()+ "/"));
   
    Assert.assertEquals(200, response.getStatus());
    Assert.assertEquals("12", response.getBody().readString());
    httpCon.close();

    QAUtil.sleep(1000);
    Assert.assertEquals(5, pool.getNumActive());
    Assert.assertEquals(1, pool.getNumIdle());
    Assert.assertEquals(0, pool.getNumDestroyed());
   
   
    pool.destroy();
    server.close();
  }
View Full Code Here

    };
    IServer server = new Server(dh);
    server.start();
   
   
    NonBlockingConnectionPool pool = new NonBlockingConnectionPool();
   
    for (int i = 0; i < 5; i++) {
     
      INonBlockingConnection con = pool.getNonBlockingConnection("localhost", server.getLocalPort());
      HttpClientConnection httpCon = new HttpClientConnection(con);
     
      IHttpResponse response =  httpCon.call(new GetRequest("http://localhost:" + server.getLocalPort()+ "/"));
      Assert.assertEquals(200, response.getStatus());
      Assert.assertEquals("12", response.getBody().readString());
    }
   
    QAUtil.sleep(1000);
    Assert.assertEquals(0, pool.getNumActive());
    Assert.assertEquals(5, pool.getNumDestroyed());
   
   
    INonBlockingConnection con = pool.getNonBlockingConnection("localhost", server.getLocalPort());
    HttpClientConnection httpCon = new HttpClientConnection(con);
    IHttpResponse response =  httpCon.call(new GetRequest("http://localhost:" + server.getLocalPort()+ "/"));
   
    Assert.assertEquals(200, response.getStatus());
    Assert.assertEquals("12", response.getBody().readString());
    httpCon.close();
   
    QAUtil.sleep(1000);
    con = pool.getNonBlockingConnection("localhost", server.getLocalPort());
    httpCon = new HttpClientConnection(con);
    response =  httpCon.call(new GetRequest("http://localhost:" + server.getLocalPort()+ "/"));
   
    Assert.assertEquals(200, response.getStatus());
    Assert.assertEquals("12", response.getBody().readString());
    httpCon.close();

    QAUtil.sleep(1000);
    Assert.assertEquals(0, pool.getNumActive());
    Assert.assertEquals(7, pool.getNumDestroyed());
   
    pool.destroy();
    server.close();
 
View Full Code Here

    };
    IServer server = new Server(dh);
    server.start();
   
   
    NonBlockingConnectionPool pool = new NonBlockingConnectionPool();
   
    for (int i = 0; i < 5; i++) {
     
      INonBlockingConnection con = pool.getNonBlockingConnection("localhost", server.getLocalPort());
      HttpClientConnection httpCon = new HttpClientConnection(con);
     
      IHttpResponse response =  httpCon.call(new GetRequest("http://localhost:" + server.getLocalPort()+ "/"));
      Assert.assertEquals(200, response.getStatus());
      Assert.assertEquals("12", response.getBody().readString());
    }
   
    QAUtil.sleep(1000);
    Assert.assertEquals(0, pool.getNumActive());
    Assert.assertEquals(5, pool.getNumDestroyed());
   
   
    INonBlockingConnection con = pool.getNonBlockingConnection("localhost", server.getLocalPort());
    HttpClientConnection httpCon = new HttpClientConnection(con);
    IHttpResponse response =  httpCon.call(new GetRequest("http://localhost:" + server.getLocalPort()+ "/"));
   
    Assert.assertEquals(200, response.getStatus());
    Assert.assertEquals("12", response.getBody().readString());
    httpCon.close();
   
    QAUtil.sleep(1000);
    con = pool.getNonBlockingConnection("localhost", server.getLocalPort());
    httpCon = new HttpClientConnection(con);
    response =  httpCon.call(new GetRequest("http://localhost:" + server.getLocalPort()+ "/"));
   
    Assert.assertEquals(200, response.getStatus());
    Assert.assertEquals("12", response.getBody().readString());
    httpCon.close();

    QAUtil.sleep(1000);
    Assert.assertEquals(0, pool.getNumActive());
    Assert.assertEquals(7, pool.getNumDestroyed());
   
    pool.destroy();
    server.close();
  }
View Full Code Here

                  LOG.fine("default SSLContext -> SSLContext.getDefault() is loaded automatically");
              }
          } catch (Exception ignore) { }
      }
     
    pool = new NonBlockingConnectionPool(sslContext);
    pool.setPooledMaxIdleTimeMillis(DEFAULT_PERSISTENT_CONNECTION_TIMEOUT);
  }
View Full Code Here

   * constructor
   *
   * @param sslContext   the ssl context or <code>null</code> if ssl should not be used
   */
  public HttpClientConnectionPool(SSLContext sslContext) {
    pool = new NonBlockingConnectionPool(sslContext);
    pool.setPooledMaxIdleTimeMillis(DEFAULT_PERSISTENT_CONNECTION_TIMEOUT);
  }
View Full Code Here

    };
    IServer server = new Server(dh);
    server.start();
   
   
    NonBlockingConnectionPool pool = new NonBlockingConnectionPool();
   
    for (int i = 0; i < 5; i++) {
     
      INonBlockingConnection con = pool.getNonBlockingConnection("localhost", server.getLocalPort());
      HttpClientConnection httpCon = new HttpClientConnection(con);
     
      IHttpResponse response =  httpCon.call(new GetRequest("http://localhost:" + server.getLocalPort()+ "/"));
      Assert.assertEquals(200, response.getStatus());
      Assert.assertEquals("12", response.getBlockingBody().readString());
    }
   
    QAUtil.sleep(1000);
    Assert.assertEquals(5, pool.getNumActive());
    Assert.assertEquals(0, pool.getNumIdle());
    Assert.assertEquals(0, pool.getNumDestroyed());
   
   
    INonBlockingConnection con = pool.getNonBlockingConnection("localhost", server.getLocalPort());
    HttpClientConnection httpCon = new HttpClientConnection(con);
    IHttpResponse response =  httpCon.call(new GetRequest("http://localhost:" + server.getLocalPort()+ "/"));
   
    Assert.assertEquals(200, response.getStatus());
    Assert.assertEquals("12", response.getBlockingBody().readString());
    httpCon.close();
   
    QAUtil.sleep(1000);
    con = pool.getNonBlockingConnection("localhost", server.getLocalPort());
    httpCon = new HttpClientConnection(con);
    response =  httpCon.call(new GetRequest("http://localhost:" + server.getLocalPort()+ "/"));
   
    Assert.assertEquals(200, response.getStatus());
    Assert.assertEquals("12", response.getBlockingBody().readString());
    httpCon.close();

    QAUtil.sleep(1000);
    Assert.assertEquals(5, pool.getNumActive());
    Assert.assertEquals(1, pool.getNumIdle());
    Assert.assertEquals(0, pool.getNumDestroyed());
   
   
    pool.destroy();
    server.close();
  }
View Full Code Here

    };
    IServer server = new Server(dh);
    server.start();
   
   
    NonBlockingConnectionPool pool = new NonBlockingConnectionPool();
   
    for (int i = 0; i < 5; i++) {
     
      INonBlockingConnection con = pool.getNonBlockingConnection("localhost", server.getLocalPort());
      HttpClientConnection httpCon = new HttpClientConnection(con);
     
      IHttpResponse response =  httpCon.call(new GetRequest("http://localhost:" + server.getLocalPort()+ "/"));
      Assert.assertEquals(200, response.getStatus());
      Assert.assertEquals("12", response.getBlockingBody().readString());
    }
   
    QAUtil.sleep(1000);
    Assert.assertEquals(0, pool.getNumActive());
    Assert.assertEquals(5, pool.getNumDestroyed());
   
   
    INonBlockingConnection con = pool.getNonBlockingConnection("localhost", server.getLocalPort());
    HttpClientConnection httpCon = new HttpClientConnection(con);
    IHttpResponse response =  httpCon.call(new GetRequest("http://localhost:" + server.getLocalPort()+ "/"));
   
    Assert.assertEquals(200, response.getStatus());
    Assert.assertEquals("12", response.getBlockingBody().readString());
    httpCon.close();
   
    QAUtil.sleep(1000);
    con = pool.getNonBlockingConnection("localhost", server.getLocalPort());
    httpCon = new HttpClientConnection(con);
    response =  httpCon.call(new GetRequest("http://localhost:" + server.getLocalPort()+ "/"));
   
    Assert.assertEquals(200, response.getStatus());
    Assert.assertEquals("12", response.getBlockingBody().readString());
    httpCon.close();

    QAUtil.sleep(1000);
    Assert.assertEquals(0, pool.getNumActive());
    Assert.assertEquals(7, pool.getNumDestroyed());
   
    pool.destroy();
    server.close();
 
View Full Code Here

    };
    IServer server = new Server(dh);
    server.start();
   
   
    NonBlockingConnectionPool pool = new NonBlockingConnectionPool();
   
    for (int i = 0; i < 5; i++) {
     
      INonBlockingConnection con = pool.getNonBlockingConnection("localhost", server.getLocalPort());
      HttpClientConnection httpCon = new HttpClientConnection(con);
     
      IHttpResponse response =  httpCon.call(new GetRequest("http://localhost:" + server.getLocalPort()+ "/"));
      Assert.assertEquals(200, response.getStatus());
      Assert.assertEquals("12", response.getBlockingBody().readString());
    }
   
    QAUtil.sleep(1000);
    Assert.assertEquals(0, pool.getNumActive());
    Assert.assertEquals(5, pool.getNumDestroyed());
   
   
    INonBlockingConnection con = pool.getNonBlockingConnection("localhost", server.getLocalPort());
    HttpClientConnection httpCon = new HttpClientConnection(con);
    IHttpResponse response =  httpCon.call(new GetRequest("http://localhost:" + server.getLocalPort()+ "/"));
   
    Assert.assertEquals(200, response.getStatus());
    Assert.assertEquals("12", response.getBlockingBody().readString());
    httpCon.close();
   
    QAUtil.sleep(1000);
    con = pool.getNonBlockingConnection("localhost", server.getLocalPort());
    httpCon = new HttpClientConnection(con);
    response =  httpCon.call(new GetRequest("http://localhost:" + server.getLocalPort()+ "/"));
   
    Assert.assertEquals(200, response.getStatus());
    Assert.assertEquals("12", response.getBlockingBody().readString());
    httpCon.close();

    QAUtil.sleep(1000);
    Assert.assertEquals(0, pool.getNumActive());
    Assert.assertEquals(7, pool.getNumDestroyed());
   
    pool.destroy();
    server.close();
  }
View Full Code Here

TOP

Related Classes of org.xsocket.connection.NonBlockingConnectionPool

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.