/** Preload all dup DBs to be converted. */ private void preloadAllDatabases() { final ArrayList<DatabaseImpl> dbsToConvert = new ArrayList<DatabaseImpl>(); try { for (DatabaseId dbId : dbTree.getDbNamesAndIds().keySet()) { final DatabaseImpl dbImpl = dbTree.getDb(dbId); boolean releaseDbImpl = true; try { if (!needsConversion(dbImpl)) { continue; } dbsToConvert.add(dbImpl); releaseDbImpl = false; } finally { if (releaseDbImpl) { dbTree.releaseDb(dbImpl); } } } if (dbsToConvert.size() == 0) { return; } final DatabaseImpl[] dbArray = new DatabaseImpl[dbsToConvert.size()]; dbsToConvert.toArray(dbArray); envImpl.preload(dbArray, preloadConfig); } finally { for (DatabaseImpl dbImpl : dbsToConvert) { dbTree.releaseDb(dbImpl); } } }
/** Converts all dup DBs that need conversion. */ public void convertDatabases() { if (DEBUG) { System.out.println("DupConvert.convertDatabases"); } if (preloadAll) { preloadAllDatabases(); } for (DatabaseId dbId : dbTree.getDbNamesAndIds().keySet()) { final DatabaseImpl dbImpl = dbTree.getDb(dbId); try { if (!needsConversion(dbImpl)) { continue; } convertDatabase(dbImpl); } finally { dbTree.releaseDb(dbImpl); } } assert noDupNodesPresent(); }
/** * Get a database object given a database name. * * @param databaseName target database. * @return null if database doesn't exist. */ public DatabaseImpl getDb(Locker locker, String databaseName, Database databaseHandle) throws DatabaseException { return dbMapTree.getDb(locker, databaseName, databaseHandle); }