本文整理汇总了Java中com.sleepycat.je.Environment.getDatabaseNames方法的典型用法代码示例。如果您正苦于以下问题:Java Environment.getDatabaseNames方法的具体用法?Java Environment.getDatabaseNames怎么用?Java Environment.getDatabaseNames使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sleepycat.je.Environment
的用法示例。
在下文中一共展示了Environment.getDatabaseNames方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: UpdateGroundhogScript
import com.sleepycat.je.Environment; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public UpdateGroundhogScript(File datadir) throws DatabaseException {
environmentConfig = new EnvironmentConfig();
environmentConfig.setAllowCreate(true);
environmentConfig.setTransactional(true);
environmentConfig.setCacheSize(302400000);
// perform other environment configurations
environment = new Environment(datadir, environmentConfig);
List<String> names = environment.getDatabaseNames();
if (names.contains(datadir.getName())) {
environment.renameDatabase(null, datadir.getName(), databaseName);
}
environment.close();
}
示例2: assertDbExists
import com.sleepycat.je.Environment; //导入方法依赖的package包/类
/**
* Asserts than a database expectExists or does not exist. If keyName is
* null, checks an entity database. If keyName is non-null, checks a
* secondary database.
*/
static void assertDbExists(boolean expectExists,
Environment env,
String storeName,
String entityClassName,
String keyName) {
String dbName = "persist#" + storeName + '#' + entityClassName;
if (keyName != null) {
dbName += "#" + keyName;
}
List allDbNames;
try {
allDbNames = env.getDatabaseNames();
} catch (DatabaseException e) {
throw new RuntimeException(e);
}
if (expectExists != allDbNames.contains(dbName)) {
TestCase.fail
((expectExists ? "Does not exist: " : "Does exist: ") +
dbName);
}
}
示例3: UpdataIntegerSetStoreScript
import com.sleepycat.je.Environment; //导入方法依赖的package包/类
public UpdataIntegerSetStoreScript(File datadir) throws DatabaseException {
environmentConfig = new EnvironmentConfig();
environmentConfig.setAllowCreate(true);
environmentConfig.setTransactional(true);
environmentConfig.setCacheSize(302400000);
// perform other environment configurations
environment = new Environment(datadir, environmentConfig);
List<String> names = environment.getDatabaseNames();
if (names.contains(datadir.getName())) {
environment.renameDatabase(null, datadir.getName(), databaseName);
}
environment.close();
}
示例4: getStoreNames
import com.sleepycat.je.Environment; //导入方法依赖的package包/类
public static Set<String> getStoreNames(Environment env)
throws DatabaseException {
Set<String> set = new HashSet<String>();
for (Object o : env.getDatabaseNames()) {
String s = (String) o;
if (s.startsWith(NAME_PREFIX)) {
int start = NAME_PREFIX.length();
int end = s.indexOf(NAME_SEPARATOR, start);
set.add(s.substring(start, end));
}
}
return set;
}
示例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());
}
}
示例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));
} 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());
}
}
示例7: CrawlController
import com.sleepycat.je.Environment; //导入方法依赖的package包/类
public CrawlController(CrawlConfig config, PageFetcher pageFetcher, RobotsTxtServer robotstxtServer)
throws Exception {
super(config);
config.validate();
File folder = new File(config.crawlStorageFolder());
if (!folder.exists()) {
if (!folder.mkdirs()) {
throw new Exception("Couldn't create this folder: " + folder.getAbsolutePath());
}
}
boolean resumable = config.resumableCrawling();
EnvironmentConfig envConfig = new EnvironmentConfig();
envConfig.setAllowCreate(true);
envConfig.setTransactional(resumable);
envConfig.setLocking(resumable);
File envHome = new File(config.crawlStorageFolder() + "/frontier");
if (!envHome.exists()) {
if (!envHome.mkdir()) {
throw new Exception("Couldn't create this folder: " + envHome.getAbsolutePath());
}
}
Environment env = new Environment(envHome, envConfig);
if (!resumable) {
List<String> names = env.getDatabaseNames();
for (String name : names) {
long count = env.truncateDatabase(null, name, true);
logger.info(count + " items deleted from database " + name);
}
//env.removeDatabase(null, "DocIDs");
//IO.deleteFolderContents(envHome);
}
docIdServer = new DocIDServer(env, config);
frontier = new Frontier(env, config, docIdServer);
this.pageFetcher = pageFetcher;
this.robotstxtServer = robotstxtServer;
finished = false;
shuttingDown = false;
}
示例8: 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());
}
}
示例9: diff
import com.sleepycat.je.Environment; //导入方法依赖的package包/类
/**
* A mechanism for efficiently comparing two quiescent environments, one
* local and one on a remote machine.
*
* @param env a valid, open Environment handle
* @param addr the address of the remote machine
* @return true if all the databases in both environments are the same
* @throws IOException if a network error occurs
* @throws ProtocolException if an unexpected message is received
* @throws ServiceConnectFailedException if the remote service was busy
* @throws Exception
*/
public boolean diff(Environment env, InetSocketAddress addr)
throws IOException,
ProtocolException,
ServiceConnectFailedException,
Exception {
List<String> envNames = env.getDatabaseNames();
boolean ret = true;
SocketChannel channel = connect(addr);
final Protocol protocol = new Protocol(
new NameIdPair("Ldiff", -1),
DbInternal.getEnvironmentImpl(env));
protocol.write(protocol.new EnvDiff(), channel);
/*
* Check that the number of local databases matches the number of
* remote databases. This is how we detect a remote db that doesn't
* exist locally.
*/
Protocol.EnvInfo msg = protocol.read(channel, Protocol.EnvInfo.class);
ret = (envNames.size() == msg.getNumberOfDBs());
if (!ret) {
output("Number of databases in local and remote environments " +
"does not match.");
}
channel.close();
/*
* Run LDiff for every database in the local environment. If they all
* succeed, the environments match.
*/
for (String dbName : envNames) {
channel = connect(addr);
DatabaseConfig dbConfig = new DatabaseConfig();
dbConfig.setReadOnly(true);
DbInternal.setUseExistingConfig(dbConfig, true);
Database db;
try {
db = env.openDatabase(null, dbName, dbConfig);
} catch (DatabaseNotFoundException e) {
/* Should never happen, ExclusiveCreate is false. */
throw EnvironmentFailureException.unexpectedException(e);
}
try {
if (!diff(db, channel)) {
ret = false;
}
} catch (ProtocolException pe) {
output(dbName + " does not exist in remote environment.");
ret = false;
} finally {
db.close();
if (channel.isOpen()) {
channel.close();
}
}
}
if (ret) {
output("Local environment matches remote.");
} else {
output("Local environment does not match remote.");
}
return ret;
}