Class FetchBin
- java.lang.Object
-
- org.apache.manifoldcf.connectorcommon.throttler.FetchBin
-
public class FetchBin extends java.lang.ObjectConnection 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 classFetchBin.SumClass
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.StringbinNameThis is the bin name which this connection pool belongs toprotected booleanisAliveThis is set to true until the bin is shut down.protected longlastFetchTimeThis is the last time a fetch was done on this binprotected longlocalMinimumThe local minimum time between fetchesprotected longminTimeBetweenFetchesThis is the minimum time between fetches for this bin, in ms.protected booleanreserveNextFetchIs the next fetch reserved?protected java.lang.StringserviceNameThe (anonymous) service nameprotected java.lang.StringserviceTypeNameService type nameprotected static java.lang.StringserviceTypePrefixThe service type prefix for fetch binsprotected java.lang.StringtargetCalcLockNameThe target calculation lock nameprotected static java.lang.StringtargetCalcLockPrefixThe target calculation lock prefix
-
Constructor Summary
Constructors Constructor Description FetchBin(IThreadContext threadContext, java.lang.String throttlingGroupName, java.lang.String binName)Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected static java.lang.StringbuildServiceTypeName(java.lang.String throttlingGroupName, java.lang.String binName)protected static java.lang.StringbuildTargetCalcLockName(java.lang.String throttlingGroupName, java.lang.String binName)voidclearReservation()Clear reserved request.java.lang.StringgetBinName()Get the bin name.protected static byte[]pack(double targetDouble, long earliestTime)voidpoll(IThreadContext threadContext)Poll this binbooleanreserveFetchRequest(IBreakCheck breakCheck)Reserve a request to fetch a document from this bin.voidshutDown(IThreadContext threadContext)Shut the bin down, and wake up all threads waiting on it.protected static longunpackEarliestTime(byte[] data)protected static doubleunpackTarget(byte[] data)voidupdateMinTimeBetweenFetches(long minTimeBetweenFetches)Update the maximum number of active connections.booleanwaitNextFetch(IBreakCheck breakCheck)Wait the necessary time to do the fetch.
-
-
-
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
-
-
Constructor Detail
-
FetchBin
public FetchBin(IThreadContext threadContext, java.lang.String throttlingGroupName, java.lang.String binName) throws ManifoldCFException
Constructor.- Throws:
ManifoldCFException
-
-
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.InterruptedExceptionBreakException
-
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.InterruptedExceptionBreakException
-
poll
public void poll(IThreadContext threadContext) throws ManifoldCFException
Poll this bin- Throws:
ManifoldCFException
-
shutDown
public void shutDown(IThreadContext threadContext) throws ManifoldCFException
Shut the bin down, and wake up all threads waiting on it.- Throws:
ManifoldCFException
-
unpackTarget
protected static double unpackTarget(byte[] data)
-
unpackEarliestTime
protected static long unpackEarliestTime(byte[] data)
-
pack
protected static byte[] pack(double targetDouble, long earliestTime)
-
-