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 and Description |
---|
AssignmentDistributionService() |
Modifier and Type | Method and Description |
---|---|
void |
addAssignmentsForNode(String node,
String host,
Integer serverPort,
SupervisorAssignments assignments)
Add an assignments for a node/supervisor for distribution.
|
void |
addLocalSupervisor(Supervisor supervisor) |
void |
close() |
Map |
getConf() |
static AssignmentDistributionService |
getInstance(Map conf)
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)
Function for initialization.
|
public static AssignmentDistributionService getInstance(Map conf)
Factory method for initialize a instance.
conf
- config.AssignmentDistributionService
public void prepare(Map conf)
Function for initialization.
conf
- configpublic void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
IOException
public void addAssignmentsForNode(String node, String host, Integer serverPort, SupervisorAssignments assignments)
Add an assignments for a node/supervisor for distribution.
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
Get an assignments from the target queue with the specific index.
queueIndex
- index of the queueNodeAssignments
InterruptedException
public boolean isActive()
public Map getConf()
Copyright © 2019 The Apache Software Foundation. All rights reserved.