Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use the Migrator class

2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly introduces how to use the Migrator class, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand it.

The Migrator class description:

Class Migrator {MDSRank * mds; record mds information MDCache * cache; record MDCache information struct export_state_t {int state; record current status of export mds_rank_t peer; record export to peer mds rank information uint64_t tid Record export to peer session id information set warning_ack_waiting; wait for warning ack mds collection set notify_ack_waiting; wait for notify ack mds collection map peer_imported; record export peer information list waiting_for_finish Record the collection waiting for finish MutationRef mut; MutationImpl object reference utime_t last_cum_auth_pins_change; int last_cum_auth_pins; int num_remote_waiters; remote auth pin waiters}; map export_state Export status collection list export_queue; export queue struct import_state_t {int state; mds_rank_t peer; uint64_t tid; set bystanders; list bound_ls; list updated_scatterlocks; map client_map; map peer_exports; MutationRef mut;}; map import_state;}

Migrator class methods:

Migrator::dispatch (m) Core Distribution handler

| | _ _ determines the subsequent processing according to the type of m |

| | _ _ type is MSG_MDS_EXPORTDIRDISCOVER |

| | _ _ call handle_export_discover (MExportDirDiscover* m) |

| | _ _ type is MSG_MDS_EXPORTDIRPREP |

| | _ _ call handle_export_prep (MExportDirPrep* m) |

| | _ _ type is MSG_MDS_EXPORTDIR |

| | _ _ call handle_export_dir (MExportDir* m) |

| | _ _ type is MSG_MDS_EXPORTDIRFINISH |

| | _ _ call handle_export_finsih (MExportDirFinish* m) |

| | _ _ type is MSG_MDS_EXPORTDIRCANCEL |

| | _ _ call handle_export_cancel (MExportDirCancel* m) |

| | _ _ type is MSG_MDS_EXPORTDIRDISCOVERACK |

| | _ _ call handle_export_discover_ack (MExportDirDiscoverAck* m) |

| | _ _ type is MSG_MDS_EXPORTDIRPREACK |

| | _ _ call handle_export_prep_ack (MExportDirPrepAck* m) |

| | _ _ type is MSG_MDS_EXPORTDIRACK |

| | _ _ call handle_export_ack (MExportDirAck* m) |

| | _ _ type is MSG_MDS_EXPORTDIRNOTIFYACK |

| | _ _ call handle_export_notify_ack (MExportDirNotifyAck* m) |

| | _ _ type is MSG_MDS_EXPORTDIRNOTIFY |

| | _ _ call handle_export_dir_notify (MExportDirNotify* m) |

| | _ _ type is MSG_MDS_EXPORTCAPS |

| | _ _ call handle_export_caps (MExportCaps* m) |

| | _ _ type is MSG_MDS_GATHERCAPS |

| | _ _ call handle_gather_caps (MGatherCaps* m) |

Migrator::export_empty_import (dir)

| | inode node corresponding to _ _ dir belongs to auth |

| | _ _ return directly |

| | _ _ dir belongs to auth |

| | _ _ return directly |

| | _ _ dir is freezing or frozen |

| | _ _ return directly |

| | _ _ dir is not an empty directory |

| | _ _ return directly |

| | _ _ dir is a root node |

| | _ _ return directly |

| | _ _ get the mds node where the export destination dir resides, namely: dir- > inode- > authority () .first |

| | _ _ call export_dir (dir, dest) to perform the actual export operation |

Migrator::export_dir (dir, dest)

| | _ _ check whether MDCache is readonly (export in read-only mode is not currently supported) |

| | _ _ return directly |

| | _ _ check whether mdsmap is degraded (if cluster is in degraded status, it cannot be export) |

| | _ _ return directly |

| | _ _ check whether the inode of dir is system (not export system dir) |

| | _ _ return directly |

| | _ _ check whether the inode of dir is stray |

| | _ _ return directly |

| | _ _ check whether dir is in freezing or frozen |

| | _ _ return directly |

| | _ _ check whether dir is in EXPORTING status |

| | _ _ return directly |

| | _ _ execute the auth_pin of dir () |

| | _ _ sets the current status of dir to EXPORTING, that is, dir- > state_set (STATE_EXPORTING) |

