当前位置: 首页>>代码示例>>Java>>正文


Java Environment.sync方法代码示例

本文整理汇总了Java中com.sleepycat.je.Environment.sync方法的典型用法代码示例。如果您正苦于以下问题:Java Environment.sync方法的具体用法?Java Environment.sync怎么用?Java Environment.sync使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.sleepycat.je.Environment的用法示例。


在下文中一共展示了Environment.sync方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testLesserVersionNotUpdated

import com.sleepycat.je.Environment; //导入方法依赖的package包/类
/**
 * Tests that when a file is opened with a lesser version than the current
 * version, a new log file is started for writing new log entries.  This is
 * important so that the new header version is written even if no new log
 * file is needed.  If the new version were not written, an older version
 * of JE would not recognize that there had been a version change.
 */
public void testLesserVersionNotUpdated()
    throws DatabaseException, IOException {

    TestUtils.loadLog(getClass(), Utils.MIN_VERSION_NAME, envHome);
    File logFile = new File(envHome, TestUtils.LOG_FILE_NAME);
    long origFileSize = logFile.length();

    EnvironmentConfig envConfig = TestUtils.initEnvConfig();
    envConfig.setAllowCreate(false);
    envConfig.setTransactional(true);

    Environment env = new Environment(envHome, envConfig);
    env.sync();
    env.close();

    assertEquals(origFileSize, logFile.length());
}
 
开发者ID:nologic,项目名称:nabs,代码行数:25,代码来源:LogHeaderVersionTest.java

示例2: testEmptyDatabaseSR14744

import com.sleepycat.je.Environment; //导入方法依赖的package包/类
public void testEmptyDatabaseSR14744()
throws Throwable {

Database db = null;
try {
    EnvironmentConfig envConfig = getEnvConfig(true);
    env = new Environment(envHome, envConfig);
    db = createDb(true);
    db.sync();
       } finally {
           if (db != null) {
               db.close();
           }

           env.sync();
           env.close();
           env = null;
       }
   }
 
开发者ID:nologic,项目名称:nabs,代码行数:20,代码来源:DeferredWriteTest.java

示例3: testEmptyExtraFile

import com.sleepycat.je.Environment; //导入方法依赖的package包/类
public void testEmptyExtraFile()
       throws Throwable {

EnvironmentConfig envConfig = TestUtils.initEnvConfig();
       envConfig.setAllowCreate(true);
       Environment env = new Environment(envHome, envConfig);

       try {
           /* Make an environment. */
           env.sync();

           /* Add an extra, 0 length file */
           EnvironmentImpl envImpl = DbInternal.envGetEnvironmentImpl(env);

           File newFile = new File(envHome, "00000001.jdb");
           newFile.createNewFile();

           INFileReader reader = new INFileReader(envImpl,
                                                  1000,
                                                  DbLsn.NULL_LSN,
					   DbLsn.NULL_LSN,
                                                  false,
                                                  false,
                                                  DbLsn.NULL_LSN,
                                                  null);
           while (reader.readNextEntry()) {
           }

       } catch (Throwable t) {
           t.printStackTrace();
           throw t;
       } finally {
           env.close();
       }
   }
 
开发者ID:nologic,项目名称:nabs,代码行数:36,代码来源:FileReaderTest.java

示例4: invoke

import com.sleepycat.je.Environment; //导入方法依赖的package包/类
/**
 * Invoke an operation for the given environment.
 *
 * @param targetEnv The target JE environment. May be null if the
 * environment is not open.
 * @param actionName operation name.
 * @param params operation parameters. May be null.
 * @param signature operation signature. May be null.
 * @return the operation result
 */
public Object invoke(Environment targetEnv,
                     String actionName,
                     Object [] params,
                     String [] signature)
    throws MBeanException {

    /* Sanity checking. */
    if (actionName == null) {
        throw new IllegalArgumentException("actionName cannot be null");
    }

    try {
        if (targetEnv != null) {
            if (actionName.equals(OP_CLEAN)) {
                int numFiles = targetEnv.cleanLog();
                return new Integer(numFiles);
            } else if (actionName.equals(OP_EVICT)) {
                targetEnv.evictMemory();
                return null;
            } else if (actionName.equals(OP_CHECKPOINT)) {
                CheckpointConfig config = new CheckpointConfig();
                if ((params != null) && (params.length > 0)) {
                    Boolean force = (Boolean) params[0];
                    config.setForce(force.booleanValue());
                }
                targetEnv.checkpoint(config);
                return null;
            } else if (actionName.equals(OP_SYNC)) {
                targetEnv.sync();
                return null;
            } else if (actionName.equals(OP_ENV_STAT)) {
                return targetEnv.getStats(getStatsConfig(params));
            } else if (actionName.equals(OP_LOCK_STAT)) {
                return targetEnv.getLockStats(getStatsConfig(params));
            } else if (actionName.equals(OP_TXN_STAT)) {
                return targetEnv.getTransactionStats(
                                                   getStatsConfig(params));
            } else if (actionName.equals(OP_DB_NAMES)) {
                return targetEnv.getDatabaseNames();
            } else if (actionName.equals(OP_DB_STAT)) {
                return getDatabaseStats(targetEnv, params);
            }
        }

        return new IllegalArgumentException("actionName: " +
                                            actionName +
                                            " is not valid");
    } catch (DatabaseException e) {
        /*
         * Add both the message and the exception for easiest
         * deciphering of the problem. Sometimes the original exception
         * stacktrace gets hidden in server logs.
         */
        throw new MBeanException(e, e.getMessage());
    }
}
 
