public static ConceptChronicle getConcept(int cNid) throws IOException { assert cNid == Bdb.getConceptNid(cNid) : " Not a concept nid: " + cNid + " Bdb cNid:" + Bdb.getConceptNid(cNid) + " max nid: " + Bdb.getUuidsToNidMap().getCurrentMaxNid() + " (" + (Bdb.getUuidsToNidMap().getCurrentMaxNid() - cNid) + ")"; return conceptDb.getConcept(cNid); }
@Override public void run() { try { activity.setIndeterminate(false); activity.setValue(0); activity.setMaximum(9); setProperty(G_VERSION, Long.toString(gVersion.incrementAndGet())); activity.setProgressInfoLower("Writing uuidDb... "); activity.setValue(1); activity.setProgressInfoLower("Writing uuidsToNidMapDb... "); uuidsToNidMapDb.sync(); activity.setValue(2); nidCidMapDb.sync(); activity.setValue(3); activity.setProgressInfoLower("Writing statusAtPositionDb... "); stampDb.sync(); activity.setValue(4); activity.setProgressInfoLower("Writing conceptDb... "); conceptDb.sync(); activity.setValue(5); activity.setValue(6); activity.setProgressInfoLower("Writing propDb... "); propDb.sync(); activity.setProgressInfoLower("Writing mutable environment... "); activity.setValue(7); mutable.bdbEnv.sync(); activity.setProgressInfoLower("Writing readonly environment... "); activity.setValue(8); if (readOnly.bdbEnv.getConfig().getReadOnly() == false) { readOnly.bdbEnv.sync(); } activity.setValue(9); long endTime = System.currentTimeMillis(); long elapsed = endTime - startTime; String elapsedStr = TimeHelper.getElapsedTimeString(elapsed); activity.setProgressInfoUpper("Database sync complete."); activity.setProgressInfoLower("Elapsed: " + elapsedStr); activity.complete(); } catch (DatabaseException | IOException e) { AceLog.getAppLog().alertAndLogException(e); } catch (ComputationCanceled e) { // Nothing to do } }
// Close the environment public static void close() throws InterruptedException, ExecutionException { if (closed == false && mutable != null && mutable.bdbEnv != null) { closed = true; try { I_ShowActivity activity = new ConsoleActivityViewer(); activity.setStopButtonVisible(false); activity.setProgressInfoLower("1-a/11: Stopping Isa Cache generation."); FileOutputStream fos = new FileOutputStream(viewCoordinateMapFile); try (ObjectOutputStream oos = new ObjectOutputStream(fos)) { oos.writeObject(viewCoordinates); } activity.setProgressInfoLower("2/11: Starting sync using service."); assert conceptDb != null : "conceptDb is null..."; new Sync().run(); activity.setProgressInfoLower("3/11: Shutting down sync service."); syncService.shutdown(); activity.setProgressInfoLower("4/11: Awaiting termination of sync service."); syncService.awaitTermination(90, TimeUnit.MINUTES); activity.setProgressInfoLower("5/11: Starting PositionMapper close."); activity.setProgressInfoLower("6/11: Canceling uncommitted changes."); BdbCommitManager.cancel(); activity.setProgressInfoLower("7/11: Starting BdbCommitManager shutdown."); BdbCommitManager.shutdown(); activity.setProgressInfoLower("8/11: Starting LuceneManager close."); LuceneManager.close(); NidDataFromBdb.close(); activity.setProgressInfoLower("9/11: Starting mutable.bdbEnv.sync()."); mutable.bdbEnv.sync(); activity.setProgressInfoLower("10/11: mutable.bdbEnv.sync() finished."); uuidsToNidMapDb.close(); nidCidMapDb.close(); stampDb.close(); conceptDb.close(); propDb.close(); mutable.bdbEnv.sync(); mutable.bdbEnv.close(); stampCache.clear(); activity.setProgressInfoLower("11/11: Shutdown complete"); } catch (DatabaseException e) { AceLog.getAppLog().alertAndLogException(e); } catch (Exception e) { AceLog.getAppLog().alertAndLogException(e); } } if (readOnly != null && readOnly.bdbEnv != null) { readOnly.bdbEnv.close(); } annotationConcepts = null; conceptDb = null; mutable = null; nidCidMapDb = null; pathManager = null; propDb = null; readOnly = null; stampCache = null; stampDb = null; uuidsToNidMapDb = null; ConceptChronicle.reset(); AceLog.getAppLog().info("bdb close finished."); }
public static void addAsAnnotations(List<TtkRefexAbstractMemberChronicle<?>> members) throws Exception { conceptDb.iterateConceptDataInParallel(new AnnotationAdder(members)); }
public static UUID getPrimUuidForConcept(int cNid) throws IOException { assert cNid == Bdb.getConceptNid(cNid) : " Not a concept nid: " + cNid; return conceptDb.getConcept(cNid).getPrimordialUuid(); }