Skip to content

Instantly share code, notes, and snippets.

@At("/:method/:id") @Service
public final class SitebricksResource {
private FormPost formPost = new FormPost();
private Logger logger = LoggerFactory.getLogger(SitebricksResource.class);
@Inject
ServiceEntity serviceEntity;
public class AddressBookMediaType implements ServiceHandlerMediaType<List<String>> {
public String entries;
public AddressBookMediaType(){
}
@Override
public AddressBookMediaType visit(List<String> object) {
List<String> entries = (List<String>) object;
StringBuilder b = new StringBuilder();
package com.google.sitebricks.test;
import com.google.sitebricks.At;
import com.google.sitebricks.http.Get;
import com.google.sitebricks.http.Select;
import com.google.sitebricks.Show;
/**
* @author Dhanji R. Prasanna ([email protected])
*/
Client: Mac Pro OS X, 2.8Ghz Quad-Core Intel Xeon, 8 GB 1066 Mhz DDR3
Server: lighttpd/1.4.26 -> Ubuntu, 2.8Ghz Duo-Core Intel Xeon, 6 1066 Mhz DDR3
50 threads that does 50 requests, done 50 times.
Async Http Client 1.5.0 (Config http://is.gd/7rGGWU)
=============================================================
BenchmarkResult{requestsPerSecond=1578.96, threads=50, batches=50, targetRequests=125000, successfulRequests=125000, failedRequests=0, averageRequestTime=0.63ms, averageBatchTime=1583.32ms, totalBenchmarkTime=79166.03ms}
(last 5 runs)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 13:33.359s
[INFO] Finished at: Mon Jan 31 13:27:22 EST 2011
[INFO] Final Memory: 21M/87M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.5:deploy (default-deploy) on project async-http-client: Failed to deploy artifacts: Could not transfer artifact com.ning:async-http-client:jar:1.5.0 from/to sonatype-nexus-staging (http://oss.sonatype.org/service/local/staging/deploy/maven2): Failed to transfer file: http://oss.sonatype.org/service/local/staging/deploy/maven2/com/ning/async-http-client/1.5.0/async-http-client-1.5.0.jar. Return code is: 504 -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
diff --git a/src/main/java/com/ning/http/client/providers/netty/NettyAsyncHttpProvider.java b/src/main/java/com/ning/http/client/providers/netty/Nindex c697e0d..80e7d01 100644
--- a/src/main/java/com/ning/http/client/providers/netty/NettyAsyncHttpProvider.java
+++ b/src/main/java/com/ning/http/client/providers/netty/NettyAsyncHttpProvider.java
@@ -828,7 +828,7 @@ public class NettyAsyncHttpProvider extends IdleStateHandler implements AsyncHtt
}
private void closeChannel(final ChannelHandlerContext ctx) {
- if (config.getMaxTotalConnections() != -1) {
+ if (config.getMaxTotalConnections() != -1 && ctx.getChannel().isOpen()) {
maxConnections.decrementAndGet();
=================================
HTTP agent: Apache HttpClient 4 (ver: 4.1)
---------------------------------
200000 GET requests
---------------------------------
Document URI: http://localhost:57845/rnd?c=2048
Document Length: 2048 bytes
Concurrency level: 100
Time taken for tests: 15.194 seconds
/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home/bin/java -agentlib:jdwp=transport=dt_socket,address=127.0.0.1:53684,suspend=y,server=n -ea -Dfile.encoding=MacRoman -classpath /Applications/IntelliJ IDEA 9.0.1.app/plugins/testng/lib/testng.jar:/Applications/IntelliJ IDEA 9.0.1.app/plugins/testng/lib/testng-jdk15.jar:/System/Library/Frameworks/JavaVM.framework/Versions/A/Resources/Deploy.bundle/Contents/Resources/Java/deploy.jar:/System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home/lib/dt.jar:/System/Library/Frameworks/JavaVM.framework/Versions/A/Resources/Deploy.bundle/Contents/Resources/Java/javaws.jar:/System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home/lib/jce.jar:/System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home/lib/management-agent.jar:/System/Library/Frameworks/JavaVM.framework/Versions/A/Resources/Deploy.bundle/Contents/Resources/Java/plugin.jar:/System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home/lib/sa-jdi.jar:/System/Library/Framework
java.lang.Thread.State: RUNNABLE
at java.util.Arrays.copyOf(Arrays.java:2734)
at java.util.PriorityQueue.toArray(PriorityQueue.java:357)
at java.util.concurrent.DelayQueue.toArray(DelayQueue.java:360)
at java.util.concurrent.DelayQueue.iterator(DelayQueue.java:439)
at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue$1.<init>(ScheduledThreadPoolExecutor.java:644)
at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.iterator(ScheduledThreadPoolExecutor.java:643)
at java.util.concurrent.ThreadPoolExecutor.drainQueue(ThreadPoolExecutor.java:1198)
at java.util.concurrent.ThreadPoolExecutor.shutdownNow(ThreadPoolExecutor.java:1175)
at java.util.concurrent.ScheduledThreadPoolExecutor.shutdownNow(ScheduledThreadPoolExecutor.java:580)
09:34:09.788 [New I/O client worker #152-2] DEBUG c.n.h.c.p.n.NettyAsyncHttpProvider - Adding uri: http://repository.sonatype.org:8081 for channel [id: 0x6fb3d611, /10.0.1.5:62131 => repository.sonatype.org/63.246.20.88:8081]
09:34:09.788 [New I/O client worker #152-2] DEBUG c.n.h.c.p.n.NettyAsyncHttpProvider - ConnectionsPool increment totalConnections 2
Downloaded: http://repository.sonatype.org:8081/content/groups/sonatype-public-grid/org/codehaus/plexus/plexus-velocity/1.1.3/plexus-velocity-1.1.3.pom (976 B at 4.5 KB/sec)
09:34:09.789 [main] DEBUG c.n.h.c.p.n.NettyAsyncHttpProvider - Channel Closed: [id: 0x25feb227, /10.0.1.5:62132 :> repository.sonatype.org/63.246.20.88:8081]
09:34:09.789 [main] DEBUG c.n.h.c.AsyncCompletionHandlerBase - null
java.util.concurrent.CancellationException: null
at com.ning.http.client.providers.netty.NettyResponseFuture.cancel(NettyResponseFuture.java:151) [async-http-client-1.6.1-SNAPSHOT-shaded.jar:na]
at org.sonatype.aether.connector.async.SimpleGetTask.cancelLeftoverCh