-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #135 from wguanicedew/dev
optimize
- Loading branch information
Showing
11 changed files
with
107 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
# http://www.apache.org/licenses/LICENSE-2.0OA | ||
# | ||
# Authors: | ||
# - Wen Guan, <[email protected]>, 2019 - 2022 | ||
# - Wen Guan, <[email protected]>, 2019 - 2023 | ||
|
||
import datetime | ||
import random | ||
|
@@ -36,6 +36,9 @@ class Poller(BaseAgent): | |
|
||
def __init__(self, num_threads=1, poll_period=10, retries=3, retrieve_bulk_size=2, | ||
name='Poller', message_bulk_size=1000, **kwargs): | ||
self.set_max_workers() | ||
num_threads = self.max_number_workers | ||
|
||
super(Poller, self).__init__(num_threads=num_threads, name=name, **kwargs) | ||
self.config_section = Sections.Carrier | ||
self.poll_period = int(poll_period) | ||
|
@@ -184,6 +187,13 @@ def update_processing(self, processing, processing_model): | |
processing['update_processing']['parameters']['locking'] = ProcessingLocking.Idle | ||
# self.logger.debug("wen: %s" % str(processing)) | ||
processing['update_processing']['parameters']['updated_at'] = datetime.datetime.utcnow() | ||
# check update_processing status | ||
if 'status' in processing['update_processing']['parameters']: | ||
new_status = processing['update_processing']['parameters']['status'] | ||
if new_status == ProcessingStatus.Submitting and processing_model['status'].value > ProcessingStatus.Submitting.value: | ||
processing['update_processing']['parameters']['status'] = ProcessingStatus.Submitted | ||
|
||
self.logger.info(log_prefix + "update_processing: %s" % (processing['update_processing']['parameters'])) | ||
|
||
retry = True | ||
retry_num = 0 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
# http://www.apache.org/licenses/LICENSE-2.0OA | ||
# | ||
# Authors: | ||
# - Wen Guan, <[email protected]>, 2019 - 2022 | ||
# - Wen Guan, <[email protected]>, 2019 - 2023 | ||
|
||
import datetime | ||
import random | ||
|
@@ -42,6 +42,8 @@ class Clerk(BaseAgent): | |
""" | ||
|
||
def __init__(self, num_threads=1, poll_period=10, retrieve_bulk_size=10, pending_time=None, **kwargs): | ||
self.set_max_workers() | ||
num_threads = self.max_number_workers | ||
super(Clerk, self).__init__(num_threads=num_threads, name='Clerk', **kwargs) | ||
self.poll_period = int(poll_period) | ||
self.retrieve_bulk_size = int(retrieve_bulk_size) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
# http://www.apache.org/licenses/LICENSE-2.0OA | ||
# | ||
# Authors: | ||
# - Wen Guan, <[email protected]>, 2022 | ||
# - Wen Guan, <[email protected]>, 2022 - 2023 | ||
|
||
import time | ||
import uuid | ||
|
@@ -46,6 +46,7 @@ class EventType(Enum): | |
SyncProcessing = 34 | ||
TerminatedProcessing = 35 | ||
TriggerProcessing = 36 | ||
MsgTriggerProcessing = 37 | ||
|
||
UpdateCommand = 40 | ||
|
||
|
@@ -278,3 +279,14 @@ def to_json(self): | |
ret = super(TriggerProcessingEvent, self).to_json() | ||
ret['processing_id'] = self._processing_id | ||
return ret | ||
|
||
|
||
class MsgTriggerProcessingEvent(Event): | ||
def __init__(self, publisher_id, processing_id, content=None, counter=1): | ||
super(MsgTriggerProcessingEvent, self).__init__(publisher_id, event_type=EventType.MsgTriggerProcessing, content=content, counter=counter) | ||
self._processing_id = processing_id | ||
|
||
def to_json(self): | ||
ret = super(MsgTriggerProcessingEvent, self).to_json() | ||
ret['processing_id'] = self._processing_id | ||
return ret |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
# http://www.apache.org/licenses/LICENSE-2.0OA | ||
# | ||
# Authors: | ||
# - Wen Guan, <[email protected]>, 2019 - 2022 | ||
# - Wen Guan, <[email protected]>, 2019 - 2023 | ||
|
||
import copy | ||
import datetime | ||
|
@@ -40,6 +40,8 @@ class Transformer(BaseAgent): | |
|
||
def __init__(self, num_threads=1, poll_period=1800, retries=3, retrieve_bulk_size=10, | ||
message_bulk_size=10000, **kwargs): | ||
self.set_max_workers() | ||
num_threads = self.max_number_workers | ||
super(Transformer, self).__init__(num_threads=num_threads, name='Transformer', **kwargs) | ||
self.config_section = Sections.Transformer | ||
self.poll_period = int(poll_period) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters