00001
#ifndef BOREALIS_QOSOPT_H
00002
#define BOREALIS_QOSOPT_H
00003
00004
#include "BasicComponent.h"
00005
00006
BOREALIS_NAMESPACE_BEGIN
00007
00008
00009
00013 class QOSOptimizer :
public BasicComponent {
00014
00015
public:
00016
QOSOptimizer(string
id);
00017 ~QOSOptimizer() {}
00018
00019
00020
00021
NMSTL_RPC_OBJECT(
QOSOptimizer);
00022
00023 RPC<void>
do_something(
double life,
double tp);
00024 RPC<int>
call_me();
00025 RPC<vector<Stats> >
get_stat();
00026
00027
00028
protected:
00029
void in_thread_init();
00030
void handle_load_offer(AsyncRPC< ptr<LoadOffer> > completion, ptr<LoadOffer> offer);
00031
00032
private:
00033
00034
00035 AsyncRPC<void> m_completion;
00036
00037
00038
class OverloadedException {
00039
public:
00040 string m_message;
00041 OverloadedException(string message): m_message(message) { }
00042 };
00043
00044
00045
static const double EPSILON_COST = 0.1;
00046
00047
00048
typedef vector< Stats > StatsList;
00049 vector<Stats> m_operatorStats;
00050
double m_total_cpu;
00051
double m_total_bw;
00052
double m_bw_utilization;
00053
double m_cpu_utilization;
00054
double m_load_level;
00055
double m_marginal_cost;
00056
00057
double m_lifetime;
00058
double m_sel;
00059
int counter;
00060
bool whereJoin;
00061
bool switchLoc;
00062
00063
00064
00065
00067
00068
00070
void update_stats();
00071
void update_stats_2(RPC<StatsList> result);
00072
void yomama(RPC<double> result);
00073
void updateSel(
double sel);
00074
00076
double compute_avg_marginal_cost(
double cpuUsage,
double deltaCPU,
double bwUsage,
double deltaBW);
00077
00078
00079
bool m_offerPending;
00080
00085
void reset_partners();
00086
void send_out_load_offers();
00087
void pick_boxes(StatsList& src, StatsList& dst,
double threshold);
00088
void handle_load_offer_response(string partner, ptr<LoadOffer> original_offer,
00089 RPC< ptr<LoadOffer> > counter_offer);
00090
void done_moving_load(RPC<void> stat);
00091 vector<Name> extract_names(vector<Stats> boxes);
00092
00093
00094
bool m_movementInProgress;
00095
typedef list< ptr<LoadOffer> > LoadOffers;
00096
typedef map < ptr<LoadOffer>, AsyncRPC< ptr<LoadOffer> > > LoadOfferCompletions;
00097 LoadOffers m_load_offers;
00098 LoadOfferCompletions m_load_offer_completions;
00099
void examine_load_offers();
00100
void pick_new_boxes(StatsList& src, StatsList& dst,
double threshold,
00101
double& acceptedDeltaCPU,
double& acceptedDeltaBW);
00102
00103
00104 };
00105
00106
BOREALIS_NAMESPACE_END
00107
00108
#endif