Esempio n. 1
0
counter_max = False

if len(argv) > 4 :
    counter_name = argv[4]
    counter_max = int(argv[5])

_home = os.environ["HOME"]

for _path, _dirs, _files in os.walk(os.path.abspath(_home)):
    for _filename in fnmatch.filter(_files, "code_instrumentation.py") :
        path.append(_path.replace("/lib/auxiliary",''))
        break

from scripts.common.cb_common import get_os_conn, get_ms_conn, get_my_ip, get_uuid_from_ip, report_app_metrics

_osci, _uuid, _cn = get_os_conn()

lock = False
leader = False

if counter_name and counter_max :
    lock = _osci.acquire_lock(_cn, _obj_type, "barrier", counter_name, 1)
    counter = int(_osci.update_counter(_cn, _obj_type, counter_name, "increment"))
    if counter == counter_max :
        print "I am leader"
        leader = True
        _osci.update_counter(_cn, _obj_type, counter_name, "decrement")
        _osci.release_lock(_cn, _obj_type, "barrier", lock)
        _osci.publish_message(_cn, _obj_type, _channel, _message, 1, 5.0)
        sleep(1)
        while True :
Esempio n. 2
0
counter_max = False

if len(argv) > 4 :
    counter_name = argv[4]
    counter_max = int(argv[5])

_home = os.environ["HOME"]

for _path, _dirs, _files in os.walk(os.path.abspath(_home)):
    for _filename in fnmatch.filter(_files, "code_instrumentation.py") :
        path.append(_path.replace("/lib/auxiliary",''))
        break

from scripts.common.cb_common import get_os_conn, get_ms_conn, get_my_ip, get_uuid_from_ip, report_app_metrics

_osci, _uuid, _cn = get_os_conn()

lock = False
leader = False

if counter_name and counter_max :
    lock = _osci.acquire_lock(_cn, _obj_type, "barrier", counter_name, 1)
    counter = int(_osci.update_counter(_cn, _obj_type, counter_name, "increment"))
    if counter == counter_max :
        print("I am leader")
        leader = True
        _osci.update_counter(_cn, _obj_type, counter_name, "decrement")
        _osci.release_lock(_cn, _obj_type, "barrier", lock)
        _osci.publish_message(_cn, _obj_type, _channel, _message, 1, 5.0)
        sleep(1)
        while True :
Esempio n. 3
0
from sys import argv, path

import os
import fnmatch

if len(argv) != 3 :
    print "Usage: cb_barrier.py <channel> <message>"
    exit(2)

_channel = argv[1]
_message = argv[2]

_home = os.environ["HOME"]

for _path, _dirs, _files in os.walk(os.path.abspath(_home)):
    for _filename in fnmatch.filter(_files, "code_instrumentation.py") :
        path.append(_path.replace("/lib/auxiliary",''))
        break

from scripts.common.cb_common import get_os_conn, get_ms_conn, get_my_ip, get_uuid_from_ip, report_app_metrics

_osci, _cn = get_os_conn()

_sub_channel = _osci.subscribe(_cn, "VM", _channel)

print "Subscribed to channel \"" + _channel + "\""
for message in _sub_channel.listen() :
    if isinstance(message["data"], str) :
        if message["data"].count(_channel) :
            _sub_channel.unsubscribe()
            exit(0)