/** * 文件名 : GfsServiceImpl.java * 版权 : <版权/公司名> * 描述 : <描述> * @author chen * 版本 : <版本> * 修改时间: 2016年9月8日 * 修改内容: <修改内容> */ package com.platform.service.impl; import java.util.ArrayList; import java.util.List; import org.springframework.stereotype.Service; import com.platform.entities.FolderNode; import com.platform.entities.VolumeEntity; import com.platform.glusterfs.CopyData; import com.platform.glusterfs.GetTreeData; import com.platform.glusterfs.VolumeInfo; import com.platform.service.IGfsService; import com.platform.utils.CacheTreeData; import com.platform.utils.VolumeThread; import com.platform.utils.getTreeDataByPath; /** * <一句话功能简述> gfs功能实现类 * <功能详细描述> * @author chen * @version [版本号,2016年9月8日] * @see [相关类/方法] * @since [产品/模块版本] */ @Service(value = "gfsService") public class GfsServiceImpl implements IGfsService { /** gfs目录树形查询 */ private getTreeDataByPath getFolder = new getTreeDataByPath(); /** 数据迁移实现 */ private CopyData copydata = new CopyData(); /** Volume信息查询 */ private VolumeInfo volumeInfo = new VolumeInfo(); @Override public FolderNode getFolder(String path) { FolderNode result = getFolder.findByPath(path); return result; } @Override public int copyFolder(List srcFolders, String dstFolder, String name) throws Exception { int status = 0 ; if (null != srcFolders) { for (String string : srcFolders) { status = copydata.copyFolderFiles(string, dstFolder, name); } } return status; } /* (non-Javadoc) * @see com.platform.service.IGfsService#getAllVolume() */ @Override public List getAllVolumes() throws Exception { List volumeList = new ArrayList<>(); List volumeNameList = volumeInfo.showAllVolumeName(); for (String volumeName : volumeNameList) { VolumeEntity volume = new VolumeEntity(); volume.setName(volumeName); String path = volumeInfo.getVolumeMountPoint(volumeName); volume.setPath(path); volume.setAllSize(volumeInfo.getVolumeAllSize(volumeName)); volume.setUsedSize(volumeInfo.getVolumeUseSize(volumeName)); //TODO // volume.setBrick(brick); if (null != volume.getPath()) { // volume.setFolder(gfsTree.getDatas(volume.getPath())); volume.setFolder(getFolder(path)); } volumeList.add(volume); } return volumeList; } @Override public VolumeEntity getOneVolume(String volumeName) throws Exception { VolumeEntity volume = new VolumeEntity(); volume.setName(volumeName); String path = volumeInfo.getVolumeMountPoint(volumeName); volume.setPath(path); // volume.setAllSize(volumeInfo.getVolumeAllSize(volumeName)); // volume.setUsedSize(volumeInfo.getVolumeUseSize(volumeName)); // volume.setBrick(brick); if (null != volume.getPath()) { volume.setFolder(getFolder(path)); } return volume; } @Override public int moveData(String volumeName, String srcPath, String dstPath) throws Exception { int result = copydata.copyFolderFiles(srcPath, dstPath, "app"); return result; } @Override public int deleteData(String volumeName, String srcPath) throws Exception { // TODO Auto-generated method stub return 0; } }