diff --git a/.classpath b/.classpath deleted file mode 100644 index 71fbf515..00000000 --- a/.classpath +++ /dev/null @@ -1,29 +0,0 @@ - - - - -<<<<<<< HEAD - - - - - - - - -======= - ->>>>>>> 355b6e47a4fa8d058029ec939fe4fefdaa751275 - - - - -<<<<<<< HEAD - -======= - - - ->>>>>>> 355b6e47a4fa8d058029ec939fe4fefdaa751275 - - diff --git a/.gitignore b/.gitignore index b73c070d..bd558629 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,4 @@ -<<<<<<< HEAD -/target/ +/target /build -======= -build/ ->>>>>>> 355b6e47a4fa8d058029ec939fe4fefdaa751275 +.classpath + diff --git a/.settings/com.genuitec.eclipse.migration.prefs b/.settings/com.genuitec.eclipse.migration.prefs deleted file mode 100644 index bf0067e7..00000000 --- a/.settings/com.genuitec.eclipse.migration.prefs +++ /dev/null @@ -1,3 +0,0 @@ -eclipse.preferences.version=1 -performed.operation.correct.unbound.jre=1.0 -performed.operation.resolve.unknown.runtime=1.0 diff --git a/.settings/org.eclipse.core.resources.prefs b/.settings/org.eclipse.core.resources.prefs deleted file mode 100644 index 544ad1e4..00000000 --- a/.settings/org.eclipse.core.resources.prefs +++ /dev/null @@ -1,5 +0,0 @@ -eclipse.preferences.version=1 -encoding//WebContent/WEB-INF/config/config.properties=UTF-8 -encoding//src/com/platform/utils/GanymedSSH.java=UTF-8 -encoding/=UTF-8 -separateDerivedEncodings=true diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 68c704e1..00000000 --- a/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,101 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.annotation.inheritNullAnnotations=disabled -org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore -org.eclipse.jdt.core.compiler.annotation.nonnull=org.eclipse.jdt.annotation.NonNull -org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault -org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable -org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 -org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.7 -org.eclipse.jdt.core.compiler.debug.lineNumber=generate -org.eclipse.jdt.core.compiler.debug.localVariable=generate -org.eclipse.jdt.core.compiler.debug.sourceFile=generate -org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.autoboxing=ignore -org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning -org.eclipse.jdt.core.compiler.problem.deadCode=warning -org.eclipse.jdt.core.compiler.problem.deprecation=warning -org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled -org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled -org.eclipse.jdt.core.compiler.problem.discouragedReference=warning -org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore -org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore -org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled -org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore -org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning -org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning -org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning -org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning -org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled -org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning -org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=warning -org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore -org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore -org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning -org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore -org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore -org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled -org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore -org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore -org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled -org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning -org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore -org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning -org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning -org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore -org.eclipse.jdt.core.compiler.problem.nonnullParameterAnnotationDropped=warning -org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error -org.eclipse.jdt.core.compiler.problem.nullReference=warning -org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error -org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=warning -org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning -org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore -org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore -org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore -org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=ignore -org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning -org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning -org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore -org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore -org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore -org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore -org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore -org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled -org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning -org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled -org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled -org.eclipse.jdt.core.compiler.problem.syntacticNullAnalysisForFields=disabled -org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore -org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning -org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=enabled -org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning -org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning -org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore -org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning -org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore -org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=ignore -org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore -org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore -org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled -org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled -org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled -org.eclipse.jdt.core.compiler.problem.unusedExceptionParameter=ignore -org.eclipse.jdt.core.compiler.problem.unusedImport=warning -org.eclipse.jdt.core.compiler.problem.unusedLabel=warning -org.eclipse.jdt.core.compiler.problem.unusedLocal=warning -org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore -org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore -org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled -org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled -org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled -org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning -org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=ignore -org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning -org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning -org.eclipse.jdt.core.compiler.source=1.7 diff --git a/.settings/org.eclipse.jpt.core.prefs b/.settings/org.eclipse.jpt.core.prefs deleted file mode 100644 index 4fd5f244..00000000 --- a/.settings/org.eclipse.jpt.core.prefs +++ /dev/null @@ -1,3 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.jpt.core.platform=generic2_1 -org.eclipse.jpt.jpa.core.discoverAnnotatedClasses=false diff --git a/.settings/org.eclipse.m2e.core.prefs b/.settings/org.eclipse.m2e.core.prefs deleted file mode 100644 index f897a7f1..00000000 --- a/.settings/org.eclipse.m2e.core.prefs +++ /dev/null @@ -1,4 +0,0 @@ -activeProfiles= -eclipse.preferences.version=1 -resolveWorkspaceProjects=true -version=1 diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component deleted file mode 100644 index a576e830..00000000 --- a/.settings/org.eclipse.wst.common.component +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/.settings/org.eclipse.wst.common.project.facet.core.prefs.xml b/.settings/org.eclipse.wst.common.project.facet.core.prefs.xml deleted file mode 100644 index 7961132f..00000000 --- a/.settings/org.eclipse.wst.common.project.facet.core.prefs.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/.settings/org.eclipse.wst.common.project.facet.core.xml b/.settings/org.eclipse.wst.common.project.facet.core.xml deleted file mode 100644 index ba1bfbde..00000000 --- a/.settings/org.eclipse.wst.common.project.facet.core.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - diff --git a/.settings/org.eclipse.wst.jsdt.ui.superType.container b/.settings/org.eclipse.wst.jsdt.ui.superType.container deleted file mode 100644 index 3bd5d0a4..00000000 --- a/.settings/org.eclipse.wst.jsdt.ui.superType.container +++ /dev/null @@ -1 +0,0 @@ -org.eclipse.wst.jsdt.launching.baseBrowserLibrary \ No newline at end of file diff --git a/.settings/org.eclipse.wst.jsdt.ui.superType.name b/.settings/org.eclipse.wst.jsdt.ui.superType.name deleted file mode 100644 index 05bd71b6..00000000 --- a/.settings/org.eclipse.wst.jsdt.ui.superType.name +++ /dev/null @@ -1 +0,0 @@ -Window \ No newline at end of file diff --git a/build/classes/com/platform/controller/DefaultController.class b/build/classes/com/platform/controller/DefaultController.class deleted file mode 100644 index e9becdfc..00000000 Binary files a/build/classes/com/platform/controller/DefaultController.class and /dev/null differ diff --git a/src/com/base/BaseController.java b/src/com/base/BaseController.java index 88038e12..64c66474 100644 --- a/src/com/base/BaseController.java +++ b/src/com/base/BaseController.java @@ -1,67 +1,4 @@ -/** - * 文件名 : BaseController.java - * 版权 : XX科技有限公司。 - * 描述 : <描述> - * 修改时间:2016年9月7日 - * 修改内容:<修改内容> - */ -package com.base; - -import java.util.HashMap; -import java.util.Map; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.apache.log4j.Logger; -import org.springframework.web.bind.annotation.ExceptionHandler; - -import com.platform.utils.Configs; - -/** - * <一句话功能简述> - * <功能详细描述> - * @author chen - * @version [版本号,2016年9月7日] - * @see [相关类/方法] - * @since [产品/模块版本] - */ -public class BaseController { - - /** log4j */ - public static Logger log = Logger.getRootLogger(); - - /** - * <一句话功能简述> 基于@ExceptionHandler异常处理----全局异常处理 - * <功能详细描述> - * @param request - * @param ex 异常 - * @return - * @see [类、类#方法、类#成员] - */ - @ExceptionHandler - public Object exp(HttpServletRequest request, HttpServletResponse response,Exception ex) { - System.out.println("URI"+request.getRequestURI()); - request.setAttribute("ex", ex); - System.err.println("BaseController --exp "); - // 根据不同错误转向不同页面 - if(ex instanceof CustomException) { - CustomException cuse = (CustomException) ex; - Map errmsg = new HashMap<>(); - errmsg.put("code", cuse.getCode()); - errmsg.put("msg", cuse.getMsg()); - log.error(cuse.getCode()); - response.setStatus(500); - return response; - } else { - //其他错误则 调到指定页面 - log.error(Configs.GLOBAL_EXP_NOT_CUSTOM, ex); - response.setStatus(500); - return response; - } - } -======= /** * 文件名 : BaseController.java * 版权 : XX科技有限公司。 diff --git a/src/com/base/CustomException.java b/src/com/base/CustomException.java index f3e90f00..9cf46a4a 100644 --- a/src/com/base/CustomException.java +++ b/src/com/base/CustomException.java @@ -1,129 +1,5 @@ -package com.base; - -import org.apache.log4j.Logger; - -/** - * <一句话功能简述> - * <功能详细描述> - * @author chen - * @version [版本号,2016年9月8日] - * @see [相关类/方法] - * @since [产品/模块版本] - */ -@SuppressWarnings("serial") -public class CustomException extends Exception { - - /** log4j */ - public static Logger log = Logger.getRootLogger(); - - /** 自定义异常信息-错误信息 */ - private String msg; - - /** 自定义异常信息-错误代码 */ - private String code; - - /** 操作对象 */ - private Object[] objArray; - - /** 异常 */ - private Throwable cause; - - public CustomException() { - super(); - } - - /** - * @功能 将异常记录进文件 - * @param code 异常编码 - * @param msg 自定义异常信息 - * @param e - * @param obj - */ - public CustomException(String code,Exception e,Object... obj) { - super(code); - StringBuffer sbuf= new StringBuffer(); - sbuf.append(msg); - this.code = code; - sbuf.append(code); - sbuf.append("\r\n"); - msg = Resource.getProperties().get(code); - // 记录自定义的 异常 - if (null != msg) { - sbuf.append(msg); - sbuf.append("\r\n"); - } - // 记录原始的异常 - if (null != e) { - StackTraceElement[] array = e.getStackTrace(); - cause = e.getCause(); - for (StackTraceElement stackTraceElement : array) { - sbuf.append(stackTraceElement.toString()); - sbuf.append("\r\n"); - } - } - //记录 出现异常时 当前的对象 - if (null != obj) { - Object[] array = obj; - sbuf.append("Object[] size : "); - sbuf.append(array.length); - int forSize = 0; - if (Constant.CustomException_log_object_size < array.length) { - forSize = Constant.CustomException_log_object_size; - } - else { - forSize = array.length; - } - for (int i = 0; i < forSize; i++) { - sbuf.append(array[i]); - sbuf.append("\r\n"); - } - sbuf.append("......"); - sbuf.append("\r\n"); - } - else { - sbuf.append("null"); - sbuf.append("\r\n"); - } - - sbuf.append("\r\n"); - // 是否 写入 文件 - log.error(sbuf.toString()); - } - - /** - * @功能 获得msg - * @return msg - */ - public String getMsg() { - return msg; - } - - - /** - * @return the code - */ - public String getCode() { - return code; - } - - /** - * @功能 获得objArray - * @return objArray - */ - public Object[] getObjArray() { - return objArray; - } - - /** - * @功能 获得cause - * @return cause - */ - public Throwable getCause() { - return cause; - } -} -======= + package com.base; import org.apache.log4j.Logger; diff --git a/src/com/platform/controller/DataModelController.java b/src/com/platform/controller/DataModelController.java index e9cc8a93..853651ba 100644 --- a/src/com/platform/controller/DataModelController.java +++ b/src/com/platform/controller/DataModelController.java @@ -1,104 +1,5 @@ -<<<<<<< HEAD -package com.platform.controller; - -import java.util.HashMap; -import java.util.Map; -import java.util.Set; - -import javax.annotation.Resource; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.apache.commons.lang.StringUtils; -import org.springframework.stereotype.Controller; -import org.springframework.ui.ModelMap; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.ResponseBody; - -import com.platform.entities.PagerOptions; -import com.platform.service.DataInfoService; -import com.platform.service.OracleStatusService; -import com.platform.utils.Configs; -import com.platform.utils.UtilsHelper; - -@Controller -public class DataModelController { - @Resource(name = "dataInfoService") - private DataInfoService dfs; - public void setDfsImp(DataInfoService dfs) { - this.dfs = dfs; - } - @RequestMapping("/data.json") - @ResponseBody - public ModelMap getAllDataToJson(HttpServletRequest res, - HttpServletResponse req) { - Map paramMap = res.getParameterMap(); - Set keySet = paramMap.keySet(); - Map params = new HashMap(); - StringBuffer sb = new StringBuffer().append("当前的请求参数:{"); - for (String str : keySet) { - String value = paramMap.get(str)[0]; - if (StringUtils.isNotEmpty(value)){ - params.put(str, value); - sb.append(str).append(":").append(value).append(","); - }else { - sb.append(str).append(":").append("null").append(","); - } - } - Configs.CONSOLE_LOGGER.info(sb.deleteCharAt(sb.length() - 1) - .append("}").toString()); - PagerOptions pagerOptions = (PagerOptions) UtilsHelper - .newObjAndSetAttrsByClass(PagerOptions.class, params); - - return dfs.getPagerTableData(pagerOptions); - } - - @RequestMapping("/delete/data") - public void deleteData(HttpServletRequest res, HttpServletResponse req) { - Map paramMap = res.getParameterMap(); - String[] data = paramMap.get("data"); - dfs.deleteData(data); - } - - @RequestMapping("/connectOracle") - public void connectOracle(HttpServletRequest res, HttpServletResponse req) { - Map paramMap = res.getParameterMap(); - String[] oraclesName = paramMap.get("oracleName"); - if (oraclesName != null) - for (String rcName : oraclesName) { - Configs.CONSOLE_LOGGER.info("执行后台数据库连接\t" + rcName); - new OracleStatusService().connectToOracle(rcName); - } - } - - @RequestMapping("/cancelOracleConection") - public void cancelOracleConnection(HttpServletRequest res, - HttpServletResponse req) { - Map paramMap = res.getParameterMap(); - String[] oraclesName = paramMap.get("oracleName"); - String operate = paramMap.get("operation")[0]; - if (null != oraclesName) { - for (String rcName : oraclesName) { - Configs.CONSOLE_LOGGER.info("取消后台数据库连接:\t" + rcName); - new OracleStatusService().cancelToOracle(rcName, operate); - } - } - } - - @RequestMapping("/extractOracleData") - public void extractOracleData(HttpServletRequest res, - HttpServletResponse req) { - - } - - @RequestMapping("/getFolder") - public void getFolder(HttpServletRequest res, HttpServletResponse req) { - System.out.println("ooooooooo"); - } -} -======= package com.platform.controller; import java.util.ArrayList; @@ -327,4 +228,4 @@ public class DataModelController extends BaseController{ System.out.println("----------updateOracleInfo-----------------------"); } } ->>>>>>> 355b6e47a4fa8d058029ec939fe4fefdaa751275 + diff --git a/src/com/platform/controller/DefaultController.java b/src/com/platform/controller/DefaultController.java index bc0f7d7b..631e6b77 100644 --- a/src/com/platform/controller/DefaultController.java +++ b/src/com/platform/controller/DefaultController.java @@ -1,35 +1,4 @@ -<<<<<<< HEAD -package com.platform.controller; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.springframework.stereotype.Controller; -import org.springframework.ui.ModelMap; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.servlet.ModelAndView; - -import com.platform.utils.Configs; - -@Controller -public class DefaultController { - - @RequestMapping("/") - public ModelAndView defaultHandler(HttpServletRequest req, HttpServletResponse res){ - //处理不匹配的请求 - System.out.println("index"); - return new ModelAndView("index"); - } - - @RequestMapping("/test") - public ModelMap test(HttpServletRequest req, HttpServletResponse res){ - //System.out.println(Class.class.getClass().getResource("/").getPath()); - System.out.println(Configs.EXTRACT_LOG_LOCALTION); - return new ModelMap(); - } - -} -======= + package com.platform.controller; import javax.servlet.http.HttpServletRequest; @@ -60,4 +29,4 @@ public class DefaultController { } } ->>>>>>> 355b6e47a4fa8d058029ec939fe4fefdaa751275 + diff --git a/src/com/platform/controller/FolderController.java b/src/com/platform/controller/FolderController.java index 4bf604e5..3460cec2 100644 --- a/src/com/platform/controller/FolderController.java +++ b/src/com/platform/controller/FolderController.java @@ -1,13 +1,7 @@ package com.platform.controller; -<<<<<<< HEAD -import javax.annotation.Resource; -import org.springframework.stereotype.Controller; -import org.springframework.stereotype.Service; -import org.springframework.web.bind.annotation.RequestMapping; -======= import java.util.Date; import java.util.List; @@ -19,16 +13,20 @@ import org.springframework.stereotype.Controller; import org.springframework.stereotype.Service; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; ->>>>>>> 355b6e47a4fa8d058029ec939fe4fefdaa751275 + + import com.base.BaseController; import com.base.CustomException; import com.platform.entities.GfsFolderEntity; -<<<<<<< HEAD -======= + + +import com.platform.entities.VolumeEntity; +import com.platform.glusterfs.VolumeInfo; + import com.platform.entities.VolumeEntity; import com.platform.glusterfs.VolumeInfo; ->>>>>>> 355b6e47a4fa8d058029ec939fe4fefdaa751275 + import com.platform.service.IGfsService; @@ -41,21 +39,19 @@ import com.platform.service.IGfsService; * @since [产品/模块版本] */ @Controller -<<<<<<< HEAD -@RequestMapping("/folder") -======= + @RequestMapping("") ->>>>>>> 355b6e47a4fa8d058029ec939fe4fefdaa751275 + public class FolderController extends BaseController { @Resource(name = "gfsService") private IGfsService gfsService; -<<<<<<< HEAD - @RequestMapping("/getAllSubPathByPath") -======= + + + @RequestMapping(value="/getAllSubPathByPath", method= RequestMethod.POST) ->>>>>>> 355b6e47a4fa8d058029ec939fe4fefdaa751275 + public Object getAllSubPathByPath(String path) throws Exception { System.out.println(path); Object result = null; @@ -66,7 +62,7 @@ public class FolderController extends BaseController { return result; } -<<<<<<< HEAD + @RequestMapping("/copyFolder") public Object copyFolder(String srcpath, String dstPath, String name) throws Exception { // -1 :error; -2: the filename is not exists ;-3 :destFolderName ; 1: right @@ -79,7 +75,8 @@ public class FolderController extends BaseController { obj = "err"; } return obj; -======= + } + // /** // * <一句话功能简述> 查询集群中所有的 volume 及其 信息 // * <功能详细描述> @@ -110,7 +107,7 @@ public class FolderController extends BaseController { public Object getVolumByName(String volumeName) throws Exception{ VolumeEntity result = gfsService.getOneVolume(volumeName); return result; ->>>>>>> 355b6e47a4fa8d058029ec939fe4fefdaa751275 + } } diff --git a/src/com/platform/controller/SetGlusterfsController.java b/src/com/platform/controller/SetGlusterfsController.java index 2875fb55..60b776b0 100644 --- a/src/com/platform/controller/SetGlusterfsController.java +++ b/src/com/platform/controller/SetGlusterfsController.java @@ -13,19 +13,16 @@ package com.platform.controller; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -<<<<<<< HEAD -import org.apache.log4j.Logger; -======= ->>>>>>> 355b6e47a4fa8d058029ec939fe4fefdaa751275 import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; /** -<<<<<<< HEAD - * 配置集群 -======= + + * <一句话功能简述> + + * <一句话功能简述> ->>>>>>> 355b6e47a4fa8d058029ec939fe4fefdaa751275 + * <功能详细描述> * @author liliy * @version [版本号,2016年9月8日] @@ -34,16 +31,7 @@ import org.springframework.web.bind.annotation.RequestMapping; */ @Controller public class SetGlusterfsController { -<<<<<<< HEAD - public static Logger log = Logger.getLogger(SetGlusterfsController.class); - - @RequestMapping("") - public void sf(){ - - } - - -======= + @RequestMapping("/tes") public Object defaultHandler(HttpServletRequest req, HttpServletResponse request) { //���?ƥ������� @@ -60,5 +48,5 @@ public class SetGlusterfsController { } ->>>>>>> 355b6e47a4fa8d058029ec939fe4fefdaa751275 + } diff --git a/src/com/platform/controller/ShowGlusterfsController.java b/src/com/platform/controller/ShowGlusterfsController.java index 3d54ec07..7667bc2b 100644 --- a/src/com/platform/controller/ShowGlusterfsController.java +++ b/src/com/platform/controller/ShowGlusterfsController.java @@ -10,31 +10,19 @@ */ package com.platform.controller; -<<<<<<< HEAD import java.util.HashMap; import java.util.List; import java.util.Map; -import org.apache.log4j.Logger; -======= -import java.util.List; -import java.util.Map; - ->>>>>>> 355b6e47a4fa8d058029ec939fe4fefdaa751275 import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import com.platform.glusterfs.ClusterInfo; -<<<<<<< HEAD import com.platform.glusterfs.VolumeInfo; -/** - * 显示集群信息 -======= - /** * <一句话功能简述> ->>>>>>> 355b6e47a4fa8d058029ec939fe4fefdaa751275 + * <功能详细描述> * @author liliy * @version [版本号,2016年9月8日] @@ -43,14 +31,11 @@ import com.platform.glusterfs.VolumeInfo; */ @Controller public class ShowGlusterfsController { -<<<<<<< HEAD - public static Logger log = Logger.getLogger(ShowGlusterfsController.class); - /** - * 显示集群节点以及状态 -======= + + /** * <一句话功能简述> ->>>>>>> 355b6e47a4fa8d058029ec939fe4fefdaa751275 + * <功能详细描述> * @return * @see [类、类#方法、类#成员] @@ -61,35 +46,5 @@ public class ShowGlusterfsController { return peer_status; } -<<<<<<< HEAD - /** - * <一句话功能简述> - * <功能详细描述> - * @return - * @see [类、类#方法、类#成员] - */ - @RequestMapping("/showVolumeStatus") - public Map showVolumeStatus(){ - VolumeInfo volumeInfo=new VolumeInfo(); - Map volume_status=new HashMap(); - List 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; - } - - -======= ->>>>>>> 355b6e47a4fa8d058029ec939fe4fefdaa751275 } diff --git a/src/com/platform/entities/Brick.java b/src/com/platform/entities/Brick.java index 0b3d2ea3..5b74b5f1 100644 --- a/src/com/platform/entities/Brick.java +++ b/src/com/platform/entities/Brick.java @@ -1,4 +1,5 @@ + /** * 文件名 : Brick.java * 版权 : <版权/公司名> @@ -91,3 +92,4 @@ public class Brick { } + diff --git a/src/com/platform/entities/FolderNode.java b/src/com/platform/entities/FolderNode.java index 663b3903..eea0e75e 100644 --- a/src/com/platform/entities/FolderNode.java +++ b/src/com/platform/entities/FolderNode.java @@ -8,12 +8,11 @@ public class FolderNode { private String path; private List childNodes; -<<<<<<< HEAD -======= + public FolderNode() { // TODO Auto-generated constructor stub } ->>>>>>> 355b6e47a4fa8d058029ec939fe4fefdaa751275 + public FolderNode(String name) { this.name = name; diff --git a/src/com/platform/glusterfs/ClusterInfo.java b/src/com/platform/glusterfs/ClusterInfo.java index e251bcb3..04923385 100644 --- a/src/com/platform/glusterfs/ClusterInfo.java +++ b/src/com/platform/glusterfs/ClusterInfo.java @@ -1,4 +1,5 @@ + package com.platform.glusterfs; @@ -109,115 +110,5 @@ public class ClusterInfo { System.out.println(new ClusterInfo().showClusterInfo()); } } -======= -package com.platform.glusterfs; - - - -import java.io.File; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -import org.apache.log4j.Logger; -import org.apache.log4j.PropertyConfigurator; - -import com.platform.utils.Constant; - -/** - * 获取集群节点信息 - * 如果获取不正常,则返回null,如果获取正常,返回map表示节点ip和ip的状态 - * 如果ip在集群中且联通状态为PeerinCluster(Connected) - * 如果ip在集群中且但不连通为PeerinCluster(Disconnected) - * @author liliy - * @version [版本号,2016年9月12日] - * @see [相关类/方法] - * @since [产品/模块版本] - */ -public class ClusterInfo { - public static Logger log = Logger.getLogger(ClusterInfo.class); - - public Map showClusterInfo() { - log.info("get cluster info"); - Map peerIps = new HashMap(); - - List 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"); - return null; - } - if (reStrings.size() == 0) { - log.error("1102 command get result is nothing"); - return null; - } - - if (!(reStrings.get(0).split(":")[0].contains("Number of Peers"))) { - - log.error("1103 get result string wrong"); - return null; - } - - - // System.out.print(reStrings.get(0)); - - int flag = 0; - String ipString = ""; - String state = ""; - for (Iterator it2 = reStrings.iterator(); it2.hasNext();) { - String line = (String) it2.next(); - line=line.replaceAll(" +", " "); - String keyValue[] = line.split(":"); - if (keyValue[0].equals("Hostname")) { - - if (keyValue.length < 2) { - log.error("1105 command get result is wrong"); - continue; - } - ipString = keyValue[1].replaceAll(" ", ""); - flag = 1; - } else if (flag == 1 && keyValue[0].equals("State")) { - - if (keyValue.length < 2) { - log.error("1106 command get result is wrong"); - continue; - } - - state = keyValue[1].replaceAll(" ", ""); - flag = 0; - peerIps.put(ipString, state); - } - - } - return peerIps; - } - - /** - * 根据给定的ip获的ip的状态,即是否在集群中并联通 - * 如果ip不在集群中,返回null - * 如果ip在集群中且联通状态为PeerinCluster(Connected) - * 如果ip在集群中且但不连通为PeerinCluster(Disconnected) - * @param peerip - * @return - * @see [类、类#方法、类#成员] - */ - public String getPeerStatus(String peerip){ - Map 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) { - PropertyConfigurator.configure("log4j.properties"); - System.out.println(new ClusterInfo().showClusterInfo()); - } -} diff --git a/src/com/platform/glusterfs/CopyData.java b/src/com/platform/glusterfs/CopyData.java index e6165ff9..e129fcb1 100644 --- a/src/com/platform/glusterfs/CopyData.java +++ b/src/com/platform/glusterfs/CopyData.java @@ -1,4 +1,4 @@ -<<<<<<< HEAD + package com.platform.glusterfs; import java.util.List; @@ -79,85 +79,5 @@ public class CopyData { copyFolderFiles("/home", "/home/ubuntu", "system_data"); } } -======= -package com.platform.glusterfs; - -import java.util.List; - -import java.util.Map; - -import org.apache.log4j.Logger; -import org.apache.log4j.PropertyConfigurator; -import org.junit.Test; - -import com.platform.utils.Constant; - - -/** - * <一句话功能简述> 复制数据 - * <功能详细描述> - * @author chen - * @version [版本号,2016年9月8日] - * @see [相关类/方法] - * @since [产品/模块版本] - */ - -public class CopyData { - public static Logger log = Logger.getLogger(CopyData.class); - public int copyVolumeFiles(String sourceVolumeName, String destVolumeName, String fileName) { - log.info("start copy " + fileName + " from " + sourceVolumeName + " to " + destVolumeName); - int status = -1; - /** - * get mount point of volumeName - */ - - String sourceFolderName = sourceVolumeName; - String destFolderName = destVolumeName; - status = copyFolderFiles(sourceFolderName, destFolderName, fileName); - return status; - } - /** - * -1 :error; -2: the filename is not exists ;-3 :destFolderName ; 1: right - * not exists - * - * @param folderName - * @param fileName - * @return - */ - public int copyFolderFiles(String sourceFolderName, String destFolderName, String fileName) { - int progress=0; - log.info("start copy " + fileName + " from " + sourceFolderName + " to " + destFolderName); - ShowData showData=new ShowData(); - Map reStrings=showData.showFolderData(destFolderName); - if(reStrings==null){ - log.info("3201 "+destFolderName+" is not exists"); - return -3; - } - - reStrings=showData.showFolderData(sourceFolderName+"/"+fileName); - if(reStrings==null){ - log.info("3202 "+sourceFolderName+"/"+fileName+" is not exists"); - return -2; - } - String command = "cp -r " + sourceFolderName + "/" + fileName+" "+destFolderName; - /* - * RunCommand runCommand = new RunCommand(); - - List reStrings = runCommand.runCommandWait(command); - */ - Constant.ganymedSSH.execCmdNoWaitAcquiescent(command); - - log.info("copy " + sourceFolderName +"/" + fileName+ " to " + destFolderName + " running"); - return 1; - } - - - @Test - public void testCopyFolderFiles() { - PropertyConfigurator.configure("log4j.properties"); - copyFolderFiles("/home", "/home/ubuntu", "system_data"); - } -} ->>>>>>> 355b6e47a4fa8d058029ec939fe4fefdaa751275 diff --git a/src/com/platform/glusterfs/GetTreeData.java b/src/com/platform/glusterfs/GetTreeData.java index 9ba5aa37..81f3ba5b 100644 --- a/src/com/platform/glusterfs/GetTreeData.java +++ b/src/com/platform/glusterfs/GetTreeData.java @@ -1,4 +1,4 @@ -<<<<<<< HEAD + package com.platform.glusterfs; @@ -123,125 +123,3 @@ class FileOrFolder { } */ -======= -package com.platform.glusterfs; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import org.junit.Test; - -import com.platform.entities.FolderNode; -import com.platform.utils.Constant; -import com.platform.utils.FileOperateHelper; - -/** - * <一句话功能简述> 获得GFS某个目录下的子目录 - * <功能详细描述> - * @author chen - * @version [版本号,2016年9月8日] - * @see [相关类/方法] - * @since [产品/模块版本] - */ -public class GetTreeData { - ShowData showData = new ShowData(); - - /** - * <一句话功能简述> 获得所以子目录 - * <功能详细描述> - * @param name - * @return - * @see [类、类#方法、类#成员] - */ - public FolderNode getDatas(String name) { - String names[]=name.split("/"); - String only_name=names[names.length-1]; - FolderNode fileNode = new FolderNode(only_name); - fileNode.setPath(name); - Map files = showData.showFolderData(name); - if(files==null || files.size()==0){ - return fileNode; - } - fileNode.setIsFolder(files.size()); - List list = new ArrayList(); - fileNode.setChildNodes(list); - for (Map.Entry entry : files.entrySet()) { - if(entry.getKey().equals("app")){ - continue; - } - int number = Integer.parseInt(entry.getValue()); - if (number == 1) { - fileNode.getChildNodes().add(new FolderNode(entry.getKey(), number)); - } - if (number > 1) { - FolderNode temp=getDatas(name+"/"+entry.getKey()); - fileNode.getChildNodes().add(temp); - } - } - - return fileNode; - } - - /** - * <一句话功能简述> 获得所以子目录 - * <功能详细描述> - * @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 files = showData.showFolderData(name); - List 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 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; - } -} - -*/ ->>>>>>> 355b6e47a4fa8d058029ec939fe4fefdaa751275 diff --git a/src/com/platform/glusterfs/SetCluster.java b/src/com/platform/glusterfs/SetCluster.java index 35d32538..8f260e5a 100644 --- a/src/com/platform/glusterfs/SetCluster.java +++ b/src/com/platform/glusterfs/SetCluster.java @@ -1,4 +1,4 @@ -<<<<<<< HEAD + package com.platform.glusterfs; import java.util.List; @@ -64,16 +64,4 @@ public class SetCluster { return 0; } } -======= -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; - } -} ->>>>>>> 355b6e47a4fa8d058029ec939fe4fefdaa751275 diff --git a/src/com/platform/glusterfs/SetVolume.java b/src/com/platform/glusterfs/SetVolume.java index cef6c69f..392d7b22 100644 --- a/src/com/platform/glusterfs/SetVolume.java +++ b/src/com/platform/glusterfs/SetVolume.java @@ -1,4 +1,4 @@ -<<<<<<< HEAD + /** * @author 李乾坤 @@ -494,503 +494,4 @@ public class SetVolume { // System.out.println(operation); } } -======= - -/** - * @author 李乾坤 - * 进行volume的一系列操作,如创建、开启停止volume,为volume添加或删除brick - */ -package com.platform.glusterfs; - - - -import java.io.File; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -import org.apache.log4j.Logger; -import org.apache.log4j.PropertyConfigurator; - -import com.platform.utils.Constant; - - - -public class SetVolume { - public static Logger log = Logger.getLogger(SetVolume.class); - - /* - * 创建volume 返回值:创建并挂载成功 1 - * - */ - public int createVolume(String volumeName, int count, String type, List bricks, String mountPoint) { - log.info("Creat new volume"); - - // 判断创建volume的条件是否满足 - int able = isAbleCreateVolume(volumeName, count, type, bricks, mountPoint); - - if (able == 1) { - String command = null; - // 将brics从List变量中提取出来并连接成可以在命令行中使用的格式 - String commandarg = concat(bricks); - - /* - * verify the type - */ - if (type.equals(Constant.distributed)) { - command = "gluster volume create " + volumeName + " " + commandarg + "force"; - } else if (type.equals(Constant.replica) || type.equals(Constant.stripe)) { - command = "gluster volume create " + volumeName + " " + type + " " + count + " " + commandarg + "force"; - } - - // 执行命令 - List reStrings = Constant.ganymedSSH.execCmdWait(Constant.hostIp, Constant.rootUser, Constant.rootPasswd, - Constant.port, command); - - // 创建成功时返回信息格式:volume create: volumename success: - if (reStrings == null || reStrings.size() == 0) { - log.error("3106 " + command + " run return error"); - return -7; - } - if (reStrings.get(0).contains("volume create: " + volumeName + ": " + "success:")) { - log.info("create volume "+volumeName+" successed!"); - // 创建成功则启动并进行挂载 - if (startVolume(volumeName) == 0) { - log.info("start volume "+volumeName+" successed!"); - if ((new ShowData().showFolderData(mountPoint)) == null) { - Constant.ganymedSSH.execCmdWaitAcquiescent("mkdir " + mountPoint); - } - // 进行挂载 - String command3 = "mount -t glusterfs " + Constant.hostIp + ":/" + volumeName + " " + mountPoint; - List reStrings3 = Constant.ganymedSSH.execCmdWait(Constant.hostIp, Constant.rootUser, - Constant.rootPasswd, Constant.port, command3); - - // 这里需要添加解析挂载命令返回字符串的语句,由于我的系统有问题,导致挂载成功后返回WARNING: getfattr - // not found, certain checks will be skipped.. - // 所以这句代码未经测试 - // 成功挂载时没有任何返回信息 - if (reStrings3.size() == 0 || reStrings.get(0).contains("GlusterFS is already mounted")) - { - log.info("mount point successed!"); - return 1; - } - } - } else { - log.error("3104 volume create failed with error" + reStrings.get(0)); - // System.out.println(reStrings.get(0)); - return -7; - } - return 1; - } else { - log.error("给出的参数不满足创建条件"); - // System.out.println("给出的参数不满足创建条件"); - return able; - } - - } - - /** - * 删除volume - * - * @param volumeName - * @return 1 表示成功 ;-1表示volume name不存在;-2表示停止volume 失败 - */ - public int deleteVolume(String volumeName) { - int status = 0; - List volumeNames = new VolumeInfo().showAllVolumeName(); - if (!volumeNames.contains(volumeName)) { - log.error("3801 " + volumeName + " is not exists !"); - return -1; - } - - List mountPoints = new VolumeInfo().getVolumeMountPoint(volumeName); - if (stopVolume(volumeName) != 0) { - log.error("3802 " + volumeName + " stop failed !"); - return -2; - } - log.info("stop "+volumeName+" 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 reStrings=Constant.ganymedSSH.execCmdWaitAcquiescent(command); - if(reStrings==null || reStrings.size()>0 || !(reStrings.get(0).contains("volume delete: "+volumeName+": success"))){ - log.error("3803 : delete volume "+volumeName+" failed !"); - return -3; - } - log.info("delete "+volumeName+" successed!"); - return 1; - } - - /* - * 为指定的volume添加brick,参数中需要指定类型、数量等 返回值:1成功 ;其他失败 - * 过程中需要先检查volume是否存在,还需检查给出的brick数量与类型、count是否相符 - */ - public int addBrickVolume(String volumeName, List brickName, int count, String type) { - // 检查是否满足添加bricks的条件 - int able = isAble(volumeName, count, type, brickName); - if (able != 1) { - return able; - } - - String command = ""; - log.info("add brick to the specified volume"); - - String brick = concat(brickName); - - if (type.equals(Constant.distributed)) - command = "gluster volume add-brick " + volumeName + " " + brick + "force"; - else if (type.equals(Constant.replica)) - command = "gluster volume add-brick " + volumeName + " " + "replica " + count + " " + brick + "force"; - else if (type.equals(Constant.stripe)) - command = "gluster volume add-brick " + volumeName + " " + "stripe " + count + " " + brick + "force"; - - List reStrings = Constant.ganymedSSH.execCmdWait(Constant.hostIp, Constant.rootUser, Constant.rootPasswd, - Constant.port, command); - - // 添加成功的返回信息是:volume add-brick: success - if (reStrings != null && reStrings.size() > 0 && reStrings.get(0).contains("volume add-brick: success")) { - log.info("添加brick成功!"); - return 1; - } else { - log.error("3205 add brick failed,please check the system"); - // System.out.println("3202 add brick failed,please check the system"); - return -5; - } - } - - /* - * 为指定的volume删除brick,参数中需要指定类型、数量等 返回值:1 成功 ;其他 失败 - * 过程中需要先检查volume是否存在,还需检查给出的brick数量与类型、count是否相符 - */ - public int deleteBrickVolume(String volumeName, List brickName, int count, String type) { - int able = isAble(volumeName, count, type, brickName); - - if (able != 1) { - return able; - } - String command = null; - - log.info("delete brick of the specified volume"); - - String brick = concat(brickName); - - if (type.equals(Constant.distributed)) { - command = "echo -e \"y\" | gluster volume remove-brick " + volumeName + " " + brick + " force"; - } else if (type.equals(Constant.replica)) { - command = "echo -e \"y\" | gluster volume remove-brick " + volumeName + " repli " + count + " " + brick - + " force"; - } else if (type.equals(Constant.stripe)) { - command = "echo -e \"y\" | gluster volume remove-brick " + volumeName + " stripe " + count + " " + brick - + " force"; - } - - if (command == null) { - log.error("3305 remove brick failed,please check the system"); - return -5; - } - log.info("即将执行删除命令"); - List reStrings = Constant.ganymedSSH.execCmdWait(Constant.hostIp, Constant.rootUser, Constant.rootPasswd, - Constant.port, command); - // System.out.println(reStrings); - log.info("删除命令执行完毕"); - - // 删除成功的返回信息是“volume remove-brick: success” - if (reStrings.get(0).contains("volume remove-brick: success")) { - { - log.info("删除brick成功"); - return 1; - } - } else { - log.error("3305 remove brick failed,please check the system"); - - return -5; - } - - } - - /* - * 停止指定volume 参数中需给出volume的名字 返回值: 0 成功 -1 失败 - * 需要先检查volume是否存在,然后判断volume的状态是否已经是停止状态 - */ - public int stopVolume(String volumeName) { - log.info("stop volume"); - - // 首先需要判断volume是否存在,调用其他函数返回所有volume的名字 - boolean volumeExist = false; - - List volume = new VolumeInfo().showAllVolumeName(); - for (String temp : volume) { - if (temp.equals(volumeName)) { - volumeExist = true; - break; - } - } - - if (!volumeExist) { - // volume不存在 - log.error("3501 the volume doesnot exist"); - System.out.println("3501 the volume doesnot exist"); - return -1; - } else { - // volume存在,则需判断volume的状态是否已经为“stop” - if (new VolumeInfo().getVolumeStatus(volumeName).equals("Stopped")) { - log.error("3502 the volume is already stoped"); - System.out.println("3502 the volume is already stoped"); - return -1; - } else { - String command = "echo -e \"y\"| gluster volume stop " + volumeName; - List reStrings = Constant.ganymedSSH.execCmdWait(Constant.hostIp, Constant.rootUser, Constant.rootPasswd, - Constant.port, command); - - // 标记操作结果:operation = 1 操作成功 - // operation = 0 操作失败 - int operation = 0; - for (String temp2 : reStrings) { - if (temp2.contains("volume stop: " + volumeName + ": " + "success")) { - operation = 1; - break; - } - System.out.println("operation: " + operation); - } - - if (operation == 1) { - return 0; - } else { - log.error("3503 stop " + volumeName + " failed"); - System.out.println("3503 stop " + volumeName + " failed"); - return -1; - } - - } - } - } - - /* - * 开启指定volume 参数中需给出volume的名字 返回值: 0 成功 -1 失败 - * 需要先检查volume是否存在,然后判断volume的状态是否已经是开启状态 - */ - public int startVolume(String volumeName) { - log.info("start volume"); - boolean volumeExist = false; - List volume = new VolumeInfo().showAllVolumeName(); - - for (String temp : volume) { - if (temp.equals(volumeName)) { - volumeExist = true; - break; - } - } - - if (volumeExist) { - if (!(new VolumeInfo().getVolumeStatus(volumeName).equals("Started"))) { - String command = "gluster volume start " + volumeName; - - int operation = 0; - - // 执行命令 - List reStrings = Constant.ganymedSSH.execCmdWait(Constant.hostIp, Constant.rootUser, Constant.rootPasswd, - Constant.port, command); - for (String temp2 : reStrings) { - if (temp2.equals("volume start: " + volumeName + ": " + "success")) { - operation = 1; - } - } - - if (operation == 1) { - return 0; - } else { - log.error("3602 start volume failed"); - System.out.println("3602 start volume failed"); - return -1; - } - } else { - log.error("volume已经开启"); - System.out.println("volume已经开启"); - return -1; - } - } else { - log.error("3601 the volume does not exist"); - // System.out.println("3601 the volume does not exist"); - return -1; - } - } - - // 需要将存于List变量中的brick的位置组装成可以在glusterfs命令行中直接使用的格式 - public String concat(List brickName) { - StringBuffer result = new StringBuffer(); - int len = brickName.size(); - for (int i = 0; i < len; i++) { - result.append(brickName.get(i)); - result.append(" "); - } - return result.toString(); - } - - /* - * 只在创建volume时使用此函数 创建volume时对不同数据卷,brick的数量需要满足和count的关系 - * 首先判断它们是否满足关系,在不满足的关系的情况下是肯定无法完成操作的 1:可以创建 ;-1:brick的ip不在集群中或者未连接; -2 -3 - * -4 :类型与brick数目不匹配 ; -5 :volumeName 已经存在;-6:挂载点存在且不为空,不能作为挂载点; -7:未知错误 - */ - public int isAbleCreateVolume(String volumeName, int count, String type, List bricks, String mountPoint) { - int status = 0; - - int length = bricks.size(); - - if (type.equals(Constant.distributed)) { - if (count != 0) { - log.error("3101 the kind of distributed requires the arg of count to be 0"); - return -2; - } - } - if (type.equals(Constant.stripe)) { - if (length % count != 0) { - log.error("3102 the number of bricks should be the same as or the times of the stripe count"); - return -3; - } - } - if (type.equals(Constant.replica)) { - if ((length % count) != 0) { - log.error( - "3103 the number of bricks should be the same as the replicate count or the times of replicate count"); - return -4; - } - } - - Map peer_status = new ClusterInfo().showClusterInfo(); - peer_status.put(Constant.hostIp, Constant.peerincluster_connected); - for (String brick : bricks) { - brick = brick.split(":")[0]; - if (!(peer_status.containsKey(brick) && peer_status.get(brick).equals(Constant.peerincluster_connected))) { - log.error("3105 birck " + brick + " ip is not in cluster"); - return -1; - } - - } - - List volumeNames = new VolumeInfo().showAllVolumeName(); - if(volumeNames==null){ - log.error("3108 showAllVolumeName return error"); - return -7; - } - if (volumeNames.contains(volumeName)) { - log.error("3106 " + volumeName + " is already exists! "); - return -5; - } - - Map datas = new ShowData().showFolderData(mountPoint); - if (datas != null && datas.size() > 0) { - log.error("3107 " + mountPoint + " is not exists or not empty ! "); - return -6; - } - return 1; - } - - /** - * 添加或删除volume的brick时,首先需要判断volume是否存在,然后需要判断volume类型、count及brick数目 - * - * @param volumeName - * @param count - * @param type - * @param bricks - * @return 1 满足条件,可以添加;-1 :volume name is not exists;-2,-3,-4 类型与brick数量不匹配; - */ - public int isAble(String volumeName, int count, String type, List bricks) { - List volumeNames = new VolumeInfo().showAllVolumeName(); - - if (!volumeNames.contains(volumeName)) { - log.error("3201:" + volumeName + " is not exists! "); - return -1; - } - - int length = bricks.size(); - if (type.equals("distribute")) { - if (count == 0) - return 1; - else { - log.error("3202: the kind of distributed requires the arg of count to be 0"); - // System.out.println(" the kind of distributed requires the - // arg of count to be 0"); - return -2; - } - } - - if (type.equals("stripe")) { - if (length % count == 0) - return 1; - else { - log.error("3203: the number of bricks should be the same as or the times of the stripe count"); - // System.out.println(" the number of bricks should be the - // same as or the times of the stripe count"); - return -3; - - } - } - if (type.equals("replicate")) { - if ((length % count) == 0) - return 1; - else { - log.error( - "3204: the number of bricks should be the same as the replicate count or the times of replicate count"); - - return -4; - } - } - - return 1; - } - - public static void main(String[] args) { - SetVolume setVolume = new SetVolume(); - int operation = 0; - PropertyConfigurator.configure("log4j.properties"); - // TODO Auto-generated method stub - // 测试创建volume的代码 - - List bricksToCreate = new ArrayList(); - bricksToCreate.add("192.168.0.110:/v1"); - bricksToCreate.add("192.168.0.116:/v1"); - operation = setVolume.createVolume("v1", 0, "distributed", bricksToCreate, "/home/v1_point"); -// operation = setVolume.deleteVolume("v3"); - // - // // 以下是测试添加brick的代码 - // - // List bricksToAdd = new ArrayList(); - // bricksToAdd.add("192.168.191.23:/v3"); - // operation = setVolume.addBrickVolume("v3", bricksToAdd, 0, - // "distribute"); - // System.out.println(operation); - - // 以下代码是测试删除brick的代码 - // List bricksToAdd= new ArrayList(); - // bricksToAdd.add("192.168.191.23:/v3"); - // operation = - // setVolume.deleteBrickVolume("v3",bricksToAdd,0,"distribute"); - // System.out.println(operation); - // 以下是测试start volume的代码 - // String volumeToStart = "testcreate" ; - // int startOperation = startVolume(volumeToStart); - // System.out.println(startOperation); - // 以下是测试stop volume - String volumeToStop = "v3"; - // int startOperation = setVolume.stopVolume(volumeToStop); - // 以下是测试创建volume并完成挂载的代码 - // List bricksToCreate= new ArrayList(); - // bricksToCreate.add("192.168.214.135:/home/create"); - // bricksToCreate.add("192.168.214.138:/home/create"); - // - // int operation = - // createVolume("createAndmount",0,"distribute",bricksToCreate,"/mnt/create"); - // System.out.println(operation); - } -} ->>>>>>> 355b6e47a4fa8d058029ec939fe4fefdaa751275 + diff --git a/src/com/platform/glusterfs/ShowData.java b/src/com/platform/glusterfs/ShowData.java index 968681bd..de218e5e 100644 --- a/src/com/platform/glusterfs/ShowData.java +++ b/src/com/platform/glusterfs/ShowData.java @@ -1,4 +1,4 @@ -<<<<<<< HEAD + package com.platform.glusterfs; import java.util.HashMap; @@ -130,110 +130,4 @@ public class ShowData { System.out.println(getFolderSize("/home/ubuntu")); } -======= -package com.platform.glusterfs; - -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -import org.apache.log4j.Logger; - - -import org.apache.log4j.PropertyConfigurator; -import org.junit.Test; - -import com.platform.utils.Constant; - - -public class ShowData { - - public static Logger log = Logger.getLogger ( ShowData.class); - - /** - * get the data of volumeName Map s1 is data name and s2 is type file or folder - * <功能详细描述> - * @param volumeName - * @return - * @see [类、类#方法、类#成员] - */ - public Map showVolumeFiles(String volumeName){ - log.info("start show the data"); - Map data_type=new HashMap(); - /** - * get mount point of volumeName - */ - String folderName=volumeName; - - data_type=showFolderData(volumeName); - return data_type; -} - /** - * get the data of folder name - * Map is folder name and type 1 is file and others is folder - - - * @param FolderName - * @return - */ - public Map showFolderData(String folderName){ - log.info(" start get "+folderName+" data"); - - - Map data_type=new HashMap(); - String command="ls -l "+folderName; - - /* - RunCommand runCommand=new RunCommand(); - List reStrings=runCommand.runCommandWait(command); - */ - List reStrings = Constant.ganymedSSH.execCmdWait(Constant.hostIp, Constant.rootUser, Constant.rootPasswd, Constant.port, command); - if(reStrings==null){ - log.error("2101 command get result is null"); - return null; - } - if(reStrings.size()==0){ - log.info("2102 the folder is empty"); - return data_type; - } - if(reStrings.get(0).contains("No such file or directory")){ - log.info("2103 the "+folderName+" is not exists"); - return null; - } - /** - * remove first line total number - */ - reStrings.remove(0); - - for(Iterator it2 = reStrings.iterator();it2.hasNext();){ - String line=(String)it2.next(); - line=line.replaceAll(" +", " "); - String keyValue[]=line.split(" "); - if(keyValue.length<9){ - log.error("2104 "+line+" length is short"); - continue; - } - - data_type.put(keyValue[8], keyValue[1]); - - } - log.info(" get "+folderName+" data successed"); - return data_type; - } - - - /** - * - * <一句话功能简述> - * <功能详细描述> - * @see [类、类#方法、类#成员] - */ - @Test - public void testShowData(){ - - System.out.println(showFolderData("/home")); - - } ->>>>>>> 355b6e47a4fa8d058029ec939fe4fefdaa751275 } \ No newline at end of file diff --git a/src/com/platform/glusterfs/VolumeInfo.java b/src/com/platform/glusterfs/VolumeInfo.java index b0d17405..8d592921 100644 --- a/src/com/platform/glusterfs/VolumeInfo.java +++ b/src/com/platform/glusterfs/VolumeInfo.java @@ -1,4 +1,4 @@ -<<<<<<< HEAD + package com.platform.glusterfs; import java.io.File; @@ -324,339 +324,3 @@ public class VolumeInfo { System.out.println(getVolumeMountPoint("v1")); } } -======= -package com.platform.glusterfs; - -import java.io.File; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -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; - -public class VolumeInfo { - public static Logger log = Logger.getLogger(VolumeInfo.class); - - /** - * 显示所有volume名称 - * <功能详细描述> - * @return - * @see [类、类#方法、类#成员] - */ - public List showAllVolumeName() { - log.info("get volume name"); - List volNames = new ArrayList(); - - /* - * String command = "echo \"" + Constant.rootPasswd + - * "\" |sudo -S gluster volume info|grep ^Volume.Name"; RunCommand - * runCommand = new RunCommand(); List reStrings = - * runCommand.runCommandWait(command); - */ - List reStrings = Constant.ganymedSSH.execCmdWait(Constant.hostIp, Constant.rootUser, - Constant.rootPasswd, Constant.port, Constant.glusterVolumeInfo + "|grep ^Volume.Name"); - // System.out.println(reStrings); - if (reStrings == null) { - log.error("1401 get result is null"); - return null; - } - if (reStrings.size() == 0) { - log.error("1402 get result is nothing"); - return null; - } - if (reStrings.get(0).contains(Constant.noVolume)) { - reStrings.clear(); - return reStrings; - } - if (!(reStrings.get(0).split(":")[0].contains("Volume Name"))) { - log.error("1403 get result string wrong"); - return null; - } - - String nameInfo = ""; - for (Iterator it = reStrings.iterator(); it.hasNext();) { - String line = (String) it.next(); - String str[] = line.split(":"); - volNames.add(str[1].replaceAll(" ", "")); - } - return volNames; - - } - - /** - * 给定参数volume的名称获得volume的类型 - * <功能详细描述> - * @param volumeName - * @return - * @see [类、类#方法、类#成员] - */ - public String getVolumeType(String volumeName) { - log.info("get volume type"); - String volType = ""; - - List reStrings = Constant.ganymedSSH.execCmdWait(Constant.hostIp, Constant.rootUser, - Constant.rootPasswd, Constant.port, Constant.glusterVolumeInfo + volumeName + "|grep ^Type"); - // System.out.println(reStrings); - if (reStrings == null) { - log.error("1501 get result is null"); - return null; - } - if (reStrings.size() == 0) { - log.error("1502 get result is nothing"); - return null; - } - if (!(reStrings.get(0).split(":")[0].contains("Type"))) { - log.error("1503 get result string wrong"); - return null; - } - - // System.out.println(reStrings); - - for (Iterator it = reStrings.iterator(); it.hasNext();) { - String line = (String) it.next(); - String str[] = line.split(":"); - volType = str[1]; - } - volType = volType.replaceAll(" ", ""); - return volType; - } - - public String getVolumeStatus(String volumeName) { - log.info("get volume status"); - String volStatus = ""; - List reStrings = Constant.ganymedSSH.execCmdWait(Constant.hostIp, Constant.rootUser, - Constant.rootPasswd, Constant.port, Constant.glusterVolumeInfo + "|grep ^Status"); - // System.out.println(reStrings); - if (reStrings == null) { - log.error("1701 get result is null"); - return null; - } - if (reStrings.size() == 0) { - log.error("1702 get result is nothing"); - return null; - } - if (!(reStrings.get(0).split(":")[0].contains("Status"))) { - log.error("1703 get result string wrong"); - return null; - } - - for (Iterator it = reStrings.iterator(); it.hasNext();) { - String line = (String) it.next(); - String str[] = line.split(":"); - volStatus = str[1].replaceAll(" ", ""); - } - return volStatus; - } - - public Double getVolumeAllSize(String volumeName) { - log.info("get volume allSize"); - Double allSize = null; - /* - * ======= // waiting for testing... public Double - * getVolumeAllSize(String volumeName) { log.info("get volume allSize"); - * Double allSize = null; - * - * >>>>>>> origin/AlexKie String command = "echo \"" + - * Constant.rootPasswd + "\" |sudo -S df -h|grep " + volumeName + - * "|awk '{print $2}'"; RunCommand runCommand = new RunCommand(); - * List reStrings = runCommand.runCommandWait(command); <<<<<<< - * HEAD - */ - List reStrings = Constant.ganymedSSH.execCmdWait(Constant.hostIp, Constant.rootUser, Constant.rootPasswd, - Constant.port, Constant.df + "|grep " + volumeName + "|awk '{print $2}'"); - // System.out.println(reStrings); - if(reStrings==null){ - log.error("1801 get result is null"); - return null; - } - if(reStrings.size()==0){ - log.error("1802 get result is nothing"); - return null; - } - char flag = reStrings.get(0).trim().toCharArray()[0]; - if (flag < 48 || flag > 57) { - log.error("1803 get result string wrong"); - return null; - } - - for (Iterator it = reStrings.iterator(); it.hasNext();) { - String line = (String) it.next(); - String str[] = line.split("[^0-9]"); - allSize = Double.parseDouble(str[0]); - } - - return allSize; - } - - public Double getVolumeUseSize(String volumeName) { - log.info("get volume used size"); - Double usedSize = null; - - List 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) { - log.error("1901 get result is null"); - return null; - } - if (reStrings.size() == 0) { - log.error("1902 get result is nothing"); - return null; - } - char flag = reStrings.get(0).trim().toCharArray()[0]; - if (flag < 48 || flag > 57) { - log.error("1903 get result string wrong"); - return null; - } - - for (Iterator it = reStrings.iterator(); it.hasNext();) { - String line = (String) it.next(); - String str[] = line.split("[^0-9]"); - - usedSize = Double.parseDouble(str[0]); - } - - return usedSize; - } - - /** - * @param volumeName - * @return String ipAndpath[] = brick.split(":"); - String ip = ipAndpath[0]; - String path = ipAndpath[1]; - */ - public List getVolumeBricks(String volumeName) { - log.info("get volume bricks"); - - String cmd = "gluster volume info " + volumeName + " |grep ^Brick'[0-9]\\+' |awk '{print $2}'"; - List 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 getVolumeMountPoint(String volumeName) { - log.info("get volume MountPoint"); - - List reStrings = Constant.ganymedSSH.execCmdWait(Constant.hostIp, Constant.rootUser, Constant.rootPasswd, - Constant.port, Constant.df + "|grep " + volumeName + "|awk '{print $6}'"); - // System.out.println(reStrings); - if(reStrings==null){ - log.error("11001 get result string wrong"); - return null; - } - if(reStrings.size()==0){ - log.error("11002 "+volumeName+" is no mountpoint"); - return null; - } - - char flag = reStrings.get(0).trim().toCharArray()[0]; - if (flag != '/') { - log.error("11003 get result string wrong"); - return null; - } - List mountPoints = new ArrayList<>(); - for(String mountPoint:reStrings){ - mountPoint=mountPoint.replaceAll(" ", ""); - mountPoints.add(mountPoint); - } - return mountPoints; - } - - public Map getVolumebricksDataSize(String volumeName) { - List bricks = getVolumeBricks(volumeName); - Map 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 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; - } - - public Map getVolumebricksAvailableSize(String volumeName) { - List bricks = getVolumeBricks(volumeName); - Map 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 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; - } - - @Test - public void test_getVolumebricksDataSize() { - System.out.println(getVolumebricksDataSize("gfs_ftp")); - } - - @Test - public void test_getVolumebricksAvailableSize() { - System.out.println(getVolumebricksAvailableSize("gfs_ftp")); - } - - // @Test - public void test_getVolumeBricks() { - getVolumeBricks("gfs_ftp"); - } -} ->>>>>>> 355b6e47a4fa8d058029ec939fe4fefdaa751275 diff --git a/src/com/platform/service/IGfsService.java b/src/com/platform/service/IGfsService.java index 24811be9..e8a693fb 100644 --- a/src/com/platform/service/IGfsService.java +++ b/src/com/platform/service/IGfsService.java @@ -10,14 +10,12 @@ */ package com.platform.service; -<<<<<<< HEAD -import com.platform.entities.FolderNode; -======= + import java.util.List; import com.platform.entities.FolderNode; import com.platform.entities.VolumeEntity; ->>>>>>> 355b6e47a4fa8d058029ec939fe4fefdaa751275 + /** * <一句话功能简述> @@ -49,9 +47,7 @@ public interface IGfsService { * @throws Exception * @see [类、类#方法、类#成员] */ -<<<<<<< HEAD - public int copyFolder(String src, String dst, String name) throws Exception; -======= + public int copyFolder(List srcFolders, String dstFolder, String name) throws Exception; /** @@ -75,6 +71,6 @@ public interface IGfsService { public int moveData(String volumeName, String srcPath, String dstPath) throws Exception; public int deleteData(String volumeName, String srcPath) throws Exception; ->>>>>>> 355b6e47a4fa8d058029ec939fe4fefdaa751275 + } diff --git a/src/com/platform/service/OracleExtractHelper.java b/src/com/platform/service/OracleExtractHelper.java index 05eaf826..82228e28 100644 --- a/src/com/platform/service/OracleExtractHelper.java +++ b/src/com/platform/service/OracleExtractHelper.java @@ -40,6 +40,7 @@ public class OracleExtractHelper { /** * 创建dblink * +<<<<<<< HEAD <<<<<<< HEAD * @param conn * @param oc @@ -47,6 +48,10 @@ public class OracleExtractHelper { * @param conn 汇总库的连接 * @param oc 采集库 >>>>>>> 355b6e47a4fa8d058029ec939fe4fefdaa751275 +======= + * @param conn 汇总库的连接 + * @param oc 采集库 +>>>>>>> web_backend_develope * dblink连接参数实体 */ public void createDBLink(Connection conn, OracleConnectorParams oc) { diff --git a/src/com/platform/service/impl/GfsServiceImpl.java b/src/com/platform/service/impl/GfsServiceImpl.java index 26f979d2..63fb8bf4 100644 --- a/src/com/platform/service/impl/GfsServiceImpl.java +++ b/src/com/platform/service/impl/GfsServiceImpl.java @@ -1,53 +1,4 @@ -<<<<<<< HEAD -/** - * 文件名 : GfsServiceImpl.java - * 版权 : <版权/公司名> - * 描述 : <描述> - * @author chen - * 版本 : <版本> - * 修改时间: 2016年9月8日 - * 修改内容: <修改内容> - */ -package com.platform.service.impl; - -import org.springframework.stereotype.Service; - -import com.platform.entities.FolderNode; -import com.platform.glusterfs.CopyData; -import com.platform.glusterfs.GetTreeData; -import com.platform.service.IGfsService; - -/** - * <一句话功能简述> - * <功能详细描述> - * @author chen - * @version [版本号,2016年9月8日] - * @see [相关类/方法] - * @since [产品/模块版本] - */ -@Service(value = "gfsService") -public class GfsServiceImpl implements IGfsService { - - private GetTreeData gfsTree = new GetTreeData(); - private CopyData copydata = new CopyData(); - - @Override - public FolderNode getFolder(String path) { - FolderNode result = gfsTree.getDatas(path); - return result; - } - - @Override - public int copyFolder(String src, String dst, String name) - throws Exception { - // TODO Auto-generated method stub - int status = copydata.copyVolumeFiles(src, dst, name); - return status; - } - -} -======= /** * 文件名 : GfsServiceImpl.java @@ -197,4 +148,4 @@ public class GfsServiceImpl implements IGfsService { } } ->>>>>>> 355b6e47a4fa8d058029ec939fe4fefdaa751275 + diff --git a/src/com/platform/utils/CacheTreeData.java b/src/com/platform/utils/CacheTreeData.java index 27b60277..fc9f0c5e 100644 --- a/src/com/platform/utils/CacheTreeData.java +++ b/src/com/platform/utils/CacheTreeData.java @@ -1,3 +1,4 @@ + package com.platform.utils; import java.util.List; @@ -17,3 +18,4 @@ public class CacheTreeData { } } + diff --git a/src/com/platform/utils/ConfigsLoader.java b/src/com/platform/utils/ConfigsLoader.java index b512f228..4d524d60 100644 --- a/src/com/platform/utils/ConfigsLoader.java +++ b/src/com/platform/utils/ConfigsLoader.java @@ -1,78 +1,4 @@ -<<<<<<< HEAD -package com.platform.utils; - -import java.util.Properties; - -import javax.servlet.ServletContextEvent; -import javax.servlet.ServletContextListener; -public class ConfigsLoader implements ServletContextListener { - private static ConfigPropertyReader cReader = null; - - @Override - public void contextDestroyed(ServletContextEvent sEvent) { - // TODO Auto-generated method stub - Configs.CONSOLE_LOGGER.info("系统停止.."); - } - - @SuppressWarnings("static-access") - @Override - public void contextInitialized(ServletContextEvent sEvent) { - // TODO Auto-generated method stub - Configs.CONSOLE_LOGGER.info("系统初始化.."); - String contextPath = sEvent.getServletContext().getRealPath("/") - + "WEB-INF/config/config.properties"; - this.cReader = ConfigPropertyReader.Builder(contextPath); - init(); - } - - public static void init() { - Properties properties = cReader.getProperties(); - - Configs.KUBE_MASTER_URL = properties.getProperty("kubeMasterUrl"); - - Configs.COLLECT_USER_NAME = properties.getProperty("collect-user-name"); - - Configs.COLLECT_PASSWORD = properties.getProperty("collect-password"); - - Configs.COLLECT_SERVICE_NAME = properties - .getProperty("collect-service-name"); - - Configs.GATHER_USER_NAME = properties.getProperty("gather-user-name"); - - Configs.GATHER_USER_PASSWORD = properties - .getProperty("gather-user-password"); - - Configs.GATHER_PORT = properties.getProperty("gather-port"); - - Configs.GATHER_SERVICE_NAME = properties - .getProperty("gather-service-name"); - - Configs.TABLE_SUFFIX = properties.getProperty("table-suffix"); - - Configs.EXTRACT_LOG_LOCALTION = properties - .getProperty("extract-log-localtion"); - - Configs.GATHER_TABLESPACE_NAME = properties - .getProperty("gather-tablespace-name"); - - Configs.GATHER_TABLESPACE_PATH = properties - .getProperty("gather-tablespace-path"); - - Configs.GATHER_TABLE_PASSWORD=properties.getProperty("gather-table-user-password"); - } - - public ConfigPropertyReader getcReader() { - return cReader; - } - - @SuppressWarnings("static-access") - public void setcReader(ConfigPropertyReader cReader) { - this.cReader = cReader; - } - -} -======= package com.platform.utils; import java.util.Properties; @@ -147,4 +73,4 @@ public class ConfigsLoader implements ServletContextListener { } } ->>>>>>> 355b6e47a4fa8d058029ec939fe4fefdaa751275 + diff --git a/src/com/platform/utils/Constant.java b/src/com/platform/utils/Constant.java index a2be1763..a80816c9 100644 --- a/src/com/platform/utils/Constant.java +++ b/src/com/platform/utils/Constant.java @@ -1,4 +1,4 @@ -<<<<<<< HEAD + package com.platform.utils; import java.util.List; @@ -28,29 +28,9 @@ public class Constant { + "then\n ergodic \\$1\"/\"\\$file\n else\n local path=\\$1\"/\"\\$file\n " + "echo \\$path \n fi\n done\n}\n\nIFS=\\$\\'\\n\\' " + "#这个必须要,否则会在文件名中有空格时出错\nINIT_PATH=\".\";\nergodic \\$1\n"; -} -======= -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 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 获取的线程休眠时间 @@ -63,4 +43,3 @@ public class Constant { public final static int update_dataInfo_sleep_time = 3000; } ->>>>>>> 355b6e47a4fa8d058029ec939fe4fefdaa751275 diff --git a/src/com/platform/utils/FileOperateHelper.java b/src/com/platform/utils/FileOperateHelper.java index 118378de..3236c597 100644 --- a/src/com/platform/utils/FileOperateHelper.java +++ b/src/com/platform/utils/FileOperateHelper.java @@ -67,23 +67,18 @@ public class FileOperateHelper { * @param path * @return */ -<<<<<<< HEAD - - public String fileReaderAndendline(String path) { -======= + @SuppressWarnings("resource") public static String fileReaderAndendline(String path) { ->>>>>>> 355b6e47a4fa8d058029ec939fe4fefdaa751275 + StringBuffer sb = new StringBuffer(); String tempString = ""; try { File file = new File(path); if (!file.exists()) -<<<<<<< HEAD - return ""; -======= + return ""; ->>>>>>> 355b6e47a4fa8d058029ec939fe4fefdaa751275 + FileInputStream fis = new FileInputStream(file); BufferedReader br = new BufferedReader(new InputStreamReader(fis)); while ((tempString = br.readLine()) != null) { @@ -94,13 +89,7 @@ public class FileOperateHelper { } return sb.toString(); } -<<<<<<< HEAD + - @Test - public void test_fileReaderAndendline(){ - System.out.println(System.getProperty("user.dir")); - System.out.println(fileReaderAndendline(Constant.fileGetTreeData)); - } -======= ->>>>>>> 355b6e47a4fa8d058029ec939fe4fefdaa751275 + } diff --git a/src/com/platform/utils/GanymedSSH.java b/src/com/platform/utils/GanymedSSH.java index d8ce1dd6..31598f93 100644 --- a/src/com/platform/utils/GanymedSSH.java +++ b/src/com/platform/utils/GanymedSSH.java @@ -1,4 +1,4 @@ -<<<<<<< HEAD + package com.platform.utils; import java.io.BufferedReader; @@ -266,272 +266,3 @@ public class GanymedSSH { } } -======= -package com.platform.utils; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.apache.log4j.Logger; -import org.apache.log4j.PropertyConfigurator; - -import ch.ethz.ssh2.Connection; -import ch.ethz.ssh2.Session; -import ch.ethz.ssh2.StreamGobbler; - -import ch.ethz.ssh2.*; - - - -public class GanymedSSH { - public static Logger log = Logger.getLogger(GanymedSSH.class); - Connection conn; - - public boolean status = true;// 锟角凤拷锟斤拷锟街达拷锟斤拷锟斤拷锟阶刺� - - public GanymedSSH() { - // TODO Auto-generated constructor stub - - } - - public GanymedSSH(String host, String username, String password, int port) { - // TODO Auto-generated constructor stub - try { - conn = getOpenedConnection(host, username, password, port); - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - - } - - - public Connection getOpenedConnection(String host, String username, String password, int port) - throws IOException { - - conn = new Connection(host, port); - conn.connect(); // make sure the connection is opened - boolean isAuthenticated = conn.authenticateWithPassword(username, password); - if (isAuthenticated == false) - throw new IOException("Authentication failed."); - return conn; - } - - public void execCmdNoWaitAcquiescent(String cmd) { - String host=Constant.hostIp; - String username=Constant.rootUser; - String password=Constant.rootPasswd; - int port=Constant.port; - - Session sess = null; - try { - conn = getOpenedConnection(host, username, password, port); - sess = conn.openSession(); - // 执锟斤拷cmd - sess.execCommand(cmd); - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } finally { - sess.close(); - - } - } - - public void execCmdNoWait(String host, String username, String password, int port, String cmd) { - - Session sess = null; - try { - conn = getOpenedConnection(host, username, password, port); - sess = conn.openSession(); - // 执锟斤拷cmd - sess.execCommand(cmd); - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } finally { - sess.close(); - - } - } - - public List execCmdWaitAcquiescent(String cmd) { - String host=Constant.hostIp; - String username=Constant.rootUser; - String password=Constant.rootPasswd; - int port=Constant.port; - List reStrings = new ArrayList(); - - Session sess = null; - try { - - sess = conn.openSession(); - // 执锟斤拷cmd - sess.execCommand(cmd); - - InputStream stdout = new StreamGobbler(sess.getStdout()); - InputStream stderr = new StreamGobbler(sess.getStderr()); - BufferedReader stdoutReader = new BufferedReader(new InputStreamReader(stdout)); - BufferedReader stderrReader = new BufferedReader(new InputStreamReader(stderr)); - while (true) { - String line = stdoutReader.readLine(); - - if (line != null) { -// System.out.println(line); - reStrings.add(line); - } else { - break; - } - } - if(reStrings.size()==0){ - while (true) { - String line = stderrReader.readLine(); - - if (line != null) { -// System.out.println(line); - reStrings.add(line); - } else { - break; - } - } - } - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } finally { - sess.close(); - - } - return reStrings; - } - - public List execCmdWait(String host, String username, String password, int port, String cmd) { - List reStrings = new ArrayList(); - - Session sess = null; - try { - - sess = conn.openSession(); - // 执锟斤拷cmd - sess.execCommand(cmd); - - InputStream stdout = new StreamGobbler(sess.getStdout()); - InputStream stderr = new StreamGobbler(sess.getStderr()); - BufferedReader stdoutReader = new BufferedReader(new InputStreamReader(stdout)); - BufferedReader stderrReader = new BufferedReader(new InputStreamReader(stderr)); - while (true) { - String line = stdoutReader.readLine(); - - if (line != null) { -// System.out.println(line); - reStrings.add(line); - } else { - break; - } - } - if(reStrings.size()==0){ - while (true) { - String line = stderrReader.readLine(); - - if (line != null) { -// System.out.println(line); - reStrings.add(line); - } else { - break; - } - } - } - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } finally { - sess.close(); - - } - return reStrings; - } - - public Map execMD5cmd(String host, String username, String password, int port, String cmd, - String prefix) { - Map md5 = new HashMap(); - - - Session sess = null; - try { - - sess = conn.openSession(); - // 执锟斤拷cmd - sess.execCommand(cmd); - InputStream stdout = new StreamGobbler(sess.getStdout()); - - @SuppressWarnings("resource") - BufferedReader br = new BufferedReader(new InputStreamReader(stdout)); - while (true) { - String line = br.readLine(); - if (line != null) { - String[] lines = line.split(" "); - String key = lines[1].replace(prefix, ""); - String value = lines[0]; - md5.put(key, value); - // System.out.println(key+"\t"+value); - } else { - break; - } - - } - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } finally { - sess.close(); - - } - return md5; - } - - public String execGetSize(String cmd) { - status = false; - String str_size = "0"; - Session sess = null; - try { - - // 执锟斤拷cmd - sess = conn.openSession(); - sess.execCommand(cmd); - InputStream stdout = new StreamGobbler(sess.getStdout()); - - @SuppressWarnings("resource") - BufferedReader br = new BufferedReader(new InputStreamReader(stdout)); - while (true) { - String line = br.readLine(); - if (line != null) { - // String[] lines=line.split(" "); - // str_size=lines[0]; - - str_size = line; - } else { - break; - } - - } - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } finally { - sess.close(); - } - status = true; - return str_size; - } - public static void main(String[] args) { - PropertyConfigurator.configure("log4j.properties"); - } - -} ->>>>>>> 355b6e47a4fa8d058029ec939fe4fefdaa751275 diff --git a/src/com/platform/utils/getTreeDataByPath.java b/src/com/platform/utils/getTreeDataByPath.java index d60cc7f1..368b20a1 100644 --- a/src/com/platform/utils/getTreeDataByPath.java +++ b/src/com/platform/utils/getTreeDataByPath.java @@ -1,3 +1,4 @@ + package com.platform.utils; import java.util.List; @@ -46,3 +47,4 @@ public class getTreeDataByPath { return result; } } +