java Java分布式系统
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7227700/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Java distributed system
提问by qballer
I'm starting my final year computer science project and I'm trying to figure out my first steps. For more details you can go to the project page.
我正在开始我的最后一年计算机科学项目,我正在努力弄清楚我的第一步。有关更多详细信息,您可以转到项目页面。
Background: Because I have very little experience in distributed systems I basically though how should I face such a challenge. What I came up with is that the system should work as following:
背景:因为我对分布式系统的经验很少,所以我基本上想我应该如何面对这样的挑战。我想出的是该系统应按以下方式工作:
The client sends out a file, or a set of files that contains code to be processed. That code will implement a distributed algorithm interface written by me, a specific class. The server will create an object from the class.That object will be responsible for the algorithm to be run. The server will return the results to the client. (I actually read about RMI later and found it very similar).
客户端发出一个文件或一组文件,其中包含要处理的代码。该代码将实现我编写的分布式算法接口,一个特定的类。服务器将从该类创建一个对象。该对象将负责运行算法。服务器将结果返回给客户端。(实际上我后来阅读了 RMI 并发现它非常相似)。
Sending out files is basic - common network I/O. The real problem is object creation and using it as the predefined interface in run-time.
发送文件是基本的 - 常见的网络 I/O。真正的问题是创建对象并将其用作运行时的预定义接口。
Questions:
问题:
- The challenge that I have presented sounds like a reflection challenge, Is this correct?
- Do you have any first tips on how to implement it?
- 我提出的挑战听起来像是反思挑战,这是正确的吗?
- 你有什么关于如何实施它的第一个提示吗?
Looking for some distributed systems java technologies I've encountered RMI, TRMI, LINDA, CORBA, JINI and many others. RMI sounds the most appealing because it's very similar to what I've gathered to be the solution, but it's also old.
寻找一些分布式系统 java 技术,我遇到了 RMI、TRMI、LINDA、CORBA、JINI 和许多其他技术。RMI 听起来最吸引人,因为它与我收集的解决方案非常相似,但它也很旧。
- What set of libraries do you think will help me complete this task? Remember I'm a computer science student, so complete out of the box solutions will not stick with my professors.
- RMI is old, any better solutions out there ?
- any comprehensive tutorial on TRMI?
- 您认为哪些库可以帮助我完成这项任务?请记住,我是一名计算机科学专业的学生,因此完整的现成解决方案不会坚持我的教授。
- RMI 是旧的,有更好的解决方案吗?
- 任何关于 TRMI 的综合教程?
If you find my logic some how faulty, please correct it.
如果您发现我的逻辑有些错误,请更正。
If you have some more tips on the subject that you think that should be discussed feel free to contact me.
如果您有关于该主题的更多提示,您认为应该讨论,请随时与我联系。
采纳答案by Enno Shioji
You could use this exampleand send class files for execution (you can store the class files on disk, and then load them using the URLClassLoader. If you don't want to write on disk, McDowell has a suggestion).
你可以使用这个例子并发送类文件执行(你可以将类文件存储在磁盘上,然后使用 URLClassLoader 加载它们。如果你不想写在磁盘上,McDowell 有一个建议)。
As for communication, there are a LOT to choose from. One thing you could think about is whether to make the message passing synchronous or asynchronous. There is nothing wrong about synchronous messaging (like RMI), but you may want to look for asynchronous solutions as well as they are supposed to be "hot" recently. Or you could just go with your own protocol on top of HTTP or something like that.
至于沟通,有很多可供选择。您可以考虑的一件事是使消息传递同步还是异步。同步消息传递(如 RMI)没有任何问题,但您可能想要寻找异步解决方案,以及它们最近应该是“热门”的。或者你可以在 HTTP 或类似的东西之上使用你自己的协议。
One fun exercise would be to distribute data among nodes and execute the algorithm against these distributed data, and then combine the results. In this case the user will specify two algorithms. One that generates data, and one that aggregates the result.
一个有趣的练习是在节点之间分配数据并针对这些分布式数据执行算法,然后组合结果。在这种情况下,用户将指定两种算法。一个生成数据,一个聚合结果。
回答by Andreas Dolk
There is not enough information for a recommendation of libraries or technologies. So I'd like to concentrate on the "more tips" part of your question ;)
没有足够的信息来推荐库或技术。所以我想专注于你问题的“更多提示”部分;)
- Server sends out a file- Usually it's a clientthat sends a request to a serverand the server will create a response. You should follow that convention.
- file needs to be executed- We can't execute a file. A file may contain some script or binary code that can be executed by an interpreter or computer. Reason for being picky: you have to do something with the content of the file (parsing, compiling, interpreting, linking, ...)
- files will implement a [...] interface- see above, the filesdo not implement anything.
- The client will run the interface- An interfacecan't be executed or run.
- return results of the algorithm to the server- Like mentioned above: usually it's a clientthat would send the file ("request") to a server. The server then would take the file, do some calculations based on the files content and return a result ("response") to the client.
- 服务器发送文件- 通常是客户端向服务器发送请求,服务器将创建响应。你应该遵守那个约定。
- 文件需要执行- 我们无法执行文件。文件可能包含一些可由解释器或计算机执行的脚本或二进制代码。挑剔的原因:你必须对文件的内容做一些事情(解析、编译、解释、链接……)
- 文件将实现一个 [...] 接口- 见上文,文件没有实现任何东西。
- 客户端将运行接口-无法执行或运行接口。
- 将算法的结果返回到服务器- 如上所述:通常是客户端将文件(“请求”)发送到服务器。然后服务器将获取文件,根据文件内容进行一些计算并将结果(“响应”)返回给客户端。
remote method invocation
远程方法调用
With RMI we usually have the following scenario: A clientwants to call a remote method. The client knows the interface and the server address. The server hasan implementation for that interface. Now the client contacts the server and calls the method on that server.
对于 RMI,我们通常有以下场景:客户端想要调用远程方法。客户端知道接口和服务器地址。服务器具有该接口的实现。现在客户端联系服务器并调用该服务器上的方法。
For your project it looks somewhat different: I think the clienthas an implementation of an algorithm (java source file or compiled class file) and wants to send it to one or more servers. The server shall process the file, executethe algorithm for some input (the slice) and return the result.
对于您的项目,它看起来有些不同:我认为客户端有一个算法的实现(java 源文件或编译的类文件),并希望将其发送到一个或多个服务器。服务器应处理文件,为某些输入(切片)执行算法并返回结果。
RMI maybe a candidate for the file transfer but not for (algorithm) method call. A remote method could look like that (assuming we send a java source file):
RMI可能是文件传输的候选对象,但不是(算法)方法调用的候选对象。远程方法可能看起来像这样(假设我们发送一个 java 源文件):
public Result process(String javaSource, Data data);