1. 程式人生 > >機架感知(Rack Awareness)機制淺述

機架感知(Rack Awareness)機制淺述

  
  
  

#!/usr/bin/env python


'''

This script used by hadoop to determine network/rack  topology.  It

should be specified in hadoop-site.xml via  topology.script.file.name

Property.

  

topology.script.file.name

/home/hadoop/topology.py


  

'''

  

import sys

from string import join

  

DEFAULT_RACK = '/default/rack0';

  

RACK_MAP = { '10.72.10.1' : '/datacenter0/rack0',

  

'10.112.110.26' : '/datacenter1/rack0',

'10.112.110.27' : '/datacenter1/rack0',

'10.112.110.28' : '/datacenter1/rack0',


  

'10.2.5.1' : '/datacenter2/rack0',

'10.2.10.1' : '/datacenter2/rack1'

}

  

if len(sys.argv)==1:

print DEFAULT_RACK

else:

print join([RACK_MAP.get(i, DEFAULT_RACK) for i in  sys.argv[1:]]," ")