Package bbflow
Class defaultJob<T,U>
java.lang.Object
bbflow.defaultJob<T,U>
- Type Parameters:
T
- Custom type of the channels
- All Implemented Interfaces:
Runnable
- Direct Known Subclasses:
complete_farm_testOutnode
,complete_farm_testWorker
,defaultCollector
,defaultEmitter
,defaultWorker
,myjob
default Job extecuted by the bbflow.ff_node. Should be extended and reimplemented with the custom code. Take a look to examples to choose what you prefer.
check if there are at least one input or output channel
For more details see run() function doc
-
Field Summary
FieldsModifier and TypeFieldDescriptionint
static final int
int
static final int
static final int
int
int
(package private) int
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addInputChannel
(ff_queue<T> input) add new input channel to the Runnable nodevoid
addOutputChannel
(ff_queue<U> output) add new output channel to the Runnable nodevoid
EOS()
EOS() function to overridegetInputChannel
(int index) get input channelgetOutputChannel
(int index) get output channelvoid
init()
function to override called after start()static void
preload()
boolean
removeInputChannel
(int index) remove input channelboolean
removeOutputChannel
(int index) remove output channelvoid
run()
default Runnable run method This method runs only if there are at least 1 input channel and 1 output channel Regarding output channel: if there isn't any node on the other side, just don't send anything in the output channel in runJobvoid
runJob()
blank function that should be overwritten by class extending bbflow.defaultJob.runJob(T element) function to overridevoid
runJobMulti
(T element, LinkedList<ff_queue<U>> channels_output) runJobMulti(T element, LinkedList channels_output) function to overridevoid
sendEOS()
send EOS to all output channelsvoid
sendEOS
(int combined_side) method overwritten by ff_combvoid
send element to the next out channel in ROUNDROBIN mannervoid
void
send element to the channel 'index'void
void
sendOutToAll
(U element) send element to all output channelsvoid
setId
(int id) set idstatic defaultJob
uniqueJob
(defaultJob obj) function to clone an object, using serializationstatic defaultJob
uniqueJob
(defaultJob obj, int id) clone a defaultJob and make it unique (it's not a reference).
-
Field Details
-
in
-
out
-
CUSTOM_FUNCTION
public static final int CUSTOM_FUNCTION- See Also:
-
INLINE
public static final int INLINE- See Also:
-
INLINE_MULTI
public static final int INLINE_MULTI- See Also:
-
runType
public int runType -
id
public int id -
position
public int position -
combined
-
combined_side
public int combined_side -
sendpos
int sendpos
-
-
Constructor Details
-
defaultJob
public defaultJob() -
defaultJob
public defaultJob(int id) default constructor- Parameters:
id
- id of the job
-
-
Method Details
-
preload
public static void preload() -
setId
public void setId(int id) set id- Parameters:
id
-
-
init
public void init()function to override called after start() -
uniqueJob
function to clone an object, using serialization- Parameters:
obj
- object to clone- Returns:
- cloned object
-
uniqueJob
clone a defaultJob and make it unique (it's not a reference).- Parameters:
obj
- job to cloneid
- id to assign to the new job- Returns:
- return the new cloned job
-
sendOut
send element to the next out channel in ROUNDROBIN manner- Parameters:
element
- element to send
-
sendOut
-
sendOutTo
-
sendOutToAll
send element to all output channels- Parameters:
element
- element to send
-
sendOutTo
send element to the channel 'index'- Parameters:
element
- element to sendindex
- index of the out channel
-
sendEOS
public void sendEOS()send EOS to all output channels -
sendEOS
public void sendEOS(int combined_side) method overwritten by ff_comb- Parameters:
combined_side
- combined side (left/right)
-
run
public void run()default Runnable run method This method runs only if there are at least 1 input channel and 1 output channel Regarding output channel: if there isn't any node on the other side, just don't send anything in the output channel in runJob -
runJob
public void runJob() throws InterruptedException, InstantiationException, IllegalAccessException, NoSuchMethodException, InvocationTargetExceptionblank function that should be overwritten by class extending bbflow.defaultJob. Here main computation task is done once we're sure there's data in at least one of the input channels Lists 'in' and 'out' must be used manually and EOS() must be managed by the user. -
runJob
public U runJob(T element) throws InterruptedException, InstantiationException, IllegalAccessException, NoSuchMethodException, InvocationTargetException runJob(T element) function to override- Parameters:
element
- element received from first input channel- Returns:
- return element to send to the first output channel or null if nothing
- Throws:
InterruptedException
InstantiationException
IllegalAccessException
NoSuchMethodException
InvocationTargetException
-
runJobMulti
runJobMulti(T element, LinkedList channels_output) function to override- Parameters:
element
- element received from input in ROUNDROBINchannels_output
- output channels list is manual usage needed. sendOut, sendOutTo, sendOutToAll available anyway.
-
addInputChannel
add new input channel to the Runnable node- Parameters:
input
- input channel
-
addOutputChannel
add new output channel to the Runnable node- Parameters:
output
- output channel
-
removeInputChannel
public boolean removeInputChannel(int index) remove input channel- Parameters:
index
- index to remove- Returns:
- result
-
removeOutputChannel
public boolean removeOutputChannel(int index) remove output channel- Parameters:
index
- index to remove- Returns:
- result
-
getOutputChannel
get output channel- Parameters:
index
- index to get- Returns:
- queue requested or null
-
getInputChannel
get input channel- Parameters:
index
- index to get- Returns:
- queue requested or null
-
EOS
public void EOS()EOS() function to override
-