Package bbflow
Class ff_farm<T,U>
java.lang.Object
bbflow.block<T,U>
bbflow.ff_node<T,U>
bbflow.ff_farm<T,U>
- Type Parameters:
T
- Custom type inputU
- Custom type output
Fundamental block modeling the Farm paradigm
Composed by one emitter (single input by default), n_workers workers and one collector
Worker must be implemented; the function runJob or runJobMulti contains the computation part. See details below or the thesis
Collector has by default one output channel
If collector is not needed and the job ends in the workers, just avoid sending data to the channel between workers and collector, and it will be ignored
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate int
-
Constructor Summary
ConstructorsConstructorDescriptionff_farm
(int n_workers, defaultJob<T, U> worker_job) Create a new farm with default Emitter in ROUNDROBING and Collector in ROUNDROBINff_farm
(int n_workers, defaultJob<T, U> worker_job, int emitter_strategy) Create a new farm with Emitter in 'emitter_strategy' and default Collector in ROUNDROBINff_farm
(int n_workers, defaultJob<T, U> workerJob, int emitter_strategy, int collector_strategy, int bufferSize) constructor for workerJob of anonymous typeff_farm
(LinkedList<defaultJob<T, U>> worker_job) constructor given a list of defaultJobff_farm
(LinkedList<defaultJob<T, U>> worker_job, int emitter_strategy) constructor given a list of defaultJob and the Emitter strategyff_farm
(LinkedList<defaultJob<T, U>> worker_job, int emitter_strategy, int collector_strategy, int bufferSize) constructor given a list of defaultJob, Emitter strategy, Collector strategy and buffer size -
Method Summary
Modifier and TypeMethodDescriptionvoid
addInputChannel
(ff_queue<T> input) add a new input channel to the farm (commonly one) - to the emittervoid
addOutputChannel
(ff_queue<U> output) add a new output channel to the collectorvoid
connect emitter to workers creating channelsvoid
connect workers to the collector creating channelsprivate void
create_farm
(LinkedList<defaultJob<T, U>> worker_job, int emitter_strategy, int collector_strategy, int bufferSize) constructor given a list of defaultJob and the Emitter strategyvoid
join()
wait the farm to finish after EOS sent in the networkstatic void
preload()
void
pushElement
(T i) Push element inside input stream at the bottom of the listvoid
remove Collector from farm, including channels between workers and collectorvoid
remove Emitter from farm, including channels between emitter and workersvoid
start()
main method to start all farm threadsMethods inherited from class bbflow.ff_node
getInputChannel, getOutputChannel, removeInputChannel, removeOutputChannel
-
Field Details
-
emitter
-
collector
-
workers
-
input
-
bufferSize
private int bufferSize
-
-
Constructor Details
-
ff_farm
public ff_farm(LinkedList<defaultJob<T, U>> worker_job, int emitter_strategy, int collector_strategy, int bufferSize) constructor given a list of defaultJob, Emitter strategy, Collector strategy and buffer size- Parameters:
worker_job
- the list of jobs (one for each worker) to be executed of type bbflow.defaultJob. They can be different if neededemitter_strategy
- Emitter communication strategy chosen between ROUNDROBIN, SCATTER and BROADCASTcollector_strategy
- Collector communication strategy chosen between FIRSTCOME, ROUNDROBIN and GATHER
-
ff_farm
constructor given a list of defaultJob and the Emitter strategy- Parameters:
worker_job
- list of defaultJobemitter_strategy
- Emitter strategy between ROUNDROBIN, SCATTER, BROADCAST
-
ff_farm
constructor given a list of defaultJob- Parameters:
worker_job
- list of defaultJob
-
ff_farm
public ff_farm(int n_workers, defaultJob<T, U> workerJob, int emitter_strategy, int collector_strategy, int bufferSize) constructor for workerJob of anonymous type- Parameters:
n_workers
- number of workersworkerJob
- worker_job the worker job declared inline (as anonymous class)emitter_strategy
- emitter strategy between ROUNDROBIN, SCATTER, BROADCASTcollector_strategy
- collector strategy between ROUNDROBIN, FIRSTCOME, GATHERbufferSize
- buffer size of channels
-
ff_farm
Create a new farm with Emitter in 'emitter_strategy' and default Collector in ROUNDROBIN- Parameters:
n_workers
- number of workersworker_job
- the worker job declared inline (as anonymous class)emitter_strategy
- emitter strategy between ROUNDROBIN, SCATTER, BROADCAST
-
ff_farm
Create a new farm with default Emitter in ROUNDROBING and Collector in ROUNDROBIN- Parameters:
n_workers
- number of workersworker_job
- the worker job declared inline (as anonymous class)
-
-
Method Details
-
preload
public static void preload() -
create_farm
private void create_farm(LinkedList<defaultJob<T, U>> worker_job, int emitter_strategy, int collector_strategy, int bufferSize) constructor given a list of defaultJob and the Emitter strategy- Parameters:
worker_job
- list of defaultJobemitter_strategy
- Emitter strategy between ROUNDROBIN, SCATTER, BROADCASTcollector_strategy
- Collector strategy between ROUNDROBIN, FIRSTCOME, GATHERbufferSize
- buffer size of channels
-
connectEmitterWorkers
public void connectEmitterWorkers()connect emitter to workers creating channels -
connectWorkersCollector
public void connectWorkersCollector()connect workers to the collector creating channels -
start
public void start()main method to start all farm threads -
join
public void join()wait the farm to finish after EOS sent in the network -
pushElement
Push element inside input stream at the bottom of the list- Parameters:
i
- element to push- Throws:
InterruptedException
-
addInputChannel
add a new input channel to the farm (commonly one) - to the emitter- Overrides:
addInputChannel
in classff_node<T,
U> - Parameters:
input
- input channel
-
addOutputChannel
add a new output channel to the collector- Overrides:
addOutputChannel
in classff_node<T,
U> - Parameters:
output
- output channel
-
removeEmitter
public void removeEmitter()remove Emitter from farm, including channels between emitter and workers -
removeCollector
public void removeCollector()remove Collector from farm, including channels between workers and collector
-