Esempio n. 1
0
    def iamAlive(self, id, args=None):
        print "I am alive..."
        msg = u.createAckMsg(id,1)

        self.msgObj.send(msg)
        self.msgObj.inbox.pop(id,0)
        return
Esempio n. 2
0
    def addClient(self, id, args ): # find arguments in args of msgbox
        # collects a client from the leader.
        # Needs some client configs: gameID, fromPath
        # start a subprocess to keep syncing data, for now lets start thread
        #msgD = self.msgObj.inbox[id]
        clientIP = args[0]
        gameID = args[1]
        fromPath = args[2]

        self.workerConfig["worker"]["clients"].append(clientIP)

        self.workerConfig["status"][clientIP] = {
            "today":{
                "count": 0,
                "bytes": 0
            },
            "full": {
                "count": 0,
                "bytes": 0
            },
            "fromdate": "<date since when client exists>"
        }
        self.workerConfig["status"][clientIP]["fromdate"] = str(datetime.now())

        utils.writeJSON(os.path.join(self.configDir, self.configFile), self.workerConfig)

        # [TODO]  in case start cluster but not new, for each client IP who does not have process to get data, start them
        # start rsync job for all this client
        print "starting Rsync for ip: %s , gameID: %s , fromPath: %s " % ( clientIP, gameID, fromPath)

        print "I am alive..."
        msg = u.createAckMsg(id,1)

        self.msgObj.send(msg)
        self.msgObj.inbox.pop(id,0)

        # Starting Rsync runner
        print "Starting Rsync...."
        self.doCopy()

        pass