-
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 CLI tools for debugging and analyzing caching issues
Add the following CLI tools for debugging and analyzing caching issues: 1. checkCaching. Checks if files under a path have been cached in alluxio. 2. location. Displays the list of hosts storing the specified file. 3. consistentHash. This command is for checking whether the consistent hash ring is changed or not. pr-link: #18151 change-id: cid-c89b98da70a5270070d873bdcfce1aa9b23cf083
- Loading branch information
1 parent
8bba797
commit 6f35645
Showing
18 changed files
with
1,238 additions
and
36 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/* | ||
* 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 fs | ||
|
||
import ( | ||
"strconv" | ||
|
||
"github.com/spf13/cobra" | ||
|
||
"alluxio.org/cli/env" | ||
) | ||
|
||
func CheckCached(className string) env.Command { | ||
return &CheckCachedCommand{ | ||
BaseJavaCommand: &env.BaseJavaCommand{ | ||
CommandName: "check-cached", | ||
JavaClassName: className, | ||
Parameters: []string{"check-cached"}, | ||
}, | ||
} | ||
} | ||
|
||
type CheckCachedCommand struct { | ||
*env.BaseJavaCommand | ||
|
||
sample int | ||
limit int | ||
} | ||
|
||
func (c *CheckCachedCommand) Base() *env.BaseJavaCommand { | ||
return c.BaseJavaCommand | ||
} | ||
|
||
func (c *CheckCachedCommand) ToCommand() *cobra.Command { | ||
cmd := c.Base().InitRunJavaClassCmd(&cobra.Command{ | ||
Use: "check-cached [path]", | ||
Short: "Checks if files under a path have been cached in alluxio.", | ||
Args: cobra.ExactArgs(1), | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
return c.Run(args) | ||
}, | ||
}) | ||
cmd.Flags().IntVar(&c.sample, "sample", 1, "Sample ratio, 10 means sample 1 in every 10 files.") | ||
cmd.Flags().IntVar(&c.limit, "limit", 1000, "Limit number of files to check") | ||
return cmd | ||
} | ||
|
||
func (c *CheckCachedCommand) Run(args []string) error { | ||
javaArgs := []string{"check-cached"} | ||
if c.sample != 0 { | ||
javaArgs = append(javaArgs, "--sample", strconv.Itoa(c.sample)) | ||
} | ||
if c.limit != 0 { | ||
javaArgs = append(javaArgs, "--limit", strconv.Itoa(c.limit)) | ||
} | ||
javaArgs = append(javaArgs, args...) | ||
return c.Base().Run(javaArgs) | ||
} |
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,74 @@ | ||
/* | ||
* 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 fs | ||
|
||
import ( | ||
"alluxio.org/cli/env" | ||
"github.com/palantir/stacktrace" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
func ConsistentHash(className string) env.Command { | ||
return &ConsistentHashCommand{ | ||
BaseJavaCommand: &env.BaseJavaCommand{ | ||
CommandName: "consistent-hash", | ||
JavaClassName: className, | ||
Parameters: []string{"consistent-hash"}, | ||
}, | ||
} | ||
} | ||
|
||
type ConsistentHashCommand struct { | ||
*env.BaseJavaCommand | ||
|
||
createCheckFile bool | ||
compareCheckFiles bool | ||
cleanCheckData bool | ||
} | ||
|
||
func (c *ConsistentHashCommand) Base() *env.BaseJavaCommand { | ||
return c.BaseJavaCommand | ||
} | ||
|
||
func (c *ConsistentHashCommand) ToCommand() *cobra.Command { | ||
cmd := c.Base().InitRunJavaClassCmd(&cobra.Command{ | ||
Use: "consistent-hash [--create]|[--compare <1stCheckFilePath> <2ndCheckFilePath>]|[--clean] ", | ||
Short: "This command is for checking whether the consistent hash ring is changed or not", | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
return c.Run(args) | ||
}, | ||
}) | ||
cmd.Flags().BoolVar(&c.createCheckFile, "create", false, "Generate check file.") | ||
cmd.Flags().BoolVar(&c.compareCheckFiles, "compare", false, "Compare check files to see if the hash ring has changed and if data lost.") | ||
cmd.Flags().BoolVar(&c.cleanCheckData, "clean", false, "Clean all check data.") | ||
cmd.MarkFlagsMutuallyExclusive("create", "compare", "clean") | ||
return cmd | ||
} | ||
|
||
func (c *ConsistentHashCommand) Run(args []string) error { | ||
javaArgs := []string{} | ||
if c.createCheckFile { | ||
javaArgs = append(javaArgs, "--create") | ||
} | ||
if c.compareCheckFiles { | ||
if len(args) != 2 { | ||
return stacktrace.NewError("expect 2 arguments with --compare-check-files but got %v", len(args)) | ||
} | ||
javaArgs = append(javaArgs, "--compare") | ||
} | ||
if c.cleanCheckData { | ||
javaArgs = append(javaArgs, "--clean") | ||
} | ||
|
||
javaArgs = append(javaArgs, args...) | ||
return c.Base().Run(javaArgs) | ||
} |
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,52 @@ | ||
/* | ||
* 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 fs | ||
|
||
import ( | ||
"github.com/spf13/cobra" | ||
|
||
"alluxio.org/cli/env" | ||
) | ||
|
||
func Location(className string) env.Command { | ||
return &LocationCommand{ | ||
BaseJavaCommand: &env.BaseJavaCommand{ | ||
CommandName: "location", | ||
JavaClassName: className, | ||
Parameters: []string{"location"}, | ||
}, | ||
} | ||
} | ||
|
||
type LocationCommand struct { | ||
*env.BaseJavaCommand | ||
} | ||
|
||
func (c *LocationCommand) Base() *env.BaseJavaCommand { | ||
return c.BaseJavaCommand | ||
} | ||
|
||
func (c *LocationCommand) ToCommand() *cobra.Command { | ||
cmd := c.Base().InitRunJavaClassCmd(&cobra.Command{ | ||
Use: "location [path]", | ||
Short: "Displays the list of hosts storing the specified file.", | ||
Args: cobra.ExactArgs(1), | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
return c.Run(args) | ||
}, | ||
}) | ||
return cmd | ||
} | ||
|
||
func (c *LocationCommand) Run(args []string) error { | ||
return c.Base().Run(args) | ||
} |
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
Oops, something went wrong.