Package org.h2.message

Examples of org.h2.message.TraceSystem


//     conn.close();
//     }

    public void test() throws Exception {
        if (config.traceLevelFile > 0) {
            TraceSystem sys = JdbcDataSourceFactory.getTraceSystem();
            sys.setFileName(getBaseDir() + "/test/trace");
            sys.setLevelFile(3);
        }
        testDataSourceFactory();
        testDataSource();
        testXAConnection();
        deleteDb("dataSource");
View Full Code Here


                    database.checkpointIfRequired();
                } else {
                    database.flush();
                }
            } catch (Exception e) {
                TraceSystem traceSystem = database.getTraceSystem();
                if (traceSystem != null) {
                    traceSystem.getTrace(Trace.DATABASE).error(e, "flush");
                }
            }
            // TODO log writer: could also flush the dirty cache
            // when there is low activity
View Full Code Here

     * @throws SQLException if it failed
     */
    public static void tryUnlockDatabase(List<String> files, String message) throws SQLException {
        for (String fileName : files) {
            if (fileName.endsWith(Constants.SUFFIX_LOCK_FILE)) {
                FileLock lock = new FileLock(new TraceSystem(null), fileName, Constants.LOCK_SLEEP);
                try {
                    lock.lock(FileLock.LOCK_FILE);
                    lock.unlock();
                } catch (DbException e) {
                    throw DbException.get(
View Full Code Here

            }
            if (existsPage && !FileUtils.canWrite(pageFileName)) {
                readOnly = true;
            }
            if (readOnly) {
                traceSystem = new TraceSystem(null);
            } else {
                traceSystem = new TraceSystem(databaseName + Constants.SUFFIX_TRACE_FILE);
            }
            traceSystem.setLevelFile(traceLevelFile);
            traceSystem.setLevelSystemOut(traceLevelSystemOut);
            trace = traceSystem.getTrace(Trace.DATABASE);
            trace.info("opening {0} (build {1})", databaseName, Constants.BUILD_ID);
            if (autoServerMode) {
                if (readOnly ||
                        fileLockMethod == FileLock.LOCK_NO ||
                        fileLockMethod == FileLock.LOCK_SERIALIZED ||
                        fileLockMethod == FileLock.LOCK_FS ||
                        !persistent) {
                    throw DbException.getUnsupportedException("autoServerMode && (readOnly || fileLockMethod == NO" +
                            " || fileLockMethod == SERIALIZED || inMemory)");
                }
            }
            String lockFileName = databaseName + Constants.SUFFIX_LOCK_FILE;
            if (readOnly) {
                if (FileUtils.exists(lockFileName)) {
                    throw DbException.get(ErrorCode.DATABASE_ALREADY_OPEN_1, "Lock file exists: " + lockFileName);
                }
            }
            if (!readOnly && fileLockMethod != FileLock.LOCK_NO) {
                if (fileLockMethod != FileLock.LOCK_FS) {
                    lock = new FileLock(traceSystem, lockFileName, Constants.LOCK_SLEEP);
                    lock.lock(fileLockMethod);
                    if (autoServerMode) {
                        startServer(lock.getUniqueId());
                    }
                }
            }
            if (SysProperties.MODIFY_ON_WRITE) {
                while (isReconnectNeeded()) {
                    // wait until others stopped writing
                }
            } else {
                while (isReconnectNeeded() && !beforeWriting()) {
                    // wait until others stopped writing and
                    // until we can write (the file is not yet open -
                    // no need to re-connect)
                }
            }
            deleteOldTempFiles();
            starting = true;
            if (SysProperties.MODIFY_ON_WRITE) {
                try {
                    getPageStore();
                } catch (DbException e) {
                    if (e.getErrorCode() != ErrorCode.DATABASE_IS_READ_ONLY) {
                        throw e;
                    }
                    pageStore = null;
                    while (!beforeWriting()) {
                        // wait until others stopped writing and
                        // until we can write (the file is not yet open -
                        // no need to re-connect)
                    }
                    getPageStore();
                }
            } else {
                getPageStore();
            }
            starting = false;
            writer = WriterThread.create(this, writeDelay);
        } else {
            if (autoServerMode) {
                throw DbException.getUnsupportedException("autoServerMode && inMemory");
            }
            traceSystem = new TraceSystem(null);
            trace = traceSystem.getTrace(Trace.DATABASE);
        }
        systemUser = new User(this, 0, SYSTEM_USER_NAME, true);
        mainSchema = new Schema(this, 0, Constants.SCHEMA_MAIN, systemUser, true);
        infoSchema = new Schema(this, -1, "INFORMATION_SCHEMA", systemUser, true);
View Full Code Here

        if (trace != null && !closed) {
            return trace;
        }
        String traceModuleName = Trace.JDBC + "[" + id + "]";
        if (closed) {
            return new TraceSystem(null).getTrace(traceModuleName);
        }
        trace = database.getTrace(traceModuleName);
        return trace;
    }
View Full Code Here

        if (idx < 0) {
            throw ci.getFormatException();
        }
        databaseName = name.substring(idx + 1);
        String server = name.substring(0, idx);
        traceSystem = new TraceSystem(null);
        String traceLevelFile = ci.getProperty(SetTypes.TRACE_LEVEL_FILE, null);
        if (traceLevelFile != null) {
            int level = Integer.parseInt(traceLevelFile);
            String prefix = getFilePrefix(SysProperties.CLIENT_TRACE_DIRECTORY);
            try {
View Full Code Here

                    database.checkpointIfRequired();
                } else {
                    database.flush();
                }
            } catch (Exception e) {
                TraceSystem traceSystem = database.getTraceSystem();
                if (traceSystem != null) {
                    traceSystem.getTrace(Trace.DATABASE).error(e, "flush");
                }
            }
            // TODO log writer: could also flush the dirty cache
            // when there is low activity
View Full Code Here

     * @throws SQLException if it failed
     */
    public static void tryUnlockDatabase(List<String> files, String message) throws SQLException {
        for (String fileName : files) {
            if (fileName.endsWith(Constants.SUFFIX_LOCK_FILE)) {
                FileLock lock = new FileLock(new TraceSystem(null), fileName, Constants.LOCK_SLEEP);
                try {
                    lock.lock(FileLock.LOCK_FILE);
                    lock.unlock();
                } catch (DbException e) {
                    throw DbException.get(
View Full Code Here

     * INTERNAL
     */
    public static TraceSystem getTraceSystem() {
        synchronized (JdbcDataSourceFactory.class) {
            if (cachedTraceSystem == null) {
                cachedTraceSystem = new TraceSystem(
                        SysProperties.CLIENT_TRACE_DIRECTORY + "h2datasource" + Constants.SUFFIX_TRACE_FILE);
                cachedTraceSystem.setLevelFile(SysProperties.DATASOURCE_TRACE_LEVEL);
            }
            return cachedTraceSystem;
        }
View Full Code Here

     * @throws SQLException if it failed
     */
    public static void tryUnlockDatabase(ArrayList<String> files, String message) throws SQLException {
        for (String fileName : files) {
            if (fileName.endsWith(Constants.SUFFIX_LOCK_FILE)) {
                FileLock lock = new FileLock(new TraceSystem(null), fileName, Constants.LOCK_SLEEP);
                try {
                    lock.lock(FileLock.LOCK_FILE);
                    lock.unlock();
                } catch (DbException e) {
                    throw DbException.get(
View Full Code Here

TOP

Related Classes of org.h2.message.TraceSystem

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.