Esempio n. 1
0
func (w *Worker) runStage(pwd string, prefix string, process Process) {
	output, err := ioutil.TempFile(pwd, prefix)
	output_name := output.Name()
	Check(err)
	defer output.Close()
	locations := make([]string, len(w.inputs))
	for i, input := range w.inputs {
		locations[i] = input.replica_location
	}

	readCloser := jobutil.AddressReader(locations, jobutil.Setting("DISCO_DATA"))
	process(readCloser, output)
	readCloser.Close()

	fileinfo, err := output.Stat()
	Check(err)

	w.outputs = make([]*Output, 1)
	w.outputs[0] = new(Output)

	absDiscoPath, err := filepath.EvalSymlinks(w.task.Disco_data)
	Check(err)
	w.outputs[0].output_location =
		"disco://" + jobutil.Setting("HOST") + "/disco/" + output_name[len(absDiscoPath)+1:]
	w.outputs[0].output_size = fileinfo.Size()
}
Esempio n. 2
0
func get_results(master string, jobname string) {
	outputs, err := jobutil.Wait(master, jobname, 20)
	Check(err)

	disco_root := jobutil.Setting("DISCO_ROOT")
	readCloser := jobutil.AddressReader(outputs, disco_root+"/data")
	defer readCloser.Close()
	scanner := bufio.NewScanner(readCloser)
	for scanner.Scan() {
		fmt.Println(scanner.Text())
	}
	if err := scanner.Err(); err != nil {
		log.Fatal(err)
	}
}
Esempio n. 3
0
func get_results(master string, jobname string) {
	outputs, err := jobutil.Wait(master, jobname, 20)
	Check(err)

	disco_root := jobutil.Setting("DISCO_ROOT")
	readCloser := jobutil.AddressReader(outputs, disco_root+"/data")
	defer readCloser.Close()

	reader := bufio.NewReader(readCloser)
	err = nil
	line := []byte("")
	for err == nil {
		thisRead, isPrefix, thisErr := reader.ReadLine()
		err = thisErr
		line = append(line, thisRead...)
		if !isPrefix {
			fmt.Println(string(line))
			line = []byte("")
		}
	}
	if err != io.EOF {
		log.Fatal(err)
	}
}