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

@ -10,16 +10,19 @@
*/
package com.platform.controller;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import com.platform.glusterfs.ClusterInfo;
import com.platform.glusterfs.VolumeInfo;
/**
* <>
*
* <>
* @author liliy
* @version [201698]
@ -28,8 +31,9 @@ import com.platform.glusterfs.ClusterInfo;
*/
@Controller
public class ShowGlusterfsController {
public static Logger log = Logger.getLogger(ShowGlusterfsController.class);
/**
* <>
*
* <>
* @return
* @see [##]
@ -40,5 +44,32 @@ public class ShowGlusterfsController {
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>();
for (Map.Entry<String, String> entry : files.entrySet()) {
int number = Integer.parseInt(entry.getValue());
if(entry.getKey().equals("app")){
continue;
}
if (number == 1) {
fileOrFolder.children.add(new FileOrFolder(entry.getKey(), number));
}

@ -218,10 +218,35 @@ public class VolumeInfo {
return usedSize;
}
public String getVolumeMountPoint(String volumeName) {
public List<String> getVolumeMountPoint(String volumeName) {
log.info("get volume 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(" ", "");
return mountPoint;
}
public static void main(String[] args) {
PropertyConfigurator.configure("log4j.properties");

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

Loading…
Cancel
Save