Class FetchBin
- java.lang.Object
-
- org.apache.manifoldcf.connectorcommon.throttler.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 toprotected 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 binprotected long
localMinimum
The local minimum time between fetchesprotected 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 nameprotected java.lang.String
serviceTypeName
Service type nameprotected static java.lang.String
serviceTypePrefix
The service type prefix for fetch binsprotected java.lang.String
targetCalcLockName
The target calculation lock nameprotected 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.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected static java.lang.String
buildServiceTypeName(java.lang.String throttlingGroupName, java.lang.String binName)
protected static java.lang.String
buildTargetCalcLockName(java.lang.String throttlingGroupName, java.lang.String binName)
void
clearReservation()
Clear reserved request.java.lang.String
getBinName()
Get the bin name.protected static byte[]
pack(double targetDouble, long earliestTime)
void
poll(IThreadContext threadContext)
Poll this binboolean
reserveFetchRequest(IBreakCheck breakCheck)
Reserve a request to fetch a document from this bin.void
shutDown(IThreadContext threadContext)
Shut the bin down, and wake up all threads waiting on it.protected static long
unpackEarliestTime(byte[] data)
protected static double
unpackTarget(byte[] data)
void
updateMinTimeBetweenFetches(long minTimeBetweenFetches)
Update the maximum number of active connections.boolean
waitNextFetch(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.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
-
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)
-
-