开发者ID:nologic,项目名称:nabs,代码行数:67,代码来源:JEMBeanHelper.java

示例5: invoke

import com.sleepycat.je.Environment; //导入方法依赖的package包/类
/**
 * Invoke an operation for the given environment.
 * 
 * @param targetEnv The target JE environment. May be null if the
 * environment is not open.
 * @param actionName operation name.
 * @param params operation parameters. May be null.
 * @param signature operation signature. May be null.
 * @return the operation result
 */
public Object invoke(Environment targetEnv,
                     String actionName,
                     Object [] params,
                     String [] signature) 
    throws MBeanException {

    /* Sanity checking. */
    if (actionName == null) {
        throw new IllegalArgumentException("actionName cannot be null");
    }

    try {
        if (targetEnv != null) {
            if (actionName.equals(OP_CLEAN)) {
                int numFiles = targetEnv.cleanLog();
                return new Integer(numFiles);
            } else if (actionName.equals(OP_EVICT)) {
                targetEnv.evictMemory();
                return null;
            } else if (actionName.equals(OP_CHECKPOINT)) {
                CheckpointConfig config = new CheckpointConfig();
                if ((params != null) && (params.length > 0)) {
                    Boolean force = (Boolean) params[0];
                    config.setForce(force.booleanValue());
                }
                targetEnv.checkpoint(config);
                return null;
            } else if (actionName.equals(OP_SYNC)) {
                targetEnv.sync();
                return null;
            } else if (actionName.equals(OP_ENV_STAT)) {
                return targetEnv.getStats(getStatsConfig(params));
            } else if (actionName.equals(OP_LOCK_STAT)) {
                return targetEnv.getLockStats(getStatsConfig(params));
            } else if (actionName.equals(OP_TXN_STAT)) {
                return targetEnv.getTransactionStats(
                                                   getStatsConfig(params));
            } else if (actionName.equals(OP_DB_NAMES)) {
                return targetEnv.getDatabaseNames();
            } else if (actionName.equals(OP_DB_STAT)) {
                return getDatabaseStats(targetEnv, params);
            }
        } 

        return new IllegalArgumentException("actionName: " +
                                            actionName +
                                            " is not valid");
    } catch (DatabaseException e) {
        /* 
         * Add both the message and the exception for easiest
         * deciphering of the problem. Sometimes the original exception
         * stacktrace gets hidden in server logs.
         */
        throw new MBeanException(e, e.getMessage());
    }
}
 
开发者ID:nologic,项目名称:nabs,代码行数:67,代码来源:JEMBeanHelper.java

示例6: invoke

import com.sleepycat.je.Environment; //导入方法依赖的package包/类
/**
 * Invoke an operation for the given environment.
 *
 * @param targetEnv The target JE environment. May be null if the
 * environment is not open.
 * @param actionName operation name.
 * @param params operation parameters. May be null.
 * @param signature operation signature. May be null.
 * @return the operation result
 */
public Object invoke(Environment targetEnv,
                     String actionName,
                     Object[] params,
                     String[] signature)
    throws MBeanException {

    /* Sanity checking. */
    if (actionName == null) {
        throw new IllegalArgumentException("actionName cannot be null");
    }

    try {
        if (targetEnv != null) {
            if (actionName.equals(OP_CLEAN)) {
                int numFiles = targetEnv.cleanLog();
                return new Integer(numFiles);
            } else if (actionName.equals(OP_EVICT)) {
                targetEnv.evictMemory();
                return null;
            } else if (actionName.equals(OP_CHECKPOINT)) {
                CheckpointConfig config = new CheckpointConfig();
                if ((params != null) && (params.length > 0)) {
                    Boolean force = (Boolean) params[0];
                    config.setForce(force.booleanValue());
                }
                targetEnv.checkpoint(config);
                return null;
            } else if (actionName.equals(OP_SYNC)) {
                targetEnv.sync();
                return null;
            } else if (actionName.equals(OP_ENV_STAT)) {
                return targetEnv.getStats
                    (getStatsConfig(params)).toString();
            } else if (actionName.equals(OP_TXN_STAT)) {
                return targetEnv.getTransactionStats
                    (getStatsConfig(params)).toString();
            } else if (actionName.equals(OP_DB_NAMES)) {
                return targetEnv.getDatabaseNames();
            } else if (actionName.equals(OP_DB_STAT)) {
                DatabaseStats stats = getDatabaseStats(targetEnv, params);
                return stats != null ? stats.toString() : null;
            }
        }

        return new IllegalArgumentException
            ("actionName: " + actionName + " is not valid");
    } catch (Exception e) {

        /*
         * Add both the message and the exception for easiest deciphering
         * of the problem. Sometimes the original exception stacktrace gets
         * hidden in server logs.
         */
        throw new MBeanException(e, e.getMessage());
    }
}
 
开发者ID:prat0318,项目名称:dbms,代码行数:67,代码来源:JEMBeanHelper.java


注:本文中的com.sleepycat.je.Environment.sync方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。