30 #define MAX_CLONE_CONDITIONS 2
50 #define CLONING_SAMPLES 10
60 #define UNCLONING_SAMPLES 50
70 #define CLONING_DECISION_LEN sizeof(CLONING_DECISIONS) / sizeof(*CLONING_DECISIONS)
71 #define UNCLONING_DECISION_LEN sizeof(UNCLONING_DECISIONS) / sizeof(*UNCLONING_DECISIONS)
110 for (
int i=0; i<info->
num_msus; i++) {
111 sum += info->
stats[i];
117 log(LOG_SCHEDULING_DECISIONS,
"Trying to clone type %d due to mean: %.2f",
127 if (clone_type == NULL) {
141 for (
int i=0; i<info->
num_msus; i++) {
145 max = max > info->
stats[i] ? max : info->
stats[i];
148 log(LOG_SCHEDULING_DECISIONS,
"Trying to unclone type %d due to max : %.2f",
153 #define MIN_CLONE_DURATION_MS 750
154 #define MIN_UNCLONE_DURATION_MS 750
157 struct timespec cur_time;
158 clock_gettime(CLOCK_MONOTONIC, &cur_time);
164 log_error(
"Error getting cloning decision %d", i);
174 log_error(
"Cloning MSU failed for MSU type %d",
186 struct timespec cur_time;
187 clock_gettime(CLOCK_MONOTONIC, &cur_time);
193 log_error(
"Error getting cloning info %d", i);
202 log(LOG_SCHEDULING,
"Uncloning MSU failed for MSU type %d",
219 if (clone_type != NULL) {
#define MIN_CLONE_DURATION_MS
#define CLONING_DECISION_LEN
double average_n(struct timed_rrdb *timeseries, int n_samples)
timeseries.c
Round-robin database (circular buffer) for storing timeseries data.
static struct clone_decision UNCLONING_DECISIONS[]
static bool should_unclone(struct clone_decision *decision)
static struct clone_decision CLONING_DECISIONS[]
struct dfg_msu * instances[512]
Each instance of this MSU type.
struct dfg_msu * clone_msu(int msu_id)
Clone a msu of given ID.
#define MAX_CLONE_CONDITIONS
stat_id
The identifiers with which stats can be logged.
static struct timespec cur_time
Static structure for holding current time, so it can be returned from next_timeout.
Logging of status messages to the terminal.
struct timed_rrdb * get_msu_stat(enum stat_id id, unsigned int msu_id)
#define UNCLONING_SAMPLES
Functions for the sending and receiving of statistics between ctrl and runtime.
#define MIN_UNCLONE_DURATION_MS
static int gather_cloning_info(struct cloning_info *info)
static bool min_instances_recorded
#define log_error(fmt,...)
static bool should_clone(struct clone_decision *decision)
int id
A unique identifier for the MSU.
Representation of a single MSU in the dfg.
#define UNCLONING_DECISION_LEN
#define MAX_MSU
The maximum number of MSUs which can be present in the system at a time.
struct local_msu * instance
#define WEBSERVER_READ_MSU_TYPE_ID
void set_haproxy_weights(int rt_id, int offset)
struct cloning_info conditions[2]
#define WEBSERVER_HTTP_MSU_TYPE_ID
int n_instances
The number of instances of this MSU type.
#define log(level, fmt,...)
Log at a custom level.
struct dfg_msu_type * get_dfg_msu_type(unsigned int id)
Returns the MSU type with the given ID.
static int gather_cloning_decision(struct clone_decision *decision)
int unclone_msu(int msu_id)
#define WEBSERVER_REGEX_MSU_TYPE_ID