mirror of
https://github.com/Febbweiss/log-generator.git
synced 2026-03-05 06:35:45 +00:00
Use id as seed value
This commit is contained in:
@@ -14,6 +14,6 @@ public class SearchRequest implements Runnable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
log.info("{} - {}", id, Utils.getRandomSearch());
|
log.info("{}", Utils.getRandomSearch(id));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,6 @@ public class SellRequest implements Runnable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
log.info("{} - {}", id, Utils.getRandomSell());
|
log.info("{}", Utils.getRandomSell(id));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,61 +50,67 @@ public class Utils {
|
|||||||
return min + new Random().nextInt(max - min) + 0.99;
|
return min + new Random().nextInt(max - min) + 0.99;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getRandomSearch() {
|
public static String getRandomClient(long id) {
|
||||||
return getRandomIP() + LOG_SEPARATOR + getRandomSearch(new Random().nextInt(10));
|
String sex = "M";
|
||||||
|
if (id % 3 == 0) sex = "F";
|
||||||
|
return new StringBuilder()
|
||||||
|
.append("client").append((id%1000)+1).append("@gmail.com")
|
||||||
|
.append(LOG_SEPARATOR)
|
||||||
|
.append(sex)
|
||||||
|
.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String getRandomSearch(int seed) {
|
public static String getRandomSell(long id) {
|
||||||
|
return new StringBuilder()
|
||||||
|
.append(id)
|
||||||
|
.append(LOG_SEPARATOR)
|
||||||
|
.append(getRandomIP())
|
||||||
|
.append(LOG_SEPARATOR)
|
||||||
|
.append(getRandomClient(id))
|
||||||
|
.append(LOG_SEPARATOR)
|
||||||
|
.append(getRandomFromList(products))
|
||||||
|
.toString();
|
||||||
|
}
|
||||||
|
|
||||||
StringBuilder sb = new StringBuilder();
|
public static String getRandomSearch(long id) {
|
||||||
|
StringBuilder sb = new StringBuilder()
|
||||||
|
.append(id)
|
||||||
|
.append(LOG_SEPARATOR)
|
||||||
|
.append(getRandomIP())
|
||||||
|
.append(LOG_SEPARATOR)
|
||||||
|
.append(getRandomFromArray(categories.values()));
|
||||||
|
|
||||||
sb.append(LOG_SEPARATOR);
|
sb.append(LOG_SEPARATOR);
|
||||||
sb.append(getRandomFromArray(categories.values()));
|
if (id % 4 == 0) {
|
||||||
|
|
||||||
sb.append(LOG_SEPARATOR);
|
|
||||||
if (seed > 7) {
|
|
||||||
sb.append(getRandomFromArray(matierials.values()));
|
sb.append(getRandomFromArray(matierials.values()));
|
||||||
}
|
}
|
||||||
|
|
||||||
sb.append(LOG_SEPARATOR);
|
sb.append(LOG_SEPARATOR);
|
||||||
if (seed > 4) {
|
if (id % 3 == 0) {
|
||||||
sb.append(getRandomFromArray(colors.values()));
|
sb.append(getRandomFromArray(colors.values()));
|
||||||
}
|
}
|
||||||
|
|
||||||
sb.append(LOG_SEPARATOR);
|
sb.append(LOG_SEPARATOR);
|
||||||
if (seed > 3) {
|
if (id % 2 == 0) {
|
||||||
sb.append(getRandomFromArray(sizes.values()));
|
sb.append(getRandomFromArray(sizes.values()));
|
||||||
}
|
}
|
||||||
|
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getRandomClient() {
|
|
||||||
int rnd = new Random().nextInt(500);
|
|
||||||
String sex = "M";
|
|
||||||
if(rnd > 300) sex = "F";
|
|
||||||
StringBuffer sb = new StringBuffer();
|
|
||||||
sb.append("client").append(rnd).append("@gmail.com")
|
|
||||||
.append(LOG_SEPARATOR)
|
|
||||||
.append(sex);
|
|
||||||
return sb.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getRandomSell() {
|
|
||||||
return new StringBuffer()
|
|
||||||
.append(getRandomIP())
|
|
||||||
.append(LOG_SEPARATOR)
|
|
||||||
.append(getRandomClient())
|
|
||||||
.append(LOG_SEPARATOR)
|
|
||||||
.append(getRandomFromList(products))
|
|
||||||
.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void initProducts(int n) {
|
private static void initProducts(int n) {
|
||||||
for (int i = 0; i < n; i++) {
|
for (int i = 0; i < n; i++) {
|
||||||
StringBuffer sb = new StringBuffer()
|
StringBuilder sb = new StringBuilder()
|
||||||
.append("ref:"+ (i + 1))
|
.append("ref:" + (i + 1))
|
||||||
.append(getRandomSearch(100)).append(LOG_SEPARATOR)
|
.append(LOG_SEPARATOR)
|
||||||
|
.append(getRandomFromArray(categories.values()))
|
||||||
|
.append(LOG_SEPARATOR)
|
||||||
|
.append(getRandomFromArray(matierials.values()))
|
||||||
|
.append(LOG_SEPARATOR)
|
||||||
|
.append(getRandomFromArray(colors.values()))
|
||||||
|
.append(LOG_SEPARATOR)
|
||||||
|
.append(getRandomFromArray(sizes.values()))
|
||||||
|
.append(LOG_SEPARATOR)
|
||||||
.append(getRandomPrice());
|
.append(getRandomPrice());
|
||||||
products.add(sb.toString());
|
products.add(sb.toString());
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user