-
Notifications
You must be signed in to change notification settings - Fork 37
Debugging EclairJS Node
To catch errors, be sure to use the catch method whenever a Promise is returned by EclairJS Node.
rdd.take(10).then(function(val) {
...
}).catch(function(err) {
console.log("Error:", err);
});As of EclairJS Node 0.6, you can enable verbose logging to help debug any issues.
$ export ECLAIRJS_VERBOSE = 1After setting ECLAIRJS_VERBOSE, running EclairJS Node will result in output such as:
Executing: JSON.stringify(pairRDD4.take(10));
Successfully executed:
JSON.stringify(pairRDD4.take(10));
Result was:
[{"0":35,"1":"of","length":2},{"0":30,"1":"the","length":2},{"0":21,"1":"and","length":2},{"0":19,"1":"be","length":2},{"0":19,"1":"to","length":2},{"0":16,"1":"a","length":2},{"0":15,"1":"will","length":2},{"0":13,"1":"freedom","length":2},{"0":13,"1":"from","length":2},{"0":12,"1":"i","length":2}]and errors will look like:
Executing: var rdd1 = jsc.te2xtFile("/Users/doronrosenberg/mystuff/ibm/eclairjs/git/eclairjs-node/examples/dream.txt");
Error on executing:
var rdd1 = jsc.te2xtFile("/Users/doronrosenberg/mystuff/ibm/eclairjs/git/eclairjs-node/examples/dream.txt");
Error was:
TypeError: Cannot call undefined in <eval> at line number 1
jdk.nashorn.api.scripting.NashornScriptEngine.throwAsScriptException(NashornScriptEngine.java:467)
jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:451)
jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:403)
jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:399)
jdk.nashorn.api.scripting.NashornScriptEngine.eval(NashornScriptEngine.java:155)
javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:264)
org.eclairjs.nashorn.JavascriptInterpreter$$anonfun$2$$anonfun$apply$1.apply(JavascriptInterpreter.scala:199)
org.eclairjs.nashorn.JavascriptInterpreter$$anonfun$2$$anonfun$apply$1.apply(JavascriptInterpreter.scala:199)
org.apache.toree.global.StreamState$.withStreams(StreamState.scala:81)
org.eclairjs.nashorn.JavascriptInterpreter$$anonfun$2.apply(JavascriptInterpreter.scala:197)
org.eclairjs.nashorn.JavascriptInterpreter$$anonfun$2.apply(JavascriptInterpreter.scala:197)
scala.concurrent.impl.Future$PromiseCompletingRunnable.liftedTree1$1(Future.scala:24)
scala.concurrent.impl.Future$PromiseCompletingRunnable.run(Future.scala:24)
scala.concurrent.impl.ExecutionContextImpl$$anon$3.exec(ExecutionContextImpl.scala:107)
scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260)
scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339)
scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979)
scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107) undefinedLog messages coming from the Eclairjs server will appear like this:
16/07/18 10:29:19 WARN : Your hostname, XXXX-MacBook-Pro.local resolves to a loopback/non-reachable address: fe80:0:0:0:90ce:cbff:febd:b8da%awdl0, but we couldn't find any external IP address!
The level of information logged by the server can be controlled by exporting the ECLAIRS_LOG environment variable. The Eclairjs server using Apache Log4j to do logging, so the control of logging follows the Log4j mechanisms.
The basic format of the ECLAIRS_LOG variable is packageName@LogLevel:anotherPackageName@LogLevel
For instance
export ECLAIRJS_LOG=org.eclairjs.nashorn@DEBUG:org.apache.spark@WARN
will set the eclairjs logging level to DEBUG, and the spark logging level to WARN