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 Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addAssignmentsForNode
(String node, String host, Integer serverPort, SupervisorAssignments assignments, StormMetricsRegistry metricsRegistry) Add an assignments for a node/supervisor for distribution.void
addLocalSupervisor
(Supervisor supervisor) void
close()
getConf()
getInstance
(Map conf, INodeAssignmentSentCallBack callback) Factory method for initialize a instance.boolean
isActive()
org.apache.storm.nimbus.AssignmentDistributionService.NodeAssignments
nextAssignments
(Integer queueIndex) Get an assignments from the target queue with the specific index.void
prepare
(Map conf, INodeAssignmentSentCallBack callBack) Function for initialization.
-
Constructor Details
-
AssignmentDistributionService
public AssignmentDistributionService()
-
-
Method Details
-
getInstance
public 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
-
prepare
Function for initialization.- Parameters:
conf
- config
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
-
addAssignmentsForNode
public 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
- theSupervisorAssignments
-
addLocalSupervisor
-
nextAssignments
public 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
-
isActive
public boolean isActive() -
getConf
-