Hi,
I have a function that has a static variable which is defined in the constructor. But when the function is operating, the defined variable is not passed to slave nodes.
I would really appreciate if anyone can advice me on if I am setting the variable correctly, and if this is the expected behavior. Thanks in advance.
Context: my cascading job is executed on AWS EMR, using Cascading 2.6.
The output is:
flag at MyFunction(): true
flag at prepare(): false
flag at operate(): false // repeat n times, n is number of tuples
flag at cleanup(): false
The function is triggered by:
Pipe pipe = new Each(sourcePipe, Fields.ALL, new MyFunction(true), Fields.ALL);
And the function looks like this:
public class MyFunction extends BaseOperation<Tuple> implements Function<Tuple> {
private static boolean flag = false;
public MyFunction(boolean flag) {
MyFunction.flag = flag;
System.out.println("flag at MyFunction(): " + flag);
}
@Override
public void prepare(FlowProcess flowProcess, OperationCall<Tuple> operationCall) {
System.out.println("flag at prepare(): " + flag);
}
@Override
public void operate(FlowProcess flowProcess, FunctionCall<Tuple> functionCall) {
System.out.println("flag at operate(): " + flag);
}
@Override
public void cleanup(FlowProcess flowProcess, OperationCall<Tuple> operationCall) {
System.out.println("flag at cleanup(): " + flag)
}
}