Class Heartbeat


  • public final class Heartbeat
    extends Object
    Incapsulates functionality for preventing connecting several servers to one data dir/database.
    Author:
    Leonid Bushuev from JetBrains
    • Method Detail

      • getStartingCodeFileDir

        @NotNull
        public static File getStartingCodeFileDir​(@NotNull
                                                  ServerPaths serverPaths)
      • switchToMainNode

        public boolean switchToMainNode()
                                 throws jetbrains.buildServer.serverSide.db.Heartbeat.CaptureError
        Returns:
        true if the node was switched in main server mode or if the node already was in mainserver mode
        Throws:
        jetbrains.buildServer.serverSide.db.Heartbeat.CaptureError - if node was unable to capture main server lock and then was unable to switch back into secondary node mode
      • capture

        public void capture()
                     throws jetbrains.buildServer.serverSide.db.Heartbeat.CaptureError
        Throws:
        jetbrains.buildServer.serverSide.db.Heartbeat.CaptureError
      • tryGetExclusiveLock

        public boolean tryGetExclusiveLock()
      • releaseExclusiveLock

        public void releaseExclusiveLock()
      • updateUUID

        public void updateUUID​(@Nullable
                               String uuid)
        Just set the field; will be updated in DB during next pulse() call.
      • updateUrl

        public void updateUrl​(@Nullable
                              String url)
        Just set the field; will be updated in DB during next pulse() call.
      • updateEffectiveResponsibilities

        public void updateEffectiveResponsibilities​(@NotNull
                                                    Collection<NodeResponsibility> effectiveResponsibilities)
      • removeResponsibility

        public void removeResponsibility​(@NotNull
                                         NodeResponsibility responsibility)
      • release

        public void release()
      • prepareLockForReleasing

        public void prepareLockForReleasing()
      • isActive

        public boolean isActive()
      • getException

        @Nullable
        public Throwable getException()
      • getCurrentSession

        public SessionInfo getCurrentSession()
      • getValidSessions

        @NotNull
        public List<SessionInfo> getValidSessions()
        Returns:
        list of currently active heartbeat sessions; the first session in the list always corresponds to current server.
      • isReadOnly

        public boolean isReadOnly()