/**
   * Print a text to the log (usually derby.log), provided that verbose is true.
   *
   * @param text The text that will be logged
   * @param writeHeader if true, encapsulates message in "begin error message" and "end error
   *     message" lines. If false, timestamps the text and writes it to the log without the header
   *     and footer.
   */
  public void logText(String text, boolean writeHeader) {

    if (verbose) {
      if (writeHeader) {
        Monitor.logTextMessage(MessageId.REPLICATION_ERROR_BEGIN, new Date());
        Monitor.logMessage(text);
        Monitor.logTextMessage(MessageId.REPLICATION_ERROR_END);
      } else {
        Monitor.logTextMessage(MessageId.REPLICATION_ONELINE_MSG_HEADER, new Date(), text);
      }
    }
  }
  /**
   * Print error message and the stack trace of the throwable to the log (usually derby.log)
   * provided that verbose is true. If verbose is false, nothing is logged.
   *
   * @param msgId The error message id
   * @param t Error trace starts from this error
   */
  public void logError(String msgId, Throwable t) {

    if (verbose) {

      Monitor.logTextMessage(MessageId.REPLICATION_ERROR_BEGIN, new Date());

      if (msgId != null) {
        Monitor.logTextMessage(msgId, dbname);
      }

      if (t != null) {
        ErrorStringBuilder esb = new ErrorStringBuilder(Monitor.getStream().getHeader());
        esb.stackTrace(t);
        Monitor.logMessage(esb.get().toString());
        esb.reset();
      }
      Monitor.logTextMessage(MessageId.REPLICATION_ERROR_END);
    }
  }
Esempio n. 3
0
  /**
   * Convert this page to requested type, as defined by input format id.
   *
   * <p>The current cache entry is a different format id than the requested type, change it. This
   * object is instantiated to the wrong subtype of cachedPage, this routine will create an object
   * with the correct subtype, and transfer all pertinent information from this to the new correct
   * object.
   *
   * <p>
   *
   * @return The new object created with the input fid and transfered info.
   * @param fid The format id of the new page.
   * @param newIdentity The key of the new page.
   * @exception StandardException Standard exception policy.
   */
  private CachedPage changeInstanceTo(int fid, PageKey newIdentity) throws StandardException {
    CachedPage realPage;

    try {
      realPage = (CachedPage) Monitor.newInstanceFromIdentifier(fid);

    } catch (StandardException se) {
      if (se.getSeverity() > ExceptionSeverity.STATEMENT_SEVERITY) {
        throw se;
      } else {
        throw StandardException.newException(
            SQLState.DATA_UNKNOWN_PAGE_FORMAT_2,
            newIdentity,
            org.apache.derby.iapi.util.StringUtil.hexDump(pageData));
      }
    }

    realPage.setFactory(dataFactory);

    // avoid creating the data buffer if possible, transfer it to the new
    // page if this is the first time the page buffer is used, then
    // createPage will create the page array with the correct page size
    if (this.pageData != null) {
      realPage.alreadyReadPage = true;
      realPage.usePageBuffer(this.pageData);
    }

    // RESOLVE (12/15/06) - the following code is commented out, but
    // not sure why.

    // this page should not be used any more, null out all its content and
    // wait for GC to clean it up

    // destroyPage();// let this subtype have a chance to get rid of stuff
    // this.pageData = null;	// this instance no longer own the data array
    // this.pageCache = null;
    // this.dataFactory = null;
    // this.containerCache = null;

    return realPage;
  }