Logo
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
file_leader.hh
Go to the documentation of this file.
1 #pragma once
2 
3 #include "../nodes/node.hh"
4 #include "directory.hh"
5 #include "../blocknode/local_io.hh"
6 #include "../messages/fileinfo.hh"
7 #include "../messages/fileupdate.hh"
8 #include "../messages/filerequest.hh"
9 #include "../messages/filelist.hh"
10 #include "../messages/filedel.hh"
11 #include "../messages/fileexist.hh"
12 #include "../messages/filedescription.hh"
13 #include "../messages/metadata.hh"
14 #include "../common/histogram.hh"
15 
16 #include <string>
17 
18 namespace eclipse {
19 
20 using vec_str = std::vector<std::string>;
21 
22 class FileLeader: public Node {
23  public:
25  ~FileLeader();
26 
28  unique_ptr<messages::Message> file_insert(messages::FileInfo*);
29 
32 
34  std::shared_ptr<messages::Message> file_request(messages::FileRequest*);
35 
37 
39  bool list(messages::FileList*);
40 
41  bool file_exist(std::string);
42 
45 
47 
49  bool format();
50 
51  protected:
52  void replicate_metadata();
55  std::unique_ptr<Histogram> boundaries;
56  std::map<std::string, std::shared_ptr<messages::FileDescription>> current_file_arrangements;
58 
60 };
61 
62 }
bool file_insert_confirm(messages::FileInfo *)
Confirm that all the blocks has been uploaded.
Definition: file_leader.cc:56
Definition: fileinfo.hh:10
Definition: metadata.hh:6
Definition: directory.hh:12
Definition: node.hh:14
std::map< std::string, std::shared_ptr< messages::FileDescription > > current_file_arrangements
Definition: file_leader.hh:56
std::vector< std::string > vec_str
Definition: cli_driver.cc:9
bool file_update(messages::FileUpdate *)
Update the file with the new size and blocks.
Definition: file_leader.cc:63
Represents the local disk.
Definition: local_io.hh:11
Definition: file_leader.hh:22
void replicate_metadata()
This function replicates to its right and left neighbor node the metadata db.
Definition: file_leader.cc:190
Definition: filedescription.hh:10
Definition: fileupdate.hh:10
Definition: filedel.hh:8
Definition: filerequest.hh:9
Definition: filelist.hh:12
unique_ptr< messages::Message > file_insert(messages::FileInfo *)
Insert file metadata and compute block metadata.
Definition: file_leader.cc:38
bool list(messages::FileList *)
Fill the param with the list of files.
Definition: file_leader.cc:176
Local_io local_io
Definition: file_leader.hh:54
Definition: client_handler.hh:12
int network_size
Definition: file_leader.hh:57
void metadata_save(messages::MetaData *)
Definition: file_leader.cc:203
bool format()
Remove everything and create tables.
Definition: file_leader.cc:209
std::unique_ptr< Histogram > boundaries
Definition: file_leader.hh:55
Directory directory
Definition: file_leader.hh:53
std::shared_ptr< messages::Message > file_request(messages::FileRequest *)
Return a description of the blocks containing the file.
Definition: file_leader.cc:119
~FileLeader()
Definition: file_leader.cc:31
bool file_exist(std::string)
Definition: file_leader.cc:182
FileLeader(network::ClientHandler *)
Definition: file_leader.cc:21
bool file_delete(messages::FileDel *)
Definition: file_leader.cc:101
void find_best_arrangement(messages::FileDescription *file_desc)
Definition: file_leader.cc:217