示例#1
0
from cloudbrain.settings import SPACEBREW_DATA_VIZ_NAME
from cloudbrain.router.spacebrew_router import SpacebrewRouter

from cloudbrain.spacebrew.spacebrew_utils import calculate_spacebrew_name
import time

start = time.time()

# todo: remove these lines line
subscriber_name = SPACEBREW_DATA_VIZ_NAME
publisher_ip = '107.170.205.177'
subscriber_ip = '10.0.0.245'
spacebrew_server_ip = '107.170.205.177'

# spacebrew router
sp_router = SpacebrewRouter(server=spacebrew_server_ip)
for path in DATA_VIZ_METRICS:

    publisher_metric_name = calculate_spacebrew_name(path)
    for muse_port in MUSE_PORTS:

        subscriber_metric_name = '%s-muse-%s' % (publisher_metric_name, muse_port)

        # route data FROM the muses
        publisher_name = 'muse-%s' % muse_port

        r = sp_router.link(publisher_metric_name, subscriber_metric_name, publisher_name, subscriber_name,
                            publisher_ip, subscriber_ip)
        print r

        time.sleep(0.1)
示例#2
0
sys.path.insert(0, dirname(dirname(dirname(abspath(__file__)))))
from cloudbrain.settings import EXPLO_BRAINSERVER_IP
from cloudbrain.settings import CASSANDRA_METRICS
from cloudbrain.settings import MUSE_PORTS
from cloudbrain.settings import SPACEBREW_CASSANDRA_NAME
from cloudbrain.settings import SPACEBREW_CASSANDRA_IP
from cloudbrain.settings import SPACEBREW_BRAINSERVER_IP
from cloudbrain.router.spacebrew_router import SpacebrewRouter

from cloudbrain.spacebrew.spacebrew_utils import calculate_spacebrew_name
import time

start = time.time()

# spacebrew router
sp_router = SpacebrewRouter(server=EXPLO_BRAINSERVER_IP)
for path in CASSANDRA_METRICS:

    publisher_metric_name = calculate_spacebrew_name(path)
    for muse_port in MUSE_PORTS:

        subscriber_metric_name = '%s-muse-%s' % (publisher_metric_name,
                                                 muse_port)

        # route data
        publisher_name = 'muse-%s' % muse_port
        subscriber_name = SPACEBREW_CASSANDRA_NAME

        r = sp_router.link(publisher_metric_name, subscriber_metric_name,
                           publisher_name, subscriber_name,
                           SPACEBREW_BRAINSERVER_IP, SPACEBREW_CASSANDRA_IP)
示例#3
0
from cloudbrain.settings import EXPLO_BRAINSERVER_IP
from cloudbrain.settings import CASSANDRA_METRICS
from cloudbrain.settings import MUSE_PORTS
from cloudbrain.settings import SPACEBREW_CASSANDRA_NAME
from cloudbrain.settings import SPACEBREW_CASSANDRA_IP
from cloudbrain.settings import SPACEBREW_BRAINSERVER_IP
from cloudbrain.router.spacebrew_router import SpacebrewRouter

from cloudbrain.spacebrew.spacebrew_utils import calculate_spacebrew_name
import time


start = time.time()

# spacebrew router
sp_router = SpacebrewRouter(server=EXPLO_BRAINSERVER_IP)
for path in CASSANDRA_METRICS:

    publisher_metric_name = calculate_spacebrew_name(path)
    for muse_port in MUSE_PORTS:

        subscriber_metric_name = '%s-muse-%s' % (publisher_metric_name, muse_port)

        # route data
        publisher_name = 'muse-%s' % muse_port
        subscriber_name = SPACEBREW_CASSANDRA_NAME

        r = sp_router.link(publisher_metric_name, subscriber_metric_name, publisher_name, subscriber_name,
                            SPACEBREW_BRAINSERVER_IP, SPACEBREW_CASSANDRA_IP)
        print r
示例#4
0
import time

from cassandra.cluster import Cluster
from flask import Flask, render_template, request, redirect, current_app

# add the shared settings file to namespace
import sys
from os.path import dirname, abspath
sys.path.insert(0, dirname(dirname(dirname(abspath(__file__)))))
from cloudbrain.settings import EXPLO_BRAINSERVER_IP

from cloudbrain.router.spacebrew_router import SpacebrewRouter

app = Flask(__name__)
app.config['PROPAGATE_EXCEPTIONS'] = True
sp_router = SpacebrewRouter(server=EXPLO_BRAINSERVER_IP)
sp_config_cache = {"subscriptions": {}, "routes": {}}

# configure cassandra cluster
cluster = Cluster()
session = cluster.connect('users')


def support_jsonp(f):
    """Wraps JSONified output for JSONP"""
    @wraps(f)
    def decorated_function(*args, **kwargs):
        callback = request.args.get('callback', False)
        if callback:
            content = str(callback) + '(' + str(f()) + ')'
            return current_app.response_class(content,