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)
Example #2
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()
Example #3
0
    def stop(self):
        CabbageControlHolder.getCabbageControl().stopCelery()
        work = Work()
        work.hostName = HOST_NAME
        work.status = REMOVE
        self.status = work.status
        with storeFactory.store() as store:
            store.updateWorkStatus(work)

        tornado.ioloop.IOLoop.current().stop()
Example #4
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()
Example #5
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()
Example #6
0
 def onLine(self):
     work = Work()
     work.hostName = HOST_NAME
     work.status = ON_LINE
     with storeFactory.store() as store:
         self.runCeleryServer(work, store)