コード例 #1
0
    def setUp(self):
        super(BenchmarkDatasource, self).setUp()
        config = {'benchmark': {
                  'module': helper.data_module_path('benchmark_driver.py'),
                  'poll_time': 0}}
        cage = harness.create(helper.root_path(), None, config)
        engine = cage.service_object('engine')
        api = {'policy': cage.service_object('api-policy'),
               'rule': cage.service_object('api-rule'),
               'table': cage.service_object('api-table'),
               'row': cage.service_object('api-row'),
               'datasource': cage.service_object('api-datasource'),
               'status': cage.service_object('api-status'),
               'schema': cage.service_object('api-schema')}
        helper.retry_check_subscriptions(engine, [(api['rule'].name,
                                         'policy-update')])
        helper.retry_check_subscribers(api['rule'], [(engine.name,
                                       'policy-update')])
        self.assertTrue('benchmark' in cage.services)
        datasource = cage.service_object('benchmark')
        table_name = datasource.BENCHTABLE

        self.assertEqual(datasource.state, {})

        # add a subscriber to ensure the updates end up in datasource.dataPath
        pubdata = datasource.pubdata.setdefault(table_name,
                                                dataobj.pubData(table_name))
        pubdata.addsubscriber(self.__class__.__name__, "push", "")
        self.assertTrue(datasource.pubdata[table_name])

        self.cage = cage
        self.engine = engine
        self.api = api
        self.table_name = table_name
        self.datasource = datasource
コード例 #2
0
ファイル: deepsix.py プロジェクト: mirzawaqasahmed/congress
    def inreq(self, msg):
        corruuid = msg.correlationId
        dataindex = msg.header['dataindex']

        if dataindex == "pubdata":
            newmsg = d6message.d6msg(key=msg.replyTo,
                                     replyTo=self.name,
                                     correlationId=msg.correlationId,
                                     type="rep",
                                     dataindex=dataindex,
                                     body=dataobj.dataObject(self.pubdata))
            self.send(newmsg)

        elif dataindex == "subdata":
            newmsg = d6message.d6msg(key=msg.replyTo,
                                     replyTo=self.name,
                                     correlationId=msg.correlationId,
                                     type="rep",
                                     dataindex=dataindex,
                                     body=dataobj.dataObject(self.subdata))
            self.send(newmsg)

        elif dataindex in self.pubdata:
            reply = d6message.d6msg(replyTo=self.name,
                                    type="rep",
                                    body=self.pubdata[dataindex].get(),
                                    srcmsg=msg)
            self.send(reply)

        elif hasattr(self, 'reqhandler'):
            self.pubdata[dataindex] = dataobj.pubData(dataindex, msg.body)
            self.pubdata[dataindex].requesters[msg.replyTo] = corruuid
            self.reqhandler(msg)
コード例 #3
0
ファイル: deepsix.py プロジェクト: ElVinto/congress
    def inreq(self, msg):
        corruuid = msg.correlationId
        dataindex = msg.header["dataindex"]

        if dataindex == "pubdata":
            newmsg = d6message.d6msg(
                key=msg.replyTo,
                replyTo=self.name,
                correlationId=msg.correlationId,
                type="rep",
                dataindex=dataindex,
                body=dataobj.dataObject(self.pubdata),
            )
            self.send(newmsg)

        elif dataindex == "subdata":
            newmsg = d6message.d6msg(
                key=msg.replyTo,
                replyTo=self.name,
                correlationId=msg.correlationId,
                type="rep",
                dataindex=dataindex,
                body=dataobj.dataObject(self.subdata),
            )
            self.send(newmsg)

        elif hasattr(self, "reqhandler"):
            self.pubdata[dataindex] = dataobj.pubData(dataindex, msg.body)
            self.pubdata[dataindex].requesters[msg.replyTo] = corruuid
            self.reqhandler(msg)

        else:
            self.log_exception("Received a request but have no handler: %s", msg)
