-
Notifications
You must be signed in to change notification settings - Fork 178
/
checkpoint_trigger.go
39 lines (30 loc) · 1.09 KB
/
checkpoint_trigger.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package execution
import (
"context"
"github.com/rs/zerolog/log"
"go.uber.org/atomic"
"github.com/onflow/flow-go/admin"
"github.com/onflow/flow-go/admin/commands"
)
var _ commands.AdminCommand = (*TriggerCheckpointCommand)(nil)
// TriggerCheckpointCommand will send a signal to compactor to trigger checkpoint
// once finishing writing the current WAL segment file
type TriggerCheckpointCommand struct {
trigger *atomic.Bool
}
func NewTriggerCheckpointCommand(trigger *atomic.Bool) *TriggerCheckpointCommand {
return &TriggerCheckpointCommand{
trigger: trigger,
}
}
func (s *TriggerCheckpointCommand) Handler(_ context.Context, _ *admin.CommandRequest) (interface{}, error) {
if s.trigger.CompareAndSwap(false, true) {
log.Info().Msgf("admintool: trigger checkpoint as soon as finishing writing the current segment file. you can find log about 'compactor' to check the checkpointing progress")
} else {
log.Info().Msgf("admintool: checkpoint is already set to be triggered")
}
return "ok", nil
}
func (s *TriggerCheckpointCommand) Validator(_ *admin.CommandRequest) error {
return nil
}