-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Zeppelin - 683][WIP] BittorrentNotebookRepo #1231
Conversation
@bzz Design help needed. Connect all the pieces...
Should this be separate or included in NotebookServer OnMessage
|
Thank you for sharing the progress! Let me look into this and get back to you |
@bzz ping. |
Sorry, was quite a busy week. Great progress so far, from the first glance and on the formal side of the contribution:
Please address this feedback and I will look more into the design tommorow and let you know! |
} | ||
|
||
private static void loadLibrary() throws IOException { | ||
String path = LIBTORRENT_OS_LIBRARY_PATH(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how about checking this return value in case it's null
, would it make sense?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@onkarshedge please make sure you follow the project java style guide regarding static members
@onkarshedge thanks for this contribution. as i can see, the design issue on passing |
String path = LIBTORRENT_OS_LIBRARY_PATH(); | ||
if (path == null) { | ||
LOG.error("Unknown Operating system"); | ||
throw new IOException(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's provide the message for auser on the reason of failure though the constructor argument here
@khalidhuseynov thanks for helping. To actually see webApp.addServlet(new ServletHolder("ws-events",new TorrentServlet()),"/download"); So then should it be like this ... public class BittorrentNotebookRepo extends VFSNotebookRepo implements TorrentEngineListener,
WebSocketCreator {
@Override
public Object createWebSocket(ServletUpgradeRequest servletUpgradeRequest,
ServletUpgradeResponse servletUpgradeResponse) {
return new TorrentSocket(this);
}
} And the public class TorrentServlet extends WebSocketServlet {
@Override
public void configure(WebSocketServletFactory webSocketServletFactory) {
webSocketServletFactory.setCreator(new BittorrentNotebookRepo());
}
} Here is the problem as I cannot instantiate the BittorrentNotebookRepo here , it requires |
private void setupDir() { | ||
if (!torrentHomeDir.exists()) | ||
torrentHomeDir.mkdir(); | ||
if (!torrentDir.exists()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please make sure you follow the project java style guide regarding usage of braces
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ping
@onkarshedge on the architecture side - could you please elaborate on the design that you choose, especially regarding Initial idea the we discussed was that Could you please clarify, what are the parts that communicate to each other here? A diagram (event ASCI one) would help here. On the code side - please read the project style guide for Java language carefully and make sure you follow the conventions described there. |
@bzz . I will post a diagram of communication for clear view. Note get(String noteId, AuthenticationInfo subject);
List<NoteInfo> list(AuthenticationInfo subject);
void save(Note note, AuthenticationInfo subject); Only two key methods are public String shareNote(String noteId); // take the note.json file and start seeding, return magnet link
public void download(String magnetLink); // download the files in the torrent directory.
Could you please elaborate this point. |
Sure. The idea with P2P notebook storage implementation, be that Bittorrent or Dat or any other protocol is to have:
In case only some parts of For more details on this approach to design object oriented architecture please read infamous Joshua Bloch "Effective Java, 2nd edition" Waiting for the diagram of current architecture and code improvements according to styleguide - please ping me and I'll be happy to make another pass tomorrow. |
@bzz here is the diagram. |
The TorrentEngineListener as you can see is similar to And also a note on directories.. The torrent directory is created which will contain the following directories. When the user wants to share a note via DHT he will give the noteId , the note.json file is copied to torrent/notes// |
@onkarshedge conf object can be obtained on the fly from current configurations by |
@onkarshedge thank you for drawing very nice diagram. Let me be very clear - you did a great job and quite possible that it is me, as a mentor, who under communicate the expectations about the architecture for this project. But.. But in order to make your work useful for the project in the nearest future, this PR must not introduce new client-facing APIs, servlets or change the existing filesystem structure a lot. So we need to refactor your implementation and simplify, so it has a single entry point
Lifecycle of all objects that are needed to perform this task (i.e TorrentEngine and all others) must be tied to NotebookRepo lifecycle:
Please let me know if that makes sense to you. Let's start by finding answers to the questions on how to do 1-4 on DHT. Please think about it and let me know if you have question - we can schedule a call. |
@bzz I read the DHT specification and here are some questions and answers. Answer to point 2) checkpointing and 3) get Revisions If we use Immutable items to be stored in DHT point 4) Magnet Link. point 1) Listing existing notes --Edited--- |
Thank you for your explanation, what's your progress on refactoring current impelemtation? Let me try to re-visit points 1-5. Also, let's make sure that behavior of BittorentRepo is consistent with other implementations, like i.e S3, so it could be a drop-in replacement for the same use-cases where S3NotebookRerpo is used by a single line of configuration change.
Let me know what you think! |
@bzz What should I do now ? As you read the answer posted by gubatron should I now consider breaking the note into multiple partitions ? |
@onkarshedge That is not an expectation here of course. Let's think about alternatives - another way is to distribute note.jspn though regular torrents, right? So we can assume that there is going to be a tracker one day, that lists all notebook that are shared and each Zeppelin instance will be just seeding it's own fraction of notebooks. Then each revision of the note need to be stored as a separate file, as it will create a new torrent file\magnet link, right? Do you think this will work?
But again, the code to do all this have to be as much as possible hidden/composed behind the single entry-point of What do you think? |
Yes, this can be done. |
@onkarshedge thank you, that is good to know :) I would rather expect you coming up with such suggestion and then posting an explanation like above though. Could you also please update PR description according to your further plans? |
@onkarshedge would you be willing to address the comments on the code style and rebase it? |
close #83 close #86 close #125 close #133 close #139 close #146 close #193 close #203 close #246 close #262 close #264 close #273 close #291 close #299 close #320 close #347 close #389 close #413 close #423 close #543 close #560 close #658 close #670 close #728 close #765 close #777 close #782 close #783 close #812 close #822 close #841 close #843 close #878 close #884 close #918 close #989 close #1076 close #1135 close #1187 close #1231 close #1304 close #1316 close #1361 close #1385 close #1390 close #1414 close #1422 close #1425 close #1447 close #1458 close #1466 close #1485 close #1492 close #1495 close #1497 close #1536 close #1545 close #1561 close #1577 close #1600 close #1603 close #1678 close #1695 close #1739 close #1748 close #1765 close #1767 close #1776 close #1783 close #1799
What is this PR for?
To share notes and download via a magnet link. Trackerless, only via DHT.
What type of PR is it?
[Feature]
Todos
What is the Jira issue?
How should this be tested?
Outline the steps to test the PR here.
Screenshots (if appropriate)
Questions: