use of org.openntf.domino.DbDirectory in project org.openntf.domino by OpenNTF.
the class DbCache method getDatabase.
public Database getDatabase(final long dbid, final String server, final Session session) {
Database result = dbMap_.get(dbid);
if (result == null) {
String replid = getReplidFromLong(dbid);
DbDirectory dir = session.getDbDirectory(server);
result = dir.openDatabaseByReplicaID(replid);
dbMap_.put(dbid, result);
}
return result;
}
use of org.openntf.domino.DbDirectory in project org.openntf.domino by OpenNTF.
the class DesignClassTest method testDesignFactory.
// @Test
public void testDesignFactory() throws IOException {
Session sess = Factory.getSession(SessionType.CURRENT);
DbDirectory dir = sess.getDbDirectory("");
for (Database db : dir) {
try {
db.open();
} catch (OpenNTFNotesException e) {
e.printStackTrace();
}
if (db.isOpen()) {
System.out.println("DB under test" + db);
testDb(db);
}
}
// Database db = sess.getDatabase("D:/Daten/notesdaten_9/localdb/proglib4work2.nsf");
// Database db = sess.getDatabase("D:/Daten/notesdaten_9/localdb/empty.ns9");
}
use of org.openntf.domino.DbDirectory in project org.openntf.domino by OpenNTF.
the class ShardingDatabase method initializeDatabases.
public void initializeDatabases() {
if (places_ > 0) {
for (int i = 0; i < pow(16, places_); i++) {
String hashChunk = Integer.toString(i, 16).toLowerCase();
while (hashChunk.length() < places_) hashChunk = "0" + hashChunk;
String server = serverStrategy_ == null ? server_ : serverStrategy_.getServerForHashChunk(hashChunk);
DbDirectory dbdir = getDbDirectoryForHashChunk(hashChunk);
String dbName = baseName_ + "-" + hashChunk + ".nsf";
Database database = session_.getDatabase(server, dbName, true);
if (!database.isOpen()) {
database = createDatabase(dbdir, dbName);
}
dbCache_.put(dbName, database);
}
} else {
Database database = session_.getDatabase(server_, baseName_ + ".nsf");
if (!database.isOpen()) {
database = createDatabase(getDbDirectoryForHashChunk(null), baseName_ + ".nsf");
}
dbCache_.put(baseName_ + ".nsf", database);
}
}
use of org.openntf.domino.DbDirectory in project org.openntf.domino by OpenNTF.
the class DominoIndexDbTest method run.
@Override
public void run() {
Session session = Factory.getSession(SessionType.CURRENT);
session.setConvertMIME(false);
session.setFixEnable(Fixes.APPEND_ITEM_VALUE, true);
session.setFixEnable(Fixes.FORCE_JAVA_DATES, true);
session.setFixEnable(Fixes.CREATE_DB, true);
DbDirectory dir = session.getDbDirectory("");
Database indexDb = dir.createDatabase("index.nsf", true);
// Database indexDb = session.getDatabase("", "index.nsf", true);
// indexDb.open();
IndexDatabase index = new org.openntf.domino.big.impl.IndexDatabase(indexDb);
index.setCaseSensitive(true);
index.scanServer(session, "");
System.out.println("Complete");
}
use of org.openntf.domino.DbDirectory in project org.openntf.domino by OpenNTF.
the class MassCopyDocumentsScratchTest method run.
@Test
public void run() {
long start = System.nanoTime();
Session s = Factory.getSession(SessionType.CURRENT);
Database source = s.getDatabase("", SOURCE, true);
Database target = s.getDatabase("", TARGET, true);
if (target != null)
target.remove();
DbDirectory dir = s.getDbDirectory("");
target = dir.createDatabase(TARGET, true);
assertEquals(0, target.getAllDocuments().size());
System.out.println("-- START --");
int i = 0;
for (Document doc : source.getAllDocuments()) {
assertNotNull(doc.copyToDatabase(target));
i++;
if (i % 5000 == 0)
System.out.println("Copied " + i + " documents of " + source.getAllDocuments().size());
}
System.out.println("-- STOP --");
assertEquals(source.getAllDocuments().size(), target.getAllDocuments().size());
long elapsed = System.nanoTime() - start;
System.out.println("Thread " + Thread.currentThread().getName() + " elapsed time: " + elapsed / 1000000 + "ms");
}
Aggregations