|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.util.TimerTask
org.red5.server.stream.SimpleBWControlService
public class SimpleBWControlService
A simple implementation of bandwidth controller. The initial burst, if not specified by user, is half of the property "defaultCapacity".
Following is the reference information for the future optimization on threading: The threads that may access this object concurrently are: * Thread A that makes token request. * Thread B that makes token request. * Thread C that distributes tokens and call the callbacks. (Timer) * Thread D that updates the bw config of a controllable. * Thread E that resets a bucket. * Thread F that unregisters a controllable. The implementation now synchronizes on each context to make sure only one thread is accessing the context object at a time.
Nested Class Summary | |
---|---|
protected class |
SimpleBWControlService.BWContext
|
protected class |
SimpleBWControlService.TokenRequest
|
protected class |
SimpleBWControlService.TokenRequestContext
|
protected static class |
SimpleBWControlService.TokenRequestType
|
Field Summary | |
---|---|
protected Map<IBWControllable,SimpleBWControlService.BWContext> |
contextMap
|
protected long |
defaultCapacity
|
protected long |
interval
|
protected Timer |
tokenDistributor
|
Fields inherited from interface org.red5.server.stream.IBWControlService |
---|
KEY |
Constructor Summary | |
---|---|
SimpleBWControlService()
|
Method Summary | |
---|---|
ITokenBucket |
getAudioBucket(IBWControlContext context)
Return the token bucket for audio channel. |
ITokenBucket |
getDataBucket(IBWControlContext context)
Return the token bucket for data channel. |
ITokenBucket |
getVideoBucket(IBWControlContext context)
Return the token bucket for video channel. |
void |
init()
|
protected void |
invokeCallback(SimpleBWControlService.BWContext context)
|
IBWControlContext |
lookupContext(IBWControllable bc)
Lookup the registry context according to the controllable. |
protected boolean |
processRequest(SimpleBWControlService.TokenRequest request)
|
IBWControlContext |
registerBWControllable(IBWControllable bc)
Register a bandwidth controllable. |
void |
resetBuckets(IBWControlContext context)
Reset all the token buckets for a controllable. |
protected void |
rollbackRequest(SimpleBWControlService.TokenRequest request)
Give back the acquired tokens due to failing to accomplish the requested operation or over-charged tokens in the case of best-effort request. |
void |
run()
|
void |
setDefaultCapacity(long capacity)
|
void |
setInterval(long interval)
|
void |
shutdown()
|
void |
unregisterBWControllable(IBWControlContext context)
Unregister the bandwidth controllable. |
void |
updateBWConfigure(IBWControlContext context)
Update the bandwidth configuration of a controllable. |
Methods inherited from class java.util.TimerTask |
---|
cancel, scheduledExecutionTime |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected Map<IBWControllable,SimpleBWControlService.BWContext> contextMap
protected Timer tokenDistributor
protected long interval
protected long defaultCapacity
Constructor Detail |
---|
public SimpleBWControlService()
Method Detail |
---|
public void init()
public void shutdown()
public void run()
run
in interface Runnable
run
in class TimerTask
public ITokenBucket getAudioBucket(IBWControlContext context)
IBWControlService
getAudioBucket
in interface IBWControlService
context
- The registry context.
public ITokenBucket getVideoBucket(IBWControlContext context)
IBWControlService
getVideoBucket
in interface IBWControlService
context
- The registry context.
public ITokenBucket getDataBucket(IBWControlContext context)
IBWControlService
getDataBucket
in interface IBWControlService
context
- The registry context.
public IBWControlContext registerBWControllable(IBWControllable bc)
IBWControlService
registerBWControllable
in interface IBWControlService
bc
- The bandwidth controllable.
public void resetBuckets(IBWControlContext context)
IBWControlService
resetBuckets
in interface IBWControlService
context
- The registry context.public void unregisterBWControllable(IBWControlContext context)
IBWControlService
unregisterBWControllable
in interface IBWControlService
context
- The registry context.public IBWControlContext lookupContext(IBWControllable bc)
IBWControlService
lookupContext
in interface IBWControlService
bc
- The bandwidth controllable.
public void updateBWConfigure(IBWControlContext context)
IBWControlService
updateBWConfigure
in interface IBWControlService
context
- The registry context.public void setInterval(long interval)
public void setDefaultCapacity(long capacity)
protected boolean processRequest(SimpleBWControlService.TokenRequest request)
protected void invokeCallback(SimpleBWControlService.BWContext context)
protected void rollbackRequest(SimpleBWControlService.TokenRequest request)
request
-
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |