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

Add process subcommands for multiple nodes #17887

Merged
merged 31 commits into from
Aug 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
a77f8dd
resolved untrimmed path on finding which java
twalluxio Jul 27, 2023
8a60780
guidelines for workers.go
twalluxio Jul 28, 2023
4c0b8b4
add entry for command workers, do nothing
twalluxio Jul 31, 2023
d2c0a3d
can ssh to workers and execute start worker commands
twalluxio Jul 31, 2023
ee9306d
fix typo, add comments and to-dos
twalluxio Jul 31, 2023
fe2ccea
able to execute commands on workers
twalluxio Aug 1, 2023
c014ebf
able to complete worker start on workers
twalluxio Aug 1, 2023
3fd38cd
re-stucture and polish workers.go
twalluxio Aug 1, 2023
bfa1a87
polished code, support process start flags
twalluxio Aug 1, 2023
37dc475
create proxies.go, do nothing
twalluxio Aug 1, 2023
aac60e9
create masters.go, do nothing
twalluxio Aug 1, 2023
b862cdc
add start/stop commands for process start/stop masters
twalluxio Aug 1, 2023
41e45db
add start/stop commands for process start/stop proxies
twalluxio Aug 1, 2023
10bb938
register masters and proxies commands
twalluxio Aug 1, 2023
cdbdeda
move common functions to common.go
twalluxio Aug 2, 2023
3f0e60e
restructured runCommands(), allow create multiple sessions
twalluxio Aug 2, 2023
8f3bbc5
create and register job_masters.go, job_workers.go
twalluxio Aug 2, 2023
24b44cf
create and register all.go, local.go
twalluxio Aug 2, 2023
814cfe7
change default path and add flags for stop commands
twalluxio Aug 4, 2023
4daa26d
rewrite local and all commands
twalluxio Aug 4, 2023
946de5d
improve code and log readability
twalluxio Aug 4, 2023
872ba01
Cleanup procedure
twalluxio Aug 7, 2023
58a59f6
combine getMasters() and getWorkers() to getNodes(bool), move cliPath…
twalluxio Aug 7, 2023
281dbe7
rewrite start/stop methods for less redundancy
twalluxio Aug 7, 2023
8c28f25
configure username and ssh port
twalluxio Aug 7, 2023
0b7522c
use go channel & goroutine to trigger ssh commands
twalluxio Aug 7, 2023
e18573c
restructured common.go
twalluxio Aug 7, 2023
2521dd8
add sync lock for reading hostnames
twalluxio Aug 7, 2023
ac5bf44
small feature fix; avoid use magic strings
twalluxio Aug 8, 2023
0fd9cb1
join with space " " instead of empty string ""
twalluxio Aug 8, 2023
390c717
Merge branch 'golangCli' into golangCli-rsync3
Xenorith Aug 8, 2023
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
2 changes: 1 addition & 1 deletion cli/src/alluxio.org/cli/env/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ func checkAndSetJava(envVar *viper.Viper) error {
// check if java is available via `PATH` using `which`
whichJavaPath, err := exec.Command("which", "java").Output()
if err == nil {
envVar.Set(ConfJava.EnvVar, string(whichJavaPath))
envVar.Set(ConfJava.EnvVar, strings.TrimSpace(string(whichJavaPath)))
return nil
}
// cannot find java
Expand Down
4 changes: 3 additions & 1 deletion cli/src/alluxio.org/cli/env/process_start.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@ import (
)

type StartProcessCommand struct {
Name string
AsyncStart bool
SkipKillOnStart bool
}

func (c *StartProcessCommand) ToCommand() *cobra.Command {
c.Name = "start"
cmd := &cobra.Command{
Use: "start",
Use: c.Name,
Short: "Starts a process",
}
cmd.PersistentFlags().BoolVarP(&c.SkipKillOnStart, "skip-kill-prev", "N", false, "Avoid killing previous running processes when starting")
Expand Down
4 changes: 3 additions & 1 deletion cli/src/alluxio.org/cli/env/process_stop.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@ package env
import "github.com/spf13/cobra"

type StopProcessCommand struct {
Name string
SoftKill bool
}

func (c *StopProcessCommand) ToCommand() *cobra.Command {
c.Name = "stop"
cmd := &cobra.Command{
Use: "stop",
Use: c.Name,
Short: "Stops a process",
}
cmd.PersistentFlags().BoolVarP(&c.SoftKill, "soft", "s", false, "Soft kill only, don't forcibly kill the process")
Expand Down
7 changes: 7 additions & 0 deletions cli/src/alluxio.org/cli/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,18 @@ import (

func main() {
for _, p := range []env.Process{
processes.All,
processes.JobMaster,
processes.JobMasters,
processes.JobWorker,
processes.JobWorkers,
processes.Local,
processes.Master,
processes.Masters,
processes.Proxy,
processes.Proxies,
processes.Worker,
processes.Workers,
} {
env.RegisterProcess(p)
}
Expand Down
76 changes: 76 additions & 0 deletions cli/src/alluxio.org/cli/processes/all.go
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
}
Loading
Loading