本文整理汇总了Java中com.sleepycat.je.Environment.getConfig方法的典型用法代码示例。如果您正苦于以下问题:Java Environment.getConfig方法的具体用法?Java Environment.getConfig怎么用?Java Environment.getConfig使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sleepycat.je.Environment
的用法示例。
在下文中一共展示了Environment.getConfig方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: CurrentTransaction
import com.sleepycat.je.Environment; //导入方法依赖的package包/类
private CurrentTransaction(Environment env) {
this.env = env;
try {
EnvironmentConfig config = env.getConfig();
txnMode = config.getTransactional();
lockingMode = DbCompat.getInitializeLocking(config);
if (txnMode || lockingMode) {
writeLockMode = LockMode.RMW;
} else {
writeLockMode = LockMode.DEFAULT;
}
cdbMode = DbCompat.getInitializeCDB(config);
if (cdbMode) {
localCdbCursors = new ThreadLocal();
}
} catch (DatabaseException e) {
throw new RuntimeExceptionWrapper(e);
}
}
示例2: checkAttribute
import com.sleepycat.je.Environment; //导入方法依赖的package包/类
private void checkAttribute(Environment env,
DynamicMBean mbean,
Method configMethod,
String attributeName,
Object newValue)
throws Exception {
/* check starting value. */
EnvironmentConfig config = env.getConfig();
Object result = configMethod.invoke(config, (Object []) null);
assertTrue(!result.toString().equals(newValue.toString()));
/* set through mbean */
mbean.setAttribute(new Attribute(attributeName, newValue));
/* check present environment config. */
config = env.getConfig();
assertEquals(newValue.toString(),
configMethod.invoke(config, (Object []) null).toString());
/* check through mbean. */
Object mbeanNewValue = mbean.getAttribute(attributeName);
assertEquals(newValue.toString(), mbeanNewValue.toString());
}
示例3: CurrentTransaction
import com.sleepycat.je.Environment; //导入方法依赖的package包/类
private CurrentTransaction(Environment env) {
envRef = new WeakReference<Environment>(env);
try {
EnvironmentConfig config = env.getConfig();
txnMode = config.getTransactional();
lockingMode = DbCompat.getInitializeLocking(config);
if (txnMode || lockingMode) {
writeLockMode = LockMode.RMW;
} else {
writeLockMode = LockMode.DEFAULT;
}
cdbMode = DbCompat.getInitializeCDB(config);
if (cdbMode) {
localCdbCursors = new ThreadLocal();
}
} catch (DatabaseException e) {
throw RuntimeExceptionWrapper.wrapIfNeeded(e);
}
}
示例4: checkAttribute
import com.sleepycat.je.Environment; //导入方法依赖的package包/类
private void checkAttribute(Environment env,
DynamicMBean mbean,
Method configMethod,
String attributeName,
Object newValue)
throws Exception {
/* check starting value. */
EnvironmentConfig config = env.getConfig();
Object result = configMethod.invoke(config, (Object []) null);
assertTrue(!result.toString().equals(newValue.toString()));
/* set through mbean */
mbean.setAttribute(new Attribute(attributeName, newValue));
/* check present environment config. */
config = env.getConfig();
assertEquals(newValue.toString(),
configMethod.invoke(config, (Object []) null).toString());
/* check through mbean. */
Object mbeanNewValue = mbean.getAttribute(attributeName);
assertEquals(newValue.toString(), mbeanNewValue.toString());
}
示例5: getOperationList
import com.sleepycat.je.Environment; //导入方法依赖的package包/类
/**
* Get mbean operation metadata for this environment.
*
* @param targetEnv The target JE environment. May be null if the
* environment is not open.
* @return List of MBeanOperationInfo describing available operations.
*/
public List getOperationList(Environment targetEnv) {
setNeedReset(false);
List operationList = new ArrayList();
if (targetEnv != null) {
/*
* These operations are only available if the environment is
* open.
*/
operationList.add(OP_CLEAN_INFO);
operationList.add(OP_EVICT_INFO);
operationList.add(OP_ENV_STAT_INFO);
operationList.add(OP_LOCK_STAT_INFO);
operationList.add(OP_DB_NAMES_INFO);
operationList.add(OP_DB_STAT_INFO);
/* Add checkpoint only for transactional environments. */
boolean isTransactional = false;
try {
EnvironmentConfig config = targetEnv.getConfig();
isTransactional = config.getTransactional();
} catch (DatabaseException e) {
/* Don't make any operations available. */
return new ArrayList();
}
if (isTransactional) {
operationList.add(OP_CHECKPOINT_INFO);
operationList.add(OP_TXN_STAT_INFO);
} else {
operationList.add(OP_SYNC_INFO);
}
}
return operationList;
}
示例6: setUp
import com.sleepycat.je.Environment; //导入方法依赖的package包/类
public void setUp()
throws IOException, DatabaseException {
TestUtils.removeFiles("Setup", envHome, FileManager.JE_SUFFIX);
EnvironmentConfig envConfig = TestUtils.initEnvConfig();
DbInternal.setLoadPropertyFile(envConfig, false);
envConfig.setConfigParam(EnvironmentParams.NODE_MAX.getName(), "6");
envConfig.setConfigParam
(EnvironmentParams.ENV_RUN_INCOMPRESSOR.getName(), "false");
envConfig.setConfigParam
(EnvironmentParams.ENV_RUN_EVICTOR.getName(), "false");
envConfig.setConfigParam
(EnvironmentParams.ENV_RUN_CHECKPOINTER.getName(), "false");
envConfig.setConfigParam
(EnvironmentParams.ENV_RUN_CLEANER.getName(), "false");
envConfig.setAllowCreate(true);
env = new Environment(envHome, envConfig);
EnvironmentConfig envConfigAsSet = env.getConfig();
noLocking = !(envConfigAsSet.getLocking());
DatabaseConfig dbConfig = new DatabaseConfig();
dbConfig.setAllowCreate(true);
dbConfig.setSortedDuplicates(true);
myDb = env.openDatabase(null, "test", dbConfig);
}
示例7: testRemoveNonPersistentDbSR15317
import com.sleepycat.je.Environment; //导入方法依赖的package包/类
/**
* Check that all INs are removed from the INList for a DB that is removed
* before it is sync'ed (or checkpointed). Before the bug fix, INs were
* not removed if the DB root IN was never logged (was still null). This
* caused a DatabaseException when evicting, because the evictor expects no
* INs for deleted DBs on the INList.
*/
public void testRemoveNonPersistentDbSR15317()
throws Throwable {
Database db = null;
try {
EnvironmentConfig envConfig = getEnvConfig(true);
/* Disable compressor for test predictability. */
envConfig.setConfigParam("je.env.runINCompressor", "false");
env = new Environment(envHome, envConfig);
db = createDb(true);
/* Insert some data to cause eviction later. */
insert(db,
null, // txn
1, // start
30000, // end
new HashSet(), // expected
false); // useRandom
db.close();
env.removeDatabase(null, DBNAME);
envConfig = env.getConfig();
/* Switch to a small cache to force eviction. */
envConfig.setCacheSize(96 * 1024);
env.setMutableConfig(envConfig);
for (int i = 0; i < 10; i += 1) {
env.evictMemory();
}
} finally {
if (env != null) {
try {
env.close();
} catch (Throwable e) {
System.out.println("Ignored: " + e);
}
env = null;
}
}
}
示例8: getOperationList
import com.sleepycat.je.Environment; //导入方法依赖的package包/类
/**
* Get mbean operation metadata for this environment.
*
* @param targetEnv The target JE environment. May be null if the
* environment is not open.
* @return List of MBeanOperationInfo describing available operations.
*/
public List<MBeanOperationInfo> getOperationList(Environment targetEnv) {
setNeedReset(false);
List<MBeanOperationInfo> operationList =
new ArrayList<MBeanOperationInfo>();
if (targetEnv != null) {
/*
* These operations are only available if the environment is open.
*/
operationList.add(OP_CLEAN_INFO);
operationList.add(OP_EVICT_INFO);
operationList.add(OP_ENV_STAT_INFO);
operationList.add(OP_DB_NAMES_INFO);
operationList.add(OP_DB_STAT_INFO);
/* Add checkpoint only for transactional environments. */
boolean isTransactional = false;
try {
EnvironmentConfig config = targetEnv.getConfig();
isTransactional = config.getTransactional();
} catch (DatabaseException e) {
/* Don't make any operations available. */
return new ArrayList<MBeanOperationInfo>();
}
if (isTransactional) {
operationList.add(OP_CHECKPOINT_INFO);
operationList.add(OP_TXN_STAT_INFO);
} else {
operationList.add(OP_SYNC_INFO);
}
}
return operationList;
}
示例9: getAttributeList
import com.sleepycat.je.Environment; //导入方法依赖的package包/类
/**
* Get MBean attribute metadata for this environment.
* @param targetEnv The target JE environment. May be null if the
* environment is not open.
* @return list of MBeanAttributeInfo objects describing the available
* attributes.
*/
public List getAttributeList(Environment targetEnv) {
/* Turn off reset because the mbean metadata is being refreshed. */
setNeedReset(false);
ArrayList attrList = new ArrayList();
/* Add attributes for all JE environments. */
for (int i = 0; i < COMMON_ATTR.length; i++) {
attrList.add(COMMON_ATTR[i]);
}
if (targetEnv == null) {
if (canConfigure) {
/* Add attributes for configuring an environment. */
for (int i = 0; i < CREATE_ATTR.length; i++) {
attrList.add(CREATE_ATTR[i]);
}
}
} else {
/* Add attributes for an open environment. */
for (int i = 0; i < OPEN_ATTR.length; i++) {
attrList.add(OPEN_ATTR[i]);
}
/* Add attributes for an open, transactional environment. */
try {
EnvironmentConfig config = targetEnv.getConfig();
if (config.getTransactional()) {
for (int i = 0; i < TRANSACTIONAL_ATTR.length; i++) {
attrList.add(TRANSACTIONAL_ATTR[i]);
}
}
} catch (DatabaseException ignore) {
/* ignore */
}
}
return attrList;
}
示例10: getAttribute
import com.sleepycat.je.Environment; //导入方法依赖的package包/类
/**
* Get an attribute value for the given environment. Check
* JEMBeanHelper.getNeedReset() after this call because the helper may
* detect that the environment has changed and that the MBean metadata
* should be reset.
*
* @param targetEnv The target JE environment. May be null if the
* environment is not open.
* @param attributeName attribute name.
* @return attribute value.
*/
public Object getAttribute(Environment targetEnv,
String attributeName)
throws AttributeNotFoundException,
MBeanException {
/* Sanity check. */
if (attributeName == null) {
throw new AttributeNotFoundException(
"Attribute name cannot be null");
}
/* These attributes are available regardless of environment state. */
try {
if (attributeName.equals(ATT_ENV_HOME)) {
return environmentHome.getCanonicalPath();
} else if (attributeName.equals(ATT_OPEN)) {
boolean envIsOpen = (targetEnv != null);
resetIfOpenStateChanged(envIsOpen);
return new Boolean(envIsOpen);
} else if (attributeName.equals(ATT_SET_READ_ONLY)) {
return new Boolean(openConfig.getReadOnly());
} else if (attributeName.equals(ATT_SET_TRANSACTIONAL)) {
return new Boolean(openConfig.getTransactional());
} else if (attributeName.equals(ATT_SET_SERIALIZABLE)) {
return new Boolean(openConfig.getTxnSerializableIsolation());
} else {
/* The rest are JE environment attributes. */
if (targetEnv != null) {
EnvironmentConfig config = targetEnv.getConfig();
if (attributeName.equals(ATT_IS_READ_ONLY)) {
return new Boolean(config.getReadOnly());
} else if (attributeName.equals(ATT_IS_TRANSACTIONAL)) {
return new Boolean(config.getTransactional());
} else if (attributeName.equals(ATT_CACHE_SIZE)) {
return new Long(config.getCacheSize());
} else if (attributeName.equals(ATT_CACHE_PERCENT)) {
return new Integer(config.getCachePercent());
} else if (attributeName.equals(ATT_LOCK_TIMEOUT)) {
return new Long(config.getLockTimeout());
} else if (attributeName.equals(ATT_IS_SERIALIZABLE)) {
return new
Boolean(config.getTxnSerializableIsolation());
} else if (attributeName.equals(ATT_TXN_TIMEOUT)) {
return new Long(config.getTxnTimeout());
} else {
throw new AttributeNotFoundException("attribute " +
attributeName +
" is not valid.");
}
}
return null;
}
} 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());
}
}
示例11: openEnv
import com.sleepycat.je.Environment; //导入方法依赖的package包/类
/**
* Opens the environment.
*/
private void openEnv(boolean transactional)
throws DatabaseException {
EnvironmentConfig config = TestUtils.initEnvConfig();
config.setTransactional(transactional);
config.setAllowCreate(true);
/* Do not run the daemons since they interfere with LN counting. */
config.setConfigParam
(EnvironmentParams.ENV_RUN_CLEANER.getName(), "false");
config.setConfigParam
(EnvironmentParams.ENV_RUN_EVICTOR.getName(), "false");
config.setConfigParam
(EnvironmentParams.ENV_RUN_CHECKPOINTER.getName(), "false");
config.setConfigParam
(EnvironmentParams.ENV_RUN_INCOMPRESSOR.getName(), "false");
/* Use small nodes to test the post-txn scanning. */
config.setConfigParam
(EnvironmentParams.NODE_MAX.getName(), "10");
config.setConfigParam
(EnvironmentParams.NODE_MAX_DUPTREE.getName(), "10");
/* Use small files to ensure that there is cleaning. */
config.setConfigParam("je.cleaner.minUtilization", "90");
DbInternal.disableParameterValidation(config);
config.setConfigParam("je.log.fileMax", "4000");
/* Obsolete LN size counting is optional per test. */
if (fetchObsoleteSize) {
config.setConfigParam
(EnvironmentParams.CLEANER_FETCH_OBSOLETE_SIZE.getName(),
"true");
}
env = new Environment(envHome, config);
config = env.getConfig();
dbEviction = config.getConfigParam
(EnvironmentParams.ENV_DB_EVICTION.getName()).equals("true");
}
示例12: testCleanerStop
import com.sleepycat.je.Environment; //导入方法依赖的package包/类
/**
* Tests that setting je.env.runCleaner=false stops the cleaner from
* processing more files even if the target minUtilization is not met
* [#15158].
*/
public void testCleanerStop()
throws Throwable {
final int fileSize = 1000000;
EnvironmentConfig envConfig = TestUtils.initEnvConfig();
envConfig.setAllowCreate(true);
envConfig.setConfigParam
(EnvironmentParams.ENV_RUN_CLEANER.getName(), "false");
envConfig.setConfigParam
(EnvironmentParams.LOG_FILE_MAX.getName(),
Integer.toString(fileSize));
envConfig.setConfigParam
(EnvironmentParams.CLEANER_MIN_UTILIZATION.getName(), "80");
Environment env = new Environment(envHome, envConfig);
DatabaseConfig dbConfig = new DatabaseConfig();
dbConfig.setAllowCreate(true);
Database db = env.openDatabase(null, "CleanerStop", dbConfig);
DatabaseEntry key = new DatabaseEntry(new byte[1]);
DatabaseEntry data = new DatabaseEntry(new byte[fileSize]);
for (int i = 0; i <= 10; i += 1) {
db.put(null, key, data);
}
env.checkpoint(forceConfig);
EnvironmentStats stats = env.getStats(null);
assertEquals(0, stats.getNCleanerRuns());
envConfig = env.getConfig();
envConfig.setConfigParam
(EnvironmentParams.ENV_RUN_CLEANER.getName(), "true");
env.setMutableConfig(envConfig);
int iter = 0;
while (stats.getNCleanerRuns() == 0) {
iter += 1;
if (iter == 20) {
fail("Cleaner did not run after " + iter + " tries");
}
Thread.yield();
Thread.sleep(1);
stats = env.getStats(null);
}
envConfig.setConfigParam
(EnvironmentParams.ENV_RUN_CLEANER.getName(), "false");
env.setMutableConfig(envConfig);
int prevNFiles = stats.getNCleanerRuns();
stats = env.getStats(null);
int currNFiles = stats.getNCleanerRuns();
if (currNFiles - prevNFiles > 5) {
fail("Expected less than 5 files cleaned," +
" prevNFiles=" + prevNFiles +
" currNFiles=" + currNFiles);
}
//System.out.println("Num runs: " + stats.getNCleanerRuns());
db.close();
env.close();
}
示例13: testMBeanSetters
import com.sleepycat.je.Environment; //导入方法依赖的package包/类
/**
* Exercise setters.
*/
public void testMBeanSetters()
throws Throwable {
Environment env = null;
try {
/* Mimic an application by opening an environment. */
env = openEnv(false);
/* Open an mbean and set the environment home. */
DynamicMBean mbean = new JEMonitor(environmentDir);
/*
* Try setting different attributes. Check against the
* initial value, and the value after setting.
*/
EnvironmentConfig config = env.getConfig();
Class configClass = config.getClass();
Method getCacheSize = configClass.getMethod("getCacheSize", (Class []) null);
checkAttribute(env,
mbean,
getCacheSize,
JEMBeanHelper.ATT_CACHE_SIZE,
new Long(100000)); // new value
Method getCachePercent =
configClass.getMethod("getCachePercent", (Class []) null);
checkAttribute(env,
mbean,
getCachePercent,
JEMBeanHelper.ATT_CACHE_PERCENT,
new Integer(10));
env.close();
checkForNoOpenHandles(environmentDir);
} catch (Throwable t) {
t.printStackTrace();
if (env != null) {
env.close();
}
throw t;
}
}
示例14: getAttributeList
import com.sleepycat.je.Environment; //导入方法依赖的package包/类
/**
* Get MBean attribute metadata for this environment.
* @param targetEnv The target JE environment. May be null if the
* environment is not open.
* @return list of MBeanAttributeInfo objects describing the available
* attributes.
*/
public List getAttributeList(Environment targetEnv) {
/* Turn off reset because the mbean metadata is being refreshed. */
setNeedReset(false);
ArrayList attrList = new ArrayList();
/* Add attributes for all JE environments. */
for (int i = 0; i < COMMON_ATTR.length; i++) {
attrList.add(COMMON_ATTR[i]);
}
if (targetEnv == null) {
if (canConfigure) {
/* Add attributes for configuring an environment. */
for (int i = 0; i < CREATE_ATTR.length; i++) {
attrList.add(CREATE_ATTR[i]);
}
}
} else {
/* Add attributes for an open environment. */
for (int i = 0; i < OPEN_ATTR.length; i++) {
attrList.add(OPEN_ATTR[i]);
}
/* Add attributes for an open, transactional environment. */
try {
EnvironmentConfig config = targetEnv.getConfig();
if (config.getTransactional()) {
for (int i = 0; i < TRANSACTIONAL_ATTR.length; i++) {
attrList.add(TRANSACTIONAL_ATTR[i]);
}
}
} catch (DatabaseException ignore) {
/* ignore */
}
}
return attrList;
}
示例15: getAttribute
import com.sleepycat.je.Environment; //导入方法依赖的package包/类
/**
* Get an attribute value for the given environment. Check
* JEMBeanHelper.getNeedReset() after this call because the helper may
* detect that the environment has changed and that the MBean metadata
* should be reset.
*
* @param targetEnv The target JE environment. May be null if the
* environment is not open.
* @param attributeName attribute name.
* @return attribute value.
*/
public Object getAttribute(Environment targetEnv,
String attributeName)
throws AttributeNotFoundException,
MBeanException {
/* Sanity check. */
if (attributeName == null) {
throw new AttributeNotFoundException(
"Attribute name cannot be null");
}
/* These attributes are available regardless of environment state. */
try {
if (attributeName.equals(ATT_ENV_HOME)) {
return environmentHome.getCanonicalPath();
} else if (attributeName.equals(ATT_OPEN)) {
boolean envIsOpen = (targetEnv != null);
resetIfOpenStateChanged(envIsOpen);
return new Boolean(envIsOpen);
} else if (attributeName.equals(ATT_SET_READ_ONLY)) {
return new Boolean(openConfig.getReadOnly());
} else if (attributeName.equals(ATT_SET_TRANSACTIONAL)) {
return new Boolean(openConfig.getTransactional());
} else if (attributeName.equals(ATT_SET_SERIALIZABLE)) {
return new Boolean(openConfig.getTxnSerializableIsolation());
} else {
/* The rest are JE environment attributes. */
if (targetEnv != null) {
EnvironmentConfig config = targetEnv.getConfig();
if (attributeName.equals(ATT_IS_READ_ONLY)) {
return new Boolean(config.getReadOnly());
} else if (attributeName.equals(ATT_IS_TRANSACTIONAL)) {
return new Boolean(config.getTransactional());
} else if (attributeName.equals(ATT_CACHE_SIZE)) {
return new Long(config.getCacheSize());
} else if (attributeName.equals(ATT_CACHE_PERCENT)) {
return new Integer(config.getCachePercent());
} else if (attributeName.equals(ATT_LOCK_TIMEOUT)) {
return new Long(config.getLockTimeout());
} else if (attributeName.equals(ATT_IS_SERIALIZABLE)) {
return new
Boolean(config.getTxnSerializableIsolation());
} else if (attributeName.equals(ATT_TXN_TIMEOUT)) {
return new Long(config.getTxnTimeout());
} else {
throw new AttributeNotFoundException("attribute " +
attributeName +
" is not valid.");
}
}
return null;
}
} 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());
}
}