Class OwnedRanges


  • public final class OwnedRanges
    extends java.lang.Object
    • Constructor Summary

      Constructors 
      Constructor Description
      OwnedRanges​(java.util.Collection<Range<Token>> ownedRanges)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean validateRangeRequest​(java.util.Collection<Range<Token>> requestedRanges, java.lang.String requestId, java.lang.String requestType, InetAddressAndPort from)
      Check that all ranges in a requested set are contained by those in the owned set.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • OwnedRanges

        public OwnedRanges​(java.util.Collection<Range<Token>> ownedRanges)
    • Method Detail

      • validateRangeRequest

        public boolean validateRangeRequest​(java.util.Collection<Range<Token>> requestedRanges,
                                            java.lang.String requestId,
                                            java.lang.String requestType,
                                            InetAddressAndPort from)
        Check that all ranges in a requested set are contained by those in the owned set. Used in several contexts, such as validating StreamRequests in StreamSession & PrepareMessage and ValidationRequest in RepairMessageVerbHandler. In those callers, we want to verify that the token ranges specified in some request from a peer are not outside the ranges owned by the local node. There are 2 levels of response if invalid ranges are detected, controlled by options in Config; logging the event and rejecting the request and either/neither/both of these options may be enabled. If neither are enabled, we short ciruit and immediately return success without any further processing. If either option is enabled and we do detect unowned ranges in the request, we increment a metric then take further action depending on the config.
        Parameters:
        requestedRanges - the set of token ranges contained in a request from a peer
        requestId - an identifier for the peer request, to be used in logging (e.g. Stream or Repair Session #)
        requestType - description of the request type, to be used in logging (e.g. "prepare request" or "validation")
        from - the originator of the request
        Returns:
        true if the request should be accepted (either because no checking was performed, invalid ranges were identified but only the logging action is enabled, or because all request ranges were valid). Otherwise, returns false to indicate the request should be rejected.