<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Blog Aliecom</title>
	<atom:link href="http://blog.aliecom.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.aliecom.com</link>
	<description>Le Blog des Experts en Performance Informatique</description>
	<lastBuildDate>Mon, 07 May 2012 11:36:46 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>Aliecom au Breizhcamp 2012 !</title>
		<link>http://blog.aliecom.com/aliecom-au-breizhcamp-2012/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=aliecom-au-breizhcamp-2012</link>
		<comments>http://blog.aliecom.com/aliecom-au-breizhcamp-2012/#comments</comments>
		<pubDate>Mon, 07 May 2012 11:15:54 +0000</pubDate>
		<dc:creator>Stéphane Chabrier</dc:creator>
				<category><![CDATA[Actualité - Evènements]]></category>

		<guid isPermaLink="false">http://blog.aliecom.com/?p=1443</guid>
		<description><![CDATA[&#160; Le 14 et 15 Juin prochain se tiendra la Breizhcamp version 2012 avec au programme une multitude de sujets sur des technologies éprouvées, des méthodologies et des nouveaux outils. &#160; A ce titre, Aliecom sera présent pour parler de la "mesure de la performance dans le milieu hostile du développement Java". Antonio Gomes-Rodrigues, consultant [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://blog.aliecom.com/aliecom-au-breizhcamp-2012/breizhcamp-copie/" rel="attachment wp-att-1450"><img class="alignleft  wp-image-1450" title="BreizhCamp - Copie" src="http://blog.aliecom.com/wp-content/uploads/2012/05/BreizhCamp-Copie.png" alt="" width="236" height="114" /></a><br />
&nbsp;<br />
Le 14 et 15 Juin prochain se tiendra la <a title="breizhcamp 2012" href="http://www.breizhcamp.org" target="_blank">Breizhcamp </a>version 2012 avec au programme une multitude de sujets sur des technologies éprouvées, des méthodologies et des nouveaux outils.</p>
<p>&nbsp;</p>
<p>A ce titre, Aliecom sera présent pour parler de la "mesure de la performance dans le milieu hostile du développement Java".<br />
<span id="more-1443"></span><br />
Antonio Gomes-Rodrigues, consultant expert justifiant de plusieurs années d'expérience sur les sujets gravitant autour de la performance, va nous apporter un peu de recul sur ce sujet extrêmement sensible et qui fait souvent défaut aux équipes d'intégration.</p>
<p>Un petit avant-goût du <a title="Breizhcamp programme" href="http://www.breizhcamp.org/programme" target="_blank">programme </a>:</p>
<p><em>"Lors de mes missions d'audit de performance, je vois régulièrement de gros problèmes de performance qui auraient pu être anticipés par le développeur sur son environnement de travail local. Partant de ce constat nous prendrons comme contexte le poste de développement d’un ingénieur Java intégré dans une équipe qui ne prête pas particulièrement attention à la notion de performance. Nous démontrerons qu'il ne faut pas vouloir tout optimiser mais plutôt les 20% utiles. (loi de Pareto) Afin de cibler ces 20% nous aborderons en détail l'importance de la mesure de la performance. Puis nous finirons par la présentation d'un certain nombre d'outils et pratiques permettant ces mesures. "</em></p>
<p>Venez nombreux, il y a plein de sujets passionnants ... et en plus c'est pas cher !!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.aliecom.com/aliecom-au-breizhcamp-2012/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ContiPerf</title>
		<link>http://blog.aliecom.com/contiperf/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=contiperf</link>
		<comments>http://blog.aliecom.com/contiperf/#comments</comments>
		<pubDate>Mon, 19 Mar 2012 21:34:09 +0000</pubDate>
		<dc:creator>Antonio Gomes-Rodrigues</dc:creator>
				<category><![CDATA[Tests de charge et performance]]></category>
		<category><![CDATA[Performance applicative]]></category>

		<guid isPermaLink="false">http://blog.aliecom.com/?p=1346</guid>
		<description><![CDATA[1. Introduction Lorsque l’on fait du développement Java, on ne se préoccupe pas toujours des problèmes de performance. Et lorsque la performance est une contrainte, on ne sait pas toujours comment la mesurer et avec quel outil. Idéalement, cet outil s'intègrerait à notre environnement de développement et se lancerait automatiquement. En somme, il nous faudrait [...]]]></description>
			<content:encoded><![CDATA[<h2>1.	Introduction</h2>
<p>Lorsque l’on fait du développement Java, on ne se préoccupe pas toujours des problèmes de performance. Et lorsque la performance est une contrainte, on ne sait pas toujours comment la mesurer et avec quel outil.<br />
Idéalement, cet outil s'intègrerait à notre environnement de développement et se lancerait automatiquement. </p>
<p>En somme, il nous faudrait un framework comme <a href="http://www.junit.org/" target="_blank">JUnit </a>mais dédié à la performance. </p>
<p><span id="more-1346"></span></p>
<h2>2.	Présentation de ContiPerf</h2>
<p>Bonne nouvelle, cela existe et porte le nom de ContiPerf. </p>
<p>ContiPerf se présente comme une surcouche à JUnit 4 pour les tests de performances, avec toutes ces facilités et avantages : </p>
<ul>
<li>configuration par annotations ;</li>
<li>intégration avec les IDE supportant JUnit 4 comme <a href="http://www.eclipse.org/" target="_blank">Eclipse</a>, <a href="http://netbeans.org/" target="_blank">Netbeans</a>... ; </li>
<li>intégration avec Apache <a href="http://maven.apache.org/" target="_blank">Maven</a> ; </li>
<li>aucune dépendance à part JUnit ; </li>
<li>export des résultats au format CSV et HTML ; </li>
<li>regroupement des tests en Test Suites.</li>
</ul>
<p><br/></p>
<p class="tip">Attention, ContiPerf ne remplace pas une bonne méthode de test de performance (avoir des résultats reproductibles, avoir les bons jeux de test...) et en particulier les tests de charge.<br />
De plus, il n'est pas encore adapté au microbenchmarking.</p>
<p><br/></p>
<p>Pour plus d'informations, <a href="http://databene.org/contiperf" target="_blank">le site officiel</a> est très complet.</p>
<p>Avant de commencer à écrire des tests unitaires de performance, regardons comment intégrer ContiPerf à notre environnement de développement. </p>
<h2>3.	Intégration dans un IDE </h2>
<p>Afin d'intégrer ContiPerf à votre IDE, il suffit d'ajouter la librairie contiperf.jar dans le Classpath. </p>
<p><a href="http://blog.aliecom.com/contiperf/tools_contiperf_dependance/" rel="attachment wp-att-1378"><img src="http://blog.aliecom.com/wp-content/uploads/2012/03/Tools_contiperf_dependance-300x132.jpg" alt="" title="Tools_contiperf_dependance" width="300" height="132" class="aligncenter size-medium wp-image-1378" /></a></p>
<p><br/><br />
Puis afin de lancer le test, on fait comme pour JUnit. </p>
<p>Par exemple avec Netbeans. </p>
<p><a href="http://blog.aliecom.com/contiperf/tools_contiperf_netbeans/" rel="attachment wp-att-1379"><img src="http://blog.aliecom.com/wp-content/uploads/2012/03/Tools_contiperf_netbeans-279x300.jpg" alt="" title="Tools_contiperf_netbeans" width="279" height="300" class="aligncenter size-medium wp-image-1379" /></a><br />
<br/><br />
<a href="http://blog.aliecom.com/contiperf/tools_contiperf_netbeans_2/" rel="attachment wp-att-1380"><img src="http://blog.aliecom.com/wp-content/uploads/2012/03/Tools_contiperf_netbeans_2-300x70.jpg" alt="" title="Tools_contiperf_netbeans_2" width="300" height="70" class="aligncenter size-medium wp-image-1380" /></a></p>
<p><br/></p>
<h2>4.	Intégration avec Maven</h2>
<p>L'intégration à Maven est tout aussi simple.</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">&lt;!-- Test dependencies --&gt;</span> 
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span> 
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>org.junit<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span> 
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>com.springsource.org.junit<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span> 
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>4.7.0<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span> 
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;scope<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>test<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/scope<span style="color: #000000; font-weight: bold;">&gt;</span></span></span> 
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span> 
&nbsp;
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span> 
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>org.databene<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span> 
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>contiperf<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span> 
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>2.0.0<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span> 
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;scope<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>test<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/scope<span style="color: #000000; font-weight: bold;">&gt;</span></span></span> 
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p><br/></p>
<h2>5.	Go pour la pratique</h2>
<p>Maintenant que vous êtes entièrement convaincu (enfin j'espère !), regardons d'un peu plus près comment écrire un test de performance ContiPerf. </p>
<p class="tip">Pour ceux qui n'ont pas l'habitude de JUnit, je leur conseille de l'étudier avant.</p>
<h2>6.	Écrire un test ContiPerf</h2>
<p>Pour un test, il nous faut : </p>
<ul>
<li>un objet <em>ContiPerfRule</em> et son annotation <em>@Rule</em> ; </li>
<li>un protocole de test (nombre d'itération, nombre de thread, durée du test) défini à l'aide de l'annotation <em>@PerfTest</em> ; </li>
<li>des critères d'acceptance (moyenne / médian / max / percentiles  / durée totale / throughput / temps de réponses) définis à l'aide de l'annotation <em>@Required</em> ; </li>
<li>du code métier.</li>
</ul>
<p><br/><br />
Le tout aura la forme suivante</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">  <span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.junit.*</span><span style="color: #339933;">;</span> 
  <span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.databene.contiperf.*</span><span style="color: #339933;">;</span> 
&nbsp;
  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> SimpleTest <span style="color: #009900;">&#123;</span> 
&nbsp;
      @Rule 
      <span style="color: #000000; font-weight: bold;">public</span> ContiPerfRule i <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> ContiPerfRule<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
&nbsp;
      @Test 
      @PerfTest<span style="color: #009900;">&#40;</span>invocations <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1000</span>, threads <span style="color: #339933;">=</span> <span style="color: #cc66cc;">20</span><span style="color: #009900;">&#41;</span> 
      @Required<span style="color: #009900;">&#40;</span>max <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1200</span>, average <span style="color: #339933;">=</span> <span style="color: #cc66cc;">250</span>, median <span style="color: #339933;">=</span> <span style="color: #cc66cc;">300</span><span style="color: #009900;">&#41;</span> 
      <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> testCodeMetier<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <span style="color: #003399;">Exception</span> <span style="color: #009900;">&#123;</span> 
          <span style="color: #666666; font-style: italic;">// code metier a tester </span>
      <span style="color: #009900;">&#125;</span> 
&nbsp;
  <span style="color: #009900;">&#125;</span></pre></div></div>

<p>Si l'on veut que ContiPerf génère aussi les rapports, il faut remplacer la ligne</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">      @Rule 
      <span style="color: #000000; font-weight: bold;">public</span> ContiPerfRule i <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> ContiPerfRule<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>par</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">    @Rule 
    <span style="color: #000000; font-weight: bold;">public</span> ContiPerfRule rule <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> ContiPerfRule<span style="color: #009900;">&#40;</span> 
            <span style="color: #000000; font-weight: bold;">new</span> HtmlReportModule<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>, 
            <span style="color: #000000; font-weight: bold;">new</span> CSVSummaryReportModule<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>, 
            <span style="color: #000000; font-weight: bold;">new</span> CSVInvocationReportModule<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>, 
            <span style="color: #000000; font-weight: bold;">new</span> CSVLatencyReportModule<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<h2>7.	Exemple 1 : maximum 15ms avec une moyenne inférieure à 10ms</h2>
<p>Nous allons écrire des tests ContiPerf pour l'application <a href="http://static.springsource.org/docs/petclinic.html">Spring PetClinic</a>. </p>
<p>Dans un premier temps, nous allons tester la class <em>org.springframework.samples.petclinic.Pet</em></p>
<p>Testons la création (<em>new Pet</em>) de 100 chiens prénommés Medor (<em>setName</em>).</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">@Rule 
    <span style="color: #000000; font-weight: bold;">public</span> ContiPerfRule i <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> ContiPerfRule<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
&nbsp;
    @Test 
    @PerfTest<span style="color: #009900;">&#40;</span>invocations <span style="color: #339933;">=</span> <span style="color: #cc66cc;">100</span>, threads <span style="color: #339933;">=</span> <span style="color: #cc66cc;">100</span><span style="color: #009900;">&#41;</span> 
    @Required<span style="color: #009900;">&#40;</span>max <span style="color: #339933;">=</span> <span style="color: #cc66cc;">15</span>, average <span style="color: #339933;">=</span> <span style="color: #cc66cc;">10</span><span style="color: #009900;">&#41;</span> 
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> testsetName<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> 
        Pet monChien <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Pet<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
        monChien.<span style="color: #006633;">setName</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Medor&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
    <span style="color: #009900;">&#125;</span></pre></div></div>

<p>Dans ce test, on crée 100 chiens (<em>invocations = 100</em>) en parallèle (1 par thread) et on veut qu'une création dure au maximum 15ms (<em>max</em>) avec une moyenne (<em>average</em>) inférieure à 10ms. </p>
<p><a href="http://blog.aliecom.com/contiperf/tools_contiperf_test_1/" rel="attachment wp-att-1383"><img src="http://blog.aliecom.com/wp-content/uploads/2012/03/Tools_contiperf_test_1-300x110.jpg" alt="" title="Tools_contiperf_test_1" width="300" height="110" class="aligncenter size-medium wp-image-1383" /></a><br />
<br/></p>
<h2>8.	Exemple 2 : maximum 15ms avec une moyenne inférieure à 10ms</h2>
<p>Reprenons le même exemple, mais cette fois ci pour certaines raisons (par exemple un pool), on sait qu'il n'y aura jamais plus de 10 créations de chien en même temps. </p>
<p>L'exemple devient.</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">    @Rule 
    <span style="color: #000000; font-weight: bold;">public</span> ContiPerfRule i <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> ContiPerfRule<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
&nbsp;
    @Test 
    @PerfTest<span style="color: #009900;">&#40;</span>invocations <span style="color: #339933;">=</span> <span style="color: #cc66cc;">100</span>, threads <span style="color: #339933;">=</span> <span style="color: #cc66cc;">10</span><span style="color: #009900;">&#41;</span> 
    @Required<span style="color: #009900;">&#40;</span>max <span style="color: #339933;">=</span> <span style="color: #cc66cc;">15</span>, average <span style="color: #339933;">=</span> <span style="color: #cc66cc;">10</span><span style="color: #009900;">&#41;</span> 
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> testsetName<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> 
        Pet monChien <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Pet<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
        monChien.<span style="color: #006633;">setName</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Medor&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
    <span style="color: #009900;">&#125;</span></pre></div></div>

<p>Ici chaque thread va créer 10 chiens (invocations/threads) pour un total de 100 chiens. </p>
<p><a href="http://blog.aliecom.com/contiperf/tools_contiperf_test_2/" rel="attachment wp-att-1384"><img src="http://blog.aliecom.com/wp-content/uploads/2012/03/Tools_contiperf_test_2-300x109.jpg" alt="" title="Tools_contiperf_test_2" width="300" height="109" class="aligncenter size-medium wp-image-1384" /></a></p>
<p><br/></p>
<h2>9.	Exemple 3 : throughput au minimum de 400 </h2>
<p>Toujours avec le même exemple mais maintenant on veut que le throughput soit au minimum de 400 invocations par seconde.</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;">    @Rule 
    public ContiPerfRule i = new ContiPerfRule(); 
&nbsp;
    @Test 
    @PerfTest(duration = 100000, threads = 10) 
    @Required(throughput = 400) 
    public void testsetName() { 
        Pet monChien = new Pet(); 
        monChien.setName(&quot;Medor&quot;); 
    }</pre></div></div>

<p>Ici le test dure 100s. </p>
<p><a href="http://blog.aliecom.com/contiperf/tools_contiperf_test_3/" rel="attachment wp-att-1385"><img src="http://blog.aliecom.com/wp-content/uploads/2012/03/Tools_contiperf_test_3-300x111.jpg" alt="" title="Tools_contiperf_test_3" width="300" height="111" class="aligncenter size-medium wp-image-1385" /></a></p>
<p><br/></p>
<h2>10.	Exemple 4 : percentil</h2>
<p>Enfin, pour ceux qui trouvent que l'utilisation du percentil est plus intéressante que la moyenne, il suffit de modifier le test de l'exemple 2 en remplaçant <em>average</em> par <em>percentile99</em>. </p>
<p>Par exemple, si on veut que 99% des exécutions ne durent pas plus de 6ms, l'exemple devient.</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">    @Rule 
    <span style="color: #000000; font-weight: bold;">public</span> ContiPerfRule i <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> ContiPerfRule<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
&nbsp;
    @Test 
    @PerfTest<span style="color: #009900;">&#40;</span>invocations <span style="color: #339933;">=</span> <span style="color: #cc66cc;">100</span>, threads <span style="color: #339933;">=</span> <span style="color: #cc66cc;">10</span><span style="color: #009900;">&#41;</span> 
    @Required<span style="color: #009900;">&#40;</span>max <span style="color: #339933;">=</span> <span style="color: #cc66cc;">10</span>, percentile99 <span style="color: #339933;">=</span> <span style="color: #cc66cc;">6</span><span style="color: #009900;">&#41;</span> 
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> testsetName<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> 
        Pet monChien <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Pet<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
        monChien.<span style="color: #006633;">setName</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Medor&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
    <span style="color: #009900;">&#125;</span></pre></div></div>

<p><a href="http://blog.aliecom.com/contiperf/tools_contiperf_test_4/" rel="attachment wp-att-1386"><img src="http://blog.aliecom.com/wp-content/uploads/2012/03/Tools_contiperf_test_4-300x101.png" alt="" title="Tools_contiperf_test_4" width="300" height="101" class="aligncenter size-medium wp-image-1386" /></a></p>
<p><br/></p>
<h2>11.	Exemple 5 : mutualisation des critères d'acceptance</h2>
<p>Continuons avec la class <em>org.springframework.samples.petclinic.Pet</em> </p>
<p>Ajoutons le test de la fonction <em>setType</em></p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">    @Test 
    @PerfTest<span style="color: #009900;">&#40;</span>invocations <span style="color: #339933;">=</span> <span style="color: #cc66cc;">100</span>, threads <span style="color: #339933;">=</span> <span style="color: #cc66cc;">10</span><span style="color: #009900;">&#41;</span> 
    @Required<span style="color: #009900;">&#40;</span>max <span style="color: #339933;">=</span> <span style="color: #cc66cc;">10</span>, percentile99 <span style="color: #339933;">=</span> <span style="color: #cc66cc;">5</span><span style="color: #009900;">&#41;</span> 
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> testsetType<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> 
        PetType bulldog <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> PetType<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
        bulldog.<span style="color: #006633;">setName</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;bulldog&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
        Pet monChien <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Pet<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
        monChien.<span style="color: #006633;">setType</span><span style="color: #009900;">&#40;</span>bulldog<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
    <span style="color: #009900;">&#125;</span></pre></div></div>

<p><a href="http://blog.aliecom.com/contiperf/tools_contiperf_test_5/" rel="attachment wp-att-1387"><img src="http://blog.aliecom.com/wp-content/uploads/2012/03/Tools_contiperf_test_5-300x104.png" alt="" title="Tools_contiperf_test_5" width="300" height="104" class="aligncenter size-medium wp-image-1387" /></a></p>
<p><br/></p>
<p>Lorsqu'on a plusieurs tests pour une classe, on peut regrouper le protocole de test (<em>@PerfTest</em>) et les critères d'acceptance (<em>@Required</em>) au niveau de la classe et plus au niveau des fonctions. </p>
<p>Par exemple, pour mettre en commun notre protocole de test pour les deux tests ContiPerf, il suffit d'écrire le test de la manière suivante.</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">@PerfTest<span style="color: #009900;">&#40;</span>invocations <span style="color: #339933;">=</span> <span style="color: #cc66cc;">100</span>, threads <span style="color: #339933;">=</span> <span style="color: #cc66cc;">10</span><span style="color: #009900;">&#41;</span> 
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> PetTestsPerf <span style="color: #009900;">&#123;</span> 
&nbsp;
    @Rule 
    <span style="color: #000000; font-weight: bold;">public</span> ContiPerfRule i <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> ContiPerfRule<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> PetTestsPerf<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> 
    <span style="color: #009900;">&#125;</span> 
&nbsp;
    @Test 
    @Required<span style="color: #009900;">&#40;</span>max <span style="color: #339933;">=</span> <span style="color: #cc66cc;">10</span>, percentile99 <span style="color: #339933;">=</span> <span style="color: #cc66cc;">6</span><span style="color: #009900;">&#41;</span> 
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> testsetName<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> 
        Pet monChien <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Pet<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
        monChien.<span style="color: #006633;">setName</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Medor&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
    <span style="color: #009900;">&#125;</span> 
&nbsp;
    @Test 
    @Required<span style="color: #009900;">&#40;</span>max <span style="color: #339933;">=</span> <span style="color: #cc66cc;">10</span>, percentile99 <span style="color: #339933;">=</span> <span style="color: #cc66cc;">5</span><span style="color: #009900;">&#41;</span> 
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> testsetType<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> 
        PetType bulldog <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> PetType<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
        bulldog.<span style="color: #006633;">setName</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;bulldog&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
        Pet monChien <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Pet<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
        monChien.<span style="color: #006633;">setType</span><span style="color: #009900;">&#40;</span>bulldog<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
    <span style="color: #009900;">&#125;</span> 
<span style="color: #009900;">&#125;</span></pre></div></div>

<h2>12.	Exemple 6</h2>
<p>Poursuivons avec un test plus complexe de la classe <em>org.springframework.samples.petclinic.web.VisitsAtomView.</em></p>
<p>Pour cela, nous allons reprendre le test unitaire qui existe déjà et le transformer en test ContiPerf.</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">org.springframework.samples.petclinic.web</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.sun.syndication.feed.atom.Entry</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.sun.syndication.feed.atom.Feed</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.*</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.databene.contiperf.PerfTest</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.databene.contiperf.Required</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.junit.Before</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.junit.Test</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.springframework.samples.petclinic.Pet</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.springframework.samples.petclinic.PetType</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.springframework.samples.petclinic.Visit</span><span style="color: #339933;">;</span>
&nbsp;
@PerfTest<span style="color: #009900;">&#40;</span>invocations <span style="color: #339933;">=</span> <span style="color: #cc66cc;">100</span>, threads <span style="color: #339933;">=</span> <span style="color: #cc66cc;">10</span><span style="color: #009900;">&#41;</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> VisitsAtomViewTestsPerf <span style="color: #009900;">&#123;</span>
&nbsp;
    @Rule
    <span style="color: #000000; font-weight: bold;">public</span> ContiPerfRule i <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> ContiPerfRule<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">private</span> VisitsAtomView visitView<span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">private</span> Map<span style="color: #339933;">&lt;</span>String, Object<span style="color: #339933;">&gt;</span> model<span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">private</span> Feed feed<span style="color: #339933;">;</span>
&nbsp;
    @Before
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> setUp<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        visitView <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> VisitsAtomView<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        PetType dog <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> PetType<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        dog.<span style="color: #006633;">setName</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;dog&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        Pet bello <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Pet<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        bello.<span style="color: #006633;">setName</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Bello&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        bello.<span style="color: #006633;">setType</span><span style="color: #009900;">&#40;</span>dog<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        Visit belloVisit <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Visit<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        belloVisit.<span style="color: #006633;">setPet</span><span style="color: #009900;">&#40;</span>bello<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        belloVisit.<span style="color: #006633;">setDate</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">Date</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">2009</span>, <span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        belloVisit.<span style="color: #006633;">setDescription</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Bello visit&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        Pet wodan <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Pet<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        wodan.<span style="color: #006633;">setName</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Wodan&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        wodan.<span style="color: #006633;">setType</span><span style="color: #009900;">&#40;</span>dog<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        Visit wodanVisit <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Visit<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        wodanVisit.<span style="color: #006633;">setPet</span><span style="color: #009900;">&#40;</span>wodan<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        wodanVisit.<span style="color: #006633;">setDate</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">Date</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">2009</span>, <span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        wodanVisit.<span style="color: #006633;">setDescription</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Wodan visit&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        List<span style="color: #339933;">&lt;</span>Visit<span style="color: #339933;">&gt;</span> visits <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> ArrayList<span style="color: #339933;">&lt;</span>Visit<span style="color: #339933;">&gt;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        visits.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span>belloVisit<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        visits.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span>wodanVisit<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        model <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> HashMap<span style="color: #339933;">&lt;</span>String, Object<span style="color: #339933;">&gt;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        model.<span style="color: #006633;">put</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;visits&quot;</span>, visits<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        feed <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Feed<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #009900;">&#125;</span>
&nbsp;
    @Test
    @Required<span style="color: #009900;">&#40;</span>max <span style="color: #339933;">=</span> <span style="color: #cc66cc;">30</span>, percentile99 <span style="color: #339933;">=</span> <span style="color: #cc66cc;">7</span><span style="color: #009900;">&#41;</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> buildFeedMetadata<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        visitView.<span style="color: #006633;">buildFeedMetadata</span><span style="color: #009900;">&#40;</span>model, feed, <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    @Test
    @Required<span style="color: #009900;">&#40;</span>max <span style="color: #339933;">=</span> <span style="color: #cc66cc;">80</span>, percentile99 <span style="color: #339933;">=</span> <span style="color: #cc66cc;">42</span><span style="color: #009900;">&#41;</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> buildFeedEntries<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <span style="color: #003399;">Exception</span> <span style="color: #009900;">&#123;</span>
        List<span style="color: #339933;">&lt;</span>Entry<span style="color: #339933;">&gt;</span> entries <span style="color: #339933;">=</span> visitView.<span style="color: #006633;">buildFeedEntries</span><span style="color: #009900;">&#40;</span>model, <span style="color: #000066; font-weight: bold;">null</span>, <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p><a href="http://blog.aliecom.com/contiperf/tools_contiperf_test_6/" rel="attachment wp-att-1377"><img src="http://blog.aliecom.com/wp-content/uploads/2012/03/Tools_contiperf_test_6-300x170.png" alt="" title="Tools_contiperf_test_6" width="300" height="170" class="aligncenter size-medium wp-image-1377" /></a></p>
<p><br/></p>
<h2>13.	Performance Test Suites</h2>
<p>Bien sûr, on peut regrouper plusieurs tests ContiPerf dans une Test Suite. </p>
<p>Pour cela, il faut utiliser ces deux annotations. </p>
<p><em>@RunWith(ContiPerfSuiteRunner.class) </em><br />
<em>@Suite.SuiteClasses({liste des classes à tester}) </em></p>
<p>Dans notre exemple on aura.</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">org.springframework.samples.petclinic</span><span style="color: #339933;">;</span> 
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.databene.contiperf.junit.ContiPerfSuiteRunner</span><span style="color: #339933;">;</span> 
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.junit.After</span><span style="color: #339933;">;</span> 
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.junit.AfterClass</span><span style="color: #339933;">;</span> 
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.junit.Before</span><span style="color: #339933;">;</span> 
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.junit.BeforeClass</span><span style="color: #339933;">;</span> 
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.junit.runner.RunWith</span><span style="color: #339933;">;</span> 
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.junit.runners.Suite</span><span style="color: #339933;">;</span> 
&nbsp;
&nbsp;
@RunWith<span style="color: #009900;">&#40;</span>ContiPerfSuiteRunner.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span> 
@Suite.<span style="color: #006633;">SuiteClasses</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>org.<span style="color: #006633;">springframework</span>.<span style="color: #006633;">samples</span>.<span style="color: #006633;">petclinic</span>.<span style="color: #006633;">PetTestsPerf</span>.<span style="color: #000000; font-weight: bold;">class</span>, org.<span style="color: #006633;">springframework</span>.<span style="color: #006633;">samples</span>.<span style="color: #006633;">petclinic</span>.<span style="color: #006633;">OwnerTestsPerf</span>.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span> 
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> PetclinicTestSuite <span style="color: #009900;">&#123;</span> 
&nbsp;
    @BeforeClass 
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> setUpClass<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <span style="color: #003399;">Exception</span> <span style="color: #009900;">&#123;</span> 
    <span style="color: #009900;">&#125;</span> 
&nbsp;
    @AfterClass 
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> tearDownClass<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <span style="color: #003399;">Exception</span> <span style="color: #009900;">&#123;</span> 
    <span style="color: #009900;">&#125;</span> 
&nbsp;
    @Before 
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> setUp<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <span style="color: #003399;">Exception</span> <span style="color: #009900;">&#123;</span> 
    <span style="color: #009900;">&#125;</span> 
&nbsp;
    @After 
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> tearDown<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <span style="color: #003399;">Exception</span> <span style="color: #009900;">&#123;</span> 
    <span style="color: #009900;">&#125;</span> 
&nbsp;
<span style="color: #009900;">&#125;</span></pre></div></div>

<h2>14	Rapports</h2>
<p>Penchons nous un peu plus sur les rapports générés par ContiPerf. </p>
<p>Avec la version 2.0.1, deux formats d'exports sont possibles. </p>
<li>Le format HTML. </li>
<p><a href="http://blog.aliecom.com/contiperf/tools_contiperf_rapport_1/" rel="attachment wp-att-1381"><img src="http://blog.aliecom.com/wp-content/uploads/2012/03/Tools_contiperf_rapport_1-300x210.png" alt="" title="Tools_contiperf_rapport_1" width="300" height="210" class="aligncenter size-medium wp-image-1381" /></a></p>
<p>Pour avoir ce rapport (fichier index.html) il faut utiliser <em>public ContiPerfRule i = new ContiPerfRule();</em> ou <em>public ContiPerfRule i = new ContiPerfRule(new HtmlReportModule());</em></p>
<li>Le format CSV. </li>
<p><a href="http://blog.aliecom.com/contiperf/tools_contiperf_rapport_2/" rel="attachment wp-att-1382"><img src="http://blog.aliecom.com/wp-content/uploads/2012/03/Tools_contiperf_rapport_2-300x40.png" alt="" title="Tools_contiperf_rapport_2" width="300" height="40" class="aligncenter size-medium wp-image-1382" /></a></p>
<p>Comme on peut le voir, on générer jusqu’à trois fichiers CSV. </p>
<p><em>summary.csv</em> </p>
<p>Fichier contenant le résumé du test ContiPerf</p>

<div class="wp_syntax"><div class="code"><pre class="csv" style="font-family:monospace;">serviceId,startTime,duration,invocations,min,average,median,90%,95%,99%,max 
org.springframework.samples.petclinic.OwnerTestsPerf.testHasPet,1329047753040,78,1000,0,0.8,0,0,0,24,67</pre></div></div>

<p>Pour l'obternir, il faut utiliser <em>public ContiPerfRule i = new ContiPerfRule(new CSVSummaryReportModule());</em> </p>
<p><em>org.springframework.samples.petclinic.OwnerTestsPerf.testHasPet.inv.csv </em></p>
<p>Fichier contenant le temps de réponse de chaque itération.</p>

<div class="wp_syntax"><div class="code"><pre class="csv" style="font-family:monospace;">latency,startTimeNanos 
67,9452032779934 
63,9452036182461 
0,9452100152044 
0,9452100162800 
0,9452100186266 
0,9452100197511 
0,9452100212177 
0,9452100223492 
62,9452037698296 
62,9452037612671 
64,9452035922372 
67,9452033027032 
59,9452040662290 
59,9452040958767 
59,9452041381935 
61,9452038566633</pre></div></div>

<p>Pour l’obtenir il faut utiliser <em>public ContiPerfRule i = new ContiPerfRule(new CSVInvocationReportModule());</em> </p>
<p><em>org.springframework.samples.petclinic.OwnerTestsPerf.testHasPet.stat.csv </em></p>
<p>Fichier contenant la répartition des temps de réponse. Par exemple, ici on voit qu'il y a eu une réponse avec un temps de réponse de 9ms, neuf cent soixante dix neuf réponses avec un temps de réponse de 0ms, ...</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">latency,sampleCount 
<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">979</span> 
<span style="color: #cc66cc;">1</span>,<span style="color: #cc66cc;">0</span> 
<span style="color: #cc66cc;">2</span>,<span style="color: #cc66cc;">2</span> 
<span style="color: #cc66cc;">3</span>,<span style="color: #cc66cc;">0</span> 
<span style="color: #cc66cc;">4</span>,<span style="color: #cc66cc;">2</span> 
<span style="color: #cc66cc;">5</span>,<span style="color: #cc66cc;">0</span> 
<span style="color: #cc66cc;">6</span>,<span style="color: #cc66cc;">0</span> 
<span style="color: #cc66cc;">7</span>,<span style="color: #cc66cc;">0</span> 
<span style="color: #cc66cc;">8</span>,<span style="color: #cc66cc;">0</span> 
<span style="color: #cc66cc;">9</span>,<span style="color: #cc66cc;">1</span> 
<span style="color: #cc66cc;">10</span>,<span style="color: #cc66cc;">0</span> 
<span style="color: #cc66cc;">11</span>,<span style="color: #cc66cc;">0</span></pre></div></div>

<p>Pour l’obtenir, il faut utiliser <em>public ContiPerfRule i = new ContiPerfRule(new CSVLatencyReportModule()); </em></p>
<p>Comme on peut le voir, on peut faire des choses intéressantes avec les rapports standards (surtout avec les fichiers CSV). Si cela n'est pas suffisant, ContiPerf étant opensource et libre, on peut ajouter facilement enrichir des rapports et des métrics. </p>
<p>Supposons que nous voulions ajouter une metric dans le rapport HTML. </p>
<p>Pour cela nous devons modifier/utiliser trois fichiers sources : </p>
<ul>
<li>HtmlReportModule                  : code générant le rapport HTML ; </li>
<li>LatencyCounter                       : code calculant les metrics de base ; </li>
<li>PerformanceRequirement    : code contenant les critères d'acceptance. </li>
</ul>
<p>Dans le cas de mon besoin initial, les metrics présentés suffisent largement. Celà dit, je reste curieux de vos remarques et des évolutions que vous aurez pu opérer en fonction des votres. </p>
]]></content:encoded>
			<wfw:commentRss>http://blog.aliecom.com/contiperf/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Présentation de l’outil de génération de jeux de données Benerator</title>
		<link>http://blog.aliecom.com/presentation-de-loutil-de-generation-de-jeux-de-donnees-benerator/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=presentation-de-loutil-de-generation-de-jeux-de-donnees-benerator</link>
		<comments>http://blog.aliecom.com/presentation-de-loutil-de-generation-de-jeux-de-donnees-benerator/#comments</comments>
		<pubDate>Wed, 15 Feb 2012 13:03:32 +0000</pubDate>
		<dc:creator>Antonio Gomes-Rodrigues</dc:creator>
				<category><![CDATA[Performance applicative]]></category>
		<category><![CDATA[Tests de charge et performance]]></category>
		<category><![CDATA[benerator]]></category>
		<category><![CDATA[tests de charge]]></category>

		<guid isPermaLink="false">http://blog.aliecom.com/?p=1277</guid>
		<description><![CDATA[Afin qu'une campagne de tirs de charges soit la plus utile possible, il est souvent nécessaire d'avoir un jeu de données conséquent et réaliste. Pour cela plusieurs solutions existent : importation des données de la base de données de production ; création du jeu de données à l'aide d'outils maison ; utilisation d'ETL ; utilisation [...]]]></description>
			<content:encoded><![CDATA[<p>Afin qu'une campagne de tirs de charges soit la plus utile possible, il est souvent nécessaire d'avoir un jeu de données conséquent et réaliste. Pour cela plusieurs solutions existent :</p>
<ul>
<li>importation des données de la base de données de production ;</li>
<li>création du jeu de données à l'aide d'outils maison ;</li>
<li>utilisation d'ETL ;</li>
<li>utilisation de l’outil de test de charge et/ou de test fonctionnel afin d’exécuter des scripts qui vont remplir la base ;</li>
<li>utilisation d'outil de création de données.</li>
</ul>
<p>Nous allons nous focaliser sur la dernière solution avec l'utilisation de l'outil <a href="http://databene.org/databene-benerator.html" target="_blank">Benerator</a> qui couvre largement ce besoin.<br />
<span id="more-1277"></span></p>
<h2>1. Un peu de théorie</h2>
<p>Pour la partie théorique et quelques exemples, je vous laisse aller sur <a href="http://databene.org/databene-benerator.html" target="_blank">le site officiel</a> et sur mon <a href="http://arodrigues.developpez.com/tutoriels/java/performance/benerator/" target="_blank">précédent article sur developpez.com</a>.</p>
<h2>2. Passons à la pratique</h2>
<h3>2.1 Présentation du cas de test</h3>
<p>Dans cet article nous allons nous pencher sur la création de plusieurs jeux de données pour l'application démo PlantsByWebSphere livré avec <a href="http://www.ibm.com/developerworks/downloads/ws/was/" target="_blank">IBM WebSphere 8</a>. Nous utiliserons une base de données <a href="http://www.mysql.fr/" target="_blank">MySQL</a> en remplacement de Derby.</p>
<p>PlantsByWebSphere est une démonstration de boutique en ligne comme vous pouvez le voir sur cette capture d'écran.</p>
<p><a href="http://blog.aliecom.com/presentation-de-loutil-de-generation-de-jeux-de-donnees-benerator/tools_benerator_plantsbywebsphere/" rel="attachment wp-att-1311"><img src="http://blog.aliecom.com/wp-content/uploads/2012/01/Tools_Benerator_PlantsByWebSphere-300x222.jpg" alt="" title="Tools_Benerator_PlantsByWebSphere" width="300" height="222" class="aligncenter size-medium wp-image-1311" /></a></p>
<p>On remarque que :</p>
<ul>
<li>les produits sont divisés en 4 catégories (<em>Flowers</em>, <em>Fruits </em>&#038; <em>Vegetables</em>, <em>Trees</em> et <em>Accessories</em>) ;</li>
<li>l'application gère des comptes clients ;</li>
<li>l'application gère un panier d'achats.</li>
</ul>
<p><br/><br />
Regardons d'un peu plus près le schéma de la base de données.</p>
<p><a href="http://blog.aliecom.com/presentation-de-loutil-de-generation-de-jeux-de-donnees-benerator/tools_benerator_schema_bdd/" rel="attachment wp-att-1312"><img src="http://blog.aliecom.com/wp-content/uploads/2012/01/Tools_Benerator_schema_bdd-300x169.png" alt="" title="Tools_Benerator_schema_bdd" width="300" height="169" class="aligncenter size-medium wp-image-1312" /></a></p>
<p>Et son code SQL.</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">TABLE</span> CUSTOMER
  	 <span style="color: #66cc66;">&#40;</span>  CUSTOMERID <span style="color: #993333; font-weight: bold;">VARCHAR</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">250</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span><span style="color: #66cc66;">,</span>
   	 PASSWORD <span style="color: #993333; font-weight: bold;">VARCHAR</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">250</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span>
   	 FIRSTNAME <span style="color: #993333; font-weight: bold;">VARCHAR</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">250</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span>
   	 LASTNAME <span style="color: #993333; font-weight: bold;">VARCHAR</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">250</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span>
   	 ADDR1 <span style="color: #993333; font-weight: bold;">VARCHAR</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">250</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span>
   	 ADDR2 <span style="color: #993333; font-weight: bold;">VARCHAR</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">250</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span>
   	 ADDRCITY <span style="color: #993333; font-weight: bold;">VARCHAR</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">250</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span>
   	 ADDRSTATE <span style="color: #993333; font-weight: bold;">VARCHAR</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">250</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span>
   	 ADDRZIP <span style="color: #993333; font-weight: bold;">VARCHAR</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">250</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span>
   	 PHONE <span style="color: #993333; font-weight: bold;">VARCHAR</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">250</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
&nbsp;
&nbsp;
	<span style="color: #993333; font-weight: bold;">ALTER</span> <span style="color: #993333; font-weight: bold;">TABLE</span> CUSTOMER
  	    <span style="color: #993333; font-weight: bold;">ADD</span> <span style="color: #993333; font-weight: bold;">CONSTRAINT</span> PK_CUSTOMER <span style="color: #993333; font-weight: bold;">PRIMARY</span> <span style="color: #993333; font-weight: bold;">KEY</span> <span style="color: #66cc66;">&#40;</span>CUSTOMERID<span style="color: #66cc66;">&#41;</span>;
&nbsp;
	<span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">TABLE</span> INVENTORY
  	 <span style="color: #66cc66;">&#40;</span>  INVENTORYID <span style="color: #993333; font-weight: bold;">VARCHAR</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">250</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span><span style="color: #66cc66;">,</span>
   	 NAME <span style="color: #993333; font-weight: bold;">VARCHAR</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">250</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span>
   	 HEADING <span style="color: #993333; font-weight: bold;">VARCHAR</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">250</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span>
   	 DESCRIPTION <span style="color: #993333; font-weight: bold;">VARCHAR</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">250</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span>
   	 PKGINFO <span style="color: #993333; font-weight: bold;">VARCHAR</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">250</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span>
   	 IMAGE <span style="color: #993333; font-weight: bold;">VARCHAR</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">250</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span>
       IMGBYTES LONG BIT <span style="color: #993333; font-weight: bold;">VARYING</span><span style="color: #66cc66;">,</span>
   	 PRICE <span style="color: #993333; font-weight: bold;">REAL</span><span style="color: #66cc66;">,</span>
   	 COST <span style="color: #993333; font-weight: bold;">REAL</span><span style="color: #66cc66;">,</span>
       CATEGORY <span style="color: #993333; font-weight: bold;">INTEGER</span><span style="color: #66cc66;">,</span>
   	 QUANTITY <span style="color: #993333; font-weight: bold;">INTEGER</span><span style="color: #66cc66;">,</span>
	    NOTES <span style="color: #993333; font-weight: bold;">VARCHAR</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">250</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span>
   	 ISPUBLIC <span style="color: #993333; font-weight: bold;">INTEGER</span><span style="color: #66cc66;">,</span>
       MINTHRESHOLD <span style="color: #993333; font-weight: bold;">INTEGER</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span><span style="color: #66cc66;">,</span>
       MAXTHRESHOLD <span style="color: #993333; font-weight: bold;">INTEGER</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
	<span style="color: #993333; font-weight: bold;">ALTER</span> <span style="color: #993333; font-weight: bold;">TABLE</span> INVENTORY
  	    <span style="color: #993333; font-weight: bold;">ADD</span> <span style="color: #993333; font-weight: bold;">CONSTRAINT</span> PK_INVENTORY <span style="color: #993333; font-weight: bold;">PRIMARY</span> <span style="color: #993333; font-weight: bold;">KEY</span> <span style="color: #66cc66;">&#40;</span>INVENTORYID<span style="color: #66cc66;">&#41;</span>;
&nbsp;
   <span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">TABLE</span> ORDER1
    <span style="color: #66cc66;">&#40;</span>  ORDERID <span style="color: #993333; font-weight: bold;">VARCHAR</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">250</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span><span style="color: #66cc66;">,</span>
       SELLDATE <span style="color: #993333; font-weight: bold;">VARCHAR</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">250</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span>
       BILLNAME <span style="color: #993333; font-weight: bold;">VARCHAR</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">250</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span>
       BILLADDR1 <span style="color: #993333; font-weight: bold;">VARCHAR</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">250</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span>
       BILLADDR2 <span style="color: #993333; font-weight: bold;">VARCHAR</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">250</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span>
       BILLCITY <span style="color: #993333; font-weight: bold;">VARCHAR</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">250</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span>
       BILLSTATE <span style="color: #993333; font-weight: bold;">VARCHAR</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">250</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span>
       BILLZIP <span style="color: #993333; font-weight: bold;">VARCHAR</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">250</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span>
       BILLPHONE <span style="color: #993333; font-weight: bold;">VARCHAR</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">250</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span>
       SHIPNAME <span style="color: #993333; font-weight: bold;">VARCHAR</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">250</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span>
       SHIPADDR1 <span style="color: #993333; font-weight: bold;">VARCHAR</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">250</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span>
       SHIPADDR2 <span style="color: #993333; font-weight: bold;">VARCHAR</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">250</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span>
       SHIPCITY <span style="color: #993333; font-weight: bold;">VARCHAR</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">250</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span>
       SHIPSTATE <span style="color: #993333; font-weight: bold;">VARCHAR</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">250</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span>
       SHIPZIP <span style="color: #993333; font-weight: bold;">VARCHAR</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">250</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span>
       SHIPPHONE <span style="color: #993333; font-weight: bold;">VARCHAR</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">250</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span>
       CREDITCARD <span style="color: #993333; font-weight: bold;">VARCHAR</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">250</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span>
       CCNUM <span style="color: #993333; font-weight: bold;">VARCHAR</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">250</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span>
       CCEXPIREMONTH <span style="color: #993333; font-weight: bold;">VARCHAR</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">250</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span>
       CCEXPIREYEAR <span style="color: #993333; font-weight: bold;">VARCHAR</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">250</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span>
       CARDHOLDER <span style="color: #993333; font-weight: bold;">VARCHAR</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">250</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span>
       SHIPPINGMETHOD <span style="color: #993333; font-weight: bold;">INTEGER</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span><span style="color: #66cc66;">,</span>
       PROFIT <span style="color: #993333; font-weight: bold;">REAL</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span><span style="color: #66cc66;">,</span>
       CUSTOMERID <span style="color: #993333; font-weight: bold;">VARCHAR</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">250</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
   <span style="color: #993333; font-weight: bold;">ALTER</span> <span style="color: #993333; font-weight: bold;">TABLE</span> ORDER1
       <span style="color: #993333; font-weight: bold;">ADD</span> <span style="color: #993333; font-weight: bold;">CONSTRAINT</span> PK_ORDER1 <span style="color: #993333; font-weight: bold;">PRIMARY</span> <span style="color: #993333; font-weight: bold;">KEY</span> <span style="color: #66cc66;">&#40;</span>ORDERID<span style="color: #66cc66;">&#41;</span>;
&nbsp;
   <span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">TABLE</span> ORDERITEM
    <span style="color: #66cc66;">&#40;</span>  INVENTORYID <span style="color: #993333; font-weight: bold;">VARCHAR</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">250</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span><span style="color: #66cc66;">,</span>
       NAME <span style="color: #993333; font-weight: bold;">VARCHAR</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">250</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span>
       PKGINFO <span style="color: #993333; font-weight: bold;">VARCHAR</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">250</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span>
       PRICE <span style="color: #993333; font-weight: bold;">REAL</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span><span style="color: #66cc66;">,</span>
       COST <span style="color: #993333; font-weight: bold;">REAL</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span><span style="color: #66cc66;">,</span>
       CATEGORY <span style="color: #993333; font-weight: bold;">INTEGER</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span><span style="color: #66cc66;">,</span>
       QUANTITY <span style="color: #993333; font-weight: bold;">INTEGER</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span><span style="color: #66cc66;">,</span>
       SELLDATE <span style="color: #993333; font-weight: bold;">VARCHAR</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">250</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span>
       ORDER_ORDERID <span style="color: #993333; font-weight: bold;">VARCHAR</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">250</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
   <span style="color: #993333; font-weight: bold;">ALTER</span> <span style="color: #993333; font-weight: bold;">TABLE</span> ORDERITEM
       <span style="color: #993333; font-weight: bold;">ADD</span> <span style="color: #993333; font-weight: bold;">CONSTRAINT</span> PK_ORDERITEM <span style="color: #993333; font-weight: bold;">PRIMARY</span> <span style="color: #993333; font-weight: bold;">KEY</span> <span style="color: #66cc66;">&#40;</span>INVENTORYID<span style="color: #66cc66;">,</span> ORDER_ORDERID<span style="color: #66cc66;">&#41;</span>;
&nbsp;
   <span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">TABLE</span> IDGENERATOR
    <span style="color: #66cc66;">&#40;</span>  IDNAME <span style="color: #993333; font-weight: bold;">VARCHAR</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">250</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span><span style="color: #66cc66;">,</span>
       IDVALUE <span style="color: #993333; font-weight: bold;">INTEGER</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
   <span style="color: #993333; font-weight: bold;">ALTER</span> <span style="color: #993333; font-weight: bold;">TABLE</span> IDGENERATOR
       <span style="color: #993333; font-weight: bold;">ADD</span> <span style="color: #993333; font-weight: bold;">CONSTRAINT</span> PK_IDGENERATOR <span style="color: #993333; font-weight: bold;">PRIMARY</span> <span style="color: #993333; font-weight: bold;">KEY</span> <span style="color: #66cc66;">&#40;</span>IDNAME<span style="color: #66cc66;">&#41;</span>;
&nbsp;
   <span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">TABLE</span> BACKORDER
    <span style="color: #66cc66;">&#40;</span>  BACKORDERID <span style="color: #993333; font-weight: bold;">VARCHAR</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">250</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span><span style="color: #66cc66;">,</span>
       INVENTORYID <span style="color: #993333; font-weight: bold;">VARCHAR</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">250</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span>
       QUANTITY <span style="color: #993333; font-weight: bold;">INTEGER</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span><span style="color: #66cc66;">,</span>
       <span style="color: #993333; font-weight: bold;">STATUS</span> <span style="color: #993333; font-weight: bold;">VARCHAR</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">250</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span>
       LOWDATE <span style="color: #993333; font-weight: bold;">BIGINT</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span><span style="color: #66cc66;">,</span>
       ORDERDATE <span style="color: #993333; font-weight: bold;">BIGINT</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span><span style="color: #66cc66;">,</span>
       SUPPLIERORDERID <span style="color: #993333; font-weight: bold;">VARCHAR</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">250</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">NULL</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
   <span style="color: #993333; font-weight: bold;">ALTER</span> <span style="color: #993333; font-weight: bold;">TABLE</span> BACKORDER
       <span style="color: #993333; font-weight: bold;">ADD</span> <span style="color: #993333; font-weight: bold;">CONSTRAINT</span> PK_BACKORDER <span style="color: #993333; font-weight: bold;">PRIMARY</span> <span style="color: #993333; font-weight: bold;">KEY</span> <span style="color: #66cc66;">&#40;</span>BACKORDERID<span style="color: #66cc66;">&#41;</span>;
&nbsp;
   <span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">TABLE</span> SUPPLIER
    <span style="color: #66cc66;">&#40;</span>  SUPPLIERID <span style="color: #993333; font-weight: bold;">VARCHAR</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">250</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span><span style="color: #66cc66;">,</span>
       NAME <span style="color: #993333; font-weight: bold;">VARCHAR</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">250</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span>
       STREET <span style="color: #993333; font-weight: bold;">VARCHAR</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">250</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span>
       CITY <span style="color: #993333; font-weight: bold;">VARCHAR</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">250</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span>
       USSTATE <span style="color: #993333; font-weight: bold;">VARCHAR</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">250</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span>
       ZIP <span style="color: #993333; font-weight: bold;">VARCHAR</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">250</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span>
       PHONE <span style="color: #993333; font-weight: bold;">VARCHAR</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">250</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span>
       URL <span style="color: #993333; font-weight: bold;">VARCHAR</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">250</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
   <span style="color: #993333; font-weight: bold;">ALTER</span> <span style="color: #993333; font-weight: bold;">TABLE</span> SUPPLIER
       <span style="color: #993333; font-weight: bold;">ADD</span> <span style="color: #993333; font-weight: bold;">CONSTRAINT</span> PK_SUPPLIER <span style="color: #993333; font-weight: bold;">PRIMARY</span> <span style="color: #993333; font-weight: bold;">KEY</span> <span style="color: #66cc66;">&#40;</span>SUPPLIERID<span style="color: #66cc66;">&#41;</span>;</pre></div></div>

<p class="info">Comme on peut le voir, le schéma de la base de données n'est pas ce qui se fait de mieux mais nous permettra d'avoir une bonne vision de l'utilisation de Benerator.</p>
<p>Après la découverte du schéma de la base de données et du fonctionnement Benerator, regardons comment créer le fichier XML de description du projet.</p>
<h3>2.2 Paramétrage de la base de données cible et de la volumétrie du jeu de données</h3>
<p>Mais avant cela, nous allons créer deux fichiers properties afin de regrouper les informations sur :</p>
<ul>
<li>la base de données ;</li>
<li>la volumétrie cible.</li>
</ul>
<p><br/><br />
Les informations sur la base de données seront dans le fichier <em>mysql\PlantsByWebSphere.mysql.properties</em></p>

<div class="wp_syntax"><div class="code"><pre class="properties" style="font-family:monospace;"><span style="color: #000080; font-weight:bold;">bddUrl</span><span style="color: #000000;">=</span><span style="color: #008000; font-weight:bold;">jdbc:mysql://localhost:3306/test</span>
<span style="color: #000080; font-weight:bold;">bddDriver</span><span style="color: #000000;">=</span><span style="color: #008000; font-weight:bold;">com.mysql.jdbc.Driver</span>
<span style="color: #000080; font-weight:bold;">bddCatalog</span><span style="color: #000000;">=</span><span style="color: #008000; font-weight:bold;">test</span>
<span style="color: #000080; font-weight:bold;">bddUser</span><span style="color: #000000;">=</span><span style="color: #008000; font-weight:bold;">root</span>
<span style="color: #000080; font-weight:bold;">bddPassword</span><span style="color: #000000;">=</span><span style="color: #008000; font-weight:bold;">mysql</span></pre></div></div>

<p><br/><br />
Les informations sur les volumétries cibles seront dans les fichiers de type <em>PlantsByWebSphere.{volumetrie}.properties</em></p>
<p>Par exemple pour un poste de développement, le fichier se nommera <em>PlantsByWebSphere.development.properties</em></p>

<div class="wp_syntax"><div class="code"><pre class="properties" style="font-family:monospace;"><span style="color: #000080; font-weight:bold;">taillePaquet</span><span style="color: #000000;">=</span><span style="color: #008000; font-weight:bold;">10</span>
<span style="color: #000080; font-weight:bold;">customer_count</span><span style="color: #000000;">=</span><span style="color: #008000; font-weight:bold;">10</span>
<span style="color: #000080; font-weight:bold;">inventory_cat0_count</span><span style="color: #000000;">=</span><span style="color: #008000; font-weight:bold;">10</span>
<span style="color: #000080; font-weight:bold;">inventory_cat1_count</span><span style="color: #000000;">=</span><span style="color: #008000; font-weight:bold;">3</span>
<span style="color: #000080; font-weight:bold;">inventory_cat2_count</span><span style="color: #000000;">=</span><span style="color: #008000; font-weight:bold;">2</span>
<span style="color: #000080; font-weight:bold;">inventory_cat3_count</span><span style="color: #000000;">=</span><span style="color: #008000; font-weight:bold;">5</span>
<span style="color: #000080; font-weight:bold;">supplier_count</span><span style="color: #000000;">=</span><span style="color: #008000; font-weight:bold;">1</span>
<span style="color: #000080; font-weight:bold;">order_count</span><span style="color: #000000;">=</span><span style="color: #008000; font-weight:bold;">60</span>
<span style="color: #000080; font-weight:bold;">items_per_order</span><span style="color: #000000;">=</span><span style="color: #008000; font-weight:bold;">3</span></pre></div></div>

<p><br/></p>
<h3>2.3 Création du fichier de description de Benerator</h3>
<ul>
<li>Commençons par l'entête du fichier.</li>
</ul>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;iso-8859-1&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;setup</span> </span>
<span style="color: #009900;">	<span style="color: #000066;">xmlns</span>=<span style="color: #ff0000;">&quot;http://databene.org/benerator/0.7.5&quot;</span></span>
<span style="color: #009900;">	<span style="color: #000066;">xmlns:xsi</span>=<span style="color: #ff0000;">&quot;http://www.w3.org/2001/XMLSchema-instance&quot;</span></span>
<span style="color: #009900;">	<span style="color: #000066;">xsi:schemaLocation</span>=<span style="color: #ff0000;">&quot;http://databene.org/benerator/0.7.5 http://databene.org/benerator-0.7.5.xsd&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/setup<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p><br/></p>
<ul>
<li>Importons les domaines nécessaires et la bonne plate-forme.</li>
</ul>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;import</span> domains   = <span style="color: #ff0000;">&quot;person,net,address,finance&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;import</span> platforms = <span style="color: #ff0000;">&quot;db,csv&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span></pre></div></div>

<p><br/></p>
<ul>
<li>Définissons des valeurs par défaut pour le type de volumétrie et le type de base de données cible.</li>
</ul>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;comment<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Valeur par défaut<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/comment<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;setting</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;volumetrie&quot;</span> <span style="color: #000066;">default</span>=<span style="color: #ff0000;">&quot;development&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;setting</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;database&quot;</span> <span style="color: #000066;">default</span>=<span style="color: #ff0000;">&quot;mysql&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span></pre></div></div>

<p><br/></p>
<ul>
<li>Chargeons les deux fichiers properties que l'on a créés.</li>
</ul>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;comment<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Récupération des valeurs pour la volumétrie et la base de données cible<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/comment<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;include</span> <span style="color: #000066;">uri</span>=<span style="color: #ff0000;">&quot;{ftl:${database}/PlantsByWebSphere.${database}.properties}&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;include</span> <span style="color: #000066;">uri</span>=<span style="color: #ff0000;">&quot;{ftl:PlantsByWebSphere.${volumetrie}.properties}&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span></pre></div></div>

<p><br/></p>
<ul>
<li>Définissons l'URL de la base de données (ne pas oublier d'ajouter les drivers dans le classpath si nécessaire).</li>
</ul>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;database</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;db&quot;</span> <span style="color: #000066;">url</span>=<span style="color: #ff0000;">&quot;{bddUrl}&quot;</span> <span style="color: #000066;">driver</span>=<span style="color: #ff0000;">&quot;{bddDriver}&quot;</span> </span>
<span style="color: #009900;">  <span style="color: #000066;">user</span>=<span style="color: #ff0000;">&quot;{bddUser}&quot;</span> <span style="color: #000066;">password</span>=<span style="color: #ff0000;">&quot;{bddPassword}&quot;</span> <span style="color: #000066;">catalog</span>=<span style="color: #ff0000;">&quot;{bddCatalog}&quot;</span> <span style="color: #000066;">batch</span>=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #000066;">fetchSize</span>=<span style="color: #ff0000;">&quot;1000&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span></pre></div></div>

<p><br/></p>
<ul>
<li>Afin d'éviter les mauvaises surprises, partons d'une base vide (<em>drop + create</em>) à l'aide de 2 scripts SQL. </li>
</ul>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;comment<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Drop des tables avant leurs créations<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/comment<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;execute</span> <span style="color: #000066;">uri</span>=<span style="color: #ff0000;">&quot;{ftl:${database}/drop_tables_${database}.sql}&quot;</span>   <span style="color: #000066;">target</span>=<span style="color: #ff0000;">&quot;db&quot;</span> <span style="color: #000066;">onError</span>=<span style="color: #ff0000;">&quot;ignore&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;execute</span> <span style="color: #000066;">uri</span>=<span style="color: #ff0000;">&quot;{ftl:${database}/create_tables_${database}.sql}&quot;</span> <span style="color: #000066;">target</span>=<span style="color: #ff0000;">&quot;db&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span></pre></div></div>

<p><br/></p>
<ul>
<li>Créons deux générateurs de nombre auto incrémenté pour les utiliser comme clé primaire.</li>
</ul>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;bean</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;idGen&quot;</span> <span style="color: #000066;">spec</span>=<span style="color: #ff0000;">&quot;new IncrementGenerator(1)&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;bean</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;idOrderGen&quot;</span> <span style="color: #000066;">spec</span>=<span style="color: #ff0000;">&quot;new IncrementGenerator(1)&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span></pre></div></div>

<p><br/><br />
Maintenant, en fonction de ce que l'on veut tester, il nous reste plusieurs choix possibles comme :</p>
<ul>
<li>simuler des tests avec un catalogue de produits plus grand que celui défini par défaut ;</li>
<li>simuler des tests à l'ouverture de la boutique en ligne ;</li>
<li>simuler des tests après plusieurs jours de fonctionnement (ce qui correspond à avoir déjà des clients et des commandes en base de données) ;</li>
<li>simuler plusieurs combinaisons des cas précédents.</li>
</ul>
<p class="info">Ces choix impacteront le volume et la répartition des données en base et donc les résultats des tests.</p>
<p>Dans notre cas, nous allons regarder comment créer des données pour chaque table.<br />
<br/></p>
<ul>
<li>Commençons par ajouter des articles en base (table <em>INVENTORY</em>).</li>
</ul>
<p>Chargeons les images des articles en mémoire afin de pouvoir remplir le champ <em>IMGBYTES</em>.<br />
L'objectif du jeu de données étant une campagne de test de charge, nous ne nous soucierons pas de la correspondance entre l'image et le produit.</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;bean</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;pictures_files&quot;</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;org.databene.benerator.file.BinaryFileContentGenerator&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;uri&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;images&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;filter&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;.*\.jpg&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/bean<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p class="tip">Afin de contrôler le plus finement possible la répartition des articles, nous les traiterons catégorie par catégorie (champ <em>CATEGORY</em>)</p>
<p><br/><br />
Chaque catégorie sera générée de cette façon (ici pour la catégorie des <em>Flowers</em>).</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;">generate type=&quot;INVENTORY&quot; count=&quot;{inventory_cat0_count}&quot; consumer=&quot;db&quot; pageSize=&quot;{taillePaquet}&quot; &gt;
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;id</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;INVENTORYID&quot;</span> <span style="color: #000066;">generator</span>=<span style="color: #ff0000;">&quot;idGen&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;attribute</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;NAME&quot;</span> <span style="color: #000066;">values</span>=<span style="color: #ff0000;">&quot;'Petunia','African Orchid','Baby Breath','Black-eyed Susan','Coleus','Yellow Shasta Daisy','Perennial Foxglove','Geranium','Goodnight Moon Iris','Impatiens','Lily','Pansy','Primrose','Red Poinsettia','Red Rose','Sparkler Celosia','Tulip','White Poinsettia','White Rose','Zinnia'&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;attribute</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;HEADING&quot;</span> <span style="color: #000066;">values</span>=<span style="color: #ff0000;">&quot;'Striped Brightness','Rare Delicate Beauty','Colorful Accent','Charming Simple Beauty','Tangerine Dream','Autumn Mix','Seasonal Beauty','Always in Bloom','Seasonal Simplicity','A Classic Beauty'&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;attribute</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;DESCRIPTION&quot;</span>  <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;attribute</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;PKGINFO&quot;</span> <span style="color: #000066;">values</span>=<span style="color: #ff0000;">&quot;'4 plants'&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;attribute</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;IMAGE&quot;</span>  <span style="color: #000066;">values</span>=<span style="color: #ff0000;">&quot;'flower_petunias.jpg','flower_african_orchid.jpg','flower_bbreath.jpg','flower_black-eyed_susan.jpg','flower_coleus.jpg','flower_daisies.jpg','flower_foxglove.jpg','flower_geranium.jpg','flower_goodnight_moon_iris.jpg','flower_impatiens.jpg','flower_lily.jpg','flower_pansies.jpg','flower_primrose.jpg','flower_red_poinsettia.jpg','flower_red_rose.jpg','flower_sparkler_celosia.jpg','flower_tulips.jpg','flower_white_poinsettia.jpg','flower_white_rose.jpg','flower_zinnia.jpg'&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;attribute</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;IMGBYTES&quot;</span> <span style="color: #000066;">generator</span>=<span style="color: #ff0000;">&quot;pictures_files&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;attribute</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;PRICE&quot;</span> <span style="color: #000066;">min</span>=<span style="color: #ff0000;">&quot;10&quot;</span> <span style="color: #000066;">max</span>=<span style="color: #ff0000;">&quot;45&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;attribute</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;COST&quot;</span> <span style="color: #000066;">min</span>=<span style="color: #ff0000;">&quot;1&quot;</span> <span style="color: #000066;">max</span>=<span style="color: #ff0000;">&quot;9&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;attribute</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;CATEGORY&quot;</span> <span style="color: #000066;">values</span>=<span style="color: #ff0000;">&quot;0&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>	
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;attribute</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;QUANTITY&quot;</span> <span style="color: #000066;">values</span>=<span style="color: #ff0000;">&quot;10000&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;attribute</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;NOTES&quot;</span> <span style="color: #000066;">values</span>=<span style="color: #ff0000;">&quot;'NOTES and stuff'&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;attribute</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;ISPUBLIC&quot;</span> <span style="color: #000066;">values</span>=<span style="color: #ff0000;">&quot;1&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;attribute</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;MINTHRESHOLD&quot;</span> <span style="color: #000066;">values</span>=<span style="color: #ff0000;">&quot;50&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;attribute</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;MAXTHRESHOLD&quot;</span> <span style="color: #000066;">values</span>=<span style="color: #ff0000;">&quot;200&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/generate<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>En fonction de la catégorie et de l'objectif du test, on pourra modifier les paramètres suivants :</p>
<ul>
<li><em>count </em>;</li>
<li><em>QUANTITY </em>;</li>
<li><em>ISPUBLIC</em>.</li>
</ul>
<p><br/></p>
<p class="info">Je vous laisse créer les autres articles pour les 3 catégories restantes (<em>CATEGORY </em>aura pour valeurs : 1, 2 et 3).</p>
<p><br/></p>
<ul>
<li>Créons à l'identique de l'original la table <em>SUPPLIER</em>.</li>
</ul>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;">  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;generate</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;SUPPLIER&quot;</span> <span style="color: #000066;">count</span>=<span style="color: #ff0000;">&quot;{supplier_count}&quot;</span> <span style="color: #000066;">consumer</span>=<span style="color: #ff0000;">&quot;db&quot;</span> <span style="color: #000066;">pageSize</span>=<span style="color: #ff0000;">&quot;{taillePaquet}&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;</span></span>
  	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;variable</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;individu&quot;</span> <span style="color: #000066;">generator</span>=<span style="color: #ff0000;">&quot;org.databene.domain.person.PersonGenerator&quot;</span> <span style="color: #000066;">dataset</span>=<span style="color: #ff0000;">&quot;US&quot;</span> <span style="color: #000066;">locale</span>=<span style="color: #ff0000;">&quot;en&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
  	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;variable</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;adresse&quot;</span> <span style="color: #000066;">generator</span>=<span style="color: #ff0000;">&quot;org.databene.domain.address.AddressGenerator&quot;</span> <span style="color: #000066;">dataset</span>=<span style="color: #ff0000;">&quot;US&quot;</span> <span style="color: #000066;">locale</span>=<span style="color: #ff0000;">&quot;en&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;attribute</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;SUPPLIERID&quot;</span> <span style="color: #000066;">script</span>=<span style="color: #ff0000;">&quot;individu.email&quot;</span> <span style="color: #000066;">unique</span>=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
  	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;attribute</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;NAME&quot;</span> <span style="color: #000066;">script</span>=<span style="color: #ff0000;">&quot;individu.givenName&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
  	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;attribute</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;STREET&quot;</span> <span style="color: #000066;">script</span>=<span style="color: #ff0000;">&quot;adresse.houseNumber + ' ' + adresse.street&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
  	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;attribute</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;CITY&quot;</span> <span style="color: #000066;">script</span>=<span style="color: #ff0000;">&quot;adresse.city&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
  	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;attribute</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;USSTATE&quot;</span> <span style="color: #000066;">script</span>=<span style="color: #ff0000;">&quot;adresse.state.id&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
  	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;attribute</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;ZIP&quot;</span> <span style="color: #000066;">script</span>=<span style="color: #ff0000;">&quot;adresse.postalCode&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;attribute</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;PHONE&quot;</span> <span style="color: #000066;">script</span>=<span style="color: #ff0000;">&quot;adresse.mobilePhone&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;attribute</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;URL&quot;</span> <span style="color: #000066;">values</span>=<span style="color: #ff0000;">&quot;'http://localhost:9080/OrderProcessorEJB/services/FrontGate?wsdl'&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>	
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/generate<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p><br/></p>
<ul>
<li>Créons des comptes clients (table <em>CUSTOMER</em>).</li>
</ul>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;generate</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;CUSTOMER&quot;</span> <span style="color: #000066;">count</span>=<span style="color: #ff0000;">&quot;{customer_count}&quot;</span> <span style="color: #000066;">consumer</span>=<span style="color: #ff0000;">&quot;db&quot;</span> <span style="color: #000066;">pageSize</span>=<span style="color: #ff0000;">&quot;{taillePaquet}&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;variable</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;individu&quot;</span> <span style="color: #000066;">generator</span>=<span style="color: #ff0000;">&quot;org.databene.domain.person.PersonGenerator&quot;</span> <span style="color: #000066;">dataset</span>=<span style="color: #ff0000;">&quot;US&quot;</span> <span style="color: #000066;">locale</span>=<span style="color: #ff0000;">&quot;en&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;variable</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;adresse&quot;</span> <span style="color: #000066;">generator</span>=<span style="color: #ff0000;">&quot;org.databene.domain.address.AddressGenerator&quot;</span> <span style="color: #000066;">dataset</span>=<span style="color: #ff0000;">&quot;US&quot;</span> <span style="color: #000066;">locale</span>=<span style="color: #ff0000;">&quot;en&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;attribute</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;CUSTOMERID&quot;</span> <span style="color: #000066;">script</span>=<span style="color: #ff0000;">&quot;individu.email&quot;</span> <span style="color: #000066;">unique</span>=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;attribute</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;PASSWORD&quot;</span> <span style="color: #000066;">minLength</span>=<span style="color: #ff0000;">&quot;6&quot;</span> <span style="color: #000066;">maxLength</span>=<span style="color: #ff0000;">&quot;10&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;attribute</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;FIRSTNAME&quot;</span> <span style="color: #000066;">script</span>=<span style="color: #ff0000;">&quot;individu.givenName&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;attribute</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;LASTNAME&quot;</span> <span style="color: #000066;">script</span>=<span style="color: #ff0000;">&quot;individu.familyName&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;attribute</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;ADDR1&quot;</span> <span style="color: #000066;">script</span>=<span style="color: #ff0000;">&quot;adresse.houseNumber + ' ' + adresse.street&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;attribute</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;ADDR2&quot;</span> <span style="color: #000066;">maxLength</span>=<span style="color: #ff0000;">&quot;20&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;attribute</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;ADDRCITY&quot;</span> <span style="color: #000066;">script</span>=<span style="color: #ff0000;">&quot;adresse.city&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;attribute</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;ADDRSTATE&quot;</span> <span style="color: #000066;">script</span>=<span style="color: #ff0000;">&quot;adresse.state.id&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;attribute</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;ADDRZIP&quot;</span> <span style="color: #000066;">script</span>=<span style="color: #ff0000;">&quot;adresse.postalCode&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;attribute</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;PHONE&quot;</span> <span style="color: #000066;">script</span>=<span style="color: #ff0000;">&quot;adresse.privatePhone&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/generate<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p class="tip">Comme on peut le voir, on utilise les domaines <em>Person </em>et <em>Address </em>afin d'avoir des données réalistes.</p>
<p>Il nous reste à créer des commandes clients (tables <em>ORDER1</em>, <em>ORDERITEM </em>et <em>IDGENERATOR</em>).<br />
<br/></p>
<ul>
<li>Remplissons la table <em>ORDER1</em>.</li>
</ul>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;">  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;generate</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;ORDER1&quot;</span> <span style="color: #000066;">count</span>=<span style="color: #ff0000;">&quot;{order_count}&quot;</span> <span style="color: #000066;">consumer</span>=<span style="color: #ff0000;">&quot;db&quot;</span> <span style="color: #000066;">pageSize</span>=<span style="color: #ff0000;">&quot;{taillePaquet}&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;</span></span>
  	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;id</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;ORDERID&quot;</span> <span style="color: #000066;">generator</span>=<span style="color: #ff0000;">&quot;idOrderGen&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
  	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;attribute</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;SELLDATE&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;date&quot;</span> <span style="color: #000066;">min</span>=<span style="color: #ff0000;">&quot;2009-01-01&quot;</span> <span style="color: #000066;">max</span>=<span style="color: #ff0000;">&quot;2011-08-01&quot;</span> <span style="color: #000066;">converter</span>=<span style="color: #ff0000;">&quot;org.databene.commons.converter.ToStringConverter&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
  	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;attribute</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;CUSTOMERID&quot;</span> <span style="color: #000066;">source</span>=<span style="color: #ff0000;">&quot;db&quot;</span> <span style="color: #000066;">selector</span>=<span style="color: #ff0000;">&quot;select CUSTOMERID from CUSTOMER&quot;</span> <span style="color: #000066;">cyclic</span>=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>	
    	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;attribute</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;BILLNAME&quot;</span> <span style="color: #000066;">source</span>=<span style="color: #ff0000;">&quot;db&quot;</span> <span style="color: #000066;">subSelector</span>=<span style="color: #ff0000;">&quot;{{'select LASTNAME from CUSTOMER where CUSTOMERID = \'' + this.CUSTOMERID + '\''}}&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;attribute</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;BILLADDR1&quot;</span> <span style="color: #000066;">source</span>=<span style="color: #ff0000;">&quot;db&quot;</span> <span style="color: #000066;">subSelector</span>=<span style="color: #ff0000;">&quot;{{'select ADDR1 from CUSTOMER where CUSTOMERID = \'' + this.CUSTOMERID + '\''}}&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;attribute</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;BILLADDR2&quot;</span> <span style="color: #000066;">source</span>=<span style="color: #ff0000;">&quot;db&quot;</span> <span style="color: #000066;">subSelector</span>=<span style="color: #ff0000;">&quot;{{'select ADDR2 from CUSTOMER where CUSTOMERID = \'' + this.CUSTOMERID + '\''}}&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;attribute</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;BILLCITY&quot;</span> <span style="color: #000066;">source</span>=<span style="color: #ff0000;">&quot;db&quot;</span> <span style="color: #000066;">subSelector</span>=<span style="color: #ff0000;">&quot;{{'select ADDRCITY from CUSTOMER where CUSTOMERID = \'' + this.CUSTOMERID + '\''}}&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;attribute</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;BILLSTATE&quot;</span> <span style="color: #000066;">source</span>=<span style="color: #ff0000;">&quot;db&quot;</span> <span style="color: #000066;">subSelector</span>=<span style="color: #ff0000;">&quot;{{'select ADDRSTATE from CUSTOMER where CUSTOMERID = \'' + this.CUSTOMERID + '\''}}&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;attribute</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;BILLZIP&quot;</span> <span style="color: #000066;">source</span>=<span style="color: #ff0000;">&quot;db&quot;</span> <span style="color: #000066;">subSelector</span>=<span style="color: #ff0000;">&quot;{{'select ADDRZIP from CUSTOMER where CUSTOMERID = \'' + this.CUSTOMERID + '\''}}&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;attribute</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;BILLPHONE&quot;</span> <span style="color: #000066;">source</span>=<span style="color: #ff0000;">&quot;db&quot;</span> <span style="color: #000066;">subSelector</span>=<span style="color: #ff0000;">&quot;{{'select PHONE from CUSTOMER where CUSTOMERID = \'' + this.CUSTOMERID + '\''}}&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>     
  	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;attribute</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;SHIPNAME&quot;</span> <span style="color: #000066;">script</span>=<span style="color: #ff0000;">&quot;this.BILLNAME&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
  	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;attribute</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;SHIPADDR1&quot;</span> <span style="color: #000066;">script</span>=<span style="color: #ff0000;">&quot;this.BILLADDR1&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
  	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;attribute</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;SHIPADDR2&quot;</span> <span style="color: #000066;">script</span>=<span style="color: #ff0000;">&quot;this.BILLADDR2&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
  	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;attribute</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;SHIPCITY&quot;</span> <span style="color: #000066;">script</span>=<span style="color: #ff0000;">&quot;this.BILLCITY&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
  	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;attribute</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;SHIPSTATE&quot;</span> <span style="color: #000066;">script</span>=<span style="color: #ff0000;">&quot;this.BILLSTATE&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
  	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;attribute</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;SHIPZIP&quot;</span> <span style="color: #000066;">script</span>=<span style="color: #ff0000;">&quot;this.BILLZIP&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
  	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;attribute</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;SHIPPHONE&quot;</span> <span style="color: #000066;">script</span>=<span style="color: #ff0000;">&quot;this.BILLPHONE&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>	
  	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;attribute</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;CREDITCARD&quot;</span> <span style="color: #000066;">pattern</span>=<span style="color: #ff0000;">&quot;(Visa|Master Card|American Express)&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
  	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;attribute</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;CCNUM&quot;</span> <span style="color: #000066;">generator</span>=<span style="color: #ff0000;">&quot;org.databene.domain.finance.CreditCardNumberGenerator&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
  	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;attribute</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;CCEXPIREMONTH&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;int&quot;</span> <span style="color: #000066;">min</span>=<span style="color: #ff0000;">&quot;01&quot;</span> <span style="color: #000066;">max</span>=<span style="color: #ff0000;">&quot;12&quot;</span> <span style="color: #000066;">converter</span>=<span style="color: #ff0000;">&quot;org.databene.commons.converter.ToStringConverter&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
  	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;attribute</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;CCEXPIREYEAR&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;int&quot;</span> <span style="color: #000066;">min</span>=<span style="color: #ff0000;">&quot;2013&quot;</span> <span style="color: #000066;">max</span>=<span style="color: #ff0000;">&quot;2016&quot;</span> <span style="color: #000066;">converter</span>=<span style="color: #ff0000;">&quot;org.databene.commons.converter.ToStringConverter&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
  	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;attribute</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;SHIPPINGMETHOD&quot;</span> <span style="color: #000066;">min</span>=<span style="color: #ff0000;">&quot;0&quot;</span> <span style="color: #000066;">max</span>=<span style="color: #ff0000;">&quot;2&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
  	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;attribute</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;CARDHOLDER&quot;</span> <span style="color: #000066;">script</span>=<span style="color: #ff0000;">&quot;this.BILLNAME&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
  	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;attribute</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;PROFIT&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;double&quot;</span> <span style="color: #000066;">values</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/generate<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p class="tip">Nous utilisons ici les commandes this et subSelector nous permettant d'être cohérent sur les données de l'acheteur par rapport à la table <em>CUSTOMER</em>.</p>
<p><br/></p>
<ul>
<li>Puis la table <em>ORDERITEM</em>.</li>
</ul>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;">  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;generate</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;dummy&quot;</span> <span style="color: #000066;">count</span>=<span style="color: #ff0000;">&quot;{order_count}&quot;</span> <span style="color: #000066;">pageSize</span>=<span style="color: #ff0000;">&quot;{taillePaquet}&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;variable</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;x&quot;</span> <span style="color: #000066;">source</span>=<span style="color: #ff0000;">&quot;db&quot;</span> <span style="color: #000066;">selector</span>=<span style="color: #ff0000;">&quot;select ORDERID from ORDER1&quot;</span> <span style="color: #000066;">distribution</span>=<span style="color: #ff0000;">&quot;increment&quot;</span> <span style="color: #000066;">unique</span>=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;generate</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;ORDERITEM&quot;</span> <span style="color: #000066;">count</span>=<span style="color: #ff0000;">&quot;{items_per_order}&quot;</span> <span style="color: #000066;">consumer</span>=<span style="color: #ff0000;">&quot;db&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;variable</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;y&quot;</span> <span style="color: #000066;">source</span>=<span style="color: #ff0000;">&quot;db&quot;</span> <span style="color: #000066;">selector</span>=<span style="color: #ff0000;">&quot;select INVENTORYID from INVENTORY&quot;</span> <span style="color: #000066;">distribution</span>=<span style="color: #ff0000;">&quot;random&quot;</span> <span style="color: #000066;">unique</span>=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;attribute</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;INVENTORYID&quot;</span> <span style="color: #000066;">script</span>=<span style="color: #ff0000;">&quot;y&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;attribute</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;ORDER_ORDERID&quot;</span> <span style="color: #000066;">script</span>=<span style="color: #ff0000;">&quot;x&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;attribute</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;NAME&quot;</span> <span style="color: #000066;">source</span>=<span style="color: #ff0000;">&quot;db&quot;</span> <span style="color: #000066;">subSelector</span>=<span style="color: #ff0000;">&quot;{{'select NAME from INVENTORY where INVENTORYID = \'' + this.INVENTORYID + '\''}}&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;attribute</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;PKGINFO&quot;</span> <span style="color: #000066;">source</span>=<span style="color: #ff0000;">&quot;db&quot;</span> <span style="color: #000066;">subSelector</span>=<span style="color: #ff0000;">&quot;{{'select PKGINFO from INVENTORY where INVENTORYID = \'' + this.INVENTORYID + '\''}}&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;attribute</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;PRICE&quot;</span> <span style="color: #000066;">source</span>=<span style="color: #ff0000;">&quot;db&quot;</span> <span style="color: #000066;">subSelector</span>=<span style="color: #ff0000;">&quot;{{'select PRICE from INVENTORY where INVENTORYID = \'' + this.INVENTORYID + '\''}}&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;attribute</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;COST&quot;</span> <span style="color: #000066;">source</span>=<span style="color: #ff0000;">&quot;db&quot;</span> <span style="color: #000066;">subSelector</span>=<span style="color: #ff0000;">&quot;{{'select COST from INVENTORY where INVENTORYID = \'' + this.INVENTORYID + '\''}}&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;attribute</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;CATEGORY&quot;</span> <span style="color: #000066;">source</span>=<span style="color: #ff0000;">&quot;db&quot;</span> <span style="color: #000066;">subSelector</span>=<span style="color: #ff0000;">&quot;{{'select CATEGORY from INVENTORY where INVENTORYID = \'' + this.INVENTORYID + '\''}}&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;attribute</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;QUANTITY&quot;</span> <span style="color: #000066;">min</span>=<span style="color: #ff0000;">&quot;1&quot;</span> <span style="color: #000066;">max</span>=<span style="color: #ff0000;">&quot;20&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;attribute</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;SELLDATE&quot;</span> <span style="color: #000066;">source</span>=<span style="color: #ff0000;">&quot;db&quot;</span> <span style="color: #000066;">subSelector</span>=<span style="color: #ff0000;">&quot;{{'select SELLDATE from ORDER1 where ORDERID = \'' + this.ORDER_ORDERID + '\''}}&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/generate<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/generate<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p class="tip">Ici on doit utiliser deux boucles imbriquées afin de garantir l'unicité de la clé primaire composée de deux champs <em>(INVENTORYID,ORDERITEM).</em></p>
<p><br/><br />
Mettons à jour le prix de chaque commande (champ <em>PROFIT </em>de la table <em>ORDER1</em>).</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;">  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;iterate</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;ORDER1&quot;</span> <span style="color: #000066;">source</span>=<span style="color: #ff0000;">&quot;db&quot;</span> <span style="color: #000066;">consumer</span>=<span style="color: #ff0000;">&quot;db.updater()&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span> 
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;attribute</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;PROFIT&quot;</span> <span style="color: #000066;">source</span>=<span style="color: #ff0000;">&quot;db&quot;</span></span>
<span style="color: #009900;">          <span style="color: #000066;">selector</span>=<span style="color: #ff0000;">&quot;{{ftl:select IFNULL(SUM((PRICE - COST)*QUANTITY), 0) from ORDERITEM where ORDER_ORDERID = '${ORDER1.ORDERID}' }}&quot;</span> <span style="color: #000066;">cyclic</span>=<span style="color: #ff0000;">&quot;true&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/iterate<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p class="tip">On utilise la fonction SQL <em>IFNULL</em> de MySQL afin d'être sûr de mettre une valeur non null dans le champ <em>PROFIT</em>.</p>
<p><br/></p>
<p class="tip">Une autre solution est d'utiliser un <em>subSelector</em> à la place de la combinaison de <em>selector</em> et <em>cyclic="true"</em>.</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;iterate</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;ORDER1&quot;</span> <span style="color: #000066;">source</span>=<span style="color: #ff0000;">&quot;db&quot;</span> <span style="color: #000066;">consumer</span>=<span style="color: #ff0000;">&quot;db.updater()&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;attribute</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;PROFIT&quot;</span> <span style="color: #000066;">source</span>=<span style="color: #ff0000;">&quot;db&quot;</span> <span style="color: #000066;">subSelector</span>=<span style="color: #ff0000;">&quot;{{ftl:select IFNULL(SUM((PRICE - COST)*QUANTITY), 0) from test.ORDERITEM where ORDER_ORDERID = '${ORDER1.ORDERID}' }}&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/iterate<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p><br/></p>
<ul>
<li>Pour la dernière table <em>IDGENERATOR</em>, on va utiliser les capacités de Benerator a importer des fichiers CSV.</li>
</ul>
<p>Importons le fichier CSV <em>idgenerator.import.csv</em>.</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;iterate</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;IDGENERATOR&quot;</span> <span style="color: #000066;">source</span>=<span style="color: #ff0000;">&quot;idgenerator.import.csv&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;utf-8&quot;</span> <span style="color: #000066;">consumer</span>=<span style="color: #ff0000;">&quot;db&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span></pre></div></div>

<p>Puis mettons à jour la valeur du champ <em>IDVALUE</em>.</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;">  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;iterate</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;IDGENERATOR&quot;</span> <span style="color: #000066;">source</span>=<span style="color: #ff0000;">&quot;db&quot;</span> <span style="color: #000066;">consumer</span>=<span style="color: #ff0000;">&quot;db.updater()&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span> 
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;attribute</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;IDVALUE&quot;</span> <span style="color: #000066;">source</span>=<span style="color: #ff0000;">&quot;db&quot;</span> </span>
<span style="color: #009900;">        <span style="color: #000066;">selector</span>=<span style="color: #ff0000;">&quot;{{ftl:select 1+${order_count}*50 from IDGENERATOR where IDNAME = 'ORDER' }}&quot;</span> <span style="color: #000066;">cyclic</span>=<span style="color: #ff0000;">&quot;true&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>  
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/iterate<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p><br/></p>
<p class="tip">Une autre solution est de tout faire lors de l'importation du fichier csv à l'aide du mot clé <em>condition</em>.</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;">  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;iterate</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;IDGENERATOR&quot;</span>  <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;idg&quot;</span> <span style="color: #000066;">source</span>=<span style="color: #ff0000;">&quot;idgenerator.import.csv&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;utf-8&quot;</span> <span style="color: #000066;">consumer</span>=<span style="color: #ff0000;">&quot;db&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;attribute</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;IDVALUE&quot;</span> <span style="color: #000066;">condition</span>=<span style="color: #ff0000;">&quot;idg.IDNAME == 'ORDER'&quot;</span> <span style="color: #000066;">script</span>=<span style="color: #ff0000;">&quot;1+order_count*50&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>     
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/iterate<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p><br/></p>
<p class="info">Il ne reste plus qu'à exécuter Benerator pour générer notre jeu de données.</p>
<p>Notre fichier XML de description est prêt et je vous laisse le paramétrer au mieux pour l'objectif de vos tests.<br />
<br/><br />
Ma conclusion sur cet outil est toujours la même :</p>
<ul>
<li>il est pratique ;</li>
<li>pilotable en ligne de commande et donc très flexible pour son intégration dans un processus ;</li>
<li>larges possibilitées :</li>
<ul>
<li>générer un jeu de données à partir de rien ;</li>
<li>anonymiser un jeu de données ;</li>
<li>traitement de données existantes comme pour un ETL ;</li>
<li>création de fichier d'entrée pour un test de charge (création de login/password, ...) ;</li>
</ul>
<li>possibilité d'utiliser le même fichier XML de configuration de Benerator pour divers environnements (test, développement, pré production...) à l'aide de fichiers properties;</li>
<li>documentation complète ;</li>
<li>développement actif ;</li>
<li>gratuit ;</li>
<li>open source ;</li>
<li>support par le développeur ;</li>
<li>extensible.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.aliecom.com/presentation-de-loutil-de-generation-de-jeux-de-donnees-benerator/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Pourquoi il est dangereux d&#8217;utiliser System.gc()</title>
		<link>http://blog.aliecom.com/pourquoi-il-est-dangereux-dutiliser-system-gc/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=pourquoi-il-est-dangereux-dutiliser-system-gc</link>
		<comments>http://blog.aliecom.com/pourquoi-il-est-dangereux-dutiliser-system-gc/#comments</comments>
		<pubDate>Tue, 07 Feb 2012 07:30:33 +0000</pubDate>
		<dc:creator>Antonio Gomes-Rodrigues</dc:creator>
				<category><![CDATA[Performance applicative]]></category>
		<category><![CDATA[Tests de charge et performance]]></category>
		<category><![CDATA[gc]]></category>
		<category><![CDATA[jvm]]></category>

		<guid isPermaLink="false">http://blog.aliecom.com/?p=1037</guid>
		<description><![CDATA[En java, la gestion de la mémoire est réalisée par la JVM, en particulier par le Garbage Collector (ramasse miettes). Or, si l'on regarde d'un peu plus près, on remarque que l'on peut appeler le GC par l'instruction System.gc(). On se dit que cela pourrait être utile afin de libérer un maximum de mémoire avant [...]]]></description>
			<content:encoded><![CDATA[<p>En java, la gestion de la mémoire est réalisée par la JVM, en particulier par le <strong>Garbage Collector</strong> (ramasse miettes). Or, si l'on regarde d'un peu plus près, on remarque que l'on peut appeler le GC par l'instruction <em>System.gc()</em>.<br />
On se dit que cela pourrait être utile afin de libérer un maximum de mémoire avant certains traitements. Cette démarche est fortement déconseillé car c'est une "fausse bonne idée" comme nous allons le démontrer par la suite.</p>
<p><span id="more-1037"></span></p>
<h2>1. Un Peu de théorie</h2>
<p>Regardons la Javadoc.</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;">    /**
     * Runs the garbage collector.
     * <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">p</span>&gt;</span>
     * Calling the <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">code</span>&gt;</span>gc<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">code</span>&gt;</span> method suggests that the Java Virtual
     * Machine expend effort toward recycling unused objects in order to
     * make the memory they currently occupy available for quick reuse.
     * When control returns from the method call, the Java Virtual
     * Machine has made a best effort to reclaim space from all discarded
     * objects.
     * <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">p</span>&gt;</span>
     * The call <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">code</span>&gt;</span>System.gc()<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">code</span>&gt;</span> is effectively equivalent to the
     * call:
     * Runtime.getRuntime().gc()
     *
     * @see     java.lang.Runtime#gc()
     */</pre></div></div>

<p>&nbsp;</p>
<p>Première mauvaise nouvelle, <strong><em>System.gc()</em> ne réalise pas forcement un GC</strong> (il peut ne rien faire) et surtout on se sait pas quand.</p>
<p>On a des chances de se retrouver dans ce cas.</p>
<p><a href="http://blog.aliecom.com/pourquoi-il-est-dangereux-dutiliser-system-gc/pq_system_gc_theorie-3/" rel="attachment wp-att-1042"><img class="aligncenter size-medium wp-image-1042" title="pq_system_gc_theorie" src="http://blog.aliecom.com/wp-content/uploads/2012/01/pq_system_gc_theorie2-271x300.png" alt="" width="271" height="300" /></a></p>
<p>Supposons que la JVM réagisse comme on le souhaite (le GC est bien exécuté), <strong>le GC ne s'exécutera pas forcement au meilleur moment</strong> par rapport à l'état de la JVM. Le tout en gardant le coût d'un GC (qui en fonction d'un certain nombre de paramètres peut aller jusqu'à plusieurs secondes).</p>
<h2>2. Passons à la pratique</h2>
<p>Afin de tester notre hypothèse (ne pas utiliser de <em>System.gc()</em>) modifions l'application <a href="http://static.springsource.org/docs/petclinic.html">Spring Pet Clinic</a> en lui ajoutant un appel au GC.<br />
Créons un scénario <a href="http://blog.aliecom.com/presentation-de-loutil-apache-jmeter-partie-1/">JMeter</a> afin de simuler de l'activité.</p>
<p>&nbsp;</p>
<h3>2.1 Exécutons notre scénario avec un seul utilisateur.</h3>
<p class="info">On remarque que l'activité GC est énorme (plus de 10%) pour la charge.</p>
<p><a href="http://blog.aliecom.com/pourquoi-il-est-dangereux-dutiliser-system-gc/pq_system_gc_bad_gc_1vu_activity/" rel="attachment wp-att-1108"><img class="aligncenter size-medium wp-image-1108" title="pq_system_gc_bad_gc_1VU_activity" src="http://blog.aliecom.com/wp-content/uploads/2012/01/pq_system_gc_bad_gc_1VU_activity-300x159.jpg" alt="" width="300" height="159" /></a></p>
<p class="info">La Heap est stable (bien trop stable par rapport au test exécuté).</p>
<p><a href="http://blog.aliecom.com/pourquoi-il-est-dangereux-dutiliser-system-gc/pq_system_gc_bad_gc_1vu_heap/" rel="attachment wp-att-1047"><img class="aligncenter size-medium wp-image-1047" title="pq_system_gc_bad_gc_1VU_heap" src="http://blog.aliecom.com/wp-content/uploads/2012/01/pq_system_gc_bad_gc_1VU_heap-300x160.jpg" alt="" width="300" height="160" /></a></p>
<p class="info">En regardant d'un peu plus près l'activité du GC dans la partie de la mémoire appelée Old Generation, on remarque qu'il y a beaucoup trop d'activité.</p>
<p><a href="http://blog.aliecom.com/pourquoi-il-est-dangereux-dutiliser-system-gc/pq_system_gc_bad_gc_1vu_activity_old/" rel="attachment wp-att-1046"><img class="aligncenter size-medium wp-image-1046" title="pq_system_gc_bad_gc_1VU_activity_old" src="http://blog.aliecom.com/wp-content/uploads/2012/01/pq_system_gc_bad_gc_1VU_activity_old-300x150.jpg" alt="" width="300" height="150" /></a></p>
<p class="info">De même, les temps de réponse ne sont pas extraordinaires.</p>
<p><a href="http://blog.aliecom.com/pourquoi-il-est-dangereux-dutiliser-system-gc/pq_system_gc_bad_gc_1vu_time/" rel="attachment wp-att-1048"><img class="aligncenter size-medium wp-image-1048" title="pq_system_gc_bad_gc_1VU_time" src="http://blog.aliecom.com/wp-content/uploads/2012/01/pq_system_gc_bad_gc_1VU_time-300x25.jpg" alt="" width="300" height="25" /></a></p>
<p>A ce stade on peut faire un focus sur l'activité du GC ne semble pas normale.</p>
<p>&nbsp;</p>
<h3>2.2 Augmentons la charge en simulant 100 utilisateurs.</h3>
<p class="info">Le taux d'activité GC passe de 10% à 40%.</p>
<p><a href="http://blog.aliecom.com/pourquoi-il-est-dangereux-dutiliser-system-gc/pq_system_gc_bad_gc_100vu_activity/" rel="attachment wp-att-1049"><img class="aligncenter size-medium wp-image-1049" title="pq_system_gc_bad_gc_100VU_activity" src="http://blog.aliecom.com/wp-content/uploads/2012/01/pq_system_gc_bad_gc_100VU_activity-300x160.jpg" alt="" width="300" height="160" /></a></p>
<p class="info">De même le nombre de GC dans la Old Generation augmente fortement.</p>
<p><a href="http://blog.aliecom.com/pourquoi-il-est-dangereux-dutiliser-system-gc/pq_system_gc_bad_gc_100vu_activity_old/" rel="attachment wp-att-1050"><img class="aligncenter size-medium wp-image-1050" title="pq_system_gc_bad_gc_100VU_activity_old" src="http://blog.aliecom.com/wp-content/uploads/2012/01/pq_system_gc_bad_gc_100VU_activity_old-300x149.jpg" alt="" width="300" height="149" /></a></p>
<p class="info">Les temps de réponse se dégradent fortement.</p>
<p><a href="http://blog.aliecom.com/pourquoi-il-est-dangereux-dutiliser-system-gc/pq_system_gc_bad_gc_100vu_time/" rel="attachment wp-att-1052"><img class="aligncenter size-medium wp-image-1052" title="pq_system_gc_bad_gc_100VU_time" src="http://blog.aliecom.com/wp-content/uploads/2012/01/pq_system_gc_bad_gc_100VU_time-300x25.jpg" alt="" width="300" height="25" /></a></p>
<p class="info">Sans parler de leurs stabilités qui nous confortent dans l'idée qu'il y a un gros problème.</p>
<p><a href="http://blog.aliecom.com/pourquoi-il-est-dangereux-dutiliser-system-gc/pq_system_gc_bad_gc_100vu_time2/" rel="attachment wp-att-1051"><img class="aligncenter size-medium wp-image-1051" title="pq_system_gc_bad_gc_100VU_time2" src="http://blog.aliecom.com/wp-content/uploads/2012/01/pq_system_gc_bad_gc_100VU_time2-300x128.jpg" alt="" width="300" height="128" /></a></p>
<p>En plus de montrer l'utilité d'un test de charge, toute illusion de passer l'application en production s'évapore.</p>
<h3>2.3 Trouvons la source du problème</h3>
<p>Afin de détecter si <em>System.gc()</em> est appelé, nous allons instrumenter le bytecode (pratique si l’on n'a pas le code source) de l'application afin qu'il nous l'indique avec le message « System.gc() est appelé » lors de chaque appel.</p>
<p>Bingo, on obtient rapidement la confirmation.</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">System.gc() est appelé
System.gc() est appelé
System.gc() est appelé
System.gc() est appelé
System.gc() est appelé
System.gc() est appelé
System.gc() est appelé
System.gc() est appelé
System.gc() est appelé
System.gc() est appelé
System.gc() est appelé</pre></div></div>

<p>Modifions un peu notre script d'instrumentation afin d'avoir la stacktrace lors d'un appel de <em>System.gc()</em>.<br />
On obtient.</p>

<div class="wp_syntax"><div class="code"><pre class="java5" style="font-family:monospace;"><span style="color: #003399; font-weight: bold;">System</span>.<span style="color: #006633;">gc</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> est appelé
StackTrace :
--------------------------------
java.<span style="color: #006633;">lang</span>.<span style="color: #003399; font-weight: bold;">System</span>.<span style="color: #006633;">gc</span><span style="color: #009900;">&#40;</span><span style="color: #003399; font-weight: bold;">System</span>.<span style="color: #006633;">java</span><span style="color: #009900;">&#41;</span>
org.<span style="color: #006633;">springframework</span>.<span style="color: #006633;">samples</span>.<span style="color: #006633;">petclinic</span>.<span style="color: #006633;">web</span>.<span style="color: #006633;">FindOwnersForm</span>.<span style="color: #006633;">processSubmit</span><span style="color: #009900;">&#40;</span>FindOwnersForm.<span style="color: #006633;">java</span>:<span style="color: #cc66cc;">50</span><span style="color: #009900;">&#41;</span>
sun.<span style="color: #006633;">reflect</span>.<span style="color: #006633;">GeneratedMethodAccessor82</span>.<span style="color: #006633;">invoke</span><span style="color: #009900;">&#40;</span>Unknown <span style="color: #003399; font-weight: bold;">Source</span><span style="color: #009900;">&#41;</span>
sun.<span style="color: #006633;">reflect</span>.<span style="color: #006633;">DelegatingMethodAccessorImpl</span>.<span style="color: #006633;">invoke</span><span style="color: #009900;">&#40;</span>DelegatingMethodAccessorImpl.<span style="color: #006633;">java</span>:<span style="color: #cc66cc;">25</span><span style="color: #009900;">&#41;</span>
java.<span style="color: #006633;">lang</span>.<span style="color: #006633;">reflect</span>.<span style="color: #003399; font-weight: bold;">Method</span>.<span style="color: #006633;">invoke</span><span style="color: #009900;">&#40;</span><span style="color: #003399; font-weight: bold;">Method</span>.<span style="color: #006633;">java</span>:<span style="color: #cc66cc;">597</span><span style="color: #009900;">&#41;</span>
org.<span style="color: #006633;">springframework</span>.<span style="color: #006633;">web</span>.<span style="color: #006633;">bind</span>.<span style="color: #006633;">annotation</span>.<span style="color: #006633;">support</span>.<span style="color: #006633;">HandlerMethodInvoker</span>.<span style="color: #006633;">doInvokeMethod</span><span style="color: #009900;">&#40;</span>HandlerMethodInvoker.<span style="color: #006633;">java</span>:<span style="color: #cc66cc;">710</span><span style="color: #009900;">&#41;</span>
org.<span style="color: #006633;">springframework</span>.<span style="color: #006633;">web</span>.<span style="color: #006633;">bind</span>.<span style="color: #006633;">annotation</span>.<span style="color: #006633;">support</span>.<span style="color: #006633;">HandlerMethodInvoker</span>.<span style="color: #006633;">invokeHandlerMethod</span><span style="color: #009900;">&#40;</span>HandlerMethodInvoker.<span style="color: #006633;">java</span>:<span style="color: #cc66cc;">167</span><span style="color: #009900;">&#41;</span>
org.<span style="color: #006633;">springframework</span>.<span style="color: #006633;">web</span>.<span style="color: #006633;">servlet</span>.<span style="color: #006633;">mvc</span>.<span style="color: #006633;">annotation</span>.<span style="color: #006633;">AnnotationMethodHandlerAdapter</span>.<span style="color: #006633;">invokeHandlerMethod</span><span style="color: #009900;">&#40;</span>AnnotationMethodHandlerAdapter.<span style="color: #006633;">java</span>:<span style="color: #cc66cc;">414</span><span style="color: #009900;">&#41;</span>
org.<span style="color: #006633;">springframework</span>.<span style="color: #006633;">web</span>.<span style="color: #006633;">servlet</span>.<span style="color: #006633;">mvc</span>.<span style="color: #006633;">annotation</span>.<span style="color: #006633;">AnnotationMethodHandlerAdapter</span>.<span style="color: #006633;">handle</span><span style="color: #009900;">&#40;</span>AnnotationMethodHandlerAdapter.<span style="color: #006633;">java</span>:<span style="color: #cc66cc;">402</span><span style="color: #009900;">&#41;</span>
org.<span style="color: #006633;">springframework</span>.<span style="color: #006633;">web</span>.<span style="color: #006633;">servlet</span>.<span style="color: #006633;">DispatcherServlet</span>.<span style="color: #006633;">doDispatch</span><span style="color: #009900;">&#40;</span>DispatcherServlet.<span style="color: #006633;">java</span>:<span style="color: #cc66cc;">771</span><span style="color: #009900;">&#41;</span>
org.<span style="color: #006633;">springframework</span>.<span style="color: #006633;">web</span>.<span style="color: #006633;">servlet</span>.<span style="color: #006633;">DispatcherServlet</span>.<span style="color: #006633;">doService</span><span style="color: #009900;">&#40;</span>DispatcherServlet.<span style="color: #006633;">java</span>:<span style="color: #cc66cc;">716</span><span style="color: #009900;">&#41;</span>
org.<span style="color: #006633;">springframework</span>.<span style="color: #006633;">web</span>.<span style="color: #006633;">servlet</span>.<span style="color: #006633;">FrameworkServlet</span>.<span style="color: #006633;">processRequest</span><span style="color: #009900;">&#40;</span>FrameworkServlet.<span style="color: #006633;">java</span>:<span style="color: #cc66cc;">647</span><span style="color: #009900;">&#41;</span>
org.<span style="color: #006633;">springframework</span>.<span style="color: #006633;">web</span>.<span style="color: #006633;">servlet</span>.<span style="color: #006633;">FrameworkServlet</span>.<span style="color: #006633;">doGet</span><span style="color: #009900;">&#40;</span>FrameworkServlet.<span style="color: #006633;">java</span>:<span style="color: #cc66cc;">552</span><span style="color: #009900;">&#41;</span>
javax.<span style="color: #006633;">servlet</span>.<span style="color: #006633;">http</span>.<span style="color: #006633;">HttpServlet</span>.<span style="color: #006633;">service</span><span style="color: #009900;">&#40;</span>HttpServlet.<span style="color: #006633;">java</span>:<span style="color: #cc66cc;">621</span><span style="color: #009900;">&#41;</span>
javax.<span style="color: #006633;">servlet</span>.<span style="color: #006633;">http</span>.<span style="color: #006633;">HttpServlet</span>.<span style="color: #006633;">service</span><span style="color: #009900;">&#40;</span>HttpServlet.<span style="color: #006633;">java</span>:<span style="color: #cc66cc;">722</span><span style="color: #009900;">&#41;</span>
org.<span style="color: #006633;">apache</span>.<span style="color: #006633;">catalina</span>.<span style="color: #006633;">core</span>.<span style="color: #006633;">ApplicationFilterChain</span>.<span style="color: #006633;">internalDoFilter</span><span style="color: #009900;">&#40;</span>ApplicationFilterChain.<span style="color: #006633;">java</span>:<span style="color: #cc66cc;">304</span><span style="color: #009900;">&#41;</span>
org.<span style="color: #006633;">apache</span>.<span style="color: #006633;">catalina</span>.<span style="color: #006633;">core</span>.<span style="color: #006633;">ApplicationFilterChain</span>.<span style="color: #006633;">doFilter</span><span style="color: #009900;">&#40;</span>ApplicationFilterChain.<span style="color: #006633;">java</span>:<span style="color: #cc66cc;">210</span><span style="color: #009900;">&#41;</span>
org.<span style="color: #006633;">springframework</span>.<span style="color: #006633;">web</span>.<span style="color: #006633;">filter</span>.<span style="color: #006633;">HiddenHttpMethodFilter</span>.<span style="color: #006633;">doFilterInternal</span><span style="color: #009900;">&#40;</span>HiddenHttpMethodFilter.<span style="color: #006633;">java</span>:<span style="color: #cc66cc;">71</span><span style="color: #009900;">&#41;</span>
org.<span style="color: #006633;">springframework</span>.<span style="color: #006633;">web</span>.<span style="color: #006633;">filter</span>.<span style="color: #006633;">OncePerRequestFilter</span>.<span style="color: #006633;">doFilter</span><span style="color: #009900;">&#40;</span>OncePerRequestFilter.<span style="color: #006633;">java</span>:<span style="color: #cc66cc;">76</span><span style="color: #009900;">&#41;</span>
org.<span style="color: #006633;">apache</span>.<span style="color: #006633;">catalina</span>.<span style="color: #006633;">core</span>.<span style="color: #006633;">ApplicationFilterChain</span>.<span style="color: #006633;">internalDoFilter</span><span style="color: #009900;">&#40;</span>ApplicationFilterChain.<span style="color: #006633;">java</span>:<span style="color: #cc66cc;">243</span><span style="color: #009900;">&#41;</span>
org.<span style="color: #006633;">apache</span>.<span style="color: #006633;">catalina</span>.<span style="color: #006633;">core</span>.<span style="color: #006633;">ApplicationFilterChain</span>.<span style="color: #006633;">doFilter</span><span style="color: #009900;">&#40;</span>ApplicationFilterChain.<span style="color: #006633;">java</span>:<span style="color: #cc66cc;">210</span><span style="color: #009900;">&#41;</span>
org.<span style="color: #006633;">apache</span>.<span style="color: #006633;">catalina</span>.<span style="color: #006633;">core</span>.<span style="color: #006633;">StandardWrapperValve</span>.<span style="color: #006633;">invoke</span><span style="color: #009900;">&#40;</span>StandardWrapperValve.<span style="color: #006633;">java</span>:<span style="color: #cc66cc;">240</span><span style="color: #009900;">&#41;</span>
org.<span style="color: #006633;">apache</span>.<span style="color: #006633;">catalina</span>.<span style="color: #006633;">core</span>.<span style="color: #006633;">StandardContextValve</span>.<span style="color: #006633;">invoke</span><span style="color: #009900;">&#40;</span>StandardContextValve.<span style="color: #006633;">java</span>:<span style="color: #cc66cc;">164</span><span style="color: #009900;">&#41;</span>
org.<span style="color: #006633;">apache</span>.<span style="color: #006633;">catalina</span>.<span style="color: #006633;">authenticator</span>.<span style="color: #006633;">AuthenticatorBase</span>.<span style="color: #006633;">invoke</span><span style="color: #009900;">&#40;</span>AuthenticatorBase.<span style="color: #006633;">java</span>:<span style="color: #cc66cc;">462</span><span style="color: #009900;">&#41;</span>
org.<span style="color: #006633;">apache</span>.<span style="color: #006633;">catalina</span>.<span style="color: #006633;">core</span>.<span style="color: #006633;">StandardHostValve</span>.<span style="color: #006633;">invoke</span><span style="color: #009900;">&#40;</span>StandardHostValve.<span style="color: #006633;">java</span>:<span style="color: #cc66cc;">164</span><span style="color: #009900;">&#41;</span>
org.<span style="color: #006633;">apache</span>.<span style="color: #006633;">catalina</span>.<span style="color: #006633;">valves</span>.<span style="color: #006633;">ErrorReportValve</span>.<span style="color: #006633;">invoke</span><span style="color: #009900;">&#40;</span>ErrorReportValve.<span style="color: #006633;">java</span>:<span style="color: #cc66cc;">100</span><span style="color: #009900;">&#41;</span>
org.<span style="color: #006633;">apache</span>.<span style="color: #006633;">catalina</span>.<span style="color: #006633;">valves</span>.<span style="color: #006633;">AccessLogValve</span>.<span style="color: #006633;">invoke</span><span style="color: #009900;">&#40;</span>AccessLogValve.<span style="color: #006633;">java</span>:<span style="color: #cc66cc;">563</span><span style="color: #009900;">&#41;</span>
org.<span style="color: #006633;">apache</span>.<span style="color: #006633;">catalina</span>.<span style="color: #006633;">core</span>.<span style="color: #006633;">StandardEngineValve</span>.<span style="color: #006633;">invoke</span><span style="color: #009900;">&#40;</span>StandardEngineValve.<span style="color: #006633;">java</span>:<span style="color: #cc66cc;">118</span><span style="color: #009900;">&#41;</span>
org.<span style="color: #006633;">apache</span>.<span style="color: #006633;">catalina</span>.<span style="color: #006633;">connector</span>.<span style="color: #006633;">CoyoteAdapter</span>.<span style="color: #006633;">service</span><span style="color: #009900;">&#40;</span>CoyoteAdapter.<span style="color: #006633;">java</span>:<span style="color: #cc66cc;">399</span><span style="color: #009900;">&#41;</span>
org.<span style="color: #006633;">apache</span>.<span style="color: #006633;">coyote</span>.<span style="color: #006633;">http11</span>.<span style="color: #006633;">Http11Processor</span>.<span style="color: #006633;">process</span><span style="color: #009900;">&#40;</span>Http11Processor.<span style="color: #006633;">java</span>:<span style="color: #cc66cc;">317</span><span style="color: #009900;">&#41;</span>
org.<span style="color: #006633;">apache</span>.<span style="color: #006633;">coyote</span>.<span style="color: #006633;">http11</span>.<span style="color: #006633;">Http11Protocol</span>$Http11ConnectionHandler.<span style="color: #006633;">process</span><span style="color: #009900;">&#40;</span>Http11Protocol.<span style="color: #006633;">java</span>:<span style="color: #cc66cc;">204</span><span style="color: #009900;">&#41;</span>
org.<span style="color: #006633;">apache</span>.<span style="color: #006633;">tomcat</span>.<span style="color: #006633;">util</span>.<span style="color: #006633;">net</span>.<span style="color: #006633;">JIoEndpoint</span>$SocketProcessor.<span style="color: #006633;">run</span><span style="color: #009900;">&#40;</span>JIoEndpoint.<span style="color: #006633;">java</span>:<span style="color: #cc66cc;">311</span><span style="color: #009900;">&#41;</span>
java.<span style="color: #006633;">util</span>.<span style="color: #006633;">concurrent</span>.<span style="color: #003399; font-weight: bold;">ThreadPoolExecutor</span>$Worker.<span style="color: #006633;">runTask</span><span style="color: #009900;">&#40;</span><span style="color: #003399; font-weight: bold;">ThreadPoolExecutor</span>.<span style="color: #006633;">java</span>:<span style="color: #cc66cc;">886</span><span style="color: #009900;">&#41;</span>
java.<span style="color: #006633;">util</span>.<span style="color: #006633;">concurrent</span>.<span style="color: #003399; font-weight: bold;">ThreadPoolExecutor</span>$Worker.<span style="color: #006633;">run</span><span style="color: #009900;">&#40;</span><span style="color: #003399; font-weight: bold;">ThreadPoolExecutor</span>.<span style="color: #006633;">java</span>:<span style="color: #cc66cc;">908</span><span style="color: #009900;">&#41;</span>
java.<span style="color: #006633;">lang</span>.<span style="color: #003399; font-weight: bold;">Thread</span>.<span style="color: #006633;">run</span><span style="color: #009900;">&#40;</span><span style="color: #003399; font-weight: bold;">Thread</span>.<span style="color: #006633;">java</span>:<span style="color: #cc66cc;">662</span><span style="color: #009900;">&#41;</span></pre></div></div>

<p style="text-align: left;">La source du problème est détectée dans la fonction : <em>org.springframework.samples.petclinic.web.FindOwnersForm.processSubmit(FindOwnersForm.java:50)</em></p>
<p>Il ne reste plus qu'à corriger le problème. Pour cela plusieurs solutions sont possibles :</p>
<ul>
<li style="text-align: left;">Modifier directement la fonction <em>org.springframework.samples.petclinic.web.FindOwnersForm.processSubmit</em></li>
<li>Utiliser Findbugs pour détecter les appels à <em>System.gc()</em></li>
<li>Utiliser l'option <em>-XX:DisableExplicitGC</em> de la JVM</li>
</ul>
<p>Dans notre cas, nous allons directement corriger le code source car nous savons exactement où se trouve le problème.</p>
<h3>2.4 Relançons nos tests de charge avec 100 utilisateurs</h3>
<p class="info">Nous pouvons constater la différence et confirmer notre hypothèse.</p>
<p><a href="http://blog.aliecom.com/pourquoi-il-est-dangereux-dutiliser-system-gc/pq_system_gc_good_gc_100vu_activity/" rel="attachment wp-att-1053"><img class="aligncenter size-medium wp-image-1053" title="pq_system_gc_good_gc_100VU_activity" src="http://blog.aliecom.com/wp-content/uploads/2012/01/pq_system_gc_good_gc_100VU_activity-300x160.jpg" alt="" width="300" height="160" /></a><br />
<a href="http://blog.aliecom.com/pourquoi-il-est-dangereux-dutiliser-system-gc/pq_system_gc_good_gc_100vu_activity_old/" rel="attachment wp-att-1054"><img class="aligncenter size-medium wp-image-1054" title="pq_system_gc_good_gc_100VU_activity_old" src="http://blog.aliecom.com/wp-content/uploads/2012/01/pq_system_gc_good_gc_100VU_activity_old-300x148.jpg" alt="" width="300" height="148" /></a></p>
<p class="info">Le temps de réponse de la transaction fautive est même divisé par dix.</p>
<p><a href="http://blog.aliecom.com/pourquoi-il-est-dangereux-dutiliser-system-gc/pq_system_gc_good_gc_100vu_time/" rel="attachment wp-att-1044"><img class="aligncenter size-medium wp-image-1044" title="pq_system_gc_good_gc_100VU_time" src="http://blog.aliecom.com/wp-content/uploads/2012/01/pq_system_gc_good_gc_100VU_time-300x25.jpg" alt="" width="300" height="25" /></a></p>
<h2>3. Mon conseil</h2>
<p class="tip">Mon conseil est de ne pas utiliser de <em>System.gc()</em>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.aliecom.com/pourquoi-il-est-dangereux-dutiliser-system-gc/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Pourquoi faire attention au volume du jeu de données en base</title>
		<link>http://blog.aliecom.com/pourquoi-faire-attention-au-volume-du-jeu-de-donnees-en-base/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=pourquoi-faire-attention-au-volume-du-jeu-de-donnees-en-base</link>
		<comments>http://blog.aliecom.com/pourquoi-faire-attention-au-volume-du-jeu-de-donnees-en-base/#comments</comments>
		<pubDate>Wed, 25 Jan 2012 07:30:41 +0000</pubDate>
		<dc:creator>Antonio Gomes-Rodrigues</dc:creator>
				<category><![CDATA[Performance applicative]]></category>
		<category><![CDATA[Tests de charge et performance]]></category>
		<category><![CDATA[jmeter]]></category>
		<category><![CDATA[méthodologie]]></category>
		<category><![CDATA[tests de charge]]></category>

		<guid isPermaLink="false">http://blog.aliecom.com/?p=959</guid>
		<description><![CDATA[1. La source du problème Lorsqu'on développe une application, pour gagner du temps on travaille souvent avec des jeux de données réduits. En dehors de la question de pure "facilité", cela permet également de : réduire le temps d’exécution des requêtes SQL ; réduire le temps de chargement de la sauvegarde de la base ; avoir toute l'application [...]]]></description>
			<content:encoded><![CDATA[<h2>1. La source du problème</h2>
<p>Lorsqu'on développe une application, pour<strong> gagner du temps</strong> on travaille souvent avec des <strong>jeux de données réduits</strong>.<br />
En dehors de la question de pure "facilité", cela permet également de :</p>
<ul>
<li>réduire le temps d’exécution des requêtes SQL ;</li>
<li>réduire le temps de chargement de la sauvegarde de la base ;</li>
<li>avoir toute l'application sur son poste de travail ;</li>
</ul>
<p><span id="more-959"></span></p>
<h2>2. Ses conséquences</h2>
<p>Malheureusement ce temps gagné peut être rapidement perdu si des tests avec une volumétrie proche de ce qu'il y aura en production ne sont pas exécutés au plus tôt. Car lorsque l'application n'est pas testée en amont avec une volumétrie réelle, on pourra se retrouver avec des nombreux <strong>problèmes de performance</strong>, non identifiés au préalable, et <strong>qui nécessiteront des retours à la case développement</strong> (et donc du <strong>temps</strong> et de l'<strong>argent</strong>).<br />
Ces problèmes peuvent être :</p>
<ul>
<li>des problèmes de conception ;</li>
<li>des problèmes d'architecture matériel et/ou logiciel ;</li>
<li>des problèmes d'algorithme ;</li>
<li>des problèmes de conception du schéma de base de données ;</li>
<li>des problèmes de choix de composant ;</li>
<li>des problèmes de paramétrage ;</li>
<li>des problèmes de stabilités ;</li>
</ul>
<p><br/><br />
Bien sûr ces problèmes peuvent aussi apparaître lors de la campagne de <strong>test de performance</strong> si le choix de la volumétrie n'a pas été bon.</p>
<h2>3. Passons à la pratique</h2>
<p>Voila quelques exemples pour illustrer ces problèmes.</p>
<h3>3.1 Exemple 1 </h3>
<p>Pour notre premier exemple, regardons l'application de démonstration PlantsByWebSphere livré avec <a href="http://www.ibm.com/developerworks/downloads/ws/was/" target="_blank">IBM WebSphere</a>.</p>
<p>Voici la page de sélection d'un article avec la volumétrie de base.</p>
<p><a href="http://blog.aliecom.com/pourquoi-faire-attention-au-volume-du-jeu-de-donnees-en-base/pq_volume_data_display_normal/" rel="attachment wp-att-956"><img class="aligncenter size-medium wp-image-956" title="pq_volume_data_display_normal" src="http://blog.aliecom.com/wp-content/uploads/2011/12/pq_volume_data_display_normal-200x300.png" alt="" width="200" height="300" /></a></p>
<p>Et son temps d'affichage.</p>
<p><a href="http://blog.aliecom.com/pourquoi-faire-attention-au-volume-du-jeu-de-donnees-en-base/pq_volume_data_display_normal_time/" rel="attachment wp-att-957"><img class="aligncenter size-medium wp-image-957" title="pq_volume_data_display_normal_time" src="http://blog.aliecom.com/wp-content/uploads/2011/12/pq_volume_data_display_normal_time-300x139.jpg" alt="" width="300" height="139" /></a><br />
<br/><br />
Maintenant, utilisons <a href="http://arodrigues.developpez.com/tutoriels/java/performance/benerator/" target="_blank">Benerator</a> afin d'augmenter la volumétrie.</p>
<p><a href="http://blog.aliecom.com/pourquoi-faire-attention-au-volume-du-jeu-de-donnees-en-base/pq_volume_data_display_normal/" rel="attachment wp-att-956"><img class="aligncenter size-medium wp-image-956" title="pq_volume_data_display_normal" src="http://blog.aliecom.com/wp-content/uploads/2011/12/pq_volume_data_display_normal-200x300.png" alt="" width="200" height="300" /></a></p>
<p>On constate qu'il aurait été judicieux de limiter le nombre d'articles affichés par page.</p>
<p>Le temps d'affichage confirme que la page met quatre fois plus de temps et que cela devient un problème.</p>
<p><a href="http://blog.aliecom.com/pourquoi-faire-attention-au-volume-du-jeu-de-donnees-en-base/pq_volume_data_display_pb_time/" rel="attachment wp-att-952"><img class="aligncenter size-medium wp-image-952" title="pq_volume_data_display_pb_time" src="http://blog.aliecom.com/wp-content/uploads/2011/12/pq_volume_data_display_pb_time-300x136.jpg" alt="" width="300" height="136" /></a></p>
<ul>
<h3>3.2 Exemple 2 </h3>
<p>Prenons un deuxième exemple.</p>
<p>Cette fois ci on va étudier l'impact de la volumétrie directement au niveau base de données.</p>
<p>Notre schéma sera le suivant.</p>
<p><a href="http://blog.aliecom.com/pourquoi-faire-attention-au-volume-du-jeu-de-donnees-en-base/pq_volume_data_schema_bdd/" rel="attachment wp-att-1020"><img class="aligncenter size-medium wp-image-1020" title="pq_volume_data_schema_bdd" src="http://blog.aliecom.com/wp-content/uploads/2011/12/pq_volume_data_schema_bdd-134x300.png" alt="" width="134" height="300" /></a></p>
<p>Et son code SQL sera.</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">TABLE</span> t_conducteur <span style="color: #66cc66;">&#40;</span>
  id_conducteur <span style="color: #993333; font-weight: bold;">INT</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span><span style="color: #66cc66;">,</span>
  nom <span style="color: #993333; font-weight: bold;">VARCHAR</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">64</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span>
  prenom <span style="color: #993333; font-weight: bold;">VARCHAR</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">64</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span>
  email <span style="color: #993333; font-weight: bold;">VARCHAR</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">64</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span>
  <span style="color: #993333; font-weight: bold;">PRIMARY</span> <span style="color: #993333; font-weight: bold;">KEY</span>  <span style="color: #66cc66;">&#40;</span>id_conducteur<span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">TABLE</span> t_voiture <span style="color: #66cc66;">&#40;</span>
  id_voiture <span style="color: #993333; font-weight: bold;">INT</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span><span style="color: #66cc66;">,</span>
  prix <span style="color: #993333; font-weight: bold;">INT</span><span style="color: #66cc66;">,</span>
  couleur <span style="color: #993333; font-weight: bold;">VARCHAR</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">64</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span><span style="color: #66cc66;">,</span>
  conducteur_fk <span style="color: #993333; font-weight: bold;">INT</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span><span style="color: #66cc66;">,</span>
  <span style="color: #993333; font-weight: bold;">PRIMARY</span> <span style="color: #993333; font-weight: bold;">KEY</span>  <span style="color: #66cc66;">&#40;</span>id_voiture<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span>
  <span style="color: #993333; font-weight: bold;">CONSTRAINT</span> t_voiture_conducteur_fk <span style="color: #993333; font-weight: bold;">FOREIGN</span> <span style="color: #993333; font-weight: bold;">KEY</span> <span style="color: #66cc66;">&#40;</span>conducteur_fk<span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">REFERENCES</span> t_conducteur <span style="color: #66cc66;">&#40;</span>id_conducteur<span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#41;</span>;</pre></div></div>

<p><br/><br />
Utilisons encore Benerator pour générer un petit volume de données.</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;iso-8859-1&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;setup</span> </span>
<span style="color: #009900;">	<span style="color: #000066;">xmlns</span>=<span style="color: #ff0000;">&quot;http://databene.org/benerator/0.7.2&quot;</span></span>
<span style="color: #009900;">	<span style="color: #000066;">xmlns:xsi</span>=<span style="color: #ff0000;">&quot;http://www.w3.org/2001/XMLSchema-instance&quot;</span></span>
<span style="color: #009900;">	<span style="color: #000066;">xsi:schemaLocation</span>=<span style="color: #ff0000;">&quot;http://databene.org/benerator/0.7.2 http://databene.org/benerator-0.7.2.xsd&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
&nbsp;
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;import</span> domains   = <span style="color: #ff0000;">&quot;person,net,address&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;import</span> platforms = <span style="color: #ff0000;">&quot;db&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;database</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;db&quot;</span> <span style="color: #000066;">url</span>=<span style="color: #ff0000;">&quot;jdbc:postgresql://localhost:5432/postgres&quot;</span> <span style="color: #000066;">driver</span>=<span style="color: #ff0000;">&quot;org.postgresql.Driver&quot;</span> <span style="color: #000066;">catalog</span>=<span style="color: #ff0000;">&quot;postgres&quot;</span> <span style="color: #000066;">schema</span>=<span style="color: #ff0000;">&quot;public&quot;</span> <span style="color: #000066;">user</span>=<span style="color: #ff0000;">&quot;benerator&quot;</span> <span style="color: #000066;">password</span>=<span style="color: #ff0000;">&quot;benerator&quot;</span> <span style="color: #000066;">batch</span>=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #000066;">fetchSize</span>=<span style="color: #ff0000;">&quot;1000&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
&nbsp;
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;bean</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;idGen&quot;</span> <span style="color: #000066;">spec</span>=<span style="color: #ff0000;">&quot;new DBSeqHiLoGenerator('seq_pq_data_id_gen', 1, db)&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
&nbsp;
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;generate</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;t_conducteur&quot;</span> <span style="color: #000066;">count</span>=<span style="color: #ff0000;">&quot;1000&quot;</span> <span style="color: #000066;">consumer</span>=<span style="color: #ff0000;">&quot;db&quot;</span> <span style="color: #000066;">pageSize</span>=<span style="color: #ff0000;">&quot;1000&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;variable</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;individu&quot;</span> <span style="color: #000066;">generator</span>=<span style="color: #ff0000;">&quot;org.databene.domain.person.PersonGenerator&quot;</span> <span style="color: #000066;">dataset</span>=<span style="color: #ff0000;">&quot;FR&quot;</span> <span style="color: #000066;">locale</span>=<span style="color: #ff0000;">&quot;fr&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;id</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;id_conducteur&quot;</span> <span style="color: #000066;">generator</span>=<span style="color: #ff0000;">&quot;idGen&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;attribute</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;prenom&quot;</span> <span style="color: #000066;">script</span>=<span style="color: #ff0000;">&quot;individu.givenName&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;attribute</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;nom&quot;</span> <span style="color: #000066;">script</span>=<span style="color: #ff0000;">&quot;individu.familyName&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;attribute</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;email&quot;</span> <span style="color: #000066;">script</span>=<span style="color: #ff0000;">&quot;individu.email&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>	
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/generate<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;generate</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;t_voiture&quot;</span> <span style="color: #000066;">count</span>=<span style="color: #ff0000;">&quot;3000&quot;</span> <span style="color: #000066;">consumer</span>=<span style="color: #ff0000;">&quot;db&quot;</span> <span style="color: #000066;">pageSize</span>=<span style="color: #ff0000;">&quot;1000&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;id</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;id_voiture&quot;</span> <span style="color: #000066;">generator</span>=<span style="color: #ff0000;">&quot;idGen&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;attribute</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;prix&quot;</span> <span style="color: #000066;">min</span>=<span style="color: #ff0000;">&quot;8000&quot;</span> <span style="color: #000066;">max</span>=<span style="color: #ff0000;">&quot;200000&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;reference</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;couleur&quot;</span> <span style="color: #000066;">values</span>=<span style="color: #ff0000;">&quot;'rouge','verte','noir','blanche','jaune','orange','bleu','violette','grise','bleu ciel','gris clair'&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;reference</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;conducteur_fk&quot;</span> <span style="color: #000066;">targetType</span>=<span style="color: #ff0000;">&quot;t_conducteur&quot;</span> <span style="color: #000066;">source</span>=<span style="color: #ff0000;">&quot;db&quot;</span> <span style="color: #000066;">distribution</span>=<span style="color: #ff0000;">&quot;expand&quot;</span> <span style="color: #000066;">cyclic</span>=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/generate<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/setup<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p><br/><br />
Utilisons <a href="http://blog.aliecom.com/presentation-de-loutil-apache-jmeter-partie-1/" target="_blank">JMeter</a> pour exécuter mille fois cette requête.</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">SELECT</span> <span style="color: #66cc66;">*</span> <span style="color: #993333; font-weight: bold;">FROM</span> t_conducteur 
<span style="color: #993333; font-weight: bold;">LEFT</span> <span style="color: #993333; font-weight: bold;">JOIN</span> t_voiture 
<span style="color: #993333; font-weight: bold;">ON</span> id_conducteur<span style="color: #66cc66;">=</span>conducteur_fk 
<span style="color: #993333; font-weight: bold;">WHERE</span> couleur <span style="color: #66cc66;">=</span> <span style="color: #ff0000;">'rouge'</span></pre></div></div>

<p><a href="http://blog.aliecom.com/pourquoi-faire-attention-au-volume-du-jeu-de-donnees-en-base/pq_volume_data_jmeter/" rel="attachment wp-att-955"><img class="aligncenter size-full wp-image-955" title="pq_volume_data_jmeter" src="http://blog.aliecom.com/wp-content/uploads/2011/12/pq_volume_data_jmeter.jpg" alt="" width="253" height="133" /></a></p>
<p>Voila les résultats<br />
<a href="http://blog.aliecom.com/pourquoi-faire-attention-au-volume-du-jeu-de-donnees-en-base/pq_volume_data_jdbc_normal/" rel="attachment wp-att-954"><img class="aligncenter size-medium wp-image-954" title="pq_volume_data_jdbc_normal" src="http://blog.aliecom.com/wp-content/uploads/2011/12/pq_volume_data_jdbc_normal-300x10.jpg" alt="" width="300" height="10" /></a><br />
&nbsp;<br />
Maintenant augmentons la volumétrie de 500 000 entrées par table et rejouons le même test.</p>
<p><a href="http://blog.aliecom.com/pourquoi-faire-attention-au-volume-du-jeu-de-donnees-en-base/pq_volume_data_jdbc_500000/" rel="attachment wp-att-953"><img class="aligncenter size-medium wp-image-953" title="pq_volume_data_jdbc_500000" src="http://blog.aliecom.com/wp-content/uploads/2011/12/pq_volume_data_jdbc_500000-300x9.jpg" alt="" width="300" height="9" /></a><br />
&nbsp;<br />
Comme on peut le constater, les temps de réponse n'ont plus rien à voir.</p>
<h2>4. Mon conseil</h2>
<p class="tip">Mon conseil est de faire au plus tôt des tests (des POC pendant la phase de conception, des tests composites, des tests de charge pour valider l'architecture et la robustesse des couches applicatives ) avec une volumétrie la plus proche de la réalité afin de minimiser au maximum les risques liés au volume de données.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.aliecom.com/pourquoi-faire-attention-au-volume-du-jeu-de-donnees-en-base/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Analyse système et réseau : généralités &#8211; Part 2</title>
		<link>http://blog.aliecom.com/analyser-votre-systeme-et-reseau-approche-de-base-part-2/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=analyser-votre-systeme-et-reseau-approche-de-base-part-2</link>
		<comments>http://blog.aliecom.com/analyser-votre-systeme-et-reseau-approche-de-base-part-2/#comments</comments>
		<pubDate>Thu, 19 Jan 2012 09:00:09 +0000</pubDate>
		<dc:creator>Stéphane Chabrier</dc:creator>
				<category><![CDATA[Systèmes et Réseaux]]></category>
		<category><![CDATA[disk]]></category>
		<category><![CDATA[iostat]]></category>
		<category><![CDATA[netstat]]></category>
		<category><![CDATA[network]]></category>
		<category><![CDATA[sar]]></category>
		<category><![CDATA[top]]></category>
		<category><![CDATA[vmstat]]></category>

		<guid isPermaLink="false">http://ded2.aliecom.com/dev/blogAliecom/?p=301</guid>
		<description><![CDATA[Après avoir vu comment superviser la partie processeur et mémoire, attardons nous maintenant sur les accès disques et les connexions réseaux.  Monitoring Disk and Network Cette commande fournit des informations à propos de l'ensemble des périphériques d'entrée et sortie : les disques, le ou les terminaux, les autres périphériques séries. 1. La commande Iostat (ou sar [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignleft  wp-image-763" title="graph_systeme" src="http://blog.aliecom.com/wp-content/uploads/2011/10/graph_systeme1.png" alt="" width="155" height="98" />Après avoir vu comment superviser la partie processeur et mémoire, attardons nous maintenant sur les accès disques et les connexions réseaux.</p>
<h3 style="padding-left: 30px;"> Monitoring Disk and Network</h3>
<p>Cette commande fournit des informations à propos de l'ensemble des périphériques d'entrée et sortie : les disques, le ou les terminaux, les autres périphériques séries.</p>
<h2>1. La commande Iostat (ou sar -d)</h2>
<p>La syntaxe de base est la suivante :</p>
<pre class="code_simple">iostat interval count</pre>
<p><span id="more-301"></span></p>
<pre class="code_simple">exemple : iostat -xtc 5 2
avg-cpu:  %user   %nice    %sys %iowait   %idle
           0.01    0.00    0.01    0.04   99.93
                      extended device statistics                    tty         cpu
device    r/s    w/s   kr/s   kw/s wait actv  svc_t  %w  %b  tin tout  us sy wt id
cmdk0     1.0    2.3   10.9   19.4  0.0  0.0    5.4   0   1    0   59  13  3  0 84
fd0       0.0    0.0    0.0    0.0  0.0  0.0  986.3   0   0
sd0       0.0    0.0    0.0    0.0  0.0  0.0    0.0   0   0
sd1       0.0    0.0    0.0    0.0  0.0  0.0    0.0   0   0 

		     extended device statistics                    tty         cpu
device    r/s    w/s   kr/s   kw/s wait actv  svc_t  %w  %b  tin tout  us sy wt id
cmdk0     0.0    9.3    0.0   35.3  0.0  0.0    3.5   0   3    0    0   7  2  0 90
fd0       0.0    0.0    0.0    0.0  0.0  0.0    0.0   0   0
sd0       0.0    0.0    0.0    0.0  0.0  0.0    0.0   0   0
sd1       0.0    0.0    0.0    0.0  0.0  0.0    0.0   0   0</pre>
<p>&nbsp;</p>
<ul>
<li><strong>wait</strong> : le nombre moyen de transactions en attente d'être traitées</li>
<li><strong>actv</strong> : le nombre moyen de transactions en cours de traitement (elles ne sont plus dans la queue mais ne sont pas pour autant terminées)</li>
<li><strong>svc _t</strong> : le temps moyen de traitement</li>
<li><strong>%w</strong> : le pourcentage du temps durant lequel des transactions sont en attente d'un traitement</li>
<li><strong>%b</strong> : pourcentage du temps durant lequel le disque est occupé</li>
</ul>
<p class="info">Les colonnes r/s, w/s, kr/s, et kw/s montrent respectivement les <strong>read</strong> et <strong>write</strong> par secondes en octets et kilo-octets.</p>
<p>Le temps de traitement et le temps d'occupation donnent une bonne impression sur l'état des entrées / sorties d'un disque. Un taux d'occupation de plus de deux-tiers (<strong>%b</strong>)  et un temps de traitement de plus de 50 millisecondes (<strong>svc_t</strong>) sont les indicateurs d'un <span style="text-decoration: underline;">goulot d'étranglement</span>.</p>
<p>&nbsp;</p>
<p><span class="surligne_jaune">Conseils et optimisations :</span></p>
<ul>
<li>répartir la charge sur plusieurs disques en utilisant un meilleur partitionnement, et en distribuant le swap (pagination) sur plusieurs disques.</li>
<li>augmenter la RAM pour diminuer la pagination; c'est le cas par exemple lors de l'utilisation de SGBD qui sont très gourmands en ressource mémoire, mais peu demandeurs de capacités de traitement rapides par le processeur.</li>
<li>utiliser autant que faire se peut les ressources en cache des applications développées. Les architectures techniques intègrent de plus en plus de serveurs de cache qui ne sollicitent que la mémoire et une faible charge de CPU. Optimiser les requêtes SQL pour optimiser les coûts de ressource CPU.</li>
<li>si le disque est utilisé à  100%, on peut répartir le système de fichier sur plusieurs disques en utilisant un SAN ou plusieurs NAS;</li>
</ul>
<h2>2. La commande Netstat</h2>
<p>C'est l'incontournable des indicateurs réseaux. En règle générale, on retrouve au moins trois ou quatre options communes aux différents OS.</p>
<ul>
<li>-a  montre l'état de tous les sockets</li>
<li>-r  montre les tables de routage du système</li>
</ul>
<pre class="code_simple">$ netstat -i

Name  Mtu Net/Dest  Address    Ipkts  Ierrs  Opkts  Oerrs  Collis Queue
lo0  8232 loopback localhost   77814  0      77814    0         0   0
hme0 1500 server1  server1  10658566  3    4832511    0    279257   0</pre>
<p>Les valeurs importantes à  noter sont :</p>
<ul>
<li>collisions (Collis)</li>
<li>les paquets envoyés (Opkts)</li>
<li>les paquets reçus (Ipkts)</li>
<li>les paquets erronés (Ierrs)</li>
</ul>
<p><span class="surligne_jaune">Conseils et optimisations :</span></p>
<ul>
<li>(Collis+Ierrs+Oerrs)/(Ipkts+Opkts) &gt; 2% peut indiquer un problème physique dans le réseau;</li>
<li>(Collis/Opkts) &gt; 10% indique que l'interface réseau est surchargée et qu'il faut redistribuer les charges;</li>
<li>(Ierrs/Ipkts) &gt; 25% montre un gros nombre de paquets abandonnés en raison d'un réseau surchargé;</li>
<li>s'il y a plus de 120 collisions par secondes, le réseau est surchargé;</li>
<li>si la somme des paquets entrants et des paquets sortants est supérieure à  600 pour une interface de 10-Mbs et à  6000 pour une interface de 100-Mbs, le segment est trop chargé et une redistribution du réseau s'impose;</li>
<li>un nombre important d'erreurs dans les colonnes "<strong>Ierrs</strong>" et "<strong>Oerrs</strong>" indique un problème de transmission et/ou de réception. Il se peut que la source et la destination aient des réglages différents comme full-duplex d'un côté et half-duplex de l'autre.</li>
</ul>
<pre class="code_simple">#netstat -nar -p tcp

Local Address Remote Address Swind    Send-Q Rwind  Recv-Q State
*.*           *.*            0        0      24576  0     IDLE
*.22          *.*            0        0      24576  0     LISTEN
*.32775       *.*            0        0      24576  0     LISTEN
*.32776       *.*            0        0      24576  0     LISTEN
*.*           *.*            0        0      24576  0     IDLE
192.168.1.184.22 192.168.1.186.56806 38912 0 24616  0     ESTABLISHED
192.168.1.184.22 192.168.1.183.58672 18048 0 24616  0     ESTABLISHED</pre>
<p>Les valeurs importantes à  noter sont :</p>
<ul>
<li>CLOSED : fermé le socket n'est pas utilisé</li>
<li>LISTEN : à l'écoute de connexions entrantes</li>
<li>SYN_SENT : essai d'établir une connexion</li>
<li>SYN_RECEIVED : synchronisation initiale de la connexion en cours</li>
<li>ESTABLISHED : connexion établie</li>
<li>CLOSE_WAIT : fermeture à  distance (côté serveur par exemple); en attente de fermeture du socket</li>
<li>FIN_WAIT_1 : socket fermé terminaison de la connexion</li>
<li>CLOSING : fermé, puis fermeture à  distance; attente d'accusé de réception</li>
<li>LAST_ACK : terminaison à  distance puis fermeture; attente d'accusé de réception</li>
<li>FIN_WAIT_2 : socket fermée; en attente de terminaison de la part du pair distant</li>
<li>TIME_WAIT : en attente après fermeture pour la retransmission de la terminaison distante</li>
</ul>
<p>&nbsp;</p>
<p><span class="surligne_jaune">Conseils et optimisations :</span></p>
<p>Trop de connexions avec un état <strong>FIN_WAIT</strong>  signifie généralement qu'il faut modifier le paramétrage TCP/IP car les connexions ne sont pas terminées (en tout cas terminées proprement d'après les séquences prévues) et des connexions inactives s'accumulent.</p>
<p>Cela peut conduire à  un épuisement des ressources système. Le mieux est de contrôler le TCP "<strong>timeout</strong>" qui ferme au bout d'un certain nombre de secondes une connexion inutilisée.</p>
<p>Le pool peut ainsi être utilisé par de nouvelles connexions.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.aliecom.com/analyser-votre-systeme-et-reseau-approche-de-base-part-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Pourquoi désactiver les plugins du navigateur Web lors de l&#8217;enregistrement d&#8217;un scénario ?</title>
		<link>http://blog.aliecom.com/pourquoi-il-est-important-de-desactiver-les-plugins-du-navigateur-web-lors-de-lenregistrement-dun-scenario-web/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=pourquoi-il-est-important-de-desactiver-les-plugins-du-navigateur-web-lors-de-lenregistrement-dun-scenario-web</link>
		<comments>http://blog.aliecom.com/pourquoi-il-est-important-de-desactiver-les-plugins-du-navigateur-web-lors-de-lenregistrement-dun-scenario-web/#comments</comments>
		<pubDate>Wed, 18 Jan 2012 08:00:06 +0000</pubDate>
		<dc:creator>Antonio Gomes-Rodrigues</dc:creator>
				<category><![CDATA[Tests de charge et performance]]></category>
		<category><![CDATA[jmeter]]></category>
		<category><![CDATA[scripting]]></category>
		<category><![CDATA[tests de charge]]></category>

		<guid isPermaLink="false">http://ded2.aliecom.com/dev/blogAliecom/?p=449</guid>
		<description><![CDATA[Dans la majorité des outils de test de charge (HP LoadRunner, Apache JMeter, Microfocus SilkPerformer...) l'enregistrement des scripts est réalisé à l'aide d'un proxy. Toutes les requêtes qui passent par ce proxy sont enregistrées et l'on peut donc se retrouver avec des requêtes qui n'ont rien à faire dans notre script, en particulier si certains [...]]]></description>
			<content:encoded><![CDATA[<p lang="fr-FR">Dans la majorité des outils de test de charge (<a href="http://www8.hp.com/us/en/software/software-product.html?compURI=tcm:245-935779" target="_blank">HP LoadRunner</a>, <a href="http://jakarta.apache.org/jmeter/" target="_blank">Apache JMeter</a>, <a href="http://www.microfocus.com/products/silk/silkperformer/index.aspx" target="_blank">Microfocus SilkPerformer</a>...) l'enregistrement des scripts est réalisé à l'aide d'un proxy. Toutes les requêtes qui passent par ce proxy sont enregistrées et l'on peut donc se retrouver avec des requêtes qui n'ont rien à faire dans notre script, en particulier si certains plugins sont installés dans le navigateur Web utilisé pour notre enregistrement.</p>
<p lang="fr-FR">Ces requêtes inutiles vont faire appel à des environnements externes à celui qu'on teste et vont poser un certain nombre de problèmes comme :</p>
<ul>
<ul>
<li>
<p lang="fr-FR">avoir des temps de réponse faussés, dû à l'attente d’acquittement des sites externes ;</p>
</li>
<li>
<p lang="fr-FR">se faire black-lister par l'environnement externe ;</p>
</li>
</ul>
</ul>
<p><span id="more-449"></span></p>
<p lang="fr-FR">Par exemple dans ce script <strong>JMeter</strong> il y a un appel à <em>toolbarqueries.clients.google.com</em> qui a été enregistré.</p>
<p lang="fr-FR"><a href="http://blog.aliecom.com/wp-content/uploads/2011/10/pq_des_bar_pb_rec.jpg"><img class="size-medium wp-image-398 aligncenter" title="pq_des_bar_pb_rec" src="http://blog.aliecom.com/wp-content/uploads/2011/10/pq_des_bar_pb_rec-300x188.jpg" alt="" width="300" height="188" /></a></p>
<p>&nbsp;</p>
<ul>
<li>
<p lang="fr-FR">On lance un test sans rien changer pour obtenir ces temps de réponse catastrophiques.</p>
</li>
</ul>
<p lang="fr-FR"><a href="http://blog.aliecom.com/wp-content/uploads/2011/10/pq_des_bar_pb_rec_result_before.jpg"><img class="size-full wp-image-402 aligncenter" title="pq_des_bar_pb_rec_result_before" src="http://blog.aliecom.com/wp-content/uploads/2011/10/pq_des_bar_pb_rec_result_before.jpg" alt="" width="559" height="49" /></a></p>
<p>&nbsp;</p>
<ul>
<li>
<p lang="fr-FR">Supprimons maintenant cette requête, le but du test n'étant pas de faire un test de charge sur <em>toolbarqueries.clients.google.com</em></p>
</li>
</ul>
<p lang="fr-FR"><a href="http://blog.aliecom.com/wp-content/uploads/2011/10/pq_des_bar_pb_rec_del.jpg"><img class="wp-image-399 aligncenter" title="pq_des_bar_pb_rec_del" src="http://blog.aliecom.com/wp-content/uploads/2011/10/pq_des_bar_pb_rec_del.jpg" alt="" width="268" height="213" /></a></p>
<p>&nbsp;</p>
<ul>
<li>
<p lang="fr-FR">Rejouons le test et regardons ce que l'on obtient.</p>
</li>
</ul>
<p lang="fr-FR"><a href="http://blog.aliecom.com/wp-content/uploads/2011/10/pq_des_bar_pb_rec_result_after.jpg"><img class="size-full wp-image-401 aligncenter" title="pq_des_bar_pb_rec_result_after" src="http://blog.aliecom.com/wp-content/uploads/2011/10/pq_des_bar_pb_rec_result_after.jpg" alt="" width="559" height="47" /></a></p>
<p>&nbsp;</p>
<p lang="fr-FR">Voila qui est beaucoup mieux (il y a un gain de performance assez conséquent car cette requête posait d'autre problèmes dans l'environnement de test).</p>
<p class="info">Un autre exemple avec Mozilla Firefox qui cherche des mise à jour pour un flux RSS.</p>
<p lang="fr-FR"><a href="http://blog.aliecom.com/wp-content/uploads/2011/10/pq_des_bar_pb_rec_ex2_rss.jpg"><img class="size-medium wp-image-400 aligncenter" title="pq_des_bar_pb_rec_ex2_rss" src="http://blog.aliecom.com/wp-content/uploads/2011/10/pq_des_bar_pb_rec_ex2_rss-300x81.jpg" alt="" width="300" height="81" /></a></p>
<p>&nbsp;</p>
<p class="tip">Conseil « après l'enregistrement d'un script, penser à bien vérifier les appels d'Urls externes ».</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.aliecom.com/pourquoi-il-est-important-de-desactiver-les-plugins-du-navigateur-web-lors-de-lenregistrement-dun-scenario-web/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Optimiser Tomcat : les bests practices &#8211; Part 2</title>
		<link>http://blog.aliecom.com/optimiser-tomcat-les-bests-practices-part-2/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=optimiser-tomcat-les-bests-practices-part-2</link>
		<comments>http://blog.aliecom.com/optimiser-tomcat-les-bests-practices-part-2/#comments</comments>
		<pubDate>Sun, 15 Jan 2012 11:37:43 +0000</pubDate>
		<dc:creator>Stéphane Chabrier</dc:creator>
				<category><![CDATA[Architectures J2EE]]></category>
		<category><![CDATA[heap]]></category>
		<category><![CDATA[jvm]]></category>
		<category><![CDATA[tcp]]></category>
		<category><![CDATA[thread]]></category>
		<category><![CDATA[tomcat]]></category>

		<guid isPermaLink="false">http://ded2.aliecom.com/dev/blogAliecom/?p=335</guid>
		<description><![CDATA[&#160; Après avoir abordé les problématiques liées à la gestion de la Heap et des threads, voici une liste des paramètres principaux restants à aborder. (liste non-exhaustive évidemment !) Le Tuning HTTP et TCP Avant de s’attaquer à ces améliorations, il est important de comprendre et d'agir en fonction des connectors utilisés par votre serveur [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignleft  wp-image-839" title="imagesCA1CGEZL" src="http://blog.aliecom.com/wp-content/uploads/2011/10/imagesCA1CGEZL.jpg" alt="" width="195" height="89" /></p>
<p>&nbsp;</p>
<p>Après avoir abordé les problématiques liées à la gestion de la <strong>Heap</strong> et des <strong>threads</strong>, voici une liste des paramètres principaux restants à aborder. (liste non-exhaustive évidemment !)</p>
<h3>Le Tuning HTTP et TCP</h3>
<p>Avant de s’attaquer à ces améliorations, il est important de comprendre et d'agir en fonction des <strong>connectors</strong> utilisés par votre serveur :</p>
<p class="garrow"><em>Blocking IO Connector</em></p>
<p><span id="more-335"></span></p>
<ul>
<li> La majorité du contenu est dynamique</li>
<li>Keep-Alive n’est pas important</li>
<li> La fiabilité est une priorité</li>
</ul>
<p class="garrow"><em>Apache Portable Runtime/APR Connector</em></p>
<ul>
<li>La majorité du contenu est dynamique</li>
<li>Keep-Alive n’est pas important</li>
<li>La fiabilité est une priorité</li>
</ul>
<p class="garrow"><em>NIO Connector</em></p>
<ul>
<li>Connecteur non bloquant comme l’APR connector</li>
<li>A la différence de l’APR connector qui nécessite la librairie native APR, le NIO connecteur est portable sur toutes les  plateformes</li>
<li>Le NIO connector ne bénéficie par de l’optimisation SSL apportée par Open SSL</li>
</ul>
<p class="garrow"><em>AJP Connector</em></p>
<ul>Déconseillé, il n’est pas plus performant que les connecteurs HTTP et est en revanche difficile à diagnostiquer en cas d'anomalies.</ul>
<p><span class="surligne_jaune">Les principaux paramètres de connecteurs à configurer :</span></p>
<ul>
<li><strong><code>maxKeepAliveRequests</code></strong> : représente le nombre de requêtes HTTP que peut gérer une connexion TCP. Généralement  entre 100 et 200 (SSL, APR / NIO connector) ou 1 pour désactiver « Keep Alive » (pas de SSL, BIO connector, très forte concurrence).</li>
<li><strong><code>acceptCount</code></strong> (stack de threads - backlog TCP) : typiquement entre 50 et 300.</li>
<li><strong><code>connectionTimeout</code></strong> :  le temps maximum entre deux paquets TCP, suite à une demande de requête HTTP : entre 2000 à 3000 ms est souvent optimal, même en activant Keep Alive (valeur par défaut de 60000)</li>
</ul>
<p>&nbsp;</p>
<h2>1.Gestion des pool de connexion DB</h2>
<p>Trois paramètres parmis une liste plus complète, permettent d'influencer la gestion du nombre de connexions dans le pool :</p>
<ul>
<li>         <strong>maxActive</strong> : le nombre maximum de connexions qui peuvent être allouées depuis le pool. Sa valeur par défaut est 8, une valeur de 0 indique "sans limite". En règle générale, une valeur de 30 maxActive devrait permettre de supporter une charge conséquente sur une application Web grand public, sous réserve de requêtes optimisées). Il faut également vérifier que la base de données autorisera de son côté ce nombre de connexions.</li>
<li>          <strong>maxIdle</strong> : le nombre maximum de connexions inactives qui peuvent être dans le pool. Sa valeur par défaut est de 8, une valeur de 0 indique "sans limite"</li>
<li>          <strong>maxWait</strong> : le temps d'attente maximum en millisecondes pour l'obtention d'une connexion. Passé ce délai, une exception est levée. Sa valeur par défaut est -1 qui correspond à un temps infini</li>
</ul>
<p>L'utilisation de JDBC pouvant vite devenir complexe, il arrive que l'on oublie de fermer une connexion. Cette connexion ne revient donc pas dans le pool, on parle alors de "fuite du pool de connexion" (<em>pool leaking</em>). Ce phénomène peut aboutir à un blocage de l'application web par manque de connexions disponibles.</p>
<p>On peut configurer Tomcat pour qu'il récupère ces connexions et laisse une stack du code qui a ouvert la connexion et ne l'a jamais fermée. Par défaut cette fonction n'est pas activée. Si vous l'activez, Tomcat effectue cette recherche quand le nombre de connexions inactives (disponible dans le pool) est inférieur à 2. Les paramètres sont :</p>
<ul>
<li>          <strong>removeAbandoned</strong> : par défaut à false, c'est lui qui permet l'activation de cette fonction. Si on le met à true, une connexion est considérée comme abandonnée et éligible à la récupération si elle est inactive depuis plus longtemps que le removeAbandonedTimeout.</li>
<li>          <strong>removeAbandonedTimeout</strong> : C'est le temps en secondes (par défaut 300), avant qu'une connexion inactive soit considérée comme abandonnée.</li>
<li>          <strong>logAbandoned</strong> : par défaut à false. Si positionné à true, Tomcat ajoute une trace de la pile de l'application qui a abandonné la connexion.</li>
</ul>
<p class="info">En règle générale, un pool de connexion doit rester optimisé : un nombre de connexions limités, avec une performance de la base de données (et des requêtes SQL) permettant l'utilisation très rapide de ces connexions. Vous le comprendrez, rien ne sert de chercher à optimiser un pool de connexion pour des requêtes SQL qui mettront plusieurs secondes alors qu'elles devraient s'exécuter en quelques millisecondes ....</p>
<p>&nbsp;</p>
<h2>2.La compression et la gestion des caches</h2>
<p class="tip"><strong> Objectif : optimiser la gestion des contenus statiques</strong></p>
<ul>
<li>Les connecteurs APR et NIO offrent l’optimisation <em>SEND_FILE,</em> utilisant des background threads<em>.<br />
</em></li>
<li>Tomcat offre un cache du contenu statique. Cependant, cette fonctionnalité ne rivalise pas avec un proxy cache comme Squid ou <em>mod_cache</em> )<br />
exemple :</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>Context cacheMaxSize<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;40250&quot;</span>
             cacheTTL<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;40000&quot;</span> cacheAllowed<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;true&quot;</span><span style="color: #339933;">/&gt;</span></pre></div></div>

<p>&nbsp;</li>
<li>La compression des flux http se fait avec les options suivantes (/conf/server.xml)

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>Connector port<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;8080&quot;</span> maxHttpHeaderSize<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;8192&quot;</span> 
maxThreads<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;150&quot;</span> minSpareThreads<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;25&quot;</span> maxSpareThreads<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;75&quot;</span> 
acceptCount<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;100&quot;</span> disableUploadTimeout<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;true&quot;</span>
compression<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;on&quot;</span> compressionMinSize<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;2048&quot;</span> 
noCompressionUserAgents<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;gozilla, traviata&quot;</span> 
compressableMimeType<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;text/html,text/xml&quot;</span><span style="color: #339933;">/&gt;</span></pre></div></div>

</li>
</ul>
<p>&nbsp;</p>
<h2>3.La gestion des écritures de logs</h2>
<p>Par défaut, toutes les logs sont traçées dans le <em>sdtout </em>et les fichiers de logs sans réel gestion de l'overflow. De plus, les contraintes d<span style="text-decoration: underline;">'I/O disk</span> se répercutent directement sur la performance du système, et donc de l'application.</p>
<ul>
<li>Bien penser à supprimer les écritures dupliquées (souvent le cas quand on crée des fichiers de logs fonctionnels, techniques, etc... )</li>
<li>Pour éviter l'overflow, mettre en place le système de logs circulaires via une classe "maison" implémentant FileHandler (max 5 fichiers de 20 à 50Mo).<br/>
<p><i>exemple dans logging.properties :</i></p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">1catalina.<span style="color: #006633;">java</span>.<span style="color: #006633;">util</span>.<span style="color: #006633;">logging</span>.<span style="color: #006633;">FileHandler</span>.<span style="color: #006633;">pattern</span> <span style="color: #339933;">=</span> 
     $<span style="color: #009900;">&#123;</span>catalina.<span style="color: #006633;">base</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">/</span>logs<span style="color: #339933;">/</span>catalina.<span style="color: #339933;">%</span>g.<span style="color: #006633;">log</span> 
1catalina.<span style="color: #006633;">java</span>.<span style="color: #006633;">util</span>.<span style="color: #006633;">logging</span>.<span style="color: #006633;">FileHandler</span>.<span style="color: #006633;">limit</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">20000000</span>
1catalina.<span style="color: #006633;">java</span>.<span style="color: #006633;">util</span>.<span style="color: #006633;">logging</span>.<span style="color: #006633;">FileHandler</span>.<span style="color: #006633;">count</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">5</span></pre></div></div>

</li>
<li>Enfin pour optimiser les écritures et donc les accès I/O, privilégier les écritures en mode asynchrone grâce à l'implémentation maison de classe de gestion de log. Cela permettra ainsi d'éviter des OutOfMemoryError à cause d'overflow d'enregistrements de logs :<br />
</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">handlers <span style="color: #339933;">=</span> 1catalina.<span style="color: #006633;">my</span>.<span style="color: #006633;">custom</span>.<span style="color: #006633;">AsyncFileHandler</span></pre></div></div>

</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.aliecom.com/optimiser-tomcat-les-bests-practices-part-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Pourquoi tester les résultats de chaque requête dans un script de test de charge ?</title>
		<link>http://blog.aliecom.com/pourquoi-il-faut-tester-les-resultats-de-chaque-requete-dans-un-tir-de-charge/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=pourquoi-il-faut-tester-les-resultats-de-chaque-requete-dans-un-tir-de-charge</link>
		<comments>http://blog.aliecom.com/pourquoi-il-faut-tester-les-resultats-de-chaque-requete-dans-un-tir-de-charge/#comments</comments>
		<pubDate>Wed, 11 Jan 2012 08:00:13 +0000</pubDate>
		<dc:creator>Antonio Gomes-Rodrigues</dc:creator>
				<category><![CDATA[Tests de charge et performance]]></category>
		<category><![CDATA[scripting]]></category>
		<category><![CDATA[tests de charge]]></category>

		<guid isPermaLink="false">http://ded2.aliecom.com/dev/blogAliecom/?p=455</guid>
		<description><![CDATA[Il peut être tentant dans un script de test de charge de ne pas tester le résultat de chaque requête. Mais en faisant cela, on s'expose à de graves problèmes pouvant fausser les résultats. Car si le résultat de la requête n'est pas testé, on ne sait pas si elle s'exécute avec succès et donc [...]]]></description>
			<content:encoded><![CDATA[<p lang="fr-FR">Il peut être tentant dans un script de test de charge de ne pas tester le résultat de chaque requête. Mais en faisant cela, on s'expose à de graves problèmes pouvant fausser les résultats.</p>
<p lang="fr-FR">Car si le résultat de la requête n'est pas testé, on ne sait pas si elle s'exécute avec succès et donc le résultat final du tir de charge proposera des moyennes de valeurs complètement faussées.</p>
<p lang="fr-FR">Cela revient à additionner des patates avec des carottes et comme nous l'ont appris nos professeurs, cela n'a aucun sens.</p>
<p><span id="more-455"></span></p>
<p class="texte_bleu">Voici un exemple de script <strong>JMeter</strong> qui simule des visiteurs sur l'application <em>PlantsByWebSphere</em> livré avec <em>WebSphere</em>. (détaillé dans notre article précédent)</p>
<ul>
<li>
<p lang="fr-FR">La transaction<strong> Selection_item</strong> est défectueuse et à la place d'afficher l'item choisi, elle ré-affiche la liste d'item (la source du problème est une variable mal corrélée).</p>
</li>
</ul>
<p lang="fr-FR"><a href="http://blog.aliecom.com/wp-content/uploads/2011/10/pq_pb_test_resultats.jpg"><img class="size-full wp-image-403 aligncenter" title="pq_pb_test_resultats" src="http://blog.aliecom.com/wp-content/uploads/2011/10/pq_pb_test_resultats.jpg" alt="" width="292" height="300" /></a></p>
<p>&nbsp;</p>
<ul>
<li>
<p lang="fr-FR">Exécutons le script.</p>
<p lang="fr-FR"><a href="http://blog.aliecom.com/wp-content/uploads/2011/10/pq_pb_test_resultats_pb.jpg"><img class="size-medium wp-image-406 aligncenter" title="pq_pb_test_resultats_pb" src="http://blog.aliecom.com/wp-content/uploads/2011/10/pq_pb_test_resultats_pb-300x25.jpg" alt="" width="300" height="25" /></a></p>
<p lang="fr-FR">Comme on peut le voir, aucune erreur n'est détectée. Ce qui est normal car le serveur envoie une réponse valide (<em>HTTP 200</em>) malgré le fait que le résultat attendu ne soit pas le bon. Donc on se retrouve avec des résultats qui ne veulent rien dire.</p>
</li>
</ul>
<p>&nbsp;</p>
<ul>
<li>
<p lang="fr-FR">Maintenant ajoutons un test au résultat de la requête.</p>
<p lang="fr-FR"><a href="http://blog.aliecom.com/wp-content/uploads/2011/10/pq_pb_test_resultats_assertion.jpg"><img class="size-medium wp-image-404 aligncenter" title="pq_pb_test_resultats_assertion" src="http://blog.aliecom.com/wp-content/uploads/2011/10/pq_pb_test_resultats_assertion-300x95.jpg" alt="" width="300" height="95" /></a></p>
<p>&nbsp;</li>
</ul>
<ul>
<li>
<p lang="fr-FR">Rejouons le script.</p>
<p lang="fr-FR"><a href="http://blog.aliecom.com/wp-content/uploads/2011/10/pq_pb_test_resultats_pb_visible.jpg"><img class="size-medium wp-image-408 aligncenter" title="pq_pb_test_resultats_pb_visible" src="http://blog.aliecom.com/wp-content/uploads/2011/10/pq_pb_test_resultats_pb_visible-300x24.jpg" alt="" width="300" height="24" /></a></p>
<p class="info">On voit bien que toutes les transactions Selection_item échouent.</p>
</li>
</ul>
<p>&nbsp;</p>
<ul>
<li>
<p lang="fr-FR">Corrigeons le problème et rejouons le test.</p>
<p lang="fr-FR"><a href="http://blog.aliecom.com/wp-content/uploads/2011/10/pq_pb_test_resultats_pb_corrige.jpg"><img class="size-medium wp-image-407 aligncenter" title="pq_pb_test_resultats_pb_corrige" src="http://blog.aliecom.com/wp-content/uploads/2011/10/pq_pb_test_resultats_pb_corrige-300x24.jpg" alt="" width="300" height="24" /></a></p>
<p class="info">Comme on peut le voir, il n'y a plus d'erreur, et les résultats deviennent pertinents.</p>
</li>
</ul>
<p>&nbsp;</p>
<p class="tip">Mon conseil est « de bien tester les retours des transactions afin de ne pas avoir de mauvaise surprise ».</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.aliecom.com/pourquoi-il-faut-tester-les-resultats-de-chaque-requete-dans-un-tir-de-charge/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Nouveaux locaux</title>
		<link>http://blog.aliecom.com/nouveaux-locaux/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=nouveaux-locaux</link>
		<comments>http://blog.aliecom.com/nouveaux-locaux/#comments</comments>
		<pubDate>Fri, 06 Jan 2012 14:04:56 +0000</pubDate>
		<dc:creator>Éric Phélippeau</dc:creator>
				<category><![CDATA[Actualité - Evènements]]></category>

		<guid isPermaLink="false">http://blog.aliecom.com/?p=1252</guid>
		<description><![CDATA[Pour faire face à sa croissance et en vue de ses prévisions de recrutements en 2012 Aliecom a emménagé le 6 janvier 2012 dans de nouveaux locaux plus spacieux à Paris : ALIECOM 75 B rue des Plantes 75014 PARIS Nos coordonnées téléphoniques et fax restent inchangées : Tél. &#160; : +33 (0)1 45 22 [...]]]></description>
			<content:encoded><![CDATA[<p>Pour faire face à sa croissance et en vue de ses prévisions de recrutements en 2012 Aliecom a emménagé le 6 janvier 2012 dans de nouveaux locaux plus spacieux à Paris :</p>
<p>ALIECOM<br />
75 B rue des Plantes<br />
75014 PARIS</p>
<p></p>
<p>Nos coordonnées téléphoniques et fax restent inchangées :</p>
<p>Tél. &nbsp; : +33 (0)1 45 22 72 55<br />
Fax &nbsp; : +33 (0)1 78 41 67 53</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.aliecom.com/nouveaux-locaux/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

