Package org.apache.storm.nimbus
Class AssignmentDistributionService
- java.lang.Object
-
- org.apache.storm.nimbus.AssignmentDistributionService
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
public class AssignmentDistributionService extends Object implements Closeable
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
Constructors Constructor Description AssignmentDistributionService()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
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()
Map
getConf()
static AssignmentDistributionService
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.
-
-
-
Method Detail
-
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
public void prepare(Map conf, INodeAssignmentSentCallBack callBack)
Function for initialization.- Parameters:
conf
- config
-
close
public void close() throws IOException
- 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
public void addLocalSupervisor(Supervisor supervisor)
-
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
public Map getConf()
-
-