| | _ _ get the MDRequestRef object from MDCache, that is, mds- > mdcache- > request_start_internal (EXPORTDIR) |

| | _ _ set the export_dir of _ more in the MDRequest class object to dir, that is, save the dir data to be export |

| | _ _ get the export_state_t object stat with dir as index from the export_state array |

| | _ _ set the state of stat to EXPORT_LOCKING |

| | _ _ set the peer of stat to dest |

| | _ _ set the tid of stat to mdr- > reqid.tid |

| | _ _ set the mut of stat to mdr |

| | _ _ call dispatch_export_dir (mdr) to send export dir request |

Migrator::dispatch_export_dir (mdr)

| | _ _ get the dir data to be export from the _ more of mdr, that is, mdr- > more ()-> export_dir |

| | _ _ find the export state entry corresponding to dir in the export_state array |

| | _ _ sets the current status of export_state_t to EXPORT_DISCOVERING |

| | _ _ create a MExportDirDiscover message |

| | _ _ send the message to the destination MDS process, that is, mds- > send_message_mds (discover, it- > second.peer) |

| | _ _ sets the last_cum_auth_pins_change in export_state_t to the current system time |

| | _ _ freeze the tree of the current dir, that is, dir- > freeze_tree () |

| | _ _ add the callback function C_MDC_ExportFreeze () of dir waiting for WAIT_FROZEN, that is, call the export_frozen () function |

Migrator::handle_export_discover (MExportDirDiscover * m) (opposite end)

| | _ _ get the mds_rank_t and dirfrag_t structure of the peer from the message, namely: from=m- > get_source_mds () / df = m-> get_dirfrag () |

| | _ _ traverse the import_state array |

| | _ _ if no corresponding item is found in the array and m-> started==false |

| | _ _ set m-> started=true |

| | _ _ update the corresponding entry in the import_state array, that is, state=IMPORT_DISCOVERING/peer=from/tid=m- > get_tid () |

| | _ _ get the CInode information of export's dir from MDCache, that is, in=cache- > get_inode (m-> get_dirfrag () .ino) |

| | _ _ update the corresponding entry in the import_state array, namely: state==IMPORT_DISCOVERED |

| | _ _ create a MExportDirDiscoverAck message |

| | _ _ send the class message back to the mds process, that is, mds- > send_message_mds () |

Migrator::handle_export_discover_ack (MExportDirDiscoverAck* m)

| | _ _ get the dirfrag from the message, and then get the CDir class object corresponding to dirfrag from MDCache, namely: cache- > get_dirfrag (m-> get_dirfrag ()) |

| | _ _ find the entry corresponding to dir in the export_state array |

| | _ _ set its status to EXPORT_FREEZING in the dir entry corresponding to the export_state array |

Migrator::export_frozen (dir, tid)

| | _ _ find the entry corresponding to dir from the export_state array |

| | _ _ get the CInode corresponding to the dir, that is, dir- > get_inode () |

| | _ _ create a new MutationImpl class object and put it in the mut of export_state_t |

| | _ _ create a MExportDirPrep message based on dirfrag and tid |

| | _ _ traverses dir's replicas array |

| | _ _ add the members of the array to the bystander of the MExportDirPrep class message |

| | _ _ add basedir to the basedir of MExportDirPrep messages |

| | _ _ traverse the bounds array |

| | _ _ add bounds members to the bound of MExportDirPrep messages |

| | _ _ Loop processes the following contents |

| | _ _ add the inode of bounds members to the inodes_added array |

| | _ _ traverses the parent directory of bounds members |

| | _ _ serialize dirfrag and start information to bufferlist |

| | _ _ write bufferlist to the trace of MExportDirPrep messages |

| | _ _ set the status in export_state_t to EXPORT_PREPPING |

| | _ _ send a MExportDirPrep message to the destination MDS, that is, mds- > send_message_mds () |

Migrator::handle_export_prep (MExportDirPrep * m) (opposite end)

| | _ _ find the corresponding dirfrag item in the message from the import_state array |

| | _ _ get the CInode corresponding to dir and dir from MDCache |

| | _ _ traverse the bounds array in the message |

| | _ _ add the contents of the array to the import_bound_fragset array |

| | _ _ if did_assim () in the message = = false |

| | _ _ sets the state of the corresponding item in the current import_state array to IMPORT_PREPPING |

| | _ _ parse traces array from message |

| | _ _ add the contents of the traces array to MDCache |

| | _ _ traverse the import_bound_fragset array |

| | _ _ from the inodeno_t of array members to the corresponding CInode structure |

| | _ _ calls the get_stickydirs () function corresponding to CInode |

| | _ _ traverse the import_bound_fragset array |

| | _ _ from the inodeno_t of array members to the corresponding CInode structure |

| | _ _ traverses all leaf nodes under fragset_t in the array members |

| | _ _ get the corresponding CDir data in MDCache according to the leaf node |

| | _ _ if the CDir data is not in MDCache |

| | _ _ execute the open_remote_dirfrag () function in MDCache to create the CDir |

| | _ _ insert the CDir data of the leaf node into the import_bounds array |

| | _ _ sets the status of the specified member of the import_state array to IMPORT_PREPPED |

| | _ _ create a MExportDirPreAck message |

| | _ _ call the send_message () method of mds to send the class message to the specified MDS process |

Migrator::handle_export_prep_ack (MExportDirPrepAck * m)

| | _ _ get the corresponding CDir class object based on the dirfrag of the message |

| | _ _ find the item corresponding to the CDir object in the export_state array |

| | _ _ traverse the replicas array |

| | _ _ insert mds_rank_t information into the warning_ack_waiting/notify_ack_waiting array in the export_state_t structure |

| | _ _ create a MExportDirNotify message |

| | _ _ send MEXportDirNotify messages to peer mds process |

| | _ _ sets the state in the export_state_t structure to EXPORT_WARNING |

Migrator::handle_export_notify (MExportDirNotify * m) (opposite end)

| | _ _ get the CDir class object corresponding to dirfrag in the message from MDCache |

| | _ _ create a MExportDirNotifyAck message |

| | _ _ call send_message_mds () of mds to send the class message back to the mds process |

Migrator::handle_export_notify_ack (MExportDirNotifyAck * m)

| | _ _ get the corresponding CDir class object based on the dirfrag of the message |

| | _ _ get peer mds_rank_t information from message |

| | _ _ if the entry corresponding to dir can be found in the export_state array |

| | _ _ if export _ state_t 's state==EXPORT_WARNING |

| | _ _ call export_go (dir) to perform the actual export operation |

| | _ _ if export _ state_t 's state==EXPORT_NOTIFYING |

| | _ _ call export_finish (dir) |

Migrator::export_go (dir)

| | _ _ call the wait_for_safe () function of mdlog in mds to set the callback function C_M_ExportGo (), and finally execute export_go_synced (dir, tid) |

| | mdlog of _ _ flush mds, namely: | mds- > mdlog- > flush () |

Migrator::export_go_synced (dir, tid)

| | _ _ find the entry corresponding to dir in the export_state array |

| | _ _ set its status to EXPORT_EXPORTING |

| | _ _ create a MExportDir message |

| | _ _ call encode_export_dir () to get the map information of export and the number of exported_inodes |

| | _ _ serialize the map information of the resulting export to the client_map of the class message |

| | _ _ traverse the bounds array |

| | _ _ add the members of the array to the export array of class messages |

| | _ _ send a class message to the peer mds process, namely: mds- > send_message_mds () |

Migrator::handle_export_dir (MExportDir * m) (opposite end)

| | _ _ get the CDir class object corresponding to dirfrag in the message from MDCache |

| | _ _ find the entry of the dirfrag object in the message from the import_state array |

| | _ _ create C_MDS_ImportDirLoggedStart callback function class |

| | _ _ create EImportStart log entry |

| | _ _ call start_entry () of MDS's mlog to start the log |

| | _ _ parse the client_map information in the message to imported_client_map in EImportStart |

| | _ _ get export_data from message |

| | _ _ call the decode_import_dir () function to write export_data to the current segment corresponding to mdlog |

| | _ _ traverse the bounds array in the message |

| | _ _ add the CDir corresponding to dirfrag_t in the array to LogSegment |

| | _ _ add CDir corresponding to dirfrag_t in the array to the import_bounds array |

| | _ _ call the add_import () function of mds's balancer to balance the search tree |

| | _ _ set the status in import_state_t to IMPORT_LOGGINGSTART |

| | _ _ start mdlog, that is, mds- > mdlog- > submit_entry () / mds- > mdlog- > flush () |

Migrator::import_logged_start () (opposite end)

| | _ _ find the entry corresponding to dirfrag in the import_state array |

| | _ _ set the state of the corresponding item to IMPORT_ACKING |

| | _ _ create MExportDirAck class object |

| | _ _ send MExportDirAck class objects to the mds process |

Migrator::handle_export_ack (MExportDirAck * m)

| | _ _ find the entry corresponding to dirfrag in the export_state array |

| | _ _ parse the imported_caps in the message to the peer_imported in export_state_t |

| | _ _ set the state of the corresponding item to EXPORT_LOGGINGFINISH |

| | _ _ create EExport class object |

| | _ _ write the contents of the bounds array to the metablob of the EExport object |

| | _ _ create C_MDS_ExportFinishLogged callback function class |

| | _ _ start mdlog, that is, mds- > mdlog- > submit_entry () / mds- > mdlog- > flush () |

Migator::export_logged_finish (dir)

| | _ _ find the export_state_t entry of the specified dir in the export_state array |

| | _ _ traverses the notify_ack_waiting array in the export_state_t entry |

| | _ _ create a MExportDirNotify message |

| | _ _ send MExportDirNotify messages to the mds process |

| | _ _ set the status in export_state_t to EXPORT_NOTIFYING |

| | _ _ create a MExportDirFinish message |

| | _ _ send MExportDirFinish messages to the mds process |

Migrator::handle_export_finish (MExportDirFinish * m) (opposite end)

| | _ _ find the corresponding item in the import_state array |

| | _ _ call import_finish () function |

Migrator::import_finish (dir, notify, last) (opposite end)

| | _ _ get the specified dirfrag from import_state array |

| | _ _ if state = = IMPORT_ACKING |

| | _ _ traverses the peer_exports array in import_state_t |

| | _ _ update the content in MDCache |

| | _ if last==false |

| | _ _ set state=IMPORT_FINISHING |

| | _ _ return directly |

| | _ _ process the content in MDCache |

= export client maps and client caps

Migrator::encode_export_inode_caps (in, auth_cap, bl, exported_client_map) to get client map and client caps map

| | _ _ call the function in- > export_client_caps () to get the client capability map information of in |

| | _ _ serialize client capability map information to bl |

| | _ _ traverses in's client_caps array |

| | _ _ get the information about the members of the client_caps array from the sessionmap of mds and write it to exported_client_map |

Migrator::export_caps (CInode * in)

| | _ _ obtain authorized mds_rank_t information from in, that is, in- > authority () .first |

| | _ _ create a MExportCaps message |

| | _ _ set the ino of class messages to in- > ino () |

| | _ _ call encode_export_inode_caps () |

| | _ _ call the send_message_mds () function of mds to send MExportCaps messages to the specified MDS process |

Migrator::handle_export_caps (MExportCaps * ex)

| | _ _ get the CInode information in the class message from MDCache, that is, in=cache- > get_inode (ex- > ino) |

| | _ _ if in is in frozen status |

| | _ _ return directly |

| | _ _ create C_M_LoggedImportCaps callback function class |

| | _ _ write the client_map information in the class message to the client_map of the callback function class |

| | _ _ call the decode_import_inode_caps () function to deserialize the client caps information in the class message and save it to the peer_exports array |

| | _ _ create a LogEvent message of type ESession (client_map) |

| | _ _ write mdlog log, that is: mds- > mdlog- > start_submit_entry () |

| | _ _ call mds- > mdlog- > flush () to refresh mdlog log |

Migrator::handle_gather_caps (MGatherCaps * m)

| | _ _ get the CInode information corresponding to the class message from MDCache, that is, cache- > get_inode (m-> ino) |

| | _ _ if caps exists in in and auth does not exist in in and in does not have EXPORTINGCAPS |

| | _ _ call export_caps (in) to send out the client maps and client caps map export corresponding to in |

The Migrator import and export state machine process is shown in the following figure:

Thank you for reading this article carefully. I hope the article "how to use the Migrator Class" shared by the editor will be helpful to everyone. At the same time, I also hope that you will support and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report