2022-09-21 10:52:02 +00:00
|
|
|
package control
|
|
|
|
|
|
|
|
import (
|
2022-12-23 17:35:35 +00:00
|
|
|
"github.com/TrueCloudLab/frostfs-api-go/v2/rpc/client"
|
|
|
|
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/common"
|
|
|
|
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/key"
|
|
|
|
"github.com/TrueCloudLab/frostfs-node/pkg/services/control"
|
2022-09-21 10:52:02 +00:00
|
|
|
"github.com/spf13/cobra"
|
|
|
|
)
|
|
|
|
|
|
|
|
var flushCacheCmd = &cobra.Command{
|
|
|
|
Use: "flush-cache",
|
|
|
|
Short: "Flush objects from the write-cache to the main storage",
|
|
|
|
Long: "Flush objects from the write-cache to the main storage",
|
|
|
|
Run: flushCache,
|
|
|
|
}
|
|
|
|
|
|
|
|
func flushCache(cmd *cobra.Command, _ []string) {
|
|
|
|
pk := key.Get(cmd)
|
|
|
|
|
|
|
|
req := &control.FlushCacheRequest{Body: new(control.FlushCacheRequest_Body)}
|
2022-10-10 17:58:28 +00:00
|
|
|
req.Body.Shard_ID = getShardIDList(cmd)
|
2022-09-21 10:52:02 +00:00
|
|
|
|
|
|
|
signRequest(cmd, pk, req)
|
|
|
|
|
|
|
|
cli := getClient(cmd, pk)
|
|
|
|
|
|
|
|
var resp *control.FlushCacheResponse
|
|
|
|
var err error
|
|
|
|
err = cli.ExecRaw(func(client *client.Client) error {
|
|
|
|
resp, err = control.FlushCache(client, req)
|
|
|
|
return err
|
|
|
|
})
|
|
|
|
common.ExitOnErr(cmd, "rpc error: %w", err)
|
|
|
|
|
|
|
|
verifyResponse(cmd, resp.GetSignature(), resp.GetBody())
|
|
|
|
|
|
|
|
cmd.Println("Write-cache has been flushed.")
|
|
|
|
}
|
|
|
|
|
|
|
|
func initControlFlushCacheCmd() {
|
2022-10-17 15:37:15 +00:00
|
|
|
initControlFlags(flushCacheCmd)
|
2022-09-21 10:52:02 +00:00
|
|
|
|
|
|
|
ff := flushCacheCmd.Flags()
|
2022-10-10 17:58:28 +00:00
|
|
|
ff.StringSlice(shardIDFlag, nil, "List of shard IDs in base58 encoding")
|
2022-10-10 18:14:12 +00:00
|
|
|
ff.Bool(shardAllFlag, false, "Process all shards")
|
2022-09-21 10:52:02 +00:00
|
|
|
|
2022-10-10 18:14:12 +00:00
|
|
|
flushCacheCmd.MarkFlagsMutuallyExclusive(shardIDFlag, shardAllFlag)
|
2022-09-21 10:52:02 +00:00
|
|
|
}
|