Ejemplo n.º 1
0
def handle_deregister_job(reader, writer):
    jobid_len = yield from reader.read(INT)
    jobid_len, = struct.Struct("!i").unpack(jobid_len)
    jobid = yield from reader.read(jobid_len)
    jobid, = struct.Struct("!" + str(jobid_len) + "s").unpack(jobid)
    jobid = jobid.decode('utf-8')

    print(
        "------------------------- DEREGISTER JOB --------------------------------",
        time.time())
    # clear weight of this job
    for (datanodeip_port, weight) in job_table.loc[jobid, 'wmask_str']:
        datanode_alloc.at[datanodeip_port,
                          'net'] = datanode_alloc.at[datanodeip_port,
                                                     'net'] - weight
    # delete job from table
    err = remove_job(jobid)
    if err == 0:
        # delete dir named jobid
        createdirsock = pocket.connect(NAMENODE_IP, NAMENODE_PORT)
        if createdirsock is None:
            return
        pocket.delete(createdirsock, None, "/" + jobid)
        #pocket.close(createdirsock)

    # reply to client with jobid int
    resp_packer = struct.Struct(RESP_STRUCT_FORMAT)
    resp = (RESP_LEN_BYTES + INT, TICKET, JOB_CMD, err, DEREGISTER_OPCODE)
    pkt = resp_packer.pack(*resp)
    writer.write(pkt)
    print(
        "------------------------- DEREGISTERED JOB --------------------------------"
    )
    return
Ejemplo n.º 2
0
def handle_deregister_job(reader, writer):
  jobid_len = yield from reader.read(INT)
  jobid_len, = struct.Struct("!i").unpack(jobid_len)
  jobid = yield from reader.read(jobid_len)
  jobid, = struct.Struct("!" + str(jobid_len) + "s").unpack(jobid)
  jobid = jobid.decode('utf-8')
  
  print("------------------------- DEREGISTER JOB --------------------------------", time.time())
  # clear weight of this job
  if jobid not in job_datanode_net_allocations:
    print("ERROR: job to deregister no net allocation recognized!\n")
    print(job_datanode_net_allocations)
  for (datanodeip_port, weight) in job_datanode_net_allocations[jobid]:
    datanode_alloc.at[datanodeip_port, 'net'] -= weight
    if datanode_alloc.at[datanodeip_port, 'net'] < 0.0: # could happen due to rounding
      datanode_alloc.at[datanodeip_port, 'net'] = 0.0
  if jobid in job_datanode_dramGB_allocations:
    for (datanodeip_port, weight) in job_datanode_dramGB_allocations[jobid]:
      datanode_alloc.at[datanodeip_port, 'DRAM_GB'] -= weight
      if datanode_alloc.at[datanodeip_port, 'DRAM_GB'] < 0.0: # could happen due to rounding
        datanode_alloc.at[datanodeip_port, 'DRAM_GB'] = 0.0
  elif jobid in job_datanode_flashGB_allocations:
    for (datanodeip_port, weight) in job_datanode_flashGB_allocations[jobid]:
      datanode_alloc.at[datanodeip_port, 'Flash_GB'] -= weight
      if datanode_alloc.at[datanodeip_port, 'Flash_GB'] < 0.0: # could happen due to rounding
        datanode_alloc.at[datanodeip_port, 'Flash_GB'] = 0.0
  else:
    print("ERROR: job to deregister no capacity allocation recognized!\n")
    print(job_datanode_dramGB_allocations)
    print(job_datanode_flashGB_allocations)
    
#  for (datanodeip_port, weight) in job_table.loc[jobid,'wmask_str']:
#    datanode_alloc.at[datanodeip_port, 'net'] =  datanode_alloc.at[datanodeip_port, 'net'] - weight
  # delete job from table
  err = remove_job(jobid)
  if err == 0:
    # delete dir named jobid
    # NOTE: this is blocking but we are not yielding
    createdirsock = pocket.connect(NAMENODE_IP, NAMENODE_PORT)
    if createdirsock is None:
      return
    pocket.delete(createdirsock, None, "/" + jobid)
    #pocket.close(createdirsock)
 
  print(datanode_alloc)
 
  # reply to client with jobid int
  resp_packer = struct.Struct(RESP_STRUCT_FORMAT)
  resp = (RESP_LEN_BYTES + INT, TICKET, JOB_CMD, err, DEREGISTER_OPCODE)
  pkt = resp_packer.pack(*resp)
  writer.write(pkt)
  print("------------------------- DEREGISTERED JOB --------------------------------")
  return