public class CreditBasedFlowControl extends Object implements FlowControl
Modifier and Type | Field and Description |
---|---|
static IntConfOption |
MAX_NUM_OF_OPEN_REQUESTS_PER_WORKER
Maximum number of requests we can have per worker without confirmation
(i.e.
|
static IntConfOption |
MAX_NUM_OF_UNSENT_REQUESTS
Aggregate number of in-memory unsent requests
|
static IntConfOption |
UNSENT_CACHE_WAIT_INTERVAL
Time interval to wait on unsent requests cahce until we find a spot in it
|
Constructor and Description |
---|
CreditBasedFlowControl(ImmutableClassesGiraphConfiguration conf,
NettyClient nettyClient,
Thread.UncaughtExceptionHandler exceptionHandler)
Constructor
|
Modifier and Type | Method and Description |
---|---|
int |
calculateResponse(AckSignalFlag flag,
int taskId)
Calculate/Build the response to piggyback with acknowledgement
|
AckSignalFlag |
getAckSignalFlag(int response)
Get the response flag from a response
|
int |
getNumberOfUnsentRequests() |
void |
logInfo()
Log the status of the flow control
|
void |
messageAckReceived(int taskId,
long requestId,
int response)
Notify the flow control policy that an open request is completed.
|
void |
processResumeSignal(int clientId,
short credit,
long requestId)
Process a resume signal came from a given worker
|
void |
sendRequest(int destTaskId,
WritableRequest request)
This method is called by a network client for all requests that should be
handled by a *remote* task.
|
void |
updateCredit(short newCredit)
Update the max credit that is announced to other workers
|
void |
waitAllRequests()
There may be requests in possession of the flow control mechanism, as the
mechanism controls whether a task should send a request or not.
|
public static final IntConfOption MAX_NUM_OF_OPEN_REQUESTS_PER_WORKER
public static final IntConfOption MAX_NUM_OF_UNSENT_REQUESTS
public static final IntConfOption UNSENT_CACHE_WAIT_INTERVAL
public CreditBasedFlowControl(ImmutableClassesGiraphConfiguration conf, NettyClient nettyClient, Thread.UncaughtExceptionHandler exceptionHandler)
conf
- configurationnettyClient
- netty clientexceptionHandler
- Exception handlerpublic void sendRequest(int destTaskId, WritableRequest request)
FlowControl
sendRequest
in interface FlowControl
destTaskId
- id of the worker to send the request torequest
- request to sendpublic AckSignalFlag getAckSignalFlag(int response)
getAckSignalFlag
in interface FlowControl
response
- response receivedpublic int calculateResponse(AckSignalFlag flag, int taskId)
FlowControl
calculateResponse
in interface FlowControl
flag
- indicating the status of processing of the request (whether it
was a new request or it was a duplicate)taskId
- id of the task the acknowledgement is forpublic void logInfo()
FlowControl
logInfo
in interface FlowControl
public void waitAllRequests()
FlowControl
waitAllRequests
in interface FlowControl
public int getNumberOfUnsentRequests()
getNumberOfUnsentRequests
in interface FlowControl
public void messageAckReceived(int taskId, long requestId, int response)
FlowControl
messageAckReceived
in interface FlowControl
taskId
- id of the task to which the open request is completedrequestId
- id of the open request which is completedresponse
- the response heard from the clientpublic void updateCredit(short newCredit)
newCredit
- new creditpublic void processResumeSignal(int clientId, short credit, long requestId)
clientId
- id of the worker that sent the signalcredit
- the credit value sent along with the resume signalrequestId
- timestamp (request id) of the resume signalCopyright © 2011-2020 The Apache Software Foundation. All Rights Reserved.