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; package theodolite.commons.workloadgeneration;
/**
* Configuration of a load generator cluster.
*/
public class ClusterConfig { public class ClusterConfig {
public static final String BOOTSTRAP_SERVER_DEFAULT = "localhost:5701"; public static final String BOOTSTRAP_SERVER_DEFAULT = "localhost:5701";
public static final int PORT_DEFAULT = 5701; public static final int PORT_DEFAULT = 5701;
...@@ -11,6 +14,9 @@ public class ClusterConfig { ...@@ -11,6 +14,9 @@ public class ClusterConfig {
private final boolean portAutoIncrement; private final boolean portAutoIncrement;
private final String clusterNamePrefix; private final String clusterNamePrefix;
/**
* Create a new {@link ClusterConfig} with its default values.
*/
public ClusterConfig() { public ClusterConfig() {
this( this(
BOOTSTRAP_SERVER_DEFAULT, BOOTSTRAP_SERVER_DEFAULT,
...@@ -19,6 +25,9 @@ public class ClusterConfig { ...@@ -19,6 +25,9 @@ public class ClusterConfig {
CLUSTER_NAME_PREFIX_DEFAULT); CLUSTER_NAME_PREFIX_DEFAULT);
} }
/**
* Create a new {@link ClusterConfig} with the given parameter values.
*/
public ClusterConfig(final String bootstrapServer, final int port, public ClusterConfig(final String bootstrapServer, final int port,
final boolean portAutoIncrement, final String clusterNamePrefix) { final boolean portAutoIncrement, final String clusterNamePrefix) {
this.bootstrapServer = bootstrapServer; this.bootstrapServer = bootstrapServer;
......
...@@ -4,11 +4,9 @@ import java.io.Serializable; ...@@ -4,11 +4,9 @@ import java.io.Serializable;
import java.util.Collection; import java.util.Collection;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.IntStream; 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 * A set of keys, where each key consists of a prefix and a number.
* {@link AbstractWorkloadGenerator}.
*/ */
public class KeySpace implements Serializable { public class KeySpace implements Serializable {
...@@ -20,7 +18,7 @@ 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 * 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 prefix the prefix to use for all keys
* @param min the lower bound (inclusive) to start counting from * @param min the lower bound (inclusive) to start counting from
...@@ -50,10 +48,16 @@ public class KeySpace implements Serializable { ...@@ -50,10 +48,16 @@ public class KeySpace implements Serializable {
return this.max; return this.max;
} }
/**
* Get the amount of keys in this {@link KeySpace}.
*/
public int getCount() { public int getCount() {
return this.getMax() - this.getMin() + 1; return this.getMax() - this.getMin() + 1;
} }
/**
* Get all keys in this {@link KeySpace}.
*/
public Collection<String> getKeys() { public Collection<String> getKeys() {
return IntStream.rangeClosed(this.min, this.max) return IntStream.rangeClosed(this.min, this.max)
.mapToObj(id -> this.prefix + id) .mapToObj(id -> this.prefix + id)
......
...@@ -6,6 +6,10 @@ import java.util.Set; ...@@ -6,6 +6,10 @@ import java.util.Set;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.IntStream; 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 { public class WorkloadDefinition implements Serializable {
private static final long serialVersionUID = -8337364281221817001L; // NOPMD private static final long serialVersionUID = -8337364281221817001L; // NOPMD
...@@ -33,6 +37,10 @@ public class WorkloadDefinition implements Serializable { ...@@ -33,6 +37,10 @@ public class WorkloadDefinition implements Serializable {
return this.period; 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) { public Set<WorkloadDefinition> divide(final int parts) {
final int effParts = Math.min(parts, this.keySpace.getCount()); final int effParts = Math.min(parts, this.keySpace.getCount());
final int minSize = this.keySpace.getCount() / effParts; 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