Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
TDDD25_Distributed System
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Muhammad Ismail
TDDD25_Distributed System
Commits
153297b7
Commit
153297b7
authored
5 years ago
by
Della Baby
Browse files
Options
Downloads
Patches
Plain Diff
changes for lab1
parent
29724326
Branches
master
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
lab1/client.py
+15
-12
15 additions, 12 deletions
lab1/client.py
lab1/dbs/fortune.db
+0
-36
0 additions, 36 deletions
lab1/dbs/fortune.db
lab1/server.py
+9
-2
9 additions, 2 deletions
lab1/server.py
with
24 additions
and
50 deletions
lab1/client.py
+
15
−
12
View file @
153297b7
...
...
@@ -68,19 +68,20 @@ class DatabaseProxy(object):
#
# Your code here.
#
args
=
[]
msg
=
{
"
method
"
:
"
read
"
,
"
args
"
:
args
"
args
"
:
[]
}
s
=
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_STREAM
)
s
.
connect
(
self
.
address
)
conn
=
s
.
makefile
(
mode
=
"
rw
"
)
conn
.
write
(
json
.
dumps
(
msg
)
+
'
\n
'
)
conn
.
flush
()
res
=
json
.
loads
(
conn
.
readline
())
conn
.
flush
()
worker
=
s
.
makefile
(
mode
=
"
rw
"
)
worker
.
write
(
json
.
dumps
(
msg
)
+
'
\n
'
)
worker
.
flush
()
res
=
json
.
loads
(
worker
.
readline
())
s
.
close
()
return
res
pass
...
...
@@ -94,12 +95,14 @@ class DatabaseProxy(object):
}
s
=
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_STREAM
)
s
.
connect
(
self
.
address
)
conn
=
s
.
makefile
(
mode
=
"
rw
"
)
conn
.
write
(
json
.
dumps
(
msg
)
+
'
\n
'
)
conn
.
flush
()
res
=
json
.
loads
(
conn
.
readline
())
conn
.
flush
()
worker
=
s
.
makefile
(
mode
=
"
rw
"
)
worker
.
write
(
json
.
dumps
(
msg
)
+
'
\n
'
)
worker
.
flush
()
res
=
json
.
loads
(
worker
.
readline
())
s
.
close
()
if
res
:
print
(
res
)
pass
...
...
This diff is collapsed.
Click to expand it.
lab1/dbs/fortune.db
+
0
−
36
View file @
153297b7
...
...
@@ -3017,39 +3017,3 @@ come at you rapidly.
"Style Invitational Report from Week 278" published
August 2, 1998
%
TDDD25
%
distributed systems
%
hai
%
hai
%
hai
%
jhj
%
jkjkj
%
nnn
%
jjj
%
hhh
%
jkdhkjhdf
%
iudyucgdhcn
%
ttttttttttttt
%
jjjjjjjjjjj
%
kkkkkkkkk
%
hhhh
%
jj
%
klooo
%
This diff is collapsed.
Click to expand it.
lab1/server.py
+
9
−
2
View file @
153297b7
...
...
@@ -129,16 +129,23 @@ class Request(threading.Thread):
#
request_message
=
json
.
loads
(
request
)
try
:
#print(request_message)
if
request_message
!=
None
and
request_message
[
'
method
'
]
!=
None
and
request_message
[
'
args
'
]
!=
None
:
if
request_message
[
'
method
'
]
==
"
write
"
and
len
(
request_message
[
'
args
'
])
>
0
:
res
=
json
.
dumps
(
self
.
db_server
.
write
(
request_message
[
'
args
'
]))
elif
request_message
[
'
method
'
]
==
"
read
"
:
res
=
json
.
dumps
(
self
.
db_server
.
read
())
except
Exception
as
e
:
else
:
res
=
json
.
dumps
({
"
error
"
:
{
"
name
"
:
"
Unknown
method
"
,
"
args
"
:
request_message
[
'
method
'
]}})
#
res = json.dumps({"error" : {"name": "
error
method" , "args": request_message['method']}})
else
:
res
=
json
.
dumps
({
"
error
"
:
{
"
name
"
:
"
Unknown
method
"
,
"
args
"
:
request_message
[
'
method
'
]}})
#
res = json.dumps({"error" : {"name": "
error
method" , "args": request_message['method']}})
return
res
pass
def
run
(
self
):
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment