Class FetchBin


  • public class FetchBin
    extends java.lang.Object
    Connection tracking for a bin. This class keeps track of information needed to figure out fetch rate throttling for connections, on a bin-by-bin basis. NOTE WELL: This is entirely local in operation
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      protected static class  FetchBin.SumClass  
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.lang.String binName
      This is the bin name which this connection pool belongs to
      protected boolean isAlive
      This is set to true until the bin is shut down.
      protected long lastFetchTime
      This is the last time a fetch was done on this bin
      protected long localMinimum
      The local minimum time between fetches
      protected long minTimeBetweenFetches
      This is the minimum time between fetches for this bin, in ms.
      protected boolean reserveNextFetch
      Is the next fetch reserved?
      protected java.lang.String serviceName
      The (anonymous) service name
      protected java.lang.String serviceTypeName
      Service type name
      protected static java.lang.String serviceTypePrefix
      The service type prefix for fetch bins
      protected java.lang.String targetCalcLockName
      The target calculation lock name
      protected static java.lang.String targetCalcLockPrefix
      The target calculation lock prefix
    • Constructor Summary

      Constructors 
      Constructor Description
      FetchBin​(IThreadContext threadContext, java.lang.String throttlingGroupName, java.lang.String binName)
      Constructor.
    • Field Detail

      • isAlive

        protected boolean isAlive
        This is set to true until the bin is shut down.
      • binName

        protected final java.lang.String binName
        This is the bin name which this connection pool belongs to
      • serviceTypeName

        protected final java.lang.String serviceTypeName
        Service type name
      • serviceName

        protected final java.lang.String serviceName
        The (anonymous) service name
      • targetCalcLockName

        protected final java.lang.String targetCalcLockName
        The target calculation lock name
      • minTimeBetweenFetches

        protected long minTimeBetweenFetches
        This is the minimum time between fetches for this bin, in ms.
      • localMinimum

        protected long localMinimum
        The local minimum time between fetches
      • lastFetchTime

        protected long lastFetchTime
        This is the last time a fetch was done on this bin
      • reserveNextFetch

        protected boolean reserveNextFetch
        Is the next fetch reserved?
      • serviceTypePrefix

        protected static final java.lang.String serviceTypePrefix
        The service type prefix for fetch bins
        See Also:
        Constant Field Values
      • targetCalcLockPrefix

        protected static final java.lang.String targetCalcLockPrefix
        The target calculation lock prefix
        See Also:
        Constant Field Values
    • Method Detail

      • buildServiceTypeName

        protected static java.lang.String buildServiceTypeName​(java.lang.String throttlingGroupName,
                                                               java.lang.String binName)
      • buildTargetCalcLockName

        protected static java.lang.String buildTargetCalcLockName​(java.lang.String throttlingGroupName,
                                                                  java.lang.String binName)
      • getBinName

        public java.lang.String getBinName()
        Get the bin name.
      • updateMinTimeBetweenFetches

        public void updateMinTimeBetweenFetches​(long minTimeBetweenFetches)
        Update the maximum number of active connections.
      • reserveFetchRequest

        public boolean reserveFetchRequest​(IBreakCheck breakCheck)
                                    throws java.lang.InterruptedException,
                                           BreakException
        Reserve a request to fetch a document from this bin. The actual fetch is not yet committed with this call, but if it succeeds for all bins associated with the document, then the caller has permission to do the fetch, and can update the last fetch time.
        Returns:
        false if the fetch bin is being shut down.
        Throws:
        java.lang.InterruptedException
        BreakException
      • clearReservation

        public void clearReservation()
        Clear reserved request.
      • waitNextFetch

        public boolean waitNextFetch​(IBreakCheck breakCheck)
                              throws java.lang.InterruptedException,
                                     BreakException
        Wait the necessary time to do the fetch. Presumes we've reserved the next fetch rights already, via reserveFetchRequest().
        Returns:
        false if the wait did not complete because the bin was shut down.
        Throws:
        java.lang.InterruptedException
        BreakException
      • unpackTarget

        protected static double unpackTarget​(byte[] data)
      • unpackEarliestTime

        protected static long unpackEarliestTime​(byte[] data)
      • pack

        protected static byte[] pack​(double targetDouble,
                                     long earliestTime)