Package org.lockss.repository
Interface RepositoryNode
- All Superinterfaces:
RepositoryNodeVersion
RepositoryNode is used to store the contents and
meta-information of urls being cached.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceRepositoryNodeContents is used to obtain Properties and InputStream. -
Method Summary
Modifier and TypeMethodDescriptionvoidDiscards the currently open new version without writing.voidDeactivates the node.intReturns the number of children at this node.longReturns the size of the current version of stored cache.intReturns the current version.Return anOutputStreamobject which writes to a new version in the cache.Return aRepositoryNodeContentsobject which accesses the content in the cache and its properties.Returns the url represented by this node.getNodeVersion(int version) Return a RepositoryNodeVersion for the specified content versionReturn an array of RepositoryNodeVersion for all versions of content/props at this node.getNodeVersions(int maxVersions) Return an array of RepositoryNodeVersion for the most recentmaxVersionsversions of content/props at this node.longgetTreeContentSize(org.lockss.daemon.CachedUrlSetSpec filter, boolean calcIfUnknown) Returns the size of the content tree under (and including) this cache, in bytes.Return aRepositoryNodeContentsobject which accesses the content written to the node but not yet sealed..booleanDetermines if the node has current stored content.booleanDetermines if the node is currently inactive.booleanDetermines if the node is deleted.booleanReturn true if the already-sealed node was identical to the previous version and was not stored.booleanisLeaf()Returns true if node has no children.listChildren(org.lockss.daemon.CachedUrlSetSpec filter, boolean includeInactive) Returns the immediate children of the entry, possibly filtered (null indicates no filtering).voidPrepares the node to write to a new version.voidMarks the node as deleted.voidMarks the node as no longer deleted.voidReverts to the last version.voidCloses the new version to any further writing.voidsetNewProperties(Properties newProps) Stores the properties for a new version of the cache.Methods inherited from interface org.lockss.repository.RepositoryNodeVersion
getVersion
-
Method Details
-
getNodeUrl
String getNodeUrl()Returns the url represented by this node.- Returns:
- the node's url
-
hasContent
boolean hasContent()Determines if the node has current stored content.- Specified by:
hasContentin interfaceRepositoryNodeVersion- Returns:
- true if the node has content
-
isContentInactive
boolean isContentInactive()Determines if the node is currently inactive. Inactive nodes often have old content but no current content, so hasContent() will return false. The node is still counted as part of the AU, and its children are present.- Returns:
- true if the node is inactive
-
isDeleted
boolean isDeleted()Determines if the node is deleted. Deleted nodes may have old content or children, but will not appear in lists of nodes. Their children will not be included in the AU.- Returns:
- true if the node is deleted
-
getContentSize
long getContentSize()Returns the size of the current version of stored cache. Throws an exception if called on a content-less node.- Specified by:
getContentSizein interfaceRepositoryNodeVersion- Returns:
- size
- Throws:
UnsupportedOperationException
-
getTreeContentSize
long getTreeContentSize(org.lockss.daemon.CachedUrlSetSpec filter, boolean calcIfUnknown) Returns the size of the content tree under (and including) this cache, in bytes.- Parameters:
filter- a spec to determine which urls to returncalcIfUnknown- if true, size will calculated if unknown (time consumeing)- Returns:
- size, or -1 if currently unknown
-
isLeaf
boolean isLeaf()Returns true if node has no children.- Returns:
- true if no children
-
getChildCount
int getChildCount()Returns the number of children at this node.- Returns:
- the child count
-
listChildren
Returns the immediate children of the entry, possibly filtered (null indicates no filtering). Includes leaf and internal nodes, but not inactive nodes unless 'includeInactive' is true.- Parameters:
filter- a spec to determine which urls to returnincludeInactive- true to include inactive nodes- Returns:
- an
Iteratorof RepositoryNode objects
-
makeNewVersion
void makeNewVersion()Prepares the node to write to a new version. Should be called before storing any data. Throws an exception if called while a new version is already open.- Throws:
UnsupportedOperationException
-
sealNewVersion
void sealNewVersion()Closes the new version to any further writing. Should be called when done storing data. Throws an exception if called beforemakeNewVersion()or if eithergetNewOutputStream()orsetNewProperties()has not been called.- Throws:
UnsupportedOperationException
-
abandonNewVersion
void abandonNewVersion()Discards the currently open new version without writing. Throws an exception if called beforemakeNewVersion()- Throws:
UnsupportedOperationException
-
isIdenticalVersion
boolean isIdenticalVersion()Return true if the already-sealed node was identical to the previous version and was not stored. -
deactivateContent
void deactivateContent()Deactivates the node. This marks its content as inactive, but still allows it to be present if it has children. Throws if called while a version is open. To reactivate, callrestoreLastVersion()or make a new version.- Throws:
UnsupportedOperationException
-
markAsDeleted
void markAsDeleted()Marks the node as deleted. This also callsdeactivateContent(). To reactivate, callrestoreLastVersion()or make a new version (which gives it content), or callmarkAsNotDeleted(). -
markAsNotDeleted
void markAsNotDeleted()Marks the node as no longer deleted. This reactivates any content also. -
getCurrentVersion
int getCurrentVersion()Returns the current version. This is the open version when writing, and the one accessed bygetNodeInfo(). If inactive, returns -1. Throws an exception if called on a content-less node.- Returns:
- the current version
- Throws:
UnsupportedOperationException
-
restoreLastVersion
void restoreLastVersion()Reverts to the last version. Throws if called on a node without content or only one version (and active). Can be used to reactivate inactive nodes or deleted nodes.- Throws:
UnsupportedOperationException
-
getNodeVersions
RepositoryNodeVersion[] getNodeVersions()Return an array of RepositoryNodeVersion for all versions of content/props at this node. The result is sorted from most to least recent; the RepositoryNodeVersion for current version is the first element in the array.- Returns:
- array of
RepositoryNodeVersion - Throws:
UnsupportedOperationException- if node has no versions
-
getNodeVersions
Return an array of RepositoryNodeVersion for the most recentmaxVersionsversions of content/props at this node. The result is sorted from most to least recent; the RepositoryNodeVersion for current version is the first element in the array.- Returns:
- array of
RepositoryNodeVersion - Throws:
UnsupportedOperationException- if node has no versions
-
getNodeVersion
Return a RepositoryNodeVersion for the specified content version- Returns:
- a
RepositoryNodeVersionbound to the specified version - Throws:
UnsupportedOperationException- if node has no versions
-
getNodeContents
RepositoryNode.RepositoryNodeContents getNodeContents()Return aRepositoryNodeContentsobject which accesses the content in the cache and its properties. Throws if called on a content-less or inactive node.- Specified by:
getNodeContentsin interfaceRepositoryNodeVersion- Returns:
- an
RepositoryNode.RepositoryNodeContentsobject from which the contents of the cache can be read. - Throws:
UnsupportedOperationException
-
getUnsealedRnc
RepositoryNode.RepositoryNodeContents getUnsealedRnc()Return aRepositoryNodeContentsobject which accesses the content written to the node but not yet sealed.. Throws if called on a node that doesn't have a new version open.- Returns:
- an
RepositoryNode.RepositoryNodeContentsobject from which the contents of the unsealed node can be read. - Throws:
UnsupportedOperationException
-
getNewOutputStream
OutputStream getNewOutputStream()Return anOutputStreamobject which writes to a new version in the cache. Throws an exception if called beforemakeNewVersion()or called twice.- Returns:
- an
OutputStreamobject to which the new contents can be written. - Throws:
UnsupportedOperationException- See Also:
-
setNewProperties
Stores the properties for a new version of the cache. Throws an exception if called beforemakeNewVersion()or called twice.- Parameters:
newProps- aPropertiesobject containing the headers of the new version being cached.- Throws:
UnsupportedOperationException- See Also:
-