Skip to content

Commit

Permalink
Fixed synchronization of metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
JosepSampe committed Oct 28, 2017
1 parent ea7b8d3 commit 418ff92
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 16 deletions.
16 changes: 7 additions & 9 deletions api/api/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,15 +162,13 @@ def rsync_dir_with_nodes(directory):
if not node['ssh_access']:
raise FileSynchronizationException("SSH credentials missing. Please, set the credentials for this "+node['type']+" node: "+node['name'])

# Directory is only synchronized if node status is UP
if calendar.timegm(time.gmtime()) - int(float(node['last_ping'])) <= NODE_STATUS_THRESHOLD:
# The basename of the path is not needed because it will be the same as source dir
logger.info("Rsync - pushing to "+node['type']+":"+node['name'])
dest_directory = os.path.dirname(directory)
data = {'directory': directory, 'dest_directory': dest_directory, 'node_ip': node['ip'],
'ssh_username': node['ssh_username'], 'ssh_password': node['ssh_password']}

threading.Thread(target=rsync, args=(node, data)).start()
# The basename of the path is not needed because it will be the same as source dir
logger.info("Rsync - pushing to "+node['type']+":"+node['name'])
dest_directory = os.path.dirname(directory)
data = {'directory': directory, 'dest_directory': dest_directory, 'node_ip': node['ip'],
'ssh_username': node['ssh_username'], 'ssh_password': node['ssh_password']}

threading.Thread(target=rsync, args=(node, data)).start()


def rsync(node, data):
Expand Down
7 changes: 0 additions & 7 deletions api/metrics/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,13 +273,6 @@ def post(self, request):

r.hmset('workload_metric:' + str(workload_metric_id), data)

if data['enabled']:
metric_name = data['metric_name'].split('.')[0]
if data['put']:
start_metric('put_'+metric_name)
if data['get']:
start_metric('get_'+metric_name)

return JSONResponse(data, status=status.HTTP_201_CREATED)

except DataError:
Expand Down

0 comments on commit 418ff92

Please sign in to comment.