/adei/ui

To get this branch, use:
bzr branch http://darksoft.org/webbzr/adei/ui

« back to all changes in this revision

Viewing changes to classes/cache.php

  • Committer: Suren A. Chilingaryan
  • Date: 2008-06-17 23:19:26 UTC
  • Revision ID: csa@dside.dyndns.org-20080617231926-w9mpfxw6lv0r0450
Administrative interface and better handling of missing group channels

Show diffs side-by-side

added added

removed removed

Lines of Context:
44
44
 const MISSING_INFO = 4;        /* Return information on data gaps in interval */
45
45
  
46
46
 function __construct(GROUPRequest &$props, READER &$reader = NULL, $flags = 0) {
 
47
    global $DEFAULT_MISSING_VALUE;
 
48
    
47
49
    parent::__construct($props);
48
50
 
49
51
    $opts = &$this->req->GetOptions();
136
138
            if (!isset($this->fix_missing_items['limit']))
137
139
                $this->fix_missing_items['limit'] = 1;
138
140
            if (!isset($this->fix_missing_items['value']))
139
 
                $this->fix_missing_items['value'] = 0;
 
141
                $this->fix_missing_items['value'] = NULL;
140
142
        }
141
143
    }
142
144
 }
327
329
                if (!sizeof($value)) continue;
328
330
                
329
331
                if (sizeof($value) != $this->items) {
330
 
                    if ($this->ignore_invalid_data) continue;
331
 
                    throw new ADEIException(translate("Number of items in the group have changed from %u to %u (CACHE::Fill)", $this->items, sizeof($value)));
332
 
                }
 
332
                    $fixed = false;
 
333
                    
 
334
                    if (sizeof($value) < $this->items) {
 
335
                        if (($this->fix_missing_items)&&(sizeof($value) >= $this->fix_missing_items['limit'])) {
 
336
                            $fixed = true;
 
337
                            if ($this->fix_missing_items['check_growth']) {
 
338
                                /* to optimize performance we are doing really a simple
 
339
                                check here. We expect what all incomplete items are processed
 
340
                                on a first run. If then amount is changing we need to
 
341
                                regenerate CACHE tables, and this will be again first run.
 
342
                                The problems will occure only if we have interupted first run
 
343
                                and not all incomplete records are processed. We ignore that,
 
344
                                just clear cache and rerun */
 
345
 
 
346
                                    // Not a first call
 
347
                                if ($this->current_raw_end) {
 
348
                                    $fixed = false;
 
349
                                    $not_a_first_run = true;
 
350
                                } else {
 
351
                                    if (($this->actual_items)&&(sizeof($value) < $this->actual_items))
 
352
                                        $fixed = false;
 
353
                                }
 
354
                                
 
355
                            }
 
356
                            if ($fixed) {
 
357
                                $this->actual_items = sizeof($value);
 
358
                                $value = array_merge($value, array_fill(0, $this->items - sizeof($value), $this->fix_missing_items['value']));
 
359
                            }
 
360
                        }
 
361
                    } else {
 
362
                        if ($this->fix_extra_items) {
 
363
                            $this->actual_items = $this->items;
 
364
                            
 
365
                            $keys = array_keys($value);
 
366
                            for ($i = sizeof($keys) - 1;$i >= $this->items; $i--) {
 
367
                                unset($value[$keys[$i]]);
 
368
                            }
 
369
                            $fixed = true;
 
370
                        }
 
371
                    }
 
372
                    
 
373
                    if (!$fixed) {
 
374
                        if ($this->ignore_invalid_data) continue;
 
375
                        if ($not_a_first_run)
 
376
                            throw new ADEIException(translate("CACHE configuration accepts missing items only on a first run. Number of items in the group have changed from %u to %u (CACHE::Fill)", $this->items, sizeof($value)));
 
377
                        else
 
378
                            throw new ADEIException(translate("Number of items in the group have changed from %u to %u (CACHE::Fill)", $this->items, sizeof($value)));
 
379
                    }
 
380
                } else $this->actual_items = $this->items;
333
381
 
334
382
                $curdata->PushValue($value, $time - $pretime);
335
383
 
362
410
                                just clear cache and rerun */
363
411
 
364
412
                                    // Not a first call
365
 
                                if ($this->current_raw_end) $fixed = false;
366
 
                                else {
 
413
                                if ($this->current_raw_end) {
 
414
                                    $fixed = false;
 
415
                                    $not_a_first_run = true;
 
416
                                } else {
367
417
                                    if (($this->actual_items)&&(sizeof($value) < $this->actual_items))
368
418
                                        $fixed = false;
369
419
                                }
388
438
                    
389
439
                    if (!$fixed) {
390
440
                        if ($this->ignore_invalid_data) continue;
391
 
                        throw new ADEIException(translate("Number of items in the group have changed from %u to %u (CACHE::Fill)", $this->items, sizeof($value)));
 
441
                        if ($not_a_first_run)
 
442
                            throw new ADEIException(translate("CACHE configuration accepts missing items only on a first run. Number of items in the group have changed from %u to %u (CACHE::Fill)", $this->items, sizeof($value)));
 
443
                        else
 
444
                            throw new ADEIException(translate("Number of items in the group have changed from %u to %u (CACHE::Fill)", $this->items, sizeof($value)));
392
445
                    }
393
446
                } else $this->actual_items = $this->items;
394
447