Beispiel #1
0
        public String dump()
        {
            StringBuilder buffer = new StringBuilder("== ARCHIVE ==\n");

            buffer.Append("RRA:").Append(consolFun.get()).Append(":").Append(xff.get()).Append(":").Append(steps.get()).Append(":").Append(rows.get()).Append("\n");
            buffer.Append("interval [").Append(getStartTime()).AppendFormat(" ({0}) ", getStartDateTime().ToString())
            .Append(", ").Append(getEndTime()).AppendFormat(" ({0}) ", getEndDateTime().ToString()).Append("]" + "\n");
            for (int i = 0; i < robins.Length; i++)
            {
                buffer.Append(states[i].dump());
                buffer.Append(robins[i].dump());
            }
            return(buffer.ToString());
        }
Beispiel #2
0
 public Archive(RrdDb parentDb, ArcDef arcDef)
 {
    bool shouldInitialize = arcDef != null;
    this.parentDb = parentDb;
    consolFun = new RrdString(this, true);  // constant, may be cached
    xff = new RrdDouble(this);
    steps = new RrdInt(this, true);            // constant, may be cached
    rows = new RrdInt(this, true);            // constant, may be cached
    if (shouldInitialize)
    {
       consolFun.set(arcDef.getConsolFun().Name);
       xff.set(arcDef.getXff());
       steps.set(arcDef.getSteps());
       rows.set(arcDef.getRows());
    }
    int n = parentDb.getHeader().getDsCount();
    states = new ArcState[n];
    robins = new Robin[n];
    for (int i = 0; i < n; i++)
    {
       states[i] = new ArcState(this, shouldInitialize);
       int numRows = rows.get();
       robins[i] = new Robin(this, numRows, shouldInitialize);
    }
 }
Beispiel #3
0
        public Archive(RrdDb parentDb, ArcDef arcDef)
        {
            bool shouldInitialize = arcDef != null;

            this.parentDb = parentDb;
            consolFun     = new RrdString(this, true); // constant, may be cached
            xff           = new RrdDouble(this);
            steps         = new RrdInt(this, true);    // constant, may be cached
            rows          = new RrdInt(this, true);    // constant, may be cached
            if (shouldInitialize)
            {
                consolFun.set(arcDef.getConsolFun().Name);
                xff.set(arcDef.getXff());
                steps.set(arcDef.getSteps());
                rows.set(arcDef.getRows());
            }
            int n = parentDb.getHeader().getDsCount();

            states = new ArcState[n];
            robins = new Robin[n];
            for (int i = 0; i < n; i++)
            {
                states[i] = new ArcState(this, shouldInitialize);
                int numRows = rows.get();
                robins[i] = new Robin(this, numRows, shouldInitialize);
            }
        }
Beispiel #4
0
        // stores single value
        public void store(double newValue)
        {
            int position = pointer.get();

            values.set(position, newValue);
            pointer.set((position + 1) % rows);
        }
Beispiel #5
0
 /**
  * Returns the number of datasources defined in the RRD.
  *
  * @return Number of datasources defined
  * @Thrown in case of I/O error
  */
 public int getDsCount()
 {
     return(dsCount.get());
 }
Beispiel #6
0
        //// read from XML
        //public Archive(RrdDb parentDb, DataImporter reader, int arcIndex) {
        //    this(parentDb, new ArcDef(
        //            reader.getConsolFun(arcIndex), reader.getXff(arcIndex),
        //            reader.getSteps(arcIndex), reader.getRows(arcIndex)));
        //    int n = parentDb.getHeader().getDsCount();
        //    for (int i = 0; i < n; i++) {
        //        // restore state
        //        states[i].setAccumValue(reader.getStateAccumValue(arcIndex, i));
        //        states[i].setNanSteps(reader.getStateNanSteps(arcIndex, i));
        //        // restore robins
        //        double[] values = reader.getValues(arcIndex, i);
        //        robins[i].update(values);
        //    }
        //}

        /**
         * Returns archive time step in seconds. Archive step is equal to RRD step
         * multiplied with the number of archive steps.
         *
         * @return Archive time step in seconds
         * @Thrown in case of I/O error.
         */
        public long getArcStep()
        {
            long step = parentDb.getHeader().getStep();

            return(step * steps.get());
        }