Project

General

Profile

Basic Repo Insertion Protocol » History » Version 3

Alex Afanasyev, 07/23/2014 04:38 PM

1 1 Alex Afanasyev
Basic Repo Insertion Protocol
2
=============================
3
4 2 Alex Afanasyev
Basic repo insertion protocol uses **[[Repo Command]]**.
5 1 Alex Afanasyev
6 3 Alex Afanasyev
## Basic operations
7
8
### Insert data
9
10
Command verb: **insert**
11
12 1 Alex Afanasyev
The name semantics follows the format of the repo command. The <command verb> is defined as ``insert``.
13
For example, for ``<repo prefix>`` as ``/ucla/cs/repo``, the following is an example:
14
15
    /ucla/cs/repo/insert/<RepoCommandParameter>/<timestamp>/<random-value>/<SignatureInfo>/<SignatureValue>
16
17
### Insertion status check
18
19 3 Alex Afanasyev
Command verb: **insert check**
20
21 1 Alex Afanasyev
During the insertion progress, the requester could send insertion status check command to check the status of the insertion progress. This status check command is also signed interest. The semantics of insertion status check command is shown as follows:
22
23
<command verb> equals to ``insert check``. For example:
24
25
    /ucla/cs/repo/insert check/<RepoCommandParameter>/<timestamp>/<random-value>/<SignatureInfo>/<SignatureValue>
26
27 3 Alex Afanasyev
## Formats
28
29 1 Alex Afanasyev
### RepoCommandParameter
30
31
RepoCommandParameter of insertion and insertion check command follows that in Repo Command section. Name, Selectors, StartBlockId, EndBlockId are used in insertion. Name and ProcessId are used in insertion check command.
32
33
In insertion command, Name represents the name or prefix of data for repo to fetch. If selectors are set, repo will use these selectors to fetch the data. If StartBlockId or EndBlockId is set, the repo will retrieve segmented data with segment number between StartBlockId and EndBlockId. If Repo Insert Command carries both Selectors and StartBlockId, EndBlockId, repo would ignore it and response with statuscode of 405.
34
35
In insertion check command, Name represents name or prefix of data for repo to fetch. ProcessId is set by the RepoCommandResponse to indicate specified process.
36
37
### Insertatation status response
38
39
This insert status data object could be the response data object of both insert command and insert check command. It will follow the format of repo command response.
40
41
StatusCode indicates the status of insertion. InsertNum represents how many data has been intersted into the repo. StartBlockId and EndBlockId is the start and end segment id of data inserted. InsertNum is the how many data segments have been inserted. ProcessId indicates an ID of process, a random number gernerated by repo.
42
43
For insert cammand, status code will be set according to definition below, StartBlockId and EndBlockId will be set according to the insert command. If StartBlockId in RepoCommandParameter is missing, it will be set 0 in response. If EndBlockId is missing, it will not be set.
44
45
For insert check command, status code will be set according to definition below, StartBlockId and EndBlockId will be set according to the StartBlockId and EndBlockId that repo is using, insertnum will be set according to insertion progress. ProcessId is set according to the ID of process checked. If EndBlockId has not been decided, this EndBlockId will not be set in response.
46
47
StatusCode Definition:
48
49
``StatusCode`` | Description
50
-------------- | ----------------------------------------------
51
``100``        | The command is OK. can start to fetch the data
52
``200``        | All the data has been inserted
53
``300``        | This insertion is in progress
54
``401``        | This insertion command or insertion check command is invalidated
55
``402``        | Selectors and BlockId both present
56
``403``        | Malformed Command
57
``404``        | No such this insertion is in progress
58
``405``        | EndBlockId Missing Timeout
59
60
### EndBlockId Missing Timeout
61
62
If StartBlockId presents but EndBlockId is missing, and returned data packets do not contain FinalBlockId, the repo will continuosly fetch the data. An EndBlockId missing timeout is set to prevent this ocassion. The repo will start a timer when StartBlockId presents but EndBlockId is missing. When timeout happens, repo will stop fetching data to store and end insert process. If an insert check command arrives during this insert process, the time of timer is set to 0. If data packet containing FinalBlockId arrives, this timeout timer will be dismissed.
63
64 3 Alex Afanasyev
## Protocol Process
65 1 Alex Afanasyev
66
1. start to authorize the command; if authorization does not fail immediately, go to step 3
67
68
2. send a negative response indicating authorization failure, and abort these steps, insert process ends (StatusCode: 401)
69
70
3. if  both StartBlockId and EndBlockId are missing, go to step 7
71
72
4. if either StartBlockId or EndBlockId is present, and one of supported selectors is present. send negative reponse back and abort steps, insert process ends (StatusCode: 402)
73
74
5. if both StartBlockId and EndBlockId are present, and StartBlockId is less than or equal to EndBlockId, go to step 7
75
76
6. send a negative response indicating malformed command, and abort these steps, insert process ends (StatusCode: 403)
77
78
7. wait for authorization completion
79
80
8. if authorization fails, go to step 2 (StatusCode: 401)
81
82
9. send a positive response indicating insert is in progress (StatusCode: 200)
83
84
10. if either StartBlockId or EndBlockId is present, go to step 16
85
86
11. start to retrieve Name with selectors in insert command
87
88
12. wait for retrieval completion
89
90
13. if retrieval fails, go to step 27
91
92
14. store retrieved Data packet
93
94
15. abort these steps, insert process ends
95
96
16. if StartBlockId is missing, set StartBlockId 0. If EndBlockId is missing, EndBlockId will be missing unless get FinalBlockId in comming data packets, start EndBlockId Misiing Timeout timer.
97
98
17. append StartBlockId to Name
99
100
18. start to retrieve Name
101
102
19. wait for retrieval completion
103
104
20. if retrieval fails, go to step 26
105
106
21. store retrieved Data packet
107
108
22. if retrieved Data packet contains FinalBlockId, and FinalBlockId is less than EndBlockId or EndBlockId is missing, let EndBlockId be FinalBlockId
109
110
23. if the last component of Name is greater than or equal to EndBlockId, abort these steps, insert process ends
111
112
24. increment the last component of Name
113
114
25. go to step 17
115
116
26. retrieve data with this data another 2 times. If these 2 retrieval both failes, abort these steps. if success, go to step 21
117
118
27. retrieve data with this data another 2 times. If these 2 retrieval both failes, abort these steps. if success, go to step 14
119
120
If EndBlockId Missing Timeout timer starts, repo will monitor this timer during step 17~26. If this timeout occurs, abort insert command process immediately.
121
122
Implementation MAY pipeline the Interests.
123
124
### Repo insert check command progress
125
126
Implementation MAY publish a notification of status regarding insert progress. The process of status check is as follows:
127
128
1. start to authorize the insert status command, if fails go to 2, if success, go to 3
129
130
2. send a negative response indicating authorization failure, and abort these steps (StatusCode: 401)
131
132
3. start to check the progress of the insert with the data name in the command. If no such progress is found, go to 4. or go to 5.
133
134
4. reponse status with status code, abort check process. (StatusCode: 404)
135
136
5. ckeck the status of insertion. return the status of insertion progress. If a EndBlockId Missing Timeour timer is running, set this timer to 0. About check process. (StatusCode: 300)
137
138
### Protocol diagram:
139
140
    Requester                     Repo                          Data producer
141
        |                           |                                 |
142
        |                           |                                 |
143
      +---+  Insert command       +---+                               |
144
      |   | --------------------> |   |                               |
145
      +---+                       |   |                               |
146
        |                         |   |                               |
147
      +---+   Confirm start       |   |                               |
148
      |   | <==================== |   |                               |
149
      +---+   Reject command      +---+                               |
150
        |     (with status code)    |                                 |
151
        |                         +---+     Interest for Data       +---+
152
        |                         |   | --------------------------> |   |
153
        |                         +---+                             |   |
154
        |                           |                               |   |
155
        |                         +---+       Data segment          |   |
156
        |                         |   | <========================== |   |
157
        |                         +---+                             +---+
158
        |                           |                                 |
159
        |                           ~                                 ~
160
        |                           ~                                 ~
161
        |                           |                                 |
162
        |                         +---+     Interest for Data       +---+
163
        |                         |   | --------------------------> |   |
164
        |                         +---+                             |   |
165
        |                           |                               |   |
166
        |                         +---+       Data segment          |   |
167
        |                         |   | <========================== |   |
168
        |                         +---+                             +---+
169
        |                           |                                 |
170
        |                           |                                 |
171
        |                           ~                                 ~
172
        |                           ~                                 ~
173
        |                           |                                 |
174
        |                           |                                 |
175
        |                           |                                 |
176
      +---+   Status interest     +---+                               |
177
      |   | --------------------> |   |                               |
178
      +---+                       |   |                               |
179
        |                         |   |                               |
180
      +---+    Status response    |   |                               |
181
      |   | <==================== |   |                               |
182
      +---+                       +---+                               |
183
        |                           |                                 |
184
        |                           |                                 |