HTTP codec?

28 views
Skip to first unread message

Dobromir Montauk

unread,
Sep 23, 2014, 3:23:50 PM9/23/14
to iago-...@googlegroups.com
Hi,

I'm trying to use the HTTP codec in Java but I can't seem to find the right class (that extends CodecFactory):


I don't see anything called HTTP that extends CodecFactory. The example suggests there should be an HTTP Codec in Scala:

val client =
  ClientBuilder()
    .codec(http())
    .hosts("twitter.com:80")
    .build()

This works fine:

import com.twitter.finagle.memcached.protocol.text.Memcached;

    ClientBuilder.safeBuild(
        ClientBuilder.get().codec(new Memcached()).hosts("localhost:80")
            .tcpConnectTimeout(Duration.fromSeconds(10)).requestTimeout(Duration.fromSeconds(10))
            .hostConnectionLimit(100).reportTo(new OstrichStatsReceiver())
            .logger(Logger.getLogger("http")));

Can someone include an example of building an HTTP client?

Thanks,
Dobromir 

Dobromir Montauk

unread,
Sep 23, 2014, 4:09:00 PM9/23/14
to iago-...@googlegroups.com
OK, I figured out that Scala default params don't translate to Java. I have this now:

import com.twitter.finagle.http.Http;

        ClientBuilder.safeBuild(ClientBuilder.get().codec(
                new Http(-1, StorageUnit.parse("5MB"), StorageUnit.parse("5MB"), true, null, null,
                         false, StorageUnit.parse("4096B"), StorageUnit.parse("8192B")))
                .hosts("localhost:80")
                .tcpConnectTimeout(Duration.fromSeconds(10))
                .requestTimeout(Duration.fromSeconds(10))
                .hostConnectionLimit(100).reportTo(new OstrichStatsReceiver())
                .logger(Logger.getLogger("http")));

Now I'm having trouble with the rest of the Java code:
    FinagleTransport transport = new FinagleTransport(new FinagleService(client), null);
    Function1<Object, RequestDistribution> distribution = new Function1<Object, RequestDistribution>() {
    }
    RequestQueue<ParrotRequest, HttpResponse> consumer = new RequestQueue<>(new RequestConsumer<>(distribution, transport), transport);
    final ParrotService<ParrotRequest, HttpResponse> service = transport.createService(consumer);
    IagoLoadTest processor = new IagoLoadTest();
    // Start sending
    transport.start();
    consumer.start();

In particular, Function1 seems to have a *ton* of methods in Java that need to be implemented. If I try to use the Java 8 lambdas:

    RequestQueue<ParrotRequest, HttpResponse> consumer = new RequestQueue<>(new RequestConsumer<>(() -> new PoissonProcess(10), transport), transport);

I get "Multiple non-overriding abstract methods found".

So how do I proceed?

Background: I'm trying to build a frontend that will stat/stop the load test based on user actions. I was hoping to use the client library directly to have tight integration with Iago, instead of just starting up a Iago process.

Dobromir 

Tom Howland

unread,
Oct 1, 2014, 2:14:33 PM10/1/14
to iago-...@googlegroups.com
Hi Dobromir

Did you consider using the ParrotServer.pause/resume methods?

--

---
You received this message because you are subscribed to the Google Groups "Iago Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to iago-users+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages