Hybrid Query Processing Engine for Coprocessing in Database Systems
HyPE
scheduler.hpp
Go to the documentation of this file.
00001 /***********************************************************************************************************
00002 Copyright (c) 2012, Sebastian Breß, Otto-von-Guericke University of Magdeburg, Germany. All rights reserved.
00003 
00004 This program and accompanying materials are made available under the terms of the 
00005 GNU LESSER GENERAL PUBLIC LICENSE - Version 3, http://www.gnu.org/licenses/lgpl-3.0.txt
00006 ***********************************************************************************************************/
00007 #pragma once
00008 
00009 #include <iostream>
00010 #include <string>
00011 #include <vector>
00012 #include <core/operation.hpp>
00013 #include <core/time_measurement.hpp>
00014 #include <core/measurementpair.hpp>
00015 #include <core/specification.hpp>
00016 #include <query_processing/virtual_processing_device.hpp>
00017 
00018 namespace hype{
00019    namespace core{
00020 
00037       class Scheduler{
00038          public:
00039 
00040             typedef std::map<std::string,std::tr1::shared_ptr<Operation> > MapNameToOperation;
00041 
00045             static Scheduler& instance();
00046 
00047             /* \brief adds an Algorithm to the AlgorithmPool of operation name_of_operation.
00048              * \details If the specified operation does not exist, it is created. Multiple calls to addAlgorithm
00049              *  with the same Operation name will add the respective algorithms to the algorithm pool of the specified Operation    
00050              * \param name_of_operation name of the operation, where the algorithm belongs to 
00051              * \param name_of_algorithm Name of Algorithm to be created
00052              * \param name_of_statistical_method assigns the StatisticalMethod name_of_statistical_method to the new Algorithm
00053              * \param name_of_recomputation_strategy assigns the RecomputationHeuristic name_of_recomputation_strategy to the new Algorithm
00054              * \return returns true on success and false otherwise   
00055              */      
00056 //          bool addAlgorithm(const std::string& name_of_operation,
00057 //                            const std::string& name_of_algorithm, 
00058 //                            ComputeDevice comp_dev,                            
00059 //                            const std::string& name_of_statistical_method, 
00060 //                            const std::string& name_of_recomputation_strategy);
00061 
00069             bool addAlgorithm(const AlgorithmSpecification& alg_spec, const DeviceSpecification& dev_spec);
00070 
00076             bool setOptimizationCriterion(const std::string& name_of_operation,
00077                                           const std::string& name_of_optimization_criterion);
00083             bool setStatisticalMethod(const std::string& name_of_algorithm,
00084                                       const std::string& name_of_statistical_method);
00090             bool setRecomputationHeuristic(const std::string& name_of_algorithm,
00091                                            const std::string& name_of_recomputation_strategy);
00092 
00093             /* \brief Returns a Scheduling Decision, which contains the name of the estimated optimal Algorithm 
00094              *  w.r.t. the user specified optimization criterion
00095              * \param name_of_operation name of the operation, where the optimal algorithm is requested
00096              * \param input_values features of the input dataset, which is needed to compute estimated execution times 
00097              for all algortihms of the specified operation
00098              * \return SchedulingDecision, which contains the suggested algortihm for the specified information   
00099              */
00100             //const SchedulingDecision getOptimalAlgorithmName(const std::string& name_of_operation, const Tuple& input_values, DeviceTypeConstraint dev_constr = ANY_DEVICE);
00101 
00108             const SchedulingDecision getOptimalAlgorithm(const OperatorSpecification& op_spec, const DeviceConstraint& dev_constr);
00109 
00110             /* \brief adds an observed MeasurementPair to the algorithm previously choosen by getOptimalAlgorithmName.
00111              * \param name_of_algorithm name of the algorithm the MeasurementPair belongs to
00112              * \param mp the observed MeasurementPair
00113              * \return Scheduling Decision, which recommends the application the optimal Algorithm w.r.t. the specified 
00114              *  operation and features of the input data set   
00115              */
00116             //bool addObservation(const std::string& name_of_algorithm, const MeasurementPair& mp);
00117             
00123             bool addObservation(const SchedulingDecision& sched_dec, const double& measured_execution_time);
00124 
00129             const AlgorithmPtr getAlgorithm(const std::string& name_of_algorithm);
00130             /* \brief request an Estimated Execution Time from HyPE for an algorithm for a certain operator
00131              * \param op_spec OperatorSpecification, contains all available information about the operator to execute
00132              * \param alg_name algorithm name
00133              * \return estimated execution time
00134              */      
00135             EstimatedTime getEstimatedExecutionTime(const OperatorSpecification& op_spec, const std::string& alg_name);
00136                                 
00137                                 void print();
00138          private:
00141             Scheduler();
00145             Scheduler(const Scheduler&);
00149             Scheduler& operator= (const Scheduler&);
00150 
00151             //void addOperation(std::string operation_name);      
00152 
00154             MapNameToOperation map_operationname_to_operation_;
00156             StatisticalMethodMap map_statisticalmethodname_to_statisticalmethod_;
00157 
00158             public:
00159             class ProcessingDevices{
00160                public:
00161                typedef std::map<ProcessingDeviceID,queryprocessing::VirtualProcessingDevicePtr> Devices;
00162                
00163                ProcessingDevices();
00164                
00165                queryprocessing::VirtualProcessingDevicePtr getProcessingDevice(ProcessingDeviceID);
00166                
00167                bool addDevice(const DeviceSpecification&);
00168                
00169                bool exists(const DeviceSpecification&) const throw();
00170                
00171                const Devices& getDevices() const throw();
00172                
00173                bool addSchedulingDecision(const SchedulingDecision&);               
00174 
00175                bool removeSchedulingDecision(const SchedulingDecision&);   
00176                                  
00177                void print() const throw();                  
00178                private:
00179                   Devices virt_comp_devs_;
00180             };
00181             
00182 
00183             ProcessingDevices& getProcessingDevices(); 
00184             
00185             private:
00187             ProcessingDevices proc_devs_;
00188 
00189       };
00190 
00191    }; //end namespace core
00192 }; //end namespace hype
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines