Skip to content

Commit

Permalink
upgrade jolokia agent to 1.6.2 and drop remove_perf_disable_shared_me…
Browse files Browse the repository at this point in the history
…m workaround

jolokia/jolokia#198 has been fixed since jolokia 1.3.7,
so there is no reason to keep the remove_perf_disable_shared_mem workaround anymore.
It is assumed that the '-XX:-PerfDisableSharedMem' usage was added exclusively for
jolokia as well.

patch by Christopher Lambert; reviewed by Mick Semb Wever
  • Loading branch information
Christopher Lambert authored and Christopher Lambert committed Sep 24, 2020
1 parent d779e86 commit 114ccff
Show file tree
Hide file tree
Showing 21 changed files with 15 additions and 88 deletions.
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,6 @@ JAVA7_HOME and JAVA8_HOME, respectively.
Writing Tests
-------------

- If you're using JMX via [the `tools.jmxutils` module](tools/jmxutils.py), make sure to call `remove_perf_disable_shared_mem` on the node or nodes you want to query with JMX _before starting the nodes_. `remove_perf_disable_shared_mem` disables a JVM option that's incompatible with JMX (see [this JMX ticket](https://github.com/rhuss/jolokia/issues/198)). It works by performing a string replacement in the node's Cassandra startup script, so changes will only propagate to the node at startup time.

If you'd like to know what to expect during a code review, please see the included [CONTRIBUTING file](CONTRIBUTING.md).

Debugging Tests
Expand Down
4 changes: 1 addition & 3 deletions auth_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@
from tools.assertions import (assert_all, assert_exception, assert_invalid,
assert_length_equal, assert_one,
assert_unauthorized)
from tools.jmxutils import (JolokiaAgent, make_mbean,
remove_perf_disable_shared_mem)
from tools.jmxutils import (JolokiaAgent, make_mbean)
from tools.metadata_wrapper import UpdatingKeyspaceMetadataWrapper
from tools.misc import ImmutableMapping

Expand Down Expand Up @@ -1056,7 +1055,6 @@ def test_auth_metrics(self):
cluster.set_datadir_count(1)
cluster.populate(1)
[node] = cluster.nodelist()
remove_perf_disable_shared_mem(node)
cluster.start()

with JolokiaAgent(node) as jmx:
Expand Down
9 changes: 1 addition & 8 deletions batch_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
from dtest import Tester, create_ks
from tools.assertions import (assert_all, assert_invalid, assert_one,
assert_unavailable)
from tools.jmxutils import (JolokiaAgent, make_mbean,
remove_perf_disable_shared_mem)
from tools.jmxutils import (JolokiaAgent, make_mbean)

since = pytest.mark.since
logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -438,10 +437,6 @@ def prepare(self, nodes=1, compression=True, version=None, protocol_version=None
logger.debug("Set cassandra dir to {}".format(self.cluster.get_install_dir()))

self.cluster.populate(nodes, install_byteman=install_byteman)

for n in self.cluster.nodelist():
remove_perf_disable_shared_mem(n)

self.cluster.start()

node1 = self.cluster.nodelist()[0]
Expand Down Expand Up @@ -501,8 +496,6 @@ def upgrade_node(self, node):
node.stop(wait_other_notice=False)
self.set_node_to_current_version(node)
logger.debug("Set cassandra dir for {} to {}".format(node.name, node.get_install_dir()))
# needed for jmx
remove_perf_disable_shared_mem(node)
# Restart nodes on new version
logger.debug('Starting {} on new version ({})'.format(node.name, node.get_cassandra_version()))
node.start(wait_for_binary_proto=True, jvm_args=['-Dcassandra.disable_max_protocol_auto_override=true'])
7 changes: 1 addition & 6 deletions configuration_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
from tools.misc import ImmutableMapping
from dtest_setup_overrides import DTestSetupOverrides
from dtest import Tester, create_ks
from tools.jmxutils import (JolokiaAgent, make_mbean,
remove_perf_disable_shared_mem)
from tools.jmxutils import (JolokiaAgent, make_mbean)

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -72,9 +71,6 @@ def new_commitlog_cluster_node():
node = self.fixture_dtest_setup.cluster.nodelist()[0]
self.fixture_dtest_setup.cluster.set_batch_commitlog(enabled=True)

# disable JVM option so we can use Jolokia
# this has to happen after .set_configuration_options because of implementation details
remove_perf_disable_shared_mem(node)
self.fixture_dtest_setup.cluster.start()
return node

Expand Down Expand Up @@ -116,7 +112,6 @@ def overlapping_data_folders(self):
node1 = self.cluster.nodelist()[0]
default_path = node1.data_directories()[0]
node1.set_configuration_options({'saved_caches_directory': os.path.join(default_path, 'saved_caches')})
remove_perf_disable_shared_mem(node1)
self.cluster.start()

session = self.patient_exclusive_cql_connection(node1)
Expand Down
3 changes: 1 addition & 2 deletions consistency_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from dtest import MultiError, Tester, create_ks, create_cf
from tools.data import (create_c1c2_table, insert_c1c2, insert_columns,
query_c1c2, rows_to_list)
from tools.jmxutils import JolokiaAgent, make_mbean, remove_perf_disable_shared_mem
from tools.jmxutils import JolokiaAgent, make_mbean

since = pytest.mark.since
logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -1231,7 +1231,6 @@ def test_13595(self):

cluster.populate(2)
node1, node2 = cluster.nodelist()
remove_perf_disable_shared_mem(node1) # necessary for jmx
cluster.start()

session = self.patient_cql_connection(node1)
Expand Down
3 changes: 1 addition & 2 deletions cql_tracing_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from distutils.version import LooseVersion

from dtest import Tester, create_ks
from tools.jmxutils import make_mbean, JolokiaAgent, remove_perf_disable_shared_mem
from tools.jmxutils import make_mbean, JolokiaAgent

since = pytest.mark.since
logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -37,7 +37,6 @@ def prepare(self, create_keyspace=True, nodes=3, rf=3, protocol_version=3, jvm_a

cluster.populate(nodes)
node1 = cluster.nodelist()[0]
remove_perf_disable_shared_mem(node1) # necessary for jmx
cluster.start(jvm_args=jvm_args)

session = self.patient_cql_connection(node1, protocol_version=protocol_version)
Expand Down
7 changes: 1 addition & 6 deletions deletion_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@

from dtest import Tester, create_ks, create_cf
from tools.data import rows_to_list
from tools.jmxutils import (JolokiaAgent, make_mbean,
remove_perf_disable_shared_mem)
from tools.jmxutils import (JolokiaAgent, make_mbean)

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -47,10 +46,6 @@ def test_gc(self):

def test_tombstone_size(self):
self.cluster.populate(1)
node1 = self.cluster.nodelist()[0]

remove_perf_disable_shared_mem(node1)

self.cluster.start()
[node1] = self.cluster.nodelist()
session = self.patient_cql_connection(node1)
Expand Down
4 changes: 1 addition & 3 deletions disk_balance_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
from dtest import Tester, create_ks
from tools.assertions import assert_almost_equal
from tools.data import create_c1c2_table, insert_c1c2, query_c1c2
from tools.jmxutils import (JolokiaAgent, make_mbean,
remove_perf_disable_shared_mem)
from tools.jmxutils import (JolokiaAgent, make_mbean)
from tools.misc import new_node
from compaction_test import grep_sstables_in_each_level

Expand Down Expand Up @@ -127,7 +126,6 @@ def test_blacklisted_directory(self):
cluster.set_datadir_count(3)
cluster.populate(1)
[node] = cluster.nodelist()
remove_perf_disable_shared_mem(node)
cluster.start()

session = self.patient_cql_connection(node)
Expand Down
1 change: 0 additions & 1 deletion dtest_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ def __init__(self, dtest_config=None, setup_overrides=None, cluster_name="test")

self.last_log = os.path.join(self.log_saved_dir, "last")
self.test_path = self.get_test_path()
self.enable_for_jolokia = False
self.subprocs = []
self.log_watch_thread = None
self.last_test_dir = "last_test_dir"
Expand Down
7 changes: 1 addition & 6 deletions jmx_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@
from distutils.version import LooseVersion

from dtest import Tester
from tools.jmxutils import (JolokiaAgent, enable_jmx_ssl, make_mbean,
remove_perf_disable_shared_mem)
from tools.jmxutils import (JolokiaAgent, enable_jmx_ssl, make_mbean)
from tools.misc import generate_ssl_stores

since = pytest.mark.since
Expand Down Expand Up @@ -72,7 +71,6 @@ def test_table_metric_mbeans(self):
cluster = self.cluster
cluster.populate(3)
node1, node2, node3 = cluster.nodelist()
remove_perf_disable_shared_mem(node1)
cluster.start()

version = cluster.version()
Expand Down Expand Up @@ -113,7 +111,6 @@ def test_mv_metric_mbeans_release(self):
cluster.set_configuration_options({'enable_materialized_views': 'true'})
cluster.populate(1)
node = cluster.nodelist()[0]
remove_perf_disable_shared_mem(node)
cluster.start()

node.run_cqlsh(cmds="""
Expand Down Expand Up @@ -187,7 +184,6 @@ def test_compactionstats(self):
cluster = self.cluster
cluster.populate(1)
node = cluster.nodelist()[0]
remove_perf_disable_shared_mem(node)
cluster.start()

# Run a quick stress command to create the keyspace and table
Expand Down Expand Up @@ -282,7 +278,6 @@ def test_set_get_batchlog_replay_throttle(self):
cluster = self.cluster
cluster.populate(2)
node = cluster.nodelist()[0]
remove_perf_disable_shared_mem(node)
cluster.start()

# Set and get throttle with JMX, ensuring that the rate change is logged
Expand Down
Binary file removed lib/jolokia-jvm-1.2.3-agent.jar
Binary file not shown.
Binary file added lib/jolokia-jvm-1.6.2-agent.jar
Binary file not shown.
File renamed without changes.
5 changes: 1 addition & 4 deletions materialized_views_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
assert_unavailable)
from tools.data import rows_to_list
from tools.misc import new_node
from tools.jmxutils import (JolokiaAgent, make_mbean, remove_perf_disable_shared_mem)
from tools.jmxutils import (JolokiaAgent, make_mbean)

since = pytest.mark.since
logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -2881,9 +2881,6 @@ def _prepare_cluster(self):
'concurrent_writes': 1,
})
self.nodes = list(self.cluster.nodes.values())
for node in self.nodes:
remove_perf_disable_shared_mem(node)

self.cluster.start(jvm_args=[
"-Dcassandra.test.fail_mv_locks_count=64"
])
Expand Down
3 changes: 1 addition & 2 deletions nodetool_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

from dtest import Tester, create_ks
from tools.assertions import assert_all, assert_invalid, assert_none
from tools.jmxutils import JolokiaAgent, make_mbean, remove_perf_disable_shared_mem
from tools.jmxutils import JolokiaAgent, make_mbean

since = pytest.mark.since
logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -254,7 +254,6 @@ def test_reloadlocalschema(self):
cluster = self.cluster
cluster.populate(1)
node = cluster.nodelist()[0]
remove_perf_disable_shared_mem(node) # for jmx
cluster.start()

session = self.patient_cql_connection(node)
Expand Down
4 changes: 1 addition & 3 deletions repair_tests/deprecated_repair_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
from dtest import Tester, create_ks, create_cf
from tools.assertions import assert_length_equal
from tools.data import insert_c1c2
from tools.jmxutils import (JolokiaAgent, make_mbean,
remove_perf_disable_shared_mem)
from tools.jmxutils import (JolokiaAgent, make_mbean)

since = pytest.mark.since
logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -147,7 +146,6 @@ def _deprecated_repair_jmx(self, method, arguments):
logger.debug("Starting cluster..")
cluster.populate([1, 1])
node1, node2 = cluster.nodelist()
remove_perf_disable_shared_mem(node1)
cluster.start()
supports_pull_repair = cluster.version() >= LooseVersion('3.10')

Expand Down
3 changes: 1 addition & 2 deletions repair_tests/incremental_repair_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from tools.assertions import assert_almost_equal, assert_one
from tools.data import insert_c1c2
from tools.misc import new_node, ImmutableMapping
from tools.jmxutils import make_mbean, JolokiaAgent, remove_perf_disable_shared_mem
from tools.jmxutils import make_mbean, JolokiaAgent

since = pytest.mark.since
logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -1077,7 +1077,6 @@ def setup_for_repaired_data_tracking(self):
self.init_default_config()
self.cluster.populate(2)
node1, node2 = self.cluster.nodelist()
remove_perf_disable_shared_mem(node1) # necessary for jmx
self.cluster.start()

session = self.patient_exclusive_cql_connection(node1)
Expand Down
5 changes: 1 addition & 4 deletions snitch_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@

from cassandra import ConsistencyLevel
from dtest import Tester
from tools.jmxutils import (JolokiaAgent, make_mbean,
remove_perf_disable_shared_mem)
from tools.jmxutils import (JolokiaAgent, make_mbean)

since = pytest.mark.since
logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -159,8 +158,6 @@ def snitchable(scores_before, scores_after, needed_nodes):
cluster.set_configuration_options(values={'dynamic_snitch_reset_interval_in_ms': 10000,
'dynamic_snitch_update_interval_in_ms': 50,
'phi_convict_threshold': 12})
remove_perf_disable_shared_mem(coordinator_node)
remove_perf_disable_shared_mem(degraded_node)
# Delay reads on the degraded node by 50 milliseconds
degraded_node.start(jvm_args=['-Dcassandra.test.read_iteration_delay_ms=50',
'-Dcassandra.allow_unsafe_join=true'])
Expand Down
3 changes: 1 addition & 2 deletions thrift_hsha_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

from dtest import DEFAULT_DIR, Tester, create_ks
from thrift_test import get_thrift_client
from tools.jmxutils import JolokiaAgent, make_mbean, remove_perf_disable_shared_mem
from tools.jmxutils import JolokiaAgent, make_mbean

since = pytest.mark.since
logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -48,7 +48,6 @@ def test_closing_connections(self):

cluster.populate(1)
(node1,) = cluster.nodelist()
remove_perf_disable_shared_mem(node1)
cluster.start()

session = self.patient_cql_connection(node1)
Expand Down
24 changes: 1 addition & 23 deletions tools/jmxutils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import glob
import json
import os
import subprocess
Expand All @@ -8,11 +7,9 @@

import ccmlib.common as common

from distutils.version import LooseVersion

logger = logging.getLogger(__name__)

JOLOKIA_JAR = os.path.join('lib', 'jolokia-jvm-1.2.3-agent.jar')
JOLOKIA_JAR = os.path.join('lib', 'jolokia-jvm-1.6.2-agent.jar')
CLASSPATH_SEP = ';' if common.is_win() else ':'


Expand Down Expand Up @@ -155,25 +152,6 @@ def apply_jmx_authentication(node):
common.replaces_in_file(node.envfilename(), replacement_list)


def remove_perf_disable_shared_mem(node):
"""
The Jolokia agent is incompatible with the -XX:+PerfDisableSharedMem JVM
option (see https://github.com/rhuss/jolokia/issues/198 for details). This
edits cassandra-env.sh (or the Windows equivalent), or jvm.options file on 3.2+ to remove that option.
"""
if node.get_cassandra_version() >= LooseVersion('3.2'):
pattern = r'\-XX:\+PerfDisableSharedMem'
replacement = '#-XX:+PerfDisableSharedMem'
for f in glob.glob(os.path.join(node.get_conf_dir(), common.JVM_OPTS_PATTERN)):
if os.path.isfile(f):
common.replace_in_file(f, pattern, replacement)
else:
conf_file = node.envfilename()
pattern = 'PerfDisableSharedMem'
replacement = ''
common.replace_in_file(conf_file, pattern, replacement)


class JolokiaAgent(object):
"""
This class provides a simple way to read, write, and execute
Expand Down
9 changes: 0 additions & 9 deletions upgrade_tests/upgrade_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from abc import ABCMeta

from ccmlib.common import get_version_from_build, is_win
from tools.jmxutils import remove_perf_disable_shared_mem

from dtest import Tester, create_ks

Expand Down Expand Up @@ -124,11 +123,6 @@ def prepare(self, ordered=False, create_keyspace=True, use_cache=False, use_thri
cluster.set_configuration_options(values=extra_config_options)

cluster.populate(nodes)
node1 = cluster.nodelist()[0]
self.fixture_dtest_setup.enable_for_jolokia = kwargs.pop('jolokia', False)
if self.fixture_dtest_setup.enable_for_jolokia:
remove_perf_disable_shared_mem(node1)

cluster.start()

node1 = cluster.nodelist()[0]
Expand Down Expand Up @@ -193,9 +187,6 @@ def do_upgrade(self, session, use_thrift=False, return_nodes=False, **kwargs):
if use_thrift and node1.get_cassandra_version() < '4':
node1.set_configuration_options(values={'start_rpc': 'true'})

if self.fixture_dtest_setup.enable_for_jolokia:
remove_perf_disable_shared_mem(node1)

node1.start(wait_for_binary_proto=True)

sessions_and_meta = []
Expand Down

0 comments on commit 114ccff

Please sign in to comment.