Skip to content

Commit

Permalink
Correct bit rate units
Browse files Browse the repository at this point in the history
  • Loading branch information
ekaterinadimitrova2 committed Jul 21, 2020
1 parent 9f67fa6 commit b4eebe0
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 26 deletions.
12 changes: 6 additions & 6 deletions conf/cassandra.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ windows_timer_interval: 1
# 16 to 32 times the rate you are inserting data is more than sufficient.
# Setting this to 0 disables throttling. Note that this account for all types
# of compaction, including validation compaction.
compaction_throughput: 16mbps
compaction_throughput: 16MiB/s

# Log a warning when compacting partitions larger than this value
compaction_large_partition_warning_threshold: 100mb
Expand Down Expand Up @@ -630,18 +630,18 @@ index_summary_resize_interval: 60m
# Streaming settings #
######################
# Throttles all outbound streaming file transfers on this node to the
# given total throughput in Mbps. This is necessary because Cassandra does
# given total throughput in MiB/s. This is necessary because Cassandra does
# mostly sequential IO when streaming data during bootstrap or repair, which
# can lead to saturating the network connection and degrading rpc performance.
# When unset, the default is 200 Mbps or 25 MB/s.
# stream_throughput_outbound: 200mbps
# When unset, the default is 200 MiB/s or 25 MB/s.
# stream_throughput_outbound: 200MiB/s

# Throttles all streaming file transfer between the datacenters,
# this setting allows users to throttle inter dc stream throughput in addition
# to throttling all network stream traffic as configured with
# stream_throughput_outbound
# When unset, the default is 200 Mbps or 25 MB/s
# inter_dc_stream_throughput_outbound: 200mbps
# When unset, the default is 200 MiB/s or 25 MB/s
# inter_dc_stream_throughput_outbound: 200MiB/s

# Set keep-alive period for streaming
# This node will send a keep-alive message periodically with this period.
Expand Down
8 changes: 4 additions & 4 deletions src/java/org/apache/cassandra/config/BitRate.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public final class BitRate
/**
* The Regexp used to parse the rate provided as String.
*/
private static final Pattern BIT_RATE_UNITS_PATTERN = Pattern.compile("^(\\d+)(bps|mbps|kbps|Kbps|Mbps)$");
private static final Pattern BIT_RATE_UNITS_PATTERN = Pattern.compile("^(\\d+)(MiB/s|KiB/s|B/s)$");

private final long quantity;

Expand Down Expand Up @@ -194,7 +194,7 @@ public String toString()

