ARC SDK
TransferShares.h
1 #ifndef TRANSFERSHARES_H_
2 #define TRANSFERSHARES_H_
3 
4 #include <map>
5 
6 #include <arc/credential/VOMSUtil.h>
7 
8 #include "DTR.h"
9 
10 namespace DataStaging {
11 
13 
20 
21  public:
22 
24  enum ShareType {
28  VO,
35  };
36 
37  private:
38 
41  std::map<std::string, int> ReferenceShares;
42 
44  ShareType shareType;
45 
47  std::string extract_user_share(const Arc::Credential& cred){
48  return getCredentialProperty(cred, "dn");
49  }
50 
52  std::string extract_vo_share(const Arc::Credential& cred){
53  return getCredentialProperty(cred, "voms:vo");
54  }
55 
57  std::string extract_group_share(const Arc::Credential& cred){
58  return getCredentialProperty(cred, "voms:group");
59  }
60 
62  std::string extract_role_share(const Arc::Credential& cred){
63  return getCredentialProperty(cred, "voms:role");
64  }
65 
66  public:
67 
69  TransferSharesConf(const std::string& type, const std::map<std::string, int>& ref_shares);
70 
73 
75  void set_share_type(const std::string& type);
76 
78  void set_reference_share(const std::string& RefShare, int Priority);
79 
81  void set_reference_shares(const std::map<std::string, int>& shares);
82 
84  bool is_configured(const std::string& ShareToCheck);
85 
87  int get_basic_priority(const std::string& ShareToCheck);
88 
90  std::string conf() const;
91 
93  std::string extract_share_info(DTR_ptr DTRToExtract);
94  };
95 
96 
98 
111 
112  private:
113 
115  TransferSharesConf conf;
116 
118  std::map<std::string, int> ActiveShares;
119 
121  std::map<std::string, int> ActiveSharesSlots;
122 
123  public:
124 
127 
129  TransferShares(const TransferSharesConf& shares_conf);
130 
133 
135  void set_shares_conf(const TransferSharesConf& share_conf);
136 
138 
143  void calculate_shares(int TotalNumberOfSlots);
144 
146  void increase_transfer_share(const std::string& ShareToIncrease);
148  void decrease_transfer_share(const std::string& ShareToDecrease);
149 
151 
155  void decrease_number_of_slots(const std::string& ShareToDecrease);
156 
158  bool can_start(const std::string& ShareToStart);
159 
161  std::map<std::string, int> active_shares() const;
162 
163  }; // class TransferShares
164 
165 } // namespace DataStaging
166 
167 #endif /* TRANSFERSHARES_H_ */