Package org.hsqldb.lib

Examples of org.hsqldb.lib.SimpleLog


    private boolean  logsStatements;
    private boolean  logStatements;
    private boolean  syncFile = false;

    public Logger() {
        appLog = new SimpleLog(null, SimpleLog.LOG_NONE, false);
    }
View Full Code Here


            HsqlDatabaseProperties.hsqldb_applog, 0);

        this.database = db;

        if (loglevel != SimpleLog.LOG_NONE) {
            appLog = new SimpleLog(path + ".app.log", loglevel,
                                   !db.isFilesReadOnly());
        }

        appLog.sendLine(SimpleLog.LOG_ERROR, "Database (re)opened");
View Full Code Here

     *  When true, writes out all cached rows that have been modified and the
     *  free position pointer for the *.data file and then closes the file.
     */
    public void close(boolean write) {

        SimpleLog appLog = database.logger.appLog;

        try {
            if (cacheReadonly) {
                if (dataFile != null) {
                    dataFile.close();

                    dataFile = null;
                }

                return;
            }

            StopWatch sw = new StopWatch();

            appLog.sendLine(SimpleLog.LOG_NORMAL,
                            "DataFileCache.close(" + write + ") : start");

            if (write) {
                cache.saveAll();
                Error.printSystemOut("saveAll: " + sw.elapsedTime());
                appLog.sendLine(SimpleLog.LOG_NORMAL,
                                "DataFileCache.close() : save data");

                if (fileModified || freeBlocks.isModified()) {

                    // set empty
                    dataFile.seek(LONG_EMPTY_SIZE);
                    dataFile.writeLong(freeBlocks.getLostBlocksSize());

                    // set end
                    dataFile.seek(LONG_FREE_POS_POS);
                    dataFile.writeLong(fileFreePosition);

                    // set saved flag;
                    dataFile.seek(FLAGS_POS);

                    int flag = BitMap.set(0, FLAG_ISSAVED);

                    if (hasRowInfo) {
                        flag = BitMap.set(flag, FLAG_ROWINFO);
                    }

                    dataFile.writeInt(flag);
                    appLog.sendLine(SimpleLog.LOG_NORMAL,
                                    "DataFileCache.close() : flags");

                    //
                    if (dataFile.length() != fileFreePosition) {
                        dataFile.seek(fileFreePosition);
                    }

                    appLog.sendLine(SimpleLog.LOG_NORMAL,
                                    "DataFileCache.close() : seek end");
                    Error.printSystemOut("pos and flags: " + sw.elapsedTime());
                }
            }

            if (dataFile != null) {
                dataFile.close();
                appLog.sendLine(SimpleLog.LOG_NORMAL,
                                "DataFileCache.close() : close");

                dataFile = null;

                Error.printSystemOut("close: " + sw.elapsedTime());
            }

            boolean empty = fileFreePosition == INITIAL_FREE_POS;

            if (empty) {
                fa.removeElement(fileName);
                fa.removeElement(backupFileName);
            }
        } catch (Throwable e) {
            appLog.logContext(e, null);

            throw Error.error(ErrorCode.FILE_IO_ERROR,
                              ErrorCode.M_DataFileCache_close, new Object[] {
                e, fileName
            });
View Full Code Here

     *  When true, writes out all cached rows that have been modified and the
     *  free position pointer for the *.data file and then closes the file.
     */
    public void close(boolean write) throws HsqlException {

        SimpleLog appLog = database.logger.appLog;

        try {
            if (cacheReadonly) {
                if (dataFile != null) {
                    dataFile.close();
                }

                return;
            }

            StopWatch sw = new StopWatch();

            appLog.sendLine(SimpleLog.LOG_NORMAL,
                            "DataFileCache.close(" + write + ") : start");

            if (write) {
                cache.saveAll();
                Trace.printSystemOut("saveAll: " + sw.elapsedTime());
                appLog.sendLine(SimpleLog.LOG_NORMAL,
                                "DataFileCache.close() : save data");

                if (fileModified || freeBlocks.isModified()) {

                    // set empty
                    dataFile.seek(LONG_EMPTY_SIZE);
                    dataFile.writeLong(freeBlocks.getLostBlocksSize());

                    // set end
                    dataFile.seek(LONG_FREE_POS_POS);
                    dataFile.writeLong(fileFreePosition);

                    // set saved flag;
                    dataFile.seek(FLAGS_POS);

                    int flag = BitMap.set(0, FLAG_ISSAVED);

                    if (hasRowInfo) {
                        flag = BitMap.set(flag, FLAG_ROWINFO);
                    }

                    dataFile.writeInt(flag);
                    appLog.sendLine(SimpleLog.LOG_NORMAL,
                                    "DataFileCache.close() : flags");

                    //
                    if (dataFile.length() != fileFreePosition) {
                        dataFile.seek(fileFreePosition);
                    }

                    appLog.sendLine(SimpleLog.LOG_NORMAL,
                                    "DataFileCache.close() : seek end");
                    Trace.printSystemOut("pos and flags: "
                                         + sw.elapsedTime());
                }
            }

            if (dataFile != null) {
                dataFile.close();
                appLog.sendLine(SimpleLog.LOG_NORMAL,
                                "DataFileCache.close() : close");

                dataFile = null;

                Trace.printSystemOut("close: " + sw.elapsedTime());
            }

            boolean empty = fileFreePosition == INITIAL_FREE_POS;

            if (empty) {
                fa.removeElement(fileName);
                fa.removeElement(backupFileName);
            }
        } catch (Throwable e) {
            appLog.logContext(e, null);

            throw Trace.error(Trace.FILE_IO_ERROR, Trace.DataFileCache_close,
                              new Object[] {
                e, fileName
            });
View Full Code Here

    LockFile lf;
    boolean  logStatements;
    boolean  syncFile = false;

    public Logger() {
        appLog = new SimpleLog(null, SimpleLog.LOG_NONE, false);
    }
View Full Code Here

        String path = db.getPath();
        int loglevel = db.getProperties().getIntegerProperty(
            HsqlDatabaseProperties.hsqldb_applog, 0);

        if (loglevel != SimpleLog.LOG_NONE) {
            appLog = new SimpleLog(path + ".app.log", loglevel,
                                   !db.isFilesReadOnly());
        }

        appLog.sendLine(SimpleLog.LOG_ERROR, "Database (re)opened");
View Full Code Here

     *  When true, writes out all cached rows that have been modified and the free
     *  position pointer for the *.data file and then closes the file.
     */
    public void close(boolean write) throws HsqlException {

        SimpleLog appLog = database.logger.appLog;

        try {
            if (cacheReadonly) {
                if (dataFile != null) {
                    dataFile.close();
                }

                return;
            }

            StopWatch sw = new StopWatch();

            appLog.sendLine(SimpleLog.LOG_NORMAL,
                            "DataFileCache.close(" + write + ") : start");

            if (write) {
                cache.saveAll();
                Trace.printSystemOut("saveAll: " + sw.elapsedTime());
                appLog.sendLine(SimpleLog.LOG_NORMAL,
                                "DataFileCache.close() : save data");

                if (fileModified || freeBlocks.isModified()) {

                    // set empty
                    dataFile.seek(LONG_EMPTY_SIZE);
                    dataFile.writeLong(freeBlocks.getLostBlocksSize());

                    // set end
                    dataFile.seek(LONG_FREE_POS_POS);
                    dataFile.writeLong(fileFreePosition);

                    // set saved flag;
                    dataFile.seek(FLAGS_POS);

                    int flag = BitMap.set(0, FLAG_ISSAVED);

                    if (hasRowInfo) {
                        flag = BitMap.set(flag, FLAG_ROWINFO);
                    }

                    dataFile.writeInt(flag);
                    appLog.sendLine(SimpleLog.LOG_NORMAL,
                                    "DataFileCache.close() : flags");

                    //
                    if (dataFile.length() != fileFreePosition) {
                        dataFile.seek(fileFreePosition);
                    }

                    appLog.sendLine(SimpleLog.LOG_NORMAL,
                                    "DataFileCache.close() : seek end");
                    Trace.printSystemOut("pos and flags: "
                                         + sw.elapsedTime());
                }
            }

            if (dataFile != null) {
                dataFile.close();
                appLog.sendLine(SimpleLog.LOG_NORMAL,
                                "DataFileCache.close() : close");

                dataFile = null;

                Trace.printSystemOut("close: " + sw.elapsedTime());
            }

            boolean empty = fileFreePosition == INITIAL_FREE_POS;

            if (empty) {
                fa.removeElement(fileName);
                fa.removeElement(backupFileName);
            }
        } catch (Throwable e) {
            appLog.logContext(e);

            throw Trace.error(Trace.FILE_IO_ERROR, Trace.DataFileCache_close,
                              new Object[] {
                e, fileName
            });
View Full Code Here

        }
    }

    void postClose(boolean keep) throws HsqlException {

        SimpleLog appLog = database.logger.appLog;

        if (cacheReadonly) {
            return;
        }

        try {
            appLog.sendLine(SimpleLog.LOG_NORMAL,
                            "DataFileCache.postClose(" + keep + ") : start");

            if (keep) {
                database.getProperties().setProperty(
                    HsqlDatabaseProperties.hsqldb_cache_version,
                    HsqlDatabaseProperties.VERSION_STRING_1_7_0);
                database.getProperties().save();
                appLog.sendLine(SimpleLog.LOG_NORMAL,
                                "DataFileCache.postClose() : save props");

                if (fileModified) {
                    backup();
                }
            } else {
                fa.removeElement(backupFileName);
                appLog.sendLine(SimpleLog.LOG_NORMAL,
                                "DataFileCache.postClose() : delete backup");
                deleteOrResetFreePos(database, fileName);
                appLog.sendLine(SimpleLog.LOG_NORMAL,
                                "DataFileCache.postClose() : delete file");
            }
        } catch (IOException e) {
            throw new HsqlException(
                e, Trace.getMessage(Trace.GENERAL_IO_ERROR),
View Full Code Here

  {
    this.needsCheckpoint = false;
    String str = paramDatabase.getPath();
    int i = paramDatabase.getProperties().getIntegerProperty("hsqldb.applog", 0);
    if (i != SimpleLog.LOG_NONE)
      this.appLog = new SimpleLog(str + ".app.log", i, !paramDatabase.isFilesReadOnly());
    this.appLog.sendLine(SimpleLog.LOG_ERROR, "Database (re)opened");
    this.logStatements = false;
    if (!paramDatabase.isFilesReadOnly())
      acquireLock(str);
    this.log = new Log(paramDatabase);
View Full Code Here

  }

  public void close(boolean paramBoolean)
    throws HsqlException
  {
    SimpleLog localSimpleLog = this.database.logger.appLog;
    try
    {
      if (this.cacheReadonly)
      {
        if (this.dataFile != null)
          this.dataFile.close();
        return;
      }
      StopWatch localStopWatch = new StopWatch();
      localSimpleLog.sendLine(SimpleLog.LOG_NORMAL, "DataFileCache.close(" + paramBoolean + ") : start");
      if (paramBoolean)
      {
        this.cache.saveAll();
        Trace.printSystemOut("saveAll: " + localStopWatch.elapsedTime());
        localSimpleLog.sendLine(SimpleLog.LOG_NORMAL, "DataFileCache.close() : save data");
        if ((this.fileModified) || (this.freeBlocks.isModified()))
        {
          this.dataFile.seek(4L);
          this.dataFile.writeLong(this.freeBlocks.getLostBlocksSize());
          this.dataFile.seek(12L);
          this.dataFile.writeLong(this.fileFreePosition);
          this.dataFile.seek(28L);
          i = BitMap.set(0, 2);
          if (this.hasRowInfo)
            i = BitMap.set(i, 3);
          this.dataFile.writeInt(i);
          localSimpleLog.sendLine(SimpleLog.LOG_NORMAL, "DataFileCache.close() : flags");
          if (this.dataFile.length() != this.fileFreePosition)
            this.dataFile.seek(this.fileFreePosition);
          localSimpleLog.sendLine(SimpleLog.LOG_NORMAL, "DataFileCache.close() : seek end");
          Trace.printSystemOut("pos and flags: " + localStopWatch.elapsedTime());
        }
      }
      if (this.dataFile != null)
      {
        this.dataFile.close();
        localSimpleLog.sendLine(SimpleLog.LOG_NORMAL, "DataFileCache.close() : close");
        this.dataFile = null;
        Trace.printSystemOut("close: " + localStopWatch.elapsedTime());
      }
      int i = this.fileFreePosition == 32L ? 1 : 0;
      if (i != 0)
      {
        this.fa.removeElement(this.fileName);
        this.fa.removeElement(this.backupFileName);
      }
    }
    catch (Throwable localThrowable)
    {
      localSimpleLog.logContext(localThrowable, null);
      throw Trace.error(29, 211, new Object[] { localThrowable, this.fileName });
    }
  }
View Full Code Here

TOP

Related Classes of org.hsqldb.lib.SimpleLog

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.