Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
ece428mp1
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
azukor2
ece428mp1
Commits
111edc30
Commit
111edc30
authored
3 years ago
by
Jeffrey Zhang
Browse files
Options
Downloads
Patches
Plain Diff
Add basic logging
parent
45e26b7e
No related branches found
No related tags found
No related merge requests found
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
.gitignore
+2
-1
2 additions, 1 deletion
.gitignore
TODO.md
+3
-7
3 additions, 7 deletions
TODO.md
TransactionDeliverer.py
+9
-1
9 additions, 1 deletion
TransactionDeliverer.py
TransactionExecutor.py
+1
-0
1 addition, 0 deletions
TransactionExecutor.py
main.py
+9
-2
9 additions, 2 deletions
main.py
with
24 additions
and
11 deletions
.gitignore
+
2
−
1
View file @
111edc30
__pycache__/
*.pyc
*.cpython*
\ No newline at end of file
*.cpython*
*.log
\ No newline at end of file
This diff is collapsed.
Click to expand it.
TODO.md
+
3
−
7
View file @
111edc30
# TODO
1.
Correctly terminate program (and fix the ports)
2.
Timeout for unicast
3.
Deal with node crash, correctly implement finish function
4.
Keep track of statistics needed for report
5.
Write report
6.
Deal with time.sleep in main.py
7.
Perhaps start deleting stuff from the received set
\ No newline at end of file
1.
Keep track of statistics needed for report
2.
Write report
3.
Perhaps start deleting stuff from the received set
\ No newline at end of file
This diff is collapsed.
Click to expand it.
TransactionDeliverer.py
+
9
−
1
View file @
111edc30
...
...
@@ -19,7 +19,8 @@ class _Transaction_Message_Queue_Item:
priority_confirmations
:
int
=
None
class
TransactionDeliverer
:
def
__init__
(
self
,
client_names
,
addresses
,
ports
)
->
None
:
def
__init__
(
self
,
client_names
,
addresses
,
ports
,
logfile
=
None
)
->
None
:
self
.
logfile
=
logfile
self
.
startup_client_names
=
client_names
self
.
addresses
=
addresses
...
...
@@ -145,8 +146,15 @@ class TransactionDeliverer:
while
len
(
self
.
transactions_queue
)
>
0
and
self
.
transactions_queue
[
0
].
transaction_message
.
deliverable
:
transaction_to_process
=
self
.
transactions_queue
.
pop
(
0
)
self
.
log
(
transaction_to_process
)
self
.
transaction_executor
.
transaction
(
transaction_to_process
.
transaction_message
.
transaction
)
def
log
(
self
,
queue_item
):
if
not
self
.
logfile
is
None
:
# Transaction ID - Generated Timestamp - Executed Timestamp
message
=
queue_item
.
transaction_message
self
.
logfile
.
write
(
f
"
{
message
.
transaction_ID
}
{
message
.
generate_timestamp
}
{
time
.
time
()
}
\n
"
)
def
check_timeouts
(
self
):
#print("Check timeouts")
while
len
(
self
.
transactions_queue
)
>
0
:
...
...
This diff is collapsed.
Click to expand it.
TransactionExecutor.py
+
1
−
0
View file @
111edc30
...
...
@@ -27,6 +27,7 @@ class TransactionExecutor:
except
InvalidTransactionError
:
pass
self
.
printTransactions
()
def
printTransactions
(
self
):
items
=
self
.
accounts
.
items
()
items
=
sorted
(
items
,
key
=
lambda
x
:
x
[
0
])
...
...
This diff is collapsed.
Click to expand it.
main.py
+
9
−
2
View file @
111edc30
...
...
@@ -67,8 +67,12 @@ if __name__ == "__main__":
identifier
=
sys
.
argv
[
1
]
config_file
=
sys
.
argv
[
2
]
logfile
=
None
if
len
(
sys
.
argv
)
>=
4
:
logfile
=
open
(
sys
.
argv
[
3
],
'
w
'
)
client_names
,
addresses
,
ports
=
process_config
(
config_file
)
td
=
TransactionDeliverer
(
client_names
,
addresses
,
ports
)
td
=
TransactionDeliverer
(
client_names
,
addresses
,
ports
,
logfile
)
server_thread
=
Server
(
td
,
addresses
[
0
],
ports
[
0
])
server_thread
.
start
()
...
...
@@ -81,4 +85,7 @@ if __name__ == "__main__":
process_inputs
(
td
)
server_thread
.
end
.
set
()
server_thread
.
join
()
\ No newline at end of file
server_thread
.
join
()
if
logfile
:
logfile
.
close
()
\ No newline at end of file
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