forked from apache/cassandra
-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add coordinator MEMORY_BYTES sensor for reads #1452
Draft
aymkhalil
wants to merge
8
commits into
cndb-8501
Choose a base branch
from
cndb-11544
base: cndb-8501
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 2 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
ff97dec
CNDB-11544 Add coordinator MEMORY_BYTES sensor for reads
aymkhalil e65faa9
Add coordinator INTERNODE_BYTES sensor for reads
aymkhalil 4123198
Sync sensors on finally blocks
aymkhalil 050ea94
Revert "Add coordinator INTERNODE_BYTES sensor for reads"
aymkhalil 9f345e8
Add dtest for read
aymkhalil bc05df7
MEMORY_BYTES -> IN_MEMORY_BYTES
aymkhalil c56d960
Fix testSensorsTrackedForReadCallback by creating concrete DataResponse
aymkhalil cfc8278
Fix NPE when calling message#serializedSize
aymkhalil File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,5 +28,6 @@ public enum Type | |
READ_BYTES, | ||
|
||
WRITE_BYTES, | ||
INDEX_WRITE_BYTES | ||
INDEX_WRITE_BYTES, | ||
MEMORY_BYTES | ||
} |
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
81 changes: 81 additions & 0 deletions
81
test/unit/org/apache/cassandra/sensors/CoordinatorSensorsTest.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,81 @@ | ||
/* | ||
* 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.sensors; | ||
|
||
import java.util.Optional; | ||
|
||
import org.junit.BeforeClass; | ||
import org.junit.Test; | ||
|
||
import org.apache.cassandra.config.CassandraRelevantProperties; | ||
import org.apache.cassandra.cql3.CQLTester; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
public class CoordinatorSensorsTest extends CQLTester | ||
{ | ||
@BeforeClass | ||
public static void setupClass() | ||
{ | ||
CassandraRelevantProperties.SENSORS_FACTORY.setString(ActiveSensorsFactory.class.getName()); | ||
// a workaround to force sensors registry to initialize (i.e. subscribe to SchemaChangeListener) before the | ||
// test creates the keyspace and tables | ||
SensorsRegistry.instance.clear(); | ||
} | ||
|
||
@Test | ||
public void testReadSensors() | ||
{ | ||
createTable("create table %s (pk int, ck int, v text, primary key(pk, ck))"); | ||
Context context = Context.from(currentTableMetadata()); | ||
Optional<Sensor> memorySensor = SensorsRegistry.instance.getSensor(context, Type.MEMORY_BYTES); | ||
assertThat(memorySensor).isEmpty(); | ||
|
||
executeNet("insert into %s (pk, ck, v) values (1, 1, 'v1')"); | ||
executeNet("select * from %s where pk = 1"); | ||
memorySensor = SensorsRegistry.instance.getSensor(context, Type.MEMORY_BYTES); | ||
assertThat(memorySensor).isPresent(); | ||
double memoryBytes = memorySensor.get().getValue(); | ||
assertThat(memoryBytes).isGreaterThan(0); | ||
|
||
executeNet("select * from %s where pk = 1"); | ||
assertThat(memorySensor.get().getValue()).isEqualTo(memoryBytes * 2); | ||
} | ||
|
||
@Test | ||
public void testRangeReadSensors() | ||
{ | ||
createTable("create table %s (pk int, ck int, v text, primary key(pk, ck))"); | ||
Context context = Context.from(currentTableMetadata()); | ||
Optional<Sensor> memorySensor = SensorsRegistry.instance.getSensor(context, Type.MEMORY_BYTES); | ||
assertThat(memorySensor).isEmpty(); | ||
|
||
executeNet("insert into %s (pk, ck, v) values (1, 1, 'v1')"); | ||
executeNet("insert into %s (pk, ck, v) values (1, 2, 'v2')"); | ||
executeNet("insert into %s (pk, ck, v) values (1, 3, 'v3')"); | ||
executeNet("select * from %s"); | ||
memorySensor = SensorsRegistry.instance.getSensor(context, Type.MEMORY_BYTES); | ||
assertThat(memorySensor).isPresent(); | ||
double memoryBytes = memorySensor.get().getValue(); | ||
assertThat(memoryBytes).isGreaterThan(0); | ||
|
||
executeNet("select * from %s"); | ||
assertThat(memorySensor.get().getValue()).isEqualTo(memoryBytes * 2); | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For testing internode message (and memory bytes from received internode message) our best shot would be dtests. Will move there once cndb-8501 is merged as it will could reuse/refactor some of the stuff. Other non-CNDB test ideas are welcome
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
update: internode is out of scope for now. I added an initial dtest anyway to exercise the code paths on the callback from replicas