Package org.apache.commons.httpclient

Examples of org.apache.commons.httpclient.MultiThreadedHttpConnectionManager


            AxisService axisService =
                createClientSideAxisService(definition, serviceQName, port.getName(), new Options());

            HttpClient httpClient = (HttpClient)configContext.getProperty(HTTPConstants.CACHED_HTTP_CLIENT);
            if (httpClient == null) {
                MultiThreadedHttpConnectionManager connectionManager = new MultiThreadedHttpConnectionManager();
                HttpConnectionManagerParams connectionManagerParams = new HttpConnectionManagerParams();
                connectionManagerParams.setDefaultMaxConnectionsPerHost(2);
                connectionManagerParams.setTcpNoDelay(true);
                connectionManagerParams.setStaleCheckingEnabled(true);
                connectionManagerParams.setLinger(0);
                connectionManager.setParams(connectionManagerParams);
                httpClient = new HttpClient(connectionManager);
                configContext.setThreadPool(new ThreadPool(1, 5));
                configContext.setProperty(HTTPConstants.REUSE_HTTP_CLIENT, Boolean.TRUE);
                configContext.setProperty(HTTPConstants.CACHED_HTTP_CLIENT, httpClient);
            }
View Full Code Here


     */
    public static void shutdown(final HttpClient httpclient) {
        if (httpclient != null) {
            final HttpConnectionManager connectionManager = httpclient.getHttpConnectionManager();
            if (connectionManager instanceof MultiThreadedHttpConnectionManager) {
                final MultiThreadedHttpConnectionManager multiThreadedHttpConnectionManager = (MultiThreadedHttpConnectionManager)connectionManager;
                multiThreadedHttpConnectionManager.shutdown();
            }
        }
    }
View Full Code Here

   * Constructor
   * @param cluster the cluster definition
   */
  public Client(Cluster cluster) {
    this.cluster = cluster;
    httpClient = new HttpClient(new MultiThreadedHttpConnectionManager());
    HttpConnectionManagerParams managerParams =
      httpClient.getHttpConnectionManager().getParams();
    managerParams.setConnectionTimeout(2000); // 2 s
    HttpClientParams clientParams = httpClient.getParams();
    clientParams.setVersion(HttpVersion.HTTP_1_1);
View Full Code Here

  /**
   * Shut down the client. Close any open persistent connections.
   */
  public void shutdown() {
    MultiThreadedHttpConnectionManager manager =
      (MultiThreadedHttpConnectionManager) httpClient.getHttpConnectionManager();
    manager.shutdown();
  }
View Full Code Here

    public static InputStream getInputStreamFromUrl(String url, String user, String password) {

        try{
          Pair<String, Integer> hostAndPort = validateUrl(url);
          HttpClient httpclient = new HttpClient(new MultiThreadedHttpConnectionManager());
          if ((user != null) && (password != null)) {
              httpclient.getParams().setAuthenticationPreemptive(true);
              Credentials defaultcreds = new UsernamePasswordCredentials(user, password);
              httpclient.getState().setCredentials(new AuthScope(hostAndPort.first(), hostAndPort.second(), AuthScope.ANY_REALM), defaultcreds);
              s_logger.info("Added username=" + user + ", password=" + password + "for host " + hostAndPort.first() + ":" + hostAndPort.second());
View Full Code Here

        System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.commons.httpclient", "error");      
       
        DocAnalyserFactory docAnalyserFactory = DocAnalyserFactory.getDefaultInstance();
        docAnalyser = docAnalyserFactory.createPrerendererDocAnalyser();
               
        httpClient = new HttpClient(new MultiThreadedHttpConnectionManager());
        httpClient.getHttpConnectionManager().
            getParams().setConnectionTimeout(30000);
        httpClient.getHttpConnectionManager().
            getParams().setDefaultMaxConnectionsPerHost(THREAD_COUNT);
                       
View Full Code Here

  HttpClient httpClient;

  @Override
  public void setUp() throws Exception {
    super.setUp();
    httpClient = new HttpClient(new MultiThreadedHttpConnectionManager());

    httpClient.getParams().setParameter("http.connection.timeout", new Integer(1000));
    for (int i = 0; i < solr.length; i++) {
      solr[i] = new SolrInstance("solr" + i, 0);
      solr[i].setUp();
View Full Code Here

  public void testReliability() throws Exception {
    String[] s = new String[solr.length];
    for (int i = 0; i < solr.length; i++) {
      s[i] = solr[i].getUrl();
    }
    HttpClient myHttpClient = new HttpClient(new MultiThreadedHttpConnectionManager());

    myHttpClient.getParams().setParameter("http.connection.timeout", new Integer(100));
    myHttpClient.getParams().setParameter("http.socket.timeout", new Integer(100));
    LBHttpSolrServer lbHttpSolrServer = new LBHttpSolrServer(myHttpClient, s);
    lbHttpSolrServer.setAliveCheckInterval(500);
View Full Code Here

    // if the compiler won't let you by without the try/catch
    boolean gotExpectedError = false;
    try {
      // switched to a local address to avoid going out on the net, ns lookup issues, etc.
      // set a 1ms timeout to let the connection fail faster.
      HttpClient httpClient = new HttpClient(new MultiThreadedHttpConnectionManager());
      httpClient.getParams().setParameter("http.connection.timeout", new Integer(1));
      SolrServer client = new CommonsHttpSolrServer("http://localhost:11235/solr/", httpClient);
      SolrQuery query = new SolrQuery("test123");
      client.query(query);
    } catch (SolrServerException sse) {
View Full Code Here

      return solrServer.getBaseURL();
    }
  }

  public LBHttpSolrServer(String... solrServerUrls) throws MalformedURLException {
    this(new HttpClient(new MultiThreadedHttpConnectionManager()), solrServerUrls);
  }
View Full Code Here

TOP

Related Classes of org.apache.commons.httpclient.MultiThreadedHttpConnectionManager

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.