Interface RepositoryNode

All Superinterfaces:
RepositoryNodeVersion

public interface RepositoryNode extends RepositoryNodeVersion
RepositoryNode is used to store the contents and meta-information of urls being cached.
  • 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:
      hasContent in interface RepositoryNodeVersion
      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:
      getContentSize in interface RepositoryNodeVersion
      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 return
      calcIfUnknown - 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

      Iterator listChildren(org.lockss.daemon.CachedUrlSetSpec filter, boolean includeInactive)
      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 return
      includeInactive - true to include inactive nodes
      Returns:
      an Iterator of 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 before makeNewVersion() or if either getNewOutputStream() or setNewProperties() has not been called.
      Throws:
      UnsupportedOperationException
    • abandonNewVersion

      void abandonNewVersion()
      Discards the currently open new version without writing. Throws an exception if called before makeNewVersion()
      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, call restoreLastVersion() or make a new version.
      Throws:
      UnsupportedOperationException
    • markAsDeleted

      void markAsDeleted()
      Marks the node as deleted. This also calls deactivateContent(). To reactivate, call restoreLastVersion() or make a new version (which gives it content), or call markAsNotDeleted().
    • 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 by getNodeInfo(). 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

      RepositoryNodeVersion[] getNodeVersions(int maxVersions)
      Return an array of RepositoryNodeVersion for the most recent maxVersions 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
    • getNodeVersion

      RepositoryNodeVersion getNodeVersion(int version)
      Return a RepositoryNodeVersion for the specified content version
      Returns:
      a RepositoryNodeVersion bound to the specified version
      Throws:
      UnsupportedOperationException - if node has no versions
    • getNodeContents

      Return a RepositoryNodeContents object which accesses the content in the cache and its properties. Throws if called on a content-less or inactive node.
      Specified by:
      getNodeContents in interface RepositoryNodeVersion
      Returns:
      an RepositoryNode.RepositoryNodeContents object from which the contents of the cache can be read.
      Throws:
      UnsupportedOperationException
    • getUnsealedRnc

      Return a RepositoryNodeContents object 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.RepositoryNodeContents object from which the contents of the unsealed node can be read.
      Throws:
      UnsupportedOperationException
    • getNewOutputStream

      OutputStream getNewOutputStream()
      Return an OutputStream object which writes to a new version in the cache. Throws an exception if called before makeNewVersion() or called twice.
      Returns:
      an OutputStream object to which the new contents can be written.
      Throws:
      UnsupportedOperationException
      See Also:
    • setNewProperties

      void setNewProperties(Properties newProps)
      Stores the properties for a new version of the cache. Throws an exception if called before makeNewVersion() or called twice.
      Parameters:
      newProps - a Properties object containing the headers of the new version being cached.
      Throws:
      UnsupportedOperationException
      See Also: