コード例 #1
0
    def registerToMaster(self):
            try:
                bootmaster = StandingCall(copy_ref_with_timeout(self.master,config.BOOTSTRAP_CONTACT_TIMEOUT), 1, max_repeat=config.BOOTSTRAP_CONTACT_REPEAT)

                self.wid,file_server_ior = bootmaster.registerWorker(self.uuid,1) # ordinary workers have capacity 1

                file_server = self.program.orb.string_to_object(file_server_ior)
                
                from diane.FileTransfer import FileTransferClient
                self.ftc = FileTransferClient(file_server,self.uuid)
                import diane.workspace
                # collect and upload vcard
                vcard = self.make_vcard()
                file('vcard.txt','w').write(repr(vcard))
                self.ftc.upload('vcard.txt',os.path.join(diane.workspace.workerSubdir(self.wid),'vcard.txt'))

                #TEST - multiple registrations
                #for i in range(1000):
                #    self.wid = self.master.registerWorker(self._this())
                #logger.info('master ping %s',str(self.master.ping()))

                self.heartbeat_thread = HeartbeatThread(self,self.master)
                self.heartbeat_thread.start()
            except CORBA.TRANSIENT:
                logger.error('unable to establish connection to the master after timeout=%d seconds'%config.BOOTSTRAP_CONTACT_TIMEOUT)
                raise
            except DIANE_CORBA.XHangup:
                logger.warning('I was refused a registration (my peer_id=%s)',self.uuid)
                raise