myxce/src/autoscaler/scaler/include/scaler.h

58 lines
1.3 KiB
C

#ifndef _SCALER_H_
#define _SCALER_H_
#include <pthread.h>
#include <stdlib.h>
#include <time.h>
#include "config.h"
#include "htab.h"
#include "mylock.h"
#include "scaler/types.h"
#include "xce/types.h"
#include "xlist.h"
#include "zarray.h"
#include <basiclib/list.h>
// in seconds
#define DEFAULT_CHECK_INTERVAL 30
typedef struct {
char providers_file[XCE_MAXPATH_LEN];
int check_interval;
} scaler_conf_t;
typedef struct {
zarray_t array;
htab_t tab;
mylock_t lock;
} scaler_obj_mgr_t;
typedef struct demand_list {
xcelist_t* list;
mylock_t lock;
pthread_cond_t cond;
} scaler_demand_queue_t;
typedef struct {
scaler_conf_t configs;
scaler_obj_mgr_t providers;
scaler_obj_mgr_t templates;
scaler_obj_mgr_t requests;
scaler_obj_mgr_t instances;
scaler_demand_queue_t demands;
mylock_t lock;
pthread_t threads[2];
int running;
#define SCALER_MENU_CHANGED 0x1
int flag;
} autoscaler_context_t;
extern autoscaler_context_t g_scaler_ctx;
extern int scaler_init(char* providers_file);
extern int scaler_start();
extern void* scaler_monitor(void* arg);
extern void* scaler_demand_handler(void* arg);
extern int publish_scaler_demand(scaler_demand_array_t* demands);
#endif