Prerequisites
You have compiled REEF locally .The beginning of this tutorial is now managed on the [Apache Wiki](https://cwiki.apache.org/confluence/display/REEF/Compiling+REEF)and set the JAVA_HOME environment variable.
Running your first REEF program: Hello, REEF! (Java)
The module REEF Examples in the folder `reefreef-
examples` examples
contains several simple programs built on REEF to help you get started with development. As always, the simplest of those is our "Hello World": Hello REEF. Upon launch, it grabs a single Evaluator and submits a single Task to it. That Actvity, fittingly, prints 'Hello REEF!' to stdout
. To launch it, navigate to REEF_HOME and use the following command (put the correct number of your REEF version in {$REEF_VERSION}:
Code Block |
---|
|
> java cd -cp lang/java/reef-examples/target/reef-examples
> mvn -PHelloREEF-{$REEF_VERSION}-SNAPSHOT-shaded.jar org.apache.reef.examples.hello.HelloREEF |
This invokes the profile `HelloREEF` in the maven build which shaded jar within the target directory and launches HelloREEF on the local runtime of REEF. During the run, you will see something similar to this output:
Code Block |
---|
language | bash |
---|
collapsetitle | trueOUTPUT |
---|
|
[INFO] Scanning for projects...
[INFO]
[INFO] Using the builder org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder with a thread count of 1
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building REEF Examples 0.10-incubating-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
...
Powered by
Powered by
___________ ______ ______ _______
/ ______ / / ___/ / ___/ / ____/
/ _____/ / /__ / /__ / /___
/ /\ \ / ___/ / ___/ / ____/
/ / \ \ / /__ / /__ / /
/__/ \__\ /_____/ /_____/ /__/
...
INFO: REEF Version: 0.14.0-SNAPSHOT
...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------ |
...
INFO: The Job HelloREEF is running.
...
INFO: The Job HelloREEF is done.
...
INFO: REEF job completed: COMPLETED |
Where's the output?
The local runtime simulates a cluster of machines: It executes each Evaluator in a separate process on your machine. Hence, the Evaluator that printed "Hello, REEF" is not executed in the same process as the program you launched above. So, how do you get to the output of the Evaluator? The local runtime creates one folder per job it executes in a configurable root folder. In our builds, these folders are generated in the `target` folder of the maven build REEF_LOCAL_RUNTIME:
Code Block |
---|
language | bash |
---|
title | REEF LOCAL RUNTIME FOLDER |
---|
|
> cd targetREEF_LOCAL_RUNTIME
> ls Hello*
Mode LastWriteTime Length Name
---- ------------- ------ ----
d---- 810/212/20132015 3:25 PM7:53 AM HelloREEF-13754823384681444603999205 |
The job folder names are comprised of the job's name (here, `HelloREEF` HelloREEF
) and the time stamp of its submission (here, `1375482338468`1444603999205). If you submit the same job multiple times, you will get multiple folders here. Let's move on:
Code Block |
---|
language | bash |
---|
title | REEF LOCAL JOB FOLDER |
---|
|
> cd HelloREEF-13754823384681444603999205
> ls
Mode LastWriteTime Length Name
---- ------------- ------ ----
d---- 8 10/212/20132015 3:25 PM7:53 AM driver
d---- 8 10/212/20132015 3:25 PM7:53 AM Node-12-13754823392661444604000469 |
Inside of the job's folder, you will find one folder for the job's Driver (named `driver` driver
) and one per Evaluator. Their name comprises of the virtual node simulated by the local runtime (here, `NodeNode-
1`2
) followed by the time stamp of when this Evaluator was allocated on that node, here `1375482339266`1444604000469. As the HelloREEF example program only allocated one Evaluator, we only see one of these folders here. Let's peek inside:
Code Block |
---|
language | bash |
---|
title | EVALUATOR OUTPUT |
---|
|
> cd Node-12-13754823392661444604000469
> ls evaluator*.txt
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a--- 2013-11-18 13:20 3 PID.txt 10/12/2015 7:53 AM 2690 evaluator.stderr
-a--- 2013-11-18 13:20 18911 STDERR.txt
-a--- 2013-11-18 13:20 3044 STDOUT.txt 10/12/2015 7:53 AM 14 evaluator.stdout |
evaluator.stderr
STDERR.txt contains the output on stderr
of this Evaluator, which mostly consists of logs helpful in debugging. `STDOUTevaluator.
txt` stdout
contains the output on stdout
. And, sure enough, this is where you find the "Hello, REEF!" message.
...