/usr/include/arc/data-staging/TransferShares.h is in nordugrid-arc-dev 4.0.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 | #ifndef TRANSFERSHARES_H_
#define TRANSFERSHARES_H_
#include <map>
#include <arc/credential/VOMSUtil.h>
#include "DTR.h"
namespace DataStaging {
/// TransferSharesConf describes the configuration of TransferShares.
/**
* It allows reference shares to be defined with certain priorities. An
* instance of this class is used when creating a TransferShares object.
* \ingroup datastaging
* \headerfile TransferShares.h arc/data-staging/TransferShares.h
*/
class TransferSharesConf {
public:
/// The criterion for assigning a share to a DTR
enum ShareType {
/// Shares are defined per DN of the user's proxy
USER,
/// Shares are defined per VOMS VO of the user's proxy
VO,
/// Shares are defined per VOMS group of the user's proxy
GROUP,
/// Shares are defined per VOMS role of the user's proxy
ROLE,
/// No share criterion - all DTRs will be assigned to a single share
NONE
};
private:
/// ReferenceShares are special shares defined in the configuration with
/// specific priorities. The "_default" share must always be defined.
std::map<std::string, int> ReferenceShares;
/// Configured share type
ShareType shareType;
/// Find the name of the share this dtr belongs to, when a USER ShareType is used
std::string extract_user_share(const Arc::Credential& cred){
return getCredentialProperty(cred, "dn");
}
/// Find the name of the share this dtr belongs to, when a VO ShareType is used
std::string extract_vo_share(const Arc::Credential& cred){
return getCredentialProperty(cred, "voms:vo");
}
/// Find the name of the share this dtr belongs to, when a GROUP ShareType is used
std::string extract_group_share(const Arc::Credential& cred){
return getCredentialProperty(cred, "voms:group");
}
/// Find the name of the share this dtr belongs to, when a ROLE ShareType is used
std::string extract_role_share(const Arc::Credential& cred){
return getCredentialProperty(cred, "voms:role");
}
public:
/// Construct a new TransferSharesConf with given share type and reference shares
TransferSharesConf(const std::string& type, const std::map<std::string, int>& ref_shares);
/// Construct a new TransferSharesConf with no defined shares or policy
TransferSharesConf();
/// Set the share type
void set_share_type(const std::string& type);
/// Add a reference share
void set_reference_share(const std::string& RefShare, int Priority);
/// Set reference shares
void set_reference_shares(const std::map<std::string, int>& shares);
/// Returns true if the given share is a reference share
bool is_configured(const std::string& ShareToCheck);
/// Get the priority of this share
int get_basic_priority(const std::string& ShareToCheck);
/// Return human-readable configuration of shares
std::string conf() const;
/// Get the name of the share the DTR should be assigned to and the proxy type
std::string extract_share_info(DTR_ptr DTRToExtract);
};
/// TransferShares is used to implement fair-sharing and priorities.
/**
* TransferShares defines the algorithm used to prioritise and share
* transfers among different users or groups. Configuration information on
* the share type and reference shares is held in a TransferSharesConf
* instance. The Scheduler uses TransferShares to determine which DTRs in the
* queue for each process go first. The calculation is based on the
* configuration and the currently active shares (the DTRs already in the
* process). can_start() is the method called by the Scheduler to
* determine whether a particular share has an available slot in the process.
* \ingroup datastaging
* \headerfile TransferShares.h arc/data-staging/TransferShares.h
*/
class TransferShares {
private:
/// Configuration of share type and reference shares
TransferSharesConf conf;
/// Shares which are active, ie running or in the queue, and number of DTRs
std::map<std::string, int> ActiveShares;
/// How many transfer slots each active share can grab
std::map<std::string, int> ActiveSharesSlots;
public:
/// Create a new TransferShares with default configuration
TransferShares() {};
/// Create a new TransferShares with given configuration
TransferShares(const TransferSharesConf& shares_conf);
/// Empty destructor
~TransferShares(){};
/// Set a new configuration, if a new reference share gets added for example
void set_shares_conf(const TransferSharesConf& share_conf);
/// Calculate how many slots to assign to each active share.
/**
* This method is called each time the Scheduler loops to calculate the
* number of slots to assign to each share, based on the current number
* of active shares and the shares' relative priorities.
*/
void calculate_shares(int TotalNumberOfSlots);
/// Increase by one the active count for the given share. Called when a new DTR enters the queue.
void increase_transfer_share(const std::string& ShareToIncrease);
/// Decrease by one the active count for the given share. Called when a completed DTR leaves the queue.
void decrease_transfer_share(const std::string& ShareToDecrease);
/// Decrease by one the number of slots available to the given share.
/**
* Called when there is a slot already used by this share to reduce the
* number available.
*/
void decrease_number_of_slots(const std::string& ShareToDecrease);
/// Returns true if there is a slot available for the given share
bool can_start(const std::string& ShareToStart);
/// Returns the map of active shares
std::map<std::string, int> active_shares() const;
}; // class TransferShares
} // namespace DataStaging
#endif /* TRANSFERSHARES_H_ */
|