|  |  | @ -1,7 +1,5 @@ | 
			
		
	
		
		
			
				
					
					|  |  |  | package com.platform.glusterfs; |  |  |  | package com.platform.glusterfs; | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | import java.io.File; |  |  |  | import java.io.File; | 
			
		
	
		
		
			
				
					
					|  |  |  | import java.util.ArrayList; |  |  |  | import java.util.ArrayList; | 
			
		
	
		
		
			
				
					
					|  |  |  | import java.util.HashMap; |  |  |  | import java.util.HashMap; | 
			
		
	
	
		
		
			
				
					|  |  | @ -11,8 +9,11 @@ import java.util.Map; | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | import org.apache.log4j.Logger; |  |  |  | import org.apache.log4j.Logger; | 
			
		
	
		
		
			
				
					
					|  |  |  | import org.apache.log4j.PropertyConfigurator; |  |  |  | import org.apache.log4j.PropertyConfigurator; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | import org.junit.Test; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | import org.omg.CosNaming.NamingContextExtPackage.StringNameHelper; | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.platform.utils.Constant; |  |  |  | import com.platform.utils.Constant; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | import com.platform.utils.GanymedSSH; | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | import java.util.regex.Matcher; |  |  |  | import java.util.regex.Matcher; | 
			
		
	
		
		
			
				
					
					|  |  |  | import java.util.regex.Pattern; |  |  |  | import java.util.regex.Pattern; | 
			
		
	
	
		
		
			
				
					|  |  | @ -20,6 +21,12 @@ import java.util.regex.Pattern; | 
			
		
	
		
		
			
				
					
					|  |  |  | public class VolumeInfo { |  |  |  | public class VolumeInfo { | 
			
		
	
		
		
			
				
					
					|  |  |  | 	public static Logger log = Logger.getLogger(VolumeInfo.class); |  |  |  | 	public static Logger log = Logger.getLogger(VolumeInfo.class); | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 	/** | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 	 * 显示所有volume名称 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 	 * <功能详细描述> | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 	 * @return | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 	 * @see [类、类#方法、类#成员] | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 	 */ | 
			
		
	
		
		
			
				
					
					|  |  |  | 	public List<String> showAllVolumeName() { |  |  |  | 	public List<String> showAllVolumeName() { | 
			
		
	
		
		
			
				
					
					|  |  |  | 		log.info("get volume name"); |  |  |  | 		log.info("get volume name"); | 
			
		
	
		
		
			
				
					
					|  |  |  | 		List<String> volNames = new ArrayList<String>(); |  |  |  | 		List<String> volNames = new ArrayList<String>(); | 
			
		
	
	
		
		
			
				
					|  |  | @ -30,18 +37,18 @@ public class VolumeInfo { | 
			
		
	
		
		
			
				
					
					|  |  |  | 		 * runCommand = new RunCommand(); List<String> reStrings = |  |  |  | 		 * runCommand = new RunCommand(); List<String> reStrings = | 
			
		
	
		
		
			
				
					
					|  |  |  | 		 * runCommand.runCommandWait(command); |  |  |  | 		 * runCommand.runCommandWait(command); | 
			
		
	
		
		
			
				
					
					|  |  |  | 		 */ |  |  |  | 		 */ | 
			
		
	
		
		
			
				
					
					|  |  |  | 		List<String> reStrings = Constant.ganymedSSH.execCmdWait(Constant.hostIp, Constant.rootUser, Constant.rootPasswd, |  |  |  | 		List<String> reStrings = Constant.ganymedSSH.execCmdWait(Constant.hostIp, Constant.rootUser, | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 				Constant.port, Constant.glusterVolumeInfo + "|grep ^Volume.Name"); |  |  |  | 				Constant.rootPasswd, Constant.port, Constant.glusterVolumeInfo + "|grep ^Volume.Name"); | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  | 		// System.out.println(reStrings);
 |  |  |  | 		// System.out.println(reStrings);
 | 
			
		
	
		
		
			
				
					
					|  |  |  | 		if(reStrings==null){ |  |  |  | 		if (reStrings == null) { | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  | 			log.error("1401 get result is null"); |  |  |  | 			log.error("1401 get result is null"); | 
			
		
	
		
		
			
				
					
					|  |  |  | 			return null; |  |  |  | 			return null; | 
			
		
	
		
		
			
				
					
					|  |  |  | 		} |  |  |  | 		} | 
			
		
	
		
		
			
				
					
					|  |  |  | 		if(reStrings.size()==0){ |  |  |  | 		if (reStrings.size() == 0) { | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  | 			log.error("1402 get result is nothing"); |  |  |  | 			log.error("1402 get result is nothing"); | 
			
		
	
		
		
			
				
					
					|  |  |  | 			return null; |  |  |  | 			return null; | 
			
		
	
		
		
			
				
					
					|  |  |  | 		} |  |  |  | 		} | 
			
		
	
		
		
			
				
					
					|  |  |  | 		if(reStrings.get(0).contains(Constant.noVolume)){ |  |  |  | 		if (reStrings.get(0).contains(Constant.noVolume)) { | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  | 			reStrings.clear(); |  |  |  | 			reStrings.clear(); | 
			
		
	
		
		
			
				
					
					|  |  |  | 			return reStrings; |  |  |  | 			return reStrings; | 
			
		
	
		
		
			
				
					
					|  |  |  | 		} |  |  |  | 		} | 
			
		
	
	
		
		
			
				
					|  |  | @ -60,27 +67,25 @@ public class VolumeInfo { | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | 	} |  |  |  | 	} | 
			
		
	
		
		
			
				
					
					|  |  |  | 	 |  |  |  | 	 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 	/** | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 	 * 给定参数volume的名称获得volume的类型 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 	 * <功能详细描述> | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 	 * @param volumeName | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 	 * @return | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 	 * @see [类、类#方法、类#成员] | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 	 */ | 
			
		
	
		
		
			
				
					
					|  |  |  | 	public String getVolumeType(String volumeName) { |  |  |  | 	public String getVolumeType(String volumeName) { | 
			
		
	
		
		
			
				
					
					|  |  |  | 		log.info("get volume type"); |  |  |  | 		log.info("get volume type"); | 
			
		
	
		
		
			
				
					
					|  |  |  | 		String volType = ""; |  |  |  | 		String volType = ""; | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | 		/* |  |  |  | 		List<String> reStrings = Constant.ganymedSSH.execCmdWait(Constant.hostIp, Constant.rootUser, | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 		 * ======= |  |  |  | 				Constant.rootPasswd, Constant.port, Constant.glusterVolumeInfo + volumeName + "|grep ^Type"); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 		 *  |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 		 * >>>>>>> origin/AlexKie String command = "echo \"" + |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 		 * Constant.rootPasswd + "\"  |sudo -S gluster volume info " + |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 		 * volumeName + "|grep ^Type"; RunCommand runCommand = new RunCommand(); |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 		 * List<String> reStrings = runCommand.runCommandWait(command); <<<<<<< |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 		 * HEAD |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 		 */ |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 		List<String> reStrings = Constant.ganymedSSH.execCmdWait(Constant.hostIp, Constant.rootUser, Constant.rootPasswd, |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 				Constant.port, Constant.glusterVolumeInfo + volumeName + "|grep ^Type"); |  |  |  |  | 
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  | 		// System.out.println(reStrings);
 |  |  |  | 		// System.out.println(reStrings);
 | 
			
		
	
		
		
			
				
					
					|  |  |  | 		if(reStrings==null){ |  |  |  | 		if (reStrings == null) { | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  | 			log.error("1501 get result is null"); |  |  |  | 			log.error("1501 get result is null"); | 
			
		
	
		
		
			
				
					
					|  |  |  | 			return null; |  |  |  | 			return null; | 
			
		
	
		
		
			
				
					
					|  |  |  | 		} |  |  |  | 		} | 
			
		
	
		
		
			
				
					
					|  |  |  | 		if(reStrings.size()==0){ |  |  |  | 		if (reStrings.size() == 0) { | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  | 			log.error("1502 get result is nothing"); |  |  |  | 			log.error("1502 get result is nothing"); | 
			
		
	
		
		
			
				
					
					|  |  |  | 			return null; |  |  |  | 			return null; | 
			
		
	
		
		
			
				
					
					|  |  |  | 		} |  |  |  | 		} | 
			
		
	
	
		
		
			
				
					|  |  | @ -96,31 +101,21 @@ public class VolumeInfo { | 
			
		
	
		
		
			
				
					
					|  |  |  | 			String str[] = line.split(":"); |  |  |  | 			String str[] = line.split(":"); | 
			
		
	
		
		
			
				
					
					|  |  |  | 			volType = str[1]; |  |  |  | 			volType = str[1]; | 
			
		
	
		
		
			
				
					
					|  |  |  | 		} |  |  |  | 		} | 
			
		
	
		
		
			
				
					
					|  |  |  | 		volType=volType.replaceAll(" ", ""); |  |  |  | 		volType = volType.replaceAll(" ", ""); | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  | 		return volType; |  |  |  | 		return volType; | 
			
		
	
		
		
			
				
					
					|  |  |  | 	} |  |  |  | 	} | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | 	public String getVolumeStatus(String volumeName) { |  |  |  | 	public String getVolumeStatus(String volumeName) { | 
			
		
	
		
		
			
				
					
					|  |  |  | 		log.info("get volume status"); |  |  |  | 		log.info("get volume status"); | 
			
		
	
		
		
			
				
					
					|  |  |  | 		String volStatus = ""; |  |  |  | 		String volStatus = ""; | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 		List<String> reStrings = Constant.ganymedSSH.execCmdWait(Constant.hostIp, Constant.rootUser, | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 		/* |  |  |  | 				Constant.rootPasswd, Constant.port, Constant.glusterVolumeInfo + "|grep ^Status"); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 		 * ======= |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 		 *  |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 		 * >>>>>>> origin/AlexKie String command = "echo \"" + |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 		 * Constant.rootPasswd + "\"  |sudo -S gluster volume info " + |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 		 * volumeName + "|grep ^Status"; RunCommand runCommand = new |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 		 * RunCommand(); List<String> reStrings = |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 		 * runCommand.runCommandWait(command); <<<<<<< HEAD |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 		 */ |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 		List<String> reStrings = Constant.ganymedSSH.execCmdWait(Constant.hostIp, Constant.rootUser, Constant.rootPasswd, |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 				Constant.port, Constant.glusterVolumeInfo + "|grep ^Status"); |  |  |  |  | 
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  | 		// System.out.println(reStrings);
 |  |  |  | 		// System.out.println(reStrings);
 | 
			
		
	
		
		
			
				
					
					|  |  |  | 		if(reStrings==null){ |  |  |  | 		if (reStrings == null) { | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  | 			log.error("1701 get result is null"); |  |  |  | 			log.error("1701 get result is null"); | 
			
		
	
		
		
			
				
					
					|  |  |  | 			return null; |  |  |  | 			return null; | 
			
		
	
		
		
			
				
					
					|  |  |  | 		} |  |  |  | 		} | 
			
		
	
		
		
			
				
					
					|  |  |  | 		if(reStrings.size()==0){ |  |  |  | 		if (reStrings.size() == 0) { | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  | 			log.error("1702 get result is nothing"); |  |  |  | 			log.error("1702 get result is nothing"); | 
			
		
	
		
		
			
				
					
					|  |  |  | 			return null; |  |  |  | 			return null; | 
			
		
	
		
		
			
				
					
					|  |  |  | 		} |  |  |  | 		} | 
			
		
	
	
		
		
			
				
					|  |  | @ -134,7 +129,6 @@ public class VolumeInfo { | 
			
		
	
		
		
			
				
					
					|  |  |  | 			String str[] = line.split(":"); |  |  |  | 			String str[] = line.split(":"); | 
			
		
	
		
		
			
				
					
					|  |  |  | 			volStatus = str[1].replaceAll(" ", ""); |  |  |  | 			volStatus = str[1].replaceAll(" ", ""); | 
			
		
	
		
		
			
				
					
					|  |  |  | 		} |  |  |  | 		} | 
			
		
	
		
		
			
				
					
					|  |  |  | 		 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 		return volStatus; |  |  |  | 		return volStatus; | 
			
		
	
		
		
			
				
					
					|  |  |  | 	} |  |  |  | 	} | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
	
		
		
			
				
					|  |  | @ -182,23 +176,14 @@ public class VolumeInfo { | 
			
		
	
		
		
			
				
					
					|  |  |  | 		log.info("get volume used size"); |  |  |  | 		log.info("get volume used size"); | 
			
		
	
		
		
			
				
					
					|  |  |  | 		Double usedSize = null; |  |  |  | 		Double usedSize = null; | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | 		/* |  |  |  | 		List<String> reStrings = Constant.ganymedSSH.execCmdWait(Constant.hostIp, Constant.rootUser, | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 		 * ======= |  |  |  | 				Constant.rootPasswd, Constant.port, Constant.df + "|grep " + volumeName + "|awk '{print $3}'"); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 		 *  |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 		 * >>>>>>> origin/AlexKie String command = "echo \"" + |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 		 * Constant.rootPasswd + "\"  |sudo -S df -h|grep " + volumeName + |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 		 * "|awk '{print $3}'"; RunCommand runCommand = new RunCommand(); |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 		 * List<String> reStrings = runCommand.runCommandWait(command); <<<<<<< |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 		 * HEAD |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 		 */ |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 		List<String> reStrings = Constant.ganymedSSH.execCmdWait(Constant.hostIp, Constant.rootUser, Constant.rootPasswd, |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 				Constant.port, Constant.df + "|grep " + volumeName + "|awk '{print $3}'"); |  |  |  |  | 
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  | 		// System.out.println(reStrings);
 |  |  |  | 		// System.out.println(reStrings);
 | 
			
		
	
		
		
			
				
					
					|  |  |  | 		if(reStrings==null){ |  |  |  | 		if (reStrings == null) { | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  | 			log.error("1901 get result is null"); |  |  |  | 			log.error("1901 get result is null"); | 
			
		
	
		
		
			
				
					
					|  |  |  | 			return null; |  |  |  | 			return null; | 
			
		
	
		
		
			
				
					
					|  |  |  | 		} |  |  |  | 		} | 
			
		
	
		
		
			
				
					
					|  |  |  | 		if(reStrings.size()==0){ |  |  |  | 		if (reStrings.size() == 0) { | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  | 			log.error("1902 get result is nothing"); |  |  |  | 			log.error("1902 get result is nothing"); | 
			
		
	
		
		
			
				
					
					|  |  |  | 			return null; |  |  |  | 			return null; | 
			
		
	
		
		
			
				
					
					|  |  |  | 		} |  |  |  | 		} | 
			
		
	
	
		
		
			
				
					|  |  | @ -218,19 +203,29 @@ public class VolumeInfo { | 
			
		
	
		
		
			
				
					
					|  |  |  | 		return usedSize; |  |  |  | 		return usedSize; | 
			
		
	
		
		
			
				
					
					|  |  |  | 	} |  |  |  | 	} | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | 	public String getVolumeMountPoint(String volumeName) { |  |  |  | 	/** | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 		log.info("get volume mountPoint"); |  |  |  | 	 * @param volumeName | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 		// String mountPoint = "";
 |  |  |  | 	 * @return String ipAndpath[] = brick.split(":"); | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			String ip = ipAndpath[0]; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			String path = ipAndpath[1]; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 	 */ | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 	public List<String> getVolumeBricks(String volumeName) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		log.info("get volume bricks"); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		String cmd = "gluster volume info " + volumeName + " |grep ^Brick'[0-9]\\+' |awk '{print $2}'"; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		List<String> reStrings = Constant.ganymedSSH.execCmdWaitAcquiescent(cmd); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		// System.out.println(reStrings);
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		if (reStrings == null) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			log.error("1601 get volume bricks wrong"); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			return null; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		} | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		return reStrings; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 	} | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 	public List<String> getVolumeMountPoint(String volumeName) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		log.info("get volume MountPoint"); | 
			
		
	
		
		
			
				
					
					|  |  |  | 		 |  |  |  | 		 | 
			
		
	
		
		
			
				
					
					|  |  |  | 		/* |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 		 * ======= |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 		 *  |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 		 * >>>>>>> origin/AlexKie String command = "echo \"" + |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 		 * Constant.rootPasswd + "\"  |sudo -S df -h|grep " + volumeName + |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 		 * "|awk '{print $6}'"; RunCommand runCommand = new RunCommand(); |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 		 * List<String> reStrings = runCommand.runCommandWait(command); <<<<<<< |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 		 * HEAD |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 		 */ |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 		List<String> reStrings = Constant.ganymedSSH.execCmdWait(Constant.hostIp, Constant.rootUser, Constant.rootPasswd, |  |  |  | 		List<String> reStrings = Constant.ganymedSSH.execCmdWait(Constant.hostIp, Constant.rootUser, Constant.rootPasswd, | 
			
		
	
		
		
			
				
					
					|  |  |  | 				Constant.port, Constant.df + "|grep " + volumeName + "|awk '{print $6}'"); |  |  |  | 				Constant.port, Constant.df + "|grep " + volumeName + "|awk '{print $6}'"); | 
			
		
	
		
		
			
				
					
					|  |  |  | 		// System.out.println(reStrings);
 |  |  |  | 		// System.out.println(reStrings);
 | 
			
		
	
	
		
		
			
				
					|  |  | @ -248,24 +243,92 @@ public class VolumeInfo { | 
			
		
	
		
		
			
				
					
					|  |  |  | 			log.error("11003 get result string wrong"); |  |  |  | 			log.error("11003 get result string wrong"); | 
			
		
	
		
		
			
				
					
					|  |  |  | 			return null; |  |  |  | 			return null; | 
			
		
	
		
		
			
				
					
					|  |  |  | 		} |  |  |  | 		} | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 		List<String> mountPoints = new ArrayList<>(); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 		Iterator it = reStrings.iterator(); |  |  |  | 		for(String mountPoint:reStrings){ | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 		String mountPoint = (String) it.next(); |  |  |  |  | 
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  | 		mountPoint=mountPoint.replaceAll(" ", ""); |  |  |  | 		mountPoint=mountPoint.replaceAll(" ", ""); | 
			
		
	
		
		
			
				
					
					|  |  |  | 		return mountPoint; |  |  |  | 		mountPoints.add(mountPoint); | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		} | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		return mountPoints; | 
			
		
	
		
		
			
				
					
					|  |  |  | 	} |  |  |  | 	} | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | 	public static void main(String[] args) { |  |  |  | 	public Map<String, Double> getVolumebricksDataSize(String volumeName) { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 		PropertyConfigurator.configure("log4j.properties"); |  |  |  | 		List<String> bricks = getVolumeBricks(volumeName); | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		Map<String, Double> brick_size = new HashMap<>(); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		if (bricks == null) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			return null; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		} | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		for (String brick : bricks) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			String ipAndpath[] = brick.split(":"); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			String ip = ipAndpath[0]; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			String path = ipAndpath[1]; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			String cmd = "du -d 0 " + path + "|awk '{print $1}'"; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			List<String> reStrings = Constant.ganymedSSH.execCmdWait(ip, Constant.rootUser, Constant.rootPasswd, | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 					Constant.port, cmd); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			// System.out.println(reStrings);
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			if (reStrings == null) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 				log.error("1901 get result is null"); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 				return null; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			} | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			if (reStrings.size() == 0) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 				log.error("1902 get result is nothing"); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 				return null; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			} | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			Pattern pattern = Pattern.compile("[0-9]*"); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			Matcher isNum = pattern.matcher(reStrings.get(0)); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			if (!isNum.matches()) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 				log.error("1903 " + reStrings.get(0) + " is unexpect"); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 				return null; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			} | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			brick_size.put(brick, Double.parseDouble(reStrings.get(0))); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		} | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		return brick_size; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 	} | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | 		System.out.println(new VolumeInfo().showAllVolumeName()); |  |  |  | 	public Map<String, Double> getVolumebricksAvailableSize(String volumeName) { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 		System.out.println(new VolumeInfo().getVolumeType("v1")); |  |  |  | 		List<String> bricks = getVolumeBricks(volumeName); | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		Map<String, Double> brick_size = new HashMap<>(); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		if (bricks == null) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			return null; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		} | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		for (String brick : bricks) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			String ipAndpath[] = brick.split(":"); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			String ip = ipAndpath[0]; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			String path = ipAndpath[1]; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			String cmd = "df " + path + "|awk '{print $4}'"; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			List<String> reStrings = Constant.ganymedSSH.execCmdWait(ip, Constant.rootUser, Constant.rootPasswd, | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 					Constant.port, cmd); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			// System.out.println(reStrings);
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			if (reStrings == null) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 				log.error("1901 get result is null"); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 				return null; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			} | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			if (reStrings.size() == 0) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 				log.error("1902 get result is nothing"); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 				return null; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			} | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			Pattern pattern = Pattern.compile("[0-9]*"); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			Matcher isNum = pattern.matcher(reStrings.get(1)); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			if (!isNum.matches()) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 				log.error("1903 " + reStrings.get(1) + " is unexpect"); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 				return null; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			} | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			brick_size.put(brick, Double.parseDouble(reStrings.get(1))); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		} | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		return brick_size; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 	} | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | 		System.out.println(new VolumeInfo().getVolumeStatus("v1")); |  |  |  | 	@Test | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 		System.out.println(new VolumeInfo().getVolumeMountPoint("v1")); |  |  |  | 	public void test_getVolumebricksDataSize() { | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		System.out.println(getVolumebricksDataSize("gfs_ftp")); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 	} | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | 		System.out.println(new VolumeInfo().getVolumeAllSize("v1")); |  |  |  | 	@Test | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 		System.out.println(new VolumeInfo().getVolumeUseSize("v1")); |  |  |  | 	public void test_getVolumebricksAvailableSize() { | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		System.out.println(getVolumebricksAvailableSize("gfs_ftp")); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 	} | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 	// @Test
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 	public void test_getVolumeBricks() { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		getVolumeBricks("gfs_ftp"); | 
			
		
	
		
		
			
				
					
					|  |  |  | 	} |  |  |  | 	} | 
			
		
	
		
		
			
				
					
					|  |  |  | } |  |  |  | } | 
			
		
	
	
		
		
			
				
					|  |  | 
 |