public class AssignmentDistributionService extends Object implements Closeable
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 and Description |
---|
AssignmentDistributionService() |
Modifier and Type | Method and 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.
|
public static AssignmentDistributionService getInstance(Map conf, INodeAssignmentSentCallBack callback)
conf
- config.callback
- callback for sendAssignment resultsAssignmentDistributionService
public void prepare(Map conf, INodeAssignmentSentCallBack callBack)
conf
- configcallback
- callback for sendAssignment resultspublic void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
IOException
public void addAssignmentsForNode(String node, String host, Integer serverPort, SupervisorAssignments assignments, StormMetricsRegistry metricsRegistry)
node
- node id of supervisor.host
- host name for the node.serverPort
- node thrift server port.assignments
- the SupervisorAssignments
public void addLocalSupervisor(Supervisor supervisor)
public org.apache.storm.nimbus.AssignmentDistributionService.NodeAssignments nextAssignments(Integer queueIndex) throws InterruptedException
queueIndex
- index of the queueNodeAssignments
InterruptedException
public boolean isActive()
public Map getConf()
Copyright © 2023 The Apache Software Foundation. All rights reserved.