2022-09-21 10:52:02 +00:00
|
|
|
package control
|
|
|
|
|
|
|
|
import (
|
2023-03-07 13:38:26 +00:00
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/rpc/client"
|
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/key"
|
|
|
|
commonCmd "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/internal/common"
|
|
|
|
"git.frostfs.info/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
|
|
|
|
})
|
2023-01-16 09:20:16 +00:00
|
|
|
commonCmd.ExitOnErr(cmd, "rpc error: %w", err)
|
2022-09-21 10:52:02 +00:00
|
|
|
|
|
|
|
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
|
|
|
}
|