org.exist.cluster
Class ClusterCollection

java.lang.Object
  extended by java.util.Observable
      extended by org.exist.collections.Collection
          extended by org.exist.cluster.ClusterCollection
All Implemented Interfaces:
Comparable, Cacheable

public final class ClusterCollection
extends Collection

Created by Francesco Mondora. TODO ... verify TRANSACTION IN CLUSTER

Author:
Francesco Mondora aka Makkina, Michele Danieli aka cinde, Nicola Breda aka maiale Date: Aug 31, 2004 Time: 8:45:47 AM Revision $Revision: 7858 $

Field Summary
 
Fields inherited from class org.exist.collections.Collection
LENGTH_COLLECTION_ID, POOL_PARSER_THRESHOLD, UNKNOWN_COLLECTION_ID
 
Fields inherited from interface org.exist.storage.cache.Cacheable
MAX_REF
 
Constructor Summary
ClusterCollection(Collection collection)
           
 
Method Summary
 BinaryDocument addBinaryResource(Txn transaction, DBBroker broker, XmldbURI name, byte[] data, String mimeType)
           
 void addCollection(DBBroker broker, Collection child, boolean isNew)
          Add a new sub-collection to the collection.
 void addDocument(Txn transaction, DBBroker broker, DocumentImpl doc)
          Add a document to the collection.
 void addObserver(Observer o)
           
 DocumentSet allDocs(DBBroker broker, DocumentSet docs, boolean recursive, boolean checkPermissions)
           
 boolean allowUnload()
          Check if this collection may be safely removed from the cache.
 Iterator collectionIterator()
          Return an iterator over all subcollections.
 int compareTo(Object obj)
           
 int decReferenceCount()
          Decrease the reference count of this object by one and return it.
 void deleteObservers()
           
 boolean equals(Object obj)
           
 long getAddress()
           
 int getChildCollectionCount()
          Return the number of child-collections managed by this collection.
 long getCreationTime()
           
 List getDescendants(DBBroker broker, User user)
          Load all collections below this collections and return them in a List.
 DocumentImpl getDocument(DBBroker broker, XmldbURI name)
          Get a child resource as identified by path.
 int getDocumentCount()
          Returns the number of documents in this collection.
 DocumentSet getDocuments(DBBroker broker, DocumentSet docs, boolean checkPermissions)
          Add all documents to the specified document set.
 DocumentImpl getDocumentWithLock(DBBroker broker, XmldbURI name)
          Retrieve a child resource after putting a read lock on it.
 DocumentImpl getDocumentWithLock(DBBroker broker, XmldbURI name, int lockMode)
          Retrieve a child resource after putting a read lock on it.
 int getId()
          Get the internal id.
 long getKey()
          Get a unique key for the object.
 Lock getLock()
           
 XmldbURI getParentURI()
          Returns the parent-collection.
 Permission getPermissions()
          Gets the permissions attribute of the Collection object
 Permission getPermissionsNoLock()
           
 int getReferenceCount()
          Get the current reference count.
 int getTimestamp()
          Get the current timestamp marker.
 XmldbURI getURI()
          Get the name of this collection.
 boolean hasChildCollection(XmldbURI name)
           
 boolean hasDocument(XmldbURI name)
          Check if the collection has a child document.
 boolean hasSubcollection(XmldbURI name)
          Check if the collection has a sub-collection.
 boolean hasSubcollectionNoLock(XmldbURI name)
           
 int incReferenceCount()
          Increase the reference count of this object by one and return it.
 boolean isDirty()
           
 Iterator iterator(DBBroker broker)
          Returns an iterator on the child-documents in this collection.
 void read(DBBroker broker, VariableByteInput istream)
          Read collection contents from the stream.
 void release(int mode)
          Closes the collection, i.e.
 void releaseDocument(DocumentImpl doc)
          Release any locks held on the document.
 void releaseDocument(DocumentImpl doc, int mode)
          Release any locks held on the document.
 void removeBinaryResource(Txn transaction, DBBroker broker, DocumentImpl doc)
           
 void removeBinaryResource(Txn transaction, DBBroker broker, XmldbURI docname)
           
 void removeCollection(XmldbURI name)
          Remove the specified sub-collection.
 void removeXMLResource(Txn transaction, DBBroker broker, XmldbURI docURI)
          Remove the specified document from the collection.
 void setAddress(long addr)
          Set the internal storage address of the collection data.
 void setCreationTime(long ms)
           
 void setId(int id)
           
 void setPermissions(int mode)
           
 void setPermissions(Permission permissions)
          Set permissions for the collection.
 void setPermissions(String mode)
           
 void setReader(XMLReader reader)
          set user-defined Reader
 void setReferenceCount(int count)
          Set the reference count of this object.
 void setTimestamp(int timestamp)
          Set the timestamp marker.
 void setTriggersEnabled(boolean enabled)
           
 void store(Txn transaction, DBBroker broker, IndexInfo info, InputSource source, boolean privileged)
          This method is used by the XML RPC client.
 void store(Txn txn, DBBroker broker, IndexInfo info, Node node, boolean privileged)
          Stores an XML document in the database.
 void store(Txn txn, DBBroker broker, IndexInfo info, String data, boolean privileged)
          Stores an XML document in the database.
 boolean sync(boolean syncJournal)
          Called before the object is released by the cache.
 String toString()
           
 void update(Collection child)
          Update the specified child-collection.
 IndexInfo validateXMLResource(Txn txn, DBBroker broker, XmldbURI name, InputSource source)
          Validates an XML document et prepares it for further storage.
 IndexInfo validateXMLResource(Txn txn, DBBroker broker, XmldbURI name, Node node)
          Validates an XML document et prepares it for further storage.
 IndexInfo validateXMLResource(Txn txn, DBBroker broker, XmldbURI name, String data)
          Validates an XML document et prepares it for further storage.
 void write(DBBroker broker, VariableByteOutputStream ostream)
          Write collection contents to stream.
 
Methods inherited from class org.exist.collections.Collection
addBinaryResource, addBinaryResource, addBinaryResource, allDocs, allDocs, getConfiguration, getDocumentNoLock, getDocuments, getFulltextIndexConfiguration, getIndexByPathConfiguration, getIndexByQNameConfiguration, getIndexConfiguration, getMemorySize, isTempCollection, setConfigEnabled, setPath, unlinkDocument
 
Methods inherited from class java.util.Observable
countObservers, deleteObserver, hasChanged, notifyObservers, notifyObservers
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ClusterCollection

public ClusterCollection(Collection collection)
Method Detail

store

public void store(Txn txn,
                  DBBroker broker,
                  IndexInfo info,
                  String data,
                  boolean privileged)
           throws EXistException,
                  PermissionDeniedException,
                  TriggerException,
                  SAXException,
                  LockException
Description copied from class: Collection
Stores an XML document in the database. Collection.validateXMLResourceInternal(org.exist.storage.txn.Txn, org.exist.storage.DBBroker, org.exist.xmldb.XmldbURI, CollectionConfiguration, org.exist.collections.Collection.ValidateBlock) should have been called previously in order to acquire a write lock for the document. Launches the finish trigger.

Overrides:
store in class Collection
Throws:
EXistException
PermissionDeniedException
TriggerException
SAXException
LockException

removeXMLResource

public void removeXMLResource(Txn transaction,
                              DBBroker broker,
                              XmldbURI docURI)
                       throws PermissionDeniedException,
                              TriggerException,
                              LockException
Description copied from class: Collection
Remove the specified document from the collection.

Overrides:
removeXMLResource in class Collection
Throws:
PermissionDeniedException
TriggerException
LockException

store

public void store(Txn transaction,
                  DBBroker broker,
                  IndexInfo info,
                  InputSource source,
                  boolean privileged)
           throws EXistException,
                  PermissionDeniedException,
                  TriggerException,
                  SAXException,
                  LockException
This method is used by the XML RPC client.

Overrides:
store in class Collection
Parameters:
broker -
info -
source -
privileged -
Throws:
EXistException
PermissionDeniedException
TriggerException
SAXException
LockException

addBinaryResource

public BinaryDocument addBinaryResource(Txn transaction,
                                        DBBroker broker,
                                        XmldbURI name,
                                        byte[] data,
                                        String mimeType)
                                 throws EXistException,
                                        PermissionDeniedException,
                                        LockException,
                                        TriggerException
Overrides:
addBinaryResource in class Collection
Throws:
EXistException
PermissionDeniedException
LockException
TriggerException

getLock

public Lock getLock()
Overrides:
getLock in class Collection

addCollection

public void addCollection(DBBroker broker,
                          Collection child,
                          boolean isNew)
Description copied from class: Collection
Add a new sub-collection to the collection.

Overrides:
addCollection in class Collection

removeCollection

public void removeCollection(XmldbURI name)
                      throws LockException
Description copied from class: Collection
Remove the specified sub-collection.

Overrides:
removeCollection in class Collection
Parameters:
name - Description of the Parameter
Throws:
LockException

hasChildCollection

public boolean hasChildCollection(XmldbURI name)
Overrides:
hasChildCollection in class Collection

release

public void release(int mode)
Description copied from class: Collection
Closes the collection, i.e. releases the lock held by the current thread. This is a shortcut for getLock().release().

Overrides:
release in class Collection

update

public void update(Collection child)
Description copied from class: Collection
Update the specified child-collection.

Overrides:
update in class Collection

addDocument

public void addDocument(Txn transaction,
                        DBBroker broker,
                        DocumentImpl doc)
Description copied from class: Collection
Add a document to the collection.

Overrides:
addDocument in class Collection

collectionIterator

public Iterator collectionIterator()
Description copied from class: Collection
Return an iterator over all subcollections. The list of subcollections is copied first, so modifications via the iterator have no affect.

Overrides:
collectionIterator in class Collection
Returns:
Description of the Return Value

getDescendants

public List getDescendants(DBBroker broker,
                           User user)
Description copied from class: Collection
Load all collections below this collections and return them in a List.

Overrides:
getDescendants in class Collection
Returns:
List

allDocs

public DocumentSet allDocs(DBBroker broker,
                           DocumentSet docs,
                           boolean recursive,
                           boolean checkPermissions)
Overrides:
allDocs in class Collection

getDocuments

public DocumentSet getDocuments(DBBroker broker,
                                DocumentSet docs,
                                boolean checkPermissions)
Description copied from class: Collection
Add all documents to the specified document set.

Overrides:
getDocuments in class Collection

allowUnload

public boolean allowUnload()
Description copied from class: Collection
Check if this collection may be safely removed from the cache. Returns false if there are ongoing write operations, i.e. one or more of the documents is locked for write.

Specified by:
allowUnload in interface Cacheable
Overrides:
allowUnload in class Collection
Returns:
A boolean value where true indicates it may be unloaded.

compareTo

public int compareTo(Object obj)
Specified by:
compareTo in interface Comparable
Overrides:
compareTo in class Collection

equals

public boolean equals(Object obj)
Overrides:
equals in class Collection

getChildCollectionCount

public int getChildCollectionCount()
Description copied from class: Collection
Return the number of child-collections managed by this collection.

Overrides:
getChildCollectionCount in class Collection
Returns:
The childCollectionCount value

getDocument

public DocumentImpl getDocument(DBBroker broker,
                                XmldbURI name)
Description copied from class: Collection
Get a child resource as identified by path. This method doesn't put a lock on the document nor does it recognize locks held by other threads. There's no guarantee that the document still exists when accessing it.

Overrides:
getDocument in class Collection
name - The name of the document (without collection path)
Returns:
the document

getDocumentWithLock

public DocumentImpl getDocumentWithLock(DBBroker broker,
                                        XmldbURI name)
                                 throws LockException
Description copied from class: Collection
Retrieve a child resource after putting a read lock on it. With this method, access to the received document object is safe.

Overrides:
getDocumentWithLock in class Collection
Returns:
The document that was locked.
Throws:
LockException

getDocumentWithLock

public DocumentImpl getDocumentWithLock(DBBroker broker,
                                        XmldbURI name,
                                        int lockMode)
                                 throws LockException
Description copied from class: Collection
Retrieve a child resource after putting a read lock on it. With this method, access to the received document object is safe.

Overrides:
getDocumentWithLock in class Collection
Returns:
The document that was locked.
Throws:
LockException

releaseDocument

public void releaseDocument(DocumentImpl doc)
Description copied from class: Collection
Release any locks held on the document.

Overrides:
releaseDocument in class Collection

releaseDocument

public void releaseDocument(DocumentImpl doc,
                            int mode)
Description copied from class: Collection
Release any locks held on the document.

Overrides:
releaseDocument in class Collection

getDocumentCount

public int getDocumentCount()
Description copied from class: Collection
Returns the number of documents in this collection.

Overrides:
getDocumentCount in class Collection
Returns:
The documentCount value

getId

public int getId()
Description copied from class: Collection
Get the internal id.

Overrides:
getId in class Collection
Returns:
The id value

getURI

public XmldbURI getURI()
Description copied from class: Collection
Get the name of this collection.

Overrides:
getURI in class Collection
Returns:
The name value

getParentURI

public XmldbURI getParentURI()
Description copied from class: Collection
Returns the parent-collection.

Overrides:
getParentURI in class Collection
Returns:
The parent-collection or null if this is the root collection.

getPermissions

public Permission getPermissions()
Description copied from class: Collection
Gets the permissions attribute of the Collection object

Overrides:
getPermissions in class Collection
Returns:
The permissions value

getPermissionsNoLock

public Permission getPermissionsNoLock()
Overrides:
getPermissionsNoLock in class Collection

hasDocument

public boolean hasDocument(XmldbURI name)
Description copied from class: Collection
Check if the collection has a child document.

Overrides:
hasDocument in class Collection
Parameters:
name - the name (without path) of the document
Returns:
A value of true when the collection has the document identified.

hasSubcollection

public boolean hasSubcollection(XmldbURI name)
Description copied from class: Collection
Check if the collection has a sub-collection.

Overrides:
hasSubcollection in class Collection
Parameters:
name - the name of the subcollection (without path).
Returns:
A value of true when the subcollection exists.

hasSubcollectionNoLock

public boolean hasSubcollectionNoLock(XmldbURI name)
Overrides:
hasSubcollectionNoLock in class Collection

iterator

public Iterator iterator(DBBroker broker)
Description copied from class: Collection
Returns an iterator on the child-documents in this collection.

Overrides:
iterator in class Collection
Returns:
A iterator of all the documents in the collection.

read

public void read(DBBroker broker,
                 VariableByteInput istream)
          throws IOException
Description copied from class: Collection
Read collection contents from the stream.

Overrides:
read in class Collection
Throws:
IOException

removeBinaryResource

public void removeBinaryResource(Txn transaction,
                                 DBBroker broker,
                                 XmldbURI docname)
                          throws PermissionDeniedException,
                                 LockException,
                                 TriggerException
Overrides:
removeBinaryResource in class Collection
Throws:
PermissionDeniedException
LockException
TriggerException

removeBinaryResource

public void removeBinaryResource(Txn transaction,
                                 DBBroker broker,
                                 DocumentImpl doc)
                          throws PermissionDeniedException,
                                 LockException,
                                 TriggerException
Overrides:
removeBinaryResource in class Collection
Throws:
PermissionDeniedException
LockException
TriggerException

validateXMLResource

public IndexInfo validateXMLResource(Txn txn,
                                     DBBroker broker,
                                     XmldbURI name,
                                     InputSource source)
                              throws EXistException,
                                     PermissionDeniedException,
                                     TriggerException,
                                     SAXException,
                                     LockException,
                                     IOException
Description copied from class: Collection
Validates an XML document et prepares it for further storage. Launches prepare and postValidate triggers. Since the process is dependant from the collection configuration, the collection acquires a write lock during the process.

Overrides:
validateXMLResource in class Collection
Returns:
An IndexInfo with a write lock on the document.
Throws:
EXistException
PermissionDeniedException
TriggerException
SAXException
LockException
IOException

validateXMLResource

public IndexInfo validateXMLResource(Txn txn,
                                     DBBroker broker,
                                     XmldbURI name,
                                     String data)
                              throws EXistException,
                                     PermissionDeniedException,
                                     TriggerException,
                                     SAXException,
                                     LockException,
                                     IOException
Description copied from class: Collection
Validates an XML document et prepares it for further storage. Launches prepare and postValidate triggers. Since the process is dependant from the collection configuration, the collection acquires a write lock during the process.

Overrides:
validateXMLResource in class Collection
Returns:
An IndexInfo with a write lock on the document.
Throws:
EXistException
PermissionDeniedException
TriggerException
SAXException
LockException
IOException

validateXMLResource

public IndexInfo validateXMLResource(Txn txn,
                                     DBBroker broker,
                                     XmldbURI name,
                                     Node node)
                              throws EXistException,
                                     PermissionDeniedException,
                                     TriggerException,
                                     SAXException,
                                     LockException,
                                     IOException
Description copied from class: Collection
Validates an XML document et prepares it for further storage. Launches prepare and postValidate triggers. Since the process is dependant from the collection configuration, the collection acquires a write lock during the process.

Overrides:
validateXMLResource in class Collection
Returns:
An IndexInfo with a write lock on the document.
Throws:
EXistException
PermissionDeniedException
TriggerException
SAXException
LockException
IOException

store

public void store(Txn txn,
                  DBBroker broker,
                  IndexInfo info,
                  Node node,
                  boolean privileged)
           throws EXistException,
                  PermissionDeniedException,
                  TriggerException,
                  SAXException,
                  LockException
Description copied from class: Collection
Stores an XML document in the database. Collection.validateXMLResourceInternal(org.exist.storage.txn.Txn, org.exist.storage.DBBroker, org.exist.xmldb.XmldbURI, CollectionConfiguration, org.exist.collections.Collection.ValidateBlock) should have been called previously in order to acquire a write lock for the document. Launches the finish trigger.

Overrides:
store in class Collection
Throws:
EXistException
PermissionDeniedException
TriggerException
SAXException
LockException

setId

public void setId(int id)
Overrides:
setId in class Collection

setPermissions

public void setPermissions(int mode)
                    throws LockException
Overrides:
setPermissions in class Collection
Throws:
LockException

setPermissions

public void setPermissions(String mode)
                    throws SyntaxException,
                           LockException
Overrides:
setPermissions in class Collection
Throws:
SyntaxException
LockException

setPermissions

public void setPermissions(Permission permissions)
                    throws LockException
Description copied from class: Collection
Set permissions for the collection.

Overrides:
setPermissions in class Collection
Throws:
LockException

write

public void write(DBBroker broker,
                  VariableByteOutputStream ostream)
           throws IOException
Description copied from class: Collection
Write collection contents to stream.

Overrides:
write in class Collection
Throws:
IOException

setAddress

public void setAddress(long addr)
Description copied from class: Collection
Set the internal storage address of the collection data.

Overrides:
setAddress in class Collection

getAddress

public long getAddress()
Overrides:
getAddress in class Collection

setCreationTime

public void setCreationTime(long ms)
Overrides:
setCreationTime in class Collection

getCreationTime

public long getCreationTime()
Overrides:
getCreationTime in class Collection

setTriggersEnabled

public void setTriggersEnabled(boolean enabled)
Overrides:
setTriggersEnabled in class Collection

setReader

public void setReader(XMLReader reader)
Description copied from class: Collection
set user-defined Reader

Overrides:
setReader in class Collection

addObserver

public void addObserver(Observer o)
Overrides:
addObserver in class Collection

deleteObservers

public void deleteObservers()
Overrides:
deleteObservers in class Collection

getKey

public long getKey()
Description copied from interface: Cacheable
Get a unique key for the object. Usually this is the page number.

Specified by:
getKey in interface Cacheable
Overrides:
getKey in class Collection
Returns:
unique key

getReferenceCount

public int getReferenceCount()
Description copied from interface: Cacheable
Get the current reference count.

Specified by:
getReferenceCount in interface Cacheable
Overrides:
getReferenceCount in class Collection
Returns:
The count value.

incReferenceCount

public int incReferenceCount()
Description copied from interface: Cacheable
Increase the reference count of this object by one and return it.

Specified by:
incReferenceCount in interface Cacheable
Overrides:
incReferenceCount in class Collection
Returns:
the reference count

decReferenceCount

public int decReferenceCount()
Description copied from interface: Cacheable
Decrease the reference count of this object by one and return it.

Specified by:
decReferenceCount in interface Cacheable
Overrides:
decReferenceCount in class Collection
Returns:
the reference count

setReferenceCount

public void setReferenceCount(int count)
Description copied from interface: Cacheable
Set the reference count of this object.

Specified by:
setReferenceCount in interface Cacheable
Overrides:
setReferenceCount in class Collection

setTimestamp

public void setTimestamp(int timestamp)
Description copied from interface: Cacheable
Set the timestamp marker.

Specified by:
setTimestamp in interface Cacheable
Overrides:
setTimestamp in class Collection

getTimestamp

public int getTimestamp()
Description copied from interface: Cacheable
Get the current timestamp marker.

Specified by:
getTimestamp in interface Cacheable
Overrides:
getTimestamp in class Collection
Returns:
timestamp marker

sync

public boolean sync(boolean syncJournal)
Description copied from interface: Cacheable
Called before the object is released by the cache. The object should prepare to be garbage collected. All unwritten data should be flushed to disk.

Specified by:
sync in interface Cacheable
Overrides:
sync in class Collection

isDirty

public boolean isDirty()
Specified by:
isDirty in interface Cacheable
Overrides:
isDirty in class Collection

toString

public String toString()
Overrides:
toString in class Collection


Copyright (C) Wolfgang Meier. All rights reserved.