00001 #ifndef TRANSFERSHARES_H_
00002 #define TRANSFERSHARES_H_
00003
00004 #include <map>
00005
00006 #include <arc/Thread.h>
00007 #include <arc/credential/VOMSUtil.h>
00008
00009 #include "DTR.h"
00010
00011 namespace DataStaging {
00012
00014
00018 class TransferSharesConf {
00019
00020 public:
00021
00023 enum ShareType {
00025 USER,
00027 VO,
00029 GROUP,
00031 ROLE,
00033 NONE
00034 };
00035
00036 private:
00037
00040 std::map<std::string, int> ReferenceShares;
00041
00043 ShareType shareType;
00044
00046 std::string extract_user_share(const Arc::Credential& cred){
00047 return getCredentialProperty(cred, "dn");
00048 }
00049
00051 std::string extract_vo_share(const Arc::Credential& cred){
00052 return getCredentialProperty(cred, "voms:vo");
00053 }
00054
00056 std::string extract_group_share(const Arc::Credential& cred){
00057 return getCredentialProperty(cred, "voms:group");
00058 }
00059
00061 std::string extract_role_share(const Arc::Credential& cred){
00062 return getCredentialProperty(cred, "voms:role");
00063 }
00064
00065 public:
00066
00068 TransferSharesConf(const std::string& type, const std::map<std::string, int>& ref_shares);
00069
00071 TransferSharesConf();
00072
00074 void set_share_type(const std::string& type);
00075
00077 void set_reference_share(const std::string& RefShare, int Priority);
00078
00080 void set_reference_shares(const std::map<std::string, int>& shares);
00081
00083 bool is_configured(const std::string& ShareToCheck);
00084
00086 int get_basic_priority(const std::string& ShareToCheck);
00087
00089 std::string conf() const;
00090
00092 std::string extract_share_info(DTR_ptr DTRToExtract);
00093 };
00094
00095
00097
00107 class TransferShares {
00108
00109 private:
00110
00112 TransferSharesConf conf;
00113
00115 std::map<std::string, int> ActiveShares;
00116
00118 std::map<std::string, int> ActiveSharesSlots;
00119
00120 public:
00121
00123 TransferShares() {};
00124
00126 TransferShares(const TransferSharesConf& shares_conf);
00127
00129 ~TransferShares(){};
00130
00132 TransferShares(const TransferShares& shares);
00134 TransferShares& operator=(const TransferShares& shares);
00135
00137 void set_shares_conf(const TransferSharesConf& share_conf);
00138
00140
00143 void calculate_shares(int TotalNumberOfSlots);
00144
00146
00147 void increase_transfer_share(const std::string& ShareToIncrease);
00149
00150 void decrease_transfer_share(const std::string& ShareToDecrease);
00151
00153
00155 void decrease_number_of_slots(const std::string& ShareToDecrease);
00156
00158 bool can_start(const std::string& ShareToStart);
00159
00161 std::map<std::string, int> active_shares() const;
00162
00163 };
00164
00165 }
00166
00167 #endif