-
Notifications
You must be signed in to change notification settings - Fork 355
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Syncing perf_coll_fw_enhance feature branch to master (#692)
* Make job scheduler local to task process (#674) * Make job scheduler local to task process * Notify distributor when a new task added (#678) * Remove db-scan for new task creation (#680) * Use consistent hash to manage the topic (#681) * Remove the periodically call from task distributor (#686) * Start one historic collection immediate when a job is rescheduled (#685) * Start one historic collection immediate when a job is rescheduled * Remove failed task distributor (#687) * Improving Failed job handling and telemetry job removal (#689) Co-authored-by: ThisIsClark <liuyuchibubao@gmail.com> Co-authored-by: Ashit Kumar <akopensrc@gmail.com>
- Loading branch information
1 parent
cdbaf38
commit e73f251
Showing
33 changed files
with
1,095 additions
and
566 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
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
Empty file.
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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# Copyright 2021 The SODA Authors. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
from oslo_log import log | ||
|
||
from delfin import manager | ||
from delfin.leader_election.distributor import task_distributor | ||
|
||
LOG = log.getLogger(__name__) | ||
|
||
|
||
class PerfJobManager(manager.Manager): | ||
"""Generate job to job distributor""" | ||
|
||
RPC_API_VERSION = '1.0' | ||
|
||
def __init__(self, service_name=None, *args, **kwargs): | ||
super(PerfJobManager, self).__init__(*args, **kwargs) | ||
|
||
def add_new_job(self, context, task_id): | ||
distributor = task_distributor.TaskDistributor(context) | ||
distributor.distribute_new_job(task_id) |
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 |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# Copyright 2021 The SODA Authors. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
|
||
import six | ||
from oslo_config import cfg | ||
from oslo_log import log | ||
|
||
from delfin import db | ||
from delfin.common.constants import TelemetryCollection | ||
from delfin.coordination import ConsistentHashing | ||
from delfin.task_manager import metrics_rpcapi as task_rpcapi | ||
|
||
CONF = cfg.CONF | ||
LOG = log.getLogger(__name__) | ||
|
||
|
||
class TaskDistributor(object): | ||
def __init__(self, ctx): | ||
self.ctx = ctx | ||
self.task_rpcapi = task_rpcapi.TaskAPI() | ||
|
||
def distribute_new_job(self, task_id): | ||
partitioner = ConsistentHashing() | ||
partitioner.start() | ||
executor = partitioner.get_task_executor(task_id) | ||
try: | ||
db.task_update(self.ctx, task_id, {'executor': executor}) | ||
LOG.info('Distribute a new job, id: %s' % task_id) | ||
self.task_rpcapi.assign_job(self.ctx, task_id, executor) | ||
except Exception as e: | ||
LOG.error('Failed to distribute the new job, reason: %s', | ||
six.text_type(e)) | ||
raise e | ||
|
||
def distribute_failed_job(self, failed_task_id, executor): | ||
|
||
try: | ||
db.failed_task_update(self.ctx, failed_task_id, | ||
{'executor': executor}) | ||
LOG.info('Distribute a failed job, id: %s' % failed_task_id) | ||
self.task_rpcapi.assign_failed_job(self.ctx, failed_task_id, | ||
executor) | ||
except Exception as e: | ||
LOG.error('Failed to distribute failed job, reason: %s', | ||
six.text_type(e)) | ||
raise e | ||
|
||
@classmethod | ||
def job_interval(cls): | ||
return TelemetryCollection.PERIODIC_JOB_INTERVAL |
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 |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# Copyright 2021 The SODA Authors. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
""" | ||
periodical task manager for metric collection tasks** | ||
""" | ||
from oslo_log import log | ||
|
||
from delfin import manager | ||
from delfin.coordination import ConsistentHashing | ||
from delfin.task_manager.scheduler import schedule_manager | ||
from delfin.task_manager.scheduler.schedulers.telemetry.job_handler \ | ||
import FailedJobHandler | ||
from delfin.task_manager.scheduler.schedulers.telemetry.job_handler \ | ||
import JobHandler | ||
from delfin.task_manager.tasks import telemetry | ||
|
||
LOG = log.getLogger(__name__) | ||
|
||
|
||
class MetricsTaskManager(manager.Manager): | ||
"""manage periodical tasks""" | ||
|
||
RPC_API_VERSION = '1.0' | ||
|
||
def __init__(self, service_name=None, *args, **kwargs): | ||
self.telemetry_task = telemetry.TelemetryTask() | ||
super(MetricsTaskManager, self).__init__(*args, **kwargs) | ||
scheduler = schedule_manager.SchedulerManager() | ||
scheduler.start() | ||
JobHandler.schedule_boot_jobs() | ||
partitioner = ConsistentHashing() | ||
partitioner.start() | ||
partitioner.join_group() | ||
|
||
def assign_job(self, context, task_id): | ||
instance = JobHandler.get_instance(context, task_id) | ||
instance.schedule_job(task_id) | ||
|
||
def remove_job(self, context, task_id): | ||
instance = JobHandler.get_instance(context, task_id) | ||
instance.remove_job(task_id) | ||
|
||
def assign_failed_job(self, context, failed_task_id): | ||
instance = FailedJobHandler.get_instance(context, failed_task_id) | ||
instance.schedule_failed_job(failed_task_id) | ||
|
||
def remove_failed_job(self, context, failed_task_id): | ||
instance = FailedJobHandler.get_instance(context, failed_task_id) | ||
instance.remove_failed_job(failed_task_id) |
Oops, something went wrong.