Search in sources :

Example 1 with NoteCollection

use of lotus.domino.NoteCollection in project org.openntf.xsp.jakartaee by OpenNTF.

the class PassingHealthCheck method call.

@Override
public HealthCheckResponse call() {
    HealthCheckResponseBuilder response = HealthCheckResponse.named("I am the liveliness check");
    try {
        Database database = NotesContext.getCurrent().getCurrentDatabase();
        NoteCollection notes = database.createNoteCollection(true);
        notes.buildCollection();
        return response.status(true).withData("noteCount", notes.getCount()).build();
    } catch (NotesException e) {
        return response.status(false).withData("exception", e.text).build();
    }
}
Also used : NotesException(lotus.domino.NotesException) HealthCheckResponseBuilder(org.eclipse.microprofile.health.HealthCheckResponseBuilder) NoteCollection(lotus.domino.NoteCollection) Database(lotus.domino.Database)

Example 2 with NoteCollection

use of lotus.domino.NoteCollection in project org.openntf.domino by OpenNTF.

the class NotesRunner method run4.

public void run4(final Session session) throws NotesException {
    Database db = session.getDatabase("", "events4.nsf");
    NoteCollection cacheNC = db.createNoteCollection(false);
    cacheNC.setSelectDocuments(true);
    cacheNC.buildCollection();
    cacheNC.recycle();
    DocumentCollection cacheDc = db.getAllDocuments();
    Document cacheDoc = cacheDc.getFirstDocument();
    cacheDoc.recycle();
    cacheDc.recycle();
    db.recycle();
    db = session.getDatabase("", "events4.nsf");
    DocumentCollection dc = db.getAllDocuments();
    Document doc = dc.getFirstDocument();
    Document nextDoc = null;
    int dcCount = dc.getCount();
    int j = 0;
    String[] dcUnids = new String[dcCount];
    long dcStart = System.nanoTime();
    while (doc != null) {
        nextDoc = dc.getNextDocument(doc);
        dcUnids[j++] = doc.getUniversalID();
        doc.recycle();
        doc = nextDoc;
    }
    System.out.println("DocumentCollection strategy got UNIDs for " + dcCount + " docs in " + (System.nanoTime() - dcStart) / 1000 + "us");
    dc.recycle();
    db.recycle();
    db = session.getDatabase("", "events4.nsf");
    NoteCollection nc3 = db.createNoteCollection(false);
    nc3.setSelectDocuments(true);
    nc3.buildCollection();
    int nc3Count = nc3.getCount();
    String[] nc3Unids = new String[nc3Count];
    int[] nids = nc3.getNoteIDs();
    int k = 0;
    long nc3Start = System.nanoTime();
    for (int id : nids) {
        nc3Unids[k++] = nc3.getUNID(Integer.toHexString(id));
    }
    System.out.println("NoteCollection strategy ints got UNIDs for " + nc3Count + " notes in " + (System.nanoTime() - nc3Start) / 1000 + "us");
    nc3.recycle();
    db.recycle();
    db = session.getDatabase("", "events4.nsf");
    NoteCollection nc = db.createNoteCollection(false);
    nc.setSelectDocuments(true);
    nc.buildCollection();
    int ncCount = nc.getCount();
    String[] ncUnids = new String[ncCount];
    String nid = nc.getFirstNoteID();
    long ncStart = System.nanoTime();
    for (int i = 0; i < ncCount; i++) {
        ncUnids[i] = nc.getUNID(nid);
        nid = nc.getNextNoteID(nid);
    }
    System.out.println("NoteCollection strategy first/next got UNIDs for " + ncCount + " notes in " + (System.nanoTime() - ncStart) / 1000 + "us");
    nc.recycle();
    db.recycle();
    db = session.getDatabase("", "events4.nsf");
    NoteCollection nc2 = db.createNoteCollection(false);
    nc2.setSelectDocuments(true);
    nc2.buildCollection();
    int nc2Count = nc2.getCount();
    String[] nc2Unids = new String[nc2Count];
    nid = nc2.getFirstNoteID();
    long nc2Start = System.nanoTime();
    for (int i = 0; i < nc2Count; i++) {
        Document nc2doc = db.getDocumentByID(nid);
        nc2Unids[i] = nc2doc.getUniversalID();
        nc2doc.recycle();
        nid = nc2.getNextNoteID(nid);
    }
    System.out.println("NoteCollection strategy doc got UNIDs for " + nc2Count + " notes in " + (System.nanoTime() - nc2Start) / 1000 + "us");
    nc2.recycle();
    db.recycle();
}
Also used : NoteCollection(lotus.domino.NoteCollection) Database(lotus.domino.Database) DocumentCollection(lotus.domino.DocumentCollection) Document(lotus.domino.Document)

Example 3 with NoteCollection

use of lotus.domino.NoteCollection in project org.openntf.domino by OpenNTF.

the class LegacyCollectionPerfTest method run.

@Override
public void run() {
    try {
        System.out.println("Starting NotesRunner");
        Session session = NotesFactory.createSession();
        Long sessId = getLotusId(session);
        sessionid.set(sessId);
        Database db = session.getDatabase("", "events4.nsf");
        System.out.println("Db id:" + getLotusId(db));
        try {
            lotus.domino.Document doc = null;
            lotus.domino.Document nextDoc = null;
            lotus.domino.DocumentCollection allDocs = db.getAllDocuments();
            System.out.println("All Collection has " + allDocs.getCount() + " documents");
            int[] nids = new int[allDocs.getCount()];
            long walkStartTime = System.nanoTime();
            doc = allDocs.getFirstDocument();
            int i = 0;
            while (doc != null) {
                nextDoc = allDocs.getNextDocument(doc);
                nids[i++] = Integer.valueOf(doc.getNoteID(), 16);
                doc.recycle();
                doc = nextDoc;
            }
            long walkEndTime = System.nanoTime();
            System.out.println("DOCWALK: noteid array has " + allDocs.getCount() + " entries in " + (walkEndTime - walkStartTime) / 1000 + "us");
            long ncStartTime = System.nanoTime();
            NoteCollection nc = db.createNoteCollection(false);
            nc.add(allDocs);
            nids = nc.getNoteIDs();
            long ncBuildTime = System.nanoTime();
            System.out.println("NOTECOLL: noteid array has " + nids.length + " entries in " + (ncBuildTime - ncStartTime) / 1000 + "us");
            // for (int j = 0; j < nids.length; j++) {
            // doc = db.getDocumentByID(Integer.toString(nids[j], 16));
            // }
            // long ncWalkTime = System.nanoTime();
            // System.out.println("NOTECOLL: noteid array walked " + nids.length + " entries in " + (ncWalkTime - ncBuildTime) / 1000
            // + "us");
            long mergeStartTime = System.nanoTime();
            DocumentCollection mergeColl = db.search("@False", db.getLastModified(), 1);
            for (int j = 0; j < nids.length; j++) {
                mergeColl.merge(nids[j]);
            }
            long mergeBuildTime = System.nanoTime();
            System.out.println("MERGECOLL: mergeColl has " + mergeColl.getCount() + " entries in " + (mergeBuildTime - mergeStartTime) / 1000 + "us");
            doc = mergeColl.getFirstDocument();
            while (doc != null) {
                nextDoc = mergeColl.getNextDocument(doc);
                int n = Integer.valueOf(doc.getNoteID(), 16);
                doc.recycle();
                doc = nextDoc;
            }
            long mergeWalkTime = System.nanoTime();
            System.out.println("MERGECOLL: mergeColl walked " + mergeColl.getCount() + " entries in " + (mergeWalkTime - mergeBuildTime) / 1000 + "us");
            System.out.println("MERGECOLL: mergeColl total time " + mergeColl.getCount() + " entries in " + (mergeWalkTime - ncStartTime) / 1000 + "us");
            walkStartTime = System.nanoTime();
            doc = allDocs.getFirstDocument();
            i = 0;
            while (doc != null) {
                nextDoc = allDocs.getNextDocument(doc);
                nids[i++] = Integer.valueOf(doc.getNoteID(), 16);
                doc.recycle();
                doc = nextDoc;
            }
            walkEndTime = System.nanoTime();
            System.out.println("DOCWALK: noteid array has " + allDocs.getCount() + " entries in " + (walkEndTime - walkStartTime) / 1000 + "us");
            ncStartTime = System.nanoTime();
            nc = db.createNoteCollection(false);
            nc.add(allDocs);
            nids = nc.getNoteIDs();
            ncBuildTime = System.nanoTime();
            System.out.println("NOTECOLL: noteid array has " + nids.length + " entries in " + (ncBuildTime - ncStartTime) / 1000 + "us");
            // for (int j = 0; j < nids.length; j++) {
            // doc = db.getDocumentByID(Integer.toString(nids[j], 16));
            // }
            // long ncWalkTime = System.nanoTime();
            // System.out.println("NOTECOLL: noteid array walked " + nids.length + " entries in " + (ncWalkTime - ncBuildTime) / 1000
            // + "us");
            mergeStartTime = System.nanoTime();
            mergeColl = db.search("@False", db.getLastModified(), 1);
            for (int j = 0; j < nids.length; j++) {
                mergeColl.merge(nids[j]);
            }
            mergeBuildTime = System.nanoTime();
            System.out.println("MERGECOLL: mergeColl has " + mergeColl.getCount() + " entries in " + (mergeBuildTime - mergeStartTime) / 1000 + "us");
            doc = mergeColl.getFirstDocument();
            while (doc != null) {
                nextDoc = mergeColl.getNextDocument(doc);
                int n = Integer.valueOf(doc.getNoteID(), 16);
                doc.recycle();
                doc = nextDoc;
            }
            mergeWalkTime = System.nanoTime();
            System.out.println("MERGECOLL: mergeColl walked " + mergeColl.getCount() + " entries in " + (mergeWalkTime - mergeBuildTime) / 1000 + "us");
            System.out.println("MERGECOLL: mergeColl total time " + mergeColl.getCount() + " entries in " + (mergeWalkTime - ncStartTime) / 1000 + "us");
            nc.recycle();
            allDocs.recycle();
            mergeColl.recycle();
        } catch (Throwable t) {
            t.printStackTrace();
        }
        session.recycle();
    } catch (Throwable t) {
        t.printStackTrace();
    }
    System.out.println("FINI!");
}
Also used : DocumentCollection(lotus.domino.DocumentCollection) NoteCollection(lotus.domino.NoteCollection) Database(lotus.domino.Database) DocumentCollection(lotus.domino.DocumentCollection) Session(lotus.domino.Session)

Example 4 with NoteCollection

use of lotus.domino.NoteCollection in project org.openntf.xsp.jakartaee by OpenNTF.

the class AbstractOpenAPIResource method getVersionNumber.

private static String getVersionNumber(Database database) throws NotesException {
    NoteCollection noteCollection = database.createNoteCollection(true);
    noteCollection.setSelectSharedFields(true);
    noteCollection.setSelectionFormula("$TITLE=\"$TemplateBuild\"");
    noteCollection.buildCollection();
    String noteID = noteCollection.getFirstNoteID();
    Document designDoc = database.getDocumentByID(noteID);
    if (null != designDoc) {
        String buildVersion = designDoc.getItemValueString("$TemplateBuild");
        Date buildDate = ((DateTime) designDoc.getItemValueDateTimeArray("$TemplateBuildDate").get(0)).toJavaDate();
        String buildDateFormatted = DateFormat.getDateTimeInstance(DateFormat.DEFAULT, DateFormat.DEFAULT).format(buildDate);
        return buildVersion + " (" + buildDateFormatted + ")";
    }
    return "";
}
Also used : NoteCollection(lotus.domino.NoteCollection) Document(lotus.domino.Document) Date(java.util.Date) DateTime(lotus.domino.DateTime)

Example 5 with NoteCollection

use of lotus.domino.NoteCollection in project org.openntf.domino by OpenNTF.

the class NotesRunner method run3.

public void run3(final Session session) throws NotesException {
    Database db = session.getDatabase("", "index.ntf");
    NoteCollection nc = db.createNoteCollection(false);
    nc.setSelectIcon(true);
    nc.setSelectAcl(true);
    nc.selectAllDesignElements(true);
    nc.buildCollection();
    DxlExporter export = session.createDxlExporter();
    export.setForceNoteFormat(true);
    export.setRichTextOption(DxlExporter.DXLRICHTEXTOPTION_RAW);
    String dxl = export.exportDxl(nc);
    nc.recycle();
    export.recycle();
    db.recycle();
    try {
        PrintWriter out = new PrintWriter("c:\\data\\index.dxl");
        out.println(dxl);
        out.close();
    } catch (Throwable t) {
        t.printStackTrace();
    }
}
Also used : DxlExporter(lotus.domino.DxlExporter) NoteCollection(lotus.domino.NoteCollection) Database(lotus.domino.Database) PrintWriter(java.io.PrintWriter)

Aggregations

NoteCollection (lotus.domino.NoteCollection)6 Database (lotus.domino.Database)5 Document (lotus.domino.Document)3 DocumentCollection (lotus.domino.DocumentCollection)2 NotesException (lotus.domino.NotesException)2 Session (lotus.domino.Session)2 PrintWriter (java.io.PrintWriter)1 Date (java.util.Date)1 DateTime (lotus.domino.DateTime)1 DxlExporter (lotus.domino.DxlExporter)1 IStatus (org.eclipse.core.runtime.IStatus)1 Status (org.eclipse.core.runtime.Status)1 HealthCheckResponseBuilder (org.eclipse.microprofile.health.HealthCheckResponseBuilder)1