Class MergeRegionRequest

java.lang.Object
me.tayebyassine.homestead.sessions.MergeRegionRequest

public final class MergeRegionRequest extends Object
Tracks pending merge requests between regions.

A merge request is created when a region owner initiates a merge with another region. The request expires after 60 seconds if not accepted.

  • Field Details

    • REQUESTS

      public static final Map<Long,Long> REQUESTS
      Maps source region ID to target region ID.
  • Method Details

    • newMergeRequest

      public static void newMergeRequest(Region from, Region to)
      Create a new merge request from one region to another.

      If either region already has a pending request (as source or target), the new request is silently ignored.

      Parameters:
      from - the region to merge from (will be deleted on accept)
      to - the region to merge into
    • isFromHaveRequest

      public static boolean isFromHaveRequest(Region from)
      Check whether the given region has a pending merge request as the source.
      Parameters:
      from - the region to check
      Returns:
      true if the region has an outgoing merge request
    • isToHaveRequest

      public static boolean isToHaveRequest(Region to)
      Check whether the given region has a pending merge request as the target.
      Parameters:
      to - the region to check
      Returns:
      true if the region is the target of a merge request
    • getFrom

      public static long getFrom(Region to)
      Get the source region ID for a merge request targeting the given region.
      Parameters:
      to - the target region
      Returns:
      the source region ID, or -1 if no request exists
    • getTo

      public static long getTo(Region from)
      Get the target region ID for a merge request originating from the given region.
      Parameters:
      from - the source region
      Returns:
      the target region ID