add getVolumeBricks

glusterfs-api
lily 9 years ago
parent 355e6a9b78
commit a9b02c497b

@ -13,11 +13,12 @@ package com.platform.controller;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
/** /**
* <> *
* <> * <>
* @author liliy * @author liliy
* @version [201698] * @version [201698]
@ -26,20 +27,12 @@ import org.springframework.web.bind.annotation.RequestMapping;
*/ */
@Controller @Controller
public class SetGlusterfsController { public class SetGlusterfsController {
@RequestMapping("/tes") public static Logger log = Logger.getLogger(SetGlusterfsController.class);
public Object defaultHandler(HttpServletRequest req, HttpServletResponse request) {
//<2F><><EFBFBD><><C6A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> @RequestMapping("")
try { public void sf(){
System.out.println("fsdfds");
return "listAll";
} catch (Exception e) {
e.printStackTrace();
return "result";
}
} }
} }

@ -10,16 +10,19 @@
*/ */
package com.platform.controller; package com.platform.controller;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import com.platform.glusterfs.ClusterInfo; import com.platform.glusterfs.ClusterInfo;
import com.platform.glusterfs.VolumeInfo;
/** /**
* <> *
* <> * <>
* @author liliy * @author liliy
* @version [201698] * @version [201698]
@ -28,8 +31,9 @@ import com.platform.glusterfs.ClusterInfo;
*/ */
@Controller @Controller
public class ShowGlusterfsController { public class ShowGlusterfsController {
public static Logger log = Logger.getLogger(ShowGlusterfsController.class);
/** /**
* <> *
* <> * <>
* @return * @return
* @see [##] * @see [##]
@ -40,5 +44,32 @@ public class ShowGlusterfsController {
return peer_status; return peer_status;
} }
/**
* <>
* <>
* @return
* @see [##]
*/
@RequestMapping("/showVolumeStatus")
public Map<String,String> showVolumeStatus(){
VolumeInfo volumeInfo=new VolumeInfo();
Map<String, String> volume_status=new HashMap<String, String>();
List<String> volumes=volumeInfo.showAllVolumeName();
if(volumes==null){
log.error("showAllVolumeName is error!");
return null;
}
for(String vol:volumes){
String status=volumeInfo.getVolumeStatus(vol);
if(status==null){
log.error("getVolumeStatus is error!");
return null;
}
volume_status.put(vol, status);
}
return volume_status;
}
} }

@ -24,6 +24,9 @@ public class GetTreeData {
fileOrFolder.children = new ArrayList<FileOrFolder>(); fileOrFolder.children = new ArrayList<FileOrFolder>();
for (Map.Entry<String, String> entry : files.entrySet()) { for (Map.Entry<String, String> entry : files.entrySet()) {
int number = Integer.parseInt(entry.getValue()); int number = Integer.parseInt(entry.getValue());
if(entry.getKey().equals("app")){
continue;
}
if (number == 1) { if (number == 1) {
fileOrFolder.children.add(new FileOrFolder(entry.getKey(), number)); fileOrFolder.children.add(new FileOrFolder(entry.getKey(), number));
} }

@ -218,10 +218,35 @@ public class VolumeInfo {
return usedSize; return usedSize;
} }
public String getVolumeMountPoint(String volumeName) {
public List<String> getVolumeMountPoint(String volumeName) {
log.info("get volume mountPoint"); log.info("get volume mountPoint");
// String mountPoint = ""; // String 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
*/
String cmd="gluster volume info "+volumeName+" |grep ^Brick'[0-9]\\+' |awk '{print $2}'";
List<String> reStrings = Constant.ganymedSSH.execCmdWaitAcquiescent(volumeName);
// System.out.println(reStrings);
if(reStrings==null){
log.error("1601 get result string wrong");
return null;
}
return reStrings;
}
public String getVolumeBricks(String volumeName) {
log.info("get volume bricks");
// String mountPoint = "";
/* /*
* ======= * =======
* *
@ -254,7 +279,7 @@ public class VolumeInfo {
mountPoint=mountPoint.replaceAll(" ", ""); mountPoint=mountPoint.replaceAll(" ", "");
return mountPoint; return mountPoint;
} }
public static void main(String[] args) { public static void main(String[] args) {
PropertyConfigurator.configure("log4j.properties"); PropertyConfigurator.configure("log4j.properties");

@ -120,7 +120,7 @@ public class GanymedSSH {
break; break;
} }
} }
if(reStrings.size()==0){
while (true) { while (true) {
String line = stderrReader.readLine(); String line = stderrReader.readLine();
@ -131,6 +131,7 @@ public class GanymedSSH {
break; break;
} }
} }
}
} catch (IOException e) { } catch (IOException e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
@ -165,7 +166,7 @@ public class GanymedSSH {
break; break;
} }
} }
if(reStrings.size()==0){
while (true) { while (true) {
String line = stderrReader.readLine(); String line = stderrReader.readLine();
@ -176,6 +177,7 @@ public class GanymedSSH {
break; break;
} }
} }
}
} catch (IOException e) { } catch (IOException e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();

Loading…
Cancel
Save