public enum BitRateUnit
{
BITS_PER_SECOND("bps")
BITS_PER_SECOND("b/s")
{
public long toBitsPerSecond(long d)
{
Expand All @@ -216,7 +216,7 @@ public long convert(long source, BitRateUnit sourceUnit)
return sourceUnit.toBitsPerSecond(source);
}
},
KILOBITS_PER_SECOND("kbps")
KILOBITS_PER_SECOND("kib/s")
{
public long toBitsPerSecond(long d)
{
Expand All @@ -238,7 +238,7 @@ public long convert(long source, BitRateUnit sourceUnit)
return sourceUnit.toKilobitsPerSecond(source);
}
},
MEGABITS_PER_SECOND("mbps")
MEGABITS_PER_SECOND("mib/s")
{
public long toBitsPerSecond(long d)
{
Expand Down
6 changes: 3 additions & 3 deletions src/java/org/apache/cassandra/config/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -241,17 +241,17 @@ public class Config
public volatile Integer concurrent_compactors;

@Replaces(oldName = "compaction_throughput_mb_per_sec", converter = Converter.MegabitsPerSecondBitRateConverter.class, deprecated = true)
public volatile BitRate compaction_throughput = new BitRate("16Mbps");
public volatile BitRate compaction_throughput = new BitRate("16MiB/s");
@Replaces(oldName = "compaction_large_partition_warning_threshold_mb", converter = Converter.MegabytesDataStorageConverter.class, deprecated = true)
public DataStorage compaction_large_partition_warning_threshold = new DataStorage("100MB");
public DataStorage min_free_space_per_drive = new DataStorage("50MB");

public volatile int concurrent_materialized_view_builders = 1;

@Replaces(oldName = "stream_throughput_outbound_megabits_per_sec", converter = Converter.MegabitsPerSecondBitRateConverter.class, deprecated = true)
public volatile BitRate stream_throughput_outbound = new BitRate("200Mbps");
public volatile BitRate stream_throughput_outbound = new BitRate("200MiB/s");
@Replaces(oldName = "inter_dc_stream_throughput_outbound_megabits_per_sec", converter = Converter.MegabitsPerSecondBitRateConverter.class, deprecated = true)
public volatile BitRate inter_dc_stream_throughput_outbound = new BitRate("200Mbps");
public volatile BitRate inter_dc_stream_throughput_outbound = new BitRate("200MiB/s");

public String[] data_file_directories = new String[0];

Expand Down
26 changes: 13 additions & 13 deletions test/unit/org/apache/cassandra/config/BitRateTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,33 +27,33 @@ public class BitRateTest
@Test
public void testConversions()
{
assertEquals(10, new BitRate("10bps").toBitsPerSecond());
assertEquals(10000, new BitRate("10Kbps").toBitsPerSecond());
assertEquals(0, new BitRate("10Kbps").toMegabitsPerSecond());
assertEquals(10000, new BitRate("10Mbps").toKilobitsPerSecond());
assertEquals(10000000, new BitRate("10Mbps").toBitsPerSecond());
assertEquals(10, new BitRate("10B/s").toBitsPerSecond());
assertEquals(10000, new BitRate("10KiB/s").toBitsPerSecond());
assertEquals(0, new BitRate("10KiB/s").toMegabitsPerSecond());
assertEquals(10000, new BitRate("10MiB/s").toKilobitsPerSecond());
assertEquals(10000000, new BitRate("10MiB/s").toBitsPerSecond());
}

@Test
public void testInvalidInputs()
{
assertThatThrownBy(() -> new BitRate("10")).isInstanceOf(IllegalArgumentException.class)
.hasMessageContaining("Invalid bit rate: 10");
assertThatThrownBy(() -> new BitRate("-10bps")).isInstanceOf(IllegalArgumentException.class)
.hasMessageContaining("Invalid bit rate: -10bps");
assertThatThrownBy(() -> new BitRate("10xbps")).isInstanceOf(IllegalArgumentException.class)
.hasMessageContaining("Unsupported bit rate unit: xbps. Supported units are: bps, kbps, mbps");
assertThatThrownBy(() -> new BitRate("-10b/s")).isInstanceOf(IllegalArgumentException.class)
.hasMessageContaining("Invalid bit rate: -10b/s");
assertThatThrownBy(() -> new BitRate("10xb/s")).isInstanceOf(IllegalArgumentException.class)
.hasMessageContaining("Invalid bit rate: 10xb/s");
}

@Test
public void testEquals()
{
assertEquals(new BitRate("10bps"), new BitRate("10bps"));
assertEquals(new BitRate("10kbps"), new BitRate("10000bps"));
assertEquals(new BitRate("10000bps"), new BitRate("10kbps"));
assertEquals(new BitRate("10b/s"), new BitRate("10b/s"));
assertEquals(new BitRate("10kib/s"), new BitRate("10000b/s"));
assertEquals(new BitRate("10000b/s"), new BitRate("10kib/s"));
assertEquals(BitRate.inMegabitsPerSecond(Long.MAX_VALUE), BitRate.inMegabitsPerSecond(Long.MAX_VALUE));
assertNotEquals(BitRate.inMegabitsPerSecond(Long.MAX_VALUE), BitRate.inBitsPerSeconds(Long.MAX_VALUE));
assertNotEquals(new BitRate("0kbps"), new BitRate("10mbps"));
assertNotEquals(new BitRate("0kib/s"), new BitRate("10mib/s"));
}

}

0 comments on commit b4eebe0

Please sign in to comment.