diff options
author | Florian Dold <florian.dold@gmail.com> | 2012-04-12 06:46:06 +0000 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2012-04-12 06:46:06 +0000 |
commit | d0a7563427b29ac4ae33eb8b6222cecea247887e (patch) | |
tree | ac7216436badb17a9df2451cafca72b56290c54c | |
parent | c416ef96040c6f23f07d1ed25e3efc79b29e2d7e (diff) | |
download | gnunet-java-d0a7563427b29ac4ae33eb8b6222cecea247887e.tar.gz gnunet-java-d0a7563427b29ac4ae33eb8b6222cecea247887e.zip |
updated issues, doc
-rw-r--r-- | ISSUES | 46 | ||||
-rwxr-xr-x | bin/gnunet-core | 5 | ||||
-rw-r--r-- | doc/gnunet-exercise.tex | 149 |
3 files changed, 171 insertions, 29 deletions
@@ -347,17 +347,39 @@ public interface GnunetMessageBody extends MessageUnion { } | |||
347 | 347 | ||
348 | ======================================================================================== | 348 | ======================================================================================== |
349 | 349 | ||
350 | * client_api.c | 350 | * are we in a hurry? when should gnunet-java be usable to students? |
351 | * according to the website the project begins very soon | ||
352 | * currently my progress with the tutorial is not that far, as the java APIs are not | ||
353 | yet completely implemented / stable. | ||
354 | * needed: a place to host the javadocs (so the tutorial can link to it) | ||
355 | |||
356 | * what is the best way to configure the classpath for gnunet-java-ext? | ||
357 | * a bash script that exports environment variables for e.g. the gnunet-java.jar? | ||
358 | * once a MessageMap.txt has been generated for a new extension, how do we tell gnunet-java that/where it | ||
359 | exists? | ||
360 | * what about allocation of message IDs for extesions / what about clashes? | ||
361 | |||
362 | * core_api.c, notify_transmit_ready: | ||
351 | * pr = GNUNET_CONTAINER_multihashmap_get (handle->peers, &target->hashPubKey); | 363 | * pr = GNUNET_CONTAINER_multihashmap_get (handle->peers, &target->hashPubKey); |
352 | * the above line crashes when target==NULL, but comment indicates that NULL is valid for target | 364 | * the above line crashes when target==NULL, but comment indicates that NULL is valid for target |
353 | 365 | ||
354 | * ...NOTIFY_PRE_CONNECT.. message type not used | 366 | * ...NOTIFY_PRE_CONNECT.. message type not used |
355 | 367 | ||
356 | * what about allocation of message IDs for extesions / what about clashes? | ||
357 | 368 | ||
358 | core: | 369 | core: |
359 | * we seem to get all incoming messages if the handlers array is empty (even if we don't request anything) | 370 | * we seem to get all incoming messages if the handlers array is empty (even if we don't request anything) |
360 | * being notified about outbound messages does not seem to work at all | 371 | * being notified about outbound messages does not seem to work at all |
372 | * comment in core_connect talks about timout, but there is no timeout parameter. | ||
373 | * GNUNET_MESSAGE_TYPE_CORE_NOTIFY_STATUS_CHANGE not used | ||
374 | * also GNUNET_CORE_OPTION_SEND_STATUS_CHANGE | ||
375 | * inconsistency in structs with trailing ATS information (NotifyTrafficMessage vs ConnectNotifyMessage) | ||
376 | * why zero-termination *and* size field? | ||
377 | * what does zero-termination really mean? is it only one byte? a whole ats entry? | ||
378 | * what happens when we can't connect to core / lose connection? in the c api implementation, this is never handeled? | ||
379 | * why is there even the init callback if init can't fail? | ||
380 | |||
381 | * are there really any ambiguities when receiving messages with a runabout? | ||
382 | |||
361 | 383 | ||
362 | 384 | ||
363 | * how does the Hash ascii-encoding work? | 385 | * how does the Hash ascii-encoding work? |
@@ -388,6 +410,8 @@ int[] foo; | |||
388 | * server: | 410 | * server: |
389 | * what is a MessageStreamTokenizer and why does it belong to the server? | 411 | * what is a MessageStreamTokenizer and why does it belong to the server? |
390 | * my guess: for fragmented messages inside other messages? | 412 | * my guess: for fragmented messages inside other messages? |
413 | * GNUNET_SERVER_connect_socket: what is it for? | ||
414 | * how to disable corking in java? is corking the same as TCP_NODELAY? | ||
391 | 415 | ||
392 | 416 | ||
393 | * discuss: the size parameter in the various notifyTransmitReady methods | 417 | * discuss: the size parameter in the various notifyTransmitReady methods |
@@ -395,22 +419,10 @@ int[] foo; | |||
395 | * proposal: keep for c api compatibility, introduce additional version that | 419 | * proposal: keep for c api compatibility, introduce additional version that |
396 | gets a message object directly, and calls a continuation to notify about success/failure | 420 | gets a message object directly, and calls a continuation to notify about success/failure |
397 | 421 | ||
398 | * core: | ||
399 | * comment in core_connect talks about timout, but there is no timeout parameter. | ||
400 | * GNUNET_MESSAGE_TYPE_CORE_NOTIFY_STATUS_CHANGE not used | ||
401 | * also GNUNET_CORE_OPTION_SEND_STATUS_CHANGE | ||
402 | * inconsistency in structs with trailing ATS information (NotifyTrafficMessage vs ConnectNotifyMessage) | ||
403 | * why zero-termination *and* size field? | ||
404 | * what does zero-termination really mean? is it only one byte? a whole ats entry? | ||
405 | * what happens when we can't connect to core / lose connection? in the c api implementation, this is never handeled? | ||
406 | * why is there even the init callback if init can't fail? | ||
407 | 422 | ||
408 | 423 | ||
409 | * GNUNET_SERVER_connect_socket: what is it for? | 424 | * server: |
410 | * how to disable corking in java? is corking the same as TCP_NODELAY? | 425 | * what is client_keep? |
411 | 426 | * when handling signals through the pipe, how is the service / server notified? | |
412 | 427 | ||
413 | * why is installing gnunet so compilicated? | ||
414 | * e.g. stuff like "base of XYZ installation" in ./configure is very confusing | ||
415 | * many dependencies with out-of-date packages on common distros | ||
416 | 428 | ||
diff --git a/bin/gnunet-core b/bin/gnunet-core new file mode 100755 index 0000000..dea64d8 --- /dev/null +++ b/bin/gnunet-core | |||
@@ -0,0 +1,5 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | DIR=`dirname $0` | ||
4 | |||
5 | java -ea -cp "$DIR/../build/:$DIR/../lib/*" org.gnunet.core.Core "$@" | ||
diff --git a/doc/gnunet-exercise.tex b/doc/gnunet-exercise.tex index 692b03c..1845e0e 100644 --- a/doc/gnunet-exercise.tex +++ b/doc/gnunet-exercise.tex | |||
@@ -26,7 +26,7 @@ | |||
26 | This tutorial assumes that you have gnunet$\geq$0.9.2 installed on your system. | 26 | This tutorial assumes that you have gnunet$\geq$0.9.2 installed on your system. |
27 | Instructions on how to do this can be found at \url{https://gnunet.org/installation}. | 27 | Instructions on how to do this can be found at \url{https://gnunet.org/installation}. |
28 | 28 | ||
29 | TODO: ./configure --enable-javaports | 29 | TODO: remark about ./configure --enable-javaports / port configuration |
30 | 30 | ||
31 | Make sure that the default gnunet services are running by typing | 31 | Make sure that the default gnunet services are running by typing |
32 | \begin{lstlisting} | 32 | \begin{lstlisting} |
@@ -35,17 +35,16 @@ gnunet-arm -I | |||
35 | on your command line. | 35 | on your command line. |
36 | 36 | ||
37 | \section{Installing gnunet-java} | 37 | \section{Installing gnunet-java} |
38 | You can either check out the latest version of gnunet-java with | 38 | Check out the latest version of gnunet-java with |
39 | \lstset{language=bash} | 39 | \lstset{language=bash} |
40 | \begin{lstlisting} | 40 | \begin{lstlisting} |
41 | svn checkout https://gnunet.org/svn/gnunet-java/ | 41 | svn checkout https://gnunet.org/svn/gnunet-java/ |
42 | \end{lstlisting} | 42 | \end{lstlisting} |
43 | or download a more convenient installer at \url{http://example.com/gnunet-java-installer.jar}. | 43 | as well as the template directory for extensions with |
44 | You can start the installer by double-clicking on it, or running | ||
45 | \begin{lstlisting} | 44 | \begin{lstlisting} |
46 | java -jar gnunet-java-installer.jar | 45 | svn checkout https://gnunet.org/svn/gnunet-java-ext/ |
47 | \end{lstlisting} | 46 | \end{lstlisting} |
48 | on your command line. | 47 | |
49 | 48 | ||
50 | \section{First Steps} | 49 | \section{First Steps} |
51 | Programs to communicate with gnunet are located unter the bin/ directory. You can add this directory to your path, | 50 | Programs to communicate with gnunet are located unter the bin/ directory. You can add this directory to your path, |
@@ -55,10 +54,17 @@ To test if everything is working, try to run the program gnunet-nse. This should | |||
55 | of the network. | 54 | of the network. |
56 | 55 | ||
57 | \subsection{Project Layout} | 56 | \subsection{Project Layout} |
58 | (explanation of the directory structure: src, test, bin, tools, gnunet-java-ext) | 57 | src contains the source code of gnunet-java, test contains test cases, bin contains wrappers arround main classes, |
58 | tools contain scripts used for development. | ||
59 | |||
60 | gnunet-java-ext has a similar structure. | ||
61 | |||
59 | 62 | ||
60 | \section{Creating an extension} | 63 | \section{Creating an extension} |
61 | (copying gnunet-java-ext, setting variables / the gnunet-java path in the bash wrapper) | 64 | create a copy of gnunet-java-ext and rename it to gnunet-java-hellognunet. |
65 | |||
66 | \subsection{configuring your extension} | ||
67 | describe the classpath config file, the shell wrapper | ||
62 | 68 | ||
63 | \section{A simple gnunet-java program} | 69 | \section{A simple gnunet-java program} |
64 | \lstset{language=java} | 70 | \lstset{language=java} |
@@ -73,22 +79,141 @@ public class HelloGnunet { | |||
73 | } | 79 | } |
74 | \end{lstlisting} | 80 | \end{lstlisting} |
75 | 81 | ||
82 | The Program class takes care of parsing command line arguments (thus it's constructur gets the args array passed) | ||
83 | and loading the gnunet configuration files (accessed by Program.getConfiguration()) | ||
84 | (talk about scheduler/asynchronous stuff) | ||
85 | |||
76 | \subsection{Adding and using command line arguments} | 86 | \subsection{Adding and using command line arguments} |
77 | Command line options are added by annotating members of your org.gnunet.util.Program-subclass | 87 | Command line options are added by annotating members of your org.gnunet.util.Program-subclass |
78 | with the \@Option-annotation. | 88 | with the \@Option-annotation. |
79 | 89 | ||
90 | Let's start with an example: | ||
91 | |||
92 | \lstset{language=java} | ||
93 | \begin{lstlisting} | ||
94 | new Program(args) { | ||
95 | @Option( | ||
96 | shortname = "n", | ||
97 | longname = "name", | ||
98 | action = OptionAction.STORE_STRING, | ||
99 | description = "the name of the person you want to greet") | ||
100 | String name; | ||
101 | [...] | ||
102 | } | ||
103 | \end{lstlisting} | ||
104 | |||
105 | The command line program can now be called with -nXXX or --name=XXX. | ||
106 | Inside of the run-method, the class member 'name' will then be initialized with the passed argument, | ||
107 | or null if the option has not been passed. | ||
108 | |||
109 | The \@Option annotation can not only be used with Strings, but also with booleans and numbers. | ||
110 | |||
111 | (reference the java docs) | ||
112 | |||
113 | By default, the following arguments are available on the command line | ||
114 | |||
115 | (table comes here) | ||
116 | |||
117 | You can change the about text and the version by subclassing the getVersion / getAboutTest methods in your Program subclass. | ||
118 | |||
80 | 119 | ||
81 | \subsection{Using an existing service API} | 120 | \subsection{Using an existing service API} |
82 | In this section we will use the gnunet statistics api to track how often the HelloGnunet program | 121 | In this section we will use the gnunet statistics api to track how often the HelloGnunet program |
83 | has been run. | 122 | has been run. |
123 | \subsubsection{Establishing a connection to the statistics service} | ||
124 | |||
125 | \begin{lstlisting} | ||
126 | Statistics statistics = new Statistics(cfg); | ||
127 | \end{lstlisting} | ||
128 | |||
129 | establishes a connection to the statistics service. As with most API calls in gnunet-java, this operation is asynchronous. | ||
130 | This is one of the main reasons why you have to wrap your program in the run method: Once all your asynchronous calls are | ||
131 | made, the run method returns, and gnunet-java hast to keep the system running until all work has been done. | ||
132 | |||
133 | \begin{lstlisting} | ||
134 | statistics.set(RelativeTime.SECOND, "gnunet-java-ext-hello", "has said hello", 1, | ||
135 | new SetCompleted() { | ||
136 | @Override | ||
137 | public void onCompleted() { | ||
138 | System.out.println("done."); | ||
139 | } | ||
140 | |||
141 | @Override | ||
142 | public void onTimeout() { | ||
143 | System.out.println("timeout while setting"); | ||
144 | }}); | ||
145 | \end{lstlisting} | ||
146 | |||
84 | 147 | ||
85 | \section {Overview of useful APIs} | 148 | \section {Overview of useful APIs} |
86 | statistics, dht, core | 149 | statistics |
150 | |||
151 | dht | ||
152 | * explain dht-put and dht-get / one example | ||
153 | |||
154 | core | ||
155 | * explain API, maybe refer to example code | ||
156 | |||
157 | |||
158 | \section{Creating a new gnunet-java service} | ||
159 | |||
160 | \subsection{Defining new Messages} | ||
161 | All gnunet services have a common communication protocol. | ||
162 | Every message consists of a header (with the message size and the message type), and a body. | ||
163 | |||
164 | You can define a new type of Message in gnunet-java by annotating a class with how | ||
165 | to represent its members in binary format. | ||
166 | |||
167 | Additionaly, you have to register your new message type with gnunet-java, giving it a unique id. | ||
168 | |||
169 | \begin{lstlisting} | ||
170 | @UnionCase(4242) | ||
171 | public class HelloWorldMessage implements GnunetMessage.Body { | ||
172 | @UInt8 | ||
173 | public int age; | ||
174 | @ZeroTerminatedString; | ||
175 | public String name; | ||
176 | } | ||
177 | \end{lstlisting} | ||
178 | Todo: explain the above | ||
179 | |||
180 | |||
181 | Other useful annotations are: | ||
182 | ... | ||
183 | |||
184 | |||
185 | Running the msgtypes-tool: | ||
186 | |||
187 | \subsection{Implementing the Service} | ||
188 | Similarily to Program.run, Service.run is the entry point of every gnunet-java service. | ||
189 | It's members can be annotated with the same command line parsing options as in Program. | ||
190 | |||
191 | The first difference is that every Service has at least one server, waiting on new clients to connect. | ||
192 | When implementing a Service, you have to specify the kind of messages you are interested in. | ||
193 | |||
194 | The basic skeleton for a Service looks like this: | ||
195 | |||
196 | \subsubsection{Talking back to a client} | ||
197 | explain Client.this.notifyTransmitReady(...) | ||
198 | |||
199 | \subsection{Creating the configuration file} | ||
200 | For every service ther is a configuration file that specifies | ||
201 | over which port the service is reachable. Other options in the configuration can be used to | ||
202 | configure the service without touching the code or implementing your own configuration. | ||
203 | |||
204 | [provide example config file here] | ||
205 | |||
206 | \subsection{Using arm to start the service} | ||
87 | 207 | ||
88 | \section{Communicating with a Service directly} | 208 | \section{Communicating with a Service directly} |
89 | \subsection{Using the client API} | 209 | \subsection{Using the client API} |
90 | \subsection{Defining a new message type} | 210 | \subsubsection{Creating a new Client} |
91 | (example, annotations, running gnunet-java-update-msgtypes) | 211 | \begin{lstlisting} |
92 | \section{Writing a gnunet service} | 212 | Client = new Client("hello-world-service", getConfiguration()); |
213 | \end{lstlisting} | ||
214 | establishes a connection with the service named "hello-world-service". The necessary information (e.g. the right TCP/IP port) for connecting | ||
215 | to the service is is looked up under the section [hello-world-service] in the configuration. | ||
216 | |||
217 | |||
93 | 218 | ||
94 | \end{document} | 219 | \end{document} |