forked from TrueCloudLab/frostfs-node
Move to frostfs-node
Signed-off-by: Pavel Karpy <p.karpy@yadro.com>
This commit is contained in:
parent
42554a9298
commit
923f84722a
934 changed files with 3470 additions and 3451 deletions
35
cmd/frostfs-lens/internal/writecache/inspect.go
Normal file
35
cmd/frostfs-lens/internal/writecache/inspect.go
Normal file
|
@ -0,0 +1,35 @@
|
|||
package writecache
|
||||
|
||||
import (
|
||||
common "github.com/TrueCloudLab/frostfs-node/cmd/frostfs-lens/internal"
|
||||
"github.com/TrueCloudLab/frostfs-node/pkg/local_object_storage/writecache"
|
||||
"github.com/TrueCloudLab/frostfs-sdk-go/object"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var inspectCMD = &cobra.Command{
|
||||
Use: "inspect",
|
||||
Short: "Object inspection",
|
||||
Long: `Inspect specific object in a write-cache.`,
|
||||
Run: inspectFunc,
|
||||
}
|
||||
|
||||
func init() {
|
||||
common.AddAddressFlag(inspectCMD, &vAddress)
|
||||
common.AddComponentPathFlag(inspectCMD, &vPath)
|
||||
common.AddOutputFileFlag(inspectCMD, &vOut)
|
||||
}
|
||||
|
||||
func inspectFunc(cmd *cobra.Command, _ []string) {
|
||||
db := openWC(cmd)
|
||||
defer db.Close()
|
||||
|
||||
data, err := writecache.Get(db, []byte(vAddress))
|
||||
common.ExitOnErr(cmd, common.Errf("could not fetch object: %w", err))
|
||||
|
||||
var o object.Object
|
||||
common.ExitOnErr(cmd, common.Errf("could not unmarshal object: %w", o.Unmarshal(data)))
|
||||
|
||||
common.PrintObjectHeader(cmd, o)
|
||||
common.WriteObjectToFile(cmd, vOut, data)
|
||||
}
|
38
cmd/frostfs-lens/internal/writecache/list.go
Normal file
38
cmd/frostfs-lens/internal/writecache/list.go
Normal file
|
@ -0,0 +1,38 @@
|
|||
package writecache
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
|
||||
common "github.com/TrueCloudLab/frostfs-node/cmd/frostfs-lens/internal"
|
||||
"github.com/TrueCloudLab/frostfs-node/pkg/local_object_storage/writecache"
|
||||
oid "github.com/TrueCloudLab/frostfs-sdk-go/object/id"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var listCMD = &cobra.Command{
|
||||
Use: "inspect",
|
||||
Short: "Object inspection",
|
||||
Long: `Inspect specific object in a write-cache.`,
|
||||
Run: listFunc,
|
||||
}
|
||||
|
||||
func init() {
|
||||
common.AddComponentPathFlag(listCMD, &vPath)
|
||||
}
|
||||
|
||||
func listFunc(cmd *cobra.Command, _ []string) {
|
||||
// other targets can be supported
|
||||
w := cmd.OutOrStderr()
|
||||
|
||||
wAddr := func(addr oid.Address) error {
|
||||
_, err := io.WriteString(w, fmt.Sprintf("%s\n", addr))
|
||||
return err
|
||||
}
|
||||
|
||||
db := openWC(cmd)
|
||||
defer db.Close()
|
||||
|
||||
err := writecache.IterateDB(db, wAddr)
|
||||
common.ExitOnErr(cmd, common.Errf("write-cache iterator failure: %w", err))
|
||||
}
|
31
cmd/frostfs-lens/internal/writecache/root.go
Normal file
31
cmd/frostfs-lens/internal/writecache/root.go
Normal file
|
@ -0,0 +1,31 @@
|
|||
package writecache
|
||||
|
||||
import (
|
||||
common "github.com/TrueCloudLab/frostfs-node/cmd/frostfs-lens/internal"
|
||||
"github.com/TrueCloudLab/frostfs-node/pkg/local_object_storage/writecache"
|
||||
"github.com/spf13/cobra"
|
||||
"go.etcd.io/bbolt"
|
||||
)
|
||||
|
||||
var (
|
||||
vAddress string
|
||||
vPath string
|
||||
vOut string
|
||||
)
|
||||
|
||||
// Root contains `write-cache` command definition.
|
||||
var Root = &cobra.Command{
|
||||
Use: "write-cache",
|
||||
Short: "Operations with write-cache",
|
||||
}
|
||||
|
||||
func init() {
|
||||
Root.AddCommand(listCMD, inspectCMD)
|
||||
}
|
||||
|
||||
func openWC(cmd *cobra.Command) *bbolt.DB {
|
||||
db, err := writecache.OpenDB(vPath, true)
|
||||
common.ExitOnErr(cmd, common.Errf("could not open write-cache db: %w", err))
|
||||
|
||||
return db
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue