Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modify accumulo-cluster to support starting and stopping groups of tservers #5114

Merged
merged 4 commits into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 22 additions & 36 deletions assemble/bin/accumulo-cluster
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,10 @@ Commands:
start Starts Accumulo cluster
stop Stops Accumulo cluster
kill Kills Accumulo cluster
start-non-tservers Deprecated. Starts all services except tservers
start-servers [--all|--tservers|--no-tservers|--sservers [group]|--compactors [group]]
start-servers [--all|--tservers [group]|--sservers [group]|--compactors [group]]
Starts various server types, can optionally specify a group
stop-servers [--all|--tservers| --no-tservers|--sservers [group]|--compactors [group]]
stop-servers [--all|--tservers [group]|--sservers [group]|--compactors [group]]
Starts various server types, can optionally specify a group
start-tservers Deprecated. Starts all tservers on cluster
stop-tservers Deprecated. Stops all tservers on cluster
start-here Starts all services on this node
stop-here Stops all services on this node
EOF
Expand Down Expand Up @@ -273,7 +270,12 @@ function stop_sservers() {

function start_tservers() {
echo "Starting tablet servers ..."
for group in $TSERVER_GROUPS; do
groups=$TSERVER_GROUPS
if [[ -n $1 ]]; then
groups="$1"
echo "Only starting servers for group: ${groups}"
fi
for group in $groups; do
echo "Starting tablet servers for group $group"
count=1
G="TSERVER_HOSTS_${group}"
Expand All @@ -293,9 +295,7 @@ function start_tservers() {
function start_all() {
unset DISPLAY

if [[ $1 != "--no-tservers" ]]; then
start_tservers
fi
start_tservers

for manager in $MANAGER_HOSTS; do
start_service "$manager" manager "1"
Expand Down Expand Up @@ -416,8 +416,12 @@ function kill_service() {
function stop_tservers() {

echo "Stopping unresponsive tablet servers (if any)..."

for group in $TSERVER_GROUPS; do
groups=$TSERVER_GROUPS
if [[ -n $1 ]]; then
groups="$1"
echo "Only stopping servers for group: ${groups}"
fi
for group in $groups; do
echo "Stopping tablet servers for group $group"
G="TSERVER_HOSTS_${group}"
S="TSERVERS_PER_HOST_${group}"
Expand All @@ -429,18 +433,18 @@ function stop_tservers() {
sleep 10

echo "Stopping unresponsive tablet servers hard (if any)..."
for group in $TSERVER_GROUPS; do
for group in $groups; do
G="TSERVER_HOSTS_${group}"
S="TSERVERS_PER_HOST_${group}"
for tserver in ${!G}; do
kill_service "$tserver" tserver "${!S}" "-o" "tserver.group=$group" &
done
echo "Cleaning tablet server entries from zookeeper"
if ! isDebug; then
${accumulo_cmd} org.apache.accumulo.server.util.ZooZap -tservers -group "$group"
fi
done

echo "Cleaning tablet server entries from zookeeper"
if ! isDebug; then
${accumulo_cmd} org.apache.accumulo.server.util.ZooZap -tservers
fi
}

function kill_all() {
Expand Down Expand Up @@ -698,25 +702,10 @@ EOF
parse_config
kill_all
;;
start-non-tservers)
echo "$1 is deprecated. Please use \`start-servers --no-tservers\` instead"
parse_config
start_all --no-tservers
;;
start-tservers)
echo "$1 is deprecated. Please use \`start-servers --tservers\` instead"
parse_config
start_tservers
;;
start-here)
parse_config
start_here
;;
stop-tservers)
echo "$1 is deprecated. Please use \`stop-servers --tservers\` instead"
parse_config
stop_tservers
;;
stop-here)
parse_config
stop_here
Expand All @@ -729,10 +718,7 @@ EOF
start_all
;;
"--tservers")
start_tservers
;;
"--no-tservers")
start_all --no-tservers
start_tservers "${program_args[@]:2}"
;;
"--sservers")
start_sservers "${program_args[@]:2}"
Expand All @@ -753,7 +739,7 @@ EOF
stop_all
;;
"--tservers")
stop_tservers
stop_tservers "${program_args[@]:2}"
;;
"--sservers")
stop_sservers "${program_args[@]:2}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.apache.accumulo.core.fate.zookeeper.ZooUtil.NodeMissingPolicy;
import org.apache.accumulo.core.lock.ServiceLock;
import org.apache.accumulo.core.lock.ServiceLockPaths.AddressSelector;
import org.apache.accumulo.core.lock.ServiceLockPaths.ResourceGroupPredicate;
import org.apache.accumulo.core.lock.ServiceLockPaths.ServiceLockPath;
import org.apache.accumulo.core.singletons.SingletonManager;
import org.apache.accumulo.core.singletons.SingletonManager.Mode;
Expand Down Expand Up @@ -68,6 +69,9 @@ static class Opts extends Help {
boolean zapManager = false;
@Parameter(names = "-tservers", description = "remove tablet server locks")
boolean zapTservers = false;
@Parameter(names = "-group", description = "limit the zap to a specific resource group",
arity = 1)
String resourceGroup = "";
@Parameter(names = "-compactors", description = "remove compactor locks")
boolean zapCompactors = false;
@Parameter(names = "-sservers", description = "remove scan server locks")
Expand Down Expand Up @@ -108,10 +112,17 @@ public void execute(String[] args) throws Exception {
}
}

ResourceGroupPredicate rgp;
if (!opts.resourceGroup.isEmpty()) {
rgp = rg -> rg.equals(opts.resourceGroup);
} else {
rgp = rg -> true;
}

if (opts.zapTservers) {
try {
Set<ServiceLockPath> tserverLockPaths =
context.getServerPaths().getTabletServer(rg -> true, AddressSelector.all(), false);
context.getServerPaths().getTabletServer(rgp, AddressSelector.all(), false);
for (ServiceLockPath tserverPath : tserverLockPaths) {

message("Deleting " + tserverPath + " from zookeeper", opts);
Expand All @@ -133,7 +144,7 @@ public void execute(String[] args) throws Exception {

if (opts.zapCompactors) {
Set<ServiceLockPath> compactorLockPaths =
context.getServerPaths().getCompactor(rg -> true, AddressSelector.all(), false);
context.getServerPaths().getCompactor(rgp, AddressSelector.all(), false);
Set<String> compactorResourceGroupPaths = new HashSet<>();
compactorLockPaths.forEach(p -> compactorResourceGroupPaths
.add(p.toString().substring(0, p.toString().lastIndexOf('/'))));
Expand All @@ -151,7 +162,7 @@ public void execute(String[] args) throws Exception {
if (opts.zapScanServers) {
try {
Set<ServiceLockPath> sserverLockPaths =
context.getServerPaths().getScanServer(rg -> true, AddressSelector.all(), false);
context.getServerPaths().getScanServer(rgp, AddressSelector.all(), false);
for (ServiceLockPath sserverPath : sserverLockPaths) {
message("Deleting " + sserverPath + " from zookeeper", opts);
if (!zoo.getChildren(sserverPath.toString()).isEmpty()) {
Expand Down