示例#1
0
 def _getConnectUri(self):
     connectUri = ConfigHolder.getConfig().getProperty(BASE, CONNECT_URI)
     work = CacheHolder.getCache().get(HOST_NAME, WORKS)
     if work.brokerServer:
         brokerServer = StoreHolder.getStore().getBrokerServer(
             work.brokerServer)
         connectUri = brokerServer.connectUri
     return connectUri
    def test_status(self):
        self.store = StoreHolder.getStore()
        work = Work()
        work.hostName = getHostName()
        work.status = OFF_LINE
        self.store.updateWorkStatus(work)
        time.sleep(10)
        work.status = ON_LINE
        self.store.updateWorkStatus(work)

        time.sleep(20)
        work.status = REMOVE
        self.store.updateWorkStatus(work)
示例#3
0
    def getCabbage(self):
        connectUri = CabbageHolder._getConnectUri()
        work = CacheHolder.getCache().get(HOST_NAME, WORKS)
        if work.queues and len(work.queues) > 0:
            queues = []
            for queueName in work.queues:
                brokerQueue = StoreHolder.getStore().getQueue(queueName)
                queues.append(
                    Queue(name=brokerQueue.queueName,
                          exchange=Exchange(brokerQueue.exchangeName),
                          routing_key=brokerQueue.routingKey))
            celeryconfig.CELERY_QUEUES = tuple(queues)

        return Cabbage(broker=str(connectUri))
示例#4
0
 def addScriptJobId(self,jobId):
     store =None
     try:
         store = StoreHolder.getStore()
         log.info("节点【%s】当前任务【%s】的脚本开始加载。。。。" % (HOST_NAME,jobId))
         self.loadJobScript(jobId,store)
         work=store.getWork(HOST_NAME)
         self.sendBeReady(jobId,work,store)
         store.close()
     except Exception:
         Logger.exception(log)
     finally:
         if store:
             store.close()
 def _create(self):
     self.num_created += 1
     return StoreHolder.getStore()
示例#6
0
def worker():
    print "worker_pid:%d" % os.getpid()
    job = StoreHolder.getStore().getJob("123456789")
    print StoreHolder.getStore()
    print job.fileName
示例#7
0
 def setUp(self):
     self.store = StoreHolder.getStore()