Package org.jrobin.core

Examples of org.jrobin.core.RrdException


    for (int i = 0; i < unitNames.length; i++) {
      if (unitName.equalsIgnoreCase(unitNames[i])) {
        return units[i];
      }
    }
    throw new RrdException("Unknown time unit specified: " + unitName);
  }
View Full Code Here


    String[] maximums = getMultipleOptionValues("a", "maximum");
    String[] dsTypes = getMultipleOptionValues("d", "data-source-type");
    String[] dsNames = getMultipleOptionValues("r", "data-source-rename");
    String[] words = getRemainingWords();
    if (words.length < 2) {
      throw new RrdException("File name not specified");
    }
    if (words.length > 2) {
      throw new RrdException("Unexpected token encountered: " + words[2]);
    }
    String path = words[1];
    RrdDb rrd = getRrdDbReference(path);
    try {
      // heartbeat
View Full Code Here

  }

  private void expectToken(int desired, String errorMessage) throws RrdException {
    token = scanner.nextToken();
    if (token.id != desired) {
      throw new RrdException(errorMessage);
    }
  }
View Full Code Here

    }
    if (token.id == TimeToken.COLON) {
      expectToken(TimeToken.NUMBER, "Parsing HH:MM syntax, expecting MM as number, got none");
      minute = Integer.parseInt(token.value);
      if (minute > 59) {
        throw new RrdException("Parsing HH:MM syntax, got MM = " +
            minute + " (>59!)");
      }
      token = scanner.nextToken();
    }
    /* check if an AM or PM specifier was given */
    if (token.id == TimeToken.AM || token.id == TimeToken.PM) {
      if (hour > 12) {
        throw new RrdException("There cannot be more than 12 AM or PM hours");
      }
      if (token.id == TimeToken.PM) {
        if (hour != 12) {
          /* 12:xx PM is 12:xx, not 24:xx */
          hour += 12;
View Full Code Here

    if (year > 138) {
      if (year > 1970) {
        year -= 1900;
      }
      else {
        throw new RrdException("Invalid year " + year +
            " (should be either 00-99 or >1900)");
      }
    }
    else if (year >= 0 && year < 38) {
      year += 100;     /* Allow year 2000-2037 to be specified as   */
    }             /* 00-37 until the problem of 2038 year will */
    /* arise for unices with 32-bit time_t     */
    if (year < 70) {
      throw new RrdException("Won't handle dates before epoch (01/01/1970), sorry");
    }
    spec.year = (int) year;
    spec.month = (int) mon;
    spec.day = (int) mday;
  }
View Full Code Here

            }
          }
        }
        mon--;
        if (mon < 0 || mon > 11) {
          throw new RrdException("Did you really mean month " + (mon + 1));
        }
        if (mday < 1 || mday > 31) {
          throw new RrdException("I'm afraid that " + mday +
              " is not a valid day of the month");
        }
        assignDate(mday, mon, year);
        break;
    }
View Full Code Here

        token = scanner.nextToken();
        if (token.id == TimeToken.PLUS || token.id == TimeToken.MINUS) {
          break;
        }
        if (time_reference != TimeToken.NOW) {
          throw new RrdException("Words 'start' or 'end' MUST be followed by +|- offset");
        }
        else if (token.id != TimeToken.EOF) {
          throw new RrdException("If 'now' is followed by a token it must be +|- offset");
        }
        break;
        /* Only absolute time specifications below */
      case TimeToken.NUMBER:
        timeOfDay();
        if (token.id != TimeToken.NUMBER) {
          break;
        }
        /* fix month parsing */
      case TimeToken.JAN:
      case TimeToken.FEB:
      case TimeToken.MAR:
      case TimeToken.APR:
      case TimeToken.MAY:
      case TimeToken.JUN:
      case TimeToken.JUL:
      case TimeToken.AUG:
      case TimeToken.SEP:
      case TimeToken.OCT:
      case TimeToken.NOV:
      case TimeToken.DEC:
        day();
        if (token.id != TimeToken.NUMBER) {
          break;
        }
        timeOfDay();
        break;

        /* evil coding for TEATIME|NOON|MIDNIGHT - we've initialized
         * hr to zero up above, then fall into this case in such a
         * way so we add +12 +4 hours to it for teatime, +12 hours
         * to it for noon, and nothing at all for midnight, then
         * set our rettime to that hour before leaping into the
         * month scanner
         */
      case TimeToken.TEATIME:
        hr += 4;
        /* FALLTHRU */
      case TimeToken.NOON:
        hr += 12;
        /* FALLTHRU */
      case TimeToken.MIDNIGHT:
        spec.hour = hr;
        spec.min = 0;
        spec.sec = 0;
        token = scanner.nextToken();
        day();
        break;
      default:
        throw new RrdException("Unparsable time: " + token.value);
    }

    /*
     * the OFFSET-SPEC part
     *
     * (NOTE, the sc_tokid was prefetched for us by the previous code)
     */
    if (token.id == TimeToken.PLUS || token.id == TimeToken.MINUS) {
      scanner.setContext(false);
      while (token.id == TimeToken.PLUS || token.id == TimeToken.MINUS ||
          token.id == TimeToken.NUMBER) {
        if (token.id == TimeToken.NUMBER) {
          plusMinus(PREVIOUS_OP);
        }
        else {
          plusMinus(token.id);
        }
        token = scanner.nextToken();
        /* We will get EOF eventually but that's OK, since
        token() will return us as many EOFs as needed */
      }
    }
    /* now we should be at EOF */
    if (token.id != TimeToken.EOF) {
      throw new RrdException("Unparsable trailing text: " + token.value);
    }
    return spec;
  }
View Full Code Here

    else if (context != null && context.type == TYPE_ABSOLUTE) {
      gc = context.getTime();
    }
    // how would I guess what time it was?
    else {
      throw new RrdException("Relative times like '" +
          dateString + "' require proper absolute context to be evaluated");
    }
    gc.add(Calendar.YEAR, dyear);
    gc.add(Calendar.MONTH, dmonth);
    gc.add(Calendar.DAY_OF_MONTH, dday);
View Full Code Here

   * @return Two element array containing Calendar objects
   * @throws RrdException Thrown if relative time references cannot be resolved
   */
  public static Calendar[] getTimes(TimeSpec spec1, TimeSpec spec2) throws RrdException {
    if (spec1.type == TYPE_START || spec2.type == TYPE_END) {
      throw new RrdException("Recursive time specifications not allowed");
    }
    spec1.context = spec2;
    spec2.context = spec1;
    return new Calendar[] {
        spec1.getTime(),
View Full Code Here

      throws RrdException, IOException {

    ArrayList<Archive> possibleArchives = getArchiveList(type);

    if (possibleArchives.size() == 0) {
      throw new RrdException("Database does not contain an Archive of consolidation function type "
          + type);
    }

    Calendar endCal = Calendar.getInstance();
View Full Code Here

TOP

Related Classes of org.jrobin.core.RrdException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.