修复启动oracle服务,测试连接oracle的Bub

web_backend_develope
wu ming 9 years ago
commit 608e658d3a

@ -2,11 +2,6 @@
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="test"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/Java">
<attributes>
<attribute name="owner.project.facets" value="java"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jst.server.core.container/org.eclipse.jst.server.tomcat.runtimeTarget/Apache Tomcat v7.0">
<attributes>
<attribute name="owner.project.facets" value="jst.web"/>
@ -14,5 +9,6 @@
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.web.container"/>
<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.module.container"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/Java"/>
<classpathentry kind="output" path="build/classes"/>
</classpath>

@ -4,7 +4,7 @@
# 驱动程序
jdbc.mysql.driver=com.mysql.jdbc.Driver
# 连接url
jdbc.mysql.url=jdbc:mysql://127.0.0.1:3306/test?useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true
jdbc.mysql.url=jdbc:mysql://192.168.0.101:3306/test?useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true
# 用户名
jdbc.mysql.username=root
# 密码

@ -21,6 +21,7 @@
<url-pattern>/*</url-pattern>
</filter-mapping>
<!-- spring配置文件 -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>WEB-INF/config/spring-applicationContext.xml</param-value>
@ -46,7 +47,7 @@
</servlet>
<servlet-mapping>
<servlet-name>springmvc</servlet-name>
<url-pattern>/*</url-pattern>
<url-pattern>/</url-pattern>
</servlet-mapping>
<!-- log4j配置文件 -->
@ -59,7 +60,7 @@
</listener>
<!-- 防止Spring内存溢出监听器 -->
<listener>
<!-- <listener>
<listener-class>org.springframework.web.util.IntrospectorCleanupListener</listener-class>
</listener>
</listener> -->
</web-app>

@ -0,0 +1,151 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//ibatis.apache.org//DTD Mapper 3.0//EN"
"http://ibatis.apache.org/dtd/ibatis-3-mapper.dtd">
<mapper namespace="com.platform.dao.DataInfoMoveTmpDao">
<resultMap id="getEntityByText" type="com.platform.entities.DataInfoEntityMoveTmp">
<id property="id" column="id" javaType="int" jdbcType="INTEGER" />
<result property="regionalismCode" column="regionalism_code"
javaType="string" jdbcType="VARCHAR" />
<result property="cityName" column="city_name" javaType="string"
jdbcType="VARCHAR" />
<result property="districtName" column="district_name"
javaType="string" jdbcType="VARCHAR" />
<result property="systemCode" column="system_code" javaType="int"
jdbcType="INTEGER" />
<result property="systemName" column="system_name" javaType="string"
jdbcType="VARCHAR" />
<result property="dataType" column="data_type" javaType="string"
jdbcType="VARCHAR" />
<result property="dataVersion" column="data_version" javaType="int"
jdbcType="INTEGER" />
<result property="submittedBatch" column="submitted_batch"
javaType="string" jdbcType="VARCHAR" />
<result property="dataPath" column="data_path" javaType="string"
jdbcType="VARCHAR" />
<result property="charset" column="data_charset" javaType="string"
jdbcType="VARCHAR" />
<result property="collectingTime" column="collection_time"
javaType="string" jdbcType="DATE" />
<result property="collectorContacts" column="collector_contacts"
javaType="string" jdbcType="VARCHAR" />
<result property="collectorName" column="collector_name"
javaType="string" jdbcType="VARCHAR" />
<result property="year" column="data_year" javaType="string"
jdbcType="VARCHAR" />
<result property="dstPath" column="dst_path" javaType="string"
jdbcType="VARCHAR" />
<result property="completeStatus" column="complete_status" javaType="string"
jdbcType="VARCHAR" />
<result property="rate" column="rate" javaType="int"
jdbcType="INTEGER" />
</resultMap>
<!-- 获取数据全部记录信息 -->
<select id="findAll" parameterType="" resultMap="getEntityByText">
SELECT
a.id,a.regionalism_code,b.city_name,b.district_name, a.system_code,b.system_name,b.data_type,b.data_version,b.submitted_batch,
b.data_path,b.data_charset,b.collection_time,b.collector_name,b.collector_contacts,b.data_year,a.dst_path,a.complete_status,a.rate
FROM
move_data_tmp a LEFT JOIN data_details b
ON a.system_code = b.system_code AND a.regionalism_code = b.regionalism_code;
</select>
<update id="update" parameterType="com.platform.entities.DataInfoEntityMoveTmp">
UPDATE
move_data_tmp
<set >
<trim suffixOverrides=",">
<if test="regionalismCode != null and regionalismCode != ''">
regionalism_code = #{regionalismCode},
</if>
<if test="systemCode != null and systemCode != ''">
system_code= #{systemCode},
</if>
<if test="dstPath != null and dstPath != ''">
dst_path= #{dstPath},
</if>
<if test="completeStatus != null and completeStatus != ''">
complete_status= #{completeStatus},
</if>
rate= #{rate}
</trim>
</set>
<where>
id = #{id}
</where>
</update>
<insert id="save" parameterType="">
INSERT INTO
move_data_tmp(
<trim suffixOverrides=",">
<if test="id > 0">
id,
</if>
<if test="regionalismCode != null and regionalismCode != ''">
regionalism_code,
</if>
<if test="systemCode != null and systemCode != ''">
system_code,
</if>
<if test="dstPath != null and dstPath != ''">
dst_path,
</if>
<if test="completeStatus != null and completeStatus != ''">
complete_status,
</if>
rate
</trim>
)
VALUES(
<trim suffixOverrides=",">
<if test="id > 0">
id,
</if>
<if test="regionalismCode != null and regionalismCode != ''">
#{regionalismCode},
</if>
<if test="systemCode != null and systemCode != ''">
#{systemCode},
</if>
<if test="dstPath != null and dstPath != ''">
#{dstPath},
</if>
<if test="completeStatus != null and completeStatus != ''">
#{completeStatus},
</if>
#{rate}
</trim>
)
</insert>
<delete id="remove" parameterType="java.lang.INTEGER">
DELETE FROM
move_data_tmp
WHERE
id = #{id}
</delete>
<!-- 获取数据符合筛选条件的总记录条数 -->
<select id="getLimitedDataCount" resultType="java.lang.Integer"
parameterType="PagerOptions">
SELECT COUNT(id) FROM move_data_tmp
<if test="PagerOptions!=null">
<where>
<include refid="conditionsFilters" />
</where>
</if>
</select>
<!-- 获取数据查询的起始di -->
<select id="getLimitedBeginId" resultType="java.lang.Integer"
parameterType="PagerOptions">
SELECT MAX(idx) FROM (SELECT id idx FROM move_data_tmp
ORDER BY id LIMIT 0,#{PagerOptions.totalLimit}) AS TEMP
</select>
</mapper>

@ -58,7 +58,7 @@ public class DataModelController extends BaseController{
Map<String, String[]> paramMap = res.getParameterMap();
Set<String> keySet = paramMap.keySet();
Map<String, String> params = new HashMap<String, String>();
StringBuffer sb = new StringBuffer().append("锟斤拷前锟斤拷锟斤拷锟斤拷锟斤拷锟<EFBFBD>:{");
StringBuffer sb = new StringBuffer().append("<EFBFBD><EFBFBD>ǰ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:{");
for (String str : keySet) {
String value = paramMap.get(str)[0];
if (StringUtils.isNotEmpty(value)) {
@ -89,7 +89,7 @@ public class DataModelController extends BaseController{
String[] oraclesName = paramMap.get("oracleName");
if (oraclesName != null)
for (String rcName : oraclesName) {
Configs.CONSOLE_LOGGER.info("杩炴帴鎴愬姛\t" + rcName);
Configs.CONSOLE_LOGGER.info("连接成功\t" + rcName);
new OracleStatusService().connectToOracle(rcName);
}
}
@ -102,19 +102,20 @@ public class DataModelController extends BaseController{
String operate = paramMap.get("operation")[0];
if (null != oraclesName) {
for (String rcName : oraclesName) {
Configs.CONSOLE_LOGGER.info("杩炴帴鎴愬姛:\t" + rcName);
Configs.CONSOLE_LOGGER.info("连接成功:\t" + rcName);
new OracleStatusService().cancelToOracle(rcName, operate);
}
}
}
@SuppressWarnings({ "unchecked", "unused", "rawtypes" })
@RequestMapping("/oracle/{name}/extract")
public void extractOracleData(HttpServletRequest res,
HttpServletResponse req, String name) throws Exception {
System.out.println("------extract-------");
System.out.println(name);
Map<String, String[]> paramMap = res.getParameterMap();
//姹囨<EFBFBD>诲簱 瀵硅薄淇℃伅--甯︽湁tableName-
//汇总库 对象信息--带有tableName-
String[] nodes = paramMap.get("target");
Map map = null;
for (String string : nodes) {
@ -123,7 +124,7 @@ public class DataModelController extends BaseController{
System.out.println(map);
}
// 閲囬泦搴撳璞<EFBFBD>--(澶氫釜閲囬泦搴撴娊鍙栧埌1涓眹鎬诲簱鐨<E7B0B1>1涓猼ableName涓<65>)
// 采集库对象--(多个采集库抽取到1个汇总库的1个tableName下)
String[] inneed = paramMap.get("inneed");
List<Map<String, String>> colleclist = new ArrayList<Map<String,String>>();
for (String string : nodes) {
@ -148,6 +149,7 @@ public class DataModelController extends BaseController{
return result;
}
@SuppressWarnings("rawtypes")
@RequestMapping(value = "/volume/{name}/move", method= RequestMethod.POST)
@ResponseBody
public Object move(HttpServletRequest res, HttpServletResponse req, String name,
@ -176,7 +178,7 @@ public class DataModelController extends BaseController{
System.out.println(nodes);
System.out.println(selectItems);
System.out.println("--------------");
int result = gfsService.copyFolder(listItemPath, (String)map.get("name"), "app");
int result = gfsService.copyFolder(listItemPath, (String)map.get("path"), "app");
return result;
}
@ -216,13 +218,4 @@ public class DataModelController extends BaseController{
mySqlService.updateOracle(oracle);
System.out.println("----------updateOracleInfo-----------------------");
}
@RequestMapping("/oracle/delete/")
public void deleteOracleInfo(HttpServletRequest res,
HttpServletResponse req){
Map<String, String[]> paramMap = res.getParameterMap();
String[] oraclesName = paramMap.get("param");
for(String str: oraclesName)
System.out.println(str);
}
}

@ -0,0 +1,28 @@
package com.platform.controller;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.base.BaseController;
@Controller
public class TaskModelController extends BaseController{
@RequestMapping("/task/transfer/list")
@ResponseBody
public List<Integer> getTransferTask(HttpServletRequest res, HttpServletResponse req) {
List<Integer> list = new ArrayList<Integer>();
list.add(1);
list.add(2);
list.add(3);
list.add(4);
return list;
}
}

@ -0,0 +1,28 @@
package com.platform.dao;
import java.util.List;
import org.springframework.stereotype.Repository;
import com.platform.entities.DataInfoEntityMoveTmp;
/**
* @author chen
*
*/
@Repository(value = "dataInfoMoveTmpDao")
public interface DataInfoMoveTmpDao {
/**
* @return
* @throws Exception
*/
List<DataInfoEntityMoveTmp> findAll() throws Exception;
int update(DataInfoEntityMoveTmp data) throws Exception;
int save(DataInfoEntityMoveTmp data) throws Exception;
int remove(DataInfoEntityMoveTmp data) throws Exception;
}

