def run(self): registerClientEvent() work = Work() work.hostName = getHostName() work.port = "1024" work.status = "aa" self.kazooClient = ZookeeperClientHolder.getClient() self.store = ZookeeperStore() self.kazooClient.addChildListener("/cabbage/jobs", jobChildWatch) self.store.saveWork(work) self.t1 = threading.Thread(target=run) self.t1.setDaemon(True) self.t1.start() time.sleep(5) self.app = CabbageHolder.getCabbage().getApp() # clientDir = ConfigHolder.getConfig().getProperty(BASE,CLIENT_FILE_DIRECTORY) # if os.path.exists(clientDir) is False: # os.mkdir(clientDir) time.sleep(10) i = self.app.control.inspect() result = i.stats() print result print i.registered_tasks() print self.app.events.State().workers.items()
def test_status(self): work=Work() work.hostName=getHostName() workContorl = CeleryWorkContorl(work) workContorl.stopService() time.sleep(10) workContorl.startService() print workContorl.serviceIsAlive() time.sleep(20) workContorl.stop()
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 setUp(self): registerClientEvent() work = Work() work.hostName = getHostName() work.port = "1024" work.status = "aa" self.kazooClient = ZookeeperClientHolder.getClient() self.store = ZookeeperStore() self.kazooClient.addChildListener("/cabbage/jobs", jobChildWatch) self.store.saveWork(work) self.t1 = threading.Thread(target=run) self.t1.setDaemon(True) self.t1.start() time.sleep(5) self.app = CabbageHolder.getCabbage().getApp()
# -*- encoding: utf-8 -*- ''' Created on 2016年8月17日 @author: hua ''' from cabbage.common.log.logger import Logger from cabbage.utils.host_name import getHostName def error(): raise Exception("dadsfasdf") log = Logger.getLogger(__name__) try: error() except Exception as e: log.exception(getHostName())
def test_update(self): for i in range(5): print i self.kazooClient.putData("/cabbage/works/"+getHostName()+"/"+BROKER_SERVER, str(i)) time.sleep(10)
def test_update(self): print self.kazooClient.getData("/cabbage/works/" + getHostName() + "/" + BROKER_SERVER) print self.kazooClient.getData("/cabbage/works/" + getHostName() + "/" + QUEUES)
# -*- encoding: utf-8 -*- ''' Created on 2016年6月24日 @author: hua ''' from cabbage.utils.host_name import getHostName print getHostName()