apache/storm — pull request #322 by tedxia (2014-11-20 08:08:57+00:00)
Title: STORM-564: Worker use dynamic port

PR for STORM-564

The main change are:
1. Add worker.dynamic.port to indicate whether worker bind dynamic port or not;
2. Add node+port->bind-port in Assignment for tell worker's real bind port;

The whole process are:
1. Worker launch receiver, if worker.dynamic.port set as true, receiver will bind 0, or receiver will bind port specified by supervisor.slots.ports.
2. After receiver launched, set it's real bind port to (:bind-port worker-data);
3. Set up worker heartbeat thread, add (:bind-port worker-data) to executor heartbeat info, this will take (:bind-port) to nimbus;
4. Nimbus generate schedule table periodically:
1) worker.dynamic.port set true: when new schedule table and cur schedule table have common in executor->node+port, nimbus will select the same part and add the corresponding node+port into node+port->bind-port. Here we does't add newly scheduled node+port into node+port->bind-port, because until worker launched receiver and finished it's first heartbeat, nimbus can know the worker's bind port;
2) worker.dynamic.port set false: we will add all node+port in ececutor->node+port (come form new schedule table) into node+port->bind-port, with bind-port is same as port. This make the new version act exactly the same as older version when set worker.synamic.port as false.
5. Worker read nimbus assignment, and it will connect the worker that bind-port not null;