def infoAll(mode='all'): '''Overall info process.''' setting = common.Setting() setting.read(settingpath) storage.initStorages(setting) storage.checkHealth(setting) storage.syncMirror(setting, setting.mirrordir) #Get file list recrusively from directory: fileList = [] for root, dirs, files in os.walk(setting.mirrordir): for fl in files: filepath = '/'.join([root, fl]) filepath = filepath[len(setting.mirrordir):] if filepath[0] == '/': filepath = filepath[1:] fileList.append(filepath) if mode == 'all' or mode == 'node': #Info nodes: print "*** Node information ***" infoNode(setting) if mode == 'all' or mode == 'file': #Info files: print "*** File information ***" for targetFile in fileList: infoFile(setting, targetFile)
def __init__(self, *args, **kw): '''Initialize Fuse class object.''' global settingpath Fuse.__init__(self, *args, **kw) #Read file system settings: setting.read(settingpath) self.root = setting.mirrordir self.settingpath = os.path.join(os.path.dirname(setting.mirrordir), 'setting.cfg') settingpath = self.settingpath #Clean temporary directories: clean.cleanAll() """ #Connect to ZooKeeper servers if needed: if setting.zookeeper: self.zkLock = zk.ZooKeeperLock(setting) setting.zk = self.zkLock """ #Check health of nodes: storage.checkHealth(setting) #Print system setting and status: #for i in range(setting.totalnode): # print "Node " + str(i) + " healthy = " + str(setting.nodeInfo[i].healthy) + "\n" #print "HealthyNodes = " + str(setting.healthynode) + "\n" #Handle auto-repair: if (setting.autorepair == True) and (setting.healthynode < setting.totalnode) \ and (setting.totalnode - setting.healthynode <= setting.totalsparenode): print "Auto-repair starts." globalstate = "repair" rebuild.rebuildNode() setting.__init__() setting.read(settingpath) globalstate = "normal" print "Auto-repair finishes." #Update settings for ZooKeeper zkLock.updateSetting(setting) setting.zk = self.zkLock #Check health of nodes after repair: storage.checkHealth(setting) #Print system setting and status: for i in range(setting.totalnode): print "Node " + str(i) + " healthy = " + str( setting.nodeInfo[i].healthy) + "\n" print "HealthyNodes = " + str(setting.healthynode) + "\n" #It is necessary to reset the storage queue for later initStorages(): storage.resetStorageQueue()
def __init__(self, *args, **kw): '''Initialize Fuse class object.''' global settingpath Fuse.__init__(self, *args, **kw) #Read file system settings: setting.read(settingpath) self.root = setting.mirrordir self.settingpath = os.path.join(os.path.dirname(setting.mirrordir),'setting.cfg') settingpath = self.settingpath #Clean temporary directories: clean.cleanAll() """ #Connect to ZooKeeper servers if needed: if setting.zookeeper: self.zkLock = zk.ZooKeeperLock(setting) setting.zk = self.zkLock """ #Check health of nodes: storage.checkHealth(setting) #Print system setting and status: #for i in range(setting.totalnode): # print "Node " + str(i) + " healthy = " + str(setting.nodeInfo[i].healthy) + "\n" #print "HealthyNodes = " + str(setting.healthynode) + "\n" #Handle auto-repair: if (setting.autorepair == True) and (setting.healthynode < setting.totalnode) \ and (setting.totalnode - setting.healthynode <= setting.totalsparenode): print "Auto-repair starts." globalstate = "repair" rebuild.rebuildNode() setting.__init__() setting.read(settingpath) globalstate = "normal" print "Auto-repair finishes." #Update settings for ZooKeeper zkLock.updateSetting(setting) setting.zk = self.zkLock #Check health of nodes after repair: storage.checkHealth(setting) #Print system setting and status: for i in range(setting.totalnode): print "Node " + str(i) + " healthy = " + str(setting.nodeInfo[i].healthy) + "\n" print "HealthyNodes = " + str(setting.healthynode) + "\n" #It is necessary to reset the storage queue for later initStorages(): storage.resetStorageQueue()
def rebuildNode(filter=[]): '''Overall rebuild process.''' settingOld = common.Setting() settingOld.read(settingpath) rebuildthreads = settingOld.rebuildthreads if rebuildthreads > 0: initRebuild(rebuildthreads) storage.initStorages(settingOld) storage.checkHealth(settingOld) #for i in range(settingOld.totalnode): # print "Node " + str(i) + " healthy = " + str(settingOld.nodeInfo[i].healthy) + "\n" #print "HealthyNodes = " + str(settingOld.healthynode) + "\n" storage.syncMirror(settingOld, settingOld.mirrordir) #Get file list recursively from directory: fileList = [] for root, dirs, files in os.walk(settingOld.mirrordir): for fl in files: filepath = '/'.join([root, fl]) filepath = filepath[len(settingOld.mirrordir) + 1:] if filepath[0] == '/': filepath = filepath[1:] fileList.append(filepath) #Get new setting: settingNew = getNewSetting(settingOld, settingpath) #Rebuild files recursively: for targetFile in fileList: if (filter == []) or (targetFile in filter): if rebuildthreads > 0: rebuildQueue.put( ('rebuildFile', (settingOld, settingNew, targetFile))) else: rebuildFile(settingOld, settingNew, targetFile) if rebuildthreads > 0: waitForRebuild() #Backup old setting file, write new setting file: #print "Rebuild finishes. Writing new setting file." shutil.copyfile(settingpath, settingpath + ".old") settingNew.write(settingpath)
def rebuildNode(filter=[]): '''Overall rebuild process.''' settingOld = common.Setting() settingOld.read(settingpath) rebuildthreads = settingOld.rebuildthreads if rebuildthreads > 0: initRebuild(rebuildthreads) storage.initStorages(settingOld) storage.checkHealth(settingOld) #for i in range(settingOld.totalnode): # print "Node " + str(i) + " healthy = " + str(settingOld.nodeInfo[i].healthy) + "\n" #print "HealthyNodes = " + str(settingOld.healthynode) + "\n" storage.syncMirror(settingOld, settingOld.mirrordir) #Get file list recursively from directory: fileList = [] for root, dirs, files in os.walk(settingOld.mirrordir): for fl in files: filepath = '/'.join([root, fl]) filepath = filepath[len(settingOld.mirrordir)+1:] if filepath[0] == '/': filepath = filepath[1:] fileList.append(filepath) #Get new setting: settingNew = getNewSetting(settingOld, settingpath) #Rebuild files recursively: for targetFile in fileList: if (filter == []) or (targetFile in filter): if rebuildthreads > 0: rebuildQueue.put(('rebuildFile',(settingOld, settingNew, targetFile))) else: rebuildFile(settingOld, settingNew, targetFile) if rebuildthreads > 0: waitForRebuild() #Backup old setting file, write new setting file: #print "Rebuild finishes. Writing new setting file." shutil.copyfile(settingpath, settingpath+".old") settingNew.write(settingpath)
def setUp(self): # Setup for testing: self.setting = common.Setting() self.setting.read(settingpath) storage.initStorages(self.setting) storage.checkHealth(self.setting)
def setUp(self): #Setup for testing: self.setting = common.Setting() self.setting.read(settingpath) storage.initStorages(self.setting) storage.checkHealth(self.setting)