INFO [08-17 15:52:12] [Thread-2024] org.apache.http.impl.client.DefaultRequestDirector.tryExecute(696) | I/O exception (java.net.SocketException) caught when processing request to {}->http://192.168.4.190:80: Broken pipe
INFO [08-17 15:52:12] [Thread-2024]
org.apache.http.impl.client.DefaultRequestDirector.tryExecute(706) | Retrying request to {}->http://192.168.4.190:80
java代码:
import java.io.File;
import java.util.Date;
import java.util.concurrent.ExecutionException;
public class TestHTTP {
// 线程池的容量
/**
* @param args
* @throws ExecutionException
* @throws InterruptedException
*/
public static void main(String[] args) throws InterruptedException, ExecutionException {
int cnt = 2001;
if (args.length > 0 ) {
cnt = StringUtil.str2Int(args[0]);
}
System.out.println(111 + new Date().toString());
for (int i = 0; i < cnt; i++) {
TTT ttt = new TTT();// f, "test"
Thread t = new Thread(ttt);
t.start();
}
}
}
class TTT extends Thread {
@Override
public void run() {
String pathname = "E:\\test\\cca.txt";
pathname = "C:\\Users\\Public\\Documents\\data.txt";
pathname = "/usr/linkapp/bin/tomcat-master/lktest/data.txt";
File f = new File(pathname);
String key = LKRestUtil.put(f);
System.out.println(" key : " + key + new Date().toString());
}
}
LKRestUtil.put 方法 :
HttpClient httpClient = getHttpClient(); // 从连接池中获取
String url = "http://"+MyNodeStatusChecker.mainHost +"/cmd/put";
HttpPost httppost = new HttpPost(url);
httppost.setHeader("content-type", "application/octet-stream");
httppost.setHeader("x-my-policy", policy );
httppost.setHeader("Connection", "keep-alive");
ByteArrayEntity entity = new ByteArrayEntity(data);
httppost.setEntity(entity);
String key = "";
try {
HttpResponse response = httpClient.execute(httppost, context);
HttpEntity entity2 = response.getEntity();
if (entity2 != null) {
StatusLine statusLine = response.getStatusLine();
int statusCode = statusLine.getStatusCode();
if (statusCode == 200) {
Header[] allHeaders = response.getAllHeaders();
for (int i = 0; i < allHeaders.length; i++) {
Header header = allHeaders[i];
if ("x-my-key".equals(header.getName())) {
key = header.getValue();
//System.out.println(header.getName() +" : "+ header.getValue());
}
}
} else {
return "MyError:"+statusCode;
}
} else {
return "MyError: entity2 is null "+ entity2;
}
EntityUtils.consume(entity);
} catch (Exception e) {
httppost.abort();
logger.error("My出现异常: " + e.toString());
return "MyError:" + e.getMessage();
}finally{
httppost.releaseConnection();
}
open files 已经修改过了的:
core file size (blocks, -c) 0
data seg size (kbytes, -d) unlimited
scheduling priority (-e) 0
file size (blocks, -f) unlimited
pending signals (-i) 62812
max locked memory (kbytes, -l) 64
max memory size (kbytes, -m) unlimited
open files (-n) 2024
pipe size (512 bytes, -p) 8
POSIX message queues (bytes, -q) 819200
real-time priority (-r) 0
stack size (kbytes, -s) 10240
cpu time (seconds, -t) unlimited
max user processes (-u) 62812
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited