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)
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))
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()
def worker(): print "worker_pid:%d" % os.getpid() job = StoreHolder.getStore().getJob("123456789") print StoreHolder.getStore() print job.fileName
def setUp(self): self.store = StoreHolder.getStore()