This repository has been archived by the owner on Jul 12, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Lab-3.html
267 lines (245 loc) · 11.4 KB
/
Lab-3.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
<!DOCTYPE html><html><head><meta charset="utf-8"><style>html { font-size: 100%; overflow-y: scroll; -webkit-text-size-adjust: 100%; -ms-text-size-adjust: 100%; }
body{
color:#444;
font-family:Georgia, Palatino, 'Palatino Linotype', Times, 'Times New Roman',
"Hiragino Sans GB", "STXihei", "微软雅黑", serif;
font-size:12px;
line-height:1.5em;
background:#fefefe;
width: 45em;
margin: 10px auto;
padding: 1em;
outline: 1300px solid #FAFAFA;
}
a{ color: #0645ad; text-decoration:none;}
a:visited{ color: #0b0080; }
a:hover{ color: #06e; }
a:active{ color:#faa700; }
a:focus{ outline: thin dotted; }
a:hover, a:active{ outline: 0; }
span.backtick {
border:1px solid #EAEAEA;
border-radius:3px;
background:#F8F8F8;
padding:0 3px 0 3px;
}
::-moz-selection{background:rgba(255,255,0,0.3);color:#000}
::selection{background:rgba(255,255,0,0.3);color:#000}
a::-moz-selection{background:rgba(255,255,0,0.3);color:#0645ad}
a::selection{background:rgba(255,255,0,0.3);color:#0645ad}
p{
margin:1em 0;
}
img{
max-width:100%;
}
h1,h2,h3,h4,h5,h6{
font-weight:normal;
color:#111;
line-height:1em;
}
h4,h5,h6{ font-weight: bold; }
h1{ font-size:2.5em; }
h2{ font-size:2em; border-bottom:1px solid silver; padding-bottom: 5px; }
h3{ font-size:1.5em; }
h4{ font-size:1.2em; }
h5{ font-size:1em; }
h6{ font-size:0.9em; }
blockquote{
color:#666666;
margin:0;
padding-left: 3em;
border-left: 0.5em #EEE solid;
}
hr { display: block; height: 2px; border: 0; border-top: 1px solid #aaa;border-bottom: 1px solid #eee; margin: 1em 0; padding: 0; }
pre , code, kbd, samp {
color: #000;
font-family: monospace;
font-size: 0.88em;
border-radius:3px;
background-color: #F8F8F8;
border: 1px solid #CCC;
}
pre { white-space: pre; white-space: pre-wrap; word-wrap: break-word; padding: 5px 12px;}
pre code { border: 0px !important; padding: 0;}
code { padding: 0 3px 0 3px; }
b, strong { font-weight: bold; }
dfn { font-style: italic; }
ins { background: #ff9; color: #000; text-decoration: none; }
mark { background: #ff0; color: #000; font-style: italic; font-weight: bold; }
sub, sup { font-size: 75%; line-height: 0; position: relative; vertical-align: baseline; }
sup { top: -0.5em; }
sub { bottom: -0.25em; }
ul, ol { margin: 1em 0; padding: 0 0 0 2em; }
li p:last-child { margin:0 }
dd { margin: 0 0 0 2em; }
img { border: 0; -ms-interpolation-mode: bicubic; vertical-align: middle; }
table { border-collapse: collapse; border-spacing: 0; }
td { vertical-align: top; }
@media only screen and (min-width: 480px) {
body{font-size:14px;}
}
@media only screen and (min-width: 768px) {
body{font-size:16px;}
}
@media print {
* { background: transparent !important; color: black !important; filter:none !important; -ms-filter: none !important; }
body{font-size:12pt; max-width:100%; outline:none;}
a, a:visited { text-decoration: underline; }
hr { height: 1px; border:0; border-bottom:1px solid black; }
a[href]:after { content: " (" attr(href) ")"; }
abbr[title]:after { content: " (" attr(title) ")"; }
.ir a:after, a[href^="javascript:"]:after, a[href^="#"]:after { content: ""; }
pre, blockquote { border: 1px solid #999; padding-right: 1em; page-break-inside: avoid; }
tr, img { page-break-inside: avoid; }
img { max-width: 100% !important; }
@page :left { margin: 15mm 20mm 15mm 10mm; }
@page :right { margin: 15mm 10mm 15mm 20mm; }
p, h2, h3 { orphans: 3; widows: 3; }
h2, h3 { page-break-after: avoid; }
}
</style><title>Lab-3</title></head><body><h1 id="lab-3-rpc-hands-on">Lab-3: RPC Hands-on</h1>
<h3 id="due-3-4-2014-0001-utc8">Due: 3-4-2014 00:01 (UTC+8)</h3>
<h3 id="general-lab-info-can-be-found-in-lab-information">General Lab Info can be found in Lab Information.</h3>
<h1></h1>
<h2 id="introduction">Introduction</h2>
<ul>
<li>In this lab, you will:<ol>
<li>use RPC to implement a single client file server</li>
</ol>
</li>
<li>In the previous lab, you have finished a filesystem on a single machine. And in lab 3 (and 4), your aim is to extend it to a distributed file server. And from the architectural point of view, it now moves on to the RPC part.<ul>
<li><img src="https://www.evernote.com/shard/s9/res/3e442e35-5f8d-47c6-acb6-90998e6ca134.png"></li>
</ul>
</li>
<li>If you have questions about this lab, either in programming environment or requirement, please ask TA: Di Xiao (xiaodi@sjtu.edu.cn).</li>
</ul>
<h2 id="getting-started">Getting started</h2>
<ul>
<li>
<p>Please backup your solution to lab1 and lab2 before starting the steps below</p>
<ul>
<li>
<p>At first, please remember to save your lab2 solution:
<pre>
% cd lab-cse/lab2
% git commit -a -m “solution for lab2” </pre></p>
</li>
<li>
<p>Then, pull from the repository:
<pre>
% git pull
remote: Counting objects: 43, done.
…
[new branch] lab3 -> origin/lab3
Already up-to-date
</pre> </p>
</li>
<li>
<p>Then, change to lab3 branch:
<pre>
% git checkout lab3
</pre></p>
</li>
<li>
<p>Merge with lab2, and solve the conflict by yourself (mainly in fuse.cc and yfs_client.cc):
<pre>% git merge lab2
Auto-merging fuse.cc
CONFLICT (content): Merge conflict in yfs_client.cc
Auto-merging yfs_client.cc
CONFLICT (content): Merge conflict in ifs_client.cc
Automatic merge failed; fix conflicts and then commit the result
…</pre></p>
</li>
<li>
<p>After merge all of the conflicts, you should be able to compile successfully:
<pre>
% make
</pre></p>
</li>
<li>
<p>if there's no error in make, 3 executable files yfs_client, extent_server, test-lab-3-a will be generated.</p>
</li>
</ul>
</li>
<li>
<p>Note: For Lab2 and beyond, you'll need to use a computer that has the FUSE module, library, and headers installed. You should be able to install these on your own machine by following the instructions at <a href="http://fuse.sourceforge.net/">FUSE: Filesystem in Userspace</a> (see Lab Information)</p>
</li>
<li>Note: Both 32-bit and 64-bit librpc are provided, so the lab should be architecture independent.</li>
<li>Note: For this lab, you will not have to worry about server failures or client failures. You also need not be concerned about malicious or buggy applications.</li>
</ul>
<h2 id="distributed-filesystem-strawmans-approach">Distributed FileSystem (Strawman's Approach)</h2>
<ul>
<li>In lab2, we have implemented a file system on a single machine. In this lab, we just extend the single machine fils system to a distributed file system.</li>
<li>Separating extent service from yfs logic brings us a lot of advantages, such as no fate sharing with yfs client, high availability.</li>
<li>Luckily, most of your job has been done in the previous lab. You now can use extent service provided by extent_server through RPC in extent_client. Then a strawman distributed file system has been finished.</li>
<li><i>You had better test your code with the previous test suit before any progress.</i></li>
</ul>
<h2 id="detailed-guidance">Detailed Guidance</h2>
<ul>
<li>In principle, you can implement whatever design you like as long as it satisfies the requirements in the "Your Job" section and passes the testers. In practice, you should follow the detailed guidance below. <ul>
<li>Using the RPC system:<ul>
<li>The RPC library. In this lab, you don't need to care about the implementation of RPC mechanisms, rather you'll use the RPC system to make your local filesystem become a distributed filesystem.</li>
<li>A server uses the RPC library by creating an RPC server object (rpcs) listening on a port and registering various RPC handlers (see <code>main()</code> function in demo_server.cc).</li>
<li>A client creates a RPC client object (rpcc), asks for it to be connected to the demo_server's address and port, and invokes RPC calls (see demo_client.cc).</li>
<li><b>You can learn how to use the RPC system by studying the stat call implementation.</b> please note it's for illustration purpose only, you won't need to follow the implementation<ul>
<li>use <code>make rpcdemo</code> to build the RPC demo</li>
</ul>
</li>
<li>RPC handlers have a standard interface with one to six request arguments and a reply value implemented as a last reference argument. The handler also returns an integer status code; the convention is to return zero for success and to return positive numbers for various errors. If the RPC fails in the RPC library (e.g.timeouts), the RPC client gets a negative return value instead. The various reasons for RPC failures in the RPC library are defined in rpc.h under rpc_const.</li>
<li>The RPC system marshalls objects into a stream of bytes to transmit over the network and unmarshalls them at the other end. Beware: the RPC library does not check that the data in an arriving message have the expected type(s). If a client sends one type and the server is expecting a different type, something bad will happen. You should check that the client's RPC call function sends types that are the same as those expected by the corresponding server handler function.</li>
<li>The RPC library provides marshall/unmarshall methods for standard C++ objects such asstd::string, int, and char. <u>You should be able to complete this lab with existing marshall/unmarshall methods. </u></li>
</ul>
</li>
</ul>
</li>
</ul>
<h2 id="testers-grading">Testers & Grading</h2>
<ul>
<li>The test for this lab is test-lab-3-a. The test take two directories as arguments, issue operations in the two directories, and check that the results are consistent with the operations. Here's a successful execution of the tester:
<pre>
% ./start.sh
starting ./extent_server 29409 > extent_server.log 2>&1 &
starting ./yfs_client /home/cse/cse-2014/yfs1 29409 > yfs_client1.log 2>&1 &
starting ./yfs_client /home/cse/cse-2014/yfs2 29409 > yfs_client2.log 2>&1 &
% ./test-lab-3-a ./yfs1 ./yfs2
Create then read: OK
Unlink: OK
Append: OK
Readdir: OK
Many sequential creates: OK
Write 20000 bytes: OK
test-lab-2-a: Passed all tests.
% ./stop.sh
</pre></li>
<li>To grade this part of lab, a test script <code>grade.sh</code> is provided. It contains are all tests from lab2 (tested on both clients), and test-lab-3-a. Here's a successful grading.
<pre>
% ./grade.sh
Passed A
Passed B
Passed C
Passed D
Passed E
Passed test-lab-3-a (consistency)
Passed all tests!
>> Lab 3 OK
</pre></li>
</ul>
<h2 id="tips">Tips</h2>
<ul>
<li>This is also the first lab that writes null ('\0') characters to files. The std::string(char*)constructor treats '\0' as the end of the string, so if you use that constructor to hold file content or the written data, you will have trouble with this lab. Use the std::string(buf, size) constructor instead. Also, if you use C-style char[] carelessly you may run into trouble!</li>
<li>Do notice that a non RPC version may pass the tests, but RPC is checked against in actual grading. So please refrain yourself from doing so ;)</li>
</ul>
<h2 id="handin-procedure">Handin procedure</h2>
<ul>
<li>After all above done:
<pre>
% make handin
</pre></li>
<li>That should produce a file called lab3.tgz in the directory. Change the file name to your student id:
<pre>
% mv lab3.tgz lab3_[your student id].tgz
</pre></li>
<li>Then upload lab3_[your student id].tgz file to ftp://xiaodi:public@public.sjtu.edu.cn/upload/lab3 before the deadline. You are only given the permission to list and create new file, but no overwrite and read. So make sure your implementation has passed all the tests before final submit.</li>
<li>You will receive full credits if your software passes the same tests we gave you when we run your software on our machines.</li>
</ul></body></html>