FlashGraph-ng
A new frontier in large-scale graph analysis and data mining
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
RAID_config.h
1 #ifndef __RAID_CONFIG_H__
2 #define __RAID_CONFIG_H__
3 
4 /*
5  * Copyright 2014 Open Connectome Project (http://openconnecto.me)
6  * Written by Da Zheng (zhengda1936@gmail.com)
7  *
8  * This file is part of SAFSlib.
9  *
10  * Licensed under the Apache License, Version 2.0 (the "License");
11  * you may not use this file except in compliance with the License.
12  * You may obtain a copy of the License at
13  *
14  * http://www.apache.org/licenses/LICENSE-2.0
15  *
16  * Unless required by applicable law or agreed to in writing, software
17  * distributed under the License is distributed on an "AS IS" BASIS,
18  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19  * See the License for the specific language governing permissions and
20  * limitations under the License.
21  */
22 
23 #include <vector>
24 #include <set>
25 #include <memory>
26 
27 #include "safs_file.h"
28 
29 namespace safs
30 {
31 
32 class file_mapper;
33 
34 enum {
35  RAID0,
36  RAID5,
37  HASH,
38 };
39 
40 class RAID_config
41 {
42  /*
43  * These are default values for the RAID config.
44  * A per-file config can overwrite these parameters.
45  */
46  int RAID_mapping_option;
47  int RAID_block_size;
48 
49  std::string conf_file;
50  std::vector<part_file_info> root_paths;
51 public:
52  typedef std::shared_ptr<RAID_config> ptr;
53 
54  static ptr create(const std::string &conf_file, int mapping_option,
55  int block_size);
56 
60  file_mapper *create_file_mapper() const;
64  file_mapper *create_file_mapper(const std::string &file_name) const;
65 
69  std::set<int> get_node_ids() const;
70 
71  const part_file_info &get_disk(int idx) const {
72  return root_paths[idx];
73  }
74 
75  std::vector<part_file_info> get_disks() const {
76  return root_paths;
77  }
78 
79  int get_num_disks() const {
80  return root_paths.size();
81  }
82 };
83 
84 }
85 
86 #endif