|
From: David F. <dwf...@us...> - 2006-09-25 03:53:08
|
Update of /cvsroot/openmed/OpenEMed/src/servers/persistent/gov/lanl/COAS In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv22810 Modified Files: ObservationMgrImpl.java Added Files: ObservationMgrImplLoader.java Log Message: Moved observation loading to a separate thread Index: ObservationMgrImpl.java =================================================================== RCS file: /cvsroot/openmed/OpenEMed/src/servers/persistent/gov/lanl/COAS/ObservationMgrImpl.java,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** ObservationMgrImpl.java 13 Sep 2006 03:47:42 -0000 1.24 --- ObservationMgrImpl.java 25 Sep 2006 03:53:03 -0000 1.25 *************** *** 1,1117 **** ! /*--- formatted by Jindent 2.1, (www.c-lab.de/~jindent) ---*/ ! ! // ObservationMgrImpl.java ! ! /** ! * *********************************** ! * Copyright Notice ! * Copyright (c) 1999, Regents of the University of California. All rights reserved. ! * ! * DISCLAIMER [...2141 lines suppressed...] ! ! persChild.update(origPersChild); ! persChild.clearComposite(); ! persObj.addComposite(persChild); ! } ! ! // inspect the subtree of origPersObj ! restoreSignedNodesRecursive(origPersChild, persChild, ht); ! } ! } ! } // end for ! } ! ! } ! ! } ! ! ! /*--- formatting done in "OpenEMed Convention" style on 10-18-2001 ---*/ ! --- NEW FILE: ObservationMgrImplLoader.java --- /*--- formatted by Jindent 2.1, (www.c-lab.de/~jindent) ---*/ // ObservationMgrImplLoader.java /** * *********************************** * Copyright Notice * Copyright (c) 2006, Richard Schilling. All rights reserved. * * DISCLAIMER * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT * SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH * DAMAGE. * ************************************ */ package gov.lanl.COAS; import gov.lanl.Utility.ConfigProperties; import gov.lanl.Utility.DomDoc2ObsData; import gov.lanl.Utility.ObsData2Dom; import gov.lanl.Utility.Xml2DomDoc; import org.apache.log4j.Logger; import org.omg.DsObservationAccess.ObservationDataStruct; import org.omg.DsObservationAccess.ObservationDataStructHelper; import java.io.FileInputStream; /** * This class is used by ObservationMgrImpl to load data into the COAS server. * * @author Richard Schilling * @version 1.0 * @since 09/20/2006 */ public class ObservationMgrImplLoader implements Runnable { // Version & Date static final String version = "$Revision: 1.1 $"; // static final String shortVersion = "1.00"; // static String name = "gov.lanl.ObservationManager.ObservationMgr"; // static final String shortVersion = "1.00"; static final String date = "$Date: 2006/09/25 03:53:03 $"; // the name of the class // private final String cn = this.getClass().getName(); private static Logger cat = Logger.getLogger(ObservationMgrImplLoader.class.getName()); // miscellaneous ConfigProperties props; // holder for an empty persistent object // the parent object ObservationComponentImpl parent; private String loadFile = ""; /** * Constructor declaration * * @param parent * @see */ public ObservationMgrImplLoader(ObservationComponentImpl parent) { this.parent = parent; // theOrb = parent.theOrb; props = parent.props; // dbMgr = DBMgrFactory.current(); // dbMgr.setDebug( debug); // persObjFact = dbMgr.getObjectFactory(); // theOrb.connect(this); loadFile = props.getProperty("CreateDB", ""); cat.debug("ObservationMgrImplLoader instantiated."); } public void run() { if (!loadFile.equals("")) { cat.info("Loading observation data from file '" + loadFile + "'"); try { // create a DomTree out of the xml file Xml2DomDoc x2dd = new Xml2DomDoc(new FileInputStream(loadFile)); // create observation data from the DomTree DomDoc2ObsData dd2od = new DomDoc2ObsData(x2dd.getDomDoc().getRootElement()); ObservationDataStruct[] obsDataSeq = dd2od.getObsDataSeq(); // embed external URI links as a multimedia.blob into the database? String embedMultimedia = props.getProperty("embedMultimedia", "no"); Thread.sleep(250); if (embedMultimedia.equalsIgnoreCase("YES")) { cat.info("Embedding URIs into Multimedia objects..."); URI2Blob uri2blob = new URI2Blob(obsDataSeq, parent.theOrb); obsDataSeq = uri2blob.getObservationDataSeq(); cat.info("Embedding URIs into Multimedia objects done!"); } // the createXML property can be used to create a new xml file // (usefull for creating a xml file after embedding the URIs as Blobs) String createXML = props.getProperty("createXML", ""); if (!createXML.equals("")) { cat.info("Creating XML file " + createXML + "..."); ObsData2Dom od2doc = new ObsData2Dom(obsDataSeq); // Writer out = new FileWriter(createXML); od2doc.write(createXML); // out.write(od2x.getXml()); // out.flush(); // out.close(); cat.info("Creating XML file " + createXML + " done!"); } cat.info("Adding observations to the database..."); Thread.sleep(250); for (int i = 0; i < obsDataSeq.length; i++) { // sleep to let other threads work. if ((i % 500) == 0) Thread.sleep(250); // output some status if ((i % 1000) == 0) cat.debug("Loading record number " + i); org.omg.CORBA.Any any = parent.theOrb.create_any(); try { ObservationDataStructHelper.insert(any, obsDataSeq[i]); parent.get_observation_mgr().add_observation(any); // add_observation(any); } catch (Exception e) { cat.error("failed to add object: ", e); if (obsDataSeq[i] != null) cat.error("obsDataSeq: " + i + ":" + obsDataSeq[i].code); } } cat.info("Added " + obsDataSeq.length + " observations to the database"); } catch (Exception e) { cat.error(e); } } } } |