Пример #1
0
    def __init__(self,program,peer,ds_enabled,labels):
        BaseThread.__init__(self,name='WorkerAgent')
        from diane.util.compatibility import uuid
        self.uuid = str(uuid())
        self.program = program
        self.ds_enabled = ds_enabled
        if ds_enabled:
            self.ds = peer
            self.master = None
        else:
            self.ds = None
            self.master = peer
        self.labels = labels
        self.heartbeat_thread = None
        self.wid = None
        self.application = None
        self.finalization_cookie = None
        self.ftc = None #file transfer client connected to the default file transfer server
        
        # if this worker is run as a Ganga job (optional) then retrive the Ganga Job UUID to make it available
        # in monitoring/vcards etc...

        self.ganga_job_uuid =  os.environ.get('GANGA_JOB_UUID', '')

        if not self.ganga_job_uuid:
            try:
                self.ganga_job_uuid = open('ganga_job_uuid', 'r').read() 
            except IOError:
                pass 
Пример #2
0
 def __init__(self,snapshot_name,ntraj=1):
     self.snapshot_name = snapshot_name
     r = re.compile('%s[_](?P<ntraj_count>\d+)[_](?P<beta>\d+(\.\d*)?|\.\d+)[_](?P<seed>\d+)'%SNAPSHOT_PREFIX).match(os.path.basename(snapshot_name))
     assert r, 'malformed snapshot file %s'%snapshot_name
     self.beta = r.group('beta')
     self.seed = r.group('seed')
     self.ntraj_count = int(r.group('ntraj_count'))
     #print 'TASK',snapshot_name, self.beta, self.seed
     self.runtype = 'auto'
     self.ntraj = ntraj
     #self.ntraj_count = count_lines(self._fn('fort.11',basedir = os.path.dirname(os.path.abspath(snapshot_name))))
     self.task_uuid = uuid()
Пример #3
0
def unique_md5sum_hexdigest(name,opts=None):
   """ Return md5 checksum of a file. If a file does not exist or there is a read error
   return a globally unique identifier.
   """
   if opts is None:
      opts = FileTransferOptions()
   try:
      f = file(name,'r')
      import md5
      m = md5.new()
      data = f.read(opts.CHUNK_SIZE)
      while bool(data):
         m.update(data)
         data = f.read(opts.CHUNK_SIZE)
      m.update(data)
      return m.hexdigest()
   except IOError,x:
      logger.debug('md5sum: %s',str(x))
      return uuid()
Пример #4
0
    def __init__(self,rid,server):
        Peer.__init__(self,server,logger)
        
        ## CORBAProgram server object which contains this service.
        self.server = server
        
        ## WorkerRegistry.
        self.worker_registry = WorkerRegistry()
        
        self.__ping_cnt = 0
        
        ## TaskScheduler.
        self.task_scheduler = None

        ## ControlThread,
        self.control_thread = ControlThread(self)

        ## cache for lookup efficiency
        ##self.free_workers = {}
        ##self.received_workers = {}

        # application bootstrap parameters
        self.app_boot_data = None

        self.file_server = None # default file server

        # numeric run identifier
        self.rid = rid

        # uuid
        from diane.util.compatibility import uuid
        self.uuid = str(uuid())
       
        # journal has an option to report events via MSG and uuid is used to identify the master
        self.journal = diane.journal.Journal('master.j', self.uuid)

        # automatically generated task id
        self.__tid = 1
Пример #5
0
 def __init__(self,file_server,_uuid=None):
    if _uuid is None:
       self.uuid = uuid()
    else:
       self.uuid = _uuid
    self.file_server = file_server