|
5 | 5 |
|
6 | 6 | /** |
7 | 7 | * |
| 8 | + * Communication break down in ad-hoc networks is normal and no failure. |
| 9 | + * That chunk storage is meant to keep messages which are produced by an |
| 10 | + * app for later transmission. |
| 11 | + * |
| 12 | + * Messages which cannot be sent to their recipients can be stored in ASP3 chunks. |
| 13 | + * Each chunk is addressed with an URI (comparable to URIs e.g. in Android |
| 14 | + * Content Provider) |
| 15 | + * |
| 16 | + * Applications can easlily store their messages by calling add(URI, message). |
| 17 | + * That message is stored in a chunk addressed by the URI. |
| 18 | + * |
| 19 | + * Each chunk has a recipient list which can be changed anytime. The ASP3Engine |
| 20 | + * uses those information for sending such stored messages whenever a peer |
| 21 | + * establishes a connection. |
| 22 | + * |
| 23 | + * It is recommended to use ASP3EngineFS to set up that framework. |
| 24 | + * Create a ASP3Engine like this |
| 25 | + * |
| 26 | + * <pre> |
| 27 | + * ASP3Reader reader = ...; |
| 28 | + * ASP3ChunkStorage myStorage = ASP3EngineFS.getASP3Engine("EngineName", "ChunkStorageRootFolder", reader); |
| 29 | + * </pre> |
| 30 | + * |
| 31 | + * An ASP3Reader must be implemented prior using that framework. Objects of |
| 32 | + * that class are called whenever another peer transmits messages to the |
| 33 | + * local peer. @seeASP3Reader |
| 34 | + * |
| 35 | + * Chunks are structured by eras. In most cases, application developers don't |
| 36 | + * have to care about era management at all. If so, take care. Eras are usually |
| 37 | + * changed by the ASPEngine whenever a peer (re-) connects. In that case, the |
| 38 | + * current era is declared to be finished and an new era is opened. |
| 39 | + * Any new message is now tagged as message from that new era. The ASP3Engine |
| 40 | + * transmitts all message to the peer which are stored after the final |
| 41 | + * encounter. If no encounter ever happend - all avaiable messages are |
| 42 | + * transmitted. |
| 43 | + * |
| 44 | + * @see ASPEngine |
| 45 | + * @see ASP3Reader |
| 46 | + * |
8 | 47 | * @author thsc |
9 | 48 | */ |
10 | 49 | public interface ASP3ChunkStorage extends ASP3Storage { |
11 | 50 |
|
| 51 | + /** |
| 52 | + * Adds a recipient to chunk recipient list. |
| 53 | + * @param urlTarget chunk address |
| 54 | + * @param recipient recipient to add |
| 55 | + * @throws IOException |
| 56 | + */ |
12 | 57 | public void addRecipient(CharSequence urlTarget, CharSequence recipient) throws IOException; |
| 58 | + |
| 59 | + /** |
| 60 | + /** |
| 61 | + * Set a list of recipients for chunk. A former list is dropped. |
| 62 | + * |
| 63 | + * @param urlTarget chunk address |
| 64 | + * @param recipients new list of recipients |
| 65 | + * @throws IOException |
| 66 | + */ |
13 | 67 | public void setRecipients(CharSequence urlTarget, List<CharSequence> recipients) throws IOException; |
| 68 | + |
| 69 | + /** |
| 70 | + * Removes recipients |
| 71 | + * @param urlTarget chunk address |
| 72 | + * @param recipients list of recipients to be removed |
| 73 | + * @throws IOException |
| 74 | + */ |
14 | 75 | public void removeRecipient(CharSequence urlTarget, CharSequence recipients) throws IOException; |
15 | 76 |
|
| 77 | + /** |
| 78 | + * Add a message to that chunk. |
| 79 | + * @param urlTarget chunk address |
| 80 | + * @param message Message to be kept for later transmission |
| 81 | + * @throws IOException |
| 82 | + */ |
16 | 83 | public void add(CharSequence urlTarget, CharSequence message) throws IOException; |
17 | 84 |
|
| 85 | + /** |
| 86 | + * Create a new era |
| 87 | + */ |
18 | 88 | public void newEra(); |
19 | 89 |
|
| 90 | + /** |
| 91 | + * Get oldest era available on that peer. |
| 92 | + * @return |
| 93 | + */ |
20 | 94 | public int getOldestEra(); |
| 95 | + |
| 96 | + /** |
| 97 | + * Get current era. |
| 98 | + * @return |
| 99 | + */ |
21 | 100 | public int getEra(); |
| 101 | + |
| 102 | + /** |
| 103 | + * Get next era number. Era numbers are organized in a circle. Number 0 |
| 104 | + * follows Integer.MAXVALUE. That method takes care of that fact. |
| 105 | + * No change is made on current era. |
| 106 | + * |
| 107 | + * @param era |
| 108 | + * @return |
| 109 | + */ |
22 | 110 | public int getNextEra(int era); |
| 111 | + |
| 112 | + /** |
| 113 | + * Get previous era number. Era numbers are organized in a circle. Er |
| 114 | + * number 0 is proceeded by era number Integer.MAXVALUE. |
| 115 | + * That method takes care of that fact. |
| 116 | + * No change is made on current era. |
| 117 | + * |
| 118 | + * @param era |
| 119 | + * @return |
| 120 | + */ |
23 | 121 | public int getPreviousEra(int era); |
24 | 122 | } |
0 commit comments