Exemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="other"></param>
        public void CopyStateTo(IRrdUpdatable other)
        {
            if (!(other is Robin))
            {
                throw new RrdException("Cannot copy Robin object to " + other.ToString());
            }
            Robin robin    = (Robin)other;
            int   rowsDiff = rows - robin.rows;

            if (rowsDiff == 0)
            {
                // Identical dimensions. Do copy in BULK to speed things up
                robin.pointer.Set(pointer.Get());
                robin.values.WriteBytes(values.ReadBytes());
            }
            else
            {
                // different sizes
                for (int i = 0; i < robin.rows; i++)
                {
                    int j = i + rowsDiff;
                    robin.Store(j >= 0? GetValue(j): Double.NaN);
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="parentDb"></param>
        public Archive(RrdDb parentDb)
        {
            this.parentDb = parentDb;
            consolFun     = new RrdString(this);
            xff           = new RrdDouble(this);
            steps         = new RrdInt(this);
            rows          = new RrdInt(this);
            int n = parentDb.Header.DsCount;

            states = new ArcState[n];
            robins = new Robin[n];
            for (int i = 0; i < n; i++)
            {
                states[i] = new ArcState(this);
                robins[i] = new Robin(this, rows.Get());
            }
        }
Exemplo n.º 3
0
        private void FinalizeStep(ArcState state, Robin robin)
        {
            // should store
            long   arcSteps = steps.Get();
            double arcXff   = xff.Get();
            long   nanSteps = state.NanSteps;
            //double nanPct = (double) nanSteps / (double) arcSteps;
            double accumValue = state.AccumValue;

            if (nanSteps <= arcXff * arcSteps && !Double.IsNaN(accumValue))
            {
                if (consolFun.Get().Equals("AVERAGE"))
                {
                    accumValue /= (arcSteps - nanSteps);
                }
                robin.Store(accumValue);
            }
            else
            {
                robin.Store(Double.NaN);
            }
            state.AccumValue = Double.NaN;
            state.NanSteps   = 0;
        }
Exemplo n.º 4
0
        internal void archive(int dsIndex, double data, long numUpdates)
        {
            Robin    robin          = robins[dsIndex];
            ArcState state          = states[dsIndex];
            long     step           = parentDb.Header.Step;
            long     lastUpdateTime = parentDb.Header.LastUpdateTime;
            long     updateTime     = Util.Normalize(lastUpdateTime, step) + step;
            long     arcStep        = ArcStep;

            while (numUpdates > 0)
            {
                Accumulate(state, data);
                numUpdates--;
                if (updateTime % arcStep == 0)
                {
                    FinalizeStep(state, robin);
                    break;
                }
                else
                {
                    updateTime += step;
                }
            }


            int bulkUpdateCount = (int)Math.Min(numUpdates / steps.Get(), (long)rows.Get());

            robin.BulkStore(data, bulkUpdateCount);

            long remainingUpdates = numUpdates % steps.Get();

            for (long i = 0; i < remainingUpdates; i++)
            {
                Accumulate(state, data);
            }
        }