コード例 #1
0
def updateJobCache(jobId):
    store = storeFactory.getStore()
    try:
        job=store.getJob(jobId)
        CacheHolder.getCache().put(jobId, job,JOBS)
    finally:
        storeFactory.returnStroe(store)
コード例 #2
0
def brokerServerWatch(children):
    for brokerName in children:
        if not CabbageHolder.getServerCabbages().has_key(brokerName):
            store = storeFactory.getStore()
            try:
                brokerServer = store.getBrokerServer(brokerName)
                zope.event.notify(AddBrokerServerEvent(brokerServer))
            finally:
                storeFactory.returnStroe(store)
コード例 #3
0
def workWatch(children):
    store = storeFactory.getStore()
    try:
        for hostname in children:
            if CacheHolder.getCache().hasKey(hostname, WORKS) is False:
                    work = store.getWork(hostname)
                    CacheHolder.getCache().put(hostname, work,WORKS)
    finally:
        storeFactory.returnStroe(store)
コード例 #4
0
 def _excute(cls, *args, **kwargs):
     store = storeFactory.getStore()
     try:
         return callback(cls, store, *args, **kwargs)
     except Exception as e:
         traceback.print_exc()
         raise e
     finally:
         storeFactory.returnStroe(store)
コード例 #5
0
def jobWebWatch(children):
    store = storeFactory.getStore()
    try:
        brokers={}
        for jobId in children:
            try:
                job=store.getJob(jobId)#toreHolder.getStore().getJob(jobId)
                if CacheHolder.getCache().hasKey(jobId, JOBS) is False:
                    CacheHolder.getCache().put(jobId, job,JOBS)
                
#                 kazooClient.addDataListener(parent+"/"+STATUS, jobRunStatusWatch)
                #偷个懒,只要没有删除的全部放到ROUTER里面去
                if job.status != JOB_DELETE:
                    brokerServer=job.brokerServer
                   
                    routes={}
                    for taskName in job.tasks:
                        que=store.getQueue(job.brokerQueue)
                        routes[taskName]={'queue': que.queueName, 'routing_key': que.routingKey}
                        TaskCacheHolder.getJobCache().put(taskName,job.jobId)
                         
                    if brokerServer in brokers:
                        brokers[brokerServer].update(routes)
                    else:
                        brokers[brokerServer] = routes
            except Exception:
                Logger.exception( log)
                
        #偷个懒,只要没有删除的全部放到ROUTER里面去
        for broker,routes in brokers.items():
            brokerServer = store.getBrokerServer(broker)
            #修复BUG,导致任务提交的celery队列里面去了
            cabbage = Cabbage(hostName=brokerServer.hostName,broker=brokerServer.connectUri)
            cabbage.app.conf.update(CELERY_ROUTES = routes)
            CabbageHolder.getServerCabbages()[brokerServer.hostName] = cabbage
            
#             CabbageHolder.getServerCabbages()[brokerServer.hostName].getApp().conf.update(CELERY_ROUTES = routes)
            Logger.info(log,"更新队列服务器【%s】ROUTES【%s】"% (brokerServer.hostName,str(routes)))
        
    except Exception:
        Logger.exception( log)
    finally:
        storeFactory.returnStroe(store)