AutomicLong used by two Feeders

21 views
Skip to first unread message

CyberNinja

unread,
Aug 26, 2016, 1:03:42 AM8/26/16
to Gatling User Group
Hi All,

An AutomicLong val (idSequence) in my simulation is used by two feeders. FirstFeeder increments the value and uses it.
SecondFeeder needs to use it as it is and this value needs to be same as the one used by FirstFeeder. This is currently not happening because idSequence will be used by other users in the test. So i get different values is both feeders.
Is there any way to get this working?


val idSequence = new AtomicLong(0);

//in 'before' hook, idSequence is loaded with a Long value from a file

val firstFeeder = Iterator.continually(Map("first" -> {
var next: Long = idSequence.incrementAndGet()
// do some processing on next and return
next;
}))

val secondFeeder = Iterator.continually(Map("second" -> {
var curr: Long = idSequence.get() //this doesn't return correct value because idSequence is also used by other users
// do some processing on curr and return
curr;
}))

//in my scenario(), the feeders are fed like this

.feed(firstFeeder)
.exec(somethingThatUsesNext)
.feed(secondFeeder)
.exec(somethingThatUsesCurr)

//in 'after' hook, once test is finished, the last used idSequence is written back to the file to use for next execution



CyberNinja

unread,
Aug 30, 2016, 2:21:25 AM8/30/16
to Gatling User Group
Any suggestions folks?

Stéphane LANDELLE

unread,
Sep 1, 2016, 9:19:15 AM9/1/16
to gat...@googlegroups.com
A feeder is a shared datasource.
If you want a per user counters, don't use a feeder and store those counters in each virtual user's session.

Stéphane Landelle
GatlingCorp CEO


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

Reply all
Reply to author
Forward
0 new messages