Compare commits
89 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
69951d5a2d | ||
|
12cd93f7c1 | ||
|
c43992ba08 | ||
|
cd30267633 | ||
|
88d9bdc5b2 | ||
|
06f27357b4 | ||
|
fe351e8491 | ||
|
53f7f55e8c | ||
|
2c43d99aa5 | ||
|
26a6919714 | ||
|
d6225c5231 | ||
|
48d37f3402 | ||
|
5c383b641b | ||
|
658818b2d0 | ||
|
70b19e6270 | ||
|
5311e9bae3 | ||
|
fbfbdaa298 | ||
|
a7c4c39dd0 | ||
|
440313eb72 | ||
|
9c687b562e | ||
|
15c1d4f43f | ||
|
ffab41d714 | ||
|
bac7d0b31e | ||
|
59fd4d2b03 | ||
|
9d7ee8af3c | ||
|
c2fc96be71 | ||
|
8073af6e06 | ||
|
bf8bb16b52 | ||
|
8f62d71e11 | ||
|
3618481e23 | ||
|
949cefc251 | ||
|
611d586981 | ||
|
2c9565024f | ||
|
20469bf749 | ||
|
6174a47924 | ||
|
91e7adffb1 | ||
|
c51906ed01 | ||
|
c55f3f292b | ||
|
e3a381d5a1 | ||
|
25bcd76017 | ||
|
45e4f28766 | ||
|
6795a22afe | ||
|
5fa422c4ea | ||
|
f1612ef508 | ||
|
d3096f32e0 | ||
|
99e491df40 | ||
|
8d92e5450e | ||
|
ba3f58c63c | ||
|
771fe3e360 | ||
|
12ab6aaeb8 | ||
|
1219faf9f1 | ||
|
d998ac2e1e | ||
|
6311525346 | ||
|
d5d1efd188 | ||
|
23da40b559 | ||
|
be8f1ac511 | ||
|
c5ed83178a | ||
|
626fd75173 | ||
|
c0d9d0f051 | ||
|
7578d359af | ||
|
aa94fe53e0 | ||
|
4727910b5e | ||
|
15eb6adf92 | ||
|
5820992a8e | ||
|
38eb871383 | ||
|
28fe33e588 | ||
|
b2195734cc | ||
|
b2e4796901 | ||
|
78c3b7627f | ||
|
e0b21b9a19 | ||
|
2883a8dc63 | ||
|
354df10ea9 | ||
|
3fb777a8f0 | ||
|
f044c8988e | ||
|
ec2a830876 | ||
|
9628cc0728 | ||
|
c7dcbd7f42 | ||
|
fc43c56369 | ||
|
52bd496006 | ||
|
18f8acc60e | ||
|
773a82d539 | ||
|
46681753cd | ||
|
29601254fc | ||
|
4c8660d41a | ||
|
2f34a97c6e | ||
|
236ffa6c98 | ||
|
771cf6ea50 | ||
|
31e6bcf9be | ||
|
d8c47603d9 |
6
.gitignore
vendored
6
.gitignore
vendored
@ -1,7 +1,9 @@
|
|||||||
/target/
|
/target/
|
||||||
/bin/
|
/bin/
|
||||||
dependecy-reduced-pom.xml
|
dependency-reduced-pom.xml
|
||||||
|
scylla-apiclient/target/
|
||||||
.classpath
|
.classpath
|
||||||
.project
|
.project
|
||||||
.settings
|
.settings
|
||||||
|
build/
|
||||||
|
/.idea/
|
||||||
|
@ -8,12 +8,40 @@ then
|
|||||||
SCYLLA_VERSION=$(cat version | awk -F'-' '{print $1}')
|
SCYLLA_VERSION=$(cat version | awk -F'-' '{print $1}')
|
||||||
SCYLLA_RELEASE=$(cat version | awk -F'-' '{print $2}')
|
SCYLLA_RELEASE=$(cat version | awk -F'-' '{print $2}')
|
||||||
else
|
else
|
||||||
DATE=$(date +%Y%m%d)
|
DATE=$(date --utc +%Y%m%d)
|
||||||
GIT_COMMIT=$(git log --pretty=format:'%h' -n 1)
|
GIT_COMMIT=$(git log --pretty=format:'%h' -n 1)
|
||||||
SCYLLA_VERSION=$VERSION
|
SCYLLA_VERSION=$VERSION
|
||||||
SCYLLA_RELEASE=$DATE.$GIT_COMMIT
|
SCYLLA_RELEASE=$DATE.$GIT_COMMIT
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
usage() {
|
||||||
|
echo "usage: $0"
|
||||||
|
echo " [--version product-version-release] # override p-v-r"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
OVERRIDE=
|
||||||
|
while [[ $# > 0 ]]; do
|
||||||
|
case "$1" in
|
||||||
|
--version)
|
||||||
|
OVERRIDE="$2"
|
||||||
|
shift 2
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
usage
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
if [[ -n "$OVERRIDE" ]]; then
|
||||||
|
# regular expression for p-v-r: alphabetic+dashes for product, trailing non-dashes
|
||||||
|
# for release, everything else for version
|
||||||
|
RE='^([-a-z]+)-(.+)-([^-]+)$'
|
||||||
|
PRODUCT="$(sed -E "s/$RE/\\1/" <<<"$OVERRIDE")"
|
||||||
|
SCYLLA_VERSION="$(sed -E "s/$RE/\\2/" <<<"$OVERRIDE")"
|
||||||
|
SCYLLA_RELEASE="$(sed -E "s/$RE/\\3/" <<<"$OVERRIDE")"
|
||||||
|
fi
|
||||||
|
|
||||||
echo "$SCYLLA_VERSION-$SCYLLA_RELEASE"
|
echo "$SCYLLA_VERSION-$SCYLLA_RELEASE"
|
||||||
mkdir -p build
|
mkdir -p build
|
||||||
echo "$SCYLLA_VERSION" > build/SCYLLA-VERSION-FILE
|
echo "$SCYLLA_VERSION" > build/SCYLLA-VERSION-FILE
|
||||||
|
3
dist/common/sysconfig/scylla-jmx
vendored
3
dist/common/sysconfig/scylla-jmx
vendored
@ -27,3 +27,6 @@ SCYLLA_JMX_LOCAL="-l /opt/scylladb/jmx"
|
|||||||
|
|
||||||
# allow debug
|
# allow debug
|
||||||
#SCYLLA_JMX_DEBUG="-d"
|
#SCYLLA_JMX_DEBUG="-d"
|
||||||
|
|
||||||
|
# specify JVM options
|
||||||
|
JAVA_TOOL_OPTIONS=""
|
||||||
|
1
dist/common/systemd/scylla-jmx.service
vendored
1
dist/common/systemd/scylla-jmx.service
vendored
@ -12,6 +12,7 @@ ExecStart=/opt/scylladb/jmx/scylla-jmx $SCYLLA_JMX_PORT $SCYLLA_API_PORT $SCYLLA
|
|||||||
KillMode=process
|
KillMode=process
|
||||||
Restart=on-abnormal
|
Restart=on-abnormal
|
||||||
Slice=scylla-helper.slice
|
Slice=scylla-helper.slice
|
||||||
|
WorkingDirectory=/var/lib/scylla
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target
|
WantedBy=multi-user.target
|
||||||
|
126
dist/debian/build_deb.sh
vendored
126
dist/debian/build_deb.sh
vendored
@ -1,126 +0,0 @@
|
|||||||
#!/bin/bash -e
|
|
||||||
|
|
||||||
PRODUCT=$(cat SCYLLA-PRODUCT-FILE)
|
|
||||||
|
|
||||||
. /etc/os-release
|
|
||||||
print_usage() {
|
|
||||||
echo "build_deb.sh --reloc-pkg build/scylla-jmx-package.tar.gz"
|
|
||||||
echo " --reloc-pkg specify relocatable package path"
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
TARGET=stable
|
|
||||||
RELOC_PKG=
|
|
||||||
while [ $# -gt 0 ]; do
|
|
||||||
case "$1" in
|
|
||||||
"--reloc-pkg")
|
|
||||||
RELOC_PKG=$2
|
|
||||||
shift 2
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
print_usage
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
|
||||||
is_redhat_variant() {
|
|
||||||
[ -f /etc/redhat-release ]
|
|
||||||
}
|
|
||||||
is_debian_variant() {
|
|
||||||
[ -f /etc/debian_version ]
|
|
||||||
}
|
|
||||||
pkg_install() {
|
|
||||||
if is_redhat_variant; then
|
|
||||||
sudo yum install -y $1
|
|
||||||
elif is_debian_variant; then
|
|
||||||
sudo apt-get install -y $1
|
|
||||||
else
|
|
||||||
echo "Requires to install following command: $1"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
if [ ! -e SCYLLA-RELOCATABLE-FILE ]; then
|
|
||||||
echo "do not directly execute build_rpm.sh, use reloc/build_rpm.sh instead."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "$(arch)" != "x86_64" ]; then
|
|
||||||
echo "Unsupported architecture: $(arch)"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -z "$RELOC_PKG" ]; then
|
|
||||||
print_usage
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
if [ ! -f "$RELOC_PKG" ]; then
|
|
||||||
echo "$RELOC_PKG is not found."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -e debian ] || [ -e build/release ]; then
|
|
||||||
sudo rm -rf debian build
|
|
||||||
mkdir build
|
|
||||||
fi
|
|
||||||
if is_debian_variant; then
|
|
||||||
sudo apt-get -y update
|
|
||||||
fi
|
|
||||||
# this hack is needed since some environment installs 'git-core' package, it's
|
|
||||||
# subset of the git command and doesn't works for our git-archive-all script.
|
|
||||||
if is_redhat_variant && [ ! -f /usr/libexec/git-core/git-submodule ]; then
|
|
||||||
sudo yum install -y git
|
|
||||||
fi
|
|
||||||
if [ ! -f /usr/bin/git ]; then
|
|
||||||
pkg_install git
|
|
||||||
fi
|
|
||||||
if [ ! -f /usr/bin/python ]; then
|
|
||||||
pkg_install python
|
|
||||||
fi
|
|
||||||
if [ ! -f /usr/sbin/debuild ]; then
|
|
||||||
pkg_install devscripts
|
|
||||||
fi
|
|
||||||
if [ ! -f /usr/bin/dh_testdir ]; then
|
|
||||||
pkg_install debhelper
|
|
||||||
fi
|
|
||||||
if [ ! -f /usr/bin/fakeroot ]; then
|
|
||||||
pkg_install fakeroot
|
|
||||||
fi
|
|
||||||
if [ ! -f /usr/bin/pystache ]; then
|
|
||||||
if is_redhat_variant; then
|
|
||||||
sudo yum install -y /usr/bin/pystache
|
|
||||||
elif is_debian_variant; then
|
|
||||||
sudo apt-get install -y python-pystache
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "$ID" = "ubuntu" ] && [ ! -f /usr/share/keyrings/debian-archive-keyring.gpg ]; then
|
|
||||||
sudo apt-get install -y debian-archive-keyring
|
|
||||||
fi
|
|
||||||
if [ "$ID" = "debian" ] && [ ! -f /usr/share/keyrings/ubuntu-archive-keyring.gpg ]; then
|
|
||||||
sudo apt-get install -y ubuntu-archive-keyring
|
|
||||||
fi
|
|
||||||
|
|
||||||
RELOC_PKG_FULLPATH=$(readlink -f $RELOC_PKG)
|
|
||||||
RELOC_PKG_BASENAME=$(basename $RELOC_PKG)
|
|
||||||
SCYLLA_VERSION=$(cat SCYLLA-VERSION-FILE | sed 's/\.rc/~rc/')
|
|
||||||
SCYLLA_RELEASE=$(cat SCYLLA-RELEASE-FILE)
|
|
||||||
|
|
||||||
ln -fv $RELOC_PKG_FULLPATH ../$PRODUCT-jmx_$SCYLLA_VERSION-$SCYLLA_RELEASE.orig.tar.gz
|
|
||||||
|
|
||||||
cp -al dist/debian/debian debian
|
|
||||||
if [ "$PRODUCT" != "scylla" ]; then
|
|
||||||
for i in debian/scylla-*;do
|
|
||||||
mv $i ${i/scylla-/$PRODUCT-}
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
|
|
||||||
REVISION="1"
|
|
||||||
MUSTACHE_DIST="\"debian\": true, \"$TARGET\": true, \"product\": \"$PRODUCT\", \"$PRODUCT\": true"
|
|
||||||
pystache dist/debian/changelog.mustache "{ $MUSTACHE_DIST, \"version\": \"$SCYLLA_VERSION\", \"release\": \"$SCYLLA_RELEASE\", \"revision\": \"$REVISION\", \"codename\": \"$TARGET\" }" > debian/changelog
|
|
||||||
pystache dist/debian/rules.mustache "{ $MUSTACHE_DIST }" > debian/rules
|
|
||||||
chmod a+rx debian/rules
|
|
||||||
pystache dist/debian/control.mustache "{ $MUSTACHE_DIST }" > debian/control
|
|
||||||
|
|
||||||
cp dist/common/systemd/scylla-jmx.service debian/scylla-jmx.service
|
|
||||||
|
|
||||||
debuild -rfakeroot -us -uc
|
|
@ -1,4 +1,4 @@
|
|||||||
{{product}}-jmx ({{version}}-{{release}}-{{revision}}) {{codename}}; urgency=medium
|
%{product}-jmx (%{version}-%{release}-%{revision}) %{codename}; urgency=medium
|
||||||
|
|
||||||
* Initial release.
|
* Initial release.
|
||||||
|
|
@ -1,13 +1,14 @@
|
|||||||
Source: {{product}}-jmx
|
Source: %{product}-jmx
|
||||||
Maintainer: Takuya ASADA <syuu@scylladb.com>
|
Maintainer: Takuya ASADA <syuu@scylladb.com>
|
||||||
Homepage: http://scylladb.com
|
Homepage: http://scylladb.com
|
||||||
Section: database
|
Section: database
|
||||||
Priority: optional
|
Priority: optional
|
||||||
Standards-Version: 3.9.5
|
Standards-Version: 3.9.5
|
||||||
|
Rules-Requires-Root: no
|
||||||
|
|
||||||
Package: {{product}}-jmx
|
Package: %{product}-jmx
|
||||||
Architecture: all
|
Architecture: all
|
||||||
Depends: ${shlibs:Depends}, ${misc:Depends}, openjdk-8-jre-headless | openjdk-8-jre | oracle-java8-set-default, {{product}}-server
|
Depends: ${shlibs:Depends}, ${misc:Depends}, openjdk-8-jre-headless | openjdk-8-jre | oracle-java8-set-default | adoptopenjdk-8-hotspot-jre | openjdk-11-jre-headless | openjdk-11-jre |oracle-java11-set-default , %{product}-server
|
||||||
Description: Scylla JMX server binaries
|
Description: Scylla JMX server binaries
|
||||||
Scylla is a highly scalable, eventually consistent, distributed,
|
Scylla is a highly scalable, eventually consistent, distributed,
|
||||||
partitioned row DB.
|
partitioned row DB.
|
@ -1,20 +1,21 @@
|
|||||||
#!/usr/bin/make -f
|
#!/usr/bin/make -f
|
||||||
|
|
||||||
|
include /usr/share/dpkg/pkg-info.mk
|
||||||
|
|
||||||
override_dh_auto_build:
|
override_dh_auto_build:
|
||||||
|
|
||||||
override_dh_auto_clean:
|
override_dh_auto_clean:
|
||||||
|
|
||||||
override_dh_auto_install:
|
override_dh_auto_install:
|
||||||
dh_auto_install
|
dh_auto_install
|
||||||
./install.sh --root "$(CURDIR)/debian/{{product}}-jmx" --sysconfdir /etc/default
|
cd scylla-jmx; ./install.sh --packaging --root "$(CURDIR)/debian/tmp" --sysconfdir /etc/default
|
||||||
|
|
||||||
override_dh_installinit:
|
override_dh_installinit:
|
||||||
{{#scylla}}
|
ifeq ($(DEB_SOURCE),scylla-jmx)
|
||||||
dh_installinit --no-start
|
dh_installinit --no-start
|
||||||
{{/scylla}}
|
else
|
||||||
{{^scylla}}
|
|
||||||
dh_installinit --no-start --name scylla-jmx
|
dh_installinit --no-start --name scylla-jmx
|
||||||
{{/scylla}}
|
endif
|
||||||
|
|
||||||
override_dh_strip_nondeterminism:
|
override_dh_strip_nondeterminism:
|
||||||
|
|
4
dist/debian/debian/scylla-jmx.install
vendored
Normal file
4
dist/debian/debian/scylla-jmx.install
vendored
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
etc/default/scylla-jmx
|
||||||
|
etc/systemd/system/scylla-jmx.service.d/sysconfdir.conf
|
||||||
|
opt/scylladb/jmx/*
|
||||||
|
usr/lib/scylla/jmx/*
|
1
dist/debian/debian/scylla-jmx.service
vendored
Symbolic link
1
dist/debian/debian/scylla-jmx.service
vendored
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../../common/systemd/scylla-jmx.service
|
21
dist/debian/debian/scylla-jmx.upstart
vendored
21
dist/debian/debian/scylla-jmx.upstart
vendored
@ -1,21 +0,0 @@
|
|||||||
# scylla-jmx - ScyllaDB
|
|
||||||
#
|
|
||||||
# ScyllaDB
|
|
||||||
|
|
||||||
description "ScyllaDB jmx"
|
|
||||||
|
|
||||||
start on started scylla-server
|
|
||||||
stop on stopping scylla-server
|
|
||||||
|
|
||||||
umask 022
|
|
||||||
|
|
||||||
console log
|
|
||||||
|
|
||||||
setuid scylla
|
|
||||||
setgid scylla
|
|
||||||
|
|
||||||
script
|
|
||||||
. /etc/default/scylla-jmx
|
|
||||||
export SCYLLA_HOME SCYLLA_CONF
|
|
||||||
exec /usr/lib/scylla/jmx/scylla-jmx -l /usr/lib/scylla/jmx
|
|
||||||
end script
|
|
80
dist/debian/debian_files_gen.py
vendored
Executable file
80
dist/debian/debian_files_gen.py
vendored
Executable file
@ -0,0 +1,80 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
#
|
||||||
|
# Copyright (C) 2020 ScyllaDB
|
||||||
|
#
|
||||||
|
|
||||||
|
#
|
||||||
|
# This file is part of Scylla.
|
||||||
|
#
|
||||||
|
# Scylla is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU Affero General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# Scylla is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with Scylla. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
|
|
||||||
|
import string
|
||||||
|
import os
|
||||||
|
import shutil
|
||||||
|
import re
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
class DebianFilesTemplate(string.Template):
|
||||||
|
delimiter = '%'
|
||||||
|
|
||||||
|
scriptdir = os.path.dirname(__file__)
|
||||||
|
|
||||||
|
with open(os.path.join(scriptdir, 'changelog.template')) as f:
|
||||||
|
changelog_template = f.read()
|
||||||
|
|
||||||
|
with open(os.path.join(scriptdir, 'control.template')) as f:
|
||||||
|
control_template = f.read()
|
||||||
|
|
||||||
|
with open('build/SCYLLA-PRODUCT-FILE') as f:
|
||||||
|
product = f.read().strip()
|
||||||
|
|
||||||
|
with open('build/SCYLLA-VERSION-FILE') as f:
|
||||||
|
version = f.read().strip().replace('.rc', '~rc').replace('_', '-')
|
||||||
|
|
||||||
|
with open('build/SCYLLA-RELEASE-FILE') as f:
|
||||||
|
release = f.read().strip()
|
||||||
|
|
||||||
|
if os.path.exists('build/debian/debian'):
|
||||||
|
shutil.rmtree('build/debian/debian')
|
||||||
|
shutil.copytree('dist/debian/debian', 'build/debian/debian')
|
||||||
|
|
||||||
|
if product != 'scylla':
|
||||||
|
for p in Path('build/debian/debian').glob('scylla-*'):
|
||||||
|
# pat1: scylla-server.service
|
||||||
|
# -> scylla-enterprise-server.scylla-server.service
|
||||||
|
# pat2: scylla-server.scylla-fstrim.service
|
||||||
|
# -> scylla-enterprise-server.scylla-fstrim.service
|
||||||
|
# pat3: scylla-conf.install
|
||||||
|
# -> scylla-enterprise-conf.install
|
||||||
|
|
||||||
|
if m := re.match(r'^scylla(-[^.]+)\.service$', p.name):
|
||||||
|
p.rename(p.parent / f'{product}{m.group(1)}.{p.name}')
|
||||||
|
elif m := re.match(r'^scylla(-[^.]+\.scylla-[^.]+\.[^.]+)$', p.name):
|
||||||
|
p.rename(p.parent / f'{product}{m.group(1)}')
|
||||||
|
else:
|
||||||
|
p.rename(p.parent / p.name.replace('scylla', product, 1))
|
||||||
|
|
||||||
|
s = DebianFilesTemplate(changelog_template)
|
||||||
|
changelog_applied = s.substitute(product=product, version=version, release=release, revision='1', codename='stable')
|
||||||
|
|
||||||
|
s = DebianFilesTemplate(control_template)
|
||||||
|
control_applied = s.substitute(product=product)
|
||||||
|
|
||||||
|
with open('build/debian/debian/changelog', 'w') as f:
|
||||||
|
f.write(changelog_applied)
|
||||||
|
|
||||||
|
with open('build/debian/debian/control', 'w') as f:
|
||||||
|
f.write(control_applied)
|
75
dist/redhat/build_rpm.sh
vendored
75
dist/redhat/build_rpm.sh
vendored
@ -1,75 +0,0 @@
|
|||||||
#!/bin/bash -e
|
|
||||||
|
|
||||||
PRODUCT=$(cat SCYLLA-PRODUCT-FILE)
|
|
||||||
|
|
||||||
. /etc/os-release
|
|
||||||
print_usage() {
|
|
||||||
echo "build_rpm.sh --reloc-pkg build/scylla-jmx-package.tar.gz"
|
|
||||||
echo " --reloc-pkg specify relocatable package path"
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
RELOC_PKG=
|
|
||||||
while [ $# -gt 0 ]; do
|
|
||||||
case "$1" in
|
|
||||||
"--reloc-pkg")
|
|
||||||
RELOC_PKG=$2
|
|
||||||
shift 2
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
print_usage
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
|
||||||
is_redhat_variant() {
|
|
||||||
[ -f /etc/redhat-release ]
|
|
||||||
}
|
|
||||||
pkg_install() {
|
|
||||||
if is_redhat_variant; then
|
|
||||||
sudo yum install -y $1
|
|
||||||
else
|
|
||||||
echo "Requires to install following command: $1"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
if [ ! -e SCYLLA-RELOCATABLE-FILE ]; then
|
|
||||||
echo "do not directly execute build_rpm.sh, use reloc/build_rpm.sh instead."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -z "$RELOC_PKG" ]; then
|
|
||||||
print_usage
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
if [ ! -f "$RELOC_PKG" ]; then
|
|
||||||
echo "$RELOC_PKG is not found."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ ! -f /usr/bin/rpmbuild ]; then
|
|
||||||
pkg_install rpm-build
|
|
||||||
fi
|
|
||||||
if [ ! -f /usr/bin/git ]; then
|
|
||||||
pkg_install git
|
|
||||||
fi
|
|
||||||
if [ ! -f /usr/bin/pystache ]; then
|
|
||||||
if is_redhat_variant; then
|
|
||||||
sudo yum install -y python2-pystache || sudo yum install -y pystache
|
|
||||||
elif is_debian_variant; then
|
|
||||||
sudo apt-get install -y python-pystache
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
SCYLLA_VERSION=$(cat SCYLLA-VERSION-FILE)
|
|
||||||
SCYLLA_RELEASE=$(cat SCYLLA-RELEASE-FILE)
|
|
||||||
VERSION=$SCYLLA_VERSION-$SCYLLA_RELEASE
|
|
||||||
|
|
||||||
RPMBUILD=$(readlink -f ../)
|
|
||||||
mkdir -p $RPMBUILD/{BUILD,BUILDROOT,RPMS,SOURCES,SPECS,SRPMS}
|
|
||||||
|
|
||||||
ln -fv $RELOC_PKG $RPMBUILD/SOURCES/
|
|
||||||
pystache dist/redhat/scylla-jmx.spec.mustache "{ \"version\": \"$SCYLLA_VERSION\", \"release\": \"$SCYLLA_RELEASE\", \"product\": \"$PRODUCT\", \"$PRODUCT\": true }" > $RPMBUILD/SPECS/scylla-jmx.spec
|
|
||||||
|
|
||||||
# this rpm can be install on both fedora / centos7, so drop distribution name from the file name
|
|
||||||
rpmbuild -ba --define "_topdir $RPMBUILD" --undefine "dist" $RPM_JOBS_OPTS $RPMBUILD/SPECS/scylla-jmx.spec
|
|
@ -1,30 +1,29 @@
|
|||||||
Name: {{product}}-jmx
|
Name: %{product}-jmx
|
||||||
Version: {{version}}
|
Version: %{version}
|
||||||
Release: {{release}}%{?dist}
|
Release: %{release}%{?dist}
|
||||||
Summary: Scylla JMX
|
Summary: Scylla JMX
|
||||||
Group: Applications/Databases
|
Group: Applications/Databases
|
||||||
|
|
||||||
License: AGPLv3
|
License: AGPLv3
|
||||||
URL: http://www.scylladb.com/
|
URL: http://www.scylladb.com/
|
||||||
Source0: scylla-jmx-package.tar.gz
|
Source0: %{reloc_pkg}
|
||||||
|
|
||||||
BuildArch: noarch
|
BuildArch: noarch
|
||||||
BuildRequires: systemd-units
|
BuildRequires: systemd-units
|
||||||
BuildRequires: pystache
|
Requires: %{product}-server jre-1.8.0-headless
|
||||||
%{?rhel:BuildRequires: python-setuptools}
|
AutoReqProv: no
|
||||||
Requires: {{product}}-server java-1.8.0-openjdk-headless
|
|
||||||
|
|
||||||
%description
|
%description
|
||||||
|
|
||||||
|
|
||||||
%prep
|
%prep
|
||||||
%setup -c
|
%setup -q -n scylla-jmx
|
||||||
|
|
||||||
|
|
||||||
%build
|
%build
|
||||||
|
|
||||||
%install
|
%install
|
||||||
./install.sh --root "$RPM_BUILD_ROOT"
|
./install.sh --packaging --root "$RPM_BUILD_ROOT"
|
||||||
|
|
||||||
%pre
|
%pre
|
||||||
/usr/sbin/groupadd scylla 2> /dev/null || :
|
/usr/sbin/groupadd scylla 2> /dev/null || :
|
||||||
@ -40,13 +39,20 @@ echo
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
%post
|
%post
|
||||||
%systemd_post scylla-jmx.service
|
if [ $1 -eq 1 ] ; then
|
||||||
|
/usr/bin/systemctl preset scylla-jmx.service ||:
|
||||||
|
fi
|
||||||
|
|
||||||
|
/usr/bin/systemctl daemon-reload ||:
|
||||||
|
|
||||||
%preun
|
%preun
|
||||||
%systemd_preun scylla-jmx.service
|
if [ $1 -eq 0 ] ; then
|
||||||
|
/usr/bin/systemctl --no-reload disable scylla-jmx.service ||:
|
||||||
|
/usr/bin/systemctl stop scylla-jmx.service ||:
|
||||||
|
fi
|
||||||
|
|
||||||
%postun
|
%postun
|
||||||
%systemd_postun
|
/usr/bin/systemctl daemon-reload ||:
|
||||||
|
|
||||||
%clean
|
%clean
|
||||||
rm -rf $RPM_BUILD_ROOT
|
rm -rf $RPM_BUILD_ROOT
|
||||||
@ -58,9 +64,11 @@ rm -rf $RPM_BUILD_ROOT
|
|||||||
%config(noreplace) %{_sysconfdir}/sysconfig/scylla-jmx
|
%config(noreplace) %{_sysconfdir}/sysconfig/scylla-jmx
|
||||||
%{_unitdir}/scylla-jmx.service
|
%{_unitdir}/scylla-jmx.service
|
||||||
/opt/scylladb/jmx/scylla-jmx
|
/opt/scylladb/jmx/scylla-jmx
|
||||||
/opt/scylladb/jmx/scylla-jmx-1.0.jar
|
/opt/scylladb/jmx/scylla-jmx-1.1.jar
|
||||||
/opt/scylladb/jmx/symlinks/scylla-jmx
|
/opt/scylladb/jmx/symlinks/scylla-jmx
|
||||||
/opt/scylladb/scripts/jmx
|
%{_prefix}/lib/scylla/jmx/scylla-jmx
|
||||||
|
%{_prefix}/lib/scylla/jmx/scylla-jmx-1.1.jar
|
||||||
|
%{_prefix}/lib/scylla/jmx/symlinks/scylla-jmx
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
* Fri Aug 7 2015 Takuya ASADA Takuya ASADA <syuu@cloudius-systems.com>
|
* Fri Aug 7 2015 Takuya ASADA Takuya ASADA <syuu@cloudius-systems.com>
|
@ -22,5 +22,5 @@
|
|||||||
if [ "$ID" = "ubuntu" ] || [ "$ID" = "debian" ]; then
|
if [ "$ID" = "ubuntu" ] || [ "$ID" = "debian" ]; then
|
||||||
apt -y install maven openjdk-8-jdk-headless
|
apt -y install maven openjdk-8-jdk-headless
|
||||||
elif [ "$ID" = "fedora" ] || [ "$ID" = "centos" ]; then
|
elif [ "$ID" = "fedora" ] || [ "$ID" = "centos" ]; then
|
||||||
yum install -y maven java-1.8.0-openjdk-devel
|
dnf install -y maven java-1.8.0-openjdk-devel
|
||||||
fi
|
fi
|
||||||
|
67
install.sh
67
install.sh
@ -31,6 +31,8 @@ Options:
|
|||||||
--prefix /prefix directory prefix (default /usr)
|
--prefix /prefix directory prefix (default /usr)
|
||||||
--nonroot shortcut of '--disttype nonroot'
|
--nonroot shortcut of '--disttype nonroot'
|
||||||
--sysconfdir /etc/sysconfig specify sysconfig directory name
|
--sysconfdir /etc/sysconfig specify sysconfig directory name
|
||||||
|
--packaging use install.sh for packaging
|
||||||
|
--without-systemd skip installing systemd units
|
||||||
--help this helpful message
|
--help this helpful message
|
||||||
EOF
|
EOF
|
||||||
exit 1
|
exit 1
|
||||||
@ -39,6 +41,8 @@ EOF
|
|||||||
root=/
|
root=/
|
||||||
sysconfdir=/etc/sysconfig
|
sysconfdir=/etc/sysconfig
|
||||||
nonroot=false
|
nonroot=false
|
||||||
|
packaging=false
|
||||||
|
without_systemd=false
|
||||||
|
|
||||||
while [ $# -gt 0 ]; do
|
while [ $# -gt 0 ]; do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
@ -58,6 +62,14 @@ while [ $# -gt 0 ]; do
|
|||||||
sysconfdir="$2"
|
sysconfdir="$2"
|
||||||
shift 2
|
shift 2
|
||||||
;;
|
;;
|
||||||
|
"--packaging")
|
||||||
|
packaging=true
|
||||||
|
shift 1
|
||||||
|
;;
|
||||||
|
"--without-systemd")
|
||||||
|
without_systemd=true
|
||||||
|
shift 1
|
||||||
|
;;
|
||||||
"--help")
|
"--help")
|
||||||
shift 1
|
shift 1
|
||||||
print_usage
|
print_usage
|
||||||
@ -68,6 +80,23 @@ while [ $# -gt 0 ]; do
|
|||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
|
check_usermode_support() {
|
||||||
|
user=$(systemctl --help|grep -e '--user')
|
||||||
|
[ -n "$user" ]
|
||||||
|
}
|
||||||
|
|
||||||
|
if ! $packaging; then
|
||||||
|
has_java=false
|
||||||
|
if [ -x /usr/bin/java ]; then
|
||||||
|
javaver=$(/usr/bin/java -version 2>&1|head -n1|cut -f 3 -d " ")
|
||||||
|
has_java=true
|
||||||
|
fi
|
||||||
|
if ! $has_java; then
|
||||||
|
echo "Please install openjdk-8, openjdk-11, or openjdk-17 before running install.sh."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
if [ -z "$prefix" ]; then
|
if [ -z "$prefix" ]; then
|
||||||
if $nonroot; then
|
if $nonroot; then
|
||||||
prefix=~/scylladb
|
prefix=~/scylladb
|
||||||
@ -85,16 +114,20 @@ if ! $nonroot; then
|
|||||||
else
|
else
|
||||||
retc="$rprefix/etc"
|
retc="$rprefix/etc"
|
||||||
rsysconfdir="$rprefix/$sysconfdir"
|
rsysconfdir="$rprefix/$sysconfdir"
|
||||||
rsystemd="$retc/systemd"
|
rsystemd="$HOME/.config/systemd/user"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
install -d -m755 "$rsysconfdir"
|
install -d -m755 "$rsysconfdir"
|
||||||
install -d -m755 "$rsystemd"
|
if ! $without_systemd; then
|
||||||
|
install -d -m755 "$rsystemd"
|
||||||
|
fi
|
||||||
install -d -m755 "$rprefix/scripts" "$rprefix/jmx" "$rprefix/jmx/symlinks"
|
install -d -m755 "$rprefix/scripts" "$rprefix/jmx" "$rprefix/jmx/symlinks"
|
||||||
|
|
||||||
install -m644 dist/common/sysconfig/scylla-jmx -Dt "$rsysconfdir"
|
install -m644 dist/common/sysconfig/scylla-jmx -Dt "$rsysconfdir"
|
||||||
install -m644 dist/common/systemd/scylla-jmx.service -Dt "$rsystemd"
|
if ! $without_systemd; then
|
||||||
if ! $nonroot; then
|
install -m644 dist/common/systemd/scylla-jmx.service -Dt "$rsystemd"
|
||||||
|
fi
|
||||||
|
if ! $nonroot && ! $without_systemd; then
|
||||||
if [ "$sysconfdir" != "/etc/sysconfig" ]; then
|
if [ "$sysconfdir" != "/etc/sysconfig" ]; then
|
||||||
install -d -m755 "$retc"/systemd/system/scylla-jmx.service.d
|
install -d -m755 "$retc"/systemd/system/scylla-jmx.service.d
|
||||||
cat << EOS > "$retc"/systemd/system/scylla-jmx.service.d/sysconfdir.conf
|
cat << EOS > "$retc"/systemd/system/scylla-jmx.service.d/sysconfdir.conf
|
||||||
@ -103,9 +136,9 @@ EnvironmentFile=
|
|||||||
EnvironmentFile=$sysconfdir/scylla-jmx
|
EnvironmentFile=$sysconfdir/scylla-jmx
|
||||||
EOS
|
EOS
|
||||||
fi
|
fi
|
||||||
else
|
elif ! $without_systemd; then
|
||||||
install -d -m755 "$retc"/systemd/system/scylla-jmx.service.d
|
install -d -m755 "$rsystemd"/scylla-jmx.service.d
|
||||||
cat << EOS > "$retc"/systemd/system/scylla-jmx.service.d/nonroot.conf
|
cat << EOS > "$rsystemd"/scylla-jmx.service.d/nonroot.conf
|
||||||
[Service]
|
[Service]
|
||||||
EnvironmentFile=
|
EnvironmentFile=
|
||||||
EnvironmentFile=$retc/sysconfig/scylla-jmx
|
EnvironmentFile=$retc/sysconfig/scylla-jmx
|
||||||
@ -113,24 +146,28 @@ ExecStart=
|
|||||||
ExecStart=$rprefix/jmx/scylla-jmx \$SCYLLA_JMX_PORT \$SCYLLA_API_PORT \$SCYLLA_API_ADDR \$SCYLLA_JMX_ADDR \$SCYLLA_JMX_FILE \$SCYLLA_JMX_LOCAL \$SCYLLA_JMX_REMOTE \$SCYLLA_JMX_DEBUG
|
ExecStart=$rprefix/jmx/scylla-jmx \$SCYLLA_JMX_PORT \$SCYLLA_API_PORT \$SCYLLA_API_ADDR \$SCYLLA_JMX_ADDR \$SCYLLA_JMX_FILE \$SCYLLA_JMX_LOCAL \$SCYLLA_JMX_REMOTE \$SCYLLA_JMX_DEBUG
|
||||||
User=
|
User=
|
||||||
Group=
|
Group=
|
||||||
|
WorkingDirectory=$rprefix
|
||||||
EOS
|
EOS
|
||||||
if [ ! -d ~/.config/systemd/user/scylla-jmx.service.d ]; then
|
|
||||||
mkdir -p ~/.config/systemd/user/scylla-jmx.service.d
|
|
||||||
fi
|
|
||||||
ln -srf $rsystemd/scylla-jmx.service ~/.config/systemd/user/
|
|
||||||
ln -srf "$retc"/systemd/system/scylla-jmx.service.d/nonroot.conf ~/.config/systemd/user/scylla-jmx.service.d
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
install -m644 scylla-jmx-1.0.jar "$rprefix/jmx"
|
install -m644 scylla-jmx-1.1.jar "$rprefix/jmx"
|
||||||
install -m755 scylla-jmx "$rprefix/jmx"
|
install -m755 scylla-jmx "$rprefix/jmx"
|
||||||
ln -sf /usr/bin/java "$rprefix/jmx/symlinks/scylla-jmx"
|
ln -sf /usr/bin/java "$rprefix/jmx/symlinks/scylla-jmx"
|
||||||
# create symlink for /usr/lib/scylla/jmx
|
if ! $nonroot; then
|
||||||
ln -srf $rprefix/jmx "$rprefix/scripts/"
|
install -m755 -d "$rusr"/lib/scylla/jmx/symlinks
|
||||||
|
ln -srf "$rprefix"/jmx/scylla-jmx-1.1.jar "$rusr"/lib/scylla/jmx/
|
||||||
|
ln -srf "$rprefix"/jmx/scylla-jmx "$rusr"/lib/scylla/jmx/
|
||||||
|
ln -sf /usr/bin/java "$rusr"/lib/scylla/jmx/symlinks/scylla-jmx
|
||||||
|
fi
|
||||||
|
|
||||||
if $nonroot; then
|
if $nonroot; then
|
||||||
sed -i -e "s#/var/lib/scylla#$rprefix#g" "$rsysconfdir"/scylla-jmx
|
sed -i -e "s#/var/lib/scylla#$rprefix#g" "$rsysconfdir"/scylla-jmx
|
||||||
sed -i -e "s#/etc/scylla#$rprefix/etc/scylla#g" "$rsysconfdir"/scylla-jmx
|
sed -i -e "s#/etc/scylla#$rprefix/etc/scylla#g" "$rsysconfdir"/scylla-jmx
|
||||||
sed -i -e "s#/opt/scylladb/jmx#$rprefix/jmx#g" "$rsysconfdir"/scylla-jmx
|
sed -i -e "s#/opt/scylladb/jmx#$rprefix/jmx#g" "$rsysconfdir"/scylla-jmx
|
||||||
|
if ! $without_systemd && check_usermode_support; then
|
||||||
systemctl --user daemon-reload
|
systemctl --user daemon-reload
|
||||||
|
fi
|
||||||
echo "Scylla-JMX non-root install completed."
|
echo "Scylla-JMX non-root install completed."
|
||||||
|
elif ! $without_systemd && ! $packaging; then
|
||||||
|
systemctl --system daemon-reload
|
||||||
fi
|
fi
|
||||||
|
78
pom.xml
78
pom.xml
@ -2,59 +2,81 @@
|
|||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
<groupId>com.scylladb.jmx</groupId>
|
|
||||||
<artifactId>scylla-jmx</artifactId>
|
<artifactId>scylla-jmx</artifactId>
|
||||||
<version>1.0</version>
|
<version>1.1</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>com.scylladb.jmx</groupId>
|
<groupId>it.cavallium.scylladb.jmx</groupId>
|
||||||
<artifactId>scylla-jmx-parent</artifactId>
|
<artifactId>scylla-jmx-parent</artifactId>
|
||||||
<version>1.0</version>
|
<version>1.1</version>
|
||||||
<relativePath>./scylla-jmx-parent/pom.xml</relativePath>
|
<relativePath>./scylla-jmx-parent/pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<name>Scylla JMX</name>
|
<name>Scylla JMX</name>
|
||||||
|
|
||||||
<properties>
|
|
||||||
<maven.compiler.target>1.8</maven.compiler.target>
|
|
||||||
<maven.compiler.source>1.8</maven.compiler.source>
|
|
||||||
</properties>
|
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.scylladb.jmx</groupId>
|
<groupId>it.cavallium.scylladb.jmx</groupId>
|
||||||
<artifactId>scylla-apiclient</artifactId>
|
<artifactId>scylla-apiclient</artifactId>
|
||||||
<version>1.0</version>
|
<version>1.1</version>
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.slf4j</groupId>
|
|
||||||
<artifactId>slf4j-api</artifactId>
|
|
||||||
<version>1.7.5</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.slf4j</groupId>
|
|
||||||
<artifactId>slf4j-simple</artifactId>
|
|
||||||
<version>1.6.4</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.slf4j</groupId>
|
|
||||||
<artifactId>slf4j-log4j12</artifactId>
|
|
||||||
<version>1.7.5</version>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>junit</groupId>
|
<groupId>junit</groupId>
|
||||||
<artifactId>junit</artifactId>
|
<artifactId>junit</artifactId>
|
||||||
<version>4.8.2</version>
|
<version>4.13.1</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<build>
|
<build>
|
||||||
<plugins>
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<version>3.10.1</version>
|
||||||
|
<configuration>
|
||||||
|
<source>11</source>
|
||||||
|
<target>11</target>
|
||||||
|
<compilerArgs>
|
||||||
|
<arg>--add-exports</arg>
|
||||||
|
<arg>java.management/com.sun.jmx.mbeanserver=scylla.jmx</arg>
|
||||||
|
<arg>--add-exports</arg>
|
||||||
|
<arg>java.management/com.sun.jmx.interceptor=scylla.jmx</arg>
|
||||||
|
</compilerArgs>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-shade-plugin</artifactId>
|
<artifactId>maven-shade-plugin</artifactId>
|
||||||
<version>2.4.1</version>
|
<version>3.4.1</version>
|
||||||
|
<configuration>
|
||||||
|
<artifactSet>
|
||||||
|
<includes>
|
||||||
|
<include>*:*</include>
|
||||||
|
</includes>
|
||||||
|
<excludes>
|
||||||
|
<exclude>com.sun.activation:jakarta.activation</exclude>
|
||||||
|
</excludes>
|
||||||
|
</artifactSet>
|
||||||
|
<filters>
|
||||||
|
<filter>
|
||||||
|
<artifact>*:*</artifact>
|
||||||
|
<excludes>
|
||||||
|
<exclude>module-info.class</exclude>
|
||||||
|
<exclude>META-INF/versions/*/module-info.class</exclude>
|
||||||
|
<exclude>META-INF/*.SF</exclude>
|
||||||
|
<exclude>META-INF/*.DSA</exclude>
|
||||||
|
<exclude>META-INF/*.RSA</exclude>
|
||||||
|
<exclude>META-INF/MANIFEST.MF</exclude>
|
||||||
|
<exclude>META-INF/*.MD</exclude>
|
||||||
|
<exclude>META-INF/*.md</exclude>
|
||||||
|
<exclude>META-INF/LICENSE</exclude>
|
||||||
|
<exclude>META-INF/LICENSE.txt</exclude>
|
||||||
|
<exclude>META-INF/NOTICE</exclude>
|
||||||
|
</excludes>
|
||||||
|
</filter>
|
||||||
|
</filters>
|
||||||
|
</configuration>
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<phase>package</phase>
|
<phase>package</phase>
|
||||||
|
@ -1,31 +1,42 @@
|
|||||||
#!/bin/bash -e
|
#!/bin/bash -e
|
||||||
|
|
||||||
. /etc/os-release
|
|
||||||
print_usage() {
|
print_usage() {
|
||||||
echo "build_deb.sh --reloc-pkg build/scylla-jmx-package.tar.gz"
|
echo "build_deb.sh --reloc-pkg build/scylla-jmx-package.tar.gz"
|
||||||
echo " --reloc-pkg specify relocatable package path"
|
echo " --reloc-pkg specify relocatable package path"
|
||||||
|
echo " --builddir specify Debian package build path"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
RELOC_PKG=$(readlink -f build/scylla-jmx-package.tar.gz)
|
RELOC_PKG=build/scylla-jmx-package.tar.gz
|
||||||
OPTS=""
|
BUILDDIR=build/debian
|
||||||
while [ $# -gt 0 ]; do
|
while [ $# -gt 0 ]; do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
"--reloc-pkg")
|
"--reloc-pkg")
|
||||||
OPTS="$OPTS $1 $(readlink -f $2)"
|
|
||||||
RELOC_PKG=$2
|
RELOC_PKG=$2
|
||||||
shift 2
|
shift 2
|
||||||
;;
|
;;
|
||||||
|
"--builddir")
|
||||||
|
BUILDDIR="$2"
|
||||||
|
shift 2
|
||||||
|
;;
|
||||||
*)
|
*)
|
||||||
print_usage
|
print_usage
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
if [[ ! $OPTS =~ --reloc-pkg ]]; then
|
RELOC_PKG=$(readlink -f $RELOC_PKG)
|
||||||
OPTS="$OPTS --reloc-pkg $RELOC_PKG"
|
rm -rf "$BUILDDIR"/scylla-package "$BUILDDIR"/scylla-package.orig "$BUILDDIR"/debian
|
||||||
fi
|
mkdir -p "$BUILDDIR"/scylla-package
|
||||||
mkdir -p build/debian/scylla-package
|
tar -C "$BUILDDIR"/scylla-package -xpf $RELOC_PKG
|
||||||
tar -C build/debian/scylla-package -xpf $RELOC_PKG
|
cd "$BUILDDIR"/scylla-package
|
||||||
cd build/debian/scylla-package
|
|
||||||
exec ./dist/debian/build_deb.sh $OPTS
|
RELOC_PKG=$(readlink -f $RELOC_PKG)
|
||||||
|
|
||||||
|
mv scylla-jmx/debian debian
|
||||||
|
PKG_NAME=$(dpkg-parsechangelog --show-field Source)
|
||||||
|
# XXX: Drop revision number from version string.
|
||||||
|
# Since it always '1', this should be okay for now.
|
||||||
|
PKG_VERSION=$(dpkg-parsechangelog --show-field Version |sed -e 's/-1$//')
|
||||||
|
ln -fv $RELOC_PKG ../"$PKG_NAME"_"$PKG_VERSION".orig.tar.gz
|
||||||
|
debuild -rfakeroot -us -uc
|
||||||
|
@ -6,11 +6,13 @@ print_usage() {
|
|||||||
echo "build_reloc.sh --clean --nodeps"
|
echo "build_reloc.sh --clean --nodeps"
|
||||||
echo " --clean clean build directory"
|
echo " --clean clean build directory"
|
||||||
echo " --nodeps skip installing dependencies"
|
echo " --nodeps skip installing dependencies"
|
||||||
|
echo " --version V product-version-release string (overriding SCYLLA-VERSION-GEN)"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
CLEAN=
|
CLEAN=
|
||||||
NODEPS=
|
NODEPS=
|
||||||
|
VERSION_OVERRIDE=
|
||||||
while [ $# -gt 0 ]; do
|
while [ $# -gt 0 ]; do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
"--clean")
|
"--clean")
|
||||||
@ -21,12 +23,22 @@ while [ $# -gt 0 ]; do
|
|||||||
NODEPS=yes
|
NODEPS=yes
|
||||||
shift 1
|
shift 1
|
||||||
;;
|
;;
|
||||||
|
"--version")
|
||||||
|
VERSION_OVERRIDE="$2"
|
||||||
|
shift 2
|
||||||
|
;;
|
||||||
*)
|
*)
|
||||||
print_usage
|
print_usage
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
|
VERSION=$(./SCYLLA-VERSION-GEN ${VERSION_OVERRIDE:+ --version "$VERSION_OVERRIDE"})
|
||||||
|
# the former command should generate build/SCYLLA-PRODUCT-FILE and some other version
|
||||||
|
# related files
|
||||||
|
PRODUCT=`cat build/SCYLLA-PRODUCT-FILE`
|
||||||
|
DEST="build/$PRODUCT-jmx-$VERSION.noarch.tar.gz"
|
||||||
|
|
||||||
is_redhat_variant() {
|
is_redhat_variant() {
|
||||||
[ -f /etc/redhat-release ]
|
[ -f /etc/redhat-release ]
|
||||||
}
|
}
|
||||||
@ -44,8 +56,8 @@ if [ "$CLEAN" = "yes" ]; then
|
|||||||
rm -rf build target
|
rm -rf build target
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -f build/scylla-jmx-package.tar.gz ]; then
|
if [ -f "$DEST" ]; then
|
||||||
rm build/scylla-jmx-package.tar.gz
|
rm "$DEST"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z "$NODEPS" ]; then
|
if [ -z "$NODEPS" ]; then
|
||||||
@ -53,5 +65,6 @@ if [ -z "$NODEPS" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
mvn -B --file scylla-jmx-parent/pom.xml install
|
mvn -B --file scylla-jmx-parent/pom.xml install
|
||||||
./SCYLLA-VERSION-GEN
|
./SCYLLA-VERSION-GEN ${VERSION_OVERRIDE:+ --version "$VERSION_OVERRIDE"}
|
||||||
scripts/create-relocatable-package.py build/scylla-jmx-package.tar.gz
|
./dist/debian/debian_files_gen.py
|
||||||
|
scripts/create-relocatable-package.py "$DEST"
|
||||||
|
@ -1,30 +1,52 @@
|
|||||||
#!/bin/bash -e
|
#!/bin/bash -e
|
||||||
|
|
||||||
. /etc/os-release
|
|
||||||
print_usage() {
|
print_usage() {
|
||||||
echo "build_rpm.sh --reloc-pkg build/scylla-jmx-package.tar.gz"
|
echo "build_rpm.sh --reloc-pkg build/scylla-jmx-package.tar.gz"
|
||||||
echo " --reloc-pkg specify relocatable package path"
|
echo " --reloc-pkg specify relocatable package path"
|
||||||
|
echo " --builddir specify rpmbuild directory"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
RELOC_PKG=$(readlink -f build/scylla-jmx-package.tar.gz)
|
RELOC_PKG=build/scylla-jmx-package.tar.gz
|
||||||
OPTS=""
|
BUILDDIR=build/redhat
|
||||||
while [ $# -gt 0 ]; do
|
while [ $# -gt 0 ]; do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
"--reloc-pkg")
|
"--reloc-pkg")
|
||||||
OPTS="$OPTS $1 $(readlink -f $2)"
|
|
||||||
RELOC_PKG=$2
|
RELOC_PKG=$2
|
||||||
shift 2
|
shift 2
|
||||||
;;
|
;;
|
||||||
|
"--builddir")
|
||||||
|
BUILDDIR="$2"
|
||||||
|
shift 2
|
||||||
|
;;
|
||||||
*)
|
*)
|
||||||
print_usage
|
print_usage
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
if [[ ! $OPTS =~ --reloc-pkg ]]; then
|
RELOC_PKG=$(readlink -f $RELOC_PKG)
|
||||||
OPTS="$OPTS --reloc-pkg $RELOC_PKG"
|
RPMBUILD=$(readlink -f $BUILDDIR)
|
||||||
fi
|
mkdir -p "$BUILDDIR"
|
||||||
mkdir -p build/redhat/scylla-package
|
tar -C "$BUILDDIR" -xpf $RELOC_PKG scylla-jmx/SCYLLA-RELEASE-FILE scylla-jmx/SCYLLA-RELOCATABLE-FILE scylla-jmx/SCYLLA-VERSION-FILE scylla-jmx/SCYLLA-PRODUCT-FILE scylla-jmx/dist/redhat
|
||||||
tar -C build/redhat/scylla-package -xpf $RELOC_PKG SCYLLA-RELEASE-FILE SCYLLA-RELOCATABLE-FILE SCYLLA-VERSION-FILE SCYLLA-PRODUCT-FILE dist/redhat
|
cd "$BUILDDIR"/scylla-jmx
|
||||||
cd build/redhat/scylla-package
|
|
||||||
exec ./dist/redhat/build_rpm.sh $OPTS
|
RELOC_PKG_BASENAME=$(basename "$RELOC_PKG")
|
||||||
|
SCYLLA_VERSION=$(cat SCYLLA-VERSION-FILE)
|
||||||
|
SCYLLA_RELEASE=$(cat SCYLLA-RELEASE-FILE)
|
||||||
|
VERSION=$SCYLLA_VERSION-$SCYLLA_RELEASE
|
||||||
|
PRODUCT=$(cat SCYLLA-PRODUCT-FILE)
|
||||||
|
|
||||||
|
mkdir -p $RPMBUILD/{BUILD,BUILDROOT,RPMS,SOURCES,SPECS,SRPMS}
|
||||||
|
|
||||||
|
ln -fv $RELOC_PKG $RPMBUILD/SOURCES/
|
||||||
|
|
||||||
|
parameters=(
|
||||||
|
-D"version $SCYLLA_VERSION"
|
||||||
|
-D"release $SCYLLA_RELEASE"
|
||||||
|
-D"product $PRODUCT"
|
||||||
|
-D"reloc_pkg $RELOC_PKG_BASENAME"
|
||||||
|
)
|
||||||
|
|
||||||
|
cp dist/redhat/scylla-jmx.spec $RPMBUILD/SPECS
|
||||||
|
# this rpm can be install on both fedora / centos7, so drop distribution name from the file name
|
||||||
|
rpmbuild -ba "${parameters[@]}" --define '_binary_payload w2.xzdio' --define "_topdir $RPMBUILD" --undefine "dist" $RPMBUILD/SPECS/scylla-jmx.spec
|
||||||
|
@ -27,6 +27,14 @@ import os
|
|||||||
import tarfile
|
import tarfile
|
||||||
import pathlib
|
import pathlib
|
||||||
|
|
||||||
|
RELOC_PREFIX='scylla-jmx'
|
||||||
|
def reloc_add(self, name, arcname=None, recursive=True, *, filter=None):
|
||||||
|
if arcname:
|
||||||
|
return self.add(name, arcname="{}/{}".format(RELOC_PREFIX, arcname))
|
||||||
|
else:
|
||||||
|
return self.add(name, arcname="{}/{}".format(RELOC_PREFIX, name))
|
||||||
|
|
||||||
|
tarfile.TarFile.reloc_add = reloc_add
|
||||||
|
|
||||||
ap = argparse.ArgumentParser(description='Create a relocatable scylla package.')
|
ap = argparse.ArgumentParser(description='Create a relocatable scylla package.')
|
||||||
ap.add_argument('dest',
|
ap.add_argument('dest',
|
||||||
@ -37,14 +45,20 @@ args = ap.parse_args()
|
|||||||
output = args.dest
|
output = args.dest
|
||||||
|
|
||||||
ar = tarfile.open(output, mode='w|gz')
|
ar = tarfile.open(output, mode='w|gz')
|
||||||
|
# relocatable package format version = 2.2
|
||||||
|
with open('build/.relocatable_package_version', 'w') as f:
|
||||||
|
f.write('2.2\n')
|
||||||
|
ar.add('build/.relocatable_package_version', arcname='.relocatable_package_version')
|
||||||
|
|
||||||
pathlib.Path('build/SCYLLA-RELOCATABLE-FILE').touch()
|
pathlib.Path('build/SCYLLA-RELOCATABLE-FILE').touch()
|
||||||
ar.add('build/SCYLLA-RELOCATABLE-FILE', arcname='SCYLLA-RELOCATABLE-FILE')
|
ar.reloc_add('build/SCYLLA-RELOCATABLE-FILE', arcname='SCYLLA-RELOCATABLE-FILE')
|
||||||
ar.add('build/SCYLLA-RELEASE-FILE', arcname='SCYLLA-RELEASE-FILE')
|
ar.reloc_add('build/SCYLLA-RELEASE-FILE', arcname='SCYLLA-RELEASE-FILE')
|
||||||
ar.add('build/SCYLLA-VERSION-FILE', arcname='SCYLLA-VERSION-FILE')
|
ar.reloc_add('build/SCYLLA-VERSION-FILE', arcname='SCYLLA-VERSION-FILE')
|
||||||
ar.add('build/SCYLLA-PRODUCT-FILE', arcname='SCYLLA-PRODUCT-FILE')
|
ar.reloc_add('build/SCYLLA-PRODUCT-FILE', arcname='SCYLLA-PRODUCT-FILE')
|
||||||
ar.add('dist')
|
ar.reloc_add('dist')
|
||||||
ar.add('install.sh')
|
ar.reloc_add('install.sh')
|
||||||
ar.add('target/scylla-jmx-1.0.jar', arcname='scylla-jmx-1.0.jar')
|
ar.reloc_add('target/scylla-jmx-1.1.jar', arcname='scylla-jmx-1.1.jar')
|
||||||
ar.add('scripts/scylla-jmx', arcname='scylla-jmx')
|
ar.reloc_add('scripts/scylla-jmx', arcname='scylla-jmx')
|
||||||
ar.add('README.md')
|
ar.reloc_add('README.md')
|
||||||
ar.add('NOTICE')
|
ar.reloc_add('NOTICE')
|
||||||
|
ar.reloc_add('build/debian/debian', arcname='debian')
|
||||||
|
@ -131,11 +131,13 @@ else
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
exec "$LOCATION_SCRIPTS"/symlinks/scylla-jmx $DEBUG \
|
"$LOCATION_SCRIPTS"/symlinks/scylla-jmx $DEBUG \
|
||||||
$API_PORT $API_ADDR $CONF_FILE -Xmx256m -XX:+UseSerialGC \
|
$API_PORT $API_ADDR $CONF_FILE -Xmx256m -XX:+UseSerialGC \
|
||||||
-XX:+HeapDumpOnOutOfMemoryError \
|
-XX:+HeapDumpOnOutOfMemoryError \
|
||||||
$JMX_AUTH $JMX_SSL $JMX_ADDR $JMX_LOCAL \
|
$JMX_AUTH $JMX_SSL $JMX_ADDR $JMX_LOCAL \
|
||||||
|
--add-exports java.management/com.sun.jmx.mbeanserver=ALL-UNNAMED \
|
||||||
|
--add-exports java.management/com.sun.jmx.interceptor=ALL-UNNAMED \
|
||||||
-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=$JMX_PORT \
|
-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=$JMX_PORT \
|
||||||
-Djava.rmi.server.hostname=$HOSTNAME -Dcom.sun.management.jmxremote.rmi.port=$JMX_PORT \
|
-Djava.rmi.server.hostname=$HOSTNAME -Dcom.sun.management.jmxremote.rmi.port=$JMX_PORT \
|
||||||
-Djavax.management.builder.initial=com.scylladb.jmx.utils.APIBuilder \
|
-Djavax.management.builder.initial=com.scylladb.jmx.utils.APIBuilder \
|
||||||
$PROPERTIES -jar $LOCATION/scylla-jmx-1.0.jar
|
$PROPERTIES -jar $LOCATION/scylla-jmx-1.1.jar
|
||||||
|
@ -1,24 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
|
||||||
<parent>
|
|
||||||
<artifactId>scylla-jmx</artifactId>
|
|
||||||
<groupId>com.scylladb.jmx</groupId>
|
|
||||||
<version>1.0</version>
|
|
||||||
</parent>
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
<artifactId>scylla-apiclient</artifactId>
|
|
||||||
<name>Scylla REST API client</name>
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>junit</groupId>
|
|
||||||
<artifactId>junit</artifactId>
|
|
||||||
<version>4.8.2</version>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
<properties>
|
|
||||||
<maven.compiler.source>1.8</maven.compiler.source>
|
|
||||||
<maven.compiler.target>1.8</maven.compiler.target>
|
|
||||||
</properties>
|
|
||||||
</project>
|
|
||||||
|
|
@ -1,84 +1,99 @@
|
|||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
<groupId>com.scylladb.jmx</groupId>
|
|
||||||
<artifactId>scylla-apiclient</artifactId>
|
<artifactId>scylla-apiclient</artifactId>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
<version>1.0</version>
|
<version>1.1</version>
|
||||||
|
|
||||||
|
<parent>
|
||||||
|
<relativePath>../scylla-jmx-parent/pom.xml</relativePath>
|
||||||
|
<groupId>it.cavallium.scylladb.jmx</groupId>
|
||||||
|
<artifactId>scylla-jmx-parent</artifactId>
|
||||||
|
<version>1.1</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
<name>Scylla REST API client</name>
|
<name>Scylla REST API client</name>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<maven.compiler.target>1.8</maven.compiler.target>
|
<jackson.version>2.14.0</jackson.version>
|
||||||
<maven.compiler.source>1.8</maven.compiler.source>
|
<jackson.databind.version>2.14.0</jackson.databind.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.eclipse.parsson</groupId>
|
||||||
|
<artifactId>parsson</artifactId>
|
||||||
|
<version>1.1.1</version>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.yaml</groupId>
|
<groupId>org.yaml</groupId>
|
||||||
<artifactId>snakeyaml</artifactId>
|
<artifactId>snakeyaml</artifactId>
|
||||||
<version>1.16</version>
|
<version>1.33</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.glassfish.jersey.core</groupId>
|
<groupId>org.glassfish.jersey.core</groupId>
|
||||||
<artifactId>jersey-common</artifactId>
|
<artifactId>jersey-common</artifactId>
|
||||||
<version>2.22.1</version>
|
<version>3.1.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>javax.ws.rs</groupId>
|
<groupId>jakarta.ws.rs</groupId>
|
||||||
<artifactId>javax.ws.rs-api</artifactId>
|
<artifactId>jakarta.ws.rs-api</artifactId>
|
||||||
<version>2.0.1</version>
|
<version>3.1.0</version>
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>javax.ws.rs</groupId>
|
|
||||||
<artifactId>jsr311-api</artifactId>
|
|
||||||
<version>1.1.1</version>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.glassfish.jersey.core</groupId>
|
<groupId>org.glassfish.jersey.core</groupId>
|
||||||
<artifactId>jersey-client</artifactId>
|
<artifactId>jersey-client</artifactId>
|
||||||
<version>2.22.1</version>
|
<version>3.1.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.glassfish</groupId>
|
<groupId>org.glassfish.jersey.inject</groupId>
|
||||||
<artifactId>javax.json</artifactId>
|
<artifactId>jersey-hk2</artifactId>
|
||||||
<version>1.0.4</version>
|
<version>3.1.0</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>jakarta.json</groupId>
|
||||||
|
<artifactId>jakarta.json-api</artifactId>
|
||||||
|
<version>2.1.1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.google.guava</groupId>
|
<groupId>com.google.guava</groupId>
|
||||||
<artifactId>guava</artifactId>
|
<artifactId>guava</artifactId>
|
||||||
<version>18.0</version>
|
<version>31.1-jre</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.google.collections</groupId>
|
<groupId>jakarta.activation</groupId>
|
||||||
<artifactId>google-collections</artifactId>
|
<artifactId>jakarta.activation-api</artifactId>
|
||||||
<version>1.0</version>
|
<version>2.1.1</version>
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>javax.activation</groupId>
|
|
||||||
<artifactId>activation</artifactId>
|
|
||||||
<version>1.1</version>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.fasterxml.jackson.core</groupId>
|
<groupId>com.fasterxml.jackson.core</groupId>
|
||||||
<artifactId>jackson-annotations</artifactId>
|
<artifactId>jackson-annotations</artifactId>
|
||||||
<version>2.9.9</version>
|
<version>${jackson.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.fasterxml.jackson.core</groupId>
|
<groupId>com.fasterxml.jackson.core</groupId>
|
||||||
<artifactId>jackson-databind</artifactId>
|
<artifactId>jackson-databind</artifactId>
|
||||||
<version>2.9.10.1</version>
|
<version>${jackson.databind.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.fasterxml.jackson.jaxrs</groupId>
|
<groupId>com.fasterxml.jackson.jakarta.rs</groupId>
|
||||||
<artifactId>jackson-jaxrs-json-provider</artifactId>
|
<artifactId>jackson-jakarta-rs-json-provider</artifactId>
|
||||||
<version>2.9.9</version>
|
<version>2.14.1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<version>3.10.1</version>
|
||||||
|
<configuration>
|
||||||
|
<release>11</release>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
@ -3,7 +3,24 @@
|
|||||||
*/
|
*/
|
||||||
package com.scylladb.jmx.api;
|
package com.scylladb.jmx.api;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.jakarta.rs.json.JacksonJsonProvider;
|
||||||
|
import jakarta.json.Json;
|
||||||
|
import jakarta.json.JsonArray;
|
||||||
|
import jakarta.json.JsonObject;
|
||||||
|
import jakarta.json.JsonReader;
|
||||||
|
import jakarta.json.JsonReaderFactory;
|
||||||
|
import jakarta.json.JsonString;
|
||||||
|
import jakarta.ws.rs.ProcessingException;
|
||||||
|
import jakarta.ws.rs.client.Client;
|
||||||
|
import jakarta.ws.rs.client.ClientBuilder;
|
||||||
|
import jakarta.ws.rs.client.Entity;
|
||||||
|
import jakarta.ws.rs.client.Invocation;
|
||||||
|
import jakarta.ws.rs.client.WebTarget;
|
||||||
|
import jakarta.ws.rs.core.MediaType;
|
||||||
|
import jakarta.ws.rs.core.MultivaluedMap;
|
||||||
|
import jakarta.ws.rs.core.Response;
|
||||||
import java.io.StringReader;
|
import java.io.StringReader;
|
||||||
|
import java.lang.System.Logger.Level;
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.net.UnknownHostException;
|
import java.net.UnknownHostException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -18,31 +35,28 @@ import java.util.Set;
|
|||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import javax.json.Json;
|
|
||||||
import javax.json.JsonArray;
|
|
||||||
import javax.json.JsonObject;
|
|
||||||
import javax.json.JsonReader;
|
|
||||||
import javax.json.JsonReaderFactory;
|
|
||||||
import javax.json.JsonString;
|
|
||||||
import javax.management.openmbean.TabularData;
|
import javax.management.openmbean.TabularData;
|
||||||
import javax.management.openmbean.TabularDataSupport;
|
import javax.management.openmbean.TabularDataSupport;
|
||||||
import javax.ws.rs.ProcessingException;
|
|
||||||
import javax.ws.rs.client.Client;
|
|
||||||
import javax.ws.rs.client.ClientBuilder;
|
|
||||||
import javax.ws.rs.client.Entity;
|
|
||||||
import javax.ws.rs.client.Invocation;
|
|
||||||
import javax.ws.rs.client.WebTarget;
|
|
||||||
import javax.ws.rs.core.MediaType;
|
|
||||||
import javax.ws.rs.core.MultivaluedMap;
|
|
||||||
import javax.ws.rs.core.Response;
|
|
||||||
|
|
||||||
import org.glassfish.jersey.client.ClientConfig;
|
import org.glassfish.jersey.client.ClientConfig;
|
||||||
|
|
||||||
import com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider;
|
import com.scylladb.jmx.api.utils.SnapshotDetailsTabularData;
|
||||||
import com.scylladb.jmx.utils.SnapshotDetailsTabularData;
|
|
||||||
|
|
||||||
public class APIClient {
|
public class APIClient {
|
||||||
private Map<String, CacheEntry> cache = new HashMap<String, CacheEntry>();
|
private Map<String, CacheEntry> cache = new HashMap<String, CacheEntry>();
|
||||||
|
private final APIConfig config;
|
||||||
|
private final ClientConfig clientConfig;
|
||||||
|
private final Client client;
|
||||||
|
private JsonReaderFactory factory = Json.createReaderFactory(null);
|
||||||
|
|
||||||
|
private static final Logger logger = Logger.getLogger(APIClient.class.getName());
|
||||||
|
|
||||||
|
public APIClient(APIConfig config) {
|
||||||
|
this.config = config;
|
||||||
|
this.clientConfig = new ClientConfig();
|
||||||
|
clientConfig.register(new JacksonJsonProvider());
|
||||||
|
this.client = ClientBuilder.newClient(clientConfig);
|
||||||
|
}
|
||||||
|
|
||||||
private String getCacheKey(String key, MultivaluedMap<String, String> param, long duration) {
|
private String getCacheKey(String key, MultivaluedMap<String, String> param, long duration) {
|
||||||
if (duration <= 0) {
|
if (duration <= 0) {
|
||||||
@ -75,24 +89,12 @@ public class APIClient {
|
|||||||
return (value != null && value.valid(duration)) ? value.jsonObject() : null;
|
return (value != null && value.valid(duration)) ? value.jsonObject() : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private JsonReaderFactory factory = Json.createReaderFactory(null);
|
|
||||||
private static final Logger logger = Logger.getLogger(APIClient.class.getName());
|
|
||||||
|
|
||||||
private final APIConfig config;
|
|
||||||
private final ClientConfig clientConfig;
|
|
||||||
|
|
||||||
public APIClient(APIConfig config) {
|
|
||||||
this.config = config;
|
|
||||||
this.clientConfig = new ClientConfig();
|
|
||||||
clientConfig.register(new JacksonJaxbJsonProvider());
|
|
||||||
}
|
|
||||||
|
|
||||||
private String getBaseUrl() {
|
private String getBaseUrl() {
|
||||||
return config.getBaseUrl();
|
return config.getBaseUrl();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Invocation.Builder get(String path, MultivaluedMap<String, String> queryParams) {
|
public Invocation.Builder get(String path, MultivaluedMap<String, String> queryParams) {
|
||||||
Client client = ClientBuilder.newClient(clientConfig);
|
|
||||||
WebTarget webTarget = client.target(getBaseUrl()).path(path);
|
WebTarget webTarget = client.target(getBaseUrl()).path(path);
|
||||||
if (queryParams != null) {
|
if (queryParams != null) {
|
||||||
for (Entry<String, List<String>> qp : queryParams.entrySet()) {
|
for (Entry<String, List<String>> qp : queryParams.entrySet()) {
|
||||||
|
@ -21,7 +21,8 @@
|
|||||||
|
|
||||||
package com.scylladb.jmx.api;
|
package com.scylladb.jmx.api;
|
||||||
|
|
||||||
import javax.json.JsonObject;
|
|
||||||
|
import jakarta.json.JsonObject;
|
||||||
|
|
||||||
class CacheEntry {
|
class CacheEntry {
|
||||||
private long time;
|
private long time;
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
* Modified by Cloudius Systems
|
* Modified by Cloudius Systems
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.scylladb.jmx.utils;
|
package com.scylladb.jmx.api.utils;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
@ -22,7 +22,7 @@
|
|||||||
* Modified by Cloudius Systems
|
* Modified by Cloudius Systems
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.scylladb.jmx.utils;
|
package com.scylladb.jmx.api.utils;
|
||||||
|
|
||||||
import com.google.common.base.Objects;
|
import com.google.common.base.Objects;
|
||||||
|
|
@ -20,7 +20,7 @@
|
|||||||
*
|
*
|
||||||
* Modified by Cloudius Systems
|
* Modified by Cloudius Systems
|
||||||
*/
|
*/
|
||||||
package com.scylladb.jmx.utils;
|
package com.scylladb.jmx.api.utils;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
15
scylla-apiclient/src/main/java/module-info.java
Normal file
15
scylla-apiclient/src/main/java/module-info.java
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
module scylla.apiclient {
|
||||||
|
exports com.scylladb.jmx.api;
|
||||||
|
exports com.scylladb.jmx.api.utils;
|
||||||
|
requires org.eclipse.parsson;
|
||||||
|
requires jakarta.ws.rs;
|
||||||
|
requires com.fasterxml.jackson.jakarta.rs.json;
|
||||||
|
requires jersey.client;
|
||||||
|
requires java.logging;
|
||||||
|
requires jakarta.json;
|
||||||
|
requires java.management;
|
||||||
|
requires org.yaml.snakeyaml;
|
||||||
|
requires com.google.common;
|
||||||
|
requires jersey.common;
|
||||||
|
requires jersey.hk2;
|
||||||
|
}
|
@ -2,9 +2,9 @@
|
|||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
<groupId>com.scylladb.jmx</groupId>
|
<groupId>it.cavallium.scylladb.jmx</groupId>
|
||||||
<artifactId>scylla-jmx-parent</artifactId>
|
<artifactId>scylla-jmx-parent</artifactId>
|
||||||
<version>1.0</version>
|
<version>1.1</version>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
|
|
||||||
<modules>
|
<modules>
|
||||||
@ -12,7 +12,18 @@
|
|||||||
<module>../scylla-apiclient</module>
|
<module>../scylla-apiclient</module>
|
||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<name>Scylla JMX Parent</name>
|
<name>Scylla JMX Parent</name>
|
||||||
|
|
||||||
|
<distributionManagement>
|
||||||
|
<repository>
|
||||||
|
<id>mchv-release-distribution</id>
|
||||||
|
<name>MCHV Release Apache Maven Packages Distribution</name>
|
||||||
|
<url>https://mvn.mchv.eu/repository/mchv</url>
|
||||||
|
</repository>
|
||||||
|
<snapshotRepository>
|
||||||
|
<id>mchv-snapshot-distribution</id>
|
||||||
|
<name>MCHV Snapshot Apache Maven Packages Distribution</name>
|
||||||
|
<url>https://mvn.mchv.eu/repository/mchv-snapshot</url>
|
||||||
|
</snapshotRepository>
|
||||||
|
</distributionManagement>
|
||||||
</project>
|
</project>
|
||||||
|
@ -27,12 +27,27 @@ import com.scylladb.jmx.api.APIConfig;
|
|||||||
import com.scylladb.jmx.metrics.APIMBean;
|
import com.scylladb.jmx.metrics.APIMBean;
|
||||||
|
|
||||||
public class Main {
|
public class Main {
|
||||||
// todo: command line options. Make us an agent class (also)
|
|
||||||
private static final APIConfig config = new APIConfig();
|
private static APIConfig config;
|
||||||
public static final APIClient client = new APIClient(config);
|
private static APIClient client;
|
||||||
|
|
||||||
|
public static synchronized APIConfig getApiConfig() {
|
||||||
|
if (config == null) {
|
||||||
|
config = new APIConfig();
|
||||||
|
}
|
||||||
|
return config;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static synchronized APIClient getApiClient() {
|
||||||
|
if (client == null) {
|
||||||
|
client = new APIClient(getApiConfig());
|
||||||
|
}
|
||||||
|
return client;
|
||||||
|
}
|
||||||
|
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
System.out.println("Connecting to " + config.getBaseUrl());
|
System.out.printf("Java %s%n", System.getProperty("java.version"));
|
||||||
|
System.out.printf("Connecting to %s%n", getApiConfig().getBaseUrl());
|
||||||
System.out.println("Starting the JMX server");
|
System.out.println("Starting the JMX server");
|
||||||
|
|
||||||
MBeanServer server = getPlatformMBeanServer();
|
MBeanServer server = getPlatformMBeanServer();
|
||||||
@ -40,7 +55,7 @@ public class Main {
|
|||||||
CommitLog.class, Gossiper.class, EndpointSnitchInfo.class, FailureDetector.class, CacheService.class,
|
CommitLog.class, Gossiper.class, EndpointSnitchInfo.class, FailureDetector.class, CacheService.class,
|
||||||
CompactionManager.class, GCInspector.class, StreamManager.class)) {
|
CompactionManager.class, GCInspector.class, StreamManager.class)) {
|
||||||
Constructor<? extends APIMBean> c = clazz.getDeclaredConstructor(APIClient.class);
|
Constructor<? extends APIMBean> c = clazz.getDeclaredConstructor(APIClient.class);
|
||||||
APIMBean m = c.newInstance(client);
|
APIMBean m = c.newInstance(getApiClient());
|
||||||
server.registerMBean(m, null);
|
server.registerMBean(m, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.scylladb.jmx.metrics;
|
package com.scylladb.jmx.metrics;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
|
import java.util.EnumSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
@ -55,14 +56,14 @@ public class APIMBean implements MBeanRegistration {
|
|||||||
* @param generator
|
* @param generator
|
||||||
* {@link Function} to create a new MBean instance for a given
|
* {@link Function} to create a new MBean instance for a given
|
||||||
* {@link ObjectName}
|
* {@link ObjectName}
|
||||||
*
|
|
||||||
* @return
|
* @return
|
||||||
* @throws MalformedObjectNameException
|
* @throws MalformedObjectNameException
|
||||||
*/
|
*/
|
||||||
public static boolean checkRegistration(JmxMBeanServer server, Set<ObjectName> all,
|
public static boolean checkRegistration(JmxMBeanServer server, Set<ObjectName> all,
|
||||||
final Predicate<ObjectName> predicate, Function<ObjectName, Object> generator)
|
EnumSet<RegistrationMode> mode, final Predicate<ObjectName> predicate,
|
||||||
throws MalformedObjectNameException {
|
Function<ObjectName, Object> generator) throws MalformedObjectNameException {
|
||||||
Set<ObjectName> registered = queryNames(server, predicate);
|
Set<ObjectName> registered = queryNames(server, predicate);
|
||||||
|
if (mode.contains(RegistrationMode.Remove)) {
|
||||||
for (ObjectName name : registered) {
|
for (ObjectName name : registered) {
|
||||||
if (!all.contains(name)) {
|
if (!all.contains(name)) {
|
||||||
try {
|
try {
|
||||||
@ -71,14 +72,18 @@ public class APIMBean implements MBeanRegistration {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int added = 0;
|
int added = 0;
|
||||||
|
if (mode.contains(RegistrationMode.Add)) {
|
||||||
for (ObjectName name : all) {
|
for (ObjectName name : all) {
|
||||||
if (!registered.contains(name)) {
|
if (!registered.contains(name)) {
|
||||||
try {
|
try {
|
||||||
server.getMBeanServerInterceptor().registerMBean(generator.apply(name), name);
|
server.getMBeanServerInterceptor().registerMBean(generator.apply(name), name);
|
||||||
added++;
|
added++;
|
||||||
} catch (InstanceAlreadyExistsException | MBeanRegistrationException | NotCompliantMBeanException e) {
|
} catch (InstanceAlreadyExistsException | MBeanRegistrationException
|
||||||
|
| NotCompliantMBeanException e) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,69 @@
|
|||||||
|
package com.scylladb.jmx.metrics;
|
||||||
|
|
||||||
|
import static com.scylladb.jmx.metrics.RegistrationMode.Remove;
|
||||||
|
import static com.scylladb.jmx.metrics.RegistrationMode.Wait;
|
||||||
|
import static java.util.EnumSet.allOf;
|
||||||
|
import static java.util.EnumSet.of;
|
||||||
|
|
||||||
|
import java.net.UnknownHostException;
|
||||||
|
import java.util.EnumSet;
|
||||||
|
import java.util.concurrent.locks.Lock;
|
||||||
|
import java.util.concurrent.locks.ReentrantLock;
|
||||||
|
|
||||||
|
import javax.management.OperationsException;
|
||||||
|
|
||||||
|
import com.scylladb.jmx.api.APIClient;
|
||||||
|
import com.sun.jmx.mbeanserver.JmxMBeanServer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper type to do optional locking for registration. Allows for
|
||||||
|
* per-bind-point locks and registration, instead of per-type or per-instance
|
||||||
|
* locks which may be misguiding, since for example one instance can be bound to
|
||||||
|
* many MBeanServers etc.
|
||||||
|
*
|
||||||
|
* Also allows for polled checks, i.e. try-lock and either wait or skip. Wait,
|
||||||
|
* because we probably should not repeat things hidden by this type too often,
|
||||||
|
* and skip because for example a periodic task checking can just skip if a
|
||||||
|
* user-initiated registration check is being done.
|
||||||
|
*
|
||||||
|
* @author calle
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("restriction")
|
||||||
|
public abstract class RegistrationChecker {
|
||||||
|
private final Lock lock = new ReentrantLock();
|
||||||
|
|
||||||
|
public static final EnumSet<RegistrationMode> REMOVE_NO_WAIT = of(Remove);
|
||||||
|
public static final EnumSet<RegistrationMode> ADD_AND_REMOVE = allOf(RegistrationMode.class);
|
||||||
|
|
||||||
|
public final void reap(APIClient client, JmxMBeanServer server) throws OperationsException, UnknownHostException {
|
||||||
|
check(client, server, REMOVE_NO_WAIT);
|
||||||
|
}
|
||||||
|
|
||||||
|
public final void check(APIClient client, JmxMBeanServer server) throws OperationsException, UnknownHostException {
|
||||||
|
check(client, server, ADD_AND_REMOVE);
|
||||||
|
}
|
||||||
|
|
||||||
|
public final void check(APIClient client, JmxMBeanServer server, EnumSet<RegistrationMode> mode)
|
||||||
|
throws OperationsException, UnknownHostException {
|
||||||
|
if (!lock.tryLock()) {
|
||||||
|
if (mode.contains(Wait)) {
|
||||||
|
// someone is doing update.
|
||||||
|
// since this is jmx, and sloppy, we'll just
|
||||||
|
// assume that once he is done, things are
|
||||||
|
// good enough.
|
||||||
|
lock.lock();
|
||||||
|
lock.unlock();
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
doCheck(client, server, mode);
|
||||||
|
} finally {
|
||||||
|
lock.unlock();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected abstract void doCheck(APIClient client, JmxMBeanServer server, EnumSet<RegistrationMode> mode)
|
||||||
|
throws OperationsException, UnknownHostException;
|
||||||
|
}
|
@ -0,0 +1,5 @@
|
|||||||
|
package com.scylladb.jmx.metrics;
|
||||||
|
|
||||||
|
public enum RegistrationMode {
|
||||||
|
Wait, Add, Remove,
|
||||||
|
}
|
@ -3,7 +3,7 @@ package com.scylladb.jmx.utils;
|
|||||||
* Copyright 2016 ScyllaDB
|
* Copyright 2016 ScyllaDB
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import static com.scylladb.jmx.main.Main.client;
|
import static com.scylladb.jmx.main.Main.getApiClient;
|
||||||
import static com.sun.jmx.mbeanserver.Util.wildmatch;
|
import static com.sun.jmx.mbeanserver.Util.wildmatch;
|
||||||
import static java.util.logging.Level.SEVERE;
|
import static java.util.logging.Level.SEVERE;
|
||||||
import static javax.management.MBeanServerDelegate.DELEGATE_NAME;
|
import static javax.management.MBeanServerDelegate.DELEGATE_NAME;
|
||||||
@ -172,7 +172,7 @@ public class APIBuilder extends MBeanServerBuilder {
|
|||||||
logger.log(SEVERE, "Unexpected error.", x);
|
logger.log(SEVERE, "Unexpected error.", x);
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
lock.writeLock().lock();
|
lock.writeLock().unlock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -491,6 +491,6 @@ public class APIBuilder extends MBeanServerBuilder {
|
|||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new APIMBeanServer(client, nested);
|
return new APIMBeanServer(getApiClient(), nested);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,13 @@
|
|||||||
package com.scylladb.jmx.utils;
|
package com.scylladb.jmx.utils;
|
||||||
|
|
||||||
|
import static java.util.Arrays.asList;
|
||||||
|
import static java.util.concurrent.Executors.newScheduledThreadPool;
|
||||||
|
import static java.util.concurrent.TimeUnit.MINUTES;
|
||||||
|
|
||||||
import java.io.ObjectInputStream;
|
import java.io.ObjectInputStream;
|
||||||
import java.net.UnknownHostException;
|
import java.net.UnknownHostException;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.concurrent.ScheduledExecutorService;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
@ -34,12 +39,17 @@ import org.apache.cassandra.db.ColumnFamilyStore;
|
|||||||
import org.apache.cassandra.metrics.StreamingMetrics;
|
import org.apache.cassandra.metrics.StreamingMetrics;
|
||||||
|
|
||||||
import com.scylladb.jmx.api.APIClient;
|
import com.scylladb.jmx.api.APIClient;
|
||||||
|
import com.scylladb.jmx.metrics.RegistrationChecker;
|
||||||
import com.sun.jmx.mbeanserver.JmxMBeanServer;
|
import com.sun.jmx.mbeanserver.JmxMBeanServer;
|
||||||
|
|
||||||
@SuppressWarnings("restriction")
|
@SuppressWarnings("restriction")
|
||||||
public class APIMBeanServer implements MBeanServer {
|
public class APIMBeanServer implements MBeanServer {
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
private static final Logger logger = Logger.getLogger(APIMBeanServer.class.getName());
|
private static final Logger logger = Logger.getLogger(APIMBeanServer.class.getName());
|
||||||
|
private static final ScheduledExecutorService executor = newScheduledThreadPool(1);
|
||||||
|
|
||||||
|
private final RegistrationChecker columnFamilyStoreChecker = ColumnFamilyStore.createRegistrationChecker();
|
||||||
|
private final RegistrationChecker streamingMetricsChecker = StreamingMetrics.createRegistrationChecker();
|
||||||
|
|
||||||
private final APIClient client;
|
private final APIClient client;
|
||||||
private final JmxMBeanServer server;
|
private final JmxMBeanServer server;
|
||||||
@ -47,6 +57,16 @@ public class APIMBeanServer implements MBeanServer {
|
|||||||
public APIMBeanServer(APIClient client, JmxMBeanServer server) {
|
public APIMBeanServer(APIClient client, JmxMBeanServer server) {
|
||||||
this.client = client;
|
this.client = client;
|
||||||
this.server = server;
|
this.server = server;
|
||||||
|
|
||||||
|
executor.scheduleWithFixedDelay(() -> {
|
||||||
|
for (RegistrationChecker c : asList(columnFamilyStoreChecker, streamingMetricsChecker)) {
|
||||||
|
try {
|
||||||
|
c.reap(client, server);
|
||||||
|
} catch (OperationsException | UnknownHostException e) {
|
||||||
|
// TODO: log?
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, 1, 5, MINUTES);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ObjectInstance prepareForRemote(final ObjectInstance i) {
|
private static ObjectInstance prepareForRemote(final ObjectInstance i) {
|
||||||
@ -287,24 +307,21 @@ public class APIMBeanServer implements MBeanServer {
|
|||||||
|
|
||||||
static final Pattern tables = Pattern.compile("^\\*?((Index)?ColumnFamil(ies|y)|(Index)?(Table(s)?)?)$");
|
static final Pattern tables = Pattern.compile("^\\*?((Index)?ColumnFamil(ies|y)|(Index)?(Table(s)?)?)$");
|
||||||
|
|
||||||
private boolean checkRegistrations(ObjectName name) {
|
private void checkRegistrations(ObjectName name) {
|
||||||
if (name != null && server.isRegistered(name)) {
|
if (name != null && server.isRegistered(name)) {
|
||||||
return false;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean result = false;
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
String type = name != null ? name.getKeyProperty("type") : null;
|
String type = name != null ? name.getKeyProperty("type") : null;
|
||||||
if (type == null || tables.matcher(type).matches()) {
|
if (type == null || tables.matcher(type).matches()) {
|
||||||
result |= ColumnFamilyStore.checkRegistration(client, server);
|
columnFamilyStoreChecker.check(client, server);
|
||||||
}
|
}
|
||||||
if (type == null || StreamingMetrics.TYPE_NAME.equals(type)) {
|
if (type == null || StreamingMetrics.TYPE_NAME.equals(type)) {
|
||||||
result |= StreamingMetrics.checkRegistration(client, server);
|
streamingMetricsChecker.check(client, server);
|
||||||
}
|
}
|
||||||
} catch (MalformedObjectNameException | UnknownHostException e) {
|
} catch (OperationsException | UnknownHostException e) {
|
||||||
// TODO: log
|
// TODO: log
|
||||||
}
|
}
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,10 +1,9 @@
|
|||||||
package com.scylladb.jmx.utils;
|
package com.scylladb.jmx.utils;
|
||||||
|
|
||||||
|
import jakarta.xml.bind.annotation.adapters.XmlAdapter;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
import javax.xml.bind.annotation.adapters.XmlAdapter;
|
|
||||||
|
|
||||||
public class DateXmlAdapter extends XmlAdapter<String, Date> {
|
public class DateXmlAdapter extends XmlAdapter<String, Date> {
|
||||||
@Override
|
@Override
|
||||||
public String marshal(Date v) throws Exception {
|
public String marshal(Date v) throws Exception {
|
||||||
|
16
src/main/java/module-info.java
Normal file
16
src/main/java/module-info.java
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
module scylla.jmx {
|
||||||
|
opens com.scylladb.jmx.utils;
|
||||||
|
exports com.scylladb.jmx.utils;
|
||||||
|
opens com.scylladb.jmx.main;
|
||||||
|
exports com.scylladb.jmx.main;
|
||||||
|
opens com.scylladb.jmx.metrics;
|
||||||
|
exports com.scylladb.jmx.metrics;
|
||||||
|
requires java.logging;
|
||||||
|
requires java.management;
|
||||||
|
requires scylla.apiclient;
|
||||||
|
requires jakarta.json;
|
||||||
|
requires jakarta.ws.rs;
|
||||||
|
requires com.google.common;
|
||||||
|
requires jakarta.xml.bind;
|
||||||
|
requires com.fasterxml.jackson.annotation;
|
||||||
|
}
|
@ -23,13 +23,22 @@
|
|||||||
*/
|
*/
|
||||||
package org.apache.cassandra.db;
|
package org.apache.cassandra.db;
|
||||||
|
|
||||||
|
import static jakarta.json.Json.createObjectBuilder;
|
||||||
import static java.lang.String.valueOf;
|
import static java.lang.String.valueOf;
|
||||||
import static java.util.Arrays.asList;
|
import static java.util.Arrays.asList;
|
||||||
import static java.util.stream.Collectors.toMap;
|
import static java.util.stream.Collectors.toMap;
|
||||||
import static javax.json.Json.createObjectBuilder;
|
|
||||||
|
|
||||||
|
import jakarta.json.Json;
|
||||||
|
import jakarta.json.JsonArray;
|
||||||
|
import jakarta.json.JsonObject;
|
||||||
|
import jakarta.json.JsonObjectBuilder;
|
||||||
|
import jakarta.json.JsonReader;
|
||||||
|
import jakarta.ws.rs.core.MultivaluedHashMap;
|
||||||
|
import jakarta.ws.rs.core.MultivaluedMap;
|
||||||
import java.io.StringReader;
|
import java.io.StringReader;
|
||||||
|
import java.io.OutputStream;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
import java.util.EnumSet;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -42,14 +51,10 @@ import java.util.concurrent.Future;
|
|||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import javax.json.Json;
|
|
||||||
import javax.json.JsonArray;
|
|
||||||
import javax.json.JsonObject;
|
|
||||||
import javax.json.JsonObjectBuilder;
|
|
||||||
import javax.json.JsonReader;
|
|
||||||
import javax.management.MBeanServer;
|
import javax.management.MBeanServer;
|
||||||
import javax.management.MalformedObjectNameException;
|
import javax.management.MalformedObjectNameException;
|
||||||
import javax.management.ObjectName;
|
import javax.management.ObjectName;
|
||||||
|
import javax.management.OperationsException;
|
||||||
import javax.management.openmbean.CompositeData;
|
import javax.management.openmbean.CompositeData;
|
||||||
import javax.management.openmbean.CompositeDataSupport;
|
import javax.management.openmbean.CompositeDataSupport;
|
||||||
import javax.management.openmbean.CompositeType;
|
import javax.management.openmbean.CompositeType;
|
||||||
@ -58,13 +63,13 @@ import javax.management.openmbean.OpenType;
|
|||||||
import javax.management.openmbean.SimpleType;
|
import javax.management.openmbean.SimpleType;
|
||||||
import javax.management.openmbean.TabularDataSupport;
|
import javax.management.openmbean.TabularDataSupport;
|
||||||
import javax.management.openmbean.TabularType;
|
import javax.management.openmbean.TabularType;
|
||||||
import javax.ws.rs.core.MultivaluedHashMap;
|
|
||||||
import javax.ws.rs.core.MultivaluedMap;
|
|
||||||
|
|
||||||
import org.apache.cassandra.metrics.TableMetrics;
|
import org.apache.cassandra.metrics.TableMetrics;
|
||||||
|
|
||||||
import com.scylladb.jmx.api.APIClient;
|
import com.scylladb.jmx.api.APIClient;
|
||||||
import com.scylladb.jmx.metrics.MetricsMBean;
|
import com.scylladb.jmx.metrics.MetricsMBean;
|
||||||
|
import com.scylladb.jmx.metrics.RegistrationChecker;
|
||||||
|
import com.scylladb.jmx.metrics.RegistrationMode;
|
||||||
import com.sun.jmx.mbeanserver.JmxMBeanServer;
|
import com.sun.jmx.mbeanserver.JmxMBeanServer;
|
||||||
import com.google.common.base.Throwables;
|
import com.google.common.base.Throwables;
|
||||||
|
|
||||||
@ -182,14 +187,21 @@ public class ColumnFamilyStore extends MetricsMBean implements ColumnFamilyStore
|
|||||||
"org.apache.cassandra.db:type=" + type + ",keyspace=" + keyspace + ",columnfamily=" + name);
|
"org.apache.cassandra.db:type=" + type + ",keyspace=" + keyspace + ",columnfamily=" + name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean checkRegistration(APIClient client, JmxMBeanServer server) throws MalformedObjectNameException {
|
public static RegistrationChecker createRegistrationChecker() {
|
||||||
|
return new RegistrationChecker() {
|
||||||
|
@Override
|
||||||
|
protected void doCheck(APIClient client, JmxMBeanServer server, EnumSet<RegistrationMode> mode)
|
||||||
|
throws OperationsException {
|
||||||
JsonArray mbeans = client.getJsonArray("/column_family/");
|
JsonArray mbeans = client.getJsonArray("/column_family/");
|
||||||
Set<ObjectName> all = new HashSet<ObjectName>();
|
Set<ObjectName> all = new HashSet<ObjectName>();
|
||||||
for (int i = 0; i < mbeans.size(); i++) {
|
for (int i = 0; i < mbeans.size(); i++) {
|
||||||
JsonObject mbean = mbeans.getJsonObject(i);
|
JsonObject mbean = mbeans.getJsonObject(i);
|
||||||
all.add(getName(mbean.getString("type"), mbean.getString("ks"), mbean.getString("cf")));
|
all.add(getName(mbean.getString("type"), mbean.getString("ks"), mbean.getString("cf")));
|
||||||
}
|
}
|
||||||
return checkRegistration(server, all, n -> TYPE_NAMES.contains(n.getKeyProperty("type")), n -> new ColumnFamilyStore(client, n));
|
checkRegistration(server, all, mode,
|
||||||
|
n -> TYPE_NAMES.contains(n.getKeyProperty("type")), n -> new ColumnFamilyStore(client, n));
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -320,7 +332,7 @@ public class ColumnFamilyStore extends MetricsMBean implements ColumnFamilyStore
|
|||||||
@Override
|
@Override
|
||||||
public boolean isAutoCompactionDisabled() {
|
public boolean isAutoCompactionDisabled() {
|
||||||
log(" isAutoCompactionDisabled()");
|
log(" isAutoCompactionDisabled()");
|
||||||
return client.getBooleanValue("column_family/autocompaction/" + getCFName());
|
return !client.getBooleanValue("column_family/autocompaction/" + getCFName());
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Number of tombstoned cells retreived during the last slicequery */
|
/** Number of tombstoned cells retreived during the last slicequery */
|
||||||
@ -534,6 +546,7 @@ public class ColumnFamilyStore extends MetricsMBean implements ColumnFamilyStore
|
|||||||
TabularDataSupport result = new TabularDataSupport(COUNTER_TYPE);
|
TabularDataSupport result = new TabularDataSupport(COUNTER_TYPE);
|
||||||
|
|
||||||
JsonArray counters = tableSamplerResult.getJsonArray((samplerType.equalsIgnoreCase("reads")) ? "read" : "write");
|
JsonArray counters = tableSamplerResult.getJsonArray((samplerType.equalsIgnoreCase("reads")) ? "read" : "write");
|
||||||
|
long cardinality = tableSamplerResult.getJsonNumber((samplerType.equalsIgnoreCase("reads")) ? "read_cardinality" : "write_cardinality").longValue();
|
||||||
long size = 0;
|
long size = 0;
|
||||||
if (counters != null) {
|
if (counters != null) {
|
||||||
size = (count > counters.size()) ? counters.size() : count;
|
size = (count > counters.size()) ? counters.size() : count;
|
||||||
@ -546,7 +559,6 @@ public class ColumnFamilyStore extends MetricsMBean implements ColumnFamilyStore
|
|||||||
counter.getString("partition") })); // string
|
counter.getString("partition") })); // string
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//FIXME: size is not the cardinality, a true value needs to be propogated
|
return new CompositeDataSupport(SAMPLING_RESULT, SAMPLER_NAMES, new Object[] { cardinality, result });
|
||||||
return new CompositeDataSupport(SAMPLING_RESULT, SAMPLER_NAMES, new Object[] { size, result });
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,8 +22,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.apache.cassandra.db.compaction;
|
package org.apache.cassandra.db.compaction;
|
||||||
|
|
||||||
import javax.json.JsonArray;
|
import jakarta.json.JsonArray;
|
||||||
import javax.json.JsonObject;
|
import jakarta.json.JsonObject;
|
||||||
import javax.management.openmbean.CompositeDataSupport;
|
import javax.management.openmbean.CompositeDataSupport;
|
||||||
import javax.management.openmbean.CompositeType;
|
import javax.management.openmbean.CompositeType;
|
||||||
import javax.management.openmbean.OpenDataException;
|
import javax.management.openmbean.OpenDataException;
|
||||||
|
@ -17,18 +17,18 @@
|
|||||||
*/
|
*/
|
||||||
package org.apache.cassandra.db.compaction;
|
package org.apache.cassandra.db.compaction;
|
||||||
|
|
||||||
|
import jakarta.json.JsonArray;
|
||||||
|
import jakarta.json.JsonObject;
|
||||||
|
import jakarta.ws.rs.core.MultivaluedHashMap;
|
||||||
|
import jakarta.ws.rs.core.MultivaluedMap;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import javax.json.JsonArray;
|
|
||||||
import javax.json.JsonObject;
|
|
||||||
import javax.management.openmbean.OpenDataException;
|
import javax.management.openmbean.OpenDataException;
|
||||||
import javax.management.openmbean.TabularData;
|
import javax.management.openmbean.TabularData;
|
||||||
import javax.ws.rs.core.MultivaluedHashMap;
|
|
||||||
import javax.ws.rs.core.MultivaluedMap;
|
|
||||||
|
|
||||||
import org.apache.cassandra.metrics.CompactionMetrics;
|
import org.apache.cassandra.metrics.CompactionMetrics;
|
||||||
|
|
||||||
@ -75,7 +75,7 @@ public class CompactionManager extends MetricsMBean implements CompactionManager
|
|||||||
result.put("keyspace", compaction.getString("ks"));
|
result.put("keyspace", compaction.getString("ks"));
|
||||||
result.put("columnfamily", compaction.getString("cf"));
|
result.put("columnfamily", compaction.getString("cf"));
|
||||||
result.put("unit", compaction.getString("unit"));
|
result.put("unit", compaction.getString("unit"));
|
||||||
result.put("compactionId", "<none>");
|
result.put("compactionId", (compaction.containsKey("id"))? compaction.getString("id") : "<none>");
|
||||||
results.add(result);
|
results.add(result);
|
||||||
}
|
}
|
||||||
return results;
|
return results;
|
||||||
|
@ -24,13 +24,13 @@
|
|||||||
|
|
||||||
package org.apache.cassandra.gms;
|
package org.apache.cassandra.gms;
|
||||||
|
|
||||||
|
import jakarta.json.JsonArray;
|
||||||
|
import jakarta.json.JsonObject;
|
||||||
|
import jakarta.json.JsonValue;
|
||||||
import java.net.UnknownHostException;
|
import java.net.UnknownHostException;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import javax.json.JsonArray;
|
|
||||||
import javax.json.JsonObject;
|
|
||||||
import javax.json.JsonValue;
|
|
||||||
import javax.management.openmbean.CompositeData;
|
import javax.management.openmbean.CompositeData;
|
||||||
import javax.management.openmbean.CompositeDataSupport;
|
import javax.management.openmbean.CompositeDataSupport;
|
||||||
import javax.management.openmbean.CompositeType;
|
import javax.management.openmbean.CompositeType;
|
||||||
|
@ -23,12 +23,11 @@
|
|||||||
*/
|
*/
|
||||||
package org.apache.cassandra.gms;
|
package org.apache.cassandra.gms;
|
||||||
|
|
||||||
|
import jakarta.ws.rs.core.MultivaluedHashMap;
|
||||||
|
import jakarta.ws.rs.core.MultivaluedMap;
|
||||||
import java.net.UnknownHostException;
|
import java.net.UnknownHostException;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import javax.ws.rs.core.MultivaluedHashMap;
|
|
||||||
import javax.ws.rs.core.MultivaluedMap;
|
|
||||||
|
|
||||||
import com.scylladb.jmx.api.APIClient;
|
import com.scylladb.jmx.api.APIClient;
|
||||||
import com.scylladb.jmx.metrics.APIMBean;
|
import com.scylladb.jmx.metrics.APIMBean;
|
||||||
|
|
||||||
|
@ -19,13 +19,12 @@ package org.apache.cassandra.locator;
|
|||||||
|
|
||||||
import static java.util.Collections.singletonMap;
|
import static java.util.Collections.singletonMap;
|
||||||
|
|
||||||
|
import jakarta.ws.rs.core.MultivaluedHashMap;
|
||||||
|
import jakarta.ws.rs.core.MultivaluedMap;
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.net.UnknownHostException;
|
import java.net.UnknownHostException;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import javax.ws.rs.core.MultivaluedHashMap;
|
|
||||||
import javax.ws.rs.core.MultivaluedMap;
|
|
||||||
|
|
||||||
import com.scylladb.jmx.api.APIClient;
|
import com.scylladb.jmx.api.APIClient;
|
||||||
import com.scylladb.jmx.metrics.APIMBean;
|
import com.scylladb.jmx.metrics.APIMBean;
|
||||||
|
|
||||||
|
@ -23,11 +23,11 @@
|
|||||||
*/
|
*/
|
||||||
package org.apache.cassandra.metrics;
|
package org.apache.cassandra.metrics;
|
||||||
|
|
||||||
|
import jakarta.json.JsonArray;
|
||||||
|
import jakarta.json.JsonObject;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import javax.json.JsonArray;
|
|
||||||
import javax.json.JsonObject;
|
|
||||||
import javax.management.MalformedObjectNameException;
|
import javax.management.MalformedObjectNameException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -21,6 +21,9 @@ import static com.scylladb.jmx.api.APIClient.getReader;
|
|||||||
import static java.lang.Math.floor;
|
import static java.lang.Math.floor;
|
||||||
import static java.util.logging.Level.SEVERE;
|
import static java.util.logging.Level.SEVERE;
|
||||||
|
|
||||||
|
import jakarta.json.JsonArray;
|
||||||
|
import jakarta.json.JsonNumber;
|
||||||
|
import jakarta.json.JsonObject;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
@ -29,9 +32,6 @@ import java.util.function.Function;
|
|||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import javax.json.JsonArray;
|
|
||||||
import javax.json.JsonNumber;
|
|
||||||
import javax.json.JsonObject;
|
|
||||||
import javax.management.InstanceAlreadyExistsException;
|
import javax.management.InstanceAlreadyExistsException;
|
||||||
import javax.management.MBeanRegistrationException;
|
import javax.management.MBeanRegistrationException;
|
||||||
import javax.management.MBeanServer;
|
import javax.management.MBeanServer;
|
||||||
|
@ -24,20 +24,23 @@
|
|||||||
package org.apache.cassandra.metrics;
|
package org.apache.cassandra.metrics;
|
||||||
|
|
||||||
import static java.util.Arrays.asList;
|
import static java.util.Arrays.asList;
|
||||||
import static java.util.Collections.emptySet;
|
|
||||||
import static org.apache.cassandra.metrics.DefaultNameFactory.createMetricName;
|
import static org.apache.cassandra.metrics.DefaultNameFactory.createMetricName;
|
||||||
|
|
||||||
|
import jakarta.json.JsonArray;
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.net.UnknownHostException;
|
import java.net.UnknownHostException;
|
||||||
|
import java.util.EnumSet;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import javax.json.JsonArray;
|
|
||||||
import javax.management.MalformedObjectNameException;
|
import javax.management.MalformedObjectNameException;
|
||||||
import javax.management.ObjectName;
|
import javax.management.ObjectName;
|
||||||
|
import javax.management.OperationsException;
|
||||||
|
|
||||||
import com.scylladb.jmx.api.APIClient;
|
import com.scylladb.jmx.api.APIClient;
|
||||||
import com.scylladb.jmx.metrics.APIMBean;
|
import com.scylladb.jmx.metrics.APIMBean;
|
||||||
|
import com.scylladb.jmx.metrics.RegistrationChecker;
|
||||||
|
import com.scylladb.jmx.metrics.RegistrationMode;
|
||||||
import com.sun.jmx.mbeanserver.JmxMBeanServer;
|
import com.sun.jmx.mbeanserver.JmxMBeanServer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -65,13 +68,10 @@ public class StreamingMetrics {
|
|||||||
return TYPE_NAME.equals(n.getKeyProperty("type"));
|
return TYPE_NAME.equals(n.getKeyProperty("type"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void unregister(APIClient client, JmxMBeanServer server) throws MalformedObjectNameException {
|
public static RegistrationChecker createRegistrationChecker() {
|
||||||
APIMBean.checkRegistration(server, emptySet(), StreamingMetrics::isStreamingName, (n) -> null);
|
return new RegistrationChecker() {
|
||||||
}
|
@Override
|
||||||
|
protected void doCheck(APIClient client, JmxMBeanServer server, EnumSet<RegistrationMode> mode) throws OperationsException, UnknownHostException {
|
||||||
public static boolean checkRegistration(APIClient client, JmxMBeanServer server)
|
|
||||||
throws MalformedObjectNameException, UnknownHostException {
|
|
||||||
|
|
||||||
Set<ObjectName> all = new HashSet<ObjectName>(globalNames);
|
Set<ObjectName> all = new HashSet<ObjectName>(globalNames);
|
||||||
JsonArray streams = client.getJsonArray("/stream_manager/");
|
JsonArray streams = client.getJsonArray("/stream_manager/");
|
||||||
for (int i = 0; i < streams.size(); i++) {
|
for (int i = 0; i < streams.size(); i++) {
|
||||||
@ -85,7 +85,7 @@ public class StreamingMetrics {
|
|||||||
}
|
}
|
||||||
|
|
||||||
MetricsRegistry registry = new MetricsRegistry(client, server);
|
MetricsRegistry registry = new MetricsRegistry(client, server);
|
||||||
return APIMBean.checkRegistration(server, all, StreamingMetrics::isStreamingName, n -> {
|
APIMBean.checkRegistration(server, all, mode, StreamingMetrics::isStreamingName, n -> {
|
||||||
String scope = n.getKeyProperty("scope");
|
String scope = n.getKeyProperty("scope");
|
||||||
String name = n.getKeyProperty("name");
|
String name = n.getKeyProperty("name");
|
||||||
|
|
||||||
@ -106,4 +106,6 @@ public class StreamingMetrics {
|
|||||||
return registry.counter(url);
|
return registry.counter(url);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,8 @@ package org.apache.cassandra.metrics;
|
|||||||
|
|
||||||
import static com.scylladb.jmx.api.APIClient.getReader;
|
import static com.scylladb.jmx.api.APIClient.getReader;
|
||||||
|
|
||||||
|
import java.io.InvalidObjectException;
|
||||||
|
import java.io.ObjectStreamException;
|
||||||
import java.util.Hashtable;
|
import java.util.Hashtable;
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
@ -295,7 +297,6 @@ public class TableMetrics implements Metrics {
|
|||||||
registry.createDummyTableGauge(Double.class, "PercentRepaired");
|
registry.createDummyTableGauge(Double.class, "PercentRepaired");
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("serial")
|
|
||||||
static class TableMetricObjectName extends javax.management.ObjectName {
|
static class TableMetricObjectName extends javax.management.ObjectName {
|
||||||
private final TableMetricStringNameFactory factory;
|
private final TableMetricStringNameFactory factory;
|
||||||
private final String metricName;
|
private final String metricName;
|
||||||
@ -400,6 +401,18 @@ public class TableMetrics implements Metrics {
|
|||||||
public boolean isPropertyValuePattern() {
|
public boolean isPropertyValuePattern() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This type is not really serializable.
|
||||||
|
* Replace it with vanilla objectname.
|
||||||
|
*/
|
||||||
|
private Object writeReplace() throws ObjectStreamException {
|
||||||
|
try {
|
||||||
|
return new ObjectName(getDomain(), getKeyPropertyList());
|
||||||
|
} catch (MalformedObjectNameException e) {
|
||||||
|
throw new InvalidObjectException(toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static interface TableMetricStringNameFactory {
|
static interface TableMetricStringNameFactory {
|
||||||
|
@ -24,6 +24,8 @@ package org.apache.cassandra.net;
|
|||||||
|
|
||||||
import static java.util.Collections.emptyMap;
|
import static java.util.Collections.emptyMap;
|
||||||
|
|
||||||
|
import jakarta.json.JsonArray;
|
||||||
|
import jakarta.json.JsonObject;
|
||||||
import java.net.UnknownHostException;
|
import java.net.UnknownHostException;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -32,9 +34,6 @@ import java.util.logging.Logger;
|
|||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import javax.json.JsonArray;
|
|
||||||
import javax.json.JsonObject;
|
|
||||||
|
|
||||||
import org.apache.cassandra.metrics.DroppedMessageMetrics;
|
import org.apache.cassandra.metrics.DroppedMessageMetrics;
|
||||||
|
|
||||||
import com.scylladb.jmx.api.APIClient;
|
import com.scylladb.jmx.api.APIClient;
|
||||||
|
@ -24,12 +24,11 @@
|
|||||||
|
|
||||||
package org.apache.cassandra.service;
|
package org.apache.cassandra.service;
|
||||||
|
|
||||||
|
import jakarta.ws.rs.core.MultivaluedHashMap;
|
||||||
|
import jakarta.ws.rs.core.MultivaluedMap;
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import javax.ws.rs.core.MultivaluedHashMap;
|
|
||||||
import javax.ws.rs.core.MultivaluedMap;
|
|
||||||
|
|
||||||
import org.apache.cassandra.metrics.CacheMetrics;
|
import org.apache.cassandra.metrics.CacheMetrics;
|
||||||
|
|
||||||
import com.scylladb.jmx.api.APIClient;
|
import com.scylladb.jmx.api.APIClient;
|
||||||
|
@ -2,12 +2,12 @@ package org.apache.cassandra.service;
|
|||||||
|
|
||||||
import static com.sun.jmx.mbeanserver.MXBeanMappingFactory.DEFAULT;
|
import static com.sun.jmx.mbeanserver.MXBeanMappingFactory.DEFAULT;
|
||||||
|
|
||||||
|
import jakarta.xml.bind.annotation.XmlRootElement;
|
||||||
import java.io.InvalidObjectException;
|
import java.io.InvalidObjectException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import javax.management.openmbean.CompositeData;
|
import javax.management.openmbean.CompositeData;
|
||||||
import javax.management.openmbean.OpenDataException;
|
import javax.management.openmbean.OpenDataException;
|
||||||
import javax.xml.bind.annotation.XmlRootElement;
|
|
||||||
|
|
||||||
import com.sun.jmx.mbeanserver.MXBeanMapping;
|
import com.sun.jmx.mbeanserver.MXBeanMapping;
|
||||||
|
|
||||||
|
@ -1,13 +1,12 @@
|
|||||||
package org.apache.cassandra.service;
|
package org.apache.cassandra.service;
|
||||||
|
|
||||||
|
import jakarta.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
import com.scylladb.jmx.utils.DateXmlAdapter;
|
import com.scylladb.jmx.utils.DateXmlAdapter;
|
||||||
|
@ -25,18 +25,15 @@ package org.apache.cassandra.service;
|
|||||||
|
|
||||||
import static java.util.Collections.emptySet;
|
import static java.util.Collections.emptySet;
|
||||||
|
|
||||||
|
import jakarta.json.JsonArray;
|
||||||
|
import jakarta.ws.rs.core.MultivaluedHashMap;
|
||||||
|
import jakarta.ws.rs.core.MultivaluedMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import javax.json.JsonArray;
|
|
||||||
import javax.json.JsonObject;
|
|
||||||
import javax.management.ObjectName;
|
|
||||||
import javax.ws.rs.core.MultivaluedHashMap;
|
|
||||||
import javax.ws.rs.core.MultivaluedMap;
|
|
||||||
|
|
||||||
import org.apache.cassandra.db.ColumnFamilyStore;
|
import org.apache.cassandra.db.ColumnFamilyStore;
|
||||||
import org.apache.cassandra.metrics.CASClientRequestMetrics;
|
import org.apache.cassandra.metrics.CASClientRequestMetrics;
|
||||||
import org.apache.cassandra.metrics.ClientRequestMetrics;
|
import org.apache.cassandra.metrics.ClientRequestMetrics;
|
||||||
|
@ -24,10 +24,16 @@ package org.apache.cassandra.service;
|
|||||||
|
|
||||||
import static java.util.Arrays.asList;
|
import static java.util.Arrays.asList;
|
||||||
|
|
||||||
|
import jakarta.json.JsonArray;
|
||||||
|
import jakarta.json.JsonObject;
|
||||||
|
import jakarta.ws.rs.core.GenericType;
|
||||||
|
import jakarta.ws.rs.core.MultivaluedHashMap;
|
||||||
|
import jakarta.ws.rs.core.MultivaluedMap;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.net.UnknownHostException;
|
import java.net.UnknownHostException;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@ -44,8 +50,6 @@ import java.util.concurrent.atomic.AtomicLong;
|
|||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import javax.json.JsonArray;
|
|
||||||
import javax.json.JsonObject;
|
|
||||||
import javax.management.ListenerNotFoundException;
|
import javax.management.ListenerNotFoundException;
|
||||||
import javax.management.MBeanNotificationInfo;
|
import javax.management.MBeanNotificationInfo;
|
||||||
import javax.management.Notification;
|
import javax.management.Notification;
|
||||||
@ -54,10 +58,14 @@ import javax.management.NotificationBroadcasterSupport;
|
|||||||
import javax.management.NotificationFilter;
|
import javax.management.NotificationFilter;
|
||||||
import javax.management.NotificationListener;
|
import javax.management.NotificationListener;
|
||||||
import javax.management.openmbean.CompositeData;
|
import javax.management.openmbean.CompositeData;
|
||||||
|
import javax.management.openmbean.CompositeDataSupport;
|
||||||
|
import javax.management.openmbean.CompositeType;
|
||||||
|
import javax.management.openmbean.OpenDataException;
|
||||||
|
import javax.management.openmbean.OpenType;
|
||||||
|
import javax.management.openmbean.SimpleType;
|
||||||
import javax.management.openmbean.TabularData;
|
import javax.management.openmbean.TabularData;
|
||||||
import javax.ws.rs.core.GenericType;
|
import javax.management.openmbean.TabularDataSupport;
|
||||||
import javax.ws.rs.core.MultivaluedHashMap;
|
import javax.management.openmbean.TabularType;
|
||||||
import javax.ws.rs.core.MultivaluedMap;
|
|
||||||
|
|
||||||
import org.apache.cassandra.metrics.StorageMetrics;
|
import org.apache.cassandra.metrics.StorageMetrics;
|
||||||
import org.apache.cassandra.repair.RepairParallelism;
|
import org.apache.cassandra.repair.RepairParallelism;
|
||||||
@ -65,7 +73,8 @@ import org.apache.cassandra.repair.RepairParallelism;
|
|||||||
import com.google.common.base.Joiner;
|
import com.google.common.base.Joiner;
|
||||||
import com.scylladb.jmx.api.APIClient;
|
import com.scylladb.jmx.api.APIClient;
|
||||||
import com.scylladb.jmx.metrics.MetricsMBean;
|
import com.scylladb.jmx.metrics.MetricsMBean;
|
||||||
import com.scylladb.jmx.utils.FileUtils;
|
import com.scylladb.jmx.api.utils.FileUtils;
|
||||||
|
import com.google.common.base.Throwables;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This abstraction contains the token/identifier of this node on the identifier
|
* This abstraction contains the token/identifier of this node on the identifier
|
||||||
@ -76,6 +85,41 @@ public class StorageService extends MetricsMBean implements StorageServiceMBean,
|
|||||||
private static final Logger logger = Logger.getLogger(StorageService.class.getName());
|
private static final Logger logger = Logger.getLogger(StorageService.class.getName());
|
||||||
private static final Timer timer = new Timer("Storage Service Repair", true);
|
private static final Timer timer = new Timer("Storage Service Repair", true);
|
||||||
|
|
||||||
|
private static final String[] COUNTER_NAMES = new String[]{"raw", "count", "error", "string"};
|
||||||
|
private static final String[] COUNTER_DESCS = new String[]
|
||||||
|
{ "partition key in raw hex bytes",
|
||||||
|
"value of this partition for given sampler",
|
||||||
|
"value is within the error bounds plus or minus of this",
|
||||||
|
"the partition key turned into a human readable format" };
|
||||||
|
private static final CompositeType COUNTER_COMPOSITE_TYPE;
|
||||||
|
private static final TabularType COUNTER_TYPE;
|
||||||
|
|
||||||
|
private static final String[] OPERATION_NAMES = new String[]{"read", "write"};
|
||||||
|
|
||||||
|
private static final String[] SAMPLER_NAMES = new String[]{"cardinality", "partitions"};
|
||||||
|
private static final String[] SAMPLER_DESCS = new String[]
|
||||||
|
{ "cardinality of partitions",
|
||||||
|
"list of counter results" };
|
||||||
|
|
||||||
|
private static final String SAMPLING_RESULTS_NAME = "SAMPLING_RESULTS";
|
||||||
|
private static final CompositeType SAMPLING_RESULT;
|
||||||
|
|
||||||
|
static
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
OpenType<?>[] counterTypes = new OpenType[] { SimpleType.STRING, SimpleType.LONG, SimpleType.LONG, SimpleType.STRING };
|
||||||
|
COUNTER_COMPOSITE_TYPE = new CompositeType(SAMPLING_RESULTS_NAME, SAMPLING_RESULTS_NAME, COUNTER_NAMES, COUNTER_DESCS, counterTypes);
|
||||||
|
COUNTER_TYPE = new TabularType(SAMPLING_RESULTS_NAME, SAMPLING_RESULTS_NAME, COUNTER_COMPOSITE_TYPE, COUNTER_NAMES);
|
||||||
|
|
||||||
|
OpenType<?>[] samplerTypes = new OpenType[] { SimpleType.LONG, COUNTER_TYPE };
|
||||||
|
SAMPLING_RESULT = new CompositeType(SAMPLING_RESULTS_NAME, SAMPLING_RESULTS_NAME, SAMPLER_NAMES, SAMPLER_DESCS, samplerTypes);
|
||||||
|
} catch (OpenDataException e)
|
||||||
|
{
|
||||||
|
throw Throwables.propagate(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private final NotificationBroadcasterSupport notificationBroadcasterSupport = new NotificationBroadcasterSupport();
|
private final NotificationBroadcasterSupport notificationBroadcasterSupport = new NotificationBroadcasterSupport();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -270,7 +314,7 @@ public class StorageService extends MetricsMBean implements StorageServiceMBean,
|
|||||||
@Override
|
@Override
|
||||||
public Map<List<String>, List<String>> getRangeToEndpointMap(String keyspace) {
|
public Map<List<String>, List<String>> getRangeToEndpointMap(String keyspace) {
|
||||||
log(" getRangeToEndpointMap(String keyspace)");
|
log(" getRangeToEndpointMap(String keyspace)");
|
||||||
return client.getMapListStrValue("/storage_service/range/" + keyspace);
|
return client.getMapListStrValue("/storage_service/range_to_endpoint_map/" + keyspace);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -476,6 +520,12 @@ public class StorageService extends MetricsMBean implements StorageServiceMBean,
|
|||||||
return client.getListInetAddressValue("");
|
return client.getListInetAddressValue("");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void checkAndRepairCdcStreams() throws IOException {
|
||||||
|
log(" checkAndRepairCdcStreams() throws IOException");
|
||||||
|
client.post("/storage_service/cdc_streams_check_and_repair");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Takes the snapshot for the given keyspaces. A snapshot name must be
|
* Takes the snapshot for the given keyspaces. A snapshot name must be
|
||||||
* specified.
|
* specified.
|
||||||
@ -502,7 +552,9 @@ public class StorageService extends MetricsMBean implements StorageServiceMBean,
|
|||||||
APIClient.set_query_param(queryParams, "cf", parts[1]);
|
APIClient.set_query_param(queryParams, "cf", parts[1]);
|
||||||
}
|
}
|
||||||
APIClient.set_query_param(queryParams, "kn", APIClient.join(keyspaceNames));
|
APIClient.set_query_param(queryParams, "kn", APIClient.join(keyspaceNames));
|
||||||
// TODO: origin has one recognized option: skip flush. We don't.
|
if (options.containsKey("skipFlush")) {
|
||||||
|
APIClient.set_query_param(queryParams, "sf", options.get("skipFlush"));
|
||||||
|
}
|
||||||
client.post("/storage_service/snapshots", queryParams);
|
client.post("/storage_service/snapshots", queryParams);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -645,7 +697,7 @@ public class StorageService extends MetricsMBean implements StorageServiceMBean,
|
|||||||
APIClient.set_bool_query_param(queryParams, "disable_snapshot", disableSnapshot);
|
APIClient.set_bool_query_param(queryParams, "disable_snapshot", disableSnapshot);
|
||||||
APIClient.set_bool_query_param(queryParams, "skip_corrupted", skipCorrupted);
|
APIClient.set_bool_query_param(queryParams, "skip_corrupted", skipCorrupted);
|
||||||
APIClient.set_query_param(queryParams, "cf", APIClient.join(columnFamilies));
|
APIClient.set_query_param(queryParams, "cf", APIClient.join(columnFamilies));
|
||||||
return client.getIntValue("/storage_service/keyspace_scrub/" + keyspaceName);
|
return client.getIntValue("/storage_service/keyspace_scrub/" + keyspaceName, queryParams);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -939,13 +991,21 @@ public class StorageService extends MetricsMBean implements StorageServiceMBean,
|
|||||||
* the host id to remove
|
* the host id to remove
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void removeNode(String hostIdString) {
|
public void removeNode(String hostIdString, String ignoreNodes) {
|
||||||
log(" removeNode(String token)");
|
log(" removeNode(String token, String ignoreNodes)");
|
||||||
MultivaluedMap<String, String> queryParams = new MultivaluedHashMap<String, String>();
|
MultivaluedMap<String, String> queryParams = new MultivaluedHashMap<String, String>();
|
||||||
APIClient.set_query_param(queryParams, "host_id", hostIdString);
|
APIClient.set_query_param(queryParams, "host_id", hostIdString);
|
||||||
|
if (ignoreNodes != null) {
|
||||||
|
APIClient.set_query_param(queryParams, "ignore_nodes", ignoreNodes);
|
||||||
|
}
|
||||||
client.post("/storage_service/remove_node", queryParams);
|
client.post("/storage_service/remove_node", queryParams);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void removeNode(String hostIdString) {
|
||||||
|
String ignoreNodes = null;
|
||||||
|
removeNode(hostIdString, ignoreNodes);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the status of a token removal.
|
* Get the status of a token removal.
|
||||||
*/
|
*/
|
||||||
@ -1365,15 +1425,25 @@ public class StorageService extends MetricsMBean implements StorageServiceMBean,
|
|||||||
* The parent keyspace name
|
* The parent keyspace name
|
||||||
* @param cfName
|
* @param cfName
|
||||||
* The ColumnFamily name where SSTables belong
|
* The ColumnFamily name where SSTables belong
|
||||||
|
* @param isLoadAndStream
|
||||||
|
* Whether or not arbitrary SSTables should be loaded (and streamed to the owning nodes)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void loadNewSSTables(String ksName, String cfName) {
|
public void loadNewSSTables(String ksName, String cfName, boolean isLoadAndStream) {
|
||||||
log(" loadNewSSTables(String ksName, String cfName)");
|
log(" loadNewSSTables(String ksName, String cfName, boolean isLoadAndStream)");
|
||||||
MultivaluedMap<String, String> queryParams = new MultivaluedHashMap<String, String>();
|
MultivaluedMap<String, String> queryParams = new MultivaluedHashMap<String, String>();
|
||||||
queryParams.add("cf", cfName);
|
queryParams.add("cf", cfName);
|
||||||
|
if (isLoadAndStream) {
|
||||||
|
queryParams.add("load_and_stream", "true");
|
||||||
|
}
|
||||||
client.post("/storage_service/sstables/" + ksName, queryParams);
|
client.post("/storage_service/sstables/" + ksName, queryParams);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void loadNewSSTables(String ksName, String cfName) {
|
||||||
|
loadNewSSTables(ksName, cfName, false);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a List of Tokens representing a sample of keys across all
|
* Return a List of Tokens representing a sample of keys across all
|
||||||
* ColumnFamilyStores.
|
* ColumnFamilyStores.
|
||||||
@ -1444,13 +1514,7 @@ public class StorageService extends MetricsMBean implements StorageServiceMBean,
|
|||||||
log("enableAutoCompaction(String ks, String... columnFamilies)");
|
log("enableAutoCompaction(String ks, String... columnFamilies)");
|
||||||
MultivaluedMap<String, String> queryParams = new MultivaluedHashMap<String, String>();
|
MultivaluedMap<String, String> queryParams = new MultivaluedHashMap<String, String>();
|
||||||
APIClient.set_query_param(queryParams, "cf", APIClient.join(columnFamilies));
|
APIClient.set_query_param(queryParams, "cf", APIClient.join(columnFamilies));
|
||||||
try {
|
|
||||||
client.post("/storage_service/auto_compaction/" + ks, queryParams);
|
client.post("/storage_service/auto_compaction/" + ks, queryParams);
|
||||||
} catch (RuntimeException e) {
|
|
||||||
// FIXME should throw the right exception
|
|
||||||
throw new IOException(e.getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -1669,7 +1733,7 @@ public class StorageService extends MetricsMBean implements StorageServiceMBean,
|
|||||||
public int scrub(boolean disableSnapshot, boolean skipCorrupted, boolean checkData, int jobs, String keyspaceName,
|
public int scrub(boolean disableSnapshot, boolean skipCorrupted, boolean checkData, int jobs, String keyspaceName,
|
||||||
String... columnFamilies) throws IOException, ExecutionException, InterruptedException {
|
String... columnFamilies) throws IOException, ExecutionException, InterruptedException {
|
||||||
// "jobs" not (yet) relevant for scylla. (though possibly useful...)
|
// "jobs" not (yet) relevant for scylla. (though possibly useful...)
|
||||||
return scrub(disableSnapshot, skipCorrupted, checkData, 0, keyspaceName, columnFamilies);
|
return scrub(disableSnapshot, skipCorrupted, checkData, keyspaceName, columnFamilies);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -1738,4 +1802,74 @@ public class StorageService extends MetricsMBean implements StorageServiceMBean,
|
|||||||
public List<CompositeData> getSSTableInfo() {
|
public List<CompositeData> getSSTableInfo() {
|
||||||
return getSSTableInfo(null, null);
|
return getSSTableInfo(null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int scrub(boolean disableSnapshot, boolean skipCorrupted, boolean checkData, boolean reinsertOverflowedTTL,
|
||||||
|
int jobs, String keyspaceName, String... columnFamilies)
|
||||||
|
throws IOException, ExecutionException, InterruptedException {
|
||||||
|
MultivaluedMap<String, String> queryParams = new MultivaluedHashMap<String, String>();
|
||||||
|
APIClient.set_bool_query_param(queryParams, "disable_snapshot", disableSnapshot);
|
||||||
|
APIClient.set_bool_query_param(queryParams, "skip_corrupted", skipCorrupted);
|
||||||
|
APIClient.set_query_param(queryParams, "cf", APIClient.join(columnFamilies));
|
||||||
|
return client.getIntValue("/storage_service/keyspace_scrub/" + keyspaceName, queryParams);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int scrub(boolean disableSnapshot, String scrubMode, boolean checkData, boolean reinsertOverflowedTTL,
|
||||||
|
int jobs, String keyspaceName, String... columnFamilies)
|
||||||
|
throws IOException, ExecutionException, InterruptedException {
|
||||||
|
MultivaluedMap<String, String> queryParams = new MultivaluedHashMap<String, String>();
|
||||||
|
APIClient.set_bool_query_param(queryParams, "disable_snapshot", disableSnapshot);
|
||||||
|
if (!"".equals(scrubMode)) {
|
||||||
|
APIClient.set_query_param(queryParams, "scrub_mode", scrubMode);
|
||||||
|
}
|
||||||
|
APIClient.set_query_param(queryParams, "cf", APIClient.join(columnFamilies));
|
||||||
|
return client.getIntValue("/storage_service/keyspace_scrub/" + keyspaceName, queryParams);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getUptime() {
|
||||||
|
log("getUptime()");
|
||||||
|
return client.getLongValue("/system/uptime_ms");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CompositeData getToppartitions(String sampler, List<String> keyspaceFilters, List<String> tableFilters, int duration, int capacity, int count) throws OpenDataException {
|
||||||
|
return getToppartitions(Arrays.asList(sampler), keyspaceFilters, tableFilters, duration, capacity, count).get(sampler.toLowerCase());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<String, CompositeData> getToppartitions(List<String> samplers, List<String> keyspaceFilters, List<String> tableFilters, int duration, int capacity, int count) throws OpenDataException {
|
||||||
|
MultivaluedMap<String, String> queryParams = new MultivaluedHashMap<String, String>();
|
||||||
|
APIClient.set_query_param(queryParams, "duration", Integer.toString(duration));
|
||||||
|
APIClient.set_query_param(queryParams, "capacity", Integer.toString(capacity));
|
||||||
|
APIClient.set_query_param(queryParams, "keyspace_filters", keyspaceFilters != null ? APIClient.join(keyspaceFilters.toArray(new String[0])) : null);
|
||||||
|
APIClient.set_query_param(queryParams, "table_filters", tableFilters != null ? APIClient.join(tableFilters.toArray(new String[0])) : null);
|
||||||
|
JsonObject result = client.getJsonObj("/storage_service/toppartitions", queryParams);
|
||||||
|
|
||||||
|
Map<String, CompositeData> resultsMap = new HashMap<>();
|
||||||
|
|
||||||
|
for (String operation : OPERATION_NAMES) {
|
||||||
|
JsonArray counters = result.getJsonArray(operation);
|
||||||
|
long cardinality = result.getJsonNumber(operation + "_cardinality").longValue();
|
||||||
|
long size = 0;
|
||||||
|
TabularDataSupport tabularResult = new TabularDataSupport(COUNTER_TYPE);
|
||||||
|
|
||||||
|
if (counters != null) {
|
||||||
|
size = (count > counters.size()) ? counters.size() : count;
|
||||||
|
for (int i = 0; i < size; i++) {
|
||||||
|
JsonObject counter = counters.getJsonObject(i);
|
||||||
|
tabularResult.put(new CompositeDataSupport(COUNTER_COMPOSITE_TYPE, COUNTER_NAMES,
|
||||||
|
new Object[] { counter.getString("partition"), // raw
|
||||||
|
counter.getJsonNumber("count").longValue(), // count
|
||||||
|
counter.getJsonNumber("error").longValue(), // error
|
||||||
|
counter.getString("partition") })); // string
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
resultsMap.put(operation + "s", new CompositeDataSupport(SAMPLING_RESULT, SAMPLER_NAMES, new Object[] { cardinality, tabularResult }));
|
||||||
|
}
|
||||||
|
|
||||||
|
return resultsMap;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -37,6 +37,7 @@ import java.util.concurrent.TimeoutException;
|
|||||||
import javax.management.NotificationEmitter;
|
import javax.management.NotificationEmitter;
|
||||||
import javax.management.openmbean.CompositeData;
|
import javax.management.openmbean.CompositeData;
|
||||||
import javax.management.openmbean.TabularData;
|
import javax.management.openmbean.TabularData;
|
||||||
|
import javax.management.openmbean.OpenDataException;
|
||||||
|
|
||||||
public interface StorageServiceMBean extends NotificationEmitter {
|
public interface StorageServiceMBean extends NotificationEmitter {
|
||||||
/**
|
/**
|
||||||
@ -213,6 +214,7 @@ public interface StorageServiceMBean extends NotificationEmitter {
|
|||||||
|
|
||||||
public List<InetAddress> getNaturalEndpoints(String keyspaceName, ByteBuffer key);
|
public List<InetAddress> getNaturalEndpoints(String keyspaceName, ByteBuffer key);
|
||||||
|
|
||||||
|
public void checkAndRepairCdcStreams() throws IOException;
|
||||||
/**
|
/**
|
||||||
* Takes the snapshot for the given keyspaces. A snapshot name must be
|
* Takes the snapshot for the given keyspaces. A snapshot name must be
|
||||||
* specified.
|
* specified.
|
||||||
@ -348,6 +350,10 @@ public interface StorageServiceMBean extends NotificationEmitter {
|
|||||||
* scrubbed.
|
* scrubbed.
|
||||||
*
|
*
|
||||||
* Scrubbed CFs will be snapshotted first, if disableSnapshot is false
|
* Scrubbed CFs will be snapshotted first, if disableSnapshot is false
|
||||||
|
*
|
||||||
|
* scrubMode controls what scrub does when encountering corruption.
|
||||||
|
* It replaces skipCorrupted where skipCorrupted is equivalent to scrubMode="SKIP".
|
||||||
|
* Can be one of: "ABORT", "SKIP", "SEGREGATE", or "VALIDATE".
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public int scrub(boolean disableSnapshot, boolean skipCorrupted, String keyspaceName, String... tableNames)
|
public int scrub(boolean disableSnapshot, boolean skipCorrupted, String keyspaceName, String... tableNames)
|
||||||
@ -357,9 +363,19 @@ public interface StorageServiceMBean extends NotificationEmitter {
|
|||||||
public int scrub(boolean disableSnapshot, boolean skipCorrupted, boolean checkData, String keyspaceName,
|
public int scrub(boolean disableSnapshot, boolean skipCorrupted, boolean checkData, String keyspaceName,
|
||||||
String... tableNames) throws IOException, ExecutionException, InterruptedException;
|
String... tableNames) throws IOException, ExecutionException, InterruptedException;
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public int scrub(boolean disableSnapshot, boolean skipCorrupted, boolean checkData, int jobs, String keyspaceName,
|
public int scrub(boolean disableSnapshot, boolean skipCorrupted, boolean checkData, int jobs, String keyspaceName,
|
||||||
String... columnFamilies) throws IOException, ExecutionException, InterruptedException;
|
String... columnFamilies) throws IOException, ExecutionException, InterruptedException;
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
|
public int scrub(boolean disableSnapshot, boolean skipCorrupted, boolean checkData, boolean reinsertOverflowedTTL,
|
||||||
|
int jobs, String keyspaceName, String... columnFamilies)
|
||||||
|
throws IOException, ExecutionException, InterruptedException;
|
||||||
|
|
||||||
|
public int scrub(boolean disableSnapshot, String scrubMode, boolean checkData, boolean reinsertOverflowedTTL,
|
||||||
|
int jobs, String keyspaceName, String... columnFamilies)
|
||||||
|
throws IOException, ExecutionException, InterruptedException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Verify (checksums of) the given keyspace. If tableNames array is empty,
|
* Verify (checksums of) the given keyspace. If tableNames array is empty,
|
||||||
* all CFs are verified.
|
* all CFs are verified.
|
||||||
@ -497,8 +513,11 @@ public interface StorageServiceMBean extends NotificationEmitter {
|
|||||||
* removeToken removes token (and all data associated with enpoint that had
|
* removeToken removes token (and all data associated with enpoint that had
|
||||||
* it) from the ring
|
* it) from the ring
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public void removeNode(String token);
|
public void removeNode(String token);
|
||||||
|
|
||||||
|
public void removeNode(String token, String ignoreNodes);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the status of a token removal.
|
* Get the status of a token removal.
|
||||||
*/
|
*/
|
||||||
@ -791,7 +810,16 @@ public interface StorageServiceMBean extends NotificationEmitter {
|
|||||||
* The parent keyspace name
|
* The parent keyspace name
|
||||||
* @param cfName
|
* @param cfName
|
||||||
* The ColumnFamily name where SSTables belong
|
* The ColumnFamily name where SSTables belong
|
||||||
|
* @param isLoadAndStream
|
||||||
|
* Whether or not arbitrary SSTables should be loaded (and streamed to the owning nodes)
|
||||||
*/
|
*/
|
||||||
|
public void loadNewSSTables(String ksName, String cfName, boolean isLoadAndStream);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated use {@link #loadNewSSTables(String ksName, String cfName, boolean isLoadAndStream)} instead.
|
||||||
|
* This is kept for backward compatibility.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
public void loadNewSSTables(String ksName, String cfName);
|
public void loadNewSSTables(String ksName, String cfName);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -877,4 +905,11 @@ public interface StorageServiceMBean extends NotificationEmitter {
|
|||||||
public List<CompositeData> getSSTableInfo(String keyspace, String table);
|
public List<CompositeData> getSSTableInfo(String keyspace, String table);
|
||||||
|
|
||||||
public List<CompositeData> getSSTableInfo();
|
public List<CompositeData> getSSTableInfo();
|
||||||
|
|
||||||
|
/** retun the system uptime */
|
||||||
|
public long getUptime();
|
||||||
|
|
||||||
|
public CompositeData getToppartitions(String sampler, List<String> keyspaceFilters, List<String> tableFilters, int duration, int capacity, int count) throws OpenDataException;
|
||||||
|
|
||||||
|
public Map<String, CompositeData> getToppartitions(List<String> samplers, List<String> keyspaceFilters, List<String> tableFilters, int duration, int capacity, int count) throws OpenDataException;
|
||||||
}
|
}
|
||||||
|
@ -24,15 +24,14 @@
|
|||||||
|
|
||||||
package org.apache.cassandra.streaming;
|
package org.apache.cassandra.streaming;
|
||||||
|
|
||||||
|
import jakarta.json.JsonArray;
|
||||||
|
import jakarta.json.JsonObject;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.net.UnknownHostException;
|
import java.net.UnknownHostException;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import javax.json.JsonArray;
|
|
||||||
import javax.json.JsonObject;
|
|
||||||
|
|
||||||
import com.google.common.base.Objects;
|
import com.google.common.base.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -24,6 +24,8 @@
|
|||||||
|
|
||||||
package org.apache.cassandra.streaming;
|
package org.apache.cassandra.streaming;
|
||||||
|
|
||||||
|
import jakarta.json.JsonArray;
|
||||||
|
import jakarta.json.JsonObject;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.net.UnknownHostException;
|
import java.net.UnknownHostException;
|
||||||
@ -32,9 +34,6 @@ import java.util.HashSet;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import javax.json.JsonArray;
|
|
||||||
import javax.json.JsonObject;
|
|
||||||
|
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -24,12 +24,12 @@
|
|||||||
|
|
||||||
package org.apache.cassandra.streaming;
|
package org.apache.cassandra.streaming;
|
||||||
|
|
||||||
|
import jakarta.json.JsonArray;
|
||||||
|
import jakarta.json.JsonObject;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import javax.json.JsonArray;
|
|
||||||
import javax.json.JsonObject;
|
|
||||||
import javax.management.ListenerNotFoundException;
|
import javax.management.ListenerNotFoundException;
|
||||||
import javax.management.MBeanNotificationInfo;
|
import javax.management.MBeanNotificationInfo;
|
||||||
import javax.management.NotificationBroadcasterSupport;
|
import javax.management.NotificationBroadcasterSupport;
|
||||||
|
@ -24,13 +24,12 @@
|
|||||||
|
|
||||||
package org.apache.cassandra.streaming;
|
package org.apache.cassandra.streaming;
|
||||||
|
|
||||||
|
import jakarta.json.JsonArray;
|
||||||
|
import jakarta.json.JsonObject;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import javax.json.JsonArray;
|
|
||||||
import javax.json.JsonObject;
|
|
||||||
|
|
||||||
import com.google.common.base.Objects;
|
import com.google.common.base.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user