forked from TrueCloudLab/frostfs-node
[#1714] lens: Add open*COMPONENT*
funcs
Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
parent
01d7c007aa
commit
fa18100489
10 changed files with 58 additions and 60 deletions
|
@ -27,12 +27,7 @@ func inspectFunc(cmd *cobra.Command, _ []string) {
|
|||
err := addr.DecodeString(vAddress)
|
||||
common.ExitOnErr(cmd, common.Errf("invalid address argument: %w", err))
|
||||
|
||||
blz := blobovnicza.New(
|
||||
blobovnicza.WithPath(vPath),
|
||||
blobovnicza.WithReadOnly(true),
|
||||
)
|
||||
common.ExitOnErr(cmd, blz.Open())
|
||||
|
||||
blz := openBlobovnicza(cmd)
|
||||
defer blz.Close()
|
||||
|
||||
var prm blobovnicza.GetPrm
|
||||
|
|
|
@ -30,13 +30,7 @@ func listFunc(cmd *cobra.Command, _ []string) {
|
|||
return err
|
||||
}
|
||||
|
||||
blz := blobovnicza.New(
|
||||
blobovnicza.WithPath(vPath),
|
||||
blobovnicza.WithReadOnly(true),
|
||||
)
|
||||
|
||||
common.ExitOnErr(cmd, blz.Open())
|
||||
|
||||
blz := openBlobovnicza(cmd)
|
||||
defer blz.Close()
|
||||
|
||||
err := blobovnicza.IterateAddresses(blz, wAddr)
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
package blobovnicza
|
||||
|
||||
import "github.com/spf13/cobra"
|
||||
import (
|
||||
common "github.com/nspcc-dev/neofs-node/cmd/neofs-lens/internal"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobovnicza"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var (
|
||||
vAddress string
|
||||
|
@ -17,3 +21,13 @@ var Root = &cobra.Command{
|
|||
func init() {
|
||||
Root.AddCommand(listCMD, inspectCMD)
|
||||
}
|
||||
|
||||
func openBlobovnicza(cmd *cobra.Command) *blobovnicza.Blobovnicza {
|
||||
blz := blobovnicza.New(
|
||||
blobovnicza.WithPath(vPath),
|
||||
blobovnicza.WithReadOnly(true),
|
||||
)
|
||||
common.ExitOnErr(cmd, blz.Open())
|
||||
|
||||
return blz
|
||||
}
|
||||
|
|
|
@ -3,7 +3,6 @@ package meta
|
|||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
common "github.com/nspcc-dev/neofs-node/cmd/neofs-lens/internal"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobovnicza"
|
||||
|
@ -11,7 +10,6 @@ import (
|
|||
"github.com/nspcc-dev/neofs-sdk-go/object"
|
||||
oid "github.com/nspcc-dev/neofs-sdk-go/object/id"
|
||||
"github.com/spf13/cobra"
|
||||
"go.etcd.io/bbolt"
|
||||
)
|
||||
|
||||
var inspectCMD = &cobra.Command{
|
||||
|
@ -32,16 +30,8 @@ func inspectFunc(cmd *cobra.Command, _ []string) {
|
|||
err := addr.DecodeString(vAddress)
|
||||
common.ExitOnErr(cmd, common.Errf("invalid address argument: %w", err))
|
||||
|
||||
db := meta.New(
|
||||
meta.WithPath(vPath),
|
||||
meta.WithBoltDBOptions(&bbolt.Options{
|
||||
ReadOnly: true,
|
||||
Timeout: 100 * time.Millisecond,
|
||||
}),
|
||||
meta.WithEpochState(epochState{}),
|
||||
)
|
||||
|
||||
common.ExitOnErr(cmd, common.Errf("could not open metabase: %w", db.Open(true)))
|
||||
db := openMeta(cmd)
|
||||
defer db.Close()
|
||||
|
||||
storageID := meta.StorageIDPrm{}
|
||||
storageID.SetAddress(addr)
|
||||
|
|
|
@ -1,12 +1,9 @@
|
|||
package meta
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
common "github.com/nspcc-dev/neofs-node/cmd/neofs-lens/internal"
|
||||
meta "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/metabase"
|
||||
"github.com/spf13/cobra"
|
||||
"go.etcd.io/bbolt"
|
||||
)
|
||||
|
||||
var listGarbageCMD = &cobra.Command{
|
||||
|
@ -21,16 +18,8 @@ func init() {
|
|||
}
|
||||
|
||||
func listGarbageFunc(cmd *cobra.Command, _ []string) {
|
||||
db := meta.New(
|
||||
meta.WithPath(vPath),
|
||||
meta.WithBoltDBOptions(&bbolt.Options{
|
||||
ReadOnly: true,
|
||||
Timeout: 100 * time.Millisecond,
|
||||
}),
|
||||
meta.WithEpochState(epochState{}),
|
||||
)
|
||||
|
||||
common.ExitOnErr(cmd, common.Errf("could not open metabase: %w", db.Open(true)))
|
||||
db := openMeta(cmd)
|
||||
defer db.Close()
|
||||
|
||||
var garbPrm meta.GarbageIterationPrm
|
||||
garbPrm.SetHandler(
|
||||
|
|
|
@ -1,12 +1,9 @@
|
|||
package meta
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
common "github.com/nspcc-dev/neofs-node/cmd/neofs-lens/internal"
|
||||
meta "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/metabase"
|
||||
"github.com/spf13/cobra"
|
||||
"go.etcd.io/bbolt"
|
||||
)
|
||||
|
||||
var listGraveyardCMD = &cobra.Command{
|
||||
|
@ -21,16 +18,8 @@ func init() {
|
|||
}
|
||||
|
||||
func listGraveyardFunc(cmd *cobra.Command, _ []string) {
|
||||
db := meta.New(
|
||||
meta.WithPath(vPath),
|
||||
meta.WithBoltDBOptions(&bbolt.Options{
|
||||
ReadOnly: true,
|
||||
Timeout: 100 * time.Millisecond,
|
||||
}),
|
||||
meta.WithEpochState(epochState{}),
|
||||
)
|
||||
|
||||
common.ExitOnErr(cmd, common.Errf("could not open metabase: %w", db.Open(true)))
|
||||
db := openMeta(cmd)
|
||||
defer db.Close()
|
||||
|
||||
var gravePrm meta.GraveyardIterationPrm
|
||||
gravePrm.SetHandler(
|
||||
|
|
|
@ -1,7 +1,12 @@
|
|||
package meta
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
common "github.com/nspcc-dev/neofs-node/cmd/neofs-lens/internal"
|
||||
meta "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/metabase"
|
||||
"github.com/spf13/cobra"
|
||||
"go.etcd.io/bbolt"
|
||||
)
|
||||
|
||||
var (
|
||||
|
@ -28,3 +33,17 @@ func init() {
|
|||
listGarbageCMD,
|
||||
)
|
||||
}
|
||||
|
||||
func openMeta(cmd *cobra.Command) *meta.DB {
|
||||
db := meta.New(
|
||||
meta.WithPath(vPath),
|
||||
meta.WithBoltDBOptions(&bbolt.Options{
|
||||
ReadOnly: true,
|
||||
Timeout: 100 * time.Millisecond,
|
||||
}),
|
||||
meta.WithEpochState(epochState{}),
|
||||
)
|
||||
common.ExitOnErr(cmd, common.Errf("could not open metabase: %w", db.Open(true)))
|
||||
|
||||
return db
|
||||
}
|
||||
|
|
|
@ -21,9 +21,7 @@ func init() {
|
|||
}
|
||||
|
||||
func inspectFunc(cmd *cobra.Command, _ []string) {
|
||||
db, err := writecache.OpenDB(vPath, true)
|
||||
common.ExitOnErr(cmd, common.Errf("could not open write-cache db: %w", err))
|
||||
|
||||
db := openWC(cmd)
|
||||
defer db.Close()
|
||||
|
||||
data, err := writecache.Get(db, []byte(vAddress))
|
||||
|
|
|
@ -30,11 +30,9 @@ func listFunc(cmd *cobra.Command, _ []string) {
|
|||
return err
|
||||
}
|
||||
|
||||
db, err := writecache.OpenDB(vPath, true)
|
||||
common.ExitOnErr(cmd, common.Errf("could not open write-cache db: %w", err))
|
||||
|
||||
db := openWC(cmd)
|
||||
defer db.Close()
|
||||
|
||||
err = writecache.IterateDB(db, wAddr)
|
||||
err := writecache.IterateDB(db, wAddr)
|
||||
common.ExitOnErr(cmd, common.Errf("write-cache iterator failure: %w", err))
|
||||
}
|
||||
|
|
|
@ -1,6 +1,11 @@
|
|||
package writecache
|
||||
|
||||
import "github.com/spf13/cobra"
|
||||
import (
|
||||
common "github.com/nspcc-dev/neofs-node/cmd/neofs-lens/internal"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/writecache"
|
||||
"github.com/spf13/cobra"
|
||||
"go.etcd.io/bbolt"
|
||||
)
|
||||
|
||||
var (
|
||||
vAddress string
|
||||
|
@ -17,3 +22,10 @@ var Root = &cobra.Command{
|
|||
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…
Reference in a new issue