1 #ifndef __ARC_ENTITYRETRIEVER_H__ 2 #define __ARC_ENTITYRETRIEVER_H__ 8 #include <arc/ArcConfig.h> 9 #include <arc/compute/Endpoint.h> 10 #include <arc/UserConfig.h> 11 #include <arc/Utils.h> 12 #include <arc/compute/EndpointQueryingStatus.h> 13 #include <arc/compute/ExecutionTarget.h> 14 #include <arc/compute/EntityRetrieverPlugin.h> 20 class SimpleCondition;
22 template<>
class ThreadedPointer<class Endpoint>;
67 virtual void addEntity(
const T& t) { this->push_back(t); }
179 void wait()
const { result.wait(); };
186 bool isDone()
const {
return result.wait(0); };
251 bool removeEndpoint(
const Endpoint& e) { statusLock.
lock(); EndpointStatusMap::iterator it = statuses.find(e);
if (it != statuses.end()) { statuses.erase(it); statusLock.
unlock();
return true; }; statusLock.
unlock();
return false; }
287 static void queryEndpoint(
void *arg_);
289 void checkSuspendedAndStart(
const Endpoint& e);
295 mutex(), t(t), uc(u) {};
296 void deactivate(
void) {
301 bool lockExclusiveIfValid(
void) {
308 bool lockSharedIfValid(
void) {
316 operator const UserConfig&(void)
const {
return uc; }
317 const std::list<std::string>& getAvailablePlugins(
void)
const {
return availablePlugins; }
318 void setAvailablePlugins(
const std::list<std::string>& newAvailablePlugins) { availablePlugins = newAvailablePlugins; }
325 std::list<std::string> availablePlugins;
337 Result(
bool one_success =
false):
339 success(
false),need_one_success(one_success) { };
343 success(
false),need_one_success(r.need_one_success) {
348 if(need_one_success && success) {
355 void setSuccess(
void) { success =
true; };
357 bool wait(
int t = -1)
const {
return Ptr()->
wait(t); };
360 bool need_one_success;
367 ThreadArg(
const ThreadArg& v,
Result& result) : common(v.common), result(result), endpoint(v.endpoint), pluginName(v.pluginName), options(v.options) {};
373 std::string pluginName;
381 std::list< EntityConsumer<T>* > consumers;
386 std::map<std::string, std::string> interfacePluginMap;
387 bool need_all_results;
419 #endif // __ARC_ENTITYRETRIEVER_H__ Arc namespace contains all core ARC classes.
Definition: ArcConfig.h:11
void lock(void)
Acquire semaphor.
Definition: Thread.h:164
void getServicesWithStatus(const EndpointQueryingStatus &status, std::set< std::string > &result)
Insert into results the endpoint.ServiceName() of each endpoint with the given status.
Simple triggered condition.
Definition: Thread.h:150
void addConsumer(EntityConsumer< T > &addConsumer_consumer)
Definition: EntityRetriever.h:192
virtual void addEndpoint(const Endpoint &endpoint)
Starts querying an Endpoint.
void unlockShared(void)
Release a shared lock.
User configuration class
Definition: UserConfig.h:196
Definition: EntityRetriever.h:292
Represents the status in the EntityRetriever of the query process of an Endpoint (service registry...
Definition: EndpointQueryingStatus.h:19
virtual void addEntity(const T &t)
All the consumed entities are pushed to the list.
Definition: EntityRetriever.h:67
bool setStatusOfEndpoint(const Endpoint &endpoint, const EndpointQueryingStatus &status, bool overwrite=true)
Set the status of the query process of a given Endpoint.
Definition: EntityRetriever.h:334
Thread-safe counter with capability to wait for zero value.
Definition: Thread.h:244
bool isDone() const
Definition: EntityRetriever.h:186
virtual void wait(void) const
Wait for zero condition.
void unlockExclusive(void)
Release exclusive lock.
void unlock(void)
Release semaphor.
Definition: Thread.h:168
Definition: EntityRetrieverPlugin.h:96
A logger class.
Definition: Logger.h:493
void removeConsumer(const EntityConsumer< T > &removeConsumer_consumer)
EntityRetriever(const UserConfig &uc, const EndpointQueryOptions< T > &options=EndpointQueryOptions< T >())
Needs the credentials of the user and can have some options.
Mutex which allows shared and exclusive locking.
Definition: Thread.h:333
Represents an endpoint of a service with a given interface type and capabilities. ...
Definition: Endpoint.h:68
Queries Endpoint objects (using plugins in parallel) and sends the found entities to consumers...
Definition: EntityRetriever.h:167
EndpointStatusMap getAllStatuses() const
Get status of all the queried Endpoint objects.
Definition: EntityRetriever.h:213
Options controlling the query process.
Definition: EntityRetrieverPlugin.h:24
void wait() const
Definition: EntityRetriever.h:179
EntityRetriever< ComputingServiceType > TargetInformationRetriever
The TargetInformationRetriever is an EntityRetriever retrieving ComputingServiceType objects...
Definition: EntityRetriever.h:406
EntityRetriever< Endpoint > ServiceEndpointRetriever
The ServiceEndpointRetriever is an EntityRetriever retrieving Endpoint objects.
Definition: EntityRetriever.h:397
SimpleCounter * Ptr(void) const
Cast to original pointer.
Definition: Thread.h:494
virtual void addEntity(const T &entity)
An entity consumer class storing all the consumed entities in a list.
Definition: EntityRetriever.h:59
virtual int inc(void)
Increment value of counter.
virtual int dec(void)
Decrement value of counter.
EndpointQueryingStatus getStatusOfEndpoint(const Endpoint &endpoint) const
Get the status of the query process of a given Endpoint.
virtual void addEntity(const T &)=0
Send an entity to this consumer.
void needAllResults(bool all_results=true)
Sets if all wait for all queries.
Definition: EntityRetriever.h:284
virtual int set(int v)
Set value of counter.
void lockExclusive(void)
Acquire an exclusive lock. Blocks until all shared and exclusive locks are released.
Status map for Endpoint objects.
Definition: Endpoint.h:38
EntityRetriever< Job > JobListRetriever
The JobListRetriever is an EntityRetriever retrieving Job objects.
Definition: EntityRetriever.h:415
Definition: EntityRetriever.h:364
void clearEndpointStatuses()
Clear statuses of registered endpoints.
Definition: EntityRetriever.h:241
A general concept of an object which can consume entities use by the retrievers to return results...
Definition: EntityRetriever.h:34
Wrapper for pointer with automatic destruction and multiple references.
Definition: Thread.h:436
void lockShared(void)
Acquire a shared lock. Blocks until exclusive lock is released.
bool removeEndpoint(const Endpoint &e)
Remove a particular registered endpoint.
Definition: EntityRetriever.h:251