Compare commits
No commits in common. "Manager_Backend" and "master" have entirely different histories.
Manager_Ba
...
master
|
|
@ -0,0 +1,19 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<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"/>
|
||||
</attributes>
|
||||
</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="lib" path="WebContent/WEB-INF/lib/junit-4.12.jar"/>
|
||||
<classpathentry kind="output" path="build/classes"/>
|
||||
</classpath>
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
/target
|
||||
/build
|
||||
.classpath
|
||||
|
||||
/bin/
|
||||
7
.project
7
.project
|
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>data_manager_backend</name>
|
||||
<name>data-aggregation-platform</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
|
|
@ -25,11 +25,6 @@
|
|||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>com.genuitec.eclipse.ast.deploy.core.DeploymentBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
|
||||
|
|
|
|||
|
|
@ -1,3 +0,0 @@
|
|||
eclipse.preferences.version=1
|
||||
performed.operation.correct.unbound.jre=1.0
|
||||
performed.operation.resolve.unknown.runtime=1.0
|
||||
|
|
@ -1,5 +1,2 @@
|
|||
eclipse.preferences.version=1
|
||||
encoding//WebContent/WEB-INF/config/config.properties=UTF-8
|
||||
encoding//src/com/platform/utils/GanymedSSH.java=UTF-8
|
||||
encoding/<project>=UTF-8
|
||||
separateDerivedEncodings=true
|
||||
|
|
|
|||
|
|
@ -1,101 +1,7 @@
|
|||
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
|
||||
|
|
|
|||
|
|
@ -1,3 +0,0 @@
|
|||
eclipse.preferences.version=1
|
||||
org.eclipse.jpt.core.platform=generic2_1
|
||||
org.eclipse.jpt.jpa.core.discoverAnnotatedClasses=false
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
activeProfiles=
|
||||
eclipse.preferences.version=1
|
||||
resolveWorkspaceProjects=true
|
||||
version=1
|
||||
|
|
@ -1,9 +1,9 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
|
||||
<wb-module deploy-name="data_manager_backend">
|
||||
<wb-module deploy-name="data-aggregation-platform">
|
||||
<wb-resource deploy-path="/" source-path="/WebContent" tag="defaultRootSource"/>
|
||||
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src"/>
|
||||
<wb-resource deploy-path="/WEB-INF/classes" source-path="/test"/>
|
||||
<property name="java-output-path" value="/data_manager_backend/build/classes"/>
|
||||
<property name="java-output-path" value="/data-aggregation-platform/build/classes"/>
|
||||
<property name="context-root" value="/"/>
|
||||
</wb-module>
|
||||
</project-modules>
|
||||
|
|
|
|||
|
|
@ -1,7 +0,0 @@
|
|||
<root>
|
||||
<facet id="jpt.jpa">
|
||||
<node name="libprov">
|
||||
<attribute name="provider-id" value="jpa-no-op-library-provider"/>
|
||||
</node>
|
||||
</facet>
|
||||
</root>
|
||||
|
|
@ -1,11 +1,10 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<faceted-project>
|
||||
<runtime name="MyEclipse Tomcat v7.0"/>
|
||||
<runtime name="Apache Tomcat v7.0"/>
|
||||
<fixed facet="java"/>
|
||||
<fixed facet="wst.jsdt.web"/>
|
||||
<fixed facet="jst.web"/>
|
||||
<installed facet="java" version="1.7"/>
|
||||
<installed facet="jst.web" version="3.0"/>
|
||||
<installed facet="wst.jsdt.web" version="1.0"/>
|
||||
<installed facet="jpt.jpa" version="2.1"/>
|
||||
</faceted-project>
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
#=============================================================================================================
|
||||
# MySQL
|
||||
# MySQL连接配置
|
||||
#=============================================================================================================
|
||||
# 驱动程序
|
||||
jdbc.mysql.driver=com.mysql.jdbc.Driver
|
||||
# 连接url
|
||||
jdbc.mysql.url=jdbc:mysql://192.168.0.101:3306/test?useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true
|
||||
jdbc.mysql.url=jdbc:mysql://127.0.0.1:3306/test?useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true
|
||||
# 用户名
|
||||
jdbc.mysql.username=root
|
||||
# 密码
|
||||
|
|
@ -13,14 +13,15 @@ jdbc.mysql.password=root
|
|||
#=============================================================================================================
|
||||
# Oracle 连接配置
|
||||
#=============================================================================================================
|
||||
# hui用户名
|
||||
gather-user-name=system
|
||||
# 驱动程序
|
||||
jdbc.oracle.driver=oracle.jdbc.driver.OracleDriver
|
||||
# 连接url
|
||||
jdbc.oracle.url=jdbc:oracle:thin:@localhost:1521:orcl;
|
||||
# 用户名
|
||||
jdbc.oracle.username=system
|
||||
# 密码
|
||||
gather-user-password=oracle
|
||||
#
|
||||
gather-port=1521
|
||||
#
|
||||
gather-service-name=orcl
|
||||
jdbc.oracle.password=oracle
|
||||
|
||||
#=============================================================================================================
|
||||
# 数据库公共配置
|
||||
#=============================================================================================================
|
||||
|
|
@ -35,16 +36,4 @@ jdbc.removeAbandonedTimeout=600
|
|||
jdbc.testWhileIdle=true
|
||||
jdbc.timeBetweenEvictionRunsMillis=60000
|
||||
jdbc.numTestsPerEvictionRun=20
|
||||
jdbc.minEvictableIdleTimeMillis=300000
|
||||
#==============================================================================================================
|
||||
#
|
||||
#==============================================================================================================
|
||||
table-suffix=_20152016
|
||||
extract-log-localtion=/home/log/
|
||||
gather-tablespace-name=TS_TTSSS
|
||||
gather-tablespace-path=
|
||||
gather-table-user-password=
|
||||
kubeMasterUrl=http://192.168.0.110:8080/
|
||||
collect-user-name=system
|
||||
collect-password=oracle
|
||||
collect-service-name=orcl
|
||||
jdbc.minEvictableIdleTimeMillis=300000
|
||||
|
|
@ -1,17 +0,0 @@
|
|||
#!/bin/bash
|
||||
function ergodic(){
|
||||
for file in `ls $1`
|
||||
do
|
||||
if [ "$file" != "app" -a -d $1"/"$file ]
|
||||
then
|
||||
ergodic $1"/"$file
|
||||
else
|
||||
local path=$1"/"$file
|
||||
echo $path
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
IFS=$'\n' #这个必须要,否则会在文件名中有空格时出错
|
||||
INIT_PATH=".";
|
||||
ergodic $1
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
<appender name="dailyRollingFile" class="org.apache.log4j.DailyRollingFileAppender">
|
||||
<param name="Threshold" value="info"></param>
|
||||
<param name="ImmediateFlush" value="true"></param>
|
||||
<param name="File" value="logs/dailyRollingFile.log"></param>
|
||||
<param name="File" value="d:/logs/dailyRollingFile.log"></param>
|
||||
<param name="DatePattern" value="'.'yyyy-MM-dd'.log'"></param>
|
||||
<layout class="org.apache.log4j.PatternLayout">
|
||||
<param name="ConversionPattern" value="[%d{yyyy-MM-dd HH:mm:ss\} %-5p] [%t] {%c:%L}-%m%n"></param>
|
||||
|
|
@ -23,7 +23,7 @@
|
|||
|
||||
<!-- 输出日志到文件 文件大小到达指定尺寸的时候产生一个新的文件 -->
|
||||
<appender name="railyFile" class="org.apache.log4j.RollingFileAppender">
|
||||
<param name="File" value="logs/railyFile.log"></param>
|
||||
<param name="File" value="d:/logs/railyFile.log"></param>
|
||||
<param name="ImmediateFlush" value="true" />
|
||||
<param name="Threshold" value="info"></param>
|
||||
<param name="Append" value="true"></param>
|
||||
|
|
|
|||
|
|
@ -7,10 +7,8 @@
|
|||
<typeAlias alias="EncodedInfoEntity" type="com.platform.entities.EncodedInfoEntity" />
|
||||
<typeAlias alias="DataInfoEntity" type="com.platform.entities.DataInfoEntity" />
|
||||
<typeAlias alias="PagerOptions" type="com.platform.entities.PagerOptions"/>
|
||||
<typeAlias alias="GatherOracleInfo" type="com.platform.entities.GatherOracleInfo"/>
|
||||
</typeAliases>
|
||||
<mappers>
|
||||
<mapper resource="com/dao/mapper/data-details-mapper.xml" />
|
||||
<mapper resource="com/dao/mapper/config-details-mapper.xml"/>
|
||||
<mapper resource="com/dao/mapper/data-detaisl-mapper.xml" />
|
||||
</mappers>
|
||||
</configuration>
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -3,7 +3,7 @@
|
|||
xmlns="http://java.sun.com/xml/ns/javaee"
|
||||
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
|
||||
id="WebApp_ID" version="3.0">
|
||||
<display-name>javaBackend</display-name>
|
||||
<display-name>MyFirstTest</display-name>
|
||||
<welcome-file-list>
|
||||
<welcome-file>/index.html</welcome-file>
|
||||
</welcome-file-list>
|
||||
|
|
@ -20,7 +20,7 @@
|
|||
<filter-name>CharacterEncodingFilter</filter-name>
|
||||
<url-pattern>/*</url-pattern>
|
||||
</filter-mapping>
|
||||
<!-- spring配置文件 -->
|
||||
<!-- spring配置文件 -->
|
||||
<context-param>
|
||||
<param-name>contextConfigLocation</param-name>
|
||||
<param-value>WEB-INF/config/spring-applicationContext.xml</param-value>
|
||||
|
|
@ -29,10 +29,6 @@
|
|||
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
|
||||
</listener>
|
||||
|
||||
<listener>
|
||||
<listener-class>com.platform.utils.ConfigsLoader</listener-class>
|
||||
</listener>
|
||||
|
||||
<!-- springmv的配置文件 -->
|
||||
<servlet>
|
||||
<servlet-name>springmvc</servlet-name>
|
||||
|
|
@ -42,24 +38,24 @@
|
|||
<param-value>/WEB-INF/config/springmvc-applicationContext.xml</param-value>
|
||||
</init-param>
|
||||
<load-on-startup>1</load-on-startup>
|
||||
<async-supported>true</async-supported>
|
||||
<async-supported>true</async-supported>
|
||||
</servlet>
|
||||
<servlet-mapping>
|
||||
<servlet-name>springmvc</servlet-name>
|
||||
<url-pattern>/*</url-pattern>
|
||||
</servlet-mapping>
|
||||
|
||||
|
||||
<!-- log4j配置文件 -->
|
||||
<context-param>
|
||||
<param-name>log4jConfigLocation</param-name>
|
||||
<param-value>/WEB-INF/config/log4j-config.xml</param-value>
|
||||
<param-name>log4jConfigLocation</param-name>
|
||||
<param-value>/WEB-INF/config/log4j-config.xml</param-value>
|
||||
</context-param>
|
||||
<listener>
|
||||
<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
|
||||
<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
|
||||
</listener>
|
||||
|
||||
|
||||
<!-- 防止Spring内存溢出监听器 -->
|
||||
<!-- <listener>
|
||||
<listener>
|
||||
<listener-class>org.springframework.web.util.IntrospectorCleanupListener</listener-class>
|
||||
</listener> -->
|
||||
</listener>
|
||||
</web-app>
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Insert title here</title>
|
||||
<script type="text/javascript" src="jquery-1.7.2.min.js"></script>
|
||||
<script type="text/javascript">
|
||||
$(function(){
|
||||
$("#btn").{"name":"伍名"}click(function(){
|
||||
$.post("json",function(data){
|
||||
alert(data);
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<form action="hello" method="post">
|
||||
name:<input type="text" name="name">
|
||||
<input type="submit" value="submit">
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -36,43 +36,35 @@ PUBLIC "-//ibatis.apache.org//DTD Mapper 3.0//EN"
|
|||
jdbcType="VARCHAR" />
|
||||
</resultMap>
|
||||
<sql id="conditionsFilters">
|
||||
<if test="PagerOptions.dataType!=null">
|
||||
and data_details.data_type=#{PagerOptions.dataType}
|
||||
</if>
|
||||
<if test="PagerOptions.submittedBatch!=null">
|
||||
and
|
||||
data_details.submitted_batch=#{PagerOptions.submittedBatch}
|
||||
</if>
|
||||
<if test="PagerOptions.cityName!=null">
|
||||
and data_details.city_name=#{PagerOptions.cityName}
|
||||
</if>
|
||||
<if test="PagerOptions.districtName!=null">
|
||||
and
|
||||
data_details.district_name=#{PagerOptions.districtName}
|
||||
</if>
|
||||
<if test="PagerOptions.dataVersion !=null">
|
||||
and data_details.data_version=#{PagerOptions.dataVersion}
|
||||
</if>
|
||||
<if test="PagerOptions.systemName !=null">
|
||||
and data_details=#{PagerOptions.systemName}
|
||||
</if>
|
||||
<if test="PagerOptions.dataYear !=null">
|
||||
and data_details.data_year=#{PagerOptions.dataYear}
|
||||
</if>
|
||||
</sql>
|
||||
|
||||
<!-- 获取数据符合筛选条件的全部记录信息 -->
|
||||
<select id="getLimitedDataInfoEntities" parameterType="PagerOptions"
|
||||
resultMap="getEntityByText">
|
||||
SELECT
|
||||
id,regionalism_code,city_name,district_name,system_code,system_name,data_type,data_version,submitted_batch,data_path,data_charset,collection_time,collector_name,collector_contacts,data_year
|
||||
FROM data_details
|
||||
<if test="PagerOptions!=null">
|
||||
<where>
|
||||
<include refid="conditionsFilters" />
|
||||
<if test="PagerOptions.dataType!=null">
|
||||
and data_details.data_type=#{PagerOptions.dataType}
|
||||
</if>
|
||||
<if test="PagerOptions.submittedBatch!=null">
|
||||
and
|
||||
data_details.submitted_batch=#{PagerOptions.submittedBatch}
|
||||
</if>
|
||||
<if test="PagerOptions.cityName!=null">
|
||||
and data_details.city_name=#{PagerOptions.cityName}
|
||||
</if>
|
||||
<if test="PagerOptions.districtName!=null">
|
||||
and
|
||||
data_details.district_name=#{PagerOptions.districtName}
|
||||
</if>
|
||||
<if test="PagerOptions.dataVersion">
|
||||
and
|
||||
data_details.data_version=#{PagerOptions.dataVersion}
|
||||
</if>
|
||||
<if test="PagerOptions.systemName">
|
||||
and data_details=#{PagerOptions.systemName}
|
||||
</if>
|
||||
<if test="PagerOptions.dataYear">
|
||||
and data_details.data_year=#{PagerOptions.dataYear}
|
||||
</if>
|
||||
<choose>
|
||||
<when test="PagerOptions.offset > 0">
|
||||
and data_details.id>= #{PagerOptions.offset}
|
||||
<when test="PagerOptions.idIndex>0">
|
||||
and data_details.id>=#{idIndex}
|
||||
</when>
|
||||
<otherwise>
|
||||
and data_details.id>=0
|
||||
|
|
@ -80,29 +72,22 @@ PUBLIC "-//ibatis.apache.org//DTD Mapper 3.0//EN"
|
|||
</choose>
|
||||
</where>
|
||||
ORDER BY data_details.id
|
||||
<if test="PagerOptions.limit > 0">
|
||||
LIMIT #{PagerOptions.limit}
|
||||
</if>
|
||||
<if test="PagerOptions.limit">LIMIT #{PagerOptions.limit}</if>
|
||||
</if>
|
||||
</sql>
|
||||
|
||||
<select id="getLimitedDataInfoEntities" parameterType="PagerOptions"
|
||||
resultMap="getEntityByText">
|
||||
SELECT
|
||||
id,regionalism_code,city_name,district_name,system_code,system_name,data_type,data_version,submitted_batch,data_path,data_charset,collection_time,collector_name,collector_contacts,data_year
|
||||
FROM data_details
|
||||
<include refid="conditionsFilters" />
|
||||
</select>
|
||||
|
||||
<!-- 获取数据符合筛选条件的总记录条数 -->
|
||||
<select id="getLimitedDataCount" resultType="java.lang.Integer"
|
||||
parameterType="PagerOptions">
|
||||
SELECT COUNT(id) FROM data_details
|
||||
<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 data_details
|
||||
ORDER BY id LIMIT 0,#{PagerOptions.totalLimit}) AS TEMP
|
||||
<include refid="conditionsFilters" />
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -0,0 +1,64 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
|
||||
xmlns:tx="http://www.springframework.org/schema/tx" xmlns:aop="http://www.springframework.org/schema/aop"
|
||||
xmlns:context="http://www.springframework.org/schema/context"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
|
||||
http://www.springframework.org/schema/tx
|
||||
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
|
||||
http://www.springframework.org/schema/aop
|
||||
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
|
||||
http://www.springframework.org/schema/context
|
||||
http://www.springframework.org/schema/context/spring-context-3.0.xsd">
|
||||
<!-- 读取db.properties中的属性值 -->
|
||||
<bean
|
||||
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
|
||||
<property name="location" value="/WebContent/WEB-INF/config/config.properties"></property>
|
||||
</bean>
|
||||
|
||||
<!-- 连接MySQL数据库 -->
|
||||
<bean id="mySQLDataSource"
|
||||
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
|
||||
<property name="driverClassName" value="${jdbc.mysql.driver}" />
|
||||
<property name="url" value="${jdbc.mysql.url}" />
|
||||
<property name="username" value="${jdbc.mysql.username}" />
|
||||
<property name="password" value="${jdbc.mysql.password}" />
|
||||
</bean>
|
||||
<bean id="mySQLSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
|
||||
<property name="configLocation" value="/WebContent/WEB-INF/config/mybatis-applicationConfig.xml" />
|
||||
<property name="dataSource" ref="mySQLDataSource" />
|
||||
</bean>
|
||||
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
|
||||
<property name="basePackage" value="com.platform.dao" />
|
||||
</bean>
|
||||
|
||||
<!-- 配置声明式事物 -->
|
||||
<bean id="mySQLTxManager"
|
||||
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
|
||||
<property name="dataSource" ref="mySQLDataSource" />
|
||||
</bean>
|
||||
<tx:advice id="txAdvice" transaction-manager="mySQLTxManager">
|
||||
<tx:attributes>
|
||||
<tx:method name="delete*" propagation="REQUIRED" />
|
||||
<tx:method name="insert*" propagation="REQUIRED" />
|
||||
<tx:method name="update*" propagation="REQUIRED" />
|
||||
<tx:method name="get*" read-only="true" />
|
||||
<tx:method name="select*" read-only="true" />
|
||||
</tx:attributes>
|
||||
</tx:advice>
|
||||
<aop:config>
|
||||
<aop:pointcut expression="execution(* com.platform.service.*.*(..))"
|
||||
id="pointcut" />
|
||||
<aop:advisor advice-ref="txAdvice" pointcut-ref="pointcut" />
|
||||
</aop:config>
|
||||
<bean id="user" class="com.platform.test.User">
|
||||
<property name="name" value="伍名" />
|
||||
<property name="id" value="1" />
|
||||
<property name="sex" value="男" />
|
||||
</bean>
|
||||
<context:component-scan base-package="com.platform.*">
|
||||
<context:exclude-filter type="annotation"
|
||||
expression="org.springframework.stereotype.Controller" />
|
||||
</context:component-scan>
|
||||
</beans>
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
|
||||
<persistence-unit name="aggregation-platform">
|
||||
</persistence-unit>
|
||||
</persistence>
|
||||
|
|
@ -1,65 +0,0 @@
|
|||
|
||||
/**
|
||||
* 文件名 : 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<String, String> 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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
package com.base;
|
||||
|
||||
/**
|
||||
* <一句话功能简述>
|
||||
* <功能详细描述>
|
||||
* @author chen
|
||||
* @version [版本号,2016年9月8日]
|
||||
* @see [相关类/方法]
|
||||
* @since [产品/模块版本]
|
||||
*/
|
||||
public class Constant {
|
||||
|
||||
/** 国际话配置文件文件-i18n.properties */
|
||||
public static String I18N_PROPERTIES_FIEL_PATH = "/com/base/i18n.properties";
|
||||
|
||||
/** WritefileThread-线程睡眠时间--3000 */
|
||||
public final static long THREAD_SLEEP_WRITEFILETHREAD = 3000;
|
||||
|
||||
/** CustomException记录报异常的对象的对象个数--10 */
|
||||
public final static int CustomException_log_object_size = 10;
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -1,20 +0,0 @@
|
|||
package com.base;
|
||||
|
||||
/**
|
||||
* <一句话功能简述> 异常常量编码
|
||||
* <功能详细描述>
|
||||
* @author chen
|
||||
* @version [版本号,2016年9月8日]
|
||||
* @see [相关类/方法]
|
||||
* @since [产品/模块版本]
|
||||
*/
|
||||
public class Custom4exception {
|
||||
//3003001001 : 第一位:标识异常, 第二到第四位:标识模块,第五道第七位:标识类别,第八道第十位标识具体异常
|
||||
/**eg
|
||||
* 3:异常
|
||||
* 003:虚拟机模块
|
||||
* 001:软件依赖虚拟机资源类别
|
||||
* 001:启动异常
|
||||
*/
|
||||
|
||||
}
|
||||
|
|
@ -1,127 +0,0 @@
|
|||
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1,79 +0,0 @@
|
|||
package com.base;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
|
||||
import com.base.Constant;
|
||||
|
||||
public class Resource {
|
||||
|
||||
private static Map<String, String> properties = new HashMap<>();
|
||||
|
||||
static{
|
||||
// 读取 properties文件
|
||||
// readPropertiesFile(Constant.SYSTEM_PROPERTIES_FIEL_PATH);
|
||||
readPropertiesFile4Chinese(Constant.I18N_PROPERTIES_FIEL_PATH);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @功能 读取配置(解决中文乱码)
|
||||
* @param filename "/com/utils/exception/i18n.properties" 的格式
|
||||
*/
|
||||
public static void readPropertiesFile4Chinese(String filename) {
|
||||
Properties pro = new Properties();
|
||||
try {
|
||||
// 读取属性文件 XXXX.properties(Reader。writer解决中文乱码)
|
||||
// InputStreamReader in= new InputStreamReader(Resource.class.getClassLoader().getResourceAsStream(filename), "UTF-8");
|
||||
InputStreamReader in= new InputStreamReader(Resource.class.getResourceAsStream(filename), "UTF-8");
|
||||
BufferedReader bf = new BufferedReader(in);
|
||||
// InputStreamReader in = new BufferedInputStream(new FileInputStream(filename));
|
||||
pro.load(bf); // /加载属性列表
|
||||
Iterator<String> it = pro.stringPropertyNames().iterator();
|
||||
while (it.hasNext()) {
|
||||
String key = it.next();
|
||||
properties.put(key, pro.getProperty(key));
|
||||
}
|
||||
in.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @功能 获得properties
|
||||
* @return properties
|
||||
*/
|
||||
public static Map<String, String> getProperties() {
|
||||
return properties;
|
||||
}
|
||||
|
||||
/**
|
||||
* @功能 读取配置
|
||||
* @param filename 文件绝对路径
|
||||
*/
|
||||
public static void readPropertiesFile(String filename) {
|
||||
Properties pro = new Properties();
|
||||
try {
|
||||
// 读取属性文件 XXXX.properties( 中文会 乱码)
|
||||
BufferedInputStream bf = new BufferedInputStream(new FileInputStream(filename));
|
||||
pro.load(bf); // /加载属性列表
|
||||
Iterator<String> it = pro.stringPropertyNames().iterator();
|
||||
while (it.hasNext()) {
|
||||
String key = it.next();
|
||||
properties.put(key, pro.getProperty(key));
|
||||
}
|
||||
bf.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,146 +0,0 @@
|
|||
<?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.GatherOracleDao">
|
||||
<resultMap type="com.platform.entities.GatherOracleInfo" id="getEntityBytext">
|
||||
<id property="id" column="id" javaType="int" jdbcType="INTEGER" />
|
||||
<result property="port" column="service_port" javaType="int" jdbcType="INTEGER"/>
|
||||
<result property="ip" column="service_ip" javaType="string" jdbcType="VARCHAR"/>
|
||||
<result property="name" column="service_name" javaType="string" jdbcType="VARCHAR"/>
|
||||
<result property="user" column="service_user" javaType="string" jdbcType="VARCHAR"/>
|
||||
<result property="password" column="service_password" javaType="string" jdbcType="VARCHAR"/>
|
||||
<result property="databaseName" column="service_database" javaType="string" jdbcType="VARCHAR"/>
|
||||
<result property="tableName" column="service_table" javaType="string" jdbcType="VARCHAR"/>
|
||||
<result property="suffix" column="service_suffix" javaType="string" jdbcType="VARCHAR"/>
|
||||
<result property="status" column="service_status" javaType="string" jdbcType="VARCHAR"/>
|
||||
<result property="remove" column="remove" jdbcType="CHAR"/>
|
||||
</resultMap>
|
||||
<sql id="baseOracleInfo">
|
||||
id id, service_port port, service_ip ip, service_name name, service_user user, service_password password, service_database databaseName, service_table tableName, service_suffix suffix, service_status status
|
||||
</sql>
|
||||
|
||||
<select id="selectAllOracle" resultType="com.platform.entities.GatherOracleInfo">
|
||||
SELECT
|
||||
<include refid="baseOracleInfo" />
|
||||
FROM services_info
|
||||
WHERE remove = "0"
|
||||
</select>
|
||||
|
||||
<insert id="insertOracle" parameterType="com.platform.entities.GatherOracleInfo">
|
||||
INSERT INTO
|
||||
services_info(
|
||||
<trim suffixOverrides=",">
|
||||
<if test="port > 0">
|
||||
service_port,
|
||||
</if>
|
||||
<if test="ip != null and ip != ''">
|
||||
service_ip,
|
||||
</if>
|
||||
<if test="name != null and name != ''">
|
||||
service_name,
|
||||
</if>
|
||||
<if test="user != null and user != ''">
|
||||
service_user,
|
||||
</if>
|
||||
<if test="password != null and password != ''">
|
||||
service_password,
|
||||
</if>
|
||||
<if test="databaseName != null and databaseName != ''">
|
||||
service_database,
|
||||
</if>
|
||||
<if test="tableName != null and tableName != ''">
|
||||
service_table,
|
||||
</if>
|
||||
<if test="suffix != null and suffix != ''">
|
||||
service_suffix,
|
||||
</if>
|
||||
<if test="status != null and status != ''">
|
||||
service_status,
|
||||
</if>
|
||||
</trim>
|
||||
)
|
||||
VALUES(
|
||||
<trim suffixOverrides=",">
|
||||
<if test="port > 0">
|
||||
#{port},
|
||||
</if>
|
||||
<if test="ip != null and ip != ''">
|
||||
#{ip},
|
||||
</if>
|
||||
<if test="name != null and name != ''">
|
||||
#{name},
|
||||
</if>
|
||||
<if test="user != null and user != ''">
|
||||
#{user},
|
||||
</if>
|
||||
<if test="password != null and password != ''">
|
||||
#{password},
|
||||
</if>
|
||||
<if test="databaseName != null and databaseName != ''">
|
||||
#{databaseName},
|
||||
</if>
|
||||
<if test="tableName != null and tableName != ''">
|
||||
#{tableName},
|
||||
</if>
|
||||
<if test="suffix != null and suffix != ''">
|
||||
#{suffix},
|
||||
</if>
|
||||
<if test="status != null and status != ''">
|
||||
#{status},
|
||||
</if>
|
||||
</trim>
|
||||
)
|
||||
</insert>
|
||||
|
||||
<delete id="deleteOracleById" parameterType="java.lang.Integer">
|
||||
DELETE FROM services_info
|
||||
<where>
|
||||
id =#{id}
|
||||
</where>
|
||||
</delete>
|
||||
|
||||
<update id="updateOracleById" parameterType="com.platform.entities.GatherOracleInfo">
|
||||
UPDATE
|
||||
services_info
|
||||
<set >
|
||||
<trim suffixOverrides=",">
|
||||
<if test="name != null and name != ''">
|
||||
service_name = #{name},
|
||||
</if>
|
||||
<if test="ip != null and ip != ''">
|
||||
service_ip = #{ip},
|
||||
</if>
|
||||
<if test="port > 0">
|
||||
service_port= #{port},
|
||||
</if>
|
||||
<if test="user != null and user != ''">
|
||||
service_user= #{user},
|
||||
</if>
|
||||
<if test="password != null and password != ''">
|
||||
service_password= #{password},
|
||||
</if>
|
||||
<if test="databaseName != null and databaseName != ''">
|
||||
service_database= #{databaseName},
|
||||
</if>
|
||||
<if test="tableName != null and tableName != ''">
|
||||
service_table= #{tableName},
|
||||
</if>
|
||||
<if test="suffix != null and suffix != ''">
|
||||
service_suffix= #{suffix},
|
||||
</if>
|
||||
<if test="status != null and status != ''">
|
||||
service_status= #{status},
|
||||
</if>
|
||||
<if test="remove != null and remove != ''">
|
||||
remove= #{remove},
|
||||
</if>
|
||||
</trim>
|
||||
</set>
|
||||
<where>
|
||||
id = #{id}
|
||||
</where>
|
||||
</update>
|
||||
|
||||
</mapper>
|
||||
|
|
@ -36,44 +36,35 @@ PUBLIC "-//ibatis.apache.org//DTD Mapper 3.0//EN"
|
|||
jdbcType="VARCHAR" />
|
||||
</resultMap>
|
||||
<sql id="conditionsFilters">
|
||||
<if test="PagerOptions.dataType!=null">
|
||||
and data_details.data_type=#{PagerOptions.dataType}
|
||||
</if>
|
||||
<if test="PagerOptions.submittedBatch!=null">
|
||||
and
|
||||
data_details.submitted_batch=#{PagerOptions.submittedBatch}
|
||||
</if>
|
||||
<if test="PagerOptions.cityName!=null">
|
||||
and data_details.city_name=#{PagerOptions.cityName}
|
||||
</if>
|
||||
<if test="PagerOptions.districtName!=null">
|
||||
and
|
||||
data_details.district_name=#{PagerOptions.districtName}
|
||||
</if>
|
||||
<if test="PagerOptions.dataVersion !=null">
|
||||
and data_details.data_version=#{PagerOptions.dataVersion}
|
||||
</if>
|
||||
<if test="PagerOptions.systemName !=null">
|
||||
and data_details=#{PagerOptions.systemName}
|
||||
</if>
|
||||
<if test="PagerOptions.dataYear !=null">
|
||||
and data_details.data_year=#{PagerOptions.dataYear}
|
||||
</if>
|
||||
</sql>
|
||||
|
||||
<!-- 获取数据符合筛选条件的全部记录信息 -->
|
||||
<select id="3
|
||||
" parameterType="PagerOptions"
|
||||
resultMap="getEntityByText">
|
||||
SELECT
|
||||
id,regionalism_code,city_name,district_name,system_code,system_name,data_type,data_version,submitted_batch,data_path,data_charset,collection_time,collector_name,collector_contacts,data_year
|
||||
FROM data_details
|
||||
<if test="PagerOptions!=null">
|
||||
<where>
|
||||
<include refid="conditionsFilters" />
|
||||
<if test="PagerOptions.dataType!=null">
|
||||
and data_details.data_type=#{PagerOptions.dataType}
|
||||
</if>
|
||||
<if test="PagerOptions.submittedBatch!=null">
|
||||
and
|
||||
data_details.submitted_batch=#{PagerOptions.submittedBatch}
|
||||
</if>
|
||||
<if test="PagerOptions.cityName!=null">
|
||||
and data_details.city_name=#{PagerOptions.cityName}
|
||||
</if>
|
||||
<if test="PagerOptions.districtName!=null">
|
||||
and
|
||||
data_details.district_name=#{PagerOptions.districtName}
|
||||
</if>
|
||||
<if test="PagerOptions.dataVersion">
|
||||
and
|
||||
data_details.data_version=#{PagerOptions.dataVersion}
|
||||
</if>
|
||||
<if test="PagerOptions.systemName">
|
||||
and data_details=#{PagerOptions.systemName}
|
||||
</if>
|
||||
<if test="PagerOptions.dataYear">
|
||||
and data_details.data_year=#{PagerOptions.dataYear}
|
||||
</if>
|
||||
<choose>
|
||||
<when test="PagerOptions.offset > 0">
|
||||
and data_details.id>= #{PagerOptions.offset}
|
||||
<when test="PagerOptions.idIndex>0">
|
||||
and data_details.id>=#{idIndex}
|
||||
</when>
|
||||
<otherwise>
|
||||
and data_details.id>=0
|
||||
|
|
@ -81,29 +72,22 @@ PUBLIC "-//ibatis.apache.org//DTD Mapper 3.0//EN"
|
|||
</choose>
|
||||
</where>
|
||||
ORDER BY data_details.id
|
||||
<if test="PagerOptions.limit > 0">
|
||||
LIMIT #{PagerOptions.limit}
|
||||
</if>
|
||||
<if test="PagerOptions.limit">LIMIT #{PagerOptions.limit}</if>
|
||||
</if>
|
||||
</sql>
|
||||
|
||||
<select id="getLimitedDataInfoEntities" parameterType="PagerOptions"
|
||||
resultMap="getEntityByText">
|
||||
SELECT
|
||||
id,regionalism_code,city_name,district_name,system_code,system_name,data_type,data_version,submitted_batch,data_path,data_charset,collection_time,collector_name,collector_contacts,data_year
|
||||
FROM data_details
|
||||
<include refid="conditionsFilters" />
|
||||
</select>
|
||||
|
||||
<!-- 获取数据符合筛选条件的总记录条数 -->
|
||||
<select id="getLimitedDataCount" resultType="java.lang.Integer"
|
||||
parameterType="PagerOptions">
|
||||
SELECT COUNT(id) FROM data_details
|
||||
<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 data_details
|
||||
ORDER BY id LIMIT 0,#{PagerOptions.totalLimit}) AS TEMP
|
||||
<include refid="conditionsFilters" />
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
|
@ -1,151 +0,0 @@
|
|||
<?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>
|
||||
|
|
@ -1,11 +1,5 @@
|
|||
|
||||
|
||||
package com.platform.controller;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
|
|
@ -13,50 +7,19 @@ import javax.annotation.Resource;
|
|||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import net.sf.json.JSONArray;
|
||||
import net.sf.json.JSONObject;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import com.base.BaseController;
|
||||
import com.platform.entities.DataInfoEntity;
|
||||
import com.platform.entities.FolderNode;
|
||||
import com.platform.entities.GatherOracleInfo;
|
||||
import com.platform.entities.OracleConnectorParams;
|
||||
import com.platform.entities.PagerOptions;
|
||||
import com.platform.entities.VolumeEntity;
|
||||
import com.platform.service.DataInfoService;
|
||||
import com.platform.service.IGfsService;
|
||||
import com.platform.service.IMySqlService;
|
||||
import com.platform.service.IOracleExtractService;
|
||||
import com.platform.service.OracleExtractHelper;
|
||||
import com.platform.service.OracleStatusService;
|
||||
import com.platform.service.impl.MySqlServiceImpl;
|
||||
import com.platform.test.Brick;
|
||||
import com.platform.test.FolderReader;
|
||||
import com.platform.test.Volume;
|
||||
import com.platform.utils.Configs;
|
||||
import com.platform.utils.UtilsHelper;
|
||||
|
||||
@Controller
|
||||
public class DataModelController extends BaseController{
|
||||
public class DataModelController {
|
||||
@Resource(name = "dataInfoService")
|
||||
private DataInfoService dfs;
|
||||
|
||||
@Resource(name = "gfsService")
|
||||
private IGfsService gfsService;
|
||||
|
||||
@Resource(name = "mySqlService")
|
||||
private IMySqlService mySqlService;
|
||||
|
||||
@Resource(name = "OracleExtract")
|
||||
private IOracleExtractService OracleExtract;
|
||||
|
||||
public void setDfsImp(DataInfoService dfs) {
|
||||
this.dfs = dfs;
|
||||
|
|
@ -64,168 +27,12 @@ public class DataModelController extends BaseController{
|
|||
|
||||
@RequestMapping("/data.json")
|
||||
@ResponseBody
|
||||
public ModelMap getAllDataToJson(HttpServletRequest res,
|
||||
HttpServletResponse req) {
|
||||
public ModelMap getAllDataToJson(HttpServletRequest res, HttpServletResponse req) {
|
||||
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><EFBFBD>ǰ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:{");
|
||||
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(",");
|
||||
}
|
||||
Set<String> keySet= paramMap.keySet();
|
||||
for(String str: keySet){
|
||||
System.out.println(str+":"+paramMap.get(str));
|
||||
}
|
||||
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<String, String[]> paramMap = res.getParameterMap();
|
||||
String[] data = paramMap.get("data");
|
||||
dfs.deleteData(data);
|
||||
}
|
||||
|
||||
@RequestMapping("/connectOracle")
|
||||
public void connectOracle(HttpServletRequest res, HttpServletResponse req) {
|
||||
Map<String, String[]> 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<String, String[]> 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("/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();
|
||||
//汇总库 对象信息--带有tableName-
|
||||
String[] nodes = paramMap.get("target");
|
||||
Map map = null;
|
||||
for (String string : nodes) {
|
||||
JSONObject jsonobject = JSONObject.fromObject(string);
|
||||
map = jsonobject;
|
||||
System.out.println(map);
|
||||
}
|
||||
|
||||
// 采集库对象--(多个采集库抽取到1个汇总库的1个tableName下)
|
||||
String[] inneed = paramMap.get("inneed");
|
||||
List<Map<String, String>> colleclist = new ArrayList<Map<String,String>>();
|
||||
for (String string : nodes) {
|
||||
JSONObject jsonobject = JSONObject.fromObject(string);
|
||||
Map inneedMap = jsonobject;
|
||||
colleclist.add(inneedMap);
|
||||
}
|
||||
OracleExtract.extractOracle(name, colleclist, map);
|
||||
|
||||
}
|
||||
|
||||
@RequestMapping("/volume/list")
|
||||
@ResponseBody
|
||||
public List<VolumeEntity> getFolder(HttpServletRequest res, HttpServletResponse req) throws Exception {
|
||||
System.out.println("get Request");
|
||||
// Brick brick1 = new Brick("192.168.0.101", "D:/bootstrap");
|
||||
// Brick brick2 = new Brick("192.168.0.103", "D:\book");
|
||||
// List<Brick> bricks = new ArrayList<Brick>();
|
||||
// bricks.add(brick1);
|
||||
// bricks.add(brick2);
|
||||
List<VolumeEntity> result = gfsService.getAllVolumes();
|
||||
return result;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/volume/{name}/move", method= RequestMethod.POST)
|
||||
@ResponseBody
|
||||
public Object move(HttpServletRequest res, HttpServletResponse req, String name,
|
||||
FolderNode selectNode, DataInfoEntity selectItems) throws Exception {
|
||||
System.out.println("get Request");
|
||||
Map<String, String[]> paramMap = res.getParameterMap();
|
||||
// System.out.println(paramMap);
|
||||
String[] nodes = paramMap.get("selectNode");
|
||||
Map map = null;
|
||||
for (String string : nodes) {
|
||||
System.out.println(string);
|
||||
JSONObject jsonobject = JSONObject.fromObject(string);
|
||||
map = jsonobject;
|
||||
}
|
||||
List<String> listItemPath = new ArrayList<String>();
|
||||
String[] items = paramMap.get("selectItems");
|
||||
System.out.println("selectItems");
|
||||
for (String string : items) {
|
||||
System.out.println(string);
|
||||
JSONObject jsobj = JSONObject.fromObject(string);
|
||||
Map itemmap = jsobj;
|
||||
listItemPath.add((String)itemmap.get("dataPath"));
|
||||
}
|
||||
|
||||
System.out.println(name);
|
||||
System.out.println(nodes);
|
||||
System.out.println(selectItems);
|
||||
System.out.println("--------------");
|
||||
int result = gfsService.copyFolder(listItemPath, (String)map.get("path"), "app");
|
||||
return result;
|
||||
}
|
||||
|
||||
@RequestMapping("/oracle/list")
|
||||
@ResponseBody
|
||||
public List<GatherOracleInfo> getOracleInfo(HttpServletRequest res,
|
||||
HttpServletResponse req) throws Exception {
|
||||
|
||||
List<GatherOracleInfo> result = mySqlService.findAllMySql();
|
||||
System.out.println("----------getOracleInfo-----------------------");
|
||||
return result;
|
||||
}
|
||||
|
||||
@RequestMapping("/oracle/{id}/delete")
|
||||
@ResponseBody
|
||||
public void deleteOracleInfo(HttpServletRequest res,
|
||||
HttpServletResponse req, int id) throws Exception {
|
||||
|
||||
mySqlService.deleteMySql(id);
|
||||
System.out.println("----------deleteOracleInfo-----------------------");
|
||||
}
|
||||
|
||||
@RequestMapping("/oracle/{id}/insert")
|
||||
@ResponseBody
|
||||
public void insertOracleInfo(HttpServletRequest res,
|
||||
HttpServletResponse req, GatherOracleInfo oracle) throws Exception {
|
||||
|
||||
mySqlService.insertOracle(oracle);
|
||||
System.out.println("----------insertOracleInfo-----------------------");
|
||||
}
|
||||
|
||||
@RequestMapping("/oracle/{id}/update")
|
||||
@ResponseBody
|
||||
public void updateOracleInfo(HttpServletRequest res,
|
||||
HttpServletResponse req, GatherOracleInfo oracle) throws Exception {
|
||||
|
||||
mySqlService.updateOracle(oracle);
|
||||
System.out.println("----------updateOracleInfo-----------------------");
|
||||
return dfs.getPagerTableData((PagerOptions) UtilsHelper.newObjAndSetAttrsByClass(PagerOptions.class, res));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,32 +1,18 @@
|
|||
|
||||
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");
|
||||
//处理不匹配的请求
|
||||
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();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,113 +0,0 @@
|
|||
|
||||
package com.platform.controller;
|
||||
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import oracle.sql.DATE;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
|
||||
|
||||
|
||||
import com.base.BaseController;
|
||||
import com.base.CustomException;
|
||||
import com.platform.entities.GfsFolderEntity;
|
||||
|
||||
|
||||
import com.platform.entities.VolumeEntity;
|
||||
import com.platform.glusterfs.VolumeInfo;
|
||||
|
||||
import com.platform.entities.VolumeEntity;
|
||||
import com.platform.glusterfs.VolumeInfo;
|
||||
|
||||
import com.platform.service.IGfsService;
|
||||
|
||||
|
||||
/**
|
||||
* <一句话功能简述>
|
||||
* <功能详细描述>
|
||||
* @author chen
|
||||
* @version [版本号,2016年9月8日]
|
||||
* @see [相关类/方法]
|
||||
* @since [产品/模块版本]
|
||||
*/
|
||||
@Controller
|
||||
|
||||
@RequestMapping("")
|
||||
|
||||
public class FolderController extends BaseController {
|
||||
|
||||
@Resource(name = "gfsService")
|
||||
private IGfsService gfsService;
|
||||
|
||||
|
||||
|
||||
|
||||
@RequestMapping(value="/getAllSubPathByPath", method= RequestMethod.POST)
|
||||
|
||||
public Object getAllSubPathByPath(String path) throws Exception {
|
||||
System.out.println(path);
|
||||
Object result = null;
|
||||
if (null != path && !"".equals(path)) {
|
||||
System.out.println(path);
|
||||
result = gfsService.getFolder(path);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@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
|
||||
int result = gfsService.copyFolder(srcpath, dstPath, name);
|
||||
System.out.println(srcpath);
|
||||
System.out.println(dstPath);
|
||||
String obj = "right";
|
||||
|
||||
if (1 != result) {
|
||||
obj = "err";
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
|
||||
// /**
|
||||
// * <一句话功能简述> 查询集群中所有的 volume 及其 信息
|
||||
// * <功能详细描述>
|
||||
// * @return
|
||||
// * @throws Exception
|
||||
// * @see [类、类#方法、类#成员]
|
||||
// */
|
||||
// @RequestMapping(value="/volume/list", method= RequestMethod.POST)
|
||||
// public Object getVolums() throws Exception{
|
||||
// System.out.println("----------------------------------");
|
||||
// long a = new Date().getTime();
|
||||
// List<VolumeEntity> result = gfsService.getAllVolumes();
|
||||
// System.out.println("----------------------------------");
|
||||
// System.out.println(new Date().getTime()-a);
|
||||
// return result;
|
||||
// }
|
||||
//
|
||||
/**
|
||||
* <一句话功能简述> 查询集群中所有的 volume 及其 信息
|
||||
* <功能详细描述>
|
||||
* @param volumeName "/home/gfs_ftp_point" "/home/v1_point"
|
||||
* @return
|
||||
* @throws Exception
|
||||
* @see [类、类#方法、类#成员]
|
||||
*/
|
||||
|
||||
@RequestMapping(value="/volume/findByName", method= RequestMethod.POST)
|
||||
public Object getVolumByName(String volumeName) throws Exception{
|
||||
VolumeEntity result = gfsService.getOneVolume(volumeName);
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,52 +0,0 @@
|
|||
|
||||
/**
|
||||
* 文件名 : SetGlusterfs.java
|
||||
* 版权 : <版权/公司名>
|
||||
* 描述 : <描述>
|
||||
* @author liliy
|
||||
* 版本 : <版本>
|
||||
* 修改时间: 2016年9月8日
|
||||
* 修改内容: <修改内容>
|
||||
*/
|
||||
package com.platform.controller;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
||||
/**
|
||||
|
||||
* <一句话功能简述>
|
||||
|
||||
|
||||
* <一句话功能简述>
|
||||
|
||||
* <功能详细描述>
|
||||
* @author liliy
|
||||
* @version [版本号,2016年9月8日]
|
||||
* @see [相关类/方法]
|
||||
* @since [产品/模块版本]
|
||||
*/
|
||||
@Controller
|
||||
public class SetGlusterfsController {
|
||||
|
||||
@RequestMapping("/tes")
|
||||
public Object defaultHandler(HttpServletRequest req, HttpServletResponse request) {
|
||||
//<EFBFBD><EFBFBD><EFBFBD>?ƥ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
try {
|
||||
|
||||
System.out.println("fsdfds");
|
||||
|
||||
return "listAll";
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
||||
return "result";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,50 +0,0 @@
|
|||
|
||||
/**
|
||||
* 文件名 : ShowGlusterfsController.java
|
||||
* 版权 : <版权/公司名>
|
||||
* 描述 : <描述>
|
||||
* @author liliy
|
||||
* 版本 : <版本>
|
||||
* 修改时间: 2016年9月8日
|
||||
* 修改内容: <修改内容>
|
||||
*/
|
||||
package com.platform.controller;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
||||
import com.platform.glusterfs.ClusterInfo;
|
||||
import com.platform.glusterfs.VolumeInfo;
|
||||
|
||||
/**
|
||||
* <一句话功能简述>
|
||||
|
||||
* <功能详细描述>
|
||||
* @author liliy
|
||||
* @version [版本号,2016年9月8日]
|
||||
* @see [相关类/方法]
|
||||
* @since [产品/模块版本]
|
||||
*/
|
||||
@Controller
|
||||
public class ShowGlusterfsController {
|
||||
|
||||
|
||||
/**
|
||||
* <一句话功能简述>
|
||||
|
||||
* <功能详细描述>
|
||||
* @return
|
||||
* @see [类、类#方法、类#成员]
|
||||
*/
|
||||
@RequestMapping("/showPeerStatus")
|
||||
public Map<String,String> showPeerStatus(){
|
||||
Map<String, String> peer_status=new ClusterInfo().showClusterInfo();
|
||||
return peer_status;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -2,19 +2,30 @@ package com.platform.dao;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.ibatis.annotations.Insert;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.platform.entities.DataInfoEntity;
|
||||
import com.platform.entities.PagerOptions;
|
||||
|
||||
@Repository(value = "dataInfoDao")
|
||||
public interface DataInfoDao {
|
||||
|
||||
int getLimitedDataCount(@Param("PagerOptions")PagerOptions pagerOptions);
|
||||
public List<DataInfoEntity> getLimitedDataInfoEntities(
|
||||
@Param(value = "PagerOptions") PagerOptions pagerOptions);
|
||||
|
||||
int getLimitedBeginId(@Param("PagerOptions")PagerOptions pagerOptions);
|
||||
|
||||
List<DataInfoEntity> getLimitedDataInfoEntities(@Param("PagerOptions")PagerOptions pagerOptions);
|
||||
|
||||
List<String> getIdIsExist(int parseInt);
|
||||
public int getLimitedDataCount(
|
||||
@Param(value = "PagerOptions") PagerOptions pagerOptions);
|
||||
|
||||
@Insert("INSERT INTO data_info(regionalism_code, system_code, data_type, data_version, submitted_batch, data_path, collection_time, data_charset)"
|
||||
+ " values(#{regionalismCcode},#{systemCcode},#{dataType},#{dataVersion},#{submittedBbatch},#{dataPath},#{collectionTime},#{dataCharset})")
|
||||
public int inserRecode(@Param("regionalismCcode") String regionalismCcode,
|
||||
@Param("systemCcode") int systemCcode,
|
||||
@Param("dataType") String dataType,
|
||||
@Param("dataVersion") int dataVersion,
|
||||
@Param("submittedBbatch") String submittedBbatch,
|
||||
@Param("dataPath") String dataPath,
|
||||
@Param("collectionTime") String collectionTime,
|
||||
@Param("dataCharset") String dataCharset);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,28 +0,0 @@
|
|||
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;
|
||||
|
||||
}
|
||||
|
|
@ -12,7 +12,7 @@ import org.springframework.stereotype.Repository;
|
|||
import com.platform.entities.EncodedInfoEntity;
|
||||
|
||||
/**
|
||||
* 数据库操作: 实现增、删、改、查
|
||||
* 数据库操作: 实现增、删、改、查
|
||||
*
|
||||
* @author wuming
|
||||
*
|
||||
|
|
@ -21,49 +21,49 @@ import com.platform.entities.EncodedInfoEntity;
|
|||
public interface EncodeInfoDao {
|
||||
|
||||
/**
|
||||
* 获取查询表下的所有实体(行政区划/系统)信息
|
||||
* 获取查询表下的所有实体(行政区划/系统)信息
|
||||
*
|
||||
* @param tableName
|
||||
* 查询的表名
|
||||
* @return 所有实体信息:名称和编码
|
||||
* 查询的表名
|
||||
* @return 所有实体信息:名称和编码
|
||||
*/
|
||||
@Select("SELECT code, name FROM ${tableName}")
|
||||
public List<EncodedInfoEntity> getAllEntityInfo(
|
||||
@Param("tableName") String tableName);
|
||||
|
||||
/**
|
||||
* 根据实体(行政区划/系统)的名称查询编码
|
||||
* 根据实体(行政区划/系统)的名称查询编码
|
||||
*
|
||||
* @param code
|
||||
* 实体编码
|
||||
* 实体编码
|
||||
* @param tableName
|
||||
* 查询的表名
|
||||
* @return 编码是主键,查询结果最多只有一条记录
|
||||
* 查询的表名
|
||||
* @return 编码是主键,查询结果最多只有一条记录
|
||||
*/
|
||||
@Select("SELECT name FROM ${tableName} WHERE code = #{code}")
|
||||
public String getEncodeNameByCode(@Param("code") String code,
|
||||
@Param("tableName") String tableName);
|
||||
|
||||
/**
|
||||
* 根据实体(行政区划/系统)的编码查询名称
|
||||
* 根据实体(行政区划/系统)的编码查询名称
|
||||
*
|
||||
* @param name
|
||||
* 实体名称
|
||||
* 实体名称
|
||||
* @param tableName
|
||||
* 查询的表名
|
||||
* @return 名称不是主键,查询结果可能会有多个
|
||||
* 查询的表名
|
||||
* @return 名称不是主键,查询结果可能会有多个
|
||||
*/
|
||||
@Select("SELECT code FROM ${tableName} WHERE name = #{name}")
|
||||
public List<String> getEncodeCodeByName(@Param("name") String name,
|
||||
@Param("tableName") String tableName);
|
||||
|
||||
/**
|
||||
* 根据实体(行政区划/系统)的编码,更新实体的名称
|
||||
* 根据实体(行政区划/系统)的编码,更新实体的名称
|
||||
*
|
||||
* @param code
|
||||
* 系统编码
|
||||
* 系统编码
|
||||
* @param tableName
|
||||
* 查询的表名
|
||||
* 查询的表名
|
||||
* @return
|
||||
*/
|
||||
@Update("UPDATE ${tableName} SET name = #{name} WHERE code = #{code}")
|
||||
|
|
@ -71,12 +71,12 @@ public interface EncodeInfoDao {
|
|||
@Param("name") String name, @Param("tableName") String tableName);
|
||||
|
||||
/**
|
||||
* 向表中插入实体(行政区划/系统)信息
|
||||
* 向表中插入实体(行政区划/系统)信息
|
||||
*
|
||||
* @param efe
|
||||
* 插入的实体信息
|
||||
* 插入的实体信息
|
||||
* @param tableName
|
||||
* 表名
|
||||
* 表名
|
||||
* @return
|
||||
*/
|
||||
@Insert("INSERT INTO ${tableName} (code, name) VALUES (#{efe.code}, #{efe.name})")
|
||||
|
|
@ -84,12 +84,12 @@ public interface EncodeInfoDao {
|
|||
@Param("tableName") String tableName);
|
||||
|
||||
/**
|
||||
* 删除表中的实体(行政区划/系统)
|
||||
* 删除表中的实体(行政区划/系统)
|
||||
*
|
||||
* @param code
|
||||
* 实体的编码
|
||||
* 实体的编码
|
||||
* @param tableName
|
||||
* 表名
|
||||
* 表名
|
||||
* @return
|
||||
*/
|
||||
@Delete("DELETE FROM ${tableName} WHERE code = #{code}")
|
||||
|
|
|
|||
|
|
@ -1,39 +0,0 @@
|
|||
package com.platform.dao;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.platform.entities.GatherOracleInfo;
|
||||
|
||||
@Repository(value = "gatherOracleDao")
|
||||
public interface GatherOracleDao {
|
||||
|
||||
/**
|
||||
* @return 查询所有的oracle记录
|
||||
* @throws Exception 异常
|
||||
*/
|
||||
public List<GatherOracleInfo> selectAllOracle() throws Exception;
|
||||
|
||||
/**
|
||||
* @param id
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public int deleteOracleById(int id) throws Exception;
|
||||
|
||||
/**
|
||||
* @param oracle
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public int insertOracle(GatherOracleInfo oracle) throws Exception;
|
||||
|
||||
/**
|
||||
* @param oracle
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public int updateOracleById(GatherOracleInfo oracle) throws Exception;
|
||||
|
||||
}
|
||||
|
|
@ -1,95 +0,0 @@
|
|||
|
||||
|
||||
/**
|
||||
* 文件名 : Brick.java
|
||||
* 版权 : <版权/公司名>
|
||||
* 描述 : <描述>
|
||||
* @author chen
|
||||
* 版本 : <版本>
|
||||
* 修改时间: 2016年9月9日
|
||||
* 修改内容: <修改内容>
|
||||
*/
|
||||
package com.platform.entities;
|
||||
|
||||
/**
|
||||
* <一句话功能简述> volume 下的 块 对象
|
||||
* <功能详细描述>
|
||||
* @author chen
|
||||
* @version [版本号,2016年9月9日]
|
||||
* @see [相关类/方法]
|
||||
* @since [产品/模块版本]
|
||||
*/
|
||||
|
||||
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
|
||||
*/
|
||||
public String getIp() {
|
||||
return ip;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ip the ip to set
|
||||
*/
|
||||
public void setIp(String ip) {
|
||||
this.ip = ip;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the path
|
||||
*/
|
||||
public String getPath() {
|
||||
return path;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param path the path to set
|
||||
*/
|
||||
public void setPath(String path) {
|
||||
this.path = path;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -1,27 +1,27 @@
|
|||
package com.platform.entities;
|
||||
|
||||
/**
|
||||
* 数据信息实体类
|
||||
* 数据信息实体类
|
||||
*
|
||||
* @author wuming
|
||||
*
|
||||
*/
|
||||
public class DataInfoEntity {
|
||||
private int id;
|
||||
private String regionalismCode; // 行政区划编码
|
||||
private String cityName; // 市
|
||||
private String districtName; // 区县
|
||||
private int systemCode; // 系统编码
|
||||
private String systemName; // 系统名称
|
||||
private String dataType; // 数据类型:财政\社保\...
|
||||
private int dataVersion; // 数据版本
|
||||
private String submittedBatch; // 上报批次
|
||||
private String dataPath; // 数据路径
|
||||
private String collectingTime; // 采集时间
|
||||
private String collectorContacts; // 采集人的联系
|
||||
private String charset; // 数据的字符编码
|
||||
private String collectorName; // 采集人姓名
|
||||
private String year; // 数据年度
|
||||
private String regionalismCode; // 行政区划编码
|
||||
private String cityName; // 市
|
||||
private String districtName; // 区县
|
||||
private int systemCode; // 系统编码
|
||||
private String systemName; // 系统名称
|
||||
private String dataType; // 数据类型:财政\社保\...
|
||||
private int dataVersion; // 数据版本
|
||||
private String submittedBatch; // 上报批次
|
||||
private String dataPath; // 数据路径
|
||||
private String collectingTime; // 采集时间
|
||||
private String collectorContacts; // 采集人的联系
|
||||
private String charset; // 数据的字符编码
|
||||
private String collectorName; // 采集人姓名
|
||||
private String year; // 数据年度
|
||||
|
||||
public DataInfoEntity() {
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,54 +0,0 @@
|
|||
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;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -2,14 +2,14 @@ package com.platform.entities;
|
|||
|
||||
/**
|
||||
*
|
||||
* 编码信息实体
|
||||
* 行政区划/系统信息
|
||||
* 编码信息实体
|
||||
* 行政区划/系统信息
|
||||
* @author wuming
|
||||
*
|
||||
*/
|
||||
public class EncodedInfoEntity {
|
||||
private String name; //名称
|
||||
private String code; //编码
|
||||
private String name; //名称
|
||||
private String code; //编码
|
||||
|
||||
public EncodedInfoEntity() {}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,64 +0,0 @@
|
|||
package com.platform.entities;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class FolderNode {
|
||||
private String name;
|
||||
private int isFolder; // 1 is file and other integer is folder show children number
|
||||
private String path;
|
||||
private List<FolderNode> childNodes;
|
||||
|
||||
|
||||
public FolderNode() {
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
|
||||
public FolderNode(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public FolderNode(String name, int isFolder) {
|
||||
this.name = name;
|
||||
this.isFolder = isFolder;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the isFolder
|
||||
*/
|
||||
public int getIsFolder() {
|
||||
return isFolder;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param isFolder the isFolder to set
|
||||
*/
|
||||
public void setIsFolder(int isFolder) {
|
||||
this.isFolder = isFolder;
|
||||
}
|
||||
|
||||
public String getPath() {
|
||||
return path;
|
||||
}
|
||||
|
||||
public void setPath(String path) {
|
||||
this.path = path;
|
||||
}
|
||||
|
||||
public List<FolderNode> getChildNodes() {
|
||||
return childNodes;
|
||||
}
|
||||
|
||||
public void setChildNodes(List<FolderNode> childNodes) {
|
||||
this.childNodes = childNodes;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,82 +0,0 @@
|
|||
package com.platform.entities;
|
||||
|
||||
import com.platform.entities.OracleConnectorParams;
|
||||
|
||||
public class GatherOracleInfo extends OracleConnectorParams {
|
||||
|
||||
private String tableName;
|
||||
|
||||
private String suffix;
|
||||
|
||||
private int id;
|
||||
|
||||
private String remove;
|
||||
|
||||
/**
|
||||
* 0:未知状态, 1:连接成功 ,2:在使用 ,3 :失败
|
||||
*/
|
||||
private int status;
|
||||
|
||||
public GatherOracleInfo() {
|
||||
super();
|
||||
}
|
||||
|
||||
public GatherOracleInfo(String port, String ip, String name, String user,
|
||||
String password, String database) {
|
||||
super(port, ip, name, user, password, database);
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
public GatherOracleInfo(String port, String ip, String name, String user,
|
||||
String password, String database, int _id, String tableName, String suffix, int status) {
|
||||
super(port, ip, name, user, password, database);
|
||||
this.tableName = tableName;
|
||||
this.suffix = suffix;
|
||||
this.id=_id;
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public String getTableName() {
|
||||
return tableName;
|
||||
}
|
||||
|
||||
public void setTableName(String tableName) {
|
||||
this.tableName = tableName;
|
||||
}
|
||||
|
||||
public String getSuffix() {
|
||||
return suffix;
|
||||
}
|
||||
|
||||
public void setSuffix(String suffix) {
|
||||
this.suffix = suffix;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public int getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(int status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public String getRemove() {
|
||||
return remove;
|
||||
}
|
||||
|
||||
public void setRemove(String remove) {
|
||||
this.remove = remove;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,77 +0,0 @@
|
|||
|
||||
/**
|
||||
* 文件名 : GfsPathModel.java
|
||||
* 版权 : <版权/公司名>
|
||||
* 描述 : <描述>
|
||||
* @author chen
|
||||
* 版本 : <版本>
|
||||
* 修改时间: 2016年9月8日
|
||||
* 修改内容: <修改内容>
|
||||
*/
|
||||
package com.platform.entities;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <一句话功能简述>
|
||||
* <功能详细描述>
|
||||
* @author chen
|
||||
* @version [版本号,2016年9月8日]
|
||||
* @see [相关类/方法]
|
||||
* @since [产品/模块版本]
|
||||
*/
|
||||
|
||||
public class GfsFolderEntity {
|
||||
|
||||
/** 当前路径 */
|
||||
private String path;
|
||||
|
||||
/** 当前路径 */
|
||||
private String name;
|
||||
|
||||
/** 子目录 */
|
||||
private List<GfsFolderEntity> children;
|
||||
|
||||
/**
|
||||
* @return the path
|
||||
*/
|
||||
public String getPath() {
|
||||
return path;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param path the path to set
|
||||
*/
|
||||
public void setPath(String path) {
|
||||
this.path = path;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the name
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param name the name to set
|
||||
*/
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the children
|
||||
*/
|
||||
public List<GfsFolderEntity> getChildren() {
|
||||
return children;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param children the children to set
|
||||
*/
|
||||
public void setChildren(List<GfsFolderEntity> children) {
|
||||
this.children = children;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,93 +0,0 @@
|
|||
package com.platform.entities;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
import com.platform.utils.ConfigPropertyReader;
|
||||
import com.platform.utils.Configs;
|
||||
|
||||
public class OracleConnectorParams {
|
||||
private String port;
|
||||
private String ip;
|
||||
private String name;
|
||||
private String user;
|
||||
private String password;
|
||||
private String databaseName;
|
||||
|
||||
public OracleConnectorParams() {
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
public OracleConnectorParams(String port, String ip, String name) {
|
||||
maybeInit();
|
||||
this.port = port;
|
||||
this.ip = ip;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public OracleConnectorParams(String port, String ip, String name,
|
||||
String user, String password, String database) {
|
||||
this.port = port;
|
||||
this.ip = ip;
|
||||
this.name = name;
|
||||
this.user = user;
|
||||
this.password = password;
|
||||
this.databaseName = database;
|
||||
}
|
||||
|
||||
private void maybeInit() {
|
||||
Properties properties = ConfigPropertyReader.Builder(
|
||||
Configs.CONFIG_LOCALTION).getProperties();
|
||||
this.user = properties.getProperty("collect-user");
|
||||
this.password = properties.getProperty("collect-password");
|
||||
this.databaseName = properties.getProperty("collect-database");
|
||||
}
|
||||
|
||||
public String getPort() {
|
||||
return port;
|
||||
}
|
||||
|
||||
public void setPort(String port) {
|
||||
this.port = port;
|
||||
}
|
||||
|
||||
public String getIp() {
|
||||
return ip;
|
||||
}
|
||||
|
||||
public void setIp(String ip) {
|
||||
this.ip = ip;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getUser() {
|
||||
return user;
|
||||
}
|
||||
|
||||
public void setUser(String user) {
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public String getDatabaseName() {
|
||||
return databaseName;
|
||||
}
|
||||
|
||||
public void setDatabaseName(String databaseName) {
|
||||
this.databaseName = databaseName;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,36 +1,30 @@
|
|||
package com.platform.entities;
|
||||
|
||||
public class PagerOptions {
|
||||
private Integer currentPageNum; //当前页码
|
||||
private int idIndex;
|
||||
|
||||
private String dataType; //数据类型
|
||||
private String dataType;
|
||||
|
||||
private String submittedBatch; //数据批次
|
||||
|
||||
private String cityName; //城市名称
|
||||
private String submittedBatch;
|
||||
|
||||
private String districtName; //区县名
|
||||
private String cityName;
|
||||
|
||||
private Integer dataVersion; //数据版本
|
||||
private String districtName;
|
||||
|
||||
private String systemName; //系统名称
|
||||
private int dataVersion;
|
||||
|
||||
private String dataYear; // 数据年度
|
||||
private String systemName;
|
||||
|
||||
private Integer limit; //一次查询返回记录条数
|
||||
private String dataYear;
|
||||
|
||||
private Integer offset; // 查询偏移量:起始id
|
||||
|
||||
private Integer totalLimit; //当前页前面已有多少条数据
|
||||
|
||||
private Integer priorTableSize; //前一次操作一页显示的数据条数
|
||||
private int limit;
|
||||
|
||||
public Integer getCurrentPageNum() {
|
||||
return currentPageNum;
|
||||
public int getIdIndex() {
|
||||
return idIndex;
|
||||
}
|
||||
|
||||
public void setCurrentPageNum(Integer currentPageNum) {
|
||||
this.currentPageNum = currentPageNum;
|
||||
public void setIdIndex(int idIndex) {
|
||||
this.idIndex = idIndex;
|
||||
}
|
||||
|
||||
public String getDataType() {
|
||||
|
|
@ -65,11 +59,11 @@ public class PagerOptions {
|
|||
this.districtName = districtName;
|
||||
}
|
||||
|
||||
public Integer getDataVersion() {
|
||||
public int getDataVersion() {
|
||||
return dataVersion;
|
||||
}
|
||||
|
||||
public void setDataVersion(Integer dataVersion) {
|
||||
public void setDataVersion(int dataVersion) {
|
||||
this.dataVersion = dataVersion;
|
||||
}
|
||||
|
||||
|
|
@ -89,36 +83,12 @@ public class PagerOptions {
|
|||
this.dataYear = dataYear;
|
||||
}
|
||||
|
||||
public Integer getLimit() {
|
||||
public int getLimit() {
|
||||
return limit;
|
||||
}
|
||||
|
||||
public void setLimit(Integer limit) {
|
||||
public void setLimit(int limit) {
|
||||
this.limit = limit;
|
||||
}
|
||||
|
||||
public Integer getOffset() {
|
||||
return offset;
|
||||
}
|
||||
|
||||
public void setOffset(Integer offset) {
|
||||
this.offset = offset;
|
||||
}
|
||||
|
||||
public Integer getTotalLimit() {
|
||||
return totalLimit;
|
||||
}
|
||||
|
||||
public void setTotalLimit(Integer totalLimit) {
|
||||
this.totalLimit = totalLimit;
|
||||
}
|
||||
|
||||
public Integer getPriorTableSize() {
|
||||
return priorTableSize;
|
||||
}
|
||||
|
||||
public void setPriorTableSize(Integer priorTableSize) {
|
||||
this.priorTableSize = priorTableSize;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,44 +0,0 @@
|
|||
package com.platform.entities;
|
||||
|
||||
public class SimpleConfigParamsBean {
|
||||
private String masterUrl;
|
||||
|
||||
private String oracleUserName;
|
||||
|
||||
private String oraclePassword;
|
||||
|
||||
private String oracleDBName;
|
||||
|
||||
public String getMasterUrl() {
|
||||
return masterUrl;
|
||||
}
|
||||
|
||||
public void setMasterUrl(String masterUrl) {
|
||||
this.masterUrl = masterUrl;
|
||||
}
|
||||
|
||||
public String getOracleUserName() {
|
||||
return oracleUserName;
|
||||
}
|
||||
|
||||
public void setOracleUserName(String oracleUserName) {
|
||||
this.oracleUserName = oracleUserName;
|
||||
}
|
||||
|
||||
public String getOraclePassword() {
|
||||
return oraclePassword;
|
||||
}
|
||||
|
||||
public void setOraclePassword(String oraclePassword) {
|
||||
this.oraclePassword = oraclePassword;
|
||||
}
|
||||
|
||||
public String getOracleDBName() {
|
||||
return oracleDBName;
|
||||
}
|
||||
|
||||
public void setOracleDBName(String oracleDBName) {
|
||||
this.oracleDBName = oracleDBName;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,129 +0,0 @@
|
|||
|
||||
/**
|
||||
* 文件名 : VolumeEntity.java
|
||||
* 版权 : <版权/公司名>
|
||||
* 描述 : <描述>
|
||||
* @author chen
|
||||
* 版本 : <版本>
|
||||
* 修改时间: 2016年9月9日
|
||||
* 修改内容: <修改内容>
|
||||
*/
|
||||
package com.platform.entities;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <一句话功能简述> gfs的 volume 对象
|
||||
* <功能详细描述>
|
||||
* @author chen
|
||||
* @version [版本号,2016年9月9日]
|
||||
* @see [相关类/方法]
|
||||
* @since [产品/模块版本]
|
||||
*/
|
||||
|
||||
public class VolumeEntity {
|
||||
|
||||
/** volume总大小 */
|
||||
private double allSize;
|
||||
|
||||
/** volume已使用大小 */
|
||||
private double usedSize;
|
||||
|
||||
/** volume名称 */
|
||||
private String name;
|
||||
|
||||
/** 挂载点 */
|
||||
private String path;
|
||||
|
||||
/** volume树形目录 */
|
||||
private FolderNode folder;
|
||||
|
||||
/** volume的 块 */
|
||||
private List<Brick> brick = new ArrayList<Brick>();
|
||||
|
||||
/**
|
||||
* @return the allSize
|
||||
*/
|
||||
public double getAllSize() {
|
||||
return allSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param allSize the allSize to set
|
||||
*/
|
||||
public void setAllSize(double allSize) {
|
||||
this.allSize = allSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the usedSize
|
||||
*/
|
||||
public double getUsedSize() {
|
||||
return usedSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param usedSize the usedSize to set
|
||||
*/
|
||||
public void setUsedSize(double usedSize) {
|
||||
this.usedSize = usedSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the name
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param name the name to set
|
||||
*/
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the path
|
||||
*/
|
||||
public String getPath() {
|
||||
return path;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param path the path to set
|
||||
*/
|
||||
public void setPath(String path) {
|
||||
this.path = path;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the folder
|
||||
*/
|
||||
public FolderNode getFolder() {
|
||||
return folder;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param folder the folder to set
|
||||
*/
|
||||
public void setFolder(FolderNode folder) {
|
||||
this.folder = folder;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the brick
|
||||
*/
|
||||
public List<Brick> getBrick() {
|
||||
return brick;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param brick the brick to set
|
||||
*/
|
||||
public void setBrick(List<Brick> brick) {
|
||||
this.brick = brick;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,106 +0,0 @@
|
|||
package com.platform.glusterfs;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.aspectj.weaver.ast.And;
|
||||
|
||||
import com.mysql.jdbc.log.Log;
|
||||
import com.platform.utils.Constant;
|
||||
|
||||
public class CheckoutMD5 {
|
||||
public static Logger log = Logger.getLogger(CheckoutMD5.class);
|
||||
String sourcePath;
|
||||
String destPath;
|
||||
String dataName;
|
||||
// String cmd_crateSourceMD5File="find "+sourcePath+dataName+"/app/ -type f
|
||||
// -print0 | xargs -0 md5sum | sort >"+deskPath+dataName+"_md5.txt";
|
||||
String cmd_getSourceMD5File;
|
||||
// String cmd_crateDestMD5File="find "+destPath+dataName+"/app/ -type f
|
||||
// -print0 | xargs -0 md5sum | sort >"+deskPath+dataName+"_md5.txt";
|
||||
String cmd_getDestMD5File;
|
||||
Map<String, String> source_md5 = new HashMap<String, String>();
|
||||
Map<String, String> dest_md5 = new HashMap<String, String>();
|
||||
|
||||
public CheckoutMD5() {
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
public CheckoutMD5(String sourcePath, String destPath, String dataName) {
|
||||
// TODO Auto-generated constructor stub
|
||||
this.sourcePath = sourcePath;
|
||||
this.destPath = destPath;
|
||||
this.dataName = dataName;
|
||||
cmd_getSourceMD5File = "find " + sourcePath + dataName + "/app/ -type f -print0 | xargs -0 md5sum | sort ";
|
||||
cmd_getDestMD5File = "find " + destPath + dataName + "/app/ -type f -print0 | xargs -0 md5sum | sort ";
|
||||
}
|
||||
|
||||
/**
|
||||
* 文件夹校验 校验sourcePath和destPath是否完全相同,如果相同,返回1;
|
||||
* 如果不相同,返回0,如果获取文件MD5出错,返回-1;如何源文件不存在返回-2;目标文件不存在,返回-3;
|
||||
*
|
||||
* @param sourcePath
|
||||
* @param destPath
|
||||
* @return
|
||||
* @see [类、类#方法、类#成员]
|
||||
*/
|
||||
public int checkoutMD5Folder(String sourcePath, String destPath) {
|
||||
log.info("start checkout md5 "+sourcePath+" and "+ destPath);
|
||||
List<String> wrong_files = new ArrayList<String>();
|
||||
String source_cmd = "find " + sourcePath + " -type f -print0 | xargs -0 md5sum";
|
||||
String dest_cmd = "find " + destPath + " -type f -print0 | xargs -0 md5sum";
|
||||
List<String> sourceReStrings = Constant.ganymedSSH.execCmdWaitAcquiescent(source_cmd);
|
||||
if (sourceReStrings == null || sourceReStrings.size() == 0) {
|
||||
log.error("get " + sourcePath + " MD5 error!");
|
||||
return -1;
|
||||
}
|
||||
if(sourceReStrings.get(0).contains(Constant.noSuchFile)){
|
||||
log.error(sourcePath+" is not exist!");
|
||||
return -2;
|
||||
}
|
||||
List<String> destReStrings = Constant.ganymedSSH.execCmdWaitAcquiescent(dest_cmd);
|
||||
if (destReStrings == null || destReStrings.size() == 0) {
|
||||
log.error("get " + destReStrings + " MD5 error!");
|
||||
return -1;
|
||||
}
|
||||
if(destReStrings.get(0).contains(Constant.noSuchFile)){
|
||||
log.error(destPath+" is not exist!");
|
||||
return -3;
|
||||
}
|
||||
Map<String, String> source_md5 = new HashMap<String, String>();
|
||||
Map<String, String> dest_md5 = new HashMap<String, String>();
|
||||
for (String line : sourceReStrings) {
|
||||
String[] lines = line.split(" ");
|
||||
String key = lines[1].replace(sourcePath, "").trim();
|
||||
String value = lines[0].trim();
|
||||
source_md5.put(key, value);
|
||||
}
|
||||
for (String line : destReStrings) {
|
||||
String[] lines = line.split(" ");
|
||||
String key = lines[1].replace(destPath, "").trim();
|
||||
String value = lines[0].trim();
|
||||
dest_md5.put(key, value);
|
||||
}
|
||||
for (Map.Entry<String, String> mapEntry : source_md5.entrySet()) {
|
||||
if (!(dest_md5.containsKey(mapEntry.getKey())
|
||||
&& dest_md5.get(mapEntry.getKey()).equals(mapEntry.getValue()))) {
|
||||
|
||||
log.info(sourcePath + " and " + destPath + " is not same!");
|
||||
return 0;
|
||||
// System.out.println(mapEntry.getKey());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
log.info(sourcePath + " and " + destPath + " is same!");
|
||||
return 1;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
CheckoutMD5 checkoutMD5 = new CheckoutMD5();
|
||||
System.out.println(checkoutMD5.checkoutMD5Folder("/home/v1_copy","/home/ubuntu"));
|
||||
}
|
||||
}
|
||||
|
|
@ -1,124 +0,0 @@
|
|||
|
||||
|
||||
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;
|
||||
|
||||
/**
|
||||
* 获取集群信息
|
||||
* @author liliy
|
||||
* @version [版本号,2016年9月12日]
|
||||
* @see [相关类/方法]
|
||||
* @since [产品/模块版本]
|
||||
*/
|
||||
public class ClusterInfo {
|
||||
public static Logger log = Logger.getLogger(ClusterInfo.class);
|
||||
|
||||
/**
|
||||
* 获取集群节点信息
|
||||
* 如果获取不正常,则返回null,如果获取正常,返回map表示节点ip和ip的状态
|
||||
* 如果ip在集群中且联通状态为PeerinCluster(Connected)
|
||||
* 如果ip在集群中且但不连通为PeerinCluster(Disconnected)
|
||||
* @return
|
||||
* @see [类、类#方法、类#成员]
|
||||
*/
|
||||
public Map<String, String> showClusterInfo() {
|
||||
log.info("get cluster info");
|
||||
Map<String, String> peerIps = new HashMap<String, String>();
|
||||
|
||||
List<String> reStrings = Constant.ganymedSSH.execCmdWaitAcquiescent(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<String, String> peerIps=showClusterInfo();
|
||||
if(peerIps==null || peerIps.size()==0){
|
||||
return null;
|
||||
}
|
||||
|
||||
if(peerip.equals(Constant.hostIp)){
|
||||
return Constant.peerincluster_connected;
|
||||
}
|
||||
if(!peerIps.containsKey(peerip)){
|
||||
return Constant.peerNotinCluster;
|
||||
}
|
||||
return peerIps.get(peerip);
|
||||
}
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
// PropertyConfigurator.configure("log4j.properties");
|
||||
System.out.println(new ClusterInfo().showClusterInfo());
|
||||
System.out.println(new ClusterInfo().getPeerStatus("192.168.0.116"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -1,99 +0,0 @@
|
|||
|
||||
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<String,String> 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<String> reStrings = runCommand.runCommandWait(command);
|
||||
*/
|
||||
Constant.ganymedSSH.execCmdNoWaitAcquiescent(command);
|
||||
|
||||
log.info("copy " + sourceFolderName +"/" + fileName+ " to " + destFolderName + " running");
|
||||
return 1;
|
||||
}
|
||||
|
||||
public int createFolders(String folder){
|
||||
log.info("create "+folder);
|
||||
String splitFolder[]=folder.substring(1).split("/");
|
||||
String cmd="mkdir ";
|
||||
for(String one:splitFolder){
|
||||
cmd+="/"+one.replaceAll(" ", "");
|
||||
Constant.ganymedSSH.execCmdWaitAcquiescent(cmd);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testcreateFolders() {
|
||||
|
||||
createFolders("/aaa/vvv/ddd/www/rrrr");
|
||||
}
|
||||
|
||||
//@Test
|
||||
public void testCopyFolderFiles() {
|
||||
|
||||
copyFolderFiles("/home", "/home/ubuntu", "system_data");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -1,125 +0,0 @@
|
|||
|
||||
|
||||
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;
|
||||
import com.platform.utils.GanymedSSH;
|
||||
|
||||
/**
|
||||
* <一句话功能简述> 获得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<String, String> files = showData.showFolderData(name);
|
||||
if(files==null || files.size()==0){
|
||||
return fileNode;
|
||||
}
|
||||
fileNode.setIsFolder(files.size());
|
||||
List<FolderNode> list = new ArrayList<FolderNode>();
|
||||
fileNode.setChildNodes(list);
|
||||
for (Map.Entry<String, String> 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()-1);
|
||||
}
|
||||
// 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 shellComment= Constant.strGetTreeData;
|
||||
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/gfs_ftp_point");
|
||||
FolderNode fileOrFolder=getTreeData.getDatasWithShell("/home/gfs_ftp_point/");
|
||||
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;
|
||||
}
|
||||
|
||||
public FileOrFolder(String name, int isFolder) {
|
||||
// TODO Auto-generated constructor stub
|
||||
this.name = name;
|
||||
this.isFolder = isFolder;
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
|
|
@ -1,56 +0,0 @@
|
|||
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 RemoveData {
|
||||
|
||||
public static Logger log = Logger.getLogger ( RemoveData.class);
|
||||
|
||||
|
||||
/**
|
||||
* -1 :error; 0: the filename is not exists ; 1: right
|
||||
* @param folderName
|
||||
* @param fileName
|
||||
* @return
|
||||
*/
|
||||
public int deleteFolder(String folderName){
|
||||
log.info("start delete "+folderName);
|
||||
|
||||
ShowData showData=new ShowData();
|
||||
Map<String,String> reStrings=showData.showFolderData(folderName);
|
||||
|
||||
if(reStrings==null){
|
||||
log.error("3301 "+folderName+" is not exists");
|
||||
return -1;
|
||||
}
|
||||
|
||||
String command="rm -r "+folderName;
|
||||
|
||||
// int status=runCommand.runCommand(command);
|
||||
Constant.ganymedSSH.execCmdNoWaitAcquiescent(command);
|
||||
|
||||
log.info("delete "+folderName+" running");
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void testDeleteFolderFiles() {
|
||||
PropertyConfigurator.configure("log4j.properties");
|
||||
deleteFolder("/home/ubuntu");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,67 +0,0 @@
|
|||
|
||||
package com.platform.glusterfs;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.hamcrest.core.Is;
|
||||
|
||||
import com.platform.utils.Constant;
|
||||
import com.platform.utils.Support;
|
||||
|
||||
public class SetCluster {
|
||||
public static Logger log = Logger.getLogger ( SetCluster.class);
|
||||
|
||||
/**
|
||||
* 向集群中添加节点
|
||||
* 返回1表示添加成功;-1表示ip不合法,-2 表示出错,0表示添加失败
|
||||
* @param peerip
|
||||
* @return
|
||||
* @see [类、类#方法、类#成员]
|
||||
*/
|
||||
public int probePeer(String peerip){
|
||||
if(!Support.checkIP(peerip)){
|
||||
log.error(peerip +"is illegal!" );
|
||||
return -1;
|
||||
}
|
||||
String cmd="gluster peer probe "+peerip;
|
||||
List<String> reStrings=Constant.ganymedSSH.execCmdWaitAcquiescent(cmd);
|
||||
if(reStrings==null || reStrings.size()==0){
|
||||
log.error("detach error! ");
|
||||
return -2;
|
||||
}
|
||||
if(reStrings.contains(Constant.success)){
|
||||
log.info("probe success!");
|
||||
return 1;
|
||||
}
|
||||
log.info("probe failed!");
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除集群中节点
|
||||
* 返回1表示删除成功;-1表示ip不合法,-2 表示出错,0表示添加失败
|
||||
* @param peerip
|
||||
* @return
|
||||
* @see [类、类#方法、类#成员]
|
||||
*/
|
||||
public int detachPeer(String peerip){
|
||||
if(!Support.checkIP(peerip)){
|
||||
log.error(peerip +"is illegal!" );
|
||||
return -1;
|
||||
}
|
||||
String cmd="gluster peer detach "+peerip;
|
||||
List<String> reStrings=Constant.ganymedSSH.execCmdWaitAcquiescent(cmd);
|
||||
if(reStrings==null || reStrings.size()==0){
|
||||
log.error("detach error! ");
|
||||
return -2;
|
||||
}
|
||||
if(reStrings.contains(Constant.success)){
|
||||
log.info("detach success!");
|
||||
return 1;
|
||||
}
|
||||
log.info("detach failed!");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1,511 +0,0 @@
|
|||
|
||||
|
||||
/**
|
||||
* @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<String> 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<String> 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<String> volumeNames = new VolumeInfo().showAllVolumeName();
|
||||
if (!volumeNames.contains(volumeName)) {
|
||||
log.error("3801 " + volumeName + " is not exists !");
|
||||
return -1;
|
||||
}
|
||||
|
||||
List<String> mountPoints = new VolumeInfo().getVolumeMountPoint(volumeName);
|
||||
if (stopVolume(volumeName) != 0) {
|
||||
log.error("3802 " + volumeName + " stop failed !");
|
||||
return -2;
|
||||
}
|
||||
log.info("stop "+volumeName+" successed!");
|
||||
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);
|
||||
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是否相符
|
||||
* <功能详细描述>
|
||||
* @param volumeName
|
||||
* @param brickName
|
||||
* @param count
|
||||
* @param type
|
||||
* @return
|
||||
* @see [类、类#方法、类#成员]
|
||||
*/
|
||||
public int addBrickVolume(String volumeName, List<String> 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<String> 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是否相符
|
||||
* @param volumeName
|
||||
* @param brickName
|
||||
* @param count
|
||||
* @param type
|
||||
* @return
|
||||
* @see [类、类#方法、类#成员]
|
||||
*/
|
||||
public int deleteBrickVolume(String volumeName, List<String> 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<String> 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<String> 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<String> 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<String> 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<String> 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<String> 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<String> 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<String> 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<String> 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<String> bricksToCreate = new ArrayList<String>();
|
||||
bricksToCreate.add("192.168.0.110:/v2");
|
||||
bricksToCreate.add("192.168.0.116:/v2");
|
||||
operation = setVolume.createVolume("v2", 0, "distributed", bricksToCreate, "/home/v2_point");
|
||||
// operation = setVolume.deleteVolume("v3");
|
||||
//
|
||||
// // 以下是测试添加brick的代码
|
||||
//
|
||||
// List<String> bricksToAdd = new ArrayList<String>();
|
||||
// bricksToAdd.add("192.168.191.23:/v3");
|
||||
// operation = setVolume.addBrickVolume("v3", bricksToAdd, 0,
|
||||
// "distribute");
|
||||
// System.out.println(operation);
|
||||
|
||||
// 以下代码是测试删除brick的代码
|
||||
// List<String> bricksToAdd= new ArrayList<String>();
|
||||
// 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<String> bricksToCreate= new ArrayList<String>();
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue