Skip to content
Snippets Groups Projects
Commit 48b31811 authored by Sören Henning's avatar Sören Henning
Browse files

Add some JavaDoc

parent 6536c2d7
No related branches found
No related tags found
No related merge requests found
package theodolite.commons.workloadgeneration;
/**
* Configuration of a load generator cluster.
*/
public class ClusterConfig {
public static final String BOOTSTRAP_SERVER_DEFAULT = "localhost:5701";
public static final int PORT_DEFAULT = 5701;
......@@ -11,6 +14,9 @@ public class ClusterConfig {
private final boolean portAutoIncrement;
private final String clusterNamePrefix;
/**
* Create a new {@link ClusterConfig} with its default values.
*/
public ClusterConfig() {
this(
BOOTSTRAP_SERVER_DEFAULT,
......@@ -19,6 +25,9 @@ public class ClusterConfig {
CLUSTER_NAME_PREFIX_DEFAULT);
}
/**
* Create a new {@link ClusterConfig} with the given parameter values.
*/
public ClusterConfig(final String bootstrapServer, final int port,
final boolean portAutoIncrement, final String clusterNamePrefix) {
this.bootstrapServer = bootstrapServer;
......
......@@ -4,11 +4,9 @@ import java.io.Serializable;
import java.util.Collection;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import theodolite.commons.workloadgeneration.generators.AbstractWorkloadGenerator;
/**
* Wrapper class for the definition of the Keys that should be used by the
* {@link AbstractWorkloadGenerator}.
* A set of keys, where each key consists of a prefix and a number.
*/
public class KeySpace implements Serializable {
......@@ -20,7 +18,7 @@ public class KeySpace implements Serializable {
/**
* Create a new key space. All keys will have the prefix {@code prefix}. The remaining part of
* each key will be determined by a number of the interval ({@code min}, {@code max}-1).
* each key will be determined by a number of the interval ({@code min}, {@code max}).
*
* @param prefix the prefix to use for all keys
* @param min the lower bound (inclusive) to start counting from
......@@ -50,10 +48,16 @@ public class KeySpace implements Serializable {
return this.max;
}
/**
* Get the amount of keys in this {@link KeySpace}.
*/
public int getCount() {
return this.getMax() - this.getMin() + 1;
}
/**
* Get all keys in this {@link KeySpace}.
*/
public Collection<String> getKeys() {
return IntStream.rangeClosed(this.min, this.max)
.mapToObj(id -> this.prefix + id)
......
......@@ -6,6 +6,10 @@ import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
/**
* Definition of a workload consisting of a {@link KeySpace} and a period with which messages will
* be generated for key of that {@link KeySpace}.
*/
public class WorkloadDefinition implements Serializable {
private static final long serialVersionUID = -8337364281221817001L; // NOPMD
......@@ -33,6 +37,10 @@ public class WorkloadDefinition implements Serializable {
return this.period;
}
/**
* Divide this {@link WorkloadDefinition} into {@code parts} {@link WorkloadDefinition}s by
* distributing its {@link KeySpace} (almost) equally among all {@link WorkloadDefinition}s.
*/
public Set<WorkloadDefinition> divide(final int parts) {
final int effParts = Math.min(parts, this.keySpace.getCount());
final int minSize = this.keySpace.getCount() / effParts;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment