Esempio n. 1
0
    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()
Esempio n. 2
0
    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()
Esempio n. 3
0
    def start(self):
        work = Work()
        work.hostName = HOST_NAME
        work.port = "1024"
        work.ip = LOCAL_IP

        work.status = READY

        with storeFactory.store() as store:
            if not store.isExistWork(work):
                store.saveWork(work)
                CacheHolder.getCache().put(HOST_NAME, work, WORKS)
            else:
                CacheHolder.getCache().put(HOST_NAME, store.getWork(HOST_NAME),
                                           WORKS)
                store.updateWorkStatus(work)

            self.runCeleryServer(work, store)

        t2 = threading.Thread(target=scheduler)
        t2.setDaemon(True)
        t2.start()
        tornado.ioloop.IOLoop.current().start()