Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow column_index_size_in_kb to be configurable through nodetool
patch by Francisco Guerrero; reviewed by Dinesh Joshi, Yifan Cai for CASSANDRA-17121
- Loading branch information
Showing
10 changed files
with
212 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
src/java/org/apache/cassandra/tools/nodetool/GetColumnIndexSize.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.cassandra.tools.nodetool; | ||
|
||
import io.airlift.airline.Command; | ||
import org.apache.cassandra.tools.NodeProbe; | ||
import org.apache.cassandra.tools.NodeTool.NodeToolCmd; | ||
|
||
@Command(name = "getcolumnindexsize", description = "Print the granularity of the collation index of rows within a partition in KiB") | ||
public class GetColumnIndexSize extends NodeToolCmd | ||
{ | ||
@Override | ||
protected void execute(NodeProbe probe) | ||
{ | ||
probe.output().out.println("Current value for column_index_size_in_kb: " + probe.getColumnIndexSizeInKB() + " KiB"); | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
src/java/org/apache/cassandra/tools/nodetool/SetColumnIndexSize.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.cassandra.tools.nodetool; | ||
|
||
import io.airlift.airline.Arguments; | ||
import io.airlift.airline.Command; | ||
import org.apache.cassandra.tools.NodeProbe; | ||
import org.apache.cassandra.tools.NodeTool.NodeToolCmd; | ||
|
||
@Command(name = "setcolumnindexsize", description = "Set the granularity of the collation index of rows within a partition in KiB") | ||
public class SetColumnIndexSize extends NodeToolCmd | ||
{ | ||
@SuppressWarnings("UnusedDeclaration") | ||
@Arguments(title = "column_index_size_in_kb", usage = "<value_in_kib>", description = "Value in KiB", required = true) | ||
private int columnIndexSizeInKB; | ||
|
||
@Override | ||
protected void execute(NodeProbe probe) | ||
{ | ||
probe.setColumnIndexSize(columnIndexSizeInKB); | ||
} | ||
} |
110 changes: 110 additions & 0 deletions
110
test/unit/org/apache/cassandra/tools/nodetool/SetGetColumnIndexSizeTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.cassandra.tools.nodetool; | ||
|
||
import org.junit.BeforeClass; | ||
import org.junit.Test; | ||
|
||
import org.apache.cassandra.cql3.CQLTester; | ||
import org.apache.cassandra.service.StorageService; | ||
|
||
import static org.apache.cassandra.tools.ToolRunner.ToolResult; | ||
import static org.apache.cassandra.tools.ToolRunner.invokeNodetool; | ||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
/** | ||
* Tests for {@code nodetool setcolumnindexsize} and {@code nodetool getcolumnindexsize}. | ||
*/ | ||
public class SetGetColumnIndexSizeTest extends CQLTester | ||
{ | ||
@BeforeClass | ||
public static void setup() throws Exception | ||
{ | ||
startJMXServer(); | ||
} | ||
|
||
@Test | ||
public void testNull() | ||
{ | ||
assertSetInvalidColumnIndexSize(null, "Required parameters are missing: column_index_size_in_kb", 1); | ||
} | ||
|
||
@Test | ||
public void testPositive() | ||
{ | ||
assertSetGetValidColumnIndexSize(7); | ||
} | ||
|
||
@Test | ||
public void testMaxValue() | ||
{ | ||
assertSetGetValidColumnIndexSize(2097151); | ||
} | ||
|
||
@Test | ||
public void testZero() | ||
{ | ||
assertSetGetValidColumnIndexSize(0); | ||
} | ||
|
||
@Test | ||
public void testNegative() | ||
{ | ||
assertSetInvalidColumnIndexSize("-7", "column_index_size_in_kb must be positive value < 2097152, but was -7", 2); | ||
} | ||
|
||
@Test | ||
public void testInvalidValue() | ||
{ | ||
assertSetInvalidColumnIndexSize("2097152", "column_index_size_in_kb must be positive value < 2097152, but was 2097152", 2); | ||
} | ||
|
||
@Test | ||
public void testUnparseable() | ||
{ | ||
assertSetInvalidColumnIndexSize("1.2", "column_index_size_in_kb: can not convert \"1.2\" to a int", 1); | ||
assertSetInvalidColumnIndexSize("value", "column_index_size_in_kb: can not convert \"value\" to a int", 1); | ||
} | ||
|
||
private static void assertSetGetValidColumnIndexSize(int columnIndexSizeInKB) | ||
{ | ||
ToolResult tool = invokeNodetool("setcolumnindexsize", String.valueOf(columnIndexSizeInKB)); | ||
tool.assertOnCleanExit(); | ||
assertThat(tool.getStdout()).isEmpty(); | ||
|
||
assertGetThroughput(columnIndexSizeInKB); | ||
|
||
assertThat(StorageService.instance.getColumnIndexSizeInKB()).isEqualTo(columnIndexSizeInKB); | ||
} | ||
|
||
private static void assertSetInvalidColumnIndexSize(String columnIndexSizeInKB, String expectedErrorMessage, int expectedErrorCode) | ||
{ | ||
ToolResult tool = columnIndexSizeInKB == null ? invokeNodetool("setcolumnindexsize") | ||
: invokeNodetool("setcolumnindexsize", columnIndexSizeInKB); | ||
assertThat(tool.getExitCode()).isEqualTo(expectedErrorCode); | ||
assertThat(expectedErrorCode == 1 ? tool.getStdout() : tool.getStderr()).contains(expectedErrorMessage); | ||
} | ||
|
||
private static void assertGetThroughput(int expected) | ||
{ | ||
ToolResult tool = invokeNodetool("getcolumnindexsize"); | ||
tool.assertOnCleanExit(); | ||
assertThat(tool.getStdout()).contains("Current value for column_index_size_in_kb: " + expected + " KiB"); | ||
} | ||
} |