查询volume修改

web_backend_develope
chenlw 9 years ago
parent 1e424e71e0
commit 4ba10ae6e6

@ -4,6 +4,8 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import net.sf.json.JSONArray;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.base.Custom4exception; import com.base.Custom4exception;
@ -14,6 +16,7 @@ import com.platform.entities.VolumeEntity;
import com.platform.glusterfs.ClusterInfo; import com.platform.glusterfs.ClusterInfo;
import com.platform.glusterfs.GetTreeData; import com.platform.glusterfs.GetTreeData;
import com.platform.glusterfs.VolumeInfo; import com.platform.glusterfs.VolumeInfo;
import com.platform.http.gfs.HttpUtils;
public class ThreadVolume extends Thread { public class ThreadVolume extends Thread {
@ -71,88 +74,100 @@ public class ThreadVolume extends Thread {
public void getVolumeMsg() { public void getVolumeMsg() {
List<FolderNode> folderlist = new ArrayList<FolderNode>(); List<FolderNode> folderlist = new ArrayList<FolderNode>();
List<VolumeEntity> volumeList = new ArrayList<VolumeEntity>(); List<VolumeEntity> volumeList = new ArrayList<VolumeEntity>();
// brick状态 map集合 HttpUtils ht = new HttpUtils();
Map<String, String> brickStatusMap = cluster.showClusterInfo(); String rest = ht.sendPost("gfs/getAllvolume", null);
// JSONArray jsondata = JSONArray.fromObject(volumeList);
// 查询 volume name JSONArray json = JSONArray.fromObject(rest);
List<String> volumeNameList = volumeInfo.showAllVolumeName(); List<VolumeEntity> volumes = (List<VolumeEntity>)JSONArray.toCollection(json, VolumeEntity.class);
if (null != volumeNameList) { for (VolumeEntity volumeEntity : volumes) {
for (String volumeName : volumeNameList) { if (null != volumeEntity.getFolder()) {
try { folderlist.addAll(volumeEntity.getFolder());
VolumeEntity volume = new VolumeEntity(); }
volume.setName(volumeName); }
List<String> path = volumeInfo volumeList = volumes;
.getVolumeMountPoint(volumeName);
// 默认加载第一个路径 // // brick状态 map集合
if (null != path) { // Map<String, String> brickStatusMap = cluster.showClusterInfo();
for (String one : path) { //
if (!one.contains("df")) { // // 查询 volume name
volume.setPath(one); // List<String> volumeNameList = volumeInfo.showAllVolumeName();
} // if (null != volumeNameList) {
} // for (String volumeName : volumeNameList) {
} // try {
if (null == volume.getPath()) { // VolumeEntity volume = new VolumeEntity();
volume.setPath(""); // volume.setName(volumeName);
} // List<String> path = volumeInfo
volume.setAllSize((double) (volumeInfo // .getVolumeMountPoint(volumeName);
.getVolumeAvailableSize(volumeName) // // 默认加载第一个路径
+ volumeInfo.getVolumeUseSize(volumeName))); // if (null != path) {
// 状态Started,Stopped,Created // for (String one : path) {
String status = volumeInfo.getVolumeStatus(volumeName); // if (!one.contains("df")) {
if ("Started".equals(status)) { // volume.setPath(one);
volume.setStatus(true); // }
} else { // }
volume.setStatus(false); // }
} // if (null == volume.getPath()) {
volume.setUsedSize((double) volumeInfo.getVolumeUseSize(volumeName)); // volume.setPath("");
volume.setType(volumeInfo.getVolumeType(volumeName)); // }
// TODO 查询brick-- // volume.setAllSize((double) (volumeInfo
// 返回 ip:path // .getVolumeAvailableSize(volumeName)
List<String> brickStrs = volumeInfo // + volumeInfo.getVolumeUseSize(volumeName)));
.getVolumeBricks(volumeName); // // 状态Started,Stopped,Created
// brick已用大小 // String status = volumeInfo.getVolumeStatus(volumeName);
Map<String, Double> usedSize = volumeInfo // if ("Started".equals(status)) {
.getVolumebricksDataSize(volumeName); // volume.setStatus(true);
Map<String, Double> availableSize = volumeInfo // } else {
.getVolumebricksAvailableSize(volumeName); // volume.setStatus(false);
// }
List<Brick> brickList = new ArrayList<Brick>(); // volume.setUsedSize((double) volumeInfo.getVolumeUseSize(volumeName));
for (String brickIpPath : brickStrs) { // volume.setType(volumeInfo.getVolumeType(volumeName));
Brick b = new Brick(); // // TODO 查询brick--
String ipAndpath[] = brickIpPath.split(":"); // // 返回 ip:path
String brickip = ipAndpath[0]; // List<String> brickStrs = volumeInfo
String brickpath = ipAndpath[1]; // .getVolumeBricks(volumeName);
// iP , path , // // brick已用大小
b.setIp(brickip); // Map<String, Double> usedSize = volumeInfo
if (brickStatusMap == null // .getVolumebricksDataSize(volumeName);
|| brickStatusMap.size() == 0) { // Map<String, Double> availableSize = volumeInfo
b.setStatus(false); // .getVolumebricksAvailableSize(volumeName);
} else if (brickStatusMap.containsKey(brickip)) { //
b.setStatus(true); // List<Brick> brickList = new ArrayList<Brick>();
} else { // for (String brickIpPath : brickStrs) {
b.setStatus(false); // Brick b = new Brick();
} // String ipAndpath[] = brickIpPath.split(":");
b.setPath(brickpath); // String brickip = ipAndpath[0];
b.setAvailableSize(availableSize.get(brickIpPath)); // String brickpath = ipAndpath[1];
b.setUsedSize(usedSize.get(brickIpPath)); // // iP , path ,
brickList.add(b); // b.setIp(brickip);
} // if (brickStatusMap == null
volume.setBrick(brickList); // || brickStatusMap.size() == 0) {
// b.setStatus(false);
// 默认加载第一个路径 // } else if (brickStatusMap.containsKey(brickip)) {
if (null != path && path.size() > 0) { // b.setStatus(true);
// 装入 folder // } else {
// 查询 每个 volume 下的 folder // b.setStatus(false);
FolderNode foldertmp = gfsTree.getDatas(path.get(0)); // }
folderlist.add(foldertmp); // b.setPath(brickpath);
} // b.setAvailableSize(availableSize.get(brickIpPath));
volumeList.add(volume); // b.setUsedSize(usedSize.get(brickIpPath));
} catch (Exception e) { // brickList.add(b);
new CustomException( // }
Custom4exception.threadVolume_class_Except, e); // volume.setBrick(brickList);
} //
} // // 默认加载第一个路径
} // if (null != path && path.size() > 0) {
// // 装入 folder
// // 查询 每个 volume 下的 folder
// FolderNode foldertmp = gfsTree.getDatas(path.get(0));
// folderlist.add(foldertmp);
// }
// volumeList.add(volume);
// } catch (Exception e) {
// new CustomException(
// Custom4exception.threadVolume_class_Except, e);
// }
// }
// }
// 更新folder 目录 // 更新folder 目录
CacheTreeData.setFolders(folderlist); CacheTreeData.setFolders(folderlist);
CacheTreeData.setVolumeList(volumeList); CacheTreeData.setVolumeList(volumeList);

Loading…
Cancel
Save