List of usage examples for org.apache.http.impl.conn SingleClientConnManager SingleClientConnManager
public SingleClientConnManager()
From source file:org.jboss.capedwarf.tools.BulkLoader.java
private static void doUpload(Arguments args) { String url = getUrl(args);/* w w w . j a va 2 s.c o m*/ String filename = getFilename(args); int packetSize = getPacketSize(args); System.out.println("Uploading data from " + filename + " to " + url + " in packets of size " + packetSize); DumpFileFacade dumpFileFacade = new DumpFileFacade(new File(filename)); try { Iterator<byte[]> iterator = dumpFileFacade.iterator(); DefaultHttpClient client = new DefaultHttpClient(new SingleClientConnManager()); try { File partFile = new File(filename + ".part"); UploadPacket packet = new UploadPacket(partFile); while (iterator.hasNext()) { byte[] pbBytes = iterator.next(); packet.add(pbBytes); if (packet.size() == packetSize || !iterator.hasNext()) { packet.close(); sendPacket(packet, client, url); if (iterator.hasNext()) { packet = new UploadPacket(partFile); } } } } catch (IOException e) { throw new RuntimeException(e); } } finally { dumpFileFacade.close(); } }
From source file:de.adorsys.forge.plugin.curl.CurlPlugin.java
@PostConstruct public void init() { singleClientConnManager = new SingleClientConnManager(); defaultHttpClient = new DefaultHttpClient(singleClientConnManager); }
From source file:org.jboss.capedwarf.tools.BulkLoader.java
private static void doDump(Arguments args) { String url = getUrl(args);//from w ww. java2s.c om String filename = getFilename(args); int packetSize = getPacketSize(args); File file = new File(filename); if (file.exists()) { System.out.println("WARNING: File " + filename + " already exists!"); System.exit(1); } System.out.println("Dumping data from " + url + " to " + filename + " in packets of size " + packetSize); DumpFileFacade dumpFileFacade = new DumpFileFacade(file); try { DefaultHttpClient client = new DefaultHttpClient(new SingleClientConnManager()); try { HttpGet get = new HttpGet(url); get.getParams().setParameter("action", "dump"); System.out.println("Downloading packet of " + packetSize + " entities"); HttpResponse response = client.execute(get); DataInputStream in = new DataInputStream(response.getEntity().getContent()); while (true) { byte[] idBytes = readArray(in); if (idBytes == null) { break; } byte[] entityPbBytes = readArray(in); byte[] sortKeyBytes = readArray(in); dumpFileFacade.add(idBytes, entityPbBytes, sortKeyBytes); } } catch (IOException e) { throw new RuntimeException(e); } } finally { dumpFileFacade.close(); } }
From source file:org.exoplatform.addons.es.client.ElasticIndexingClient.java
@Override protected ClientConnectionManager getClientConnectionManager() { return new SingleClientConnManager(); }
From source file:org.springframework.data.solr.server.support.SolrClientUtilTests.java
/** * @see DATASOLR-227/*w w w. j a v a 2 s. c o m*/ */ @Test public void cloningHttpSolrClientShouldCopyConnectionManager() { ClientConnectionManager conncetionManager = new SingleClientConnManager(); DefaultHttpClient client = new DefaultHttpClient(conncetionManager); HttpSolrClient solrClient = new HttpSolrClient(BASE_URL, client); HttpSolrClient cloned = SolrClientUtils.clone(solrClient); Assert.assertThat(((AbstractHttpClient) cloned.getHttpClient()).getConnectionManager(), IsEqual.<ClientConnectionManager>equalTo(conncetionManager)); }