-
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.
Notify distributor when a new task added (#678)
- Loading branch information
1 parent
903138a
commit d2b4140
Showing
8 changed files
with
126 additions
and
20 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 |
---|---|---|
@@ -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
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,49 @@ | ||
# 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. | ||
|
||
""" | ||
Client side of the metrics task manager RPC API. | ||
""" | ||
|
||
from oslo_config import cfg | ||
from oslo_log import log | ||
|
||
from delfin import db | ||
from delfin import exception | ||
from delfin.common import constants | ||
from delfin.task_manager import metrics_rpcapi | ||
|
||
LOG = log.getLogger(__name__) | ||
CONF = cfg.CONF | ||
|
||
|
||
def create_perf_job(context, storage_id, capabilities): | ||
# Add it to db | ||
# Check resource_metric attribute availability and | ||
# check if resource_metric is empty | ||
if 'resource_metrics' not in capabilities \ | ||
or not bool(capabilities.get('resource_metrics')): | ||
raise exception.EmptyResourceMetrics() | ||
|
||
task = dict() | ||
task.update(storage_id=storage_id) | ||
task.update(args=capabilities.get('resource_metrics')) | ||
task.update(interval=CONF.telemetry.performance_collection_interval) | ||
task.update( | ||
method=constants.TelemetryCollection.PERFORMANCE_TASK_METHOD) | ||
db.task_create(context=context, values=task) | ||
# Add it to RabbitMQ | ||
filters = {'storage_id': storage_id} | ||
task_id = db.task_get_all(context, filters=filters)[0].get('id') | ||
metrics_rpcapi.TaskAPI().create_perf_job(context, 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
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