Package org.apache.storm.nimbus
Class AssignmentDistributionService
java.lang.Object
org.apache.storm.nimbus.AssignmentDistributionService
- All Implemented Interfaces:
- Closeable,- AutoCloseable
A service for distributing master assignments to supervisors, this service makes the assignments notification
 asynchronous.
 
We support multiple working threads to distribute assignment, every thread has a queue buffer.
Master will shuffle its node request to the queues, if the target queue is full, we just discard the request, let the supervisors sync instead.
Caution: this class is not thread safe.
 Working mode
                      +--------+         +-----------------+
                      | queue1 |   ==>   | Working thread1 |
 +--------+ shuffle   +--------+         +-----------------+
 | Master |   ==>
 +--------+           +--------+         +-----------------+
                      | queue2 |   ==>   | Working thread2 |
                      +--------+         +-----------------+
 
 - 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionvoidaddAssignmentsForNode(String node, String host, Integer serverPort, SupervisorAssignments assignments, StormMetricsRegistry metricsRegistry) Add an assignments for a node/supervisor for distribution.voidaddLocalSupervisor(Supervisor supervisor) voidclose()getConf()getInstance(Map conf, INodeAssignmentSentCallBack callback) Factory method for initialize a instance.booleanisActive()org.apache.storm.nimbus.AssignmentDistributionService.NodeAssignmentsnextAssignments(Integer queueIndex) Get an assignments from the target queue with the specific index.voidprepare(Map conf, INodeAssignmentSentCallBack callBack) Function for initialization.
- 
Constructor Details- 
AssignmentDistributionServicepublic AssignmentDistributionService()
 
- 
- 
Method Details- 
getInstancepublic static AssignmentDistributionService getInstance(Map conf, INodeAssignmentSentCallBack callback) Factory method for initialize a instance.- Parameters:
- conf- config.
- callback- callback for sendAssignment results
- Returns:
- an instance of AssignmentDistributionService
 
- 
prepareFunction for initialization.- Parameters:
- conf- config
 
- 
close- Specified by:
- closein interface- AutoCloseable
- Specified by:
- closein interface- Closeable
- Throws:
- IOException
 
- 
addAssignmentsForNodepublic void addAssignmentsForNode(String node, String host, Integer serverPort, SupervisorAssignments assignments, StormMetricsRegistry metricsRegistry) Add an assignments for a node/supervisor for distribution.- Parameters:
- node- node id of supervisor.
- host- host name for the node.
- serverPort- node thrift server port.
- assignments- the- SupervisorAssignments
 
- 
addLocalSupervisor
- 
nextAssignmentspublic org.apache.storm.nimbus.AssignmentDistributionService.NodeAssignments nextAssignments(Integer queueIndex) throws InterruptedException Get an assignments from the target queue with the specific index.- Parameters:
- queueIndex- index of the queue
- Returns:
- an AssignmentDistributionService.NodeAssignments
- Throws:
- InterruptedException
 
- 
isActivepublic boolean isActive()
- 
getConf
 
-