forked from ringcentral/jagger8
-
Notifications
You must be signed in to change notification settings - Fork 0
Custom query distributors
amikryukov edited this page May 6, 2013
·
2 revisions
#Custom query distributors
- Create class which extends class QueryPoolLoadBalancer
package test;
...
public class CustomDistributor<Q, E> extends com.griddynamics.jagger.invoker.QueryPoolLoadBalancer<Q, E> {
@Override
public Iterator<com.griddynamics.jagger.util.Pair<Q, E>> provide() {
...
}
}
- Create bean in XML file in one of the subdirectories directory "suite" with this class
<beans:bean id="customDistributor" class="test.CustomDistributor"/>
- Create component "query-distributor" with type "query-distributor-ref" and set attribute "ref" to id of bean
<scenario ...>
...
<query-distributor xsi:type="query-distributor-ref" ref="customDistributor"/>
</scenario>
Let's make simple custom Query Distributor.
package group.id.distributor;
import com.griddynamics.jagger.invoker.QueryPoolLoadBalancer;
import com.griddynamics.jagger.util.Pair;
import java.util.Iterator;
public class FirstPairDistributer<Q, E> extends QueryPoolLoadBalancer<Q, E> {
@Override
public Iterator<Pair<Q, E>> provide() {
final Q query = queryProvider.iterator().next();
final E endpoint = endpointProvider.iterator().next();
return new Iterator<Pair<Q, E>>() {
@Override
public boolean hasNext() {
return true;
}
@Override
public Pair<Q, E> next() {
return Pair.of(query, endpoint);
}
@Override
public void remove() {
throw new UnsupportedOperationException("Read only iterator");
}
@Override
public String toString() {
return "FirstPair iterator";
}
};
}
@Override
public String toString() {
return "FirstPairDistributer";
}
}
<bean id="first-pair-distributor" class="group.id.distributor.FirstPairDistributer"/>
<beans:import resource="distributor/distributor.conf.xml"/>
<test-description id="jaggerPageTestWithCustomDistributor" parent="default" calibration="true">
<scenario xsi:type="scenario-query-pool">
<!----><query-distributor xsi:type="query-distributor-ref" ref="first-pair-distributor"/><!---->
<invoker xsi:type="invoker-class" class="group.id.PageVisitorInvoker"/>
<endpoint-provider xsi:type="endpoint-provider-list">
<endpoint>https://jagger.griddynamics.net</endpoint>
</endpoint-provider>
<query-provider xsi:type="query-provider-list">
<query>index.html</query>
<query>screenshots.html</query>
<query>download.html</query>
</query-provider>
</scenario>
</test-description>
And that is it.
For more examples take a look at Samples.