You are viewing a plain text version of this content. The canonical link for it is here.
Posted to xindice-dev@xml.apache.org by vg...@apache.org on 2007/04/28 02:51:38 UTC
svn commit: r533273 - in /xml/xindice/trunk: ./
java/src/org/apache/xindice/core/ java/src/org/apache/xindice/xml/dom/
Author: vgritsenko
Date: Fri Apr 27 17:51:37 2007
New Revision: 533273
URL: http://svn.apache.org/viewvc?view=rev&rev=533273
Log:
<action dev="VG" type="update">
Do not create meta collections for the system collections.
</action>
<action dev="VG" type="fix" fixes-bug="42273" due-to="Natalia Shilenkova">
Save meta collection configuration in the database and initialize meta
collection from the configuration on startup. This keeps meta collection
configuration consistent with database configuration.
</action>
Modified:
xml/xindice/trunk/java/src/org/apache/xindice/core/Database.java
xml/xindice/trunk/java/src/org/apache/xindice/core/MetaSystemCollection.java
xml/xindice/trunk/java/src/org/apache/xindice/core/SystemCollection.java
xml/xindice/trunk/java/src/org/apache/xindice/xml/dom/DOMParser.java
xml/xindice/trunk/status.xml
Modified: xml/xindice/trunk/java/src/org/apache/xindice/core/Database.java
URL: http://svn.apache.org/viewvc/xml/xindice/trunk/java/src/org/apache/xindice/core/Database.java?view=diff&rev=533273&r1=533272&r2=533273
==============================================================================
--- xml/xindice/trunk/java/src/org/apache/xindice/core/Database.java (original)
+++ xml/xindice/trunk/java/src/org/apache/xindice/core/Database.java Fri Apr 27 17:51:37 2007
@@ -52,16 +52,20 @@
private static final Log log = LogFactory.getLog(Database.class);
+ // Configuration elements in config/system.xml file
public static final String DBROOT = "dbroot";
public static final String NAME = "name";
private static final String QUERYENGINE = "queryengine";
- private static final String COLKEY = "database.xml";
private static final String DATABASE = "database";
private static final String METADATA = "use-metadata";
public static final String DBROOT_DEFAULT = "./db/";
+ // Configuration documents stored in SysConfigs collection
+ private static final String COLKEY = "database.xml";
+ private static final String METAKEY = "meta.xml";
+
private static final Map databases = new HashMap(); // String to Database
private static final DatabaseShutdownHandler shutdownHandler = new DatabaseShutdownHandler();
@@ -226,12 +230,25 @@
systemCollection.getCollection(SystemCollection.CONFIGS).setDocument(COLKEY, d);
getConfig().resetDirty();
} catch (Exception e) {
- log.error("Error Writing Configuration '" + getName() + "', for database " + getName(), e);
+ log.error("Error Writing Configuration '" + COLKEY + "', for database " + getName(), e);
}
// Observer
DBObserver.getInstance().flushDatabaseConfig(this, getConfig());
}
+
+ if (isMetaEnabled()) {
+ Configuration config = metaSystemCollection.getConfig();
+ if (config.isDirty()) {
+ try {
+ Document d = config.getElement().getOwnerDocument();
+ systemCollection.getCollection(SystemCollection.CONFIGS).setDocument(METAKEY, d);
+ config.resetDirty();
+ } catch (Exception e) {
+ log.error("Error writing configuration '" + METAKEY + "', for database " + getName(), e);
+ }
+ }
+ }
}
/**
@@ -370,18 +387,19 @@
this.sysInit = true;
}
+ Collection sysConfigCollection = systemCollection.getCollection(SystemCollection.CONFIGS);
try {
// Bootstrap from the database itself... This is accomplished
// by intercepting the setConfig call and using a Configuration
// retrieved from the database instead of the standard config
- Document colDoc = systemCollection.getCollection(SystemCollection.CONFIGS).getDocument(COLKEY);
+ Document colDoc = sysConfigCollection.getDocument(COLKEY);
if (colDoc == null) {
DocumentBuilder db = DocumentBuilderFactory.newInstance().newDocumentBuilder();
colDoc = db.newDocument();
Element root = colDoc.createElement(DATABASE);
root.setAttribute(NAME, getName());
colDoc.appendChild(root);
- systemCollection.getCollection(SystemCollection.CONFIGS).setDocument(COLKEY, colDoc);
+ sysConfigCollection.setDocument(COLKEY, colDoc);
}
super.setConfig(new Configuration(colDoc.getDocumentElement(), false));
@@ -399,12 +417,28 @@
String metaCfg = config.getAttribute(METADATA);
if (metaCfg.equalsIgnoreCase("on")) {
metaEnabled = true;
- if (!metaInit) {
+ }
+
+ if (metaEnabled && !metaInit) {
+ try {
metaSystemCollection = new MetaSystemCollection(this);
- metaSystemCollection.init();
+
+ Document colDoc = sysConfigCollection.getDocument(METAKEY);
+ if (colDoc == null) {
+ metaSystemCollection.init();
+ Document metaConfig = metaSystemCollection.getConfig().getElement().getOwnerDocument();
+ sysConfigCollection.setDocument(METAKEY, metaConfig);
+ } else {
+ metaSystemCollection.setConfig(new Configuration(colDoc, false));
+ }
+
super.addCollection(metaSystemCollection);
metaInit = true;
- log.debug("Meta information initialized");
+ if (log.isDebugEnabled()) {
+ log.debug("Meta collection is initialized");
+ }
+ } catch (Exception e) {
+ log.error("Meta collection was not initialized", e);
}
}
Modified: xml/xindice/trunk/java/src/org/apache/xindice/core/MetaSystemCollection.java
URL: http://svn.apache.org/viewvc/xml/xindice/trunk/java/src/org/apache/xindice/core/MetaSystemCollection.java?view=diff&rev=533273&r1=533272&r2=533273
==============================================================================
--- xml/xindice/trunk/java/src/org/apache/xindice/core/MetaSystemCollection.java (original)
+++ xml/xindice/trunk/java/src/org/apache/xindice/core/MetaSystemCollection.java Fri Apr 27 17:51:37 2007
@@ -50,40 +50,12 @@
+ " <collections>"
// Meta Collections
+ " <collection name='" + METAS + "' compressed='true'>"
- + " <filer class='org.apache.xindice.core.filer.BTreeFiler'/>"
- + " <collections>"
- // Add Meta collections for System collections to avoid eternal loop during initialization
- + " <collection name='" + SystemCollection.SYSCOL + "'>"
- + " <collections>"
- // Meta for Symbol Tables Collection
- + " <collection name='" + SystemCollection.SYMBOLS + "' compressed='true'>"
- + " <filer class='org.apache.xindice.core.filer.BTreeFiler'/>"
- + " <symbols>"
- + " <symbol name='meta' nsuri='http://apache.org/xindice/metadata' id='0'/>"
- + " <symbol name='xmlns' nsuri='http://www.w3.org/2000/xmlns/' id='1'/>"
- + " <symbol name='system' nsuri='http://apache.org/xindice/metadata' id='2'/>"
- + " <symbol name='type' id='3'/>"
- + " <symbol name='attr' nsuri='http://apache.org/xindice/metadata' id='4'/>"
- + " <symbol name='name' id='5'/>"
- + " <symbol name='value' id='6'/>"
- + " </symbols>"
- + " <indexes/>"
- + " </collection>"
- // System Configuration Collection
- + " <collection name='" + SystemCollection.CONFIGS + "' compressed='false'>"
- + " <filer class='org.apache.xindice.core.filer.BTreeFiler'/>"
- + " <indexes/>"
- + " </collection>"
- + " </collections>"
- + " </collection>"
- + " </collections>"
- + " <indexes/>"
+ " </collection>"
+ " </collections>"
+ "</collection>";
private String dbCanonicalName;
- // private String sysCanonicalName;
+ private String sysCanonicalName;
public MetaSystemCollection(Database db) {
@@ -91,7 +63,7 @@
// Set the canonical names
dbCanonicalName = db.getCanonicalName();
- // sysCanonicalName = db.getSystemCollection().getCanonicalName();
+ sysCanonicalName = db.getSystemCollection().getCanonicalName();
}
public void init() throws DBException {
@@ -115,6 +87,7 @@
* @param collection the collection whose meta you want
* @param create whether or not to create the meta if its missing
* @return collection the meta collection for the requested collection
+ * @throws DBException if unable to get meta collection
*/
public Collection getMetaCollection(Collection collection, boolean create) throws DBException {
String path = collection.getCanonicalName();
@@ -130,9 +103,9 @@
}
// this is the system collection
- // if (path.startsWith(sysCanonicalName)) {
- // return null;
- // }
+ if (path.startsWith(sysCanonicalName)) {
+ return null;
+ }
Collection current = getCollection(METAS);
StringTokenizer st = new StringTokenizer(path.substring(dbCanonicalName.length()), "/");
@@ -175,6 +148,7 @@
* Collection.
*
* @param collection The Collection whose meta is required
+ * @throws DBException if unable to delete collection meta data
*/
public void dropCollectionMeta(Collection collection) throws DBException {
Collection mcol = getMetaCollection(collection, false);
@@ -196,6 +170,7 @@
*
* @param collection The Collection whose meta is required
* @return The requested MetaData
+ * @throws DBException if unable to retrieve collection meta data
*/
public MetaData getCollectionMeta(Collection collection) throws DBException {
Collection mcol = getMetaCollection(collection, true);
@@ -221,6 +196,7 @@
*
* @param collection The Collection that owns the MetaData
* @param meta The MetaData
+ * @throws DBException if unable to update collection meta data
*/
public void setCollectionMeta(Collection collection, MetaData meta) throws DBException {
if (null == meta) {
@@ -235,11 +211,12 @@
}
/**
- * dropDocumentMeta removes the MetaData for the specified
- * Document.
+ * dropDocumentMeta removes the meta data for the specified
+ * document.
*
- * @param collection The Collection whose meta is required
- * @param id the Document id
+ * @param collection Document collection
+ * @param id Document key
+ * @throws DBException if unable to delete document meta data
*/
public void dropDocumentMeta(Collection collection, String id) throws DBException {
Collection mcol = getMetaCollection(collection, false);
@@ -255,12 +232,13 @@
}
/**
- * getDocumentMeta retrieves the MetaData for the specified
+ * getDocumentMeta retrieves the meta data for the specified
* document.
*
- * @param collection The Collection whose meta is required
- * @param id the ID
+ * @param collection Document collection
+ * @param id Document key
* @return The requested MetaData
+ * @throws DBException if unable to retrieve document meta data
*/
public MetaData getDocumentMeta(Collection collection, String id) throws DBException {
Collection mcol = getMetaCollection(collection, true);
@@ -282,11 +260,12 @@
}
/**
- * setDocumentMeta save the Meta for the specified Collection.
+ * setDocumentMeta sets the meta data for the specified document.
*
- * @param collection The Collection that owns the MetaData
- * @param id
- * @param meta The MetaData
+ * @param collection Document collection
+ * @param id Document key
+ * @param meta New document meta data
+ * @throws DBException if unable to update document meta data
*/
public void setDocumentMeta(Collection collection, String id, MetaData meta) throws DBException {
if (null == meta) {
Modified: xml/xindice/trunk/java/src/org/apache/xindice/core/SystemCollection.java
URL: http://svn.apache.org/viewvc/xml/xindice/trunk/java/src/org/apache/xindice/core/SystemCollection.java?view=diff&rev=533273&r1=533272&r2=533273
==============================================================================
--- xml/xindice/trunk/java/src/org/apache/xindice/core/SystemCollection.java (original)
+++ xml/xindice/trunk/java/src/org/apache/xindice/core/SystemCollection.java Fri Apr 27 17:51:37 2007
@@ -67,7 +67,7 @@
+ "</collection>";
/**
- * @param db
+ * @param db Its database
*/
public SystemCollection(Database db) {
super(db);
@@ -101,6 +101,7 @@
*
* @param collection The Collection whose SymbolTable is required
* @return The requested SymbolTable
+ * @throws DBException if unable to load symbols
*/
public SymbolTable loadSymbols(Collection collection) throws DBException {
String name = getSymbolTableName(collection);
@@ -119,6 +120,7 @@
*
* @param collection The Collection that owns the SymbolTable
* @param symbols The SymbolTable
+ * @throws DBException if unable to save symbols
*/
public void saveSymbols(Collection collection, SymbolTable symbols) throws DBException {
String name = getSymbolTableName(collection);
@@ -135,6 +137,7 @@
* dropSymbols drop the SymbolTable for the specified Collection.
*
* @param collection The Collection that owns the SymbolTable
+ * @throws DBException if unable to drop symbols
*/
public void dropSymbols(Collection collection) throws DBException {
String name = getSymbolTableName(collection);
Modified: xml/xindice/trunk/java/src/org/apache/xindice/xml/dom/DOMParser.java
URL: http://svn.apache.org/viewvc/xml/xindice/trunk/java/src/org/apache/xindice/xml/dom/DOMParser.java?view=diff&rev=533273&r1=533272&r2=533273
==============================================================================
--- xml/xindice/trunk/java/src/org/apache/xindice/xml/dom/DOMParser.java (original)
+++ xml/xindice/trunk/java/src/org/apache/xindice/xml/dom/DOMParser.java Fri Apr 27 17:51:37 2007
@@ -56,7 +56,8 @@
*
* @version $Revision$, $Date$
*/
-public final class DOMParser extends DefaultHandler implements DeclHandler, LexicalHandler {
+public final class DOMParser extends DefaultHandler
+ implements DeclHandler, LexicalHandler {
private static final Log log = LogFactory.getLog(DOMParser.class);
@@ -66,14 +67,15 @@
private static final SAXParserFactory factory = SAXParserFactory.newInstance();
private SAXParser sp;
- private ErrorHandler errors = null;
- private EntityResolver entities = null;
+ private ErrorHandler errors;
+ private EntityResolver entities;
private Document doc;
private Node context;
private int state = -1;
private StringBuffer buf;
private final ObjectStack states = new ObjectStack();
+
public DOMParser() throws XindiceException {
try {
Modified: xml/xindice/trunk/status.xml
URL: http://svn.apache.org/viewvc/xml/xindice/trunk/status.xml?view=diff&rev=533273&r1=533272&r2=533273
==============================================================================
--- xml/xindice/trunk/status.xml (original)
+++ xml/xindice/trunk/status.xml Fri Apr 27 17:51:37 2007
@@ -116,7 +116,15 @@
</todo>
<changes>
- <release version="1.1-dev" date="(not released)">
+ <release version="1.1" date="(not released)">
+ <action dev="VG" type="update">
+ Do not create meta collections for the system collections.
+ </action>
+ <action dev="VG" type="fix" fixes-bug="42273" due-to="Natalia Shilenkova">
+ Save meta collection configuration in the database and initialize meta
+ collection from the configuration on startup. This keeps meta collection
+ configuration consistent with database configuration.
+ </action>
<action dev="VG" type="fix" fixes-bug="42272" due-to="Natalia Shilenkova">
Clear Paged and BTree cache on close.
</action>