Q:

why some nodes were not assigned to allocate data on spark?

I am a beginner to the Spark. I made the codes and ran them on the multi nodes.
I have one master node and four worker nodes. I ran my codes multiple times and to my surprise, sometimes some of them did't work and sometimes all the worker nodes worked because they were assigned to have the data that master specified.
I didn't setup any detailed configurations so this behavior looks weired to me.
I want to have all my worker nodes process at the same time to get the better and faster results. How to achieve my requirement?
I attached my codes and commands. It is very straightforward so I skipped detailed explanation. Thanks.
import org.apache.spark.SparkConf;
import org.apache.spark.api.java.JavaRDD;
import org.apache.spark.api.java.JavaSparkContext;
import org.apache.spark.api.java.function.FlatMapFunction;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;

/**
 * Created by dst on 2/1/17.
 */

public class Test {
    public static void main(String[] args) throws Exception {
        String inputFile = args[0];
        String outputFile = args[1];
        SparkConf conf = new SparkConf().setAppName("Data Transformation")
                .set("spark.serializer","org.apache.spark.serializer.KryoSerializer");

        JavaSparkContext sc = new JavaSparkContext(conf);

        JavaRDD<String> lines = sc.textFile(inputFile);

        JavaRDD<String> newLine = lines.flatMap(new FlatMapFunction<String, String>() {
            public Iterator<String> call(String s) throws Exception {
                List<String> ret = new ArrayList<String>();
                List<String> ls = Arrays.asList(s.split("\t"));

                String values = ls.get(ls.size()-1);
                List<String> value = Arrays.asList(values.split("\\|"));

                for(int i=0;i<value.size();++i){
                    String ns = ls.get(0)+"\t"+ls.get(1)+"\t"+ls.get(2)+"\t"+ls.get(3)+"\t"+ls.get(4)+"\t"+ls.get(5);
                    ns = ns + "\t" + value.get(i);
                    ret.add(ns);
                }
                return ret.iterator();
            }
        });

        newLine.saveAsTextFile(outputFile);
    }
}

Spark-submit.
spark-submit \
        --class Test \
        --master spark://spark.dso.xxxx \
        --executor-memory 10G \
        /home/jumbo/user/sclee/dt/jars/dt_01_notcache-1.0-SNAPSHOT.jar \
        /user/sclee/data/ /user/sclee/output

A:

Referring to documentation try setting spark.deploy.spreadOut = false and the behavior will remain same after this setting. 

