Feature: add exception generation

This commit is contained in:
ECAILLE Fabrice (externe)
2017-05-23 11:47:53 +02:00
parent 69e08ee702
commit 279da8270d
3 changed files with 21 additions and 4 deletions

View File

@@ -8,7 +8,7 @@
<!-- Maven Metadatas --> <!-- Maven Metadatas -->
<groupId>com.github.vspiewak</groupId> <groupId>com.github.vspiewak</groupId>
<artifactId>log-generator</artifactId> <artifactId>log-generator</artifactId>
<version>0.0.1-SNAPSHOT</version> <version>0.0.2-SNAPSHOT</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<!-- Project Metadatas --> <!-- Project Metadatas -->

View File

@@ -52,9 +52,11 @@ public class App {
while (counter.get() < params.logs) { while (counter.get() < params.logs) {
total.incrementAndGet(); total.incrementAndGet();
counter.incrementAndGet(); counter.incrementAndGet();
int seed = new Random().nextInt(10); int seed = new Random().nextInt(100);
if (seed > 7) { if (seed > 95) {
executor.add(new SellRequest(total.get())); executor.add(new ExceptionRequest());
} else if (seed > 60) {
executor.add(new SellRequest(total.get()));
} else { } else {
executor.add(new SearchRequest(total.get())); executor.add(new SearchRequest(total.get()));
} }

View File

@@ -0,0 +1,15 @@
package com.github.vspiewak.loggenerator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class ExceptionRequest implements Runnable {
private static final Logger log = LoggerFactory.getLogger(ExceptionRequest.class);
@Override
public void run() {
log.error("Unexpected error", new RuntimeException());
}
}