Search in sources :

Example 1 with DbDirectory

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;
}
Also used : DbDirectory(org.openntf.domino.DbDirectory) Database(org.openntf.domino.Database)

Example 2 with DbDirectory

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");
}
Also used : DbDirectory(org.openntf.domino.DbDirectory) OpenNTFNotesException(org.openntf.domino.exceptions.OpenNTFNotesException) Database(org.openntf.domino.Database) Session(org.openntf.domino.Session)

Example 3 with DbDirectory

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);
    }
}
Also used : DbDirectory(org.openntf.domino.DbDirectory) Database(org.openntf.domino.Database)

Example 4 with DbDirectory

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");
}
Also used : DbDirectory(org.openntf.domino.DbDirectory) IndexDatabase(org.openntf.domino.big.IndexDatabase) Database(org.openntf.domino.Database) IndexDatabase(org.openntf.domino.big.IndexDatabase) Session(org.openntf.domino.Session)

Example 5 with DbDirectory

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");
}
Also used : DbDirectory(org.openntf.domino.DbDirectory) Database(org.openntf.domino.Database) Document(org.openntf.domino.Document) Session(org.openntf.domino.Session) Test(org.junit.Test)

Aggregations

DbDirectory (org.openntf.domino.DbDirectory)19 Database (org.openntf.domino.Database)17 Session (org.openntf.domino.Session)11 FileNotFoundException (java.io.FileNotFoundException)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Future (java.util.concurrent.Future)1 Test (org.junit.Test)1 ACL (org.openntf.domino.ACL)1 Document (org.openntf.domino.Document)1 View (org.openntf.domino.View)1 IndexDatabase (org.openntf.domino.big.IndexDatabase)1 AboutDocument (org.openntf.domino.design.AboutDocument)1 OpenNTFNotesException (org.openntf.domino.exceptions.OpenNTFNotesException)1 UserAccessException (org.openntf.domino.exceptions.UserAccessException)1 ScheduleData (org.openntf.domino.xots.ScheduleData)1