Class MissingLastRevSeeker

    • Field Detail

      • clock

        protected final Clock clock
    • Constructor Detail

      • MissingLastRevSeeker

        public MissingLastRevSeeker​(DocumentStore store,
                                    Clock clock)
    • Method Detail

      • getAllClusters

        @NotNull
        public @NotNull java.lang.Iterable<ClusterNodeInfoDocument> getAllClusters()
        Gets the clusters which potentially need _lastRev recovery.
        Returns:
        the clusters
      • getClusterNodeInfo

        @Nullable
        public @Nullable ClusterNodeInfoDocument getClusterNodeInfo​(int clusterId)
        Gets the cluster node info for the given cluster node id.
        Parameters:
        clusterId - the cluster id
        Returns:
        the cluster node info
      • getCandidates

        @NotNull
        public @NotNull java.lang.Iterable<NodeDocument> getCandidates​(long startTime)
        Get the candidates with modified time greater than or equal the specified startTime in milliseconds since the start of the epoch.
        Parameters:
        startTime - the start time in milliseconds.
        Returns:
        the candidates
      • acquireRecoveryLock

        public boolean acquireRecoveryLock​(int clusterId,
                                           int recoveredBy)
        Acquire a recovery lock for the given cluster node info document. This method may break a lock when it determines the cluster node holding the recovery lock is no more active or its lease expired.
        Parameters:
        clusterId - id of the cluster that is going to be recovered
        recoveredBy - id of cluster doing the recovery
        Returns:
        whether the lock has been acquired
      • releaseRecoveryLock

        public void releaseRecoveryLock​(int clusterId,
                                        boolean success)
        Releases the recovery lock on the given clusterId. If success is true, the state of the cluster node entry is reset, otherwise it is left as is. That is, for a cluster node which requires recovery and the recovery process failed, the state will still be active, when this release method is called with success set to false.
        Parameters:
        clusterId - the id of the cluster node that was recovered.
        success - whether recovery was successful.
      • isRecoveryNeeded

        public boolean isRecoveryNeeded()
        Returns true if any of the cluster node info documents satisfies ClusterNodeInfoDocument.isRecoveryNeeded(long) where the passed timestamp is the current time.
        Returns:
        true if any of the cluster nodes need recovery, false otherwise.