Open smallnest opened 8 years ago
Can you share your code?
It is a complex system that I try to replace threads with fibers and it has too many dependencies. I can exact the major biz logic as this:
new Fiber<Void>(new SuspendableRunnable() {
public void run() throws SuspendExecution, InterruptedException {
try {
c1.m1();
} catch (Exception ex) {
}
}
}).start();
Class c1:
@Suspendable
pubic void m1() {
//do something
c2.m2()
//do something
}
Class c2:
@Suspendable
pubic void m2() {
//do something
c3.m3()
//do something
}
Class c3:
@Suspendable
pubic void m3() {
//do something
c4.m4()
//do something
}
Class c4:
@Suspendable
pubic void m4() {
//do something
c5.m5()
//do something
}
Class c5:
@Suspendable
pubic void m5() {
//do something
contentRouterProxy.m6()
//do something
}
Class contentRouterProxy:
@Suspendable
pubic void m6() {
//do something
HttpUtil.getLocationByHttpHEAD()
//do something
}
class HttpUtil:
@Suspendable
public static void getLocationByHttpHEAD(......)
String location = ......
for(int i = 0; i < maxRedirectLoopStatic; i++){
HttpUriRequest httpRequest = new HttpHead(location);
httpRequest.setHeader("Connection", "keep-alive");
CloseableHttpResponse response = client.execute(httpRequest);
//EntityUtils.toString(response.getEntity(), Charset.forName("utf-8"));
response.close();
if (response.getStatusLine().getStatusCode() /100 = 3) {
location = getLocation(response)
continue
}
return
}
.....
}
public static RequestConfig requestConfig = RequestConfig.custom()
.setSocketTimeout(1000)
.setConnectTimeout(1000)
.setConnectionRequestTimeout(1000)
.setRedirectsEnabled(false)
.build();
public static CloseableHttpClient client = FiberHttpClientBuilder.
create(Runtime.getRuntime().availableProcessors()). // use 2 io threads
setDefaultRequestConfig(requestConfig).
disableConnectionState().
setMaxConnPerRoute(20000).
setMaxConnTotal(20000).build();
Basically a fiber runs nested methods and the last method uses comsat-httpclient to do redirection manually.
There are a lot of requests at that moment.
Is one fiber parked more than once? At the first the fiber state is changed from RUNNABLE to PARKING, At that moment the fiber is parked again.
Is one fiber parked more than once?
It appears that way from the exception, but I have a hard time seeing how this could happen. If you don't mind sharing your code, you can upload it here or send it to me personally (ron [at] ourdomain)
I write a program that queries memcached and sends a lot of http requests to CDN servers. I use comsat http client to send http requests. When I test its performance, AssertionError was thrown (quasar is 0.7.6, comsat-httpclient-0.7.0.jar):
My question is why this exception was thrown and how to fix it? I can't find any document to avoid it.