📄 request.h
字号:
};/*! * \brief return summary information for a directory---# of files/sizes. */struct MetaGetDirSummary : public MetaRequest { fid_t dir; //!< the directory of interest uint64_t numFiles; //!< # of files in dir uint64_t numBytes; //!< # of bytes in dir MetaGetDirSummary(seq_t s, fid_t f): MetaRequest(META_GETDIRSUMMARY, s, false), dir(f), numFiles(0), numBytes(0) { } int log(ofstream &file) const; void response(ostringstream &os); string Show() { ostringstream os; os << "getdirsummary: dir = " << dir; return os.str(); }};class ChunkServer;typedef boost::shared_ptr<ChunkServer> ChunkServerPtr;/*! * \brief allocate a chunk for a file */struct MetaAllocate: public MetaRequest { MetaRequest *req; //!< req that triggered allocation (e.g., truncate) fid_t fid; //!< file for which space has to be allocated chunkOff_t offset; //!< offset of chunk within file chunkId_t chunkId; //!< Id of the chunk that was allocated seq_t chunkVersion; //!< version # assigned to this chunk std::string clientHost; //!< the host from which request was received int16_t numReplicas; //!< inherited from file's fattr bool layoutDone; //!< Has layout of chunk been done //!< Server(s) on which this chunk has been placed vector <ChunkServerPtr> servers; //!< For replication, the master that runs the transaction //!< for completing the write. ChunkServerPtr master; uint32_t numServerReplies; MetaAllocate(seq_t s, fid_t f, chunkOff_t o): MetaRequest(META_ALLOCATE, s, true), req(NULL), fid(f), offset(o), layoutDone(false), numServerReplies(0) { } int log(ofstream &file) const; void response(ostringstream &os); string Show() { ostringstream os; os << "allocate: fid = " << fid; os << " offset = " << offset; return os.str(); }};/*! * \brief truncate a file */struct MetaTruncate: public MetaRequest { fid_t fid; //!< file for which space has to be allocated chunkOff_t offset; //!< offset to truncate the file to MetaTruncate(seq_t s, fid_t f, chunkOff_t o): MetaRequest(META_TRUNCATE, s, true), fid(f), offset(o) { } int log(ofstream &file) const; void response(ostringstream &os); string Show() { ostringstream os; os << "truncate: fid = " << fid; os << " offset = " << offset; return os.str(); }};/*! * \brief rename a file or directory */struct MetaRename: public MetaRequest { fid_t dir; //!< parent directory string oldname; //!< old file name string newname; //!< new file name bool overwrite; //!< overwrite newname if it exists MetaRename(seq_t s, fid_t d, const char *o, const char *n, bool c): MetaRequest(META_RENAME, s, true), dir(d), oldname(o), newname(n), overwrite(c) { } int log(ofstream &file) const; void response(ostringstream &os); string Show() { ostringstream os; os << "rename: oldname = " << oldname; os << " (fid = " << dir << ")"; os << " newname = " << newname; return os.str(); }};/*! * \brief change a file's replication factor */struct MetaChangeFileReplication: public MetaRequest { fid_t fid; //!< fid whose replication has to be changed int16_t numReplicas; //!< desired degree of replication MetaChangeFileReplication(seq_t s, fid_t f, int16_t n): MetaRequest(META_CHANGE_FILE_REPLICATION, s, true), fid(f), numReplicas(n) { } int log(ofstream &file) const; void response(ostringstream &os); string Show() { ostringstream os; os << "change-file-replication: fid = " << fid; os << "new # of replicas: " << numReplicas; return os.str(); }};/*! * \brief Notification to hibernate/retire a chunkserver: * Hibernation: when the server is put * in hibernation mode, the server is taken down temporarily with a promise that * it will come back N secs later; if the server doesnt' come up as promised * then re-replication starts. * * Retirement: is extended downtime. The server is taken down and we don't know * if it will ever come back. In this case, we use this server (preferably) * to evacuate/re-replicate all the blocks off it before we take it down. */struct MetaRetireChunkserver : public MetaRequest { ServerLocation location; //<! Location of this server int nSecsDown; //<! set to -1, we retire; otherwise, # of secs of down time MetaRetireChunkserver(seq_t s, const ServerLocation &l, int d) : MetaRequest(META_RETIRE_CHUNKSERVER, s, false), location(l), nSecsDown(d) { } int log(ofstream &file) const; void response(ostringstream &os); string Show() { if (nSecsDown > 0) return "Hibernating server: " + location.ToString(); else return "Retiring server: " + location.ToString(); }};/*! * \brief Notification to toggle rebalancing state. */struct MetaToggleRebalancing : public MetaRequest { bool value; // !< Enable/disable rebalancing MetaToggleRebalancing(seq_t s, bool v) : MetaRequest(META_TOGGLE_REBALANCING, s, false), value(v) { } int log(ofstream &file) const; void response(ostringstream &os); string Show() { if (value) return "Toggle rebalancing: Enable"; else return "Toggle rebalancing: Disable"; }};/*! * \brief Execute a rebalance plan that was constructed offline.*/struct MetaExecuteRebalancePlan : public MetaRequest { std::string planPathname; //<! full path to the file with the plan MetaExecuteRebalancePlan(seq_t s, const std::string &p) : MetaRequest(META_EXECUTE_REBALANCEPLAN, s, false), planPathname(p) { } int log(ofstream &file) const; void response(ostringstream &os); string Show() { return "Execute rebalance plan : " + planPathname; }};/*! * \brief close a log file and start a new one */struct MetaLogRollover: public MetaRequest { MetaLogRollover(): MetaRequest(META_LOG_ROLLOVER, 0, true) { } int log(ofstream &file) const; string Show() { return "log rollover"; }};/*! * \brief change the number which is used to increment * chunk version numbers. This is an internally * generated op whenever (1) the system restarts after a failure * or (2) a write-allocation fails because a replica went down.*/struct MetaChangeChunkVersionInc : public MetaRequest { seq_t cvi; //!< The request that depends on the chunk-version-inc # being //!< logged to disk. Once the logging is done, the request //!< processing can resume. MetaRequest *req; MetaChangeChunkVersionInc(seq_t n, MetaRequest *r): MetaRequest(META_CHANGE_CHUNKVERSIONINC, 0, true), cvi(n), req(r) { } int log(ofstream &file) const; string Show() { ostringstream os; os << "changing chunk version inc: value = " << cvi; return os.str(); }};struct ChunkInfo { fid_t fileId; chunkId_t chunkId; seq_t chunkVersion;};/*! * \brief hello RPC from a chunk server on startup */struct MetaHello: public MetaRequest { ChunkServerPtr server; //!< The chunkserver that sent the hello message ServerLocation location; //<! Location of this server uint64_t totalSpace; //!< How much storage space does the //!< server have (bytes) uint64_t usedSpace; //!< How much storage space is used up (in bytes) int rackId; //!< the rack on which the server is located int numChunks; //!< # of chunks hosted on this server int contentLength; //!< Length of the message body vector<ChunkInfo> chunks; //!< Chunks hosted on this server MetaHello(seq_t s): MetaRequest(META_HELLO, s, false) { } int log(ofstream &file) const; void response(ostringstream &os); string Show() { return "Chunkserver Hello"; }};/*! * \brief whenever a chunk server goes down, this message is used to clean up state. */struct MetaBye: public MetaRequest { ChunkServerPtr server; //!< The chunkserver that went down MetaBye(seq_t s, ChunkServerPtr c): MetaRequest(META_BYE, s, false), server(c) { } int log(ofstream &file) const; string Show() { return "Chunkserver Bye"; }};/*! * \brief RPCs that go from meta server->chunk server are * MetaRequest's that define a method to generate the RPC * request. */struct MetaChunkRequest: public MetaRequest { MetaRequest *req; //!< The request that triggered this RPC ChunkServer *server; //!< The chunkserver to send this RPC to MetaChunkRequest(MetaOp o, seq_t s, bool mu, MetaRequest *r, ChunkServer *c): MetaRequest(o, s, mu), req(r), server(c) { } //!< generate a request message (in string format) as per the //!< KFS protocol. virtual void request(ostringstream &os) = 0;};/*! * \brief Allocate RPC from meta server to chunk server */struct MetaChunkAllocate: public MetaChunkRequest { int64_t leaseId; MetaChunkAllocate(seq_t n, MetaAllocate *r, ChunkServer *s, int64_t l): MetaChunkRequest(META_CHUNK_ALLOCATE, n, false, r, s), leaseId(l) { } //!< generate the request string that should be sent out void request(ostringstream &os); int log(ofstream &file) const; string Show() { return "meta->chunk allocate: "; }};/*! * \brief Chunk version # change RPC from meta server to chunk server */struct MetaChunkVersChange: public MetaChunkRequest { fid_t fid; chunkId_t chunkId; //!< The chunk id to free seq_t chunkVersion; //!< version # assigned to this chunk MetaChunkVersChange(seq_t n, ChunkServer *s, fid_t f, chunkId_t c, seq_t v): MetaChunkRequest(META_CHUNK_VERSCHANGE, n, false, NULL, s), fid(f), chunkId(c), chunkVersion(v) { } //!< generate the request string that should be sent out void request(ostringstream &os); int log(ofstream &file) const; string Show() { ostringstream os; os << "meta->chunk vers change: "; os << " fid = " << fid; os << " chunkId = " << chunkId; os << " chunkVersion = " << chunkVersion; return os.str(); }};/*! * \brief Delete RPC from meta server to chunk server */struct MetaChunkDelete: public MetaChunkRequest { chunkId_t chunkId; //!< The chunk id to free MetaChunkDelete(seq_t n, ChunkServer *s, chunkId_t c): MetaChunkRequest(META_CHUNK_DELETE, n, false, NULL, s), chunkId(c) { } //!< generate the request string that should be sent out void request(ostringstream &os); int log(ofstream &file) const; string Show() { ostringstream os; os << "meta->chunk delete: "; os << " chunkId = " << chunkId; return os.str(); }};/*! * \brief Truncate chunk RPC from meta server to chunk server */struct MetaChunkTruncate: public MetaChunkRequest { chunkId_t chunkId; //!< The id of chunk to be truncated size_t chunkSize; //!< The size to which chunk should be truncated MetaChunkTruncate(seq_t n, ChunkServer *s, chunkId_t c, size_t sz): MetaChunkRequest(META_CHUNK_TRUNCATE, n, false, NULL, s), chunkId(c), chunkSize(sz) { } //!< generate the request string that should be sent out void request(ostringstream &os); int log(ofstream &file) const; string Show() { ostringstream os; os << "meta->chunk truncate: "; os << " chunkId = " << chunkId; os << " chunkSize = " << chunkSize; return os.str(); }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -