Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cs425_distributed_system_mp
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
hangxie2
cs425_distributed_system_mp
Commits
eb08b36d
Commit
eb08b36d
authored
3 years ago
by
Hang
Browse files
Options
Downloads
Patches
Plain Diff
fast push
parent
b7316b1a
No related branches found
Branches containing commit
No related tags found
1 merge request
!10
MP3 Log Version Ready
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
mp3/server.py
+15
-15
15 additions, 15 deletions
mp3/server.py
with
15 additions
and
15 deletions
mp3/server.py
+
15
−
15
View file @
eb08b36d
...
@@ -454,7 +454,7 @@ def connect_with_all_servers(servers: dict, current_server_id: str, return_value
...
@@ -454,7 +454,7 @@ def connect_with_all_servers(servers: dict, current_server_id: str, return_value
try
:
try
:
s
=
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_STREAM
)
s
=
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_STREAM
)
host_ip_address
=
SERVER_ID_TO_IP_MAPPING
[
server
[
SERVER_IDENTIFIER
]]
host_ip_address
=
SERVER_ID_TO_IP_MAPPING
[
server
[
SERVER_IDENTIFIER
]]
#
server[SERVER_PORT] = 5
678
# todo: to be deleted
server
[
SERVER_PORT
]
=
5
5555
# todo: to be deleted
address
=
(
host_ip_address
,
server
[
SERVER_PORT
])
address
=
(
host_ip_address
,
server
[
SERVER_PORT
])
s
.
connect
(
address
)
s
.
connect
(
address
)
connect_info
[
server_id
]
=
s
connect_info
[
server_id
]
=
s
...
@@ -697,7 +697,7 @@ def server_handler(conn, SELF_NODE):
...
@@ -697,7 +697,7 @@ def server_handler(conn, SELF_NODE):
def
accepting_clients
(
SELF_NODE
):
def
accepting_clients
(
SELF_NODE
):
try
:
try
:
server
=
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_STREAM
)
server
=
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_STREAM
)
server
.
bind
((
CURRENT_SERVER_IP
,
1234
))
server
.
bind
((
CURRENT_SERVER_IP
,
SERVERS
[
CURRENT_SERVER_IP
][
SERVER_PORT
]
))
server
.
listen
()
server
.
listen
()
# print(f"[LISTENING] Server is listening on {ADDR}") # DEBUG
# print(f"[LISTENING] Server is listening on {ADDR}") # DEBUG
while
True
:
while
True
:
...
@@ -718,7 +718,7 @@ def accepting_clients(SELF_NODE):
...
@@ -718,7 +718,7 @@ def accepting_clients(SELF_NODE):
def
accepting_peer_servers
(
SELF_NODE
):
def
accepting_peer_servers
(
SELF_NODE
):
try
:
try
:
server
=
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_STREAM
)
server
=
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_STREAM
)
server
.
bind
((
CURRENT_SERVER_IP
,
5
678
))
server
.
bind
((
CURRENT_SERVER_IP
,
5
5555
))
server
.
listen
()
server
.
listen
()
# print(f"[LISTENING] Server is listening on {ADDR}") # DEBUG
# print(f"[LISTENING] Server is listening on {ADDR}") # DEBUG
while
True
:
while
True
:
...
@@ -768,17 +768,17 @@ if __name__ == '__main__':
...
@@ -768,17 +768,17 @@ if __name__ == '__main__':
map_hostname_to_ip
(
SERVERS
)
map_hostname_to_ip
(
SERVERS
)
CURRENT_SERVER_PORT
=
SERVERS
[
CURRENT_SERVER_ID
][
SERVER_PORT
]
CURRENT_SERVER_PORT
=
SERVERS
[
CURRENT_SERVER_ID
][
SERVER_PORT
]
#
pprint(f'[main] - SELF_NODE: {SELF_NODE}')
pprint
(
f
'
[main] - SELF_NODE:
{
SELF_NODE
}
'
)
#
pprint(f'[main] - SELF_NODE.lock: {SELF_NODE.lock}')
pprint
(
f
'
[main] - SELF_NODE.lock:
{
SELF_NODE
.
lock
}
'
)
#
thread1 = threading.Thread(target=accepting_clients, args=[SELF_NODE])
thread1
=
threading
.
Thread
(
target
=
accepting_clients
,
args
=
[
SELF_NODE
])
#
thread2 = threading.Thread(target=accepting_peer_servers, args=[SELF_NODE])
thread2
=
threading
.
Thread
(
target
=
accepting_peer_servers
,
args
=
[
SELF_NODE
])
#
#
thread1.start()
thread1
.
start
()
#
thread2.start()
thread2
.
start
()
#
thread1.join()
thread1
.
join
()
#
thread2.join()
thread2
.
join
()
thread
=
threading
.
Thread
(
target
=
accepting_connections
,
args
=
[
SELF_NODE
])
#
thread = threading.Thread(target=accepting_connections, args=[SELF_NODE])
thread
.
start
()
#
thread.start()
thread
.
join
()
#
thread.join()
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