Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
JosepSampe committed Oct 5, 2017
2 parents 06bb2de + e19b29b commit 3afe030
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 12 deletions.
18 changes: 12 additions & 6 deletions api/controllers/actors/abstract_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ def __init__(self):
logger.error('"Error connecting with Redis DB"')

self.metrics = dict()
self.metric_data = Queue.Queue()
self.rmq_messages = Queue.Queue()

def _subscribe_metrics(self):
try:
Expand Down Expand Up @@ -67,18 +65,18 @@ def _send_message_rmq(self, routing_key, message):
def _init_consum(self, queue, routing_key):
try:
self.consumer = self.host.spawn(self.id + "_consumer", settings.CONSUMER_MODULE,
[self.queue, self.routing_key, self.proxy])
self.start_consuming()
[queue, routing_key, self.proxy])
self.consumer.start_consuming()
except Exception as e:
print e
logger.error(str(e))

def notify(self, body):
"""
Method called from the consumer to indicate the value consumed from the
RabbitMQ queue. After receive the value, this value is communicated to
all the observers subscribed to this metric.
"""
self.rmq_messages.put(body)
self.compute_rmq_message(body)

def get_target(self):
"""
Expand Down Expand Up @@ -109,6 +107,14 @@ def stop_actor(self):
for metric in self.metrics:
metric_actor = self.host.lookup(metric)
metric_actor.detach(self.id, self.get_target())
if self.consumer:
self.consumer.stop_consuming()
except NotFoundError as e:
logger.error(e)
self.host.stop_actor(self.id)

def compute_data(self, metric_data):
raise NotImplementedError()

def compute_rmq_message(self, body):
raise NotImplementedError()
6 changes: 4 additions & 2 deletions api/controllers/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,8 @@ def start_controller(controller_id, controller_name, controller_class_name):
controller_actors[controller_id] = host.spawn(controller_name, controller_location)
controller_actors[controller_id].run()
logger.info("Controller, Started controller actor: "+controller_location)
except:
except Exception as e:
logger.error(str(e))
raise ValueError


Expand All @@ -183,5 +184,6 @@ def stop_controller(controller_id):
controller_actors[controller_id].stop_actor()
del controller_actors[controller_id]
logger.info("Controller, Stopped controller actor: " + str(controller_id))
except:
except Exception as e:
logger.error(str(e))
raise ValueError
8 changes: 5 additions & 3 deletions api/filters/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
import os

from api.common import rsync_dir_with_nodes, JSONResponse, \
get_redis_connection, get_token_connection, make_sure_path_exists, save_file, md5
get_redis_connection, get_token_connection, make_sure_path_exists, save_file, md5,\
to_json_bools
from api.exceptions import SwiftClientError, StorletNotFoundException, FileSynchronizationException

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -85,6 +86,7 @@ def filter_detail(request, filter_id):

if request.method == 'GET':
my_filter = r.hgetall("filter:" + str(filter_id))
to_json_bools(my_filter, 'put', 'get')
return JSONResponse(my_filter, status=status.HTTP_200_OK)

elif request.method == 'PUT':
Expand All @@ -94,7 +96,7 @@ def filter_detail(request, filter_id):
return JSONResponse("Invalid format or empty request", status=status.HTTP_400_BAD_REQUEST)

try:
if str(filter_id) != data['dsl_name']:
if 'dsl_name' in data and str(filter_id) != data['dsl_name']:
# Check for possible activated policies
policies = r.keys('policy:*')
for policy_key in policies:
Expand Down Expand Up @@ -474,7 +476,7 @@ def set_filter(r, target, filter_data, parameters, token):
metadata = {"X-Object-Meta-Storlet-Language": filter_data["language"],
"X-Object-Meta-Storlet-Interface-Version": filter_data["interface_version"],
"X-Object-Meta-Storlet-Dependency": '',
"X-Object-Meta-Storlet-Object-Metadata": filter_data["object_metadata"],
"X-Object-Meta-Storlet-Object-Metadata": '',
"X-Object-Meta-Storlet-Main": filter_data["main"]
}

Expand Down
5 changes: 4 additions & 1 deletion api/metrics/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,10 @@ def metric_module_detail(request, metric_module_id):
redis_data.update(data)
data = redis_data

metric_name = data['metric_name'].split('.')[0]
if 'metric_name' not in data:
metric_name = r.hget('workload_metric:' + str(metric_id), 'metric_name').split('.')[0]
else:
metric_name = data['metric_name'].split('.')[0]

if data['enabled']:
try:
Expand Down

0 comments on commit 3afe030

Please sign in to comment.