Comments (6)
Good question. I can't think of a good way to do this with the current implementation.
That said, this is something I'd been thinking about as one of the possible next enhancements to the library... concurrency needs to be supported and made easy by this library. An obvious use case would be a node rest api server using this library to start/manager spark jobs. (As an aside, I'd be curious to know your use case if you can share).
Created issues #26 and #27 for this work.
from apache-spark-node.
Actually, I have created a REST API server which is working quite nicely. Unfortunately I can't OpenSource it currently because it was created for my employer. But I'm planning on disussing this, and hopefully find a solution.
As of the node-java docs I tend to think it's impossible to leverage Java threads for this purpose, see
I did some tests, and even when using the Java thread classes the calls are still synchronous. This is aus well documented in the link above.
I couldn't find another solution yet unfortunately.
from apache-spark-node.
I saw your question on node-java and looked into javaNewProxy
but I think that proxies are a red herring here - maybe due to the unfortunate choice of Thread
in the example of the node-java docs.
My guess is that it should be possible to leverage threads (following something like joeferner/node-java#290 (comment)). If you can share your tests where you used the Java thread classes but still had synchronous calls, that would be very helpful.
from apache-spark-node.
Maybe I misunderstood this... But I don't think Joe's answer really solves my problem, because the thread would need to run the JS Spark code, and I don't see how this can work within a Java class.
I'll try to make some Gists out of my trials, but this will be difficult because I used my own abstractions of the Spark context.
Furthermore, I don't really see how interfaces can be implemented with node-java
other than with new Proxy()
.
There's another implementation of node-java which can apparently do this, see https://github.com/kyriosli/node-java#implement but the project seems to be not as mature as the other.
var vm = require('./node-java').createVm();
var Runnable = vm.implement(['java/lang/Runnable'], {
'run()V' : function() {
console.log('Thread started');
// Spark code goes here
}
});
var thread = vm.findClass('java/lang/Thread').newInstance('Ljava/lang/Runnable;', Runnable.newInstance());
thread.invoke('start()V');
from apache-spark-node.
Regarding the REST API Server, I'm in discussions with my colleagues and superiors. Hopefully I can reach a decision next week.
from apache-spark-node.
Fixed in #27
from apache-spark-node.
Related Issues (20)
- Write up instructions for using with a notebook HOT 6
- Failure at installation HOT 2
- How to connect to s Spark Standalone Cluster? HOT 2
- Async APIs HOT 1
- Support concurrent jobs HOT 1
- Add promise version of async functions
- Make spark-node ES7-aware
- unionAll not working? HOT 2
- Problem with spark-node HOT 4
- Failed to start spark-node with No Java runtime present error. HOT 1
- Querying a cassandra DB via spark HOT 3
- Would you like the "spark" module name on npm? HOT 3
- Streaming support from kafka ? HOT 1
- unable to install HOT 5
- Read data from mysql HOT 5
- Unable to install module with node version of 8.1.4 HOT 1
- node-gyp binding error on windows10 HOT 2
- Error with ASSEMBLY_JAR
- Let's reactivate the project?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from apache-spark-node.