MCPcopy
hub / github.com/cubefs/cubefs / sendSuspendRequest

Function sendSuspendRequest

client/fuse.go:189–225  ·  view source on GitHub ↗
(port string, udsListener net.Listener)

Source from the content-addressed store, hash-verified

187}
188
189func sendSuspendRequest(port string, udsListener net.Listener) (err error) {
190 var (
191 req *http.Request
192 resp *http.Response
193 data []byte
194 )
195 udsFilePath := udsListener.Addr().String()
196
197 url := fmt.Sprintf("http://%s:%s/suspend?sock=%s", DefaultIP, port, udsFilePath)
198 if req, err = http.NewRequest("POST", url, nil); err != nil {
199 log.LogErrorf("Failed to get new request: %v\n", err)
200 return err
201 }
202 req.Header.Set("Content-Type", "application/text")
203
204 client := http.DefaultClient
205 client.Timeout = 120 * time.Second
206 if resp, err = client.Do(req); err != nil {
207 log.LogErrorf("Failed to post request: %v\n", err)
208 return err
209 }
210 defer resp.Body.Close()
211
212 if data, err = io.ReadAll(resp.Body); err != nil {
213 log.LogErrorf("Failed to read response: %v\n", err)
214 return err
215 }
216
217 if resp.StatusCode == http.StatusOK {
218 log.LogInfof("\n==> %s\n==> Could restore cfs-client now with -r option.\n\n", string(data))
219 } else {
220 log.LogErrorf("\n==> %s\n==> Status: %s\n\n", string(data), resp.Status)
221 return fmt.Errorf(resp.Status)
222 }
223
224 return nil
225}
226
227func sendResumeRequest(port string) (err error) {
228 var (

Callers 1

doSuspendFunction · 0.85

Calls 9

LogErrorfFunction · 0.92
LogInfofFunction · 0.92
StringMethod · 0.65
SetMethod · 0.65
DoMethod · 0.65
CloseMethod · 0.65
ReadAllMethod · 0.65
ErrorfMethod · 0.65
AddrMethod · 0.45

Tested by

no test coverage detected