- if (dp->estimate == ES_SERVER) {
- info_t info;
- nb_server++;
- get_info(dp->host->hostname, dp->name, &info);
- for(i = 0; i < MAX_LEVELS; i++) {
- int j;
- int lev = est(dp)->level[i];
-
- if(lev == -1) break;
- if(lev == 0) { /* use latest level 0, should do extrapolation */
- gint64 est_size = (gint64)0;
- int nb_est = 0;
-
- for(j=NB_HISTORY-2;j>=0;j--) {
- if(info.history[j].level == 0) {
- if(info.history[j].size < (gint64)0) continue;
- est_size = info.history[j].size;
- nb_est++;
- }
- }
- if(nb_est > 0) {
- est(dp)->est_size[i] = est_size;
- }
- else if(info.inf[lev].size > (gint64)1000) { /* stats */
- est(dp)->est_size[i] = info.inf[lev].size;
- }
- else {
- est(dp)->est_size[i] = (gint64)1000000;
- }
- }
- else if(lev == est(dp)->last_level) {
- /* means of all X day at the same level */
- #define NB_DAY 30
- int nb_day = 0;
- gint64 est_size_day[NB_DAY];
- int nb_est_day[NB_DAY];
- for(j=0;j<NB_DAY;j++) {
- est_size_day[j]=(gint64)0;
- nb_est_day[j]=0;
- }
-
- for(j=NB_HISTORY-2;j>=0;j--) {
- if(info.history[j].level <= 0) continue;
- if(info.history[j].size < (gint64)0) continue;
- if(info.history[j].level==info.history[j+1].level) {
- if(nb_day <NB_DAY-1) nb_day++;
- est_size_day[nb_day] += info.history[j].size;
- nb_est_day[nb_day]++;
- }
- else {
- nb_day=0;
- }
- }
- nb_day = info.consecutive_runs + 1;
- if(nb_day > NB_DAY-1) nb_day = NB_DAY-1;
-
- while(nb_day > 0 && nb_est_day[nb_day] == 0) nb_day--;
-
- if(nb_est_day[nb_day] > 0) {
- est(dp)->est_size[i] = est_size_day[nb_day] /
- (gint64)nb_est_day[nb_day];
- }
- else if(info.inf[lev].size > (gint64)1000) { /* stats */
- est(dp)->est_size[i] = info.inf[lev].size;
- }
- else {
- est(dp)->est_size[i] = (gint64)10000;
- }
- }
- else if(lev == est(dp)->last_level + 1) {
- /* means of all first day at a new level */
- gint64 est_size = (gint64)0;
- int nb_est = 0;
-
- for(j=NB_HISTORY-2;j>=0;j--) {
- if(info.history[j].level <= 0) continue;
- if(info.history[j].size < (gint64)0) continue;
- if(info.history[j].level == info.history[j+1].level + 1 ) {
- est_size += info.history[j].size;
- nb_est++;
- }
- }
- if(nb_est > 0) {
- est(dp)->est_size[i] = est_size / (gint64)nb_est;
- }
- else if(info.inf[lev].size > (gint64)1000) { /* stats */
- est(dp)->est_size[i] = info.inf[lev].size;
- }
- else {
- est(dp)->est_size[i] = (gint64)100000;
- }
- }
- }
- g_fprintf(stderr,_("%s time %s: got result for host %s disk %s:"),
- get_pname(), walltime_str(curclock()),
- dp->host->hostname, qname);
- g_fprintf(stderr,_(" %d -> %lldK, %d -> %lldK, %d -> %lldK\n"),
- est(dp)->level[0], (long long)est(dp)->est_size[0],
- est(dp)->level[1], (long long)est(dp)->est_size[1],
- est(dp)->level[2], (long long)est(dp)->est_size[2]);
- if (!am_has_feature(hostp->features, fe_xml_estimate)) {
- est(dp)->state = DISK_DONE;
- remove_disk(&startq, dp);
- enqueue_disk(&estq, dp);
- }
- }