Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,9 @@ public class Workload {
public int messageSize;

/**
* Message size distribution for variable-sized payloads.
* Keys are size ranges (e.g., "0-256", "256-1024", "1KB-4KB"),
* values are relative weights.
* Mutually exclusive with messageSize - if set, messageSize is ignored.
* Message size distribution for variable-sized payloads. Keys are size ranges (e.g., "0-256",
* "256-1024", "1KB-4KB"), values are relative weights. Mutually exclusive with messageSize - if
* set, messageSize is ignored.
*/
public Map<String, Integer> messageSizeDistribution;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,17 @@
*/
package io.openmessaging.benchmark.utils.payload;


import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
* Parses and represents a message size distribution from workload config.
* Creates one payload size per bucket and provides weights for runtime selection.
* Parses and represents a message size distribution from workload config. Creates one payload size
* per bucket and provides weights for runtime selection.
*
* <p>Example configuration:
*
* <pre>
* messageSizeDistribution:
* "0-256": 234
Expand All @@ -34,9 +36,7 @@ public class MessageSizeDistribution {
private final List<Bucket> buckets;
private final int totalWeight;

/**
* Represents a single size bucket with min/max range and weight.
*/
/** Represents a single size bucket with min/max range and weight. */
public static class Bucket {
public final int minSize;
public final int maxSize;
Expand Down Expand Up @@ -147,8 +147,8 @@ public List<Integer> getBucketSizes() {
}

/**
* Returns list of max sizes, one per bucket (for payload generation).
* Using max sizes ensures the system is tested with the largest messages in each bucket range.
* Returns list of max sizes, one per bucket (for payload generation). Using max sizes ensures the
* system is tested with the largest messages in each bucket range.
*
* @return list of max sizes per bucket
*/
Expand Down Expand Up @@ -212,9 +212,4 @@ public int getAvgSize() {
public int getBucketCount() {
return buckets.size();
}

public List<Bucket> getBuckets() {
return buckets;
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -240,9 +240,7 @@ private void submitProducersToExecutor(
idx = r.nextInt(payloadCount);
}
messageProducer.sendMessage(
p,
Optional.ofNullable(keyDistributor.next()),
payloads.get(idx));
p, Optional.ofNullable(keyDistributor.next()), payloads.get(idx));
});
}
} catch (Throwable t) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ public class ProducerWorkAssignment {
public List<byte[]> payloadData;

/**
* Weights for weighted payload selection. If null, uniform random selection is used.
* Each weight corresponds to the payload at the same index in payloadData.
* Used for message size distribution feature.
* Weights for weighted payload selection. If null, uniform random selection is used. Each weight
* corresponds to the payload at the same index in payloadData. Used for message size distribution
* feature.
*/
public int[] payloadWeights;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,4 +219,3 @@ void weightedSelectionProducesCorrectDistribution() {
assertThat(ratio1).isBetween(0.49, 0.51);
}
}