コード例 #4
0
ファイル: deepsix.py プロジェクト: Cindia-blue/congress
    def inreq(self, msg):
        corruuid = msg.correlationId
        dataindex = msg.header['dataindex']

        if dataindex == "pubdata":
            newmsg = d6message.d6msg(key=msg.replyTo,
                                     replyTo=self.name,
                                     correlationId=msg.correlationId,
                                     type="rep",
                                     dataindex=dataindex,
                                     body=dataobj.dataObject(self.pubdata))
            self.send(newmsg)

        elif dataindex == "subdata":
            newmsg = d6message.d6msg(key=msg.replyTo,
                                     replyTo=self.name,
                                     correlationId=msg.correlationId,
                                     type="rep",
                                     dataindex=dataindex,
                                     body=dataobj.dataObject(self.subdata))
            self.send(newmsg)

        elif dataindex in self.pubdata:
            reply = d6message.d6msg(replyTo=self.name,
                                    type="rep",
                                    body=self.pubdata[dataindex].get(),
                                    srcmsg=msg)
            self.send(reply)

        elif hasattr(self, 'reqhandler'):
            self.pubdata[dataindex] = dataobj.pubData(dataindex, msg.body)
            self.pubdata[dataindex].requesters[msg.replyTo] = corruuid
            self.reqhandler(msg)
コード例 #5
0
ファイル: deepsix.py プロジェクト: ElVinto/congress
    def publish(self, dataindex, newdata, key=""):
        self.log_debug("publishing to dataindex %s with data %s", dataindex, strutils.mask_password(newdata, "****"))
        if dataindex not in self.pubdata:
            self.pubdata[dataindex] = dataobj.pubData(dataindex)

        self.pubdata[dataindex].update(newdata)

        self.push(dataindex, type="pub")
コード例 #6
0
ファイル: deepsix.py プロジェクト: mirzawaqasahmed/congress
    def publish(self, dataindex, newdata, key=''):
        self.log_debug("publishing to dataindex %s with data %s", dataindex,
                       newdata)
        if dataindex not in self.pubdata:
            self.pubdata[dataindex] = dataobj.pubData(dataindex)

        self.pubdata[dataindex].update(newdata)

        self.push(dataindex, type='pub')
コード例 #7
0
ファイル: deepsix.py プロジェクト: mirzawaqasahmed/congress
    def incmd(self, msg):
        self.log_debug("received CMD msg: %s", msg)
        corruuid = msg.correlationId
        dataindex = msg.header['dataindex']

        if corruuid not in self.pubdata:
            self.pubdata[corruuid] = dataobj.pubData(dataindex, msg.body)
            self.pubdata[corruuid].requesters[msg.replyTo] = corruuid
            self.cmdhandler(msg)
コード例 #8
0
ファイル: deepsix.py プロジェクト: ElVinto/congress
    def incmd(self, msg):
        # self.log_debug("received CMD msg: %s", msg)
        corruuid = msg.correlationId
        dataindex = msg.header["dataindex"]

        if corruuid not in self.pubdata:
            self.pubdata[corruuid] = dataobj.pubData(dataindex, msg.body)
            self.pubdata[corruuid].requesters[msg.replyTo] = corruuid
            self.cmdhandler(msg)
コード例 #9
0
ファイル: deepsix.py プロジェクト: Cindia-blue/congress
    def publish(self, dataindex, newdata, key=''):
        self.log_debug("publishing to dataindex %s with data %s",
                       dataindex, newdata)
        if dataindex not in self.pubdata:
            self.pubdata[dataindex] = dataobj.pubData(dataindex)

        self.pubdata[dataindex].update(newdata)

        self.push(dataindex, type='pub')
コード例 #10
0
ファイル: deepsix.py プロジェクト: MustWin/congress
    def publish(self, dataindex, newdata, key='', use_snapshot=False):
        # Note(ekcs): use_snapshot param is ignored.
        #   Accepted here on temporary basis for dse1+2 compatibility.
        self.log_debug("publishing to dataindex %s with data %s",
                       dataindex, strutils.mask_password(newdata, "****"))
        if dataindex not in self.pubdata:
            self.pubdata[dataindex] = dataobj.pubData(dataindex)

        self.pubdata[dataindex].update(newdata)

        self.push(dataindex, type='pub')
コード例 #11
0
ファイル: deepsix.py プロジェクト: ElVinto/congress
    def inpull(self, msg):
        # self.log_debug("received PULL msg: %s", msg)
        dataindex = msg.header["dataindex"]

        if dataindex in self.pubdata:

            reply = d6message.d6msg(replyTo=self.name, type="rep", body=self.pubdata[dataindex].get(), srcmsg=msg)
            self.send(reply)

        else:
            self.pubdata[dataindex] = dataobj.pubData(dataindex, msg.body)
            self.subhandler(msg)

        self.pubdata[dataindex].addsubscriber(msg.replyTo, "pull", msg.correlationId)
コード例 #12
0
ファイル: deepsix.py プロジェクト: mirzawaqasahmed/congress
    def insub(self, msg):
        self.log_info("received SUB msg: %s", msg)
        corruuid = msg.correlationId
        dataindex = msg.header['dataindex']
        sender = msg.replyTo

        if corruuid not in self.subscriberCorrelationUuids:

            if dataindex not in self.pubdata:
                self.pubdata[dataindex] = dataobj.pubData(dataindex, msg.body)
                if hasattr(self, "subhandler"):
                    self.subhandler(msg)

            self.pubdata[dataindex].addsubscriber(sender, "push", corruuid)
            self.subscriberCorrelationUuids.add(corruuid)
            self.push(dataindex, sender, type='sub')
コード例 #13
0
ファイル: deepsix.py プロジェクト: mirzawaqasahmed/congress
    def inpull(self, msg):
        self.log_debug("received PULL msg: %s", msg)
        dataindex = msg.header['dataindex']

        if dataindex in self.pubdata:

            reply = d6message.d6msg(replyTo=self.name,
                                    type="rep",
                                    body=self.pubdata[dataindex].get(),
                                    srcmsg=msg)
            self.send(reply)

        else:
            self.pubdata[dataindex] = dataobj.pubData(dataindex, msg.body)
            self.subhandler(msg)

        self.pubdata[dataindex].addsubscriber(msg.replyTo, "pull",
                                              msg.correlationId)
コード例 #14
0
ファイル: deepsix.py プロジェクト: ElVinto/congress
    def insub(self, msg):
        # self.log_info("received SUB msg: %s", msg)
        corruuid = msg.correlationId
        dataindex = msg.header["dataindex"]
        sender = msg.replyTo

        if corruuid not in self.subscriberCorrelationUuids:

            if dataindex not in self.pubdata:
                self.pubdata[dataindex] = dataobj.pubData(dataindex, msg.body)
            # always call subhandler so subclass has a chance to know more
            # about the subscription
            if hasattr(self, "subhandler"):
                self.subhandler(msg)

            self.pubdata[dataindex].addsubscriber(sender, "push", corruuid)
            self.subscriberCorrelationUuids.add(corruuid)
            self.push(dataindex, sender, type="sub")
コード例 #15
0
    def setUp(self):
        super(BenchmarkDatasource, self).setUp()
        config = {
            'benchmark': {
                'module': helper.data_module_path('benchmark_driver.py'),
                'poll_time': 0
            }
        }
        cage = harness.create(helper.root_path(), helper.state_path(), None,
                              config)
        engine = cage.service_object('engine')
        api = {
            'policy': cage.service_object('api-policy'),
            'rule': cage.service_object('api-rule'),
            'table': cage.service_object('api-table'),
            'row': cage.service_object('api-row'),
            'datasource': cage.service_object('api-datasource'),
            'status': cage.service_object('api-status'),
            'schema': cage.service_object('api-schema')
        }
        helper.retry_check_subscriptions(engine,
                                         [(api['rule'].name, 'policy-update')])
        helper.retry_check_subscribers(api['rule'],
                                       [(engine.name, 'policy-update')])
        self.assertTrue('benchmark' in cage.services)
        datasource = cage.service_object('benchmark')
        table_name = datasource.BENCHTABLE

        self.assertEqual(datasource.state, {})

        # add a subscriber to ensure the updates end up in datasource.dataPath
        pubdata = datasource.pubdata.setdefault(table_name,
                                                dataobj.pubData(table_name))
        pubdata.addsubscriber(self.__class__.__name__, "push", "")
        self.assertTrue(datasource.pubdata[table_name])

        self.cage = cage
        self.engine = engine
        self.api = api
        self.table_name = table_name
        self.datasource = datasource