@ -21,12 +21,46 @@ package com.platform.entities;
public class Brick {
/** volume总大小 */
private double availableSize;
/** volume已使用大小 */
private double usedSize;
/** ip */
private String ip;
/** 路径 */
private String path;
/**
* @return the availableSize
*/
public double getAvailableSize() {
return availableSize;
}
/**
* @param availableSize the availableSize to set
*/
public void setAvailableSize(double availableSize) {
this.availableSize = availableSize;
}
/**
* @return the usedSize
*/
public double getUsedSize() {
return usedSize;
}
/**
* @param usedSize the usedSize to set
*/
public void setUsedSize(double usedSize) {
this.usedSize = usedSize;
}
/**
* @return the ip
*/
@ -55,4 +89,5 @@ public class Brick {
this.path = path;
}
}

@ -0,0 +1,54 @@
package com.platform.entities;
public class DataInfoEntityMoveTmp extends DataInfoEntity {
private String dstPath;
private String completeStatus;
private int rate;
/**
* @return the dstPath
*/
public String getDstPath() {
return dstPath;
}
/**
* @param dstPath the dstPath to set
*/
public void setDstPath(String dstPath) {
this.dstPath = dstPath;
}
/**
* @return the completeStatus
*/
public String getCompleteStatus() {
return completeStatus;
}
/**
* @param completeStatus the completeStatus to set
*/
public void setCompleteStatus(String completeStatus) {
this.completeStatus = completeStatus;
}
/**
* @return the rate
*/
public int getRate() {
return rate;
}
/**
* @param rate the rate to set
*/
public void setRate(int rate) {
this.rate = rate;
}
}

@ -14,6 +14,16 @@ import org.apache.log4j.PropertyConfigurator;
import com.platform.utils.Constant;
/**
*
* nullmapipip
* ipPeerinCluster(Connected)
* ipPeerinCluster(Disconnected)
* @author liliy
* @version [2016912]
* @see [/]
* @since [/]
*/
public class ClusterInfo {
public static Logger log = Logger.getLogger(ClusterInfo.class);
@ -21,11 +31,6 @@ public class ClusterInfo {
log.info("get cluster info");
Map<String, String> peerIps = new HashMap<String, String>();
/*
String command = "echo \"" + Constant.rootPasswd + "\"|sudo -S gluster peer status";
RunCommand runCommand = new RunCommand();
List<String> reStrings = runCommand.runCommandWait(command);
*/
List<String> reStrings = Constant.ganymedSSH.execCmdWait(Constant.hostIp, Constant.rootUser, Constant.rootPasswd, Constant.port, Constant.glusterPeerStatus);
if (reStrings == null) {
log.error("1101 command get result is null");
@ -77,6 +82,25 @@ public class ClusterInfo {
return peerIps;
}
/**
* ipip
* ipnull
* ipPeerinCluster(Connected)
* ipPeerinCluster(Disconnected)
* @param peerip
* @return
* @see [##]
*/
public String getPeerStatus(String peerip){
Map<String, String> peerIps=showClusterInfo();
if(peerIps==null || peerIps.size()==0){
return null;
}
if(!peerIps.containsKey(peerip)){
return Constant.peerincluster_disconnected;
}
return peerIps.get(peerip);
}
public static void main(String[] args) {

@ -4,11 +4,11 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.apache.log4j.PropertyConfigurator;
import org.junit.Test;
import org.springframework.stereotype.Service;
import com.platform.entities.FolderNode;
import com.platform.utils.Constant;
import com.platform.utils.FileOperateHelper;
/**
* <> GFS
@ -29,7 +29,10 @@ public class GetTreeData {
* @see [##]
*/
public FolderNode getDatas(String name) {
FolderNode fileNode = new FolderNode(name);
String names[]=name.split("/");
String only_name=names[names.length-1];
FolderNode fileNode = new FolderNode(only_name);
fileNode.setPath(name);
Map<String, String> files = showData.showFolderData(name);
if(files==null || files.size()==0){
return fileNode;
@ -38,10 +41,10 @@ public class GetTreeData {
List<FolderNode> list = new ArrayList<FolderNode>();
fileNode.setChildNodes(list);
for (Map.Entry<String, String> entry : files.entrySet()) {
int number = Integer.parseInt(entry.getValue());
if ("app".equals(entry.getKey())) {
if(entry.getKey().equals("app")){
continue;
}
int number = Integer.parseInt(entry.getValue());
if (number == 1) {
fileNode.getChildNodes().add(new FolderNode(entry.getKey(), number));
}
@ -54,27 +57,64 @@ public class GetTreeData {
return fileNode;
}
// public static void main(String[] args) {
// GetTreeData getTreeData=new GetTreeData();
// FileOrFolder fileOrFolder=getTreeData.getDatas("/home");
// System.out.println(fileOrFolder);
// }
/**
* <>
* <>
* @param name
* @return
* @see [##]
*/
public FolderNode getDatasWithShell(String name) {
if(name.endsWith("/")){
name=name.substring(0, name.length());
}
String names[]=name.split("/");
String only_name=names[names.length-1];
FolderNode fileNode = new FolderNode(name);
fileNode.setPath(name);
String shellComment=new FileOperateHelper().fileReaderAndendline(Constant.fileGetTreeData);
String sh_path="/getTreedata.sh";
String cmd="echo -e "+shellComment+" > "+sh_path+" & chmod +x "+sh_path;
Constant.ganymedSSH.execCmdWaitAcquiescent(cmd);
// Map<String, String> files = showData.showFolderData(name);
List<String> files=Constant.ganymedSSH.execCmdWaitAcquiescent(sh_path+" "+name);
if(files==null){
return null;
}
if(files.size()==0){
return fileNode;
}
for(String file:files){
}
return fileNode;
}
@Test
public void test_getTreeData() {
GetTreeData getTreeData=new GetTreeData();
FolderNode fileOrFolder=getTreeData.getDatas("/home");
System.out.println(fileOrFolder);
}
}
/*
class FileOrFolder {
String name;
int isFolder; // 1 is file and other integer is folder show children number
List<FileOrFolder> children;
public FileOrFolder(String name) {
// TODO Auto-generated constructor stub
this.name = name;
}
//class FileOrFolder {
// String name;
// int isFolder; // 1 is file and other integer is folder show children number
// List<FileOrFolder> children;
//
// public FileOrFolder(String name) {
// // TODO Auto-generated constructor stub
// this.name = name;
// }
//
// public FileOrFolder(String name, int isFolder) {
// // TODO Auto-generated constructor stub
// this.name = name;
// this.isFolder = isFolder;
// }
//}
public FileOrFolder(String name, int isFolder) {
// TODO Auto-generated constructor stub
this.name = name;
this.isFolder = isFolder;
}
}
*/

@ -1,5 +1,11 @@
package com.platform.glusterfs;
import org.apache.log4j.Logger;
public class SetCluster {
public static Logger log = Logger.getLogger ( SetCluster.class);
public int addPeer(String peerip){
return 0;
}
}

@ -108,16 +108,21 @@ public class SetVolume {
return -1;
}
String mountPoint = new VolumeInfo().getVolumeMountPoint(volumeName);
List<String> mountPoints = new VolumeInfo().getVolumeMountPoint(volumeName);
if (stopVolume(volumeName) != 0) {
log.error("3802 " + volumeName + " stop failed !");
return -2;
}
log.info("stop "+volumeName+" successed!");
if (mountPoint != null) {
String command = "umount " + mountPoint;
Constant.ganymedSSH.execCmdNoWaitAcquiescent(command);
log.info("umount "+mountPoint+" successed!");
if (null == mountPoints) {
return -2;
}
for(String mountPoint:mountPoints){
if (mountPoint != null) {
String command = "umount -l " + mountPoint;
Constant.ganymedSSH.execCmdNoWaitAcquiescent(command);
log.info("umount "+mountPoint+" successed!");
}
}
String command="echo -e \"y\"| gluster volume delete "+volumeName;
List<String> reStrings=Constant.ganymedSSH.execCmdWaitAcquiescent(command);

@ -17,13 +17,14 @@ import com.platform.utils.Constant;
public class ShowData {
public static Logger log = Logger.getLogger ( ShowData.class);
/**
* get the data of volumeName Map<string s1,string s2> s1 is data name and s2 is type file or folder
* <>
* @param volumeName
* @return
* @see [##]
*/
public Map<String,String> showVolumeFiles(String volumeName){
log.info("start show the data");
Map<String,String> data_type=new HashMap<String, String>();

@ -1,7 +1,5 @@
package com.platform.glusterfs;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
@ -11,8 +9,11 @@ import java.util.Map;
import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;
import org.junit.Test;
import org.omg.CosNaming.NamingContextExtPackage.StringNameHelper;
import com.platform.utils.Constant;
import com.platform.utils.GanymedSSH;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@ -20,6 +21,12 @@ import java.util.regex.Pattern;
public class VolumeInfo {
public static Logger log = Logger.getLogger(VolumeInfo.class);
/**
* volume
* <>
* @return
* @see [##]
*/
public List<String> showAllVolumeName() {
log.info("get volume name");
List<String> volNames = new ArrayList<String>();
@ -30,18 +37,18 @@ public class VolumeInfo {
* runCommand = new RunCommand(); List<String> reStrings =
* runCommand.runCommandWait(command);
*/
List<String> reStrings = Constant.ganymedSSH.execCmdWait(Constant.hostIp, Constant.rootUser, Constant.rootPasswd,
Constant.port, Constant.glusterVolumeInfo + "|grep ^Volume.Name");
List<String> reStrings = Constant.ganymedSSH.execCmdWait(Constant.hostIp, Constant.rootUser,
Constant.rootPasswd, Constant.port, Constant.glusterVolumeInfo + "|grep ^Volume.Name");
// System.out.println(reStrings);
if(reStrings==null){
if (reStrings == null) {
log.error("1401 get result is null");
return null;
}
if(reStrings.size()==0){
if (reStrings.size() == 0) {
log.error("1402 get result is nothing");
return null;
}
if(reStrings.get(0).contains(Constant.noVolume)){
if (reStrings.get(0).contains(Constant.noVolume)) {
reStrings.clear();
return reStrings;
}
@ -60,27 +67,25 @@ public class VolumeInfo {
}
/**
* volumevolume
* <>
* @param volumeName
* @return
* @see [##]
*/
public String getVolumeType(String volumeName) {
log.info("get volume type");
String volType = "";
/*
* =======
*
* >>>>>>> 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");
List<String> reStrings = Constant.ganymedSSH.execCmdWait(Constant.hostIp, Constant.rootUser,
Constant.rootPasswd, Constant.port, Constant.glusterVolumeInfo + volumeName + "|grep ^Type");
// System.out.println(reStrings);
if(reStrings==null){
if (reStrings == null) {
log.error("1501 get result is null");
return null;
}
if(reStrings.size()==0){
if (reStrings.size() == 0) {
log.error("1502 get result is nothing");
return null;
}
@ -96,31 +101,21 @@ public class VolumeInfo {
String str[] = line.split(":");
volType = str[1];
}
volType=volType.replaceAll(" ", "");
volType = volType.replaceAll(" ", "");
return volType;
}
public String getVolumeStatus(String volumeName) {
log.info("get volume status");
String volStatus = "";
/*
* =======
*
* >>>>>>> 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");
List<String> reStrings = Constant.ganymedSSH.execCmdWait(Constant.hostIp, Constant.rootUser,
Constant.rootPasswd, Constant.port, Constant.glusterVolumeInfo + "|grep ^Status");
// System.out.println(reStrings);
if(reStrings==null){
if (reStrings == null) {
log.error("1701 get result is null");
return null;
}
if(reStrings.size()==0){
if (reStrings.size() == 0) {
log.error("1702 get result is nothing");
return null;
}
@ -134,7 +129,6 @@ public class VolumeInfo {
String str[] = line.split(":");
volStatus = str[1].replaceAll(" ", "");
}
return volStatus;
}
@ -182,23 +176,14 @@ public class VolumeInfo {
log.info("get volume used size");
Double usedSize = null;
/*
* =======
*
* >>>>>>> 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}'");
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);
if(reStrings==null){
if (reStrings == null) {
log.error("1901 get result is null");
return null;
}
if(reStrings.size()==0){
if (reStrings.size() == 0) {
log.error("1902 get result is nothing");
return null;
}
@ -218,19 +203,29 @@ public class VolumeInfo {
return usedSize;
}
public String getVolumeMountPoint(String volumeName) {
log.info("get volume mountPoint");
// String mountPoint = "";
/**
* @param volumeName
* @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,
Constant.port, Constant.df + "|grep " + volumeName + "|awk '{print $6}'");
// System.out.println(reStrings);
@ -248,24 +243,92 @@ public class VolumeInfo {
log.error("11003 get result string wrong");
return null;
}
Iterator it = reStrings.iterator();
String mountPoint = (String) it.next();
List<String> mountPoints = new ArrayList<>();
for(String mountPoint:reStrings){
mountPoint=mountPoint.replaceAll(" ", "");
return mountPoint;
mountPoints.add(mountPoint);
}
return mountPoints;
}
public static void main(String[] args) {
PropertyConfigurator.configure("log4j.properties");
public Map<String, Double> getVolumebricksDataSize(String volumeName) {
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());
System.out.println(new VolumeInfo().getVolumeType("v1"));
public Map<String, Double> getVolumebricksAvailableSize(String volumeName) {
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"));
System.out.println(new VolumeInfo().getVolumeMountPoint("v1"));
@Test
public void test_getVolumebricksDataSize() {
System.out.println(getVolumebricksDataSize("gfs_ftp"));
}
System.out.println(new VolumeInfo().getVolumeAllSize("v1"));
System.out.println(new VolumeInfo().getVolumeUseSize("v1"));
@Test
public void test_getVolumebricksAvailableSize() {
System.out.println(getVolumebricksAvailableSize("gfs_ftp"));
}
// @Test
public void test_getVolumeBricks() {
getVolumeBricks("gfs_ftp");
}
}

@ -44,6 +44,7 @@ public class DataInfoServiceImp implements DataInfoService {
public void deleteData(String[] id) {
// TODO Auto-generated method stub
for(String idx: id){
//数据在不在?
List<String> paths = dfdDao.getIdIsExist(Integer.parseInt(idx));
if(paths.size()>0){
//删除文件操作

@ -12,9 +12,11 @@ package com.platform.service.impl;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.springframework.stereotype.Service;
import com.platform.entities.Brick;
import com.platform.entities.FolderNode;
import com.platform.entities.VolumeEntity;
import com.platform.glusterfs.CopyData;
@ -22,7 +24,7 @@ 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.ThreadVolume;
import com.platform.utils.getTreeDataByPath;
/**
@ -71,22 +73,45 @@ public class GfsServiceImpl implements IGfsService {
public List<VolumeEntity> getAllVolumes() throws Exception {
List<VolumeEntity> volumeList = new ArrayList<>();
List<String> volumeNameList = volumeInfo.showAllVolumeName();
if (null == volumeNameList) {
return null;
}
for (String volumeName : volumeNameList) {
VolumeEntity volume = new VolumeEntity();
volume.setName(volumeName);
String path = volumeInfo.getVolumeMountPoint(volumeName);
volume.setPath(path);
List<String> path = volumeInfo.getVolumeMountPoint(volumeName);
//默认加载第一个路径
if (null != path && path.size() > 0) {
volume.setPath(path.get(0));
}
volume.setAllSize(volumeInfo.getVolumeAllSize(volumeName));
volume.setUsedSize(volumeInfo.getVolumeUseSize(volumeName));
//TODO
// volume.setBrick(brick);
//TODO 查询brick--
//返回 ip:path
List<String> brickStrs = volumeInfo.getVolumeBricks(volumeName);
//brick已用大小
Map<String, Double> usedSize = volumeInfo.getVolumebricksDataSize(volumeName);
Map<String, Double> availableSize = volumeInfo.getVolumebricksAvailableSize(volumeName);
List<Brick> brickList = new ArrayList<Brick>();
for (String brickIpPath : brickStrs) {
Brick b = new Brick();
String ipAndpath[] = brickIpPath.split(":");
String brickip = ipAndpath[0];
String brickpath = ipAndpath[1];
//iP , path ,
b.setIp(brickip);
b.setPath(brickpath);
b.setAvailableSize(availableSize.get(brickIpPath));
b.setUsedSize(usedSize.get(brickIpPath));
brickList.add(b);
}
volume.setBrick(brickList);
if (null != volume.getPath()) {
// volume.setFolder(gfsTree.getDatas(volume.getPath()));
volume.setFolder(getFolder(path));
// 获得 folder 目录
volume.setFolder(getFolder(volume.getPath()));
}
volumeList.add(volume);
}
return volumeList;
}
@ -94,13 +119,15 @@ public class GfsServiceImpl implements IGfsService {
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));
List<String> path = volumeInfo.getVolumeMountPoint(volumeName);
if (null != path && path.size() > 0) {
volume.setPath(path.get(0));
}
volume.setAllSize(volumeInfo.getVolumeAllSize(volumeName));
volume.setUsedSize(volumeInfo.getVolumeUseSize(volumeName));
// volume.setBrick(brick);
if (null != volume.getPath()) {
volume.setFolder(getFolder(path));
volume.setFolder(getFolder(path.get(0)));
}
return volume;
}

@ -1,18 +1,19 @@
package com.platform.utils;
import java.util.List;
import com.platform.entities.FolderNode;
public class CacheTreeData {
private static FolderNode folders = null;
private static List<FolderNode> folders = null;
public static FolderNode getFolders() {
public static List<FolderNode> getFolders() {
return folders;
}
public static void setFolders(FolderNode folders) {
public static void setFolders(List<FolderNode> folders) {
CacheTreeData.folders = folders;
}
}

@ -23,7 +23,7 @@ public class ConfigsLoader implements ServletContextListener {
+ "WEB-INF/config/config.properties";
this.cReader = ConfigPropertyReader.Builder(contextPath);
init();
new VolumeThread("").start();
new ThreadVolume("").start();
}
public static void init() {

@ -1,24 +1,32 @@
package com.platform.utils;
import java.util.List;
public class Constant {
public static String rootUser = "root";
public static String rootPasswd = "root";
public static String hostIp = "192.168.0.116";
public static int port = 22;
public static String glusterPeerStatus = "gluster peer status";
public static String glusterVolumeInfo = "gluster volume info ";
public static String df = "df -k ";
public static String peerincluster_connected="PeerinCluster(Connected)";
public static String distributed="distributed";
public static String replica="replica";
public static String stripe="stripe";
public static String noVolume="No volumes present";
public static GanymedSSH ganymedSSH=new GanymedSSH(hostIp, rootUser, rootPasswd, port);
public static String rootUser = "root";
public static String rootPasswd = "root";
public static String hostIp = "192.168.0.110";
// public static String hostIp = "192.168.1.105";
public static int port = 22;
public static String glusterPeerStatus = "gluster peer status";
public static String glusterVolumeInfo = "gluster volume info ";
public static String df = "df -k ";
public static String peerincluster_connected="PeerinCluster(Connected)";
public static String peerincluster_disconnected="PeerinCluster(Disconnected)";
public static String distributed="distributed";
public static String replica="replica";
public static String stripe="stripe";
public static String noVolume="No volumes present";
public static GanymedSSH ganymedSSH=new GanymedSSH(hostIp, rootUser, rootPasswd, port);
public static String fileGetTreeData="./WEB-INF/config/getTreedata.sh";
/**
* volume 线
*/
public final static int get_volume_sleep_time = 300000;
/**
* volume 线
*/
public final static int update_dataInfo_sleep_time = 3000;
/**
* volume 线
*/
public final static int get_volume_sleep_time = 300000;
}

@ -59,4 +59,28 @@ public class FileOperateHelper {
}
return sb.toString();
}
/**
*
* @param path
* @return
*/
@SuppressWarnings("resource")
public static String fileReaderAndendline(String path) {
StringBuffer sb = new StringBuffer();
String tempString = "";
try {
File file = new File(path);
if (!file.exists())
return "";
FileInputStream fis = new FileInputStream(file);
BufferedReader br = new BufferedReader(new InputStreamReader(fis));
while ((tempString = br.readLine()) != null) {
sb.append(tempString+"\n");
}
} catch (Exception e) {
// TODO: handle exception
}
return sb.toString();
}
}

@ -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();

@ -0,0 +1,31 @@
package com.platform.utils;
public class ThreadMoveData extends Thread {
/**
* : --
*/
public ThreadMoveData() {
// TODO Auto-generated constructor stub
}
/* (non-Javadoc)
* @see java.lang.Thread#run()
*
*/
@Override
public void run() {
// TODO Auto-generated method stub
super.run();
//查询 表 move_data_tmp
try {
Thread.sleep(Constant.update_dataInfo_sleep_time);
} catch (InterruptedException e) {
}
}
}

@ -0,0 +1,73 @@
package com.platform.utils;
import java.util.ArrayList;
import java.util.List;
import com.platform.entities.FolderNode;
import com.platform.entities.VolumeEntity;
import com.platform.glusterfs.GetTreeData;
import com.platform.glusterfs.VolumeInfo;
public class ThreadVolume extends Thread implements Runnable{
/**
* --
*/
private static String pointPath = "/home";
/** Volume信息查询 */
private VolumeInfo volumeInfo = new VolumeInfo();
public ThreadVolume() {
// TODO Auto-generated constructor stub
}
public ThreadVolume(String path) {
if (null != path && !"".equals(path.trim())) {
ThreadVolume.pointPath = path;
}
}
/** gfs目录树形展示 */
private GetTreeData gfsTree = new GetTreeData();
@Override
public void run() {
super.run();
while(true){
List<FolderNode> folderlist = new ArrayList<FolderNode>();
//查询 volume name
List<String> volumeNameList = volumeInfo.showAllVolumeName();
if (null != volumeNameList) {
for (String volumeName : volumeNameList) {
VolumeEntity volume = new VolumeEntity();
volume.setName(volumeName);
List<String> path = volumeInfo.getVolumeMountPoint(volumeName);
//默认加载第一个路径
if (null != path && path.size() > 0) {
//装入 folder
//查询 每个 volume 下的 folder
FolderNode foldertmp = gfsTree.getDatas(path.get(0));
folderlist.add(foldertmp);
}
}
}
//TODO 更新folder 目录
CacheTreeData.setFolders(folderlist);
try {
Thread.sleep(Constant.get_volume_sleep_time);
} catch (InterruptedException e) {
}
}
}
public static String getPointPath() {
return pointPath;
}
public static void setPointPath(String pointPath) {
ThreadVolume.pointPath = pointPath;
}
}

@ -1,52 +0,0 @@
package com.platform.utils;
import java.util.List;
import com.platform.entities.FolderNode;
import com.platform.glusterfs.GetTreeData;
import com.platform.glusterfs.VolumeInfo;
public class VolumeThread extends Thread implements Runnable{
/**
*
*/
private static String pointPath = "/home";
public VolumeThread() {
// TODO Auto-generated constructor stub
}
public VolumeThread(String path) {
if (null != path && !"".equals(path.trim())) {
VolumeThread.pointPath = path;
}
}
/** gfs目录树形展示 */
private GetTreeData gfsTree = new GetTreeData();
@Override
public void run() {
super.run();
while(true){
FolderNode folders = gfsTree.getDatas(pointPath);
//TODO
CacheTreeData.setFolders(folders);
try {
Thread.sleep(Constant.get_volume_sleep_time);
} catch (InterruptedException e) {
}
}
}
public static String getPointPath() {
return pointPath;
}
public static void setPointPath(String pointPath) {
VolumeThread.pointPath = pointPath;
}
}

@ -11,11 +11,17 @@ public class getTreeDataByPath {
* @return
*/
public FolderNode findByPath(String path) {
FolderNode folderNode = CacheTreeData.getFolders();
if (null == folderNode) {
List<FolderNode> folderNodelist = CacheTreeData.getFolders();
if (null == folderNodelist) {
return null;
}
FolderNode folder = getFolder(folderNode, path);
FolderNode folder = null;
for (FolderNode folderNode : folderNodelist) {
folder = getFolder(folderNode, path);
if (null != folder) {
break;
}
}
return folder;
}

@ -21,8 +21,6 @@ public class FolderReader {
childrens.add(children);
}
}
/*folderNode = new FolderNode(file.getName(), file.getAbsolutePath(),
childrens);*/
}
return folderNode;
}

Loading…
Cancel
Save