Пример #1
0
def monitor_graph(host, port, dump_path):
    """
    monitors the execution status of a graph by polling host/port
    """

    # use monitorclient to interact with island manager
    dc = DataIslandManagerClient(host=host, port=port, timeout=MM_WAIT_TIME)

    # We want to monitor the status of the execution
    fp = os.path.dirname(dump_path)
    if (not os.path.exists(fp)):
        return
    gfile = "{0}_g.log".format(dump_path)
    sfile = "{0}_s.log".format(dump_path)
    graph_dict = dict()  # k - ssid, v - graph spec json obj
    logger.debug("Ready to check sessions")

    while True:

        for session in dc.sessions(
        ):  #TODO the interval won't work for multiple sessions
            stt = time.time()
            ssid = session['sessionId']
            wgs = {}
            wgs['ssid'] = ssid
            wgs['gs'] = dc.graph_status(ssid)  #TODO check error
            time_str = '%.3f' % time.time()
            wgs['ts'] = time_str

            if (not graph_dict.has_key(ssid)):
                graph = dc.graph(ssid)
                graph_dict[ssid] = graph
                wg = {}
                wg['ssid'] = ssid
                wg['g'] = graph
                # append to file as a line
                with open(gfile, 'a') as fg:
                    json.dump(wg, fg)
                    fg.write(os.linesep)

            # append to file as a line
            with open(sfile, 'a') as fs:
                json.dump(wgs, fs)
                fs.write(os.linesep)

            dt = time.time() - stt
            if (dt < GRAPH_MONITOR_INTERVAL):
                time.sleep(GRAPH_MONITOR_INTERVAL - dt)
def build_and_deploy_graph(**kwargs):
    graph = BuildGraph(**kwargs)
    graph.build()

    LOGGER.info('Connection to {0}:{1}'.format(kwargs['host'], kwargs['port']))
    client = DataIslandManagerClient(kwargs['host'], kwargs['port'], timeout=30)

    client.create_session(graph.session_id)
    json_dumps = json.dumps(graph.drop_list, indent=2)
    LOGGER.info('json:\n{}'.format(json_dumps))
    client.append_graph(graph.session_id, json_dumps)
    client.deploy_session(graph.session_id, get_roots(graph.drop_list))
Пример #3
0
    def test_recursive(self):
        sid = "lala"
        c = DataIslandManagerClient(hostname)
        c.createSession(sid)

        # invalid dropspec, app doesn't exist
        # This is not checked at the DIM level but only at the NM level
        # The exception should still pass through though
        with self.assertRaises(exceptions.SubManagerException) as cm:
            c.addGraphSpec(
                sid,
                [
                    {
                        "oid": "a",
                        "type": "app",
                        "app": "doesnt.exist",
                        "node": hostname,
                        "reprodata": default_repro.copy(),
                    },
                    default_graph_repro.copy(),
                ],
            )
        ex = cm.exception
        self.assertTrue(hostname in ex.args[0])
        self.assertTrue(isinstance(ex.args[0][hostname], InvalidGraphException))
Пример #4
0
    def test_recursive(self):

        sid = 'lala'
        c = DataIslandManagerClient(hostname)
        c.createSession(sid)

        # invalid dropspec, app doesn't exist
        # This is not checked at the DIM level but only at the NM level
        # The exception should still pass through though
        with self.assertRaises(exceptions.SubManagerException) as cm:
            c.addGraphSpec(sid, [{
                'oid': 'a',
                'type': 'app',
                'app': 'doesnt.exist',
                'node': hostname
            }])
        ex = cm.exception
        self.assertTrue(hostname in ex.args[0])
        self.assertTrue(isinstance(ex.args[0][hostname],
                                   InvalidGraphException))
Пример #5
0
                interpolation="linear",
                start="1408MHz",
                width="1412kHz",
                veltype="radio",
                spw="",
                combinespws=True,
                nspw=1,
                createmms=False,
                datacolumn="data",
            )
            sp.addInput(vis_in)
            sp.addOutput(split_out)
            cl.addInput(split_out)

            droplist.append(vis_in)
            droplist.append(split_out)
            droplist.append(sp)

        c = DataIslandManagerClient()
        c.create_session(sessionId)
        c.append_graph(sessionId, droplist)
        c.deploy_session(sessionId)

    except Exception as e:
        import traceback

        traceback.print_exc()
        sys.exit(-1)

    sys.exit(0)