Aggregating JDBC Feeders

Is it possible to aggregate JDBC Feeders? I have a number of client databases I need to get information from.

I’ve tried the following:

val nbUsers = Integer.getInteger(“users”, 10).toInt

val lookupFeeder = getLookupFeederForClients

def getLookupFeederForClients: RecordSeqFeederBuilder[Any] = {
val clients = List(“client1”, “client2”, “client3”, “client4”, “client5”)
val records = Vector.empty

for (client ← clients) {
records :+ jdbcFeeder(“jdbc:db2://servername:50001/” + client, “username”, “password”,
“SELECT MEMBER_ID, FIRST_NAME, LAST_NAME FROM MEMBER fetch first " + nbUsers + " rows only”).random
}

records
}

However, this results in a strange compile error.

[WARNING] warning: Class org.glassfish.grizzly.filterchain.FilterChainContext not found - continuing with a stub.
[ERROR] error: error while loading FeedableBodyGenerator, class file ‘/Users/mraible/.m2/repository/io/gatling/async-http-client/1.9.0-BETA6-gatling-1/async-http-client-1.9.0-BETA6-gatling-1.jar(com/ning/http/client/providers/grizzly/FeedableBodyGenerator.class)’ is broken
[INFO] (class java.lang.NullPointerException/null)
[WARNING] one warning found
[ERROR] one error found

I’m using Gatling 2.0.0-RC2.

Thanks,

Matt

Hi Matt,

JdbcFeeders are built upfront, before running the simulation. That’s the only way to not lag while running.

Sorry, I’m not sure I understand what you’re trying to do (or how you’re trying to do it).
What you can do is grab the data backing the feeder, index it (turn it into a Map) and manually join to get the records you want inside a exec(function) block.
Get it?

Regarding the error you get, I really don’t get how you can end up with an Exception related to Grizzly while we use the Netty provider and don’t ship (and don’t support) Grizzly?!
Could you share your Simulation please?

Cheers,

Stéphane

Hi Matt,

JdbcFeeders are built upfront, before running the simulation. That’s the only way to not lag while running.

That makes sense.

Sorry, I’m not sure I understand what you’re trying to do (or how you’re trying to do it).
What you can do is grab the data backing the feeder, index it (turn it into a Map) and manually join to get the records you want inside a exec(function) block.
Get it?

That sounds like it might work. How do I get the data from the feeder? Is it possible to dynamically build feeders for each client like my example below?

Regarding the error you get, I really don’t get how you can end up with an Exception related to Grizzly while we use the Netty provider and don’t ship (and don’t support) Grizzly?!
Could you share your Simulation please?

It turned out to be caused by a couple unused imports that got added by IntelliJ when I was trying to make this work:

import com.ning.http.client.providers.grizzly.FeedableBodyGenerator.Feeder
import io.gatling.core.action.builder.FeedBuilder

Removing them got everything to compile.

That sounds like it might work. How do I get the data from the feeder?

jdbcFeeder("sql").records

Is it possible to dynamically build feeders for each client like my
example below?

I'm not sure what a "client" means to you. Is is a virtual user? Or some
domain? If the latter, and there's not to many of them and you know them
upfront, you could consider using a doSwitch.
http://gatling.io/docs/2.0.0-RC2/cheat-sheet.html

It turned out to be caused by a couple unused imports that got added by
IntelliJ when I was trying to make this work:

import com.ning.http.client.providers.grizzly.FeedableBodyGenerator.Feeder
import io.gatling.core.action.builder.FeedBuilder

Removing them got everything to compile.

Glad to hear, I was about to call an exorcist.

Yes, it’s similar to a virtual user. In the application I’m testing, each client has a different database - so I want to grab data for each client to use in requests. I looked into doSwitch, then found roundRobinSwitch - which seems like it might fit my needs better. Here’s what I tried:

def lookupFeeder(client: String) = client →
feed(jdbcFeeder(“jdbc:db2://servername:50001/” + client, “username”, “password”,
“SELECT MEMBER_ID, FIRST_NAME, LAST_NAME FROM MEMBER fetch first " + nbUsers + " rows only”).random)

val scn = scenario(“Member Service”)
.roundRobinSwitch (
lookupFeeder(“client1”),
lookupFeeder(“client2”),
lookupFeeder(“client3”),
lookupFeeder(“client4”),
lookupFeeder(“client5”)
)

If I try this, I get:

[ERROR] /Users/mraible/…/MemberServiceSimulation.scala:23: error: type mismatch;
[ERROR] found : (String, io.gatling.core.structure.ChainBuilder)
[ERROR] required: io.gatling.core.structure.ChainBuilder
[ERROR] lookupFeeder(“client1”),

[ERROR] ^
[ERROR] one error found
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------

Thanks for any advice.

Matt

Well, the compiler error is pretty clear :slight_smile:

lookupFeeder returns couples of (String, ChainBuilder) (before of the “client ->” you left) with roundRobinSwitch expect just a ChainBuilder.
Simply remove your “client ->”

That worked - thanks!

Glad to hear.
have fun with Gatling!