Basic Repo Insertion Protocol » History » Version 3
weijia yuan, 02/03/2018 05:09 PM
1 | 1 | weijia yuan | Basic Repo Insertion Protocol |
---|---|---|---|
2 | ============================= |
||
3 | 2 | weijia yuan | |
4 | |||
5 | Basic repo insertion protocol uses **[[Repo Command]]**. |
||
6 | |||
7 | Repo insertion command requests that the repo retrieve and store content. This command interest is a signed interest and will be validated with access control policy defined by the repo. When the Interest is validated and name of the data is not existed in the repo. The repository will respond with a data object containing OK status and start to send the interest to fetch the data to insert. |
||
8 | |||
9 | Segmented data insertion is also supported in the insertion protocol. Segmentation info is defined in RepoCommandParameter. If the content is segmented, the final segment id will be encoded in this block. |
||
10 | |||
11 | |||
12 | ## Basic operations |
||
13 | |||
14 | ### Insert data |
||
15 | |||
16 | Command verb: **insert** |
||
17 | |||
18 | The name semantics follows the format of the repo command. The <command verb> is defined as ``insert``. |
||
19 | For example, for ``<repo prefix>`` as ``/ucla/cs/repo``, the following is an example: |
||
20 | |||
21 | /ucla/cs/repo/insert/<RepoCommandParameter>/<timestamp>/<random-value>/<SignatureInfo>/<SignatureValue> |
||
22 | |||
23 | ### Insertion status check |
||
24 | |||
25 | Command verb: **insert check** |
||
26 | |||
27 | 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: |
||
28 | |||
29 | <command verb> equals to ``insert check``. For example: |
||
30 | |||
31 | /ucla/cs/repo/insert check/<RepoCommandParameter>/<timestamp>/<random-value>/<SignatureInfo>/<SignatureValue> |
||
32 | |||
33 | ## Formats |
||
34 | |||
35 | ### RepoCommandParameter |
||
36 | |||
37 | 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. |
||
38 | |||
39 | 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. |
||
40 | |||
41 | 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. |
||
42 | |||
43 | ### Insertion status response |
||
44 | |||
45 | 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. |
||
46 | |||
47 | StatusCode indicates the status of insertion. InsertNum represents how many data has been interested 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 generated by repo. |
||
48 | |||
49 | For insert command, 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. |
||
50 | |||
51 | 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. |
||
52 | |||
53 | StatusCode Definition: |
||
54 | |||
55 | ``StatusCode`` | Description |
||
56 | -------------- | ---------------------------------------------- |
||
57 | ``100`` | The command is OK. can start to fetch the data |
||
58 | ``200`` | All the data has been inserted |
||
59 | ``300`` | This insertion is in progress |
||
60 | ``401`` | This insertion command or insertion check command is invalidated |
||
61 | ``402`` | Selectors and BlockId both present |
||
62 | ``403`` | Malformed Command |
||
63 | ``404`` | No such this insertion is in progress |
||
64 | ``405`` | EndBlockId Missing Timeout |
||
65 | |||
66 | ### EndBlockId Missing Timeout |
||
67 | |||
68 | If StartBlockId presents but EndBlockId is missing, and returned data packets do not contain FinalBlockId, the repo will continuously fetch the data. An EndBlockId missing timeout is set to prevent this occasion. 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. |
||
69 | |||
70 | ## Protocol Process |
||
71 | |||
72 | 1. start to authorize the command; if authorization does not fail immediately, go to step 3 |
||
73 | |||
74 | 2. send a negative response indicating authorization failure, and abort these steps, insert process ends (StatusCode: 401) |
||
75 | |||
76 | 3. if both StartBlockId and EndBlockId are missing, go to step 7 |
||
77 | |||
78 | 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) |
||
79 | |||
80 | 5. if both StartBlockId and EndBlockId are present, and StartBlockId is less than or equal to EndBlockId, go to step 7 |
||
81 | |||
82 | 6. send a negative response indicating malformed command, and abort these steps, insert process ends (StatusCode: 403) |
||
83 | |||
84 | 7. wait for authorization completion |
||
85 | |||
86 | 8. if authorization fails, go to step 2 (StatusCode: 401) |
||
87 | |||
88 | 9. send a positive response indicating insert is in progress (StatusCode: 200) |
||
89 | |||
90 | 10. if either StartBlockId or EndBlockId is present, go to step 16 |
||
91 | |||
92 | 11. start to retrieve Name with selectors in insert command |
||
93 | |||
94 | 12. wait for retrieval completion |
||
95 | |||
96 | 13. if retrieval fails, go to step 27 |
||
97 | |||
98 | 14. store retrieved Data packet |
||
99 | |||
100 | 15. abort these steps, insert process ends |
||
101 | |||
102 | 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. |
||
103 | |||
104 | 17. append StartBlockId to Name |
||
105 | |||
106 | 18. start to retrieve Name |
||
107 | |||
108 | 19. wait for retrieval completion |
||
109 | |||
110 | 20. if retrieval fails, go to step 26 |
||
111 | |||
112 | 21. store retrieved Data packet |
||
113 | |||
114 | 22. if retrieved Data packet contains FinalBlockId, and FinalBlockId is less than EndBlockId or EndBlockId is missing, let EndBlockId be FinalBlockId |
||
115 | |||
116 | 23. if the last component of Name is greater than or equal to EndBlockId, abort these steps, insert process ends |
||
117 | |||
118 | 24. increment the last component of Name |
||
119 | |||
120 | 25. go to step 17 |
||
121 | |||
122 | 26. retrieve data with this data another 2 times. If these 2 retrieval both failes, abort these steps. if success, go to step 21 |
||
123 | |||
124 | 27. retrieve data with this data another 2 times. If these 2 retrieval both failes, abort these steps. if success, go to step 14 |
||
125 | |||
126 | If EndBlockId Missing Timeout timer starts, repo will monitor this timer during step 17~26. If this timeout occurs, abort insert command process immediately. |
||
127 | |||
128 | Implementation MAY pipeline the Interests. |
||
129 | |||
130 | ### Repo insert check command progress |
||
131 | |||
132 | Implementation MAY publish a notification of status regarding insert progress. The process of status check is as follows: |
||
133 | |||
134 | 1. start to authorize the insert status command, if fails go to 2, if success, go to 3 |
||
135 | |||
136 | 2. send a negative response indicating authorization failure, and abort these steps (StatusCode: 401) |
||
137 | |||
138 | 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. |
||
139 | |||
140 | 4. response status with status code, abort check process. (StatusCode: 404) |
||
141 | |||
142 | 5. check the status of insertion. return the status of insertion progress. If a EndBlockId Missing Timeout timer is running, set this timer to 0. About check process. (StatusCode: 300) |
||
143 | |||
144 | ### Protocol diagram: |
||
145 | |||
146 | Requester Repo Data producer |
||
147 | | | | |
||
148 | | | | |
||
149 | +---+ Insert command +---+ | |
||
150 | | | --------------------> | | | |
||
151 | +---+ | | | |
||
152 | | | | | |
||
153 | +---+ Confirm start | | | |
||
154 | | | <==================== | | | |
||
155 | +---+ Reject command +---+ | |
||
156 | 3 | weijia yuan | | (with estimated time out) | | |
157 | 2 | weijia yuan | | +---+ Interest for Data +---+ |
158 | | | | --------------------------> | | |
||
159 | | +---+ | | |
||
160 | | | | | |
||
161 | | +---+ Data segment | | |
||
162 | | | | <========================== | | |
||
163 | | +---+ +---+ |
||
164 | | | | |
||
165 | | ~ ~ |
||
166 | | ~ ~ |
||
167 | | | | |
||
168 | | +---+ Interest for Data +---+ |
||
169 | | | | --------------------------> | | |
||
170 | | +---+ | | |
||
171 | | | | | |
||
172 | | +---+ Data segment | | |
||
173 | | | | <========================== | | |
||
174 | | +---+ +---+ |
||
175 | | | | |
||
176 | | | | |
||
177 | | ~ ~ |
||
178 | | ~ ~ |
||
179 | | | | |
||
180 | | | | |
||
181 | | | | |
||
182 | +---+ Status interest +---+ | |
||
183 | | | --------------------> | | | |
||
184 | +---+ | | | |
||
185 | | | | | |
||
186 | +---+ Status response | | | |
||
187 | | | <==================== | | | |
||
188 | +---+ +---+ | |
||
189 | | | | |
||
190 | | | | |