15 #ifndef STATESTORE_QUERY_RESOURCE_MGR_H
16 #define STATESTORE_QUERY_RESOURCE_MGR_H
20 #include "gen-cpp/Types_types.h"
21 #include "gen-cpp/ResourceBrokerService.h"
22 #include "gen-cpp/ImpalaInternalService.h"
23 #include "gen-cpp/Frontend_types.h"
27 #include <boost/function.hpp>
28 #include <boost/thread/mutex.hpp>
29 #include <boost/unordered_map.hpp>
30 #include <boost/unordered_set.hpp>
31 #include <boost/shared_ptr.hpp>
64 const boost::unordered_set<TNetworkAddress>& unique_hosts);
97 const TNetworkAddress& local_resource_location,
const TUniqueId&
query_id);
131 TResourceBrokerExpansionRequest* request);
161 typedef boost::unordered_map<int32_t, VcoreAvailableCb>
CallbackMap;
void GetResourceHostport(const TNetworkAddress &src, TNetworkAddress *dst)
TNetworkAddress local_resource_location_
int64_t vcores_
The number of VCores acquired for this node for this query.
boost::shared_ptr< AtomicInt< int16_t > > thread_in_expand_
int32_t AddVcoreAvailableCb(const VcoreAvailableCb &callback)
ResourceResolver(const boost::unordered_set< TNetworkAddress > &unique_hosts)
bool AboveVcoreSubscriptionThreshold()
boost::mutex exit_lock_
Used to control shutdown of AcquireCpuResources().
const TUniqueId & query_id() const
boost::condition_variable threads_changed_cv_
Waited on by AcquireCpuResources(), and notified by NotifyThreadUsageChange().
void CreateLocalLlamaNodeMapping(const boost::unordered_set< TNetworkAddress > &unique_hosts)
int64_t threads_running_
The number of threads we know to be running on behalf of this query.
QueryResourceMgr(const TUniqueId &reservation_id, const TNetworkAddress &local_resource_location, const TUniqueId &query_id)
boost::unordered_map< TNetworkAddress, TNetworkAddress > dn_to_impalad_
TUniqueId reservation_id_
ID of the single reservation corresponding to this query.
CallbackMap::iterator callbacks_it_
Round-robin iterator to notify callbacks about new VCores one at a time.
boost::function< void()> VcoreAvailableCb
boost::mutex threads_running_lock_
Protects threads_running_, threads_changed_cv_ and vcores_.
boost::unordered_map< int32_t, VcoreAvailableCb > CallbackMap
List of callbacks to notify when a new VCore resource is available.
~QueryResourceMgr()
Waits for the VCore acquisition thread to stop.
TUniqueId query_id_
Query ID of the query this class manages resources for.
void RemoveVcoreAvailableCb(int32_t callback_id)
Removes the callback with the given ID.
boost::scoped_ptr< Thread > acquire_vcore_thread_
Runs AcquireVcoreResources() after InitVcoreAcquisition() is called.
void AcquireVcoreResources(boost::shared_ptr< AtomicInt< int16_t > > thread_in_expand, boost::shared_ptr< AtomicInt< int16_t > > early_exit)
void NotifyThreadUsageChange(int delta)
bool IsVcoreOverSubscribed()
void InitVcoreAcquisition(int32_t init_vcores)
boost::shared_ptr< AtomicInt< int16_t > > early_exit_
boost::mutex callbacks_lock_
Protects callbacks_ and callbacks_it_.
Only CPU-heavy threads need be managed using this class.
boost::unordered_map< TNetworkAddress, TNetworkAddress > impalad_to_dn_
Status CreateExpansionRequest(int64_t memory_mb, int64_t vcores, TResourceBrokerExpansionRequest *request)
float max_vcore_oversubscription_ratio_
bool ShouldExit()
Notifies acquire_cpu_thread_ that it should terminate. Does not block.