MCPcopy
hub / github.com/github/gh-ost / applyServerCommand

Method applyServerCommand

go/logic/server.go:196–462  ·  view source on GitHub ↗

applyServerCommand parses and executes commands by user

(command string, writer *bufio.Writer)

Source from the content-addressed store, hash-verified

194
195// applyServerCommand parses and executes commands by user
196func (srv *Server) applyServerCommand(command string, writer *bufio.Writer) (printStatusRule PrintStatusRule, err error) {
197 tokens := strings.SplitN(command, "=", 2)
198 command = strings.TrimSpace(tokens[0])
199 arg := ""
200 if len(tokens) > 1 {
201 arg = strings.TrimSpace(tokens[1])
202 if unquoted, err := strconv.Unquote(arg); err == nil {
203 arg = unquoted
204 }
205 }
206 argIsQuestion := (arg == "?")
207 throttleHint := "# Note: you may only throttle for as long as your binary logs are not purged"
208
209 if err := srv.hooksExecutor.OnInteractiveCommand(command); err != nil {
210 return NoPrintStatusRule, err
211 }
212
213 switch command {
214 case "help":
215 {
216 fmt.Fprint(writer, `available commands:
217status # Print a detailed status message
218sup # Print a short status message
219cpu-profile=<options> # Print a base64-encoded runtime/pprof CPU profile using a duration, default: 30s. Comma-separated options 'gzip' and/or 'block' (blocked profile) may follow the profile duration
220coordinates # Print the currently inspected coordinates
221applier # Print the hostname of the applier
222inspector # Print the hostname of the inspector
223chunk-size=<newsize> # Set a new chunk-size
224dml-batch-size=<newsize> # Set a new dml-batch-size
225nice-ratio=<ratio> # Set a new nice-ratio, immediate sleep after each row-copy operation, float (examples: 0 is aggressive, 0.7 adds 70% runtime, 1.0 doubles runtime, 2.0 triples runtime, ...)
226critical-load=<load> # Set a new set of max-load thresholds
227max-lag-millis=<max-lag> # Set a new replication lag threshold
228replication-lag-query=<query> # Set a new query that determines replication lag (no quotes)
229max-load=<load> # Set a new set of max-load thresholds
230throttle-query=<query> # Set a new throttle-query (no quotes)
231throttle-http=<URL> # Set a new throttle URL
232throttle-control-replicas=<replicas> # Set a new comma delimited list of throttle control replicas
233throttle # Force throttling
234no-throttle # End forced throttling (other throttling may still apply)
235postpone-cut-over-flag-file=<path> # Postpone the cut-over phase, writing a cut over flag file to the given path
236unpostpone # Bail out a cut-over postpone; proceed to cut-over
237panic # panic and quit without cleanup
238help # This message
239- use '?' (question mark) as argument to get info rather than set. e.g. "max-load=?" will just print out current max-load.
240`)
241 }
242 case "sup":
243 return ForcePrintStatusOnlyRule, nil
244 case "info", "status":
245 return ForcePrintStatusAndHintRule, nil
246 case "cpu-profile":
247 cpuProfile, err := srv.runCPUProfile(arg)
248 if err == nil {
249 fmt.Fprint(base64.NewEncoder(base64.StdEncoding, writer), cpuProfile)
250 }
251 return NoPrintStatusRule, err
252 case "coordinates":
253 {

Callers 1

onServerCommandMethod · 0.95

Calls 15

runCPUProfileMethod · 0.95
SendWithContextFunction · 0.92
SetChunkSizeMethod · 0.80
SetDMLBatchSizeMethod · 0.80
GetNiceRatioMethod · 0.80
SetNiceRatioMethod · 0.80
GetMaxLoadMethod · 0.80
ReadMaxLoadMethod · 0.80
GetCriticalLoadMethod · 0.80

Tested by

no test coverage detected