Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
SMART
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
3
Issues
3
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
UNI-KLU
SMART
Commits
26a88ef4
Commit
26a88ef4
authored
Jan 20, 2021
by
Luca Braun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
implemented failed transaction handling
parent
e76b8df3
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
7 deletions
+19
-7
repository.py
...n/trace-retrieval-microservice/app/database/repository.py
+7
-1
MessageHandler.py
...ce-retrieval-microservice/app/messaging/MessageHandler.py
+11
-5
rest_fetcher.py
...race-retrieval-microservice/app/messaging/rest_fetcher.py
+1
-1
No files found.
src/transaction-hub-in/trace-retrieval-microservice/app/database/repository.py
View file @
26a88ef4
...
...
@@ -25,11 +25,17 @@ class Repository(MongoRepositoryBase):
collection
.
delete_many
({})
def
add_transaction
(
self
,
transaction
:
Transaction
):
'''
Adds a transaction to mongodb repository.
@throws
KeyError - Duplicate transaction ID
'''
reference
=
self
.
get_transaction_with_id
(
transaction
.
id
())
if
reference
==
None
:
super
()
.
insert_entry
(
self
.
_transaction_collection
,
transaction
.
to_serializable_dict
())
else
:
raise
Value
Error
(
f
"ID {transaction['UniqueID']} already exists"
)
raise
Key
Error
(
f
"ID {transaction['UniqueID']} already exists"
)
def
all_transactions_for_use_case
(
self
,
use_case
:
str
)
->
List
[
Transaction
]:
result
=
super
()
.
get_entries
(
self
.
_transaction_collection
,
projection
=
{
'_id'
:
False
},
selection
=
{
"use_case"
:
use_case
})
...
...
src/transaction-hub-in/trace-retrieval-microservice/app/messaging/MessageHandler.py
View file @
26a88ef4
...
...
@@ -140,7 +140,9 @@ class MessageHandler:
# check if there is a doctype in the message
if
"docType"
not
in
transaction_message
.
keys
():
LOGGER
.
error
(
"Transaction has no docType, ignoring it."
)
LOGGER
.
error
(
"Transaction has no docType, storing it under docType 'unknown'."
)
transaction_message
[
"docType"
]
=
"unknown"
self
.
_mongo_repo
.
add_failed_transaction
(
transaction_message
)
return
use_case
=
transaction_message
[
"ApplicationType"
]
...
...
@@ -149,7 +151,7 @@ class MessageHandler:
try
:
tables
=
self
.
_rest_fetcher
.
fetch_schema_information
(
use_case
)
except
ValueError
as
e
:
print
(
f
"{e}
"
)
LOGGER
.
error
(
f
"{e}
\n
Storing it as a failed transaction.
"
)
self
.
_mongo_repo
.
add_failed_transaction
(
transaction_message
)
return
...
...
@@ -162,7 +164,8 @@ class MessageHandler:
# abort if table does not exist.
if
target_table
==
None
:
LOGGER
.
error
(
f
"There is no table '{docType}', ignoring the message."
)
LOGGER
.
error
(
f
"There is no table '{docType}', storing it as a failed transaction."
)
self
.
_mongo_repo
.
add_failed_transaction
(
transaction_message
)
return
mappings
=
table
[
"mappings"
]
...
...
@@ -189,8 +192,11 @@ class MessageHandler:
try
:
self
.
_mongo_repo
.
add_transaction
(
transaction
)
except
ValueError
as
e
:
LOGGER
.
error
(
f
"{e}, ignoring node"
)
except
KeyError
as
e
:
LOGGER
.
error
(
f
"{e}"
)
self
.
_mongo_repo
.
add_failed_transaction
(
transaction_message
)
return
msg
=
{
"type"
:
"new-trace"
,
...
...
src/transaction-hub-in/trace-retrieval-microservice/app/messaging/rest_fetcher.py
View file @
26a88ef4
...
...
@@ -18,7 +18,7 @@ class RestFetcher:
)
if
response
.
status_code
!=
200
:
raise
ValueError
(
"Error while retrieving schema information
"
)
raise
ValueError
(
f
"Error while retrieving schema information.
\t
Status-code:{response.status_code}
"
)
tables
=
json
.
loads
(
response
.
text
)
return
tables
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment