MCPcopy
hub / github.com/cubefs/cubefs / getInodeHandler

Method getInodeHandler

metanode/api_handler.go:308–376  ·  view source on GitHub ↗
(w http.ResponseWriter, r *http.Request)

Source from the content-addressed store, hash-verified

306}
307
308func (m *MetaNode) getInodeHandler(w http.ResponseWriter, r *http.Request) {
309 resp := NewAPIResponse(http.StatusBadRequest, "")
310 defer func() {
311 data, _ := resp.Marshal()
312 if _, err := w.Write(data); err != nil {
313 log.LogErrorf("[getInodeHandler] response %s", err)
314 }
315 }()
316 var pid, ino common.Uint
317 var verAll common.Bool
318 if err := parseArgs(r, pid.PID(), ino.Ino(),
319 verAll.Key("verAll").OmitEmpty().OmitError()); err != nil {
320 resp.Msg = err.Error()
321 return
322 }
323
324 verSeq, err := m.getRealVerSeq(w, r)
325 if err != nil {
326 resp.Msg = err.Error()
327 return
328 }
329 mp, err := m.metadataManager.GetPartition(pid.V)
330 if err != nil {
331 resp.Code = http.StatusNotFound
332 resp.Msg = err.Error()
333 return
334 }
335 req := &InodeGetReq{
336 PartitionID: pid.V,
337 Inode: ino.V,
338 VerSeq: verSeq,
339 VerAll: verAll.V,
340 }
341 p := &Packet{}
342 err = mp.InodeGet(req, p)
343 if err != nil {
344 resp.Code = http.StatusInternalServerError
345 resp.Msg = err.Error()
346 return
347 }
348 resp.Code = http.StatusSeeOther
349 resp.Msg = p.GetResultMsg()
350 if len(p.Data) == 0 {
351 return
352 }
353 inodeResp := &proto.InodeGetResponse{}
354 err = json.Unmarshal(p.Data, inodeResp)
355 if err != nil {
356 resp.Code = http.StatusInternalServerError
357 resp.Msg = err.Error()
358 return
359 }
360 p = &Packet{}
361 err = mp.InodeGetAccessTime(req, p)
362 if err != nil {
363 resp.Code = http.StatusInternalServerError
364 resp.Msg = err.Error()
365 return

Callers

nothing calls this directly

Calls 15

MarshalMethod · 0.95
PIDMethod · 0.95
InoMethod · 0.95
KeyMethod · 0.95
getRealVerSeqMethod · 0.95
GetResultMsgMethod · 0.95
LogErrorfFunction · 0.92
NewAPIResponseFunction · 0.85
OmitErrorMethod · 0.80
OmitEmptyMethod · 0.80
WriteMethod · 0.65
ErrorMethod · 0.65

Tested by

no test coverage detected