Class RepositoryData

  • public final class RepositoryData
    extends java.lang.Object
    A class that represents the data in a repository, as captured in the repository's index blob.
    • Field Summary

      Modifier and Type Field Description
      static RepositoryData EMPTY
      An instance initialized for an empty repository.
      static long EMPTY_REPO_GEN
      The generation value indicating the repository has no index generational files.
    • Constructor Summary

      Constructor Description
      RepositoryData​(long genId, java.util.Map<java.lang.String,​SnapshotId> snapshotIds, java.util.Map<java.lang.String,​SnapshotState> snapshotStates, java.util.Map<IndexId,​java.util.Set<SnapshotId>> indexSnapshots)  
    • Field Detail


        public static final long EMPTY_REPO_GEN
        The generation value indicating the repository has no index generational files.
        See Also:
        Constant Field Values
      • EMPTY

        public static final RepositoryData EMPTY
        An instance initialized for an empty repository.
    • Constructor Detail

      • RepositoryData

        public RepositoryData​(long genId,
                              java.util.Map<java.lang.String,​SnapshotId> snapshotIds,
                              java.util.Map<java.lang.String,​SnapshotState> snapshotStates,
                              java.util.Map<IndexId,​java.util.Set<SnapshotId>> indexSnapshots)
    • Method Detail

      • getGenId

        public long getGenId()
        Gets the generational index file id from which this instance was read.
      • getSnapshotIds

        public java.util.Collection<SnapshotId> getSnapshotIds()
        Returns an unmodifiable collection of the snapshot ids.
      • getIndices

        public java.util.Map<java.lang.String,​IndexId> getIndices()
        Returns an unmodifiable map of the index names to IndexId in the repository.
      • indicesToUpdateAfterRemovingSnapshot

        public java.util.List<IndexId> indicesToUpdateAfterRemovingSnapshot​(SnapshotId snapshotId)
        Returns the list of IndexId that have their snapshots updated but not removed (because they are still referenced by other snapshots) after removing the given snapshot from the repository.
        snapshotId - SnapshotId to remove
        List of indices that are changed but not removed
      • addSnapshot

        public RepositoryData addSnapshot​(SnapshotId snapshotId,
                                          SnapshotState snapshotState,
                                          java.util.List<IndexId> snapshottedIndices)
        Add a snapshot and its indices to the repository; returns a new instance. If the snapshot already exists in the repository data, this method throws an IllegalArgumentException.
      • withGenId

        public RepositoryData withGenId​(long newGeneration)
        Create a new instance with the given generation and all other fields equal to this instance.
        newGeneration - New Generation
        New instance
      • removeSnapshot

        public RepositoryData removeSnapshot​(SnapshotId snapshotId)
        Remove a snapshot and remove any indices that no longer exist in the repository due to the deletion of the snapshot.
      • getSnapshots

        public java.util.Set<SnapshotId> getSnapshots​(IndexId indexId)
        Returns an immutable collection of the snapshot ids for the snapshots that contain the given index.
      • equals

        public boolean equals​(java.lang.Object obj)
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        hashCode in class java.lang.Object
      • resolveIndexId

        public IndexId resolveIndexId​(java.lang.String indexName)
        Resolve the index name to the index id specific to the repository, throwing an exception if the index could not be resolved.
      • resolveIndices

        public java.util.List<IndexId> resolveIndices​(java.util.List<java.lang.String> indices)
        Resolve the given index names to index ids.
      • resolveNewIndices

        public java.util.List<IndexId> resolveNewIndices​(java.util.List<java.lang.String> indicesToResolve)
        Resolve the given index names to index ids, creating new index ids for new indices in the repository.
      • snapshotsToXContent

        public XContentBuilder snapshotsToXContent​(XContentBuilder builder)
        Writes the snapshots metadata and the related indices metadata to x-content.
      • snapshotsFromXContent

        public static RepositoryData snapshotsFromXContent​(XContentParser parser,
                                                           long genId)
        Reads an instance of RepositoryData from x-content, loading the snapshots and indices metadata.