-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add process subcommands for multiple nodes
Add `process` commands with multiple nodes to golang CLI as part of #17522 `bin/alluxio-start.sh masters` -> `bin/cli.sh process start masters` `bin/alluxio-start.sh job_masters` -> `bin/cli.sh process start job_masters` `bin/alluxio-start.sh workers` -> `bin/cli.sh process start workers` `bin/alluxio-start.sh job_workers` -> `bin/cli.sh process start job_workers` `bin/alluxio-start.sh proxies` -> `bin/cli.sh process start proxies` `bin/alluxio-start.sh all` -> `bin/cli.sh process start all` `bin/alluxio-start.sh local` -> `bin/cli.sh process start local` `bin/alluxio-stop.sh masters` -> `bin/cli.sh process stop masters` `bin/alluxio-stop.sh job_masters` -> `bin/cli.sh process stop job_masters` `bin/alluxio-stop.sh workers` -> `bin/cli.sh process stop workers` `bin/alluxio-stop.sh job_workers` -> `bin/cli.sh process stop job_workers` `bin/alluxio-stop.sh proxies` -> `bin/cli.sh process stop proxies` `bin/alluxio-stop.sh all` -> `bin/cli.sh process stop all` `bin/alluxio-stop.sh local` -> `bin/cli.sh process stop local` For command `process start/stop` on multiple nodes, using crypto's `ssh` package to create an SSH session, connect to masters, workers or all nodes, then send according subcommand on single nodes to these nodes. pr-link: #17887 change-id: cid-0a660de35945738c065dae2f008a61d48f6b3be9
- Loading branch information
Showing
14 changed files
with
745 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/* | ||
* The Alluxio Open Foundation licenses this work under the Apache License, version 2.0 | ||
* (the "License"). You may not use this work except in compliance with the License, which is | ||
* available at www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, | ||
* either express or implied, as more fully set forth in the License. | ||
* | ||
* See the NOTICE file distributed with this work for information regarding copyright ownership. | ||
*/ | ||
|
||
package processes | ||
|
||
import ( | ||
"github.com/palantir/stacktrace" | ||
"github.com/spf13/cobra" | ||
"github.com/spf13/viper" | ||
|
||
"alluxio.org/cli/env" | ||
) | ||
|
||
var All = &AllProcess{ | ||
BaseProcess: &env.BaseProcess{ | ||
Name: "all", | ||
}, | ||
Processes: []env.Process{ | ||
Masters, | ||
JobMasters, | ||
Workers, | ||
JobWorkers, | ||
Proxies, | ||
}, | ||
} | ||
|
||
type AllProcess struct { | ||
*env.BaseProcess | ||
Processes []env.Process | ||
} | ||
|
||
func (p *AllProcess) SetEnvVars(envVar *viper.Viper) { | ||
return | ||
} | ||
|
||
func (p *AllProcess) Base() *env.BaseProcess { | ||
return p.BaseProcess | ||
} | ||
|
||
func (p *AllProcess) StartCmd(cmd *cobra.Command) *cobra.Command { | ||
cmd.Use = p.Name | ||
return cmd | ||
} | ||
|
||
func (p *AllProcess) StopCmd(cmd *cobra.Command) *cobra.Command { | ||
cmd.Use = p.Name | ||
return cmd | ||
} | ||
|
||
func (p *AllProcess) Start(cmd *env.StartProcessCommand) error { | ||
for i := 0; i < len(p.Processes); i++ { | ||
subProcess := p.Processes[i] | ||
if err := subProcess.Start(cmd); err != nil { | ||
return stacktrace.Propagate(err, "Error starting subprocesses for %s", p.Processes[i]) | ||
} | ||
} | ||
return nil | ||
} | ||
|
||
func (p *AllProcess) Stop(cmd *env.StopProcessCommand) error { | ||
for i := len(p.Processes) - 1; i >= 0; i-- { | ||
subProcess := p.Processes[i] | ||
if err := subProcess.Stop(cmd); err != nil { | ||
return stacktrace.Propagate(err, "Error stopping subprocesses for %s", p.Processes[i]) | ||
} | ||
} | ||
return nil | ||
} |
Oops, something went wrong.