diff --git a/.gitignore b/.gitignore index d1638636..30c0ce06 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,5 @@ -build/ \ No newline at end of file +/target +/build +.classpath + +/bin/ diff --git a/.metadata/.lock b/.metadata/.lock new file mode 100644 index 00000000..e69de29b diff --git a/.metadata/.log b/.metadata/.log new file mode 100644 index 00000000..f2fea4ba --- /dev/null +++ b/.metadata/.log @@ -0,0 +1,14 @@ +!SESSION 2016-09-13 08:39:40.662 ----------------------------------------------- +eclipse.buildId=4.3.0.I20130605-2000 +java.version=1.8.0_91 +java.vendor=Oracle Corporation +BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=zh_CN +Framework arguments: -product org.eclipse.epp.package.jee.product +Command-line arguments: -os win32 -ws win32 -arch x86_64 -product org.eclipse.epp.package.jee.product + +!ENTRY org.eclipse.egit.ui 2 0 2016-09-13 08:40:07.850 +!MESSAGE Warning: The environment variable HOME is not set. The following directory will be used to store the Git +user global configuration and to define the default location to store repositories: 'C:\Users\wuming'. If this is +not correct please set the HOME environment variable and restart Eclipse. Otherwise Git for Windows and +EGit might behave differently since they see different configuration options. +This warning can be switched off on the Team > Git > Confirmations and Warnings preference page. diff --git a/.metadata/.mylyn/repositories.xml.zip b/.metadata/.mylyn/repositories.xml.zip new file mode 100644 index 00000000..a72104b5 Binary files /dev/null and b/.metadata/.mylyn/repositories.xml.zip differ diff --git a/.metadata/.plugins/org.eclipse.core.resources/.projects/RemoteSystemsTempFiles/.indexes/properties.index b/.metadata/.plugins/org.eclipse.core.resources/.projects/RemoteSystemsTempFiles/.indexes/properties.index new file mode 100644 index 00000000..1e099f3b Binary files /dev/null and b/.metadata/.plugins/org.eclipse.core.resources/.projects/RemoteSystemsTempFiles/.indexes/properties.index differ diff --git a/.metadata/.plugins/org.eclipse.core.resources/.projects/RemoteSystemsTempFiles/org.eclipse.egit.core/GitProjectData.properties b/.metadata/.plugins/org.eclipse.core.resources/.projects/RemoteSystemsTempFiles/org.eclipse.egit.core/GitProjectData.properties new file mode 100644 index 00000000..ad45730a --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.projects/RemoteSystemsTempFiles/org.eclipse.egit.core/GitProjectData.properties @@ -0,0 +1,3 @@ +#GitProjectData +#Tue Sep 13 08:40:10 CST 2016 +.gitdir=../.git diff --git a/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/history.version b/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/history.version new file mode 100644 index 00000000..25cb955b --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/history.version @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.index b/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.index new file mode 100644 index 00000000..bfa6b4c2 Binary files /dev/null and b/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.index differ diff --git a/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.version b/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.version new file mode 100644 index 00000000..6b2aaa76 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.version @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.root/1.tree b/.metadata/.plugins/org.eclipse.core.resources/.root/1.tree new file mode 100644 index 00000000..a3003ede Binary files /dev/null and b/.metadata/.plugins/org.eclipse.core.resources/.root/1.tree differ diff --git a/.metadata/.plugins/org.eclipse.core.resources/.safetable/org.eclipse.core.resources b/.metadata/.plugins/org.eclipse.core.resources/.safetable/org.eclipse.core.resources new file mode 100644 index 00000000..75faf83a Binary files /dev/null and b/.metadata/.plugins/org.eclipse.core.resources/.safetable/org.eclipse.core.resources differ diff --git a/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.core.resources.prefs b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 00000000..dffc6b51 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +version=1 diff --git a/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.egit.core.prefs b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.egit.core.prefs new file mode 100644 index 00000000..5a1ac199 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.egit.core.prefs @@ -0,0 +1,2 @@ +GitRepositoriesView.GitDirectories=C\:\\Users\\wuming\\workspace\\data_manager_backend\\.git; +eclipse.preferences.version=1 diff --git a/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.jdt.ui.prefs b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.jdt.ui.prefs new file mode 100644 index 00000000..b91d6678 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.jdt.ui.prefs @@ -0,0 +1,14 @@ +content_assist_proposals_background=255,255,255 +content_assist_proposals_foreground=0,0,0 +eclipse.preferences.version=1 +fontPropagated=true +org.eclipse.jdt.internal.ui.navigator.layout=2 +org.eclipse.jdt.ui.editor.tab.width= +org.eclipse.jdt.ui.formatterprofiles.version=12 +org.eclipse.jdt.ui.javadoclocations.migrated=true +org.eclipse.jface.textfont=1|Courier New|10.0|0|WINDOWS|1|0|0|0|0|0|0|0|0|1|0|0|0|0|Courier New; +proposalOrderMigrated=true +spelling_locale_initialized=true +tabWidthPropagated=true +useAnnotationsPrefPage=true +useQuickDiffPrefPage=true diff --git a/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.jst.j2ee.webservice.ui.prefs b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.jst.j2ee.webservice.ui.prefs new file mode 100644 index 00000000..553bb967 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.jst.j2ee.webservice.ui.prefs @@ -0,0 +1,2 @@ +areThereWebServices=false +eclipse.preferences.version=1 diff --git a/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.m2e.discovery.prefs b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.m2e.discovery.prefs new file mode 100644 index 00000000..67b1d96c --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.m2e.discovery.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +org.eclipse.m2e.discovery.pref.projects= diff --git a/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.mylyn.context.core.prefs b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.mylyn.context.core.prefs new file mode 100644 index 00000000..43e97e40 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.mylyn.context.core.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +mylyn.attention.migrated=true diff --git a/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.mylyn.monitor.ui.prefs b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.mylyn.monitor.ui.prefs new file mode 100644 index 00000000..8d462a6c --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.mylyn.monitor.ui.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +org.eclipse.mylyn.monitor.activity.tracking.enabled.checked=true diff --git a/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.mylyn.tasks.ui.prefs b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.mylyn.tasks.ui.prefs new file mode 100644 index 00000000..453b994f --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.mylyn.tasks.ui.prefs @@ -0,0 +1,3 @@ +eclipse.preferences.version=1 +org.eclipse.mylyn.tasks.ui.filters.nonmatching=true +org.eclipse.mylyn.tasks.ui.filters.nonmatching.encouraged=true diff --git a/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.rse.core.prefs b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.rse.core.prefs new file mode 100644 index 00000000..fbf3b5bc --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.rse.core.prefs @@ -0,0 +1,3 @@ +activeuserprofiles=DESKTOP-65KJ4BV;Team +eclipse.preferences.version=1 +org.eclipse.rse.systemtype.local.systemType.defaultUserId=wuming diff --git a/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.rse.ui.prefs b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.rse.ui.prefs new file mode 100644 index 00000000..3f67aac1 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.rse.ui.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +org.eclipse.rse.preferences.order.connections=DESKTOP-65KJ4BV.Local diff --git a/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.team.cvs.ui.prefs b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.team.cvs.ui.prefs new file mode 100644 index 00000000..f9e585ba --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.team.cvs.ui.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +pref_first_startup=false diff --git a/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.team.ui.prefs b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.team.ui.prefs new file mode 100644 index 00000000..56cd496f --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.team.ui.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +org.eclipse.team.ui.first_time=false diff --git a/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.browser.prefs b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.browser.prefs new file mode 100644 index 00000000..91372956 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.browser.prefs @@ -0,0 +1,2 @@ +browsers=\r\n\r\n\r\n\r\n +eclipse.preferences.version=1 diff --git a/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.ide.prefs b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.ide.prefs new file mode 100644 index 00000000..3b68069f --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.ide.prefs @@ -0,0 +1,5 @@ +PROBLEMS_FILTERS_MIGRATE=true +eclipse.preferences.version=1 +platformState=1470357608478 +quickStart=false +tipsAndTricks=true diff --git a/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.prefs b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.prefs new file mode 100644 index 00000000..08076f23 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +showIntro=false diff --git a/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.workbench.prefs b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.workbench.prefs new file mode 100644 index 00000000..ccd7360d --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.workbench.prefs @@ -0,0 +1,4 @@ +//org.eclipse.ui.commands/state/org.eclipse.wst.xml.views.XPathView.processor.xpathprocessor/org.eclipse.ui.commands.radioState=xpath10 +ENABLED_DECORATORS=org.eclipse.jst.ws.jaxws.dom.integration.navigator.WebServiceDecorator\:true,org.eclipse.m2e.core.mavenVersionDecorator\:false,org.eclipse.wst.server.ui.decorator\:false,org.eclipse.datatools.connectivity.sqm.core.internal.ui.explorer.DependencyDecoration\:true,org.eclipse.datatools.connectivity.sqm.core.internal.ui.explorer.ColumnDecoration\:true,org.eclipse.datatools.connectivity.sqm.core.internal.ui.explorer.ForeignKeyDecoration\:true,org.eclipse.datatools.connectivity.sqm.core.internal.ui.explorer.IndexTriggerDecoration\:true,org.eclipse.datatools.connectivity.internal.core.ui.bookmarkDecoration\:true,org.eclipse.datatools.connectivity.internal.core.ui.FilterNodeDecoration\:true,org.eclipse.datatools.connectivity.ui.decorator.contentextension\:false,org.eclipse.datatools.enablement.ingres.ui.providers.decorators.SynonymDecorationService\:true,org.eclipse.datatools.enablement.ingres.internal.ui.providers.decorators.ParameterDecorationService\:true,org.eclipse.datatools.enablement.sybase.asa.proxytabledecorator\:true,org.eclipse.datatools.enablement.sybase.ase.webservicetabledecorator\:true,org.eclipse.datatools.enablement.sybase.systemtabledecorator\:true,org.eclipse.egit.ui.internal.decorators.GitLightweightDecorator\:true,org.eclipse.jdt.ui.override.decorator\:true,org.eclipse.jdt.ui.interface.decorator\:false,org.eclipse.jdt.ui.buildpath.decorator\:true,org.eclipse.jst.j2ee.internal.ui.util.AnnotationIconDecorator_ejb\:true,org.eclipse.jst.j2ee.navigator.internal.J2EEProjectDecorator\:true,org.eclipse.jst.jee.ui.internal.navigator.ejb.BeanDecorator\:true,org.eclipse.jst.jee.navigator.internal.JEEProjectDecorator\:true,org.eclipse.jst.j2ee.internal.ui.util.AnnotationIconDecorator_servlet\:true,org.eclipse.m2e.core.maven2decorator\:true,org.eclipse.mylyn.context.ui.decorator.interest\:true,org.eclipse.mylyn.tasks.ui.decorators.task\:true,org.eclipse.mylyn.team.ui.changeset.decorator\:true,org.eclipse.pde.ui.binaryProjectDecorator\:false,org.eclipse.rse.core.virtualobject.decorator\:true,org.eclipse.rse.core.binary.executable.decorator\:true,org.eclipse.rse.core.script.executable.decorator\:true,org.eclipse.rse.core.java.executable.decorator\:true,org.eclipse.rse.core.library.decorator\:true,org.eclipse.rse.core.link.decorator\:true,org.eclipse.rse.subsystems.error.decorator\:true,org.eclipse.team.cvs.ui.decorator\:true,org.eclipse.ui.LinkedResourceDecorator\:true,org.eclipse.ui.SymlinkDecorator\:true,org.eclipse.ui.VirtualResourceDecorator\:true,org.eclipse.ui.ContentTypeDecorator\:true,org.eclipse.ui.ResourceFilterDecorator\:false,org.eclipse.wst.jsdt.ui.override.decorator\:true,org.eclipse.wst.server.ui.navigatorDecorator\:true, +PLUGINS_NOT_ACTIVATED_ON_STARTUP=org.eclipse.m2e.discovery; +eclipse.preferences.version=1 diff --git a/.metadata/.plugins/org.eclipse.e4.workbench/workbench.xmi b/.metadata/.plugins/org.eclipse.e4.workbench/workbench.xmi new file mode 100644 index 00000000..82ba807c --- /dev/null +++ b/.metadata/.plugins/org.eclipse.e4.workbench/workbench.xmi @@ -0,0 +1,2492 @@ + + + + activeSchemeId:org.eclipse.ui.defaultAcceleratorConfiguration + + + + + + topLevel + shellMaximized + + + + + persp.actionSet:org.eclipse.mylyn.context.ui.actionSet + persp.actionSet:org.eclipse.mylyn.doc.actionSet + persp.actionSet:org.eclipse.mylyn.tasks.ui.navigation + persp.actionSet:org.eclipse.ui.cheatsheets.actionSet + persp.actionSet:org.eclipse.rse.core.search.searchActionSet + persp.actionSet:org.eclipse.search.searchActionSet + persp.actionSet:org.eclipse.ui.edit.text.actionSet.annotationNavigation + persp.actionSet:org.eclipse.ui.edit.text.actionSet.navigation + persp.actionSet:org.eclipse.ui.edit.text.actionSet.convertLineDelimitersTo + persp.actionSet:org.eclipse.ui.externaltools.ExternalToolsSet + persp.actionSet:org.eclipse.ui.actionSet.keyBindings + persp.actionSet:org.eclipse.ui.actionSet.openFiles + persp.actionSet:org.eclipse.jst.j2ee.J2eeMainActionSet + persp.actionSet:org.eclipse.jdt.ui.JavaActionSet + persp.actionSet:org.eclipse.debug.ui.launchActionSet + persp.actionSet:org.eclipse.debug.ui.debugActionSet + persp.actionSet:org.eclipse.ui.NavigateActionSet + persp.viewSC:org.eclipse.ui.navigator.ProjectExplorer + persp.viewSC:org.eclipse.wst.server.ui.ServersView + persp.viewSC:org.eclipse.datatools.connectivity.DataSourceExplorerNavigator + persp.viewSC:org.eclipse.ui.views.BookmarkView + persp.viewSC:org.eclipse.ui.views.ContentOutline + persp.viewSC:org.eclipse.ui.views.PropertySheet + persp.viewSC:org.eclipse.ui.views.ResourceNavigator + persp.viewSC:org.eclipse.wst.common.snippets.internal.ui.SnippetsView + persp.viewSC:org.eclipse.ui.views.AllMarkersView + persp.viewSC:org.eclipse.mylyn.tasks.ui.views.tasks + persp.viewSC:org.eclipse.search.ui.views.SearchView + persp.viewSC:org.eclipse.ui.console.ConsoleView + persp.showIn:org.eclipse.ui.navigator.ProjectExplorer + persp.newWizSC:org.eclipse.jpt.jpa.ui.wizard.newJpaProject + persp.perspSC:org.eclipse.jpt.ui.jpaPerspective + persp.perspSC:org.eclipse.debug.ui.DebugPerspective + persp.perspSC:org.eclipse.jdt.ui.JavaPerspective + persp.perspSC:org.eclipse.ui.resourcePerspective + persp.perspSC:org.eclipse.wst.web.ui.webDevPerspective + persp.newWizSC:org.eclipse.jst.j2ee.ui.project.facet.EarProjectWizard + persp.newWizSC:org.eclipse.jst.servlet.ui.project.facet.WebProjectWizard + persp.newWizSC:org.eclipse.jst.ejb.ui.project.facet.EjbProjectWizard + persp.newWizSC:org.eclipse.jst.j2ee.jca.ui.internal.wizard.ConnectorProjectWizard + persp.newWizSC:org.eclipse.jst.j2ee.ui.project.facet.appclient.AppClientProjectWizard + persp.newWizSC:org.eclipse.wst.web.ui.internal.wizards.SimpleWebProjectWizard + persp.newWizSC:org.eclipse.jpt.ui.wizard.newJpaProject + persp.newWizSC:org.eclipse.jst.servlet.ui.internal.wizard.AddServletWizard + persp.newWizSC:org.eclipse.jst.ejb.ui.internal.wizard.AddSessionBeanWizard + persp.newWizSC:org.eclipse.jst.ejb.ui.internal.wizard.AddMessageDrivenBeanWizard + persp.newWizSC:org.eclipse.jpt.ui.wizard.newEntity + persp.newWizSC:org.eclipse.jst.ws.creation.ui.wizard.serverwizard + persp.newWizSC:org.eclipse.ui.wizards.new.folder + persp.newWizSC:org.eclipse.ui.wizards.new.file + persp.actionSet:org.eclipse.wst.server.ui.internal.webbrowser.actionSet + persp.actionSet:org.eclipse.debug.ui.breakpointActionSet + persp.newWizSC:org.eclipse.m2e.core.wizards.Maven2ProjectWizard + persp.actionSet:org.eclipse.wst.ws.explorer.explorer + + + newtablook + + + + + + + + + + + newtablook + + + + + + newtablook + org.eclipse.e4.secondaryDataStack + + + + + + + + + + + + + + + + + + + + + + + + View + categoryTag:Help + + + View + categoryTag:General + + ViewMenu + menuContribution:menu + + + + + View + categoryTag:Help + + + + newtablook + org.eclipse.e4.primaryDataStack + EditorStack + + + + + View + categoryTag:General + + ViewMenu + menuContribution:menu + + + + + View + categoryTag:General + + + View + categoryTag:Java + + + View + categoryTag:Java Browsing + + + + View + categoryTag:General + + ViewMenu + menuContribution:menu + + + + + View + categoryTag:General + + + View + categoryTag:Server + + + View + categoryTag:Data Management + + + + View + categoryTag:General + + ViewMenu + menuContribution:menu + + + + + View + categoryTag:General + + + View + categoryTag:General + + + View + categoryTag:General + + + View + categoryTag:General + + + View + categoryTag:General + + + View + categoryTag:General + + + + View + categoryTag:General + + ViewMenu + menuContribution:menu + + + + + View + categoryTag:Mylyn + + + + View + categoryTag:Java + activeOnClose + + ViewMenu + menuContribution:menu + + + + + + toolbarSeparator + + + + Draggable + + + + + + + + + + + + + + + toolbarSeparator + + + + Draggable + + + + + + + Draggable + + + + + + Draggable + + + + + + + Draggable + + + + + Draggable + + + + + toolbarSeparator + + + + Draggable + + + + + + + + + + + + toolbarSeparator + + + + toolbarSeparator + + + + Draggable + + + + + stretch + + + glue + + + + glue + + + Draggable + + + + + stretch + + + + Draggable + + + + + TrimStack + + + + + + + + + + + + + + + + + + + + + + locale:zh + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + locale:zh + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + locale:zh + + + + + locale:zh + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + platform:win32 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Editor + + + View + categoryTag:Ant + + + View + categoryTag:Data Management + + + View + categoryTag:Data Management + + + View + categoryTag:Data Management + + + View + categoryTag:Debug + + + View + categoryTag:Debug + + + View + categoryTag:Debug + + + View + categoryTag:Debug + + + View + categoryTag:Debug + + + View + categoryTag:Debug + + + View + categoryTag:Debug + + + View + categoryTag:Git + + + View + categoryTag:Git + + + View + categoryTag:Git + + + View + categoryTag:Git + + + View + categoryTag:General + + + View + categoryTag:Help + + + View + categoryTag:Debug + + + View + categoryTag:Java + + + View + categoryTag:Java + + + View + categoryTag:Java + + + View + categoryTag:Java Browsing + + + View + categoryTag:Java Browsing + + + View + categoryTag:Java Browsing + + + View + categoryTag:Java Browsing + + + View + categoryTag:Java + + + View + categoryTag:General + + + View + categoryTag:Java + + + View + categoryTag:Java + + + View + categoryTag:JPA + + + View + categoryTag:JPA + + + View + categoryTag:JavaServer Faces + + + View + categoryTag:JavaServer Faces + + + View + categoryTag:Web Services + + + View + categoryTag:Maven + + + View + categoryTag:Maven + + + View + categoryTag:Mylyn + + + View + categoryTag:Mylyn + + + View + categoryTag:Mylyn + + + View + categoryTag:API Tools + + + View + categoryTag:Plug-in Development + + + View + categoryTag:Plug-in Development + + + View + categoryTag:Plug-in Development + + + View + categoryTag:Plug-in Development + + + View + categoryTag:Plug-in Development + + + View + categoryTag:Remote Systems + + + View + categoryTag:Remote Systems + + + View + categoryTag:Remote Systems + + + View + categoryTag:Remote Systems + + + View + categoryTag:Remote Systems + + + View + categoryTag:Remote Systems + + + View + categoryTag:Remote Systems + + + View + categoryTag:Remote Systems + + + View + categoryTag:General + + + View + categoryTag:General + + + View + categoryTag:CVS + + + View + categoryTag:CVS + + + View + categoryTag:Team + + + View + categoryTag:Team + + + View + categoryTag:Terminal + + + View + categoryTag:General + + + View + categoryTag:General + + + View + categoryTag:Help + + + View + categoryTag:General + + + View + categoryTag:General + + + View + categoryTag:General + + + View + categoryTag:General + + + View + categoryTag:General + + + View + categoryTag:General + + + View + categoryTag:General + + + View + categoryTag:General + + + View + categoryTag:General + + + View + categoryTag:General + + + View + categoryTag:General + + + View + categoryTag:General + + + View + categoryTag:Debug + + + View + categoryTag:JavaScript + + + View + categoryTag:JavaScript + + + View + categoryTag:JavaScript + + + View + categoryTag:JavaScript + + + View + categoryTag:JavaScript + + + View + categoryTag:Server + + + View + categoryTag:XML + + + View + categoryTag:XML + + + View + categoryTag:XML + + + View + categoryTag:XML + + + View + categoryTag:XML + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/.metadata/.plugins/org.eclipse.jdt.core/invalidArchivesCache b/.metadata/.plugins/org.eclipse.jdt.core/invalidArchivesCache new file mode 100644 index 00000000..593f4708 Binary files /dev/null and b/.metadata/.plugins/org.eclipse.jdt.core/invalidArchivesCache differ diff --git a/.metadata/.plugins/org.eclipse.jdt.core/nonChainingJarsCache b/.metadata/.plugins/org.eclipse.jdt.core/nonChainingJarsCache new file mode 100644 index 00000000..593f4708 Binary files /dev/null and b/.metadata/.plugins/org.eclipse.jdt.core/nonChainingJarsCache differ diff --git a/.metadata/.plugins/org.eclipse.jdt.core/variablesAndContainers.dat b/.metadata/.plugins/org.eclipse.jdt.core/variablesAndContainers.dat new file mode 100644 index 00000000..3de398e8 Binary files /dev/null and b/.metadata/.plugins/org.eclipse.jdt.core/variablesAndContainers.dat differ diff --git a/.metadata/.plugins/org.eclipse.jdt.ui/OpenTypeHistory.xml b/.metadata/.plugins/org.eclipse.jdt.ui/OpenTypeHistory.xml new file mode 100644 index 00000000..a4ee3cbc --- /dev/null +++ b/.metadata/.plugins/org.eclipse.jdt.ui/OpenTypeHistory.xml @@ -0,0 +1,2 @@ + + diff --git a/.metadata/.plugins/org.eclipse.jdt.ui/QualifiedTypeNameHistory.xml b/.metadata/.plugins/org.eclipse.jdt.ui/QualifiedTypeNameHistory.xml new file mode 100644 index 00000000..9e390f50 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.jdt.ui/QualifiedTypeNameHistory.xml @@ -0,0 +1,2 @@ + + diff --git a/.metadata/.plugins/org.eclipse.jdt.ui/dialog_settings.xml b/.metadata/.plugins/org.eclipse.jdt.ui/dialog_settings.xml new file mode 100644 index 00000000..86bcee4f --- /dev/null +++ b/.metadata/.plugins/org.eclipse.jdt.ui/dialog_settings.xml @@ -0,0 +1,10 @@ + +
+
+ + + + + +
+
diff --git a/.metadata/.plugins/org.eclipse.m2e.logback.configuration/0.log b/.metadata/.plugins/org.eclipse.m2e.logback.configuration/0.log new file mode 100644 index 00000000..e69de29b diff --git a/.metadata/.plugins/org.eclipse.m2e.logback.configuration/logback.1.4.0.20130601-0317.xml b/.metadata/.plugins/org.eclipse.m2e.logback.configuration/logback.1.4.0.20130601-0317.xml new file mode 100644 index 00000000..e0de5155 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.m2e.logback.configuration/logback.1.4.0.20130601-0317.xml @@ -0,0 +1,41 @@ + + + + %date [%thread] %-5level %logger{35} - %msg%n + + + + + + ${org.eclipse.m2e.log.dir}/0.log + + ${org.eclipse.m2e.log.dir}/%i.log + 1 + 10 + + + 100MB + + + %date [%thread] %-5level %logger{35} - %msg%n + + + + + + WARN + + + + + + + + + + + + + + + diff --git a/.metadata/.plugins/org.eclipse.rse.core/.log b/.metadata/.plugins/org.eclipse.rse.core/.log new file mode 100644 index 00000000..e69de29b diff --git a/.metadata/.plugins/org.eclipse.rse.core/initializerMarks/org.eclipse.rse.internal.core.RSELocalConnectionInitializer.mark b/.metadata/.plugins/org.eclipse.rse.core/initializerMarks/org.eclipse.rse.internal.core.RSELocalConnectionInitializer.mark new file mode 100644 index 00000000..e69de29b diff --git a/.metadata/.plugins/org.eclipse.rse.core/profiles/PRF.desktop-65kj4bv_32539/FP.local.files_0/node.properties b/.metadata/.plugins/org.eclipse.rse.core/profiles/PRF.desktop-65kj4bv_32539/FP.local.files_0/node.properties new file mode 100644 index 00000000..4312c4a6 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.rse.core/profiles/PRF.desktop-65kj4bv_32539/FP.local.files_0/node.properties @@ -0,0 +1,57 @@ +# RSE DOM Node +00-name=DESKTOP-65KJ4BV\:local.files +01-type=FilterPool +03-attr.default=true +03-attr.deletable=true +03-attr.id=local.files +03-attr.nonRenamable=false +03-attr.owningParentName=null +03-attr.release=200 +03-attr.singleFilterStringOnly=false +03-attr.singleFilterStringOnlyESet=false +03-attr.stringsCaseSensitive=true +03-attr.supportsDuplicateFilterStrings=false +03-attr.supportsNestedFilters=true +03-attr.type=default +06-child.00000.00-name=My Home +06-child.00000.01-type=Filter +06-child.00000.03-attr.default=false +06-child.00000.03-attr.filterType=default +06-child.00000.03-attr.id=My Home +06-child.00000.03-attr.nonChangable=false +06-child.00000.03-attr.nonDeletable=false +06-child.00000.03-attr.nonRenamable=false +06-child.00000.03-attr.promptable=false +06-child.00000.03-attr.relativeOrder=0 +06-child.00000.03-attr.release=200 +06-child.00000.03-attr.singleFilterStringOnly=false +06-child.00000.03-attr.stringsCaseSensitive=false +06-child.00000.03-attr.stringsNonChangable=false +06-child.00000.03-attr.supportsDuplicateFilterStrings=false +06-child.00000.03-attr.supportsNestedFilters=true +06-child.00000.06-child.00000.00-name=C\:\\Users\\wuming\\* +06-child.00000.06-child.00000.01-type=FilterString +06-child.00000.06-child.00000.03-attr.default=false +06-child.00000.06-child.00000.03-attr.string=C\:\\Users\\wuming\\* +06-child.00000.06-child.00000.03-attr.type=default +06-child.00001.00-name=Drives +06-child.00001.01-type=Filter +06-child.00001.03-attr.default=false +06-child.00001.03-attr.filterType=default +06-child.00001.03-attr.id=Drives +06-child.00001.03-attr.nonChangable=false +06-child.00001.03-attr.nonDeletable=false +06-child.00001.03-attr.nonRenamable=false +06-child.00001.03-attr.promptable=false +06-child.00001.03-attr.relativeOrder=0 +06-child.00001.03-attr.release=200 +06-child.00001.03-attr.singleFilterStringOnly=false +06-child.00001.03-attr.stringsCaseSensitive=false +06-child.00001.03-attr.stringsNonChangable=false +06-child.00001.03-attr.supportsDuplicateFilterStrings=false +06-child.00001.03-attr.supportsNestedFilters=true +06-child.00001.06-child.00000.00-name=* +06-child.00001.06-child.00000.01-type=FilterString +06-child.00001.06-child.00000.03-attr.default=false +06-child.00001.06-child.00000.03-attr.string=* +06-child.00001.06-child.00000.03-attr.type=default diff --git a/.metadata/.plugins/org.eclipse.rse.core/profiles/PRF.desktop-65kj4bv_32539/H.local_16/node.properties b/.metadata/.plugins/org.eclipse.rse.core/profiles/PRF.desktop-65kj4bv_32539/H.local_16/node.properties new file mode 100644 index 00000000..e469a944 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.rse.core/profiles/PRF.desktop-65kj4bv_32539/H.local_16/node.properties @@ -0,0 +1,25 @@ +# RSE DOM Node +00-name=Local +01-type=Host +03-attr.description= +03-attr.hostname=LOCALHOST +03-attr.offline=false +03-attr.promptable=false +03-attr.systemType=org.eclipse.rse.systemtype.local +03-attr.type=Local +06-child.00000.00-name=Local Connector Service +06-child.00000.01-type=ConnectorService +06-child.00000.03-attr.group=Local Connector Service +06-child.00000.03-attr.port=0 +06-child.00000.03-attr.useSSL=false +06-child.00000.06-child.00000.00-name=Local Files +06-child.00000.06-child.00000.01-type=SubSystem +06-child.00000.06-child.00000.03-attr.hidden=false +06-child.00000.06-child.00000.03-attr.type=local.files +06-child.00000.06-child.00000.06-child.00000.00-name=DESKTOP-65KJ4BV___DESKTOP-65KJ4BV\:local.files +06-child.00000.06-child.00000.06-child.00000.01-type=FilterPoolReference +06-child.00000.06-child.00000.06-child.00000.03-attr.refID=local.files +06-child.00000.06-child.00001.00-name=Local Shells +06-child.00000.06-child.00001.01-type=SubSystem +06-child.00000.06-child.00001.03-attr.hidden=false +06-child.00000.06-child.00001.03-attr.type=local.shells diff --git a/.metadata/.plugins/org.eclipse.rse.core/profiles/PRF.desktop-65kj4bv_32539/node.properties b/.metadata/.plugins/org.eclipse.rse.core/profiles/PRF.desktop-65kj4bv_32539/node.properties new file mode 100644 index 00000000..9237cbe5 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.rse.core/profiles/PRF.desktop-65kj4bv_32539/node.properties @@ -0,0 +1,7 @@ +# RSE DOM Node +00-name=DESKTOP-65KJ4BV +01-type=Profile +03-attr.defaultPrivate=true +03-attr.isActive=true +05-ref.00000=FP.local.files_0 +05-ref.00001=H.local_16 diff --git a/.metadata/.plugins/org.eclipse.rse.ui/.log b/.metadata/.plugins/org.eclipse.rse.ui/.log new file mode 100644 index 00000000..e69de29b diff --git a/.metadata/.plugins/org.eclipse.ui.workbench/dialog_settings.xml b/.metadata/.plugins/org.eclipse.ui.workbench/dialog_settings.xml new file mode 100644 index 00000000..8ce2f5ca --- /dev/null +++ b/.metadata/.plugins/org.eclipse.ui.workbench/dialog_settings.xml @@ -0,0 +1,28 @@ + +
+
+ + + + + + + + + + +
+
+ + + + + + + + + +
+
+
+
diff --git a/.metadata/.plugins/org.eclipse.wst.common.snippets/hidden.xml b/.metadata/.plugins/org.eclipse.wst.common.snippets/hidden.xml new file mode 100644 index 00000000..ab946b83 Binary files /dev/null and b/.metadata/.plugins/org.eclipse.wst.common.snippets/hidden.xml differ diff --git a/.metadata/.plugins/org.eclipse.wst.common.snippets/user.xml b/.metadata/.plugins/org.eclipse.wst.common.snippets/user.xml new file mode 100644 index 00000000..77a5127f Binary files /dev/null and b/.metadata/.plugins/org.eclipse.wst.common.snippets/user.xml differ diff --git a/.metadata/version.ini b/.metadata/version.ini new file mode 100644 index 00000000..c51ff745 --- /dev/null +++ b/.metadata/version.ini @@ -0,0 +1 @@ +org.eclipse.core.runtime=1 \ No newline at end of file diff --git a/.project b/.project index ded1f1a4..ed1fe4a2 100644 --- a/.project +++ b/.project @@ -25,6 +25,11 @@ + + com.genuitec.eclipse.ast.deploy.core.DeploymentBuilder + + + org.eclipse.jem.workbench.JavaEMFNature diff --git a/.settings/com.genuitec.eclipse.migration.prefs b/.settings/com.genuitec.eclipse.migration.prefs new file mode 100644 index 00000000..bf0067e7 --- /dev/null +++ b/.settings/com.genuitec.eclipse.migration.prefs @@ -0,0 +1,3 @@ +eclipse.preferences.version=1 +performed.operation.correct.unbound.jre=1.0 +performed.operation.resolve.unknown.runtime=1.0 diff --git a/.settings/org.eclipse.core.resources.prefs b/.settings/org.eclipse.core.resources.prefs index 8e68fb09..02c46235 100644 --- a/.settings/org.eclipse.core.resources.prefs +++ b/.settings/org.eclipse.core.resources.prefs @@ -1,4 +1,10 @@ eclipse.preferences.version=1 encoding//WebContent/WEB-INF/config/config.properties=UTF-8 +<<<<<<< HEAD encoding//src/com/platform/controller/DataModelController.java=UTF-8 encoding/=UTF-8 +======= +encoding//src/com/platform/utils/GanymedSSH.java=UTF-8 +encoding/=UTF-8 +separateDerivedEncodings=true +>>>>>>> ef099fd1aed73bcc4ef4c8d62aaba6cc6ec2dabf diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs index f42de363..68c704e1 100644 --- a/.settings/org.eclipse.jdt.core.prefs +++ b/.settings/org.eclipse.jdt.core.prefs @@ -1,7 +1,101 @@ eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.annotation.inheritNullAnnotations=disabled +org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore +org.eclipse.jdt.core.compiler.annotation.nonnull=org.eclipse.jdt.annotation.NonNull +org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault +org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable +org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve org.eclipse.jdt.core.compiler.compliance=1.7 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.autoboxing=ignore +org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning +org.eclipse.jdt.core.compiler.problem.deadCode=warning +org.eclipse.jdt.core.compiler.problem.deprecation=warning +org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled +org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled +org.eclipse.jdt.core.compiler.problem.discouragedReference=warning +org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore +org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore +org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled +org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore +org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning +org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning +org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled +org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning +org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=warning +org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore +org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore +org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning +org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore +org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled +org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled +org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning +org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore +org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning +org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning +org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore +org.eclipse.jdt.core.compiler.problem.nonnullParameterAnnotationDropped=warning +org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error +org.eclipse.jdt.core.compiler.problem.nullReference=warning +org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error +org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=warning +org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning +org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore +org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore +org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore +org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=ignore +org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning +org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning +org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore +org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore +org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore +org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore +org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore +org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled +org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning +org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled +org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled +org.eclipse.jdt.core.compiler.problem.syntacticNullAnalysisForFields=disabled +org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore +org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning +org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=enabled +org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning +org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning +org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore +org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning +org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore +org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=ignore +org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled +org.eclipse.jdt.core.compiler.problem.unusedExceptionParameter=ignore +org.eclipse.jdt.core.compiler.problem.unusedImport=warning +org.eclipse.jdt.core.compiler.problem.unusedLabel=warning +org.eclipse.jdt.core.compiler.problem.unusedLocal=warning +org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore +org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore +org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled +org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning +org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=ignore +org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning +org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning org.eclipse.jdt.core.compiler.source=1.7 diff --git a/.settings/org.eclipse.jpt.core.prefs b/.settings/org.eclipse.jpt.core.prefs new file mode 100644 index 00000000..4fd5f244 --- /dev/null +++ b/.settings/org.eclipse.jpt.core.prefs @@ -0,0 +1,3 @@ +eclipse.preferences.version=1 +org.eclipse.jpt.core.platform=generic2_1 +org.eclipse.jpt.jpa.core.discoverAnnotatedClasses=false diff --git a/.settings/org.eclipse.m2e.core.prefs b/.settings/org.eclipse.m2e.core.prefs new file mode 100644 index 00000000..f897a7f1 --- /dev/null +++ b/.settings/org.eclipse.m2e.core.prefs @@ -0,0 +1,4 @@ +activeProfiles= +eclipse.preferences.version=1 +resolveWorkspaceProjects=true +version=1 diff --git a/.settings/org.eclipse.wst.common.project.facet.core.prefs.xml b/.settings/org.eclipse.wst.common.project.facet.core.prefs.xml new file mode 100644 index 00000000..7961132f --- /dev/null +++ b/.settings/org.eclipse.wst.common.project.facet.core.prefs.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/.settings/org.eclipse.wst.common.project.facet.core.xml b/.settings/org.eclipse.wst.common.project.facet.core.xml index 6f8fb94f..ba1bfbde 100644 --- a/.settings/org.eclipse.wst.common.project.facet.core.xml +++ b/.settings/org.eclipse.wst.common.project.facet.core.xml @@ -1,10 +1,11 @@ - + + diff --git a/RemoteSystemsTempFiles/.project b/RemoteSystemsTempFiles/.project new file mode 100644 index 00000000..5447a64f --- /dev/null +++ b/RemoteSystemsTempFiles/.project @@ -0,0 +1,12 @@ + + + RemoteSystemsTempFiles + + + + + + + org.eclipse.rse.ui.remoteSystemsTempNature + + diff --git a/WebContent/WEB-INF/config/getTreedata.sh b/WebContent/WEB-INF/config/getTreedata.sh new file mode 100644 index 00000000..d486a449 --- /dev/null +++ b/WebContent/WEB-INF/config/getTreedata.sh @@ -0,0 +1,17 @@ +#!/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 \ No newline at end of file diff --git a/WebContent/WEB-INF/config/log4j-config.xml b/WebContent/WEB-INF/config/log4j-config.xml index 0a2755c5..d02e5918 100644 --- a/WebContent/WEB-INF/config/log4j-config.xml +++ b/WebContent/WEB-INF/config/log4j-config.xml @@ -14,7 +14,7 @@ - + @@ -23,7 +23,7 @@ - + diff --git a/WebContent/WEB-INF/config/mybatis-applicationConfig.xml b/WebContent/WEB-INF/config/mybatis-applicationConfig.xml index 85138096..f1679b32 100644 --- a/WebContent/WEB-INF/config/mybatis-applicationConfig.xml +++ b/WebContent/WEB-INF/config/mybatis-applicationConfig.xml @@ -8,9 +8,11 @@ + - + + \ No newline at end of file diff --git a/WebContent/WEB-INF/config/spring-applicationContext.xml b/WebContent/WEB-INF/config/spring-applicationContext.xml index 4f59451f..fc462369 100644 --- a/WebContent/WEB-INF/config/spring-applicationContext.xml +++ b/WebContent/WEB-INF/config/spring-applicationContext.xml @@ -1,8 +1,11 @@ + http://www.springframework.org/schema/websocket/spring-websocket.xsd + http://www.springframework.org/schema/beans + http://www.springframework.org/schema/beans/spring-beans.xsd + http://www.springframework.org/schema/task + http://www.springframework.org/schema/task/spring-task-3.0.xsd"> + @@ -78,4 +86,8 @@ + + + + \ No newline at end of file diff --git a/WebContent/WEB-INF/lib/spring-websocket-4.3.1.RELEASE.jar b/WebContent/WEB-INF/lib/spring-websocket-4.3.1.RELEASE.jar new file mode 100644 index 00000000..4fb19b09 Binary files /dev/null and b/WebContent/WEB-INF/lib/spring-websocket-4.3.1.RELEASE.jar differ diff --git a/WebContent/WEB-INF/web.xml b/WebContent/WEB-INF/web.xml index 207be4ed..ce73380c 100644 --- a/WebContent/WEB-INF/web.xml +++ b/WebContent/WEB-INF/web.xml @@ -18,7 +18,7 @@ CharacterEncodingFilter - /* + / diff --git a/src/com/base/BaseController.java b/src/com/base/BaseController.java index a9fd417a..64c66474 100644 --- a/src/com/base/BaseController.java +++ b/src/com/base/BaseController.java @@ -1,3 +1,4 @@ + /** * 文件名 : BaseController.java * 版权 : XX科技有限公司。 @@ -60,4 +61,5 @@ public class BaseController { return response; } } + } \ No newline at end of file diff --git a/src/com/base/CustomException.java b/src/com/base/CustomException.java index 42b44cfb..9cf46a4a 100644 --- a/src/com/base/CustomException.java +++ b/src/com/base/CustomException.java @@ -1,3 +1,5 @@ + + package com.base; import org.apache.log4j.Logger; @@ -122,3 +124,4 @@ public class CustomException extends Exception { return cause; } } + diff --git a/src/com/dao/mapper/data-details-mapper.xml b/src/com/dao/mapper/data-details-mapper.xml index 52b98767..89b9f52e 100644 --- a/src/com/dao/mapper/data-details-mapper.xml +++ b/src/com/dao/mapper/data-details-mapper.xml @@ -79,6 +79,7 @@ PUBLIC "-//ibatis.apache.org//DTD Mapper 3.0//EN" + ORDER BY data_details.id LIMIT #{PagerOptions.limit} @@ -101,8 +102,107 @@ PUBLIC "-//ibatis.apache.org//DTD Mapper 3.0//EN" + + + INSERT INTO + data_info( + + + regionalism_code, + + + system_code, + + + data_type, + + + data_version, + + + submitted_batch, + + + data_path, + + + collection_time, + + + collector_name, + + + collector_contacts, + + + data_charset, + + + data_year + + + ) + VALUES( + + + #{regionalismCode}, + + + #{systemCode}, + + + #{dataType}, + + + #{dataVersion}, + + + #{submittedBatch}, + + + #{dataPath}, + + + #{collectingTime}, + + + #{collectorName}, + + + #{collectorContacts}, + + + #{charset}, + + + #{year} + + + ) + + + + + + UPDATE + data_info + set remove = '1' + where id in + + #{item} + + and remove ='0' + \ No newline at end of file diff --git a/src/com/dao/mapper/data-detaisl-mapper.xml b/src/com/dao/mapper/data-detaisl-mapper.xml new file mode 100644 index 00000000..d0f8d7c7 --- /dev/null +++ b/src/com/dao/mapper/data-detaisl-mapper.xml @@ -0,0 +1,109 @@ + + + + + + + + + + + + + + + + + + + + + + + + and data_details.data_type=#{PagerOptions.dataType} + + + and + data_details.submitted_batch=#{PagerOptions.submittedBatch} + + + and data_details.city_name=#{PagerOptions.cityName} + + + and + data_details.district_name=#{PagerOptions.districtName} + + + and data_details.data_version=#{PagerOptions.dataVersion} + + + and data_details=#{PagerOptions.systemName} + + + and data_details.data_year=#{PagerOptions.dataYear} + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/com/dao/mapper/dataInfoMoveTmpmapper.xml b/src/com/dao/mapper/dataInfoMoveTmpmapper.xml index c0545560..7d1145d6 100644 --- a/src/com/dao/mapper/dataInfoMoveTmpmapper.xml +++ b/src/com/dao/mapper/dataInfoMoveTmpmapper.xml @@ -41,16 +41,26 @@ PUBLIC "-//ibatis.apache.org//DTD Mapper 3.0//EN" jdbcType="VARCHAR" /> + + + regionalism_code,system_code,dst_path,lasttime + + - 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 + a.id id,a.regionalism_code regionalismCode,b.city_name cityName,b.district_name districtName, + a.system_code systemCode,b.system_name systemName,b.data_type dataType,b.data_version dataVersion, + b.submitted_batch submittedBatch,b.data_path dataPath,b.data_charset charset,b.collection_time collectionTime, + b.collector_name collectorName,b.collector_contacts collectorContacts,b.data_year dataYear,a.dst_path dstPath, + a.complete_status completeStatus,a.rate rate, a.lasttime lastTime FROM move_data_tmp a LEFT JOIN data_details b - ON a.system_code = b.system_code AND a.regionalism_code = b.regionalism_code; + ON a.system_code = b.system_code AND a.regionalism_code = b.regionalism_code + ORDER BY a.id @@ -58,19 +68,18 @@ PUBLIC "-//ibatis.apache.org//DTD Mapper 3.0//EN" move_data_tmp - - regionalism_code = #{regionalismCode}, - - - system_code= #{systemCode}, - dst_path= #{dstPath}, complete_status= #{completeStatus}, - rate= #{rate} + + rate= #{rate}, + + + lasttime= #{lastTime}, + @@ -78,7 +87,7 @@ PUBLIC "-//ibatis.apache.org//DTD Mapper 3.0//EN" - + INSERT INTO move_data_tmp( @@ -88,7 +97,7 @@ PUBLIC "-//ibatis.apache.org//DTD Mapper 3.0//EN" regionalism_code, - + system_code, @@ -97,7 +106,12 @@ PUBLIC "-//ibatis.apache.org//DTD Mapper 3.0//EN" complete_status, - rate + + rate, + + + lasttime, + ) VALUES( @@ -117,19 +131,32 @@ PUBLIC "-//ibatis.apache.org//DTD Mapper 3.0//EN" #{completeStatus}, - #{rate} + + #{rate} + + + #{lastTime}, + ) - + + + DELETE FROM move_data_tmp WHERE id = #{id} - - + + + 获取数据查询的起始di + --> \ No newline at end of file diff --git a/src/com/platform/controller/DataModelController.java b/src/com/platform/controller/DataModelController.java index 3db9b91d..d99d34b8 100644 --- a/src/com/platform/controller/DataModelController.java +++ b/src/com/platform/controller/DataModelController.java @@ -1,5 +1,6 @@ package com.platform.controller; +import java.io.UnsupportedEncodingException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -21,15 +22,18 @@ import org.springframework.web.bind.annotation.ResponseBody; import com.base.BaseController; import com.platform.entities.DataInfoEntity; +import com.platform.entities.DataInfoEntityMoveTmp; import com.platform.entities.FolderNode; import com.platform.entities.GatherOracleInfo; import com.platform.entities.PagerOptions; import com.platform.entities.VolumeEntity; import com.platform.service.DataInfoService; import com.platform.service.IGfsService; +import com.platform.service.IMoveDataService; import com.platform.service.IMySqlService; import com.platform.service.IOracleExtractService; import com.platform.service.OracleStatusService; +import com.platform.utils.Bean2MapUtils; import com.platform.utils.Configs; import com.platform.utils.UtilsHelper; @@ -46,6 +50,9 @@ public class DataModelController extends BaseController{ @Resource(name = "OracleExtract") private IOracleExtractService OracleExtract; + + @Resource(name = "moveDataService") + private IMoveDataService moveDataService; public void setDfsImp(DataInfoService dfs) { this.dfs = dfs; @@ -54,11 +61,12 @@ public class DataModelController extends BaseController{ @RequestMapping("/data.json") @ResponseBody public ModelMap getAllDataToJson(HttpServletRequest res, - HttpServletResponse req) { + HttpServletResponse req) throws UnsupportedEncodingException { + res.setCharacterEncoding("UTF-8"); Map paramMap = res.getParameterMap(); Set keySet = paramMap.keySet(); Map params = new HashMap(); - StringBuffer sb = new StringBuffer().append("��ǰ���������:{"); + StringBuffer sb = new StringBuffer().append("当前的请求参数:{"); for (String str : keySet) { String value = paramMap.get(str)[0]; if (StringUtils.isNotEmpty(value)) { @@ -72,19 +80,21 @@ public class DataModelController extends BaseController{ .append("}").toString()); PagerOptions pagerOptions = (PagerOptions) UtilsHelper .newObjAndSetAttrsByClass(PagerOptions.class, params); - + return dfs.getPagerTableData(pagerOptions); } - @RequestMapping("/delete/data") - public void deleteData(HttpServletRequest res, HttpServletResponse req) { + @RequestMapping(value="/delete/data", method= RequestMethod.POST) + public void deleteData(HttpServletRequest res, HttpServletResponse req) throws Exception { + res.setCharacterEncoding("UTF-8"); Map paramMap = res.getParameterMap(); String[] data = paramMap.get("data"); dfs.deleteData(data); } @RequestMapping("/connectOracle") - public void connectOracle(HttpServletRequest res, HttpServletResponse req) { + public void connectOracle(HttpServletRequest res, HttpServletResponse req) throws UnsupportedEncodingException { + res.setCharacterEncoding("UTF-8"); Map paramMap = res.getParameterMap(); String[] oraclesName = paramMap.get("oracleName"); if (oraclesName != null) @@ -96,22 +106,24 @@ public class DataModelController extends BaseController{ @RequestMapping("/cancelOracleConection") public void cancelOracleConnection(HttpServletRequest res, - HttpServletResponse req) { + HttpServletResponse req) throws UnsupportedEncodingException { + res.setCharacterEncoding("UTF-8"); Map paramMap = res.getParameterMap(); String[] oraclesName = paramMap.get("oracleName"); String operate = paramMap.get("operation")[0]; if (null != oraclesName) { for (String rcName : oraclesName) { - Configs.CONSOLE_LOGGER.info("连接成功:\t" + rcName); + Configs.CONSOLE_LOGGER.info("取消连接:\t" + rcName); new OracleStatusService().cancelToOracle(rcName, operate); } } } - @SuppressWarnings({ "unchecked", "unused", "rawtypes" }) - @RequestMapping("/oracle/{name}/extract") + @SuppressWarnings({ "unused", "rawtypes", "unchecked" }) + @RequestMapping(value="/oracle/{name}/extract", method= RequestMethod.POST) public void extractOracleData(HttpServletRequest res, HttpServletResponse req, String name) throws Exception { + res.setCharacterEncoding("UTF-8"); System.out.println("------extract-------"); System.out.println(name); Map paramMap = res.getParameterMap(); @@ -136,7 +148,7 @@ public class DataModelController extends BaseController{ } - @RequestMapping("/volume/list") + @RequestMapping(value="/volume/list", method= RequestMethod.POST) @ResponseBody public List getFolder(HttpServletRequest res, HttpServletResponse req) throws Exception { System.out.println("get Request"); @@ -149,11 +161,12 @@ public class DataModelController extends BaseController{ return result; } - @SuppressWarnings("rawtypes") + @SuppressWarnings({ "unused", "rawtypes" }) @RequestMapping(value = "/volume/{name}/move", method= RequestMethod.POST) @ResponseBody public Object move(HttpServletRequest res, HttpServletResponse req, String name, FolderNode selectNode, DataInfoEntity selectItems) throws Exception { + res.setCharacterEncoding("UTF-8"); System.out.println("get Request"); Map paramMap = res.getParameterMap(); // System.out.println(paramMap); @@ -164,25 +177,32 @@ public class DataModelController extends BaseController{ JSONObject jsonobject = JSONObject.fromObject(string); map = jsonobject; } + String dstVolume = (String) map.get("volume"); + List listItemPath = new ArrayList(); String[] items = paramMap.get("selectItems"); System.out.println("selectItems"); + List datas = new ArrayList(); + List srcVolumes = new ArrayList(); for (String string : items) { System.out.println(string); JSONObject jsobj = JSONObject.fromObject(string); Map itemmap = jsobj; - listItemPath.add((String)itemmap.get("dataPath")); + if (null != itemmap.get("volume")) { + srcVolumes.add((String) itemmap.get("volume")); + } + DataInfoEntity data = (DataInfoEntity) Bean2MapUtils.convertMap(DataInfoEntity.class, itemmap); + datas.add(data); + } + System.out.println("------/volume/{name}/move--------"); + boolean result = false ; + if (datas.size() >0) { + result = moveDataService.moveData(datas, (String)map.get("path")); } - - 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") + @RequestMapping(value="/oracle/list", method= RequestMethod.POST) @ResponseBody public List getOracleInfo(HttpServletRequest res, HttpServletResponse req) throws Exception { @@ -192,30 +212,47 @@ public class DataModelController extends BaseController{ return result; } - @RequestMapping("/oracle/{id}/delete") + @RequestMapping(value="/oracle/{id}/delete", method= RequestMethod.POST) @ResponseBody public void deleteOracleInfo(HttpServletRequest res, HttpServletResponse req, int id) throws Exception { - + res.setCharacterEncoding("UTF-8"); mySqlService.deleteMySql(id); System.out.println("----------deleteOracleInfo-----------------------"); } - @RequestMapping("/oracle/{id}/insert") + @RequestMapping(value="/oracle/{id}/insert", method= RequestMethod.POST) @ResponseBody public void insertOracleInfo(HttpServletRequest res, HttpServletResponse req, GatherOracleInfo oracle) throws Exception { - + res.setCharacterEncoding("UTF-8"); mySqlService.insertOracle(oracle); System.out.println("----------insertOracleInfo-----------------------"); } - @RequestMapping("/oracle/{id}/update") + @RequestMapping(value="/oracle/{id}/update", method= RequestMethod.POST) @ResponseBody public void updateOracleInfo(HttpServletRequest res, HttpServletResponse req, GatherOracleInfo oracle) throws Exception { + res.setCharacterEncoding("gb2312"); + System.out.println(oracle.getName()); + System.out.println(oracle); mySqlService.updateOracle(oracle); System.out.println("----------updateOracleInfo-----------------------"); } + + @RequestMapping(value="/task/transfer/list", method= RequestMethod.POST) + @ResponseBody + public Object taskList() throws Exception { + List result = moveDataService.findAll(); + return result; + } + + @RequestMapping(value="/task/transfer/delete", method= RequestMethod.POST) + @ResponseBody + public Object taskdeletes(DataInfoEntityMoveTmp move) throws Exception { + int result = moveDataService.delete(move); + return result; + } } diff --git a/src/com/platform/controller/DefaultController.java b/src/com/platform/controller/DefaultController.java index 1d738507..631e6b77 100644 --- a/src/com/platform/controller/DefaultController.java +++ b/src/com/platform/controller/DefaultController.java @@ -1,3 +1,4 @@ + package com.platform.controller; import javax.servlet.http.HttpServletRequest; @@ -28,3 +29,4 @@ public class DefaultController { } } + diff --git a/src/com/platform/controller/FolderController.java b/src/com/platform/controller/FolderController.java index 4e817bd4..04254ffb 100644 --- a/src/com/platform/controller/FolderController.java +++ b/src/com/platform/controller/FolderController.java @@ -1,6 +1,7 @@ package com.platform.controller; + import java.util.Date; import java.util.List; @@ -13,11 +14,19 @@ 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; @@ -30,13 +39,19 @@ import com.platform.service.IGfsService; * @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; @@ -47,6 +62,22 @@ public class FolderController extends BaseController { 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 = 0; +// 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 及其 信息 // * <功能详细描述> @@ -77,6 +108,7 @@ public class FolderController extends BaseController { public Object getVolumByName(String volumeName) throws Exception{ VolumeEntity result = gfsService.getOneVolume(volumeName); return result; + } } diff --git a/src/com/platform/controller/SetGlusterfsController.java b/src/com/platform/controller/SetGlusterfsController.java index 481331dd..60b776b0 100644 --- a/src/com/platform/controller/SetGlusterfsController.java +++ b/src/com/platform/controller/SetGlusterfsController.java @@ -17,7 +17,12 @@ import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; /** + + * <一句话功能简述> + + * <一句话功能简述> + * <功能详细描述> * @author liliy * @version [版本号,2016年9月8日] @@ -26,6 +31,7 @@ import org.springframework.web.bind.annotation.RequestMapping; */ @Controller public class SetGlusterfsController { + @RequestMapping("/tes") public Object defaultHandler(HttpServletRequest req, HttpServletResponse request) { //���?ƥ������� @@ -42,4 +48,5 @@ public class SetGlusterfsController { } + } diff --git a/src/com/platform/controller/ShowGlusterfsController.java b/src/com/platform/controller/ShowGlusterfsController.java index 83f6e468..7667bc2b 100644 --- a/src/com/platform/controller/ShowGlusterfsController.java +++ b/src/com/platform/controller/ShowGlusterfsController.java @@ -10,6 +10,7 @@ */ package com.platform.controller; +import java.util.HashMap; import java.util.List; import java.util.Map; @@ -17,9 +18,11 @@ 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日] @@ -28,8 +31,11 @@ import com.platform.glusterfs.ClusterInfo; */ @Controller public class ShowGlusterfsController { + + /** * <一句话功能简述> + * <功能详细描述> * @return * @see [类、类#方法、类#成员] diff --git a/src/com/platform/dao/DataInfoDao.java b/src/com/platform/dao/DataInfoDao.java index f42b9f8f..f8423548 100644 --- a/src/com/platform/dao/DataInfoDao.java +++ b/src/com/platform/dao/DataInfoDao.java @@ -3,10 +3,12 @@ package com.platform.dao; import java.util.List; 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); @@ -15,6 +17,10 @@ public interface DataInfoDao { List getLimitedDataInfoEntities(@Param("PagerOptions")PagerOptions pagerOptions); - List getIdIsExist(int parseInt); + List getIdIsExist(List list)throws Exception; + + int removes(List list)throws Exception; + + int save(DataInfoEntity data) throws Exception; } diff --git a/src/com/platform/dao/DataInfoMoveTmpDao.java b/src/com/platform/dao/DataInfoMoveTmpDao.java index 6d6a1d6a..096d8938 100644 --- a/src/com/platform/dao/DataInfoMoveTmpDao.java +++ b/src/com/platform/dao/DataInfoMoveTmpDao.java @@ -23,6 +23,7 @@ public interface DataInfoMoveTmpDao { int save(DataInfoEntityMoveTmp data) throws Exception; - int remove(DataInfoEntityMoveTmp data) throws Exception; + void insertBatch(List list) throws Exception; + int remove(int id) throws Exception; } diff --git a/src/com/platform/entities/Brick.java b/src/com/platform/entities/Brick.java index 06a8e9c4..e6701dab 100644 --- a/src/com/platform/entities/Brick.java +++ b/src/com/platform/entities/Brick.java @@ -1,93 +1,110 @@ - -/** - * 文件名 : 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; - } - - -} + +/** + * 文件名 : 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; + + /** + * true 有连接, false: 失去连接 + */ + private boolean status; + + /** + * @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; + } + + /** + * @return the status + */ + public boolean isStatus() { + return status; + } + + /** + * @param status the status to set + */ + public void setStatus(boolean status) { + this.status = status; + } +} diff --git a/src/com/platform/entities/DataInfoEntityMoveTmp.java b/src/com/platform/entities/DataInfoEntityMoveTmp.java index 74be9e5d..0fb469e5 100644 --- a/src/com/platform/entities/DataInfoEntityMoveTmp.java +++ b/src/com/platform/entities/DataInfoEntityMoveTmp.java @@ -7,6 +7,12 @@ public class DataInfoEntityMoveTmp extends DataInfoEntity { private String completeStatus; private int rate; + + private String lastTime; // 采集时间 + + public DataInfoEntityMoveTmp() { + // TODO Auto-generated constructor stub + } /** * @return the dstPath @@ -49,6 +55,19 @@ public class DataInfoEntityMoveTmp extends DataInfoEntity { public void setRate(int rate) { this.rate = rate; } - + + /** + * @return the lastTime + */ + public String getLastTime() { + return lastTime; + } + + /** + * @param lastTime the lastTime to set + */ + public void setLastTime(String lastTime) { + this.lastTime = lastTime; + } } diff --git a/src/com/platform/entities/FolderNode.java b/src/com/platform/entities/FolderNode.java index 8f584d77..5a9a56b7 100644 --- a/src/com/platform/entities/FolderNode.java +++ b/src/com/platform/entities/FolderNode.java @@ -1,16 +1,19 @@ package com.platform.entities; +import java.util.ArrayList; 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 childNodes; + private List childNodes = new ArrayList(); + public FolderNode() { // TODO Auto-generated constructor stub } + public FolderNode(String name) { this.name = name; diff --git a/src/com/platform/entities/VolumeEntity.java b/src/com/platform/entities/VolumeEntity.java index 84455003..f66670d4 100644 --- a/src/com/platform/entities/VolumeEntity.java +++ b/src/com/platform/entities/VolumeEntity.java @@ -37,7 +37,7 @@ public class VolumeEntity { private String path; /** volume树形目录 */ - private FolderNode folder; + private List folder = new ArrayList(); /** volume的 块 */ private List brick = new ArrayList(); @@ -101,14 +101,14 @@ public class VolumeEntity { /** * @return the folder */ - public FolderNode getFolder() { + public List getFolder() { return folder; } /** * @param folder the folder to set */ - public void setFolder(FolderNode folder) { + public void setFolder(List folder) { this.folder = folder; } diff --git a/src/com/platform/glusterfs/CheckoutMD5.java b/src/com/platform/glusterfs/CheckoutMD5.java new file mode 100644 index 00000000..d0be3dad --- /dev/null +++ b/src/com/platform/glusterfs/CheckoutMD5.java @@ -0,0 +1,106 @@ +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 source_md5 = new HashMap(); + Map dest_md5 = new HashMap(); + + 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 wrong_files = new ArrayList(); + String source_cmd = "find " + sourcePath + " -type f -print0 | xargs -0 md5sum"; + String dest_cmd = "find " + destPath + " -type f -print0 | xargs -0 md5sum"; + List 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 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 source_md5 = new HashMap(); + Map dest_md5 = new HashMap(); + 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 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")); + } +} diff --git a/src/com/platform/glusterfs/ClusterInfo.java b/src/com/platform/glusterfs/ClusterInfo.java index 55674f56..add5e191 100644 --- a/src/com/platform/glusterfs/ClusterInfo.java +++ b/src/com/platform/glusterfs/ClusterInfo.java @@ -1,110 +1,124 @@ -package com.platform.glusterfs; - - - -import java.io.File; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -import org.apache.log4j.Logger; -import org.apache.log4j.PropertyConfigurator; - -import com.platform.utils.Constant; - -/** - * 获取集群节点信息 - * 如果获取不正常,则返回null,如果获取正常,返回map表示节点ip和ip的状态 - * 如果ip在集群中且联通状态为PeerinCluster(Connected) - * 如果ip在集群中且但不连通为PeerinCluster(Disconnected) - * @author liliy - * @version [版本号,2016年9月12日] - * @see [相关类/方法] - * @since [产品/模块版本] - */ -public class ClusterInfo { - public static Logger log = Logger.getLogger(ClusterInfo.class); - - public Map showClusterInfo() { - log.info("get cluster info"); - Map peerIps = new HashMap(); - - List reStrings = Constant.ganymedSSH.execCmdWait(Constant.hostIp, Constant.rootUser, Constant.rootPasswd, Constant.port, Constant.glusterPeerStatus); - if (reStrings == null) { - log.error("1101 command get result is null"); - return null; - } - if (reStrings.size() == 0) { - log.error("1102 command get result is nothing"); - return null; - } - - if (!(reStrings.get(0).split(":")[0].contains("Number of Peers"))) { - - log.error("1103 get result string wrong"); - return null; - } - - - // System.out.print(reStrings.get(0)); - - int flag = 0; - String ipString = ""; - String state = ""; - for (Iterator it2 = reStrings.iterator(); it2.hasNext();) { - String line = (String) it2.next(); - line=line.replaceAll(" +", " "); - String keyValue[] = line.split(":"); - if (keyValue[0].equals("Hostname")) { - - if (keyValue.length < 2) { - log.error("1105 command get result is wrong"); - continue; - } - - ipString = keyValue[1].replaceAll(" ", ""); - flag = 1; - } else if (flag == 1 && keyValue[0].equals("State")) { - - if (keyValue.length < 2) { - log.error("1106 command get result is wrong"); - continue; - } - - state = keyValue[1].replaceAll(" ", ""); - flag = 0; - peerIps.put(ipString, state); - } - - } - return peerIps; - } - - /** - * 根据给定的ip获的ip的状态,即是否在集群中并联通 - * 如果ip不在集群中,返回null - * 如果ip在集群中且联通状态为PeerinCluster(Connected) - * 如果ip在集群中且但不连通为PeerinCluster(Disconnected) - * @param peerip - * @return - * @see [类、类#方法、类#成员] - */ - public String getPeerStatus(String peerip){ - Map peerIps=showClusterInfo(); - if(peerIps==null || peerIps.size()==0){ - return null; - } - if(!peerIps.containsKey(peerip)){ - return Constant.peerincluster_disconnected; - } - return peerIps.get(peerip); - } - - - public static void main(String[] args) { - PropertyConfigurator.configure("log4j.properties"); - System.out.println(new ClusterInfo().showClusterInfo()); - } -} + + +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 showClusterInfo() { + log.info("get cluster info"); + Map peerIps = new HashMap(); + + List 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 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")); + } +} + + diff --git a/src/com/platform/glusterfs/CopyData.java b/src/com/platform/glusterfs/CopyData.java index 6fd1e357..86289174 100644 --- a/src/com/platform/glusterfs/CopyData.java +++ b/src/com/platform/glusterfs/CopyData.java @@ -1,3 +1,4 @@ + package com.platform.glusterfs; import java.util.List; @@ -32,7 +33,7 @@ public class CopyData { String sourceFolderName = sourceVolumeName; String destFolderName = destVolumeName; - status = copyFolderFiles(sourceFolderName, destFolderName, fileName); + status = copyFolderFilesAnyway(sourceFolderName, destFolderName, fileName); return status; } @@ -54,7 +55,7 @@ public class CopyData { return -3; } - reStrings=showData.showFolderData(sourceFolderName+"/"+fileName); + reStrings=showData.showFolderData(sourceFolderName+"/"+fileName); if(reStrings==null){ log.info("3202 "+sourceFolderName+"/"+fileName+" is not exists"); return -2; @@ -71,10 +72,40 @@ public class CopyData { return 1; } + /** 不管目的路径存在与否,强制拷贝 + * @param sourceFolderName + * @param destFolderName + * @param fileName + * @return + */ + public int copyFolderFilesAnyway(String sourceFolderName, String destFolderName, String fileName) { + createFolders(destFolderName); + int result = copyFolderFiles(sourceFolderName, destFolderName, fileName); + return result; + } + + 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() { - PropertyConfigurator.configure("log4j.properties"); + copyFolderFiles("/home", "/home/ubuntu", "system_data"); } } + + diff --git a/src/com/platform/glusterfs/GetTreeData.java b/src/com/platform/glusterfs/GetTreeData.java index c7a6018d..81f3ba5b 100644 --- a/src/com/platform/glusterfs/GetTreeData.java +++ b/src/com/platform/glusterfs/GetTreeData.java @@ -1,120 +1,125 @@ -package com.platform.glusterfs; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import org.junit.Test; - -import com.platform.entities.FolderNode; -import com.platform.utils.Constant; -import com.platform.utils.FileOperateHelper; - -/** - * <一句话功能简述> 获得GFS某个目录下的子目录 - * <功能详细描述> - * @author chen - * @version [版本号,2016年9月8日] - * @see [相关类/方法] - * @since [产品/模块版本] - */ -public class GetTreeData { - ShowData showData = new ShowData(); - - /** - * <一句话功能简述> 获得所以子目录 - * <功能详细描述> - * @param name - * @return - * @see [类、类#方法、类#成员] - */ - public FolderNode getDatas(String name) { - String names[]=name.split("/"); - String only_name=names[names.length-1]; - FolderNode fileNode = new FolderNode(only_name); - fileNode.setPath(name); - Map files = showData.showFolderData(name); - if(files==null || files.size()==0){ - return fileNode; - } - fileNode.setIsFolder(files.size()); - List list = new ArrayList(); - fileNode.setChildNodes(list); - for (Map.Entry entry : files.entrySet()) { - if(entry.getKey().equals("app")){ - continue; - } - int number = Integer.parseInt(entry.getValue()); - if (number == 1) { - fileNode.getChildNodes().add(new FolderNode(entry.getKey(), number)); - } - if (number > 1) { - FolderNode temp=getDatas(name+"/"+entry.getKey()); - fileNode.getChildNodes().add(temp); - } - } - - return fileNode; - } - - /** - * <一句话功能简述> 获得所以子目录 - * <功能详细描述> - * @param name - * @return - * @see [类、类#方法、类#成员] - */ - public FolderNode getDatasWithShell(String name) { - if(name.endsWith("/")){ - name=name.substring(0, name.length()); - } - String names[]=name.split("/"); - String only_name=names[names.length-1]; - FolderNode fileNode = new FolderNode(name); - fileNode.setPath(name); - - String shellComment=new FileOperateHelper().fileReaderAndendline(Constant.fileGetTreeData); - String sh_path="/getTreedata.sh"; - String cmd="echo -e "+shellComment+" > "+sh_path+" & chmod +x "+sh_path; - Constant.ganymedSSH.execCmdWaitAcquiescent(cmd); -// Map files = showData.showFolderData(name); - List files=Constant.ganymedSSH.execCmdWaitAcquiescent(sh_path+" "+name); - if(files==null){ - return null; - } - if(files.size()==0){ - return fileNode; - } - for(String file:files){ - - } - - return fileNode; - } - @Test - public void test_getTreeData() { - - GetTreeData getTreeData=new GetTreeData(); - FolderNode fileOrFolder=getTreeData.getDatas("/home"); - System.out.println(fileOrFolder); - } -} -/* -class FileOrFolder { - String name; - int isFolder; // 1 is file and other integer is folder show children number - List children; - - public FileOrFolder(String name) { - // TODO Auto-generated constructor stub - this.name = name; - } - - public FileOrFolder(String name, int isFolder) { - // TODO Auto-generated constructor stub - this.name = name; - this.isFolder = isFolder; - } -} - -*/ + + +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 files = showData.showFolderData(name); + if(files==null || files.size()==0){ + return fileNode; + } + fileNode.setIsFolder(files.size()); + List list = new ArrayList(); + fileNode.setChildNodes(list); + for (Map.Entry entry : files.entrySet()) { + if(entry.getKey().equals("app")){ + continue; + } + int number = Integer.parseInt(entry.getValue()); + if (number == 1) { + fileNode.getChildNodes().add(new FolderNode(entry.getKey(), number)); + } + if (number > 1) { + FolderNode temp=getDatas(name+"/"+entry.getKey()); + fileNode.getChildNodes().add(temp); + } + } + + return fileNode; + } + + + /** + * <一句话功能简述> 获得所以子目录 + * <功能详细描述> + * @param name + * @return + * @see [类、类#方法、类#成员] + */ + public FolderNode getDatasWithShell(String name) { + if(name.endsWith("/")){ + name=name.substring(0, name.length()-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 files = showData.showFolderData(name); + List files=Constant.ganymedSSH.execCmdWaitAcquiescent(sh_path+" "+name); + if(files==null){ + return null; + } + if(files.size()==0){ + return fileNode; + } + for(String file:files){ + + } + + return fileNode; + } + @Test + public void test_getTreeData() { + + GetTreeData getTreeData=new GetTreeData(); +// FolderNode fileOrFolder=getTreeData.getDatas("/home/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 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; + } +} + +*/ diff --git a/src/com/platform/glusterfs/RemoveData.java b/src/com/platform/glusterfs/RemoveData.java index 2297ed03..6f854b26 100644 --- a/src/com/platform/glusterfs/RemoveData.java +++ b/src/com/platform/glusterfs/RemoveData.java @@ -16,17 +16,7 @@ import com.platform.utils.Constant; public class RemoveData { public static Logger log = Logger.getLogger ( RemoveData.class); - public int deleteVolumeFiles(String volumeName,String fileName){ - log.info("start delete "+volumeName+" "+fileName); - int status=-1; - /** - * get mount point of volumeName - */ - String folderName=volumeName; - - status=deleteFolderFiles(folderName,fileName); - return status; - } + /** * -1 :error; 0: the filename is not exists ; 1: right @@ -34,65 +24,33 @@ public class RemoveData { * @param fileName * @return */ - public int deleteFolderFiles(String folderName,String fileName){ - log.info("start delete "+folderName+"/"+fileName); + public int deleteFolder(String folderName){ + log.info("start delete "+folderName); ShowData showData=new ShowData(); - Map reStrings=showData.showFolderData(folderName+"/"+fileName); + Map reStrings=showData.showFolderData(folderName); if(reStrings==null){ - log.error("3301 "+folderName+"/"+fileName+" is not exists"); + log.error("3301 "+folderName+" is not exists"); return -1; } - String command="rm -r "+folderName+"/"+fileName; + String command="rm -r "+folderName; // int status=runCommand.runCommand(command); Constant.ganymedSSH.execCmdNoWaitAcquiescent(command); - log.info("delete "+folderName+" "+fileName+" running"); + log.info("delete "+folderName+" running"); return 1; } - public int getFolderSize(String name) { - log.info("get "+name+" size"); - String command="du -k -d 0 "+name; - /* - * RunCommand runCommand=new RunCommand(); - - List reStrings=runCommand.runCommandWait(command); - */ - List reStrings=Constant.ganymedSSH.execCmdWaitAcquiescent(command); - - if(reStrings==null){ - log.error("3302 the "+command+" return error"); - return -1; - } - if(reStrings.size()<1){ - log.error("3303 the "+command+" return error"); - return -1; - } - - if(reStrings.size()==1 && reStrings.get(0).contains("No such file or directory")){ - log.info("3304 "+name+" is not exists"); - return 0; - } - String strSize=(reStrings.get(0).split("\t"))[0]; - int size=Integer.parseInt(strSize); - log.info(name +" size is "+size); - return size; - } -// @Test - public void test_getFolderSize() { - PropertyConfigurator.configure("log4j.properties"); - getFolderSize("/home/ubuntu"); - } + @Test public void testDeleteFolderFiles() { PropertyConfigurator.configure("log4j.properties"); - deleteFolderFiles("/home/ubuntu","system_data"); + deleteFolder("/home/ubuntu"); } } diff --git a/src/com/platform/glusterfs/SetCluster.java b/src/com/platform/glusterfs/SetCluster.java index bd556377..8f260e5a 100644 --- a/src/com/platform/glusterfs/SetCluster.java +++ b/src/com/platform/glusterfs/SetCluster.java @@ -1,11 +1,67 @@ -package com.platform.glusterfs; - -import org.apache.log4j.Logger; - -public class SetCluster { - public static Logger log = Logger.getLogger ( SetCluster.class); - - public int addPeer(String peerip){ - return 0; - } -} + +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 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 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; + } +} + diff --git a/src/com/platform/glusterfs/SetVolume.java b/src/com/platform/glusterfs/SetVolume.java index d1517011..5502aaee 100644 --- a/src/com/platform/glusterfs/SetVolume.java +++ b/src/com/platform/glusterfs/SetVolume.java @@ -1,498 +1,511 @@ - -/** - * @author 李乾坤 - * 进行volume的一系列操作,如创建、开启停止volume,为volume添加或删除brick - */ -package com.platform.glusterfs; - - - -import java.io.File; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -import org.apache.log4j.Logger; -import org.apache.log4j.PropertyConfigurator; - -import com.platform.utils.Constant; - - - -public class SetVolume { - public static Logger log = Logger.getLogger(SetVolume.class); - - /* - * 创建volume 返回值:创建并挂载成功 1 - * - */ - public int createVolume(String volumeName, int count, String type, List bricks, String mountPoint) { - log.info("Creat new volume"); - - // 判断创建volume的条件是否满足 - int able = isAbleCreateVolume(volumeName, count, type, bricks, mountPoint); - - if (able == 1) { - String command = null; - // 将brics从List变量中提取出来并连接成可以在命令行中使用的格式 - String commandarg = concat(bricks); - - /* - * verify the type - */ - if (type.equals(Constant.distributed)) { - command = "gluster volume create " + volumeName + " " + commandarg + "force"; - } else if (type.equals(Constant.replica) || type.equals(Constant.stripe)) { - command = "gluster volume create " + volumeName + " " + type + " " + count + " " + commandarg + "force"; - } - - // 执行命令 - List reStrings = Constant.ganymedSSH.execCmdWait(Constant.hostIp, Constant.rootUser, Constant.rootPasswd, - Constant.port, command); - - // 创建成功时返回信息格式:volume create: volumename success: - if (reStrings == null || reStrings.size() == 0) { - log.error("3106 " + command + " run return error"); - return -7; - } - if (reStrings.get(0).contains("volume create: " + volumeName + ": " + "success:")) { - log.info("create volume "+volumeName+" successed!"); - // 创建成功则启动并进行挂载 - if (startVolume(volumeName) == 0) { - log.info("start volume "+volumeName+" successed!"); - if ((new ShowData().showFolderData(mountPoint)) == null) { - Constant.ganymedSSH.execCmdWaitAcquiescent("mkdir " + mountPoint); - } - // 进行挂载 - String command3 = "mount -t glusterfs " + Constant.hostIp + ":/" + volumeName + " " + mountPoint; - List reStrings3 = Constant.ganymedSSH.execCmdWait(Constant.hostIp, Constant.rootUser, - Constant.rootPasswd, Constant.port, command3); - - // 这里需要添加解析挂载命令返回字符串的语句,由于我的系统有问题,导致挂载成功后返回WARNING: getfattr - // not found, certain checks will be skipped.. - // 所以这句代码未经测试 - // 成功挂载时没有任何返回信息 - if (reStrings3.size() == 0 || reStrings.get(0).contains("GlusterFS is already mounted")) - { - log.info("mount point successed!"); - return 1; - } - } - } else { - log.error("3104 volume create failed with error" + reStrings.get(0)); - // System.out.println(reStrings.get(0)); - return -7; - } - return 1; - } else { - log.error("给出的参数不满足创建条件"); - // System.out.println("给出的参数不满足创建条件"); - return able; - } - - } - - /** - * 删除volume - * - * @param volumeName - * @return 1 表示成功 ;-1表示volume name不存在;-2表示停止volume 失败 - */ - public int deleteVolume(String volumeName) { - int status = 0; - List volumeNames = new VolumeInfo().showAllVolumeName(); - if (!volumeNames.contains(volumeName)) { - log.error("3801 " + volumeName + " is not exists !"); - return -1; - } - - List mountPoints = new VolumeInfo().getVolumeMountPoint(volumeName); - if (stopVolume(volumeName) != 0) { - log.error("3802 " + volumeName + " stop failed !"); - return -2; - } - log.info("stop "+volumeName+" successed!"); - if (null == mountPoints) { - return -2; - } - for(String mountPoint:mountPoints){ - if (mountPoint != null) { - String command = "umount -l " + mountPoint; - Constant.ganymedSSH.execCmdNoWaitAcquiescent(command); - log.info("umount "+mountPoint+" successed!"); - } - } - String command="echo -e \"y\"| gluster volume delete "+volumeName; - List reStrings=Constant.ganymedSSH.execCmdWaitAcquiescent(command); - if(reStrings==null || reStrings.size()>0 || !(reStrings.get(0).contains("volume delete: "+volumeName+": success"))){ - log.error("3803 : delete volume "+volumeName+" failed !"); - return -3; - } - log.info("delete "+volumeName+" successed!"); - return 1; - } - - /* - * 为指定的volume添加brick,参数中需要指定类型、数量等 返回值:1成功 ;其他失败 - * 过程中需要先检查volume是否存在,还需检查给出的brick数量与类型、count是否相符 - */ - public int addBrickVolume(String volumeName, List brickName, int count, String type) { - // 检查是否满足添加bricks的条件 - int able = isAble(volumeName, count, type, brickName); - if (able != 1) { - return able; - } - - String command = ""; - log.info("add brick to the specified volume"); - - String brick = concat(brickName); - - if (type.equals(Constant.distributed)) - command = "gluster volume add-brick " + volumeName + " " + brick + "force"; - else if (type.equals(Constant.replica)) - command = "gluster volume add-brick " + volumeName + " " + "replica " + count + " " + brick + "force"; - else if (type.equals(Constant.stripe)) - command = "gluster volume add-brick " + volumeName + " " + "stripe " + count + " " + brick + "force"; - - List reStrings = Constant.ganymedSSH.execCmdWait(Constant.hostIp, Constant.rootUser, Constant.rootPasswd, - Constant.port, command); - - // 添加成功的返回信息是:volume add-brick: success - if (reStrings != null && reStrings.size() > 0 && reStrings.get(0).contains("volume add-brick: success")) { - log.info("添加brick成功!"); - return 1; - } else { - log.error("3205 add brick failed,please check the system"); - // System.out.println("3202 add brick failed,please check the system"); - return -5; - } - } - - /* - * 为指定的volume删除brick,参数中需要指定类型、数量等 返回值:1 成功 ;其他 失败 - * 过程中需要先检查volume是否存在,还需检查给出的brick数量与类型、count是否相符 - */ - public int deleteBrickVolume(String volumeName, List brickName, int count, String type) { - int able = isAble(volumeName, count, type, brickName); - - if (able != 1) { - return able; - } - String command = null; - - log.info("delete brick of the specified volume"); - - String brick = concat(brickName); - - if (type.equals(Constant.distributed)) { - command = "echo -e \"y\" | gluster volume remove-brick " + volumeName + " " + brick + " force"; - } else if (type.equals(Constant.replica)) { - command = "echo -e \"y\" | gluster volume remove-brick " + volumeName + " repli " + count + " " + brick - + " force"; - } else if (type.equals(Constant.stripe)) { - command = "echo -e \"y\" | gluster volume remove-brick " + volumeName + " stripe " + count + " " + brick - + " force"; - } - - if (command == null) { - log.error("3305 remove brick failed,please check the system"); - return -5; - } - log.info("即将执行删除命令"); - List reStrings = Constant.ganymedSSH.execCmdWait(Constant.hostIp, Constant.rootUser, Constant.rootPasswd, - Constant.port, command); - // System.out.println(reStrings); - log.info("删除命令执行完毕"); - - // 删除成功的返回信息是“volume remove-brick: success” - if (reStrings.get(0).contains("volume remove-brick: success")) { - { - log.info("删除brick成功"); - return 1; - } - } else { - log.error("3305 remove brick failed,please check the system"); - - return -5; - } - - } - - /* - * 停止指定volume 参数中需给出volume的名字 返回值: 0 成功 -1 失败 - * 需要先检查volume是否存在,然后判断volume的状态是否已经是停止状态 - */ - public int stopVolume(String volumeName) { - log.info("stop volume"); - - // 首先需要判断volume是否存在,调用其他函数返回所有volume的名字 - boolean volumeExist = false; - - List volume = new VolumeInfo().showAllVolumeName(); - for (String temp : volume) { - if (temp.equals(volumeName)) { - volumeExist = true; - break; - } - } - - if (!volumeExist) { - // volume不存在 - log.error("3501 the volume doesnot exist"); - System.out.println("3501 the volume doesnot exist"); - return -1; - } else { - // volume存在,则需判断volume的状态是否已经为“stop” - if (new VolumeInfo().getVolumeStatus(volumeName).equals("Stopped")) { - log.error("3502 the volume is already stoped"); - System.out.println("3502 the volume is already stoped"); - return -1; - } else { - String command = "echo -e \"y\"| gluster volume stop " + volumeName; - List reStrings = Constant.ganymedSSH.execCmdWait(Constant.hostIp, Constant.rootUser, Constant.rootPasswd, - Constant.port, command); - - // 标记操作结果:operation = 1 操作成功 - // operation = 0 操作失败 - int operation = 0; - for (String temp2 : reStrings) { - if (temp2.contains("volume stop: " + volumeName + ": " + "success")) { - operation = 1; - break; - } - System.out.println("operation: " + operation); - } - - if (operation == 1) { - return 0; - } else { - log.error("3503 stop " + volumeName + " failed"); - System.out.println("3503 stop " + volumeName + " failed"); - return -1; - } - - } - } - } - - /* - * 开启指定volume 参数中需给出volume的名字 返回值: 0 成功 -1 失败 - * 需要先检查volume是否存在,然后判断volume的状态是否已经是开启状态 - */ - public int startVolume(String volumeName) { - log.info("start volume"); - boolean volumeExist = false; - List volume = new VolumeInfo().showAllVolumeName(); - - for (String temp : volume) { - if (temp.equals(volumeName)) { - volumeExist = true; - break; - } - } - - if (volumeExist) { - if (!(new VolumeInfo().getVolumeStatus(volumeName).equals("Started"))) { - String command = "gluster volume start " + volumeName; - - int operation = 0; - - // 执行命令 - List reStrings = Constant.ganymedSSH.execCmdWait(Constant.hostIp, Constant.rootUser, Constant.rootPasswd, - Constant.port, command); - for (String temp2 : reStrings) { - if (temp2.equals("volume start: " + volumeName + ": " + "success")) { - operation = 1; - } - } - - if (operation == 1) { - return 0; - } else { - log.error("3602 start volume failed"); - System.out.println("3602 start volume failed"); - return -1; - } - } else { - log.error("volume已经开启"); - System.out.println("volume已经开启"); - return -1; - } - } else { - log.error("3601 the volume does not exist"); - // System.out.println("3601 the volume does not exist"); - return -1; - } - } - - // 需要将存于List变量中的brick的位置组装成可以在glusterfs命令行中直接使用的格式 - public String concat(List brickName) { - StringBuffer result = new StringBuffer(); - int len = brickName.size(); - for (int i = 0; i < len; i++) { - result.append(brickName.get(i)); - result.append(" "); - } - return result.toString(); - } - - /* - * 只在创建volume时使用此函数 创建volume时对不同数据卷,brick的数量需要满足和count的关系 - * 首先判断它们是否满足关系,在不满足的关系的情况下是肯定无法完成操作的 1:可以创建 ;-1:brick的ip不在集群中或者未连接; -2 -3 - * -4 :类型与brick数目不匹配 ; -5 :volumeName 已经存在;-6:挂载点存在且不为空,不能作为挂载点; -7:未知错误 - */ - public int isAbleCreateVolume(String volumeName, int count, String type, List bricks, String mountPoint) { - int status = 0; - - int length = bricks.size(); - - if (type.equals(Constant.distributed)) { - if (count != 0) { - log.error("3101 the kind of distributed requires the arg of count to be 0"); - return -2; - } - } - if (type.equals(Constant.stripe)) { - if (length % count != 0) { - log.error("3102 the number of bricks should be the same as or the times of the stripe count"); - return -3; - } - } - if (type.equals(Constant.replica)) { - if ((length % count) != 0) { - log.error( - "3103 the number of bricks should be the same as the replicate count or the times of replicate count"); - return -4; - } - } - - Map peer_status = new ClusterInfo().showClusterInfo(); - peer_status.put(Constant.hostIp, Constant.peerincluster_connected); - for (String brick : bricks) { - brick = brick.split(":")[0]; - if (!(peer_status.containsKey(brick) && peer_status.get(brick).equals(Constant.peerincluster_connected))) { - log.error("3105 birck " + brick + " ip is not in cluster"); - return -1; - } - - } - - List volumeNames = new VolumeInfo().showAllVolumeName(); - if(volumeNames==null){ - log.error("3108 showAllVolumeName return error"); - return -7; - } - if (volumeNames.contains(volumeName)) { - log.error("3106 " + volumeName + " is already exists! "); - return -5; - } - - Map datas = new ShowData().showFolderData(mountPoint); - if (datas != null && datas.size() > 0) { - log.error("3107 " + mountPoint + " is not exists or not empty ! "); - return -6; - } - return 1; - } - - /** - * 添加或删除volume的brick时,首先需要判断volume是否存在,然后需要判断volume类型、count及brick数目 - * - * @param volumeName - * @param count - * @param type - * @param bricks - * @return 1 满足条件,可以添加;-1 :volume name is not exists;-2,-3,-4 类型与brick数量不匹配; - */ - public int isAble(String volumeName, int count, String type, List bricks) { - List volumeNames = new VolumeInfo().showAllVolumeName(); - - if (!volumeNames.contains(volumeName)) { - log.error("3201:" + volumeName + " is not exists! "); - return -1; - } - - int length = bricks.size(); - if (type.equals("distribute")) { - if (count == 0) - return 1; - else { - log.error("3202: the kind of distributed requires the arg of count to be 0"); - // System.out.println(" the kind of distributed requires the - // arg of count to be 0"); - return -2; - } - } - - if (type.equals("stripe")) { - if (length % count == 0) - return 1; - else { - log.error("3203: the number of bricks should be the same as or the times of the stripe count"); - // System.out.println(" the number of bricks should be the - // same as or the times of the stripe count"); - return -3; - - } - } - if (type.equals("replicate")) { - if ((length % count) == 0) - return 1; - else { - log.error( - "3204: the number of bricks should be the same as the replicate count or the times of replicate count"); - - return -4; - } - } - - return 1; - } - - public static void main(String[] args) { - SetVolume setVolume = new SetVolume(); - int operation = 0; - PropertyConfigurator.configure("log4j.properties"); - // TODO Auto-generated method stub - // 测试创建volume的代码 - - List bricksToCreate = new ArrayList(); - bricksToCreate.add("192.168.0.110:/v1"); - bricksToCreate.add("192.168.0.116:/v1"); - operation = setVolume.createVolume("v1", 0, "distributed", bricksToCreate, "/home/v1_point"); -// operation = setVolume.deleteVolume("v3"); - // - // // 以下是测试添加brick的代码 - // - // List bricksToAdd = new ArrayList(); - // bricksToAdd.add("192.168.191.23:/v3"); - // operation = setVolume.addBrickVolume("v3", bricksToAdd, 0, - // "distribute"); - // System.out.println(operation); - - // 以下代码是测试删除brick的代码 - // List bricksToAdd= new ArrayList(); - // bricksToAdd.add("192.168.191.23:/v3"); - // operation = - // setVolume.deleteBrickVolume("v3",bricksToAdd,0,"distribute"); - // System.out.println(operation); - // 以下是测试start volume的代码 - // String volumeToStart = "testcreate" ; - // int startOperation = startVolume(volumeToStart); - // System.out.println(startOperation); - // 以下是测试stop volume - String volumeToStop = "v3"; - // int startOperation = setVolume.stopVolume(volumeToStop); - // 以下是测试创建volume并完成挂载的代码 - // List bricksToCreate= new ArrayList(); - // bricksToCreate.add("192.168.214.135:/home/create"); - // bricksToCreate.add("192.168.214.138:/home/create"); - // - // int operation = - // createVolume("createAndmount",0,"distribute",bricksToCreate,"/mnt/create"); - // System.out.println(operation); - } -} + + +/** + * @author 李乾坤 + * 进行volume的一系列操作,如创建、开启停止volume,为volume添加或删除brick + */ +package com.platform.glusterfs; + + + +import java.io.File; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import org.apache.log4j.Logger; +import org.apache.log4j.PropertyConfigurator; + +import com.platform.utils.Constant; + + + +public class SetVolume { + public static Logger log = Logger.getLogger(SetVolume.class); + + /* + * 创建volume 返回值:创建并挂载成功 1 + * + */ + public int createVolume(String volumeName, int count, String type, List bricks, String mountPoint) { + log.info("Creat new volume"); + + // 判断创建volume的条件是否满足 + int able = isAbleCreateVolume(volumeName, count, type, bricks, mountPoint); + + if (able == 1) { + String command = null; + // 将brics从List变量中提取出来并连接成可以在命令行中使用的格式 + String commandarg = concat(bricks); + + /* + * verify the type + */ + if (type.equals(Constant.distributed)) { + command = "gluster volume create " + volumeName + " " + commandarg + "force"; + } else if (type.equals(Constant.replica) || type.equals(Constant.stripe)) { + command = "gluster volume create " + volumeName + " " + type + " " + count + " " + commandarg + "force"; + } + + // 执行命令 + List reStrings = Constant.ganymedSSH.execCmdWait(Constant.hostIp, Constant.rootUser, Constant.rootPasswd, + Constant.port, command); + + // 创建成功时返回信息格式:volume create: volumename success: + if (reStrings == null || reStrings.size() == 0) { + log.error("3106 " + command + " run return error"); + return -7; + } + if (reStrings.get(0).contains("volume create: " + volumeName + ": " + "success:")) { + log.info("create volume "+volumeName+" successed!"); + // 创建成功则启动并进行挂载 + if (startVolume(volumeName) == 0) { + log.info("start volume "+volumeName+" successed!"); + if ((new ShowData().showFolderData(mountPoint)) == null) { + Constant.ganymedSSH.execCmdWaitAcquiescent("mkdir " + mountPoint); + } + // 进行挂载 + String command3 = "mount -t glusterfs " + Constant.hostIp + ":/" + volumeName + " " + mountPoint; + List reStrings3 = Constant.ganymedSSH.execCmdWait(Constant.hostIp, Constant.rootUser, + Constant.rootPasswd, Constant.port, command3); + + // 这里需要添加解析挂载命令返回字符串的语句,由于我的系统有问题,导致挂载成功后返回WARNING: getfattr + // not found, certain checks will be skipped.. + // 所以这句代码未经测试 + // 成功挂载时没有任何返回信息 + if (reStrings3.size() == 0 || reStrings.get(0).contains("GlusterFS is already mounted")) + { + log.info("mount point successed!"); + return 1; + } + } + } else { + log.error("3104 volume create failed with error" + reStrings.get(0)); + // System.out.println(reStrings.get(0)); + return -7; + } + return 1; + } else { + log.error("给出的参数不满足创建条件"); + // System.out.println("给出的参数不满足创建条件"); + return able; + } + + } + + /** + * 删除volume + * + * @param volumeName + * @return 1 表示成功 ;-1表示volume name不存在;-2表示停止volume 失败 + */ + public int deleteVolume(String volumeName) { + int status = 0; + List volumeNames = new VolumeInfo().showAllVolumeName(); + if (!volumeNames.contains(volumeName)) { + log.error("3801 " + volumeName + " is not exists !"); + return -1; + } + + List mountPoints = new VolumeInfo().getVolumeMountPoint(volumeName); + if (stopVolume(volumeName) != 0) { + log.error("3802 " + volumeName + " stop failed !"); + return -2; + } + log.info("stop "+volumeName+" successed!"); + for(String mountPoint:mountPoints){ + if (mountPoint != null) { + String command = "umount -l " + mountPoint; + Constant.ganymedSSH.execCmdNoWaitAcquiescent(command); + log.info("umount "+mountPoint+" successed!"); + } + } + String command="echo -e \"y\"| gluster volume delete "+volumeName; + List reStrings=Constant.ganymedSSH.execCmdWaitAcquiescent(command); + if(reStrings==null || reStrings.size()>0 || !(reStrings.get(0).contains("volume delete: "+volumeName+": success"))){ + log.error("3803 : delete volume "+volumeName+" failed !"); + return -3; + } + log.info("delete "+volumeName+" successed!"); + return 1; + } + + /** + * 为指定的volume添加brick,参数中需要指定类型、数量等 返回值:1成功 ;其他失败 + * 过程中需要先检查volume是否存在,还需检查给出的brick数量与类型、count是否相符 + * <功能详细描述> + * @param volumeName + * @param brickName + * @param count + * @param type + * @return + * @see [类、类#方法、类#成员] + */ + public int addBrickVolume(String volumeName, List brickName, int count, String type) { + // 检查是否满足添加bricks的条件 + int able = isAble(volumeName, count, type, brickName); + if (able != 1) { + return able; + } + + String command = ""; + log.info("add brick to the specified volume"); + + String brick = concat(brickName); + + if (type.equals(Constant.distributed)) + command = "gluster volume add-brick " + volumeName + " " + brick + "force"; + else if (type.equals(Constant.replica)) + command = "gluster volume add-brick " + volumeName + " " + "replica " + count + " " + brick + "force"; + else if (type.equals(Constant.stripe)) + command = "gluster volume add-brick " + volumeName + " " + "stripe " + count + " " + brick + "force"; + + List reStrings = Constant.ganymedSSH.execCmdWait(Constant.hostIp, Constant.rootUser, Constant.rootPasswd, + Constant.port, command); + + // 添加成功的返回信息是:volume add-brick: success + if (reStrings != null && reStrings.size() > 0 && reStrings.get(0).contains("volume add-brick: success")) { + log.info("添加brick成功!"); + return 1; + } else { + log.error("3205 add brick failed,please check the system"); + // System.out.println("3202 add brick failed,please check the system"); + return -5; + } + } + + + /** + * 为指定的volume删除brick,参数中需要指定类型、数量等 返回值:1 成功 ;其他 失败 + * 过程中需要先检查volume是否存在,还需检查给出的brick数量与类型、count是否相符 + * @param volumeName + * @param brickName + * @param count + * @param type + * @return + * @see [类、类#方法、类#成员] + */ + public int deleteBrickVolume(String volumeName, List brickName, int count, String type) { + int able = isAble(volumeName, count, type, brickName); + + if (able != 1) { + return able; + } + String command = null; + + log.info("delete brick of the specified volume"); + + String brick = concat(brickName); + + if (type.equals(Constant.distributed)) { + command = "echo -e \"y\" | gluster volume remove-brick " + volumeName + " " + brick + " force"; + } else if (type.equals(Constant.replica)) { + command = "echo -e \"y\" | gluster volume remove-brick " + volumeName + " repli " + count + " " + brick + + " force"; + } else if (type.equals(Constant.stripe)) { + command = "echo -e \"y\" | gluster volume remove-brick " + volumeName + " stripe " + count + " " + brick + + " force"; + } + + if (command == null) { + log.error("3305 remove brick failed,please check the system"); + return -5; + } + log.info("即将执行删除命令"); + List reStrings = Constant.ganymedSSH.execCmdWait(Constant.hostIp, Constant.rootUser, Constant.rootPasswd, + Constant.port, command); + // System.out.println(reStrings); + log.info("删除命令执行完毕"); + + // 删除成功的返回信息是“volume remove-brick: success” + if (reStrings.get(0).contains("volume remove-brick: success")) { + { + log.info("删除brick成功"); + return 1; + } + } else { + log.error("3305 remove brick failed,please check the system"); + + return -5; + } + + } + + /* + * 停止指定volume 参数中需给出volume的名字 返回值: 0 成功 -1 失败 + * 需要先检查volume是否存在,然后判断volume的状态是否已经是停止状态 + */ + public int stopVolume(String volumeName) { + log.info("stop volume"); + + // 首先需要判断volume是否存在,调用其他函数返回所有volume的名字 + boolean volumeExist = false; + + List volume = new VolumeInfo().showAllVolumeName(); + for (String temp : volume) { + if (temp.equals(volumeName)) { + volumeExist = true; + break; + } + } + + if (!volumeExist) { + // volume不存在 + log.error("3501 the volume doesnot exist"); + System.out.println("3501 the volume doesnot exist"); + return -1; + } else { + // volume存在,则需判断volume的状态是否已经为“stop” + if (new VolumeInfo().getVolumeStatus(volumeName).equals("Stopped")) { + log.error("3502 the volume is already stoped"); + System.out.println("3502 the volume is already stoped"); + return -1; + } else { + String command = "echo -e \"y\"| gluster volume stop " + volumeName; + List reStrings = Constant.ganymedSSH.execCmdWait(Constant.hostIp, Constant.rootUser, Constant.rootPasswd, + Constant.port, command); + + // 标记操作结果:operation = 1 操作成功 + // operation = 0 操作失败 + int operation = 0; + for (String temp2 : reStrings) { + if (temp2.contains("volume stop: " + volumeName + ": " + "success")) { + operation = 1; + break; + } + System.out.println("operation: " + operation); + } + + if (operation == 1) { + return 0; + } else { + log.error("3503 stop " + volumeName + " failed"); + System.out.println("3503 stop " + volumeName + " failed"); + return -1; + } + + } + } + } + + /* + * 开启指定volume 参数中需给出volume的名字 返回值: 0 成功 -1 失败 + * 需要先检查volume是否存在,然后判断volume的状态是否已经是开启状态 + */ + public int startVolume(String volumeName) { + log.info("start volume"); + boolean volumeExist = false; + List volume = new VolumeInfo().showAllVolumeName(); + + for (String temp : volume) { + if (temp.equals(volumeName)) { + volumeExist = true; + break; + } + } + + if (volumeExist) { + if (!(new VolumeInfo().getVolumeStatus(volumeName).equals("Started"))) { + String command = "gluster volume start " + volumeName; + + int operation = 0; + + // 执行命令 + List reStrings = Constant.ganymedSSH.execCmdWait(Constant.hostIp, Constant.rootUser, Constant.rootPasswd, + Constant.port, command); + for (String temp2 : reStrings) { + if (temp2.equals("volume start: " + volumeName + ": " + "success")) { + operation = 1; + } + } + + if (operation == 1) { + return 0; + } else { + log.error("3602 start volume failed"); + System.out.println("3602 start volume failed"); + return -1; + } + } else { + log.error("volume已经开启"); + System.out.println("volume已经开启"); + return -1; + } + } else { + log.error("3601 the volume does not exist"); + // System.out.println("3601 the volume does not exist"); + return -1; + } + } + + // 需要将存于List变量中的brick的位置组装成可以在glusterfs命令行中直接使用的格式 + public String concat(List brickName) { + StringBuffer result = new StringBuffer(); + int len = brickName.size(); + for (int i = 0; i < len; i++) { + result.append(brickName.get(i)); + result.append(" "); + } + return result.toString(); + } + + /* + * 只在创建volume时使用此函数 创建volume时对不同数据卷,brick的数量需要满足和count的关系 + * 首先判断它们是否满足关系,在不满足的关系的情况下是肯定无法完成操作的 1:可以创建 ;-1:brick的ip不在集群中或者未连接; -2 -3 + * -4 :类型与brick数目不匹配 ; -5 :volumeName 已经存在;-6:挂载点存在且不为空,不能作为挂载点; -7:未知错误 + */ + public int isAbleCreateVolume(String volumeName, int count, String type, List bricks, String mountPoint) { + int status = 0; + + int length = bricks.size(); + + if (type.equals(Constant.distributed)) { + if (count != 0) { + log.error("3101 the kind of distributed requires the arg of count to be 0"); + return -2; + } + } + if (type.equals(Constant.stripe)) { + if (length % count != 0) { + log.error("3102 the number of bricks should be the same as or the times of the stripe count"); + return -3; + } + } + if (type.equals(Constant.replica)) { + if ((length % count) != 0) { + log.error( + "3103 the number of bricks should be the same as the replicate count or the times of replicate count"); + return -4; + } + } + + Map peer_status = new ClusterInfo().showClusterInfo(); + peer_status.put(Constant.hostIp, Constant.peerincluster_connected); + for (String brick : bricks) { + brick = brick.split(":")[0]; + if (!(peer_status.containsKey(brick) && peer_status.get(brick).equals(Constant.peerincluster_connected))) { + log.error("3105 birck " + brick + " ip is not in cluster"); + return -1; + } + + } + + List volumeNames = new VolumeInfo().showAllVolumeName(); + if(volumeNames==null){ + log.error("3108 showAllVolumeName return error"); + return -7; + } + if (volumeNames.contains(volumeName)) { + log.error("3106 " + volumeName + " is already exists! "); + return -5; + } + + Map datas = new ShowData().showFolderData(mountPoint); + if (datas != null && datas.size() > 0) { + log.error("3107 " + mountPoint + " is not exists or not empty ! "); + return -6; + } + return 1; + } + + /** + * 添加或删除volume的brick时,首先需要判断volume是否存在,然后需要判断volume类型、count及brick数目 + * + * @param volumeName + * @param count + * @param type + * @param bricks + * @return 1 满足条件,可以添加;-1 :volume name is not exists;-2,-3,-4 类型与brick数量不匹配; + */ + public int isAble(String volumeName, int count, String type, List bricks) { + List volumeNames = new VolumeInfo().showAllVolumeName(); + + if (!volumeNames.contains(volumeName)) { + log.error("3201:" + volumeName + " is not exists! "); + return -1; + } + + int length = bricks.size(); + if (type.equals("distribute")) { + if (count == 0) + return 1; + else { + log.error("3202: the kind of distributed requires the arg of count to be 0"); + // System.out.println(" the kind of distributed requires the + // arg of count to be 0"); + return -2; + } + } + + if (type.equals("stripe")) { + if (length % count == 0) + return 1; + else { + log.error("3203: the number of bricks should be the same as or the times of the stripe count"); + // System.out.println(" the number of bricks should be the + // same as or the times of the stripe count"); + return -3; + + } + } + if (type.equals("replicate")) { + if ((length % count) == 0) + return 1; + else { + log.error( + "3204: the number of bricks should be the same as the replicate count or the times of replicate count"); + + return -4; + } + } + + return 1; + } + + public static void main(String[] args) { + SetVolume setVolume = new SetVolume(); + int operation = 0; +// PropertyConfigurator.configure("log4j.properties"); + // TODO Auto-generated method stub + // 测试创建volume的代码 + + List bricksToCreate = new ArrayList(); + bricksToCreate.add("192.168.0.110:/v2"); + bricksToCreate.add("192.168.0.116:/v2"); + operation = setVolume.createVolume("v2", 0, "distributed", bricksToCreate, "/home/v2_point"); +// operation = setVolume.deleteVolume("v3"); + // + // // 以下是测试添加brick的代码 + // + // List bricksToAdd = new ArrayList(); + // bricksToAdd.add("192.168.191.23:/v3"); + // operation = setVolume.addBrickVolume("v3", bricksToAdd, 0, + // "distribute"); + // System.out.println(operation); + + // 以下代码是测试删除brick的代码 + // List bricksToAdd= new ArrayList(); + // bricksToAdd.add("192.168.191.23:/v3"); + // operation = + // setVolume.deleteBrickVolume("v3",bricksToAdd,0,"distribute"); + // System.out.println(operation); + // 以下是测试start volume的代码 + // String volumeToStart = "testcreate" ; + // int startOperation = startVolume(volumeToStart); + // System.out.println(startOperation); + // 以下是测试stop volume + String volumeToStop = "v3"; + // int startOperation = setVolume.stopVolume(volumeToStop); + // 以下是测试创建volume并完成挂载的代码 + // List bricksToCreate= new ArrayList(); + // bricksToCreate.add("192.168.214.135:/home/create"); + // bricksToCreate.add("192.168.214.138:/home/create"); + // + // int operation = + // createVolume("createAndmount",0,"distribute",bricksToCreate,"/mnt/create"); + // System.out.println(operation); + } +} + diff --git a/src/com/platform/glusterfs/ShowData.java b/src/com/platform/glusterfs/ShowData.java index 77bd9867..57a7b5c7 100644 --- a/src/com/platform/glusterfs/ShowData.java +++ b/src/com/platform/glusterfs/ShowData.java @@ -1,105 +1,131 @@ -package com.platform.glusterfs; - -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -import org.apache.log4j.Logger; - - -import org.apache.log4j.PropertyConfigurator; -import org.junit.Test; - -import com.platform.utils.Constant; - - -public class ShowData { - - public static Logger log = Logger.getLogger ( ShowData.class); - - /** - * get the data of volumeName Map s1 is data name and s2 is type file or folder - * <功能详细描述> - * @param volumeName - * @return - * @see [类、类#方法、类#成员] - */ - public Map showVolumeFiles(String volumeName){ - log.info("start show the data"); - Map data_type=new HashMap(); - /** - * get mount point of volumeName - */ - String folderName=volumeName; - - data_type=showFolderData(volumeName); - return data_type; -} - /** - * get the data of folder name - * Map is folder name and type 1 is file and others is folder - - - * @param FolderName - * @return - */ - public Map showFolderData(String folderName){ - log.info(" start get "+folderName+" data"); - - - Map data_type=new HashMap(); - String command="ls -l "+folderName; - - /* - RunCommand runCommand=new RunCommand(); - List reStrings=runCommand.runCommandWait(command); - */ - List reStrings = Constant.ganymedSSH.execCmdWait(Constant.hostIp, Constant.rootUser, Constant.rootPasswd, Constant.port, command); - if(reStrings==null){ - log.error("2101 command get result is null"); - return null; - } - if(reStrings.size()==0){ - log.info("2102 the folder is empty"); - return data_type; - } - if(reStrings.get(0).contains("No such file or directory")){ - log.info("2103 the "+folderName+" is not exists"); - return null; - } - /** - * remove first line total number - */ - reStrings.remove(0); - - for(Iterator it2 = reStrings.iterator();it2.hasNext();){ - String line=(String)it2.next(); - line=line.replaceAll(" +", " "); - String keyValue[]=line.split(" "); - if(keyValue.length<9){ - log.error("2104 "+line+" length is short"); - continue; - } - - data_type.put(keyValue[8], keyValue[1]); - - } - log.info(" get "+folderName+" data successed"); - return data_type; - } - - - /** - * - * <一句话功能简述> - * <功能详细描述> - * @see [类、类#方法、类#成员] - */ - @Test - public void testShowData(){ - - System.out.println(showFolderData("/home")); - - } +package com.platform.glusterfs; + +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import org.apache.log4j.Logger; + + +import org.apache.log4j.PropertyConfigurator; +import org.junit.Test; + +import com.platform.utils.Constant; + + +public class ShowData { + + public static Logger log = Logger.getLogger ( ShowData.class); + + /** + * get the data of volumeName Map s1 is data name and s2 is type file or folder + * <功能详细描述> + * @param volumeName + * @return + * @see [类、类#方法、类#成员] + */ + public Map showVolumeFiles(String volumeName){ + log.info("start show the data"); + Map data_type=new HashMap(); + /** + * get mount point of volumeName + */ + String folderName=volumeName; + + data_type=showFolderData(volumeName); + return data_type; +} + /** + * get the data of folder name + * Map is folder name and type 1 is file and others is folder + + + * @param FolderName + * @return + */ + public Map showFolderData(String folderName){ + log.info(" start get "+folderName+" data"); + + + Map data_type=new HashMap(); + String command="ls -l "+folderName; + + /* + RunCommand runCommand=new RunCommand(); + List reStrings=runCommand.runCommandWait(command); + */ + List reStrings = Constant.ganymedSSH.execCmdWait(Constant.hostIp, Constant.rootUser, Constant.rootPasswd, Constant.port, command); + if(reStrings==null){ + log.error("2101 command get result is null"); + return null; + } + if(reStrings.size()==0){ + log.info("2102 the folder is empty"); + return data_type; + } + if(reStrings.get(0).contains("No such file or directory")){ + log.info("2103 the "+folderName+" is not exists"); + return null; + } + /** + * remove first line total number + */ + reStrings.remove(0); + + for(Iterator it2 = reStrings.iterator();it2.hasNext();){ + String line=(String)it2.next(); + line=line.replaceAll(" +", " "); + String keyValue[]=line.split(" "); + if(keyValue.length<9){ + log.error("2104 "+line+" length is short"); + continue; + } + + data_type.put(keyValue[8], keyValue[1]); + + } + log.info(" get "+folderName+" data successed"); + return data_type; + } + + /** + * 返回folder的大小字节表示 + * -2表示获取大小出错,-1表示folder不存在,其他表示folder的大小 + * @param folderPath + * @return + * @see [类、类#方法、类#成员] + */ + public long getFolderSize(String folderPath) { + log.info("get " + folderPath + " Size "); + + String command = "du -k -d 0 "+folderPath+" | grep " + folderPath + "|awk \'{print $1}\'"; + List reStrings = Constant.ganymedSSH.execCmdWaitAcquiescent(command); + if(reStrings==null || reStrings.size()==0){ + log.error("get " + folderPath + " Size error!"); + return -2; + } + if (reStrings.get(0).contains(Constant.noSuchFile)) { + log.error(folderPath+" is not exists"); + return -1; + } + long size = Long.valueOf(reStrings.get(0)); + + + return size; + } + + + /** + * + * <一句话功能简述> + * <功能详细描述> + * @see [类、类#方法、类#成员] + */ + @Test + public void testShowData(){ + + System.out.println(showFolderData("/home")); + + } } \ No newline at end of file diff --git a/src/com/platform/glusterfs/VolumeInfo.java b/src/com/platform/glusterfs/VolumeInfo.java index 26173fd8..15e4cb14 100644 --- a/src/com/platform/glusterfs/VolumeInfo.java +++ b/src/com/platform/glusterfs/VolumeInfo.java @@ -1,334 +1,422 @@ -package com.platform.glusterfs; - -import java.io.File; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -import org.apache.log4j.Logger; -import org.apache.log4j.PropertyConfigurator; -import org.junit.Test; -import org.omg.CosNaming.NamingContextExtPackage.StringNameHelper; - -import com.platform.utils.Constant; -import com.platform.utils.GanymedSSH; - -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -public class VolumeInfo { - public static Logger log = Logger.getLogger(VolumeInfo.class); - - /** - * 显示所有volume名称 - * <功能详细描述> - * @return - * @see [类、类#方法、类#成员] - */ - public List showAllVolumeName() { - log.info("get volume name"); - List volNames = new ArrayList(); - - /* - * String command = "echo \"" + Constant.rootPasswd + - * "\" |sudo -S gluster volume info|grep ^Volume.Name"; RunCommand - * runCommand = new RunCommand(); List reStrings = - * runCommand.runCommandWait(command); - */ - List reStrings = Constant.ganymedSSH.execCmdWait(Constant.hostIp, Constant.rootUser, - Constant.rootPasswd, Constant.port, Constant.glusterVolumeInfo + "|grep ^Volume.Name"); - // System.out.println(reStrings); - if (reStrings == null) { - log.error("1401 get result is null"); - return null; - } - if (reStrings.size() == 0) { - log.error("1402 get result is nothing"); - return null; - } - if (reStrings.get(0).contains(Constant.noVolume)) { - reStrings.clear(); - return reStrings; - } - if (!(reStrings.get(0).split(":")[0].contains("Volume Name"))) { - log.error("1403 get result string wrong"); - return null; - } - - String nameInfo = ""; - for (Iterator it = reStrings.iterator(); it.hasNext();) { - String line = (String) it.next(); - String str[] = line.split(":"); - volNames.add(str[1].replaceAll(" ", "")); - } - return volNames; - - } - - /** - * 给定参数volume的名称获得volume的类型 - * <功能详细描述> - * @param volumeName - * @return - * @see [类、类#方法、类#成员] - */ - public String getVolumeType(String volumeName) { - log.info("get volume type"); - String volType = ""; - - List reStrings = Constant.ganymedSSH.execCmdWait(Constant.hostIp, Constant.rootUser, - Constant.rootPasswd, Constant.port, Constant.glusterVolumeInfo + volumeName + "|grep ^Type"); - // System.out.println(reStrings); - if (reStrings == null) { - log.error("1501 get result is null"); - return null; - } - if (reStrings.size() == 0) { - log.error("1502 get result is nothing"); - return null; - } - if (!(reStrings.get(0).split(":")[0].contains("Type"))) { - log.error("1503 get result string wrong"); - return null; - } - - // System.out.println(reStrings); - - for (Iterator it = reStrings.iterator(); it.hasNext();) { - String line = (String) it.next(); - String str[] = line.split(":"); - volType = str[1]; - } - volType = volType.replaceAll(" ", ""); - return volType; - } - - public String getVolumeStatus(String volumeName) { - log.info("get volume status"); - String volStatus = ""; - List reStrings = Constant.ganymedSSH.execCmdWait(Constant.hostIp, Constant.rootUser, - Constant.rootPasswd, Constant.port, Constant.glusterVolumeInfo + "|grep ^Status"); - // System.out.println(reStrings); - if (reStrings == null) { - log.error("1701 get result is null"); - return null; - } - if (reStrings.size() == 0) { - log.error("1702 get result is nothing"); - return null; - } - if (!(reStrings.get(0).split(":")[0].contains("Status"))) { - log.error("1703 get result string wrong"); - return null; - } - - for (Iterator it = reStrings.iterator(); it.hasNext();) { - String line = (String) it.next(); - String str[] = line.split(":"); - volStatus = str[1].replaceAll(" ", ""); - } - return volStatus; - } - - public Double getVolumeAllSize(String volumeName) { - log.info("get volume allSize"); - Double allSize = null; - /* - * ======= // waiting for testing... public Double - * getVolumeAllSize(String volumeName) { log.info("get volume allSize"); - * Double allSize = null; - * - * >>>>>>> origin/AlexKie String command = "echo \"" + - * Constant.rootPasswd + "\" |sudo -S df -h|grep " + volumeName + - * "|awk '{print $2}'"; RunCommand runCommand = new RunCommand(); - * List reStrings = runCommand.runCommandWait(command); <<<<<<< - * HEAD - */ - List reStrings = Constant.ganymedSSH.execCmdWait(Constant.hostIp, Constant.rootUser, Constant.rootPasswd, - Constant.port, Constant.df + "|grep " + volumeName + "|awk '{print $2}'"); - // System.out.println(reStrings); - if(reStrings==null){ - log.error("1801 get result is null"); - return null; - } - if(reStrings.size()==0){ - log.error("1802 get result is nothing"); - return null; - } - char flag = reStrings.get(0).trim().toCharArray()[0]; - if (flag < 48 || flag > 57) { - log.error("1803 get result string wrong"); - return null; - } - - for (Iterator it = reStrings.iterator(); it.hasNext();) { - String line = (String) it.next(); - String str[] = line.split("[^0-9]"); - allSize = Double.parseDouble(str[0]); - } - - return allSize; - } - - public Double getVolumeUseSize(String volumeName) { - log.info("get volume used size"); - Double usedSize = null; - - List reStrings = Constant.ganymedSSH.execCmdWait(Constant.hostIp, Constant.rootUser, - Constant.rootPasswd, Constant.port, Constant.df + "|grep " + volumeName + "|awk '{print $3}'"); - // System.out.println(reStrings); - if (reStrings == null) { - log.error("1901 get result is null"); - return null; - } - if (reStrings.size() == 0) { - log.error("1902 get result is nothing"); - return null; - } - char flag = reStrings.get(0).trim().toCharArray()[0]; - if (flag < 48 || flag > 57) { - log.error("1903 get result string wrong"); - return null; - } - - for (Iterator it = reStrings.iterator(); it.hasNext();) { - String line = (String) it.next(); - String str[] = line.split("[^0-9]"); - - usedSize = Double.parseDouble(str[0]); - } - - return usedSize; - } - - /** - * @param volumeName - * @return String ipAndpath[] = brick.split(":"); - String ip = ipAndpath[0]; - String path = ipAndpath[1]; - */ - public List getVolumeBricks(String volumeName) { - log.info("get volume bricks"); - - String cmd = "gluster volume info " + volumeName + " |grep ^Brick'[0-9]\\+' |awk '{print $2}'"; - List reStrings = Constant.ganymedSSH.execCmdWaitAcquiescent(cmd); - // System.out.println(reStrings); - if (reStrings == null) { - log.error("1601 get volume bricks wrong"); - return null; - } - - return reStrings; - } - - public List getVolumeMountPoint(String volumeName) { - log.info("get volume MountPoint"); - - List reStrings = Constant.ganymedSSH.execCmdWait(Constant.hostIp, Constant.rootUser, Constant.rootPasswd, - Constant.port, Constant.df + "|grep " + volumeName + "|awk '{print $6}'"); - // System.out.println(reStrings); - if(reStrings==null){ - log.error("11001 get result string wrong"); - return null; - } - if(reStrings.size()==0){ - log.error("11002 "+volumeName+" is no mountpoint"); - return null; - } - - char flag = reStrings.get(0).trim().toCharArray()[0]; - if (flag != '/') { - log.error("11003 get result string wrong"); - return null; - } - List mountPoints = new ArrayList<>(); - for(String mountPoint:reStrings){ - mountPoint=mountPoint.replaceAll(" ", ""); - mountPoints.add(mountPoint); - } - return mountPoints; - } - - public Map getVolumebricksDataSize(String volumeName) { - List bricks = getVolumeBricks(volumeName); - Map brick_size = new HashMap<>(); - if (bricks == null) { - return null; - } - for (String brick : bricks) { - String ipAndpath[] = brick.split(":"); - String ip = ipAndpath[0]; - String path = ipAndpath[1]; - String cmd = "du -d 0 " + path + "|awk '{print $1}'"; - List reStrings = Constant.ganymedSSH.execCmdWait(ip, Constant.rootUser, Constant.rootPasswd, - Constant.port, cmd); - // System.out.println(reStrings); - if (reStrings == null) { - log.error("1901 get result is null"); - return null; - } - if (reStrings.size() == 0) { - log.error("1902 get result is nothing"); - return null; - } - Pattern pattern = Pattern.compile("[0-9]*"); - Matcher isNum = pattern.matcher(reStrings.get(0)); - if (!isNum.matches()) { - log.error("1903 " + reStrings.get(0) + " is unexpect"); - return null; - } - brick_size.put(brick, Double.parseDouble(reStrings.get(0))); - } - return brick_size; - } - - public Map getVolumebricksAvailableSize(String volumeName) { - List bricks = getVolumeBricks(volumeName); - Map brick_size = new HashMap<>(); - if (bricks == null) { - return null; - } - for (String brick : bricks) { - String ipAndpath[] = brick.split(":"); - String ip = ipAndpath[0]; - String path = ipAndpath[1]; - String cmd = "df " + path + "|awk '{print $4}'"; - List reStrings = Constant.ganymedSSH.execCmdWait(ip, Constant.rootUser, Constant.rootPasswd, - Constant.port, cmd); - // System.out.println(reStrings); - if (reStrings == null) { - log.error("1901 get result is null"); - return null; - } - if (reStrings.size() == 0) { - log.error("1902 get result is nothing"); - return null; - } - Pattern pattern = Pattern.compile("[0-9]*"); - Matcher isNum = pattern.matcher(reStrings.get(1)); - if (!isNum.matches()) { - log.error("1903 " + reStrings.get(1) + " is unexpect"); - return null; - } - brick_size.put(brick, Double.parseDouble(reStrings.get(1))); - } - return brick_size; - } - - @Test - public void test_getVolumebricksDataSize() { - System.out.println(getVolumebricksDataSize("gfs_ftp")); - } - - @Test - public void test_getVolumebricksAvailableSize() { - System.out.println(getVolumebricksAvailableSize("gfs_ftp")); - } - - // @Test - public void test_getVolumeBricks() { - getVolumeBricks("gfs_ftp"); - } -} + +package com.platform.glusterfs; + +import java.io.File; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import org.apache.log4j.Logger; +import org.apache.log4j.PropertyConfigurator; +import org.junit.Test; +import org.omg.CosNaming.NamingContextExtPackage.StringNameHelper; + +import com.platform.utils.Constant; +import com.platform.utils.GanymedSSH; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * 获取volume信息 <功能详细描述> + * + * @author liliy + * @version [版本号,2016年9月13日] + * @see [相关类/方法] + * @since [产品/模块版本] + */ +public class VolumeInfo { + public static Logger log = Logger.getLogger(VolumeInfo.class); + + /** + * 显示所有volume名称 <功能详细描述> + * + * @return + * @see [类、类#方法、类#成员] + */ + public List showAllVolumeName() { + log.info("get volume name"); + List volNames = new ArrayList(); + + /* + * String command = "echo \"" + Constant.rootPasswd + + * "\" |sudo -S gluster volume info|grep ^Volume.Name"; RunCommand + * runCommand = new RunCommand(); List reStrings = + * runCommand.runCommandWait(command); + */ + List reStrings = Constant.ganymedSSH + .execCmdWaitAcquiescent(Constant.glusterVolumeInfo + "|grep ^Volume.Name"); + // System.out.println(reStrings); + if (reStrings == null) { + log.error("1401 get result is null"); + return null; + } + if (reStrings.size() == 0) { + log.error("1402 get result is nothing"); + return null; + } + if (reStrings.get(0).contains(Constant.noVolume)) { + reStrings.clear(); + return reStrings; + } + if (!(reStrings.get(0).split(":")[0].contains("Volume Name"))) { + log.error("1403 get result string wrong"); + return null; + } + + String nameInfo = ""; + for (Iterator it = reStrings.iterator(); it.hasNext();) { + String line = (String) it.next(); + String str[] = line.split(":"); + volNames.add(str[1].replaceAll(" ", "")); + } + return volNames; + + } + + /** + * 给定参数volume的名称获得volume的类型 <功能详细描述> + * + * @param volumeName + * @return + * @see [类、类#方法、类#成员] + */ + public String getVolumeType(String volumeName) { + log.info("get volume type"); + String volType = ""; + + List reStrings = Constant.ganymedSSH + .execCmdWaitAcquiescent(Constant.glusterVolumeInfo + volumeName + "|grep ^Type"); + // System.out.println(reStrings); + if (reStrings == null) { + log.error("1501 get result is null"); + return null; + } + if (reStrings.size() == 0) { + log.error("1502 get result is nothing"); + return null; + } + if (!(reStrings.get(0).split(":")[0].contains("Type"))) { + log.error("1503 get result string wrong"); + return null; + } + + // System.out.println(reStrings); + + for (Iterator it = reStrings.iterator(); it.hasNext();) { + String line = (String) it.next(); + String str[] = line.split(":"); + volType = str[1]; + } + volType = volType.replaceAll(" ", ""); + return volType; + } + + /** + * 获取volumeName的状态 如果出错返回null,如果volumeName不存在则返回Volume volumeName does not + * exist,正常返回状态Started,Stopped,Created + * + * @param volumeName + * @return + * @see [类、类#方法、类#成员] + */ + public String getVolumeStatus(String volumeName) { + log.info("get volume status"); + String volStatus = ""; + String cmd = Constant.glusterVolumeInfo + " " + volumeName + " |grep ^Status"; + List reStrings = Constant.ganymedSSH.execCmdWaitAcquiescent(cmd); + // System.out.println(reStrings); + if (reStrings == null) { + log.error("1701 get result is null"); + return null; + } + if (reStrings.size() == 0) { + log.error("1702 get result is nothing"); + return null; + } + + if (reStrings.get(0).contains("does not exist")) { + log.error("1703 " + reStrings.get(0)); + return reStrings.get(0); + } + if (!(reStrings.get(0).split(":")[0].contains("Status"))) { + log.error("1704 get result string wrong"); + return null; + } + for (Iterator it = reStrings.iterator(); it.hasNext();) { + String line = (String) it.next(); + String str[] = line.split(":"); + volStatus = str[1].replaceAll(" ", ""); + } + + return volStatus; + } + + /** + * 获取volumeName的可用大小 + * volumeName不存在返回-1,获取大小错误返回-2 ,正常返回volumeName的可用大小 + * @param volumeName + * @return + * @see [类、类#方法、类#成员] + */ + public Long getVolumeAvailableSize(String volumeName) { + log.info("get volume availableSize"); + Long allSize = 0L; + + String cmd = Constant.df + " | grep " + volumeName + "|awk '{print $4}'"; + List reStrings = Constant.ganymedSSH.execCmdWaitAcquiescent(cmd); + // System.out.println(reStrings); + if (reStrings == null) { + log.error("1802 get result is error"); + return -2L; + } + if (reStrings.size() == 0) { + log.error("1801 " + volumeName + " is not exists!"); + return -1L; + } + allSize = Long.parseLong(reStrings.get(0)); + return allSize; + } + + /** + * 获取volumeName已用空间 + * volumeName不存在返回-1,获取大小错误返回-2 ,正常返回volumeName的已用的大小 + * @param volumeName + * @return + * @see [类、类#方法、类#成员] + */ + public Long getVolumeUseSize(String volumeName) { + log.info("get volume used size"); + Long usedSize = 0L; + if (volumeIsExists(volumeName) == false) { + log.error("1901 " + volumeName + " is not exists!"); + return -1L; + + } + + String cmd = "df | grep " + volumeName + "|awk '{print $3}'"; + List reStrings = Constant.ganymedSSH.execCmdWaitAcquiescent(cmd); + // System.out.println(reStrings); + if (reStrings == null) { + log.error("1901 get result is null"); + return -2L; + } + if (reStrings.size() == 0) { + log.error("1902 " + volumeName + " is not exists!"); + return -1L; + } + usedSize = Long.parseLong(reStrings.get(0)); + return usedSize; + } + + /** + * 获取volumeName的bricks + * 返回一个bircks的list ip:path,如果volumeName不存在返回null + * @param volumeName + * @return + * @see [类、类#方法、类#成员] + */ + public List getVolumeBricks(String volumeName) { + log.info("get volume bricks"); + + String cmd = "gluster volume info " + volumeName + " |grep ^Brick'[0-9]\\+' |awk '{print $2}'"; + List reStrings = Constant.ganymedSSH.execCmdWaitAcquiescent(cmd); + // System.out.println(reStrings); + if (reStrings == null) { + log.error("1601 get volume bricks wrong"); + return null; + } + if (reStrings.size()==0) { + log.error("1602 "+volumeName+" is not exists!"); + return null; + } + return reStrings; + } + + /** + * 获取volumeName所有挂载点 + * <功能详细描述> + * @param volumeName + * @return + * @see [类、类#方法、类#成员] + */ + public List getVolumeMountPoint(String volumeName) { + log.info("get volume MountPoint"); + List mountPoints = new ArrayList<>(); + String cmd=Constant.df + "|grep " + volumeName + "|awk '{print $6}'"; + List reStrings = Constant.ganymedSSH.execCmdWaitAcquiescent(cmd); + // System.out.println(reStrings); + if (reStrings == null) { + log.error("11001 get result string wrong"); + return null; + } + if (reStrings.size() == 0) { + log.error("11002 " + volumeName + " is not exists or no mountpoint"); + return null; + } + +// char flag = reStrings.get(0).trim().toCharArray()[0]; +// if (flag != '/') { +// log.error("11003 get result string wrong"); +// return null; +// } + + for (String mountPoint : reStrings) { + mountPoint = mountPoint.replaceAll(" ", ""); + mountPoints.add(mountPoint); + } + return mountPoints; + } + + public String getOneVolumeMountPoint(String volumeName) { + log.info("get one volume MountPoint"); + + String mountPoint=null; + String cmd=Constant.df + "|grep " + volumeName + "|awk '{print $6}'"; + List reStrings = Constant.ganymedSSH.execCmdWaitAcquiescent(cmd); + // System.out.println(reStrings); + if (reStrings == null) { + log.error("11001 get result string wrong"); + return null; + } + if (reStrings.size() == 0) { + log.error("11002 " + volumeName + " is not exists or no mountpoint"); + return null; + } + +// char flag = reStrings.get(0).trim().toCharArray()[0]; +// if (flag != '/') { +// log.error("11003 get result string wrong"); +// return null; +// } + + mountPoint=reStrings.get(0); + return mountPoint; + } + + /** + * 获取volumeName的所有brick中数据占用空间的大小 + * 返回一个map表示bricks和数据大小 + * @param volumeName + * @return + * @see [类、类#方法、类#成员] + */ + public Map getVolumebricksDataSize(String volumeName) { + List bricks = getVolumeBricks(volumeName); + Map brick_size = new HashMap<>(); + if (bricks == null) { + return null; + } + for (String brick : bricks) { + String ipAndpath[] = brick.split(":"); + String ip = ipAndpath[0]; + String path = ipAndpath[1]; + String cmd = "du -d 0 " + path + "|awk '{print $1}'"; + List reStrings = Constant.ganymedSSH.execCmdWait(ip, Constant.rootUser, Constant.rootPasswd, + Constant.port, cmd); + // System.out.println(reStrings); + if (reStrings == null) { + log.error("1901 get result is null"); + return null; + } + if (reStrings.size() == 0) { + log.error("1902 "+brick+" is not exits!"); + return null; + } + Pattern pattern = Pattern.compile("[0-9]*"); + Matcher isNum = pattern.matcher(reStrings.get(0)); + if (!isNum.matches()) { + log.error("1903 " + reStrings.get(0) + " is unexpect"); + return null; + } + brick_size.put(brick, Double.parseDouble(reStrings.get(0))); + } + return brick_size; + } + + /** + * 获取volumeName的所有brick中可用空间大小 + * 返回一个map表示bricks和可用空间大小 + * @param volumeName + * @return + * @see [类、类#方法、类#成员] + */ + public Map getVolumebricksAvailableSize(String volumeName) { + List bricks = getVolumeBricks(volumeName); + Map brick_size = new HashMap<>(); + if (bricks == null) { + return null; + } + for (String brick : bricks) { + String ipAndpath[] = brick.split(":"); + String ip = ipAndpath[0]; + String path = ipAndpath[1]; + String cmd = "df " + path + "|awk '{print $4}'"; + List reStrings = Constant.ganymedSSH.execCmdWait(ip, Constant.rootUser, Constant.rootPasswd, + Constant.port, cmd); + // System.out.println(reStrings); + if (reStrings == null) { + log.error("1901 get result is null"); + return null; + } + if (reStrings.size() == 0) { + log.error("1902 get result is nothing"); + return null; + } + Pattern pattern = Pattern.compile("[0-9]*"); + Matcher isNum = pattern.matcher(reStrings.get(1)); + if (!isNum.matches()) { + log.error("1903 " + reStrings.get(1) + " is unexpect"); + return null; + } + brick_size.put(brick, Double.parseDouble(reStrings.get(1))); + } + return brick_size; + } + + /** + * 判断volumeName是否存在,存在返回true,不存在返回false <功能详细描述> + * + * @param volumeName + * @return + * @see [类、类#方法、类#成员] + */ + public boolean volumeIsExists(String volumeName) { + List volumes = showAllVolumeName(); + if (volumes == null) { + return false; + } + if (volumes.contains(volumeName)) { + return true; + } + return false; + } + + // @Test + public void test_getVolumebricksDataSize() { + System.out.println(getVolumebricksDataSize("gfs_ftp")); + } + + // @Test + public void test_getVolumebricksAvailableSize() { + System.out.println(getVolumebricksAvailableSize("gfs_ftp")); + } + + // @Test + public void test_getVolumeBricks() { + getVolumeBricks("gfs_ftp"); + } + + @Test + public void test_getVolumeStatus() { + System.out.println(getVolumeStatus("gs_fp")); + } + + // @Test + public void test_getVolumeMountPoint() { + System.out.println(getVolumeMountPoint("gfs_ftp")); + System.out.println(getVolumeMountPoint("v1")); + } +} diff --git a/src/com/platform/service/DataInfoService.java b/src/com/platform/service/DataInfoService.java index be0ca7f7..c08d0850 100644 --- a/src/com/platform/service/DataInfoService.java +++ b/src/com/platform/service/DataInfoService.java @@ -1,11 +1,16 @@ + package com.platform.service; import org.springframework.ui.ModelMap; +import com.platform.dao.DataInfoDao; +import com.platform.entities.DataInfoEntity; import com.platform.entities.PagerOptions; public interface DataInfoService { public ModelMap getPagerTableData(PagerOptions pagerOptions); - void deleteData(String[] id); + void deleteData(String[] id) throws Exception; + + int save(DataInfoEntity data) throws Exception; } diff --git a/src/com/platform/service/DataInfoServiceImp.java b/src/com/platform/service/DataInfoServiceImp.java index bcbe94fb..4da74444 100644 --- a/src/com/platform/service/DataInfoServiceImp.java +++ b/src/com/platform/service/DataInfoServiceImp.java @@ -1,5 +1,6 @@ package com.platform.service; +import java.util.ArrayList; import java.util.List; import javax.annotation.Resource; @@ -24,7 +25,8 @@ public class DataInfoServiceImp implements DataInfoService { public ModelMap getPagerTableData(PagerOptions pagerOptions) { // TODO Auto-generated method stub ModelMap modelMap = new ModelMap(); - int count = dfdDao.getLimitedDataCount(pagerOptions); //获取总记录条数 + int count = dfdDao.getLimitedDataCount(pagerOptions); //获取总记录条数 + System.out.println("total colume " + count); int offset = 0; if (pagerOptions.getCurrentPageNum() > 1) { pagerOptions.setTotalLimit((pagerOptions.getCurrentPageNum() - 1) @@ -41,19 +43,29 @@ public class DataInfoServiceImp implements DataInfoService { } @Override - public void deleteData(String[] id) { + public void deleteData(String[] id) throws Exception { // TODO Auto-generated method stub + List ids = new ArrayList(); for(String idx: id){ + ids.add(Integer.parseInt(idx)); + } + if (ids.size() > 0) { //数据在不在? - List paths = dfdDao.getIdIsExist(Integer.parseInt(idx)); + List paths = dfdDao.getIdIsExist(ids); if(paths.size()>0){ //删除文件操作 for (int i = 0; i < paths.size(); i++) { System.out.println(paths.get(i)); } //删除数据库记录 - //dfdDao.deleteRow(idx); + dfdDao.removes(ids); } } } + + @Override + public int save(DataInfoEntity data) throws Exception { + int result = dfdDao.save(data); + return result; + } } diff --git a/src/com/platform/service/IGfsService.java b/src/com/platform/service/IGfsService.java index 0b9d9841..e8a693fb 100644 --- a/src/com/platform/service/IGfsService.java +++ b/src/com/platform/service/IGfsService.java @@ -10,11 +10,13 @@ */ package com.platform.service; + import java.util.List; import com.platform.entities.FolderNode; import com.platform.entities.VolumeEntity; + /** * <一句话功能简述> * <功能详细描述> @@ -45,6 +47,7 @@ public interface IGfsService { * @throws Exception * @see [类、类#方法、类#成员] */ + public int copyFolder(List srcFolders, String dstFolder, String name) throws Exception; /** @@ -68,5 +71,6 @@ public interface IGfsService { public int moveData(String volumeName, String srcPath, String dstPath) throws Exception; public int deleteData(String volumeName, String srcPath) throws Exception; + } diff --git a/src/com/platform/service/IMoveDataService.java b/src/com/platform/service/IMoveDataService.java new file mode 100644 index 00000000..bddb1e04 --- /dev/null +++ b/src/com/platform/service/IMoveDataService.java @@ -0,0 +1,40 @@ +package com.platform.service; + +import java.util.List; + +import com.platform.entities.DataInfoEntity; +import com.platform.entities.DataInfoEntityMoveTmp; + +/** 数据迁移 + * @author chen + * + */ +public interface IMoveDataService { + + /** 迁移(新增) + * @param a dataInfo实体 + * @param dstPath volume下的某个folder路径(需要补齐路径,eg: XXX/320198_16/1,or XXX/320122KFQ_15/1) + * @return + * @throws Exception + */ + public boolean moveData(List data, String dstPath) throws Exception; + + /** 查询所有进度 + * @return 返回所有的实体 + * @throws Exception + */ + public List findAll() throws Exception; + + /** 删除 + * @return + * @throws Exception + */ + public int delete(DataInfoEntityMoveTmp dataMove) throws Exception; + + public int update(DataInfoEntityMoveTmp data) throws Exception; + + public int save(DataInfoEntityMoveTmp data) throws Exception; + + public int insertBatch(List list) throws Exception; + +} diff --git a/src/com/platform/service/OracleExtractHelper.java b/src/com/platform/service/OracleExtractHelper.java index 2a7b89ed..82228e28 100644 --- a/src/com/platform/service/OracleExtractHelper.java +++ b/src/com/platform/service/OracleExtractHelper.java @@ -40,8 +40,18 @@ public class OracleExtractHelper { /** * 创建dblink * +<<<<<<< HEAD +<<<<<<< HEAD + * @param conn + * @param oc +======= + * @param conn 汇总库的连接 + * @param oc 采集库 +>>>>>>> 355b6e47a4fa8d058029ec939fe4fefdaa751275 +======= * @param conn 汇总库的连接 * @param oc 采集库 +>>>>>>> web_backend_develope * dblink连接参数实体 */ public void createDBLink(Connection conn, OracleConnectorParams oc) { diff --git a/src/com/platform/service/impl/GfsServiceImpl.java b/src/com/platform/service/impl/GfsServiceImpl.java index 683ac2f1..39ea77d2 100644 --- a/src/com/platform/service/impl/GfsServiceImpl.java +++ b/src/com/platform/service/impl/GfsServiceImpl.java @@ -1,149 +1,161 @@ - -/** - * 文件名 : GfsServiceImpl.java - * 版权 : <版权/公司名> - * 描述 : <描述> - * @author chen - * 版本 : <版本> - * 修改时间: 2016年9月8日 - * 修改内容: <修改内容> - */ -package com.platform.service.impl; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import org.springframework.stereotype.Service; - -import com.platform.entities.Brick; -import com.platform.entities.FolderNode; -import com.platform.entities.VolumeEntity; -import com.platform.glusterfs.CopyData; -import com.platform.glusterfs.GetTreeData; -import com.platform.glusterfs.VolumeInfo; -import com.platform.service.IGfsService; -import com.platform.utils.CacheTreeData; -import com.platform.utils.ThreadVolume; -import com.platform.utils.getTreeDataByPath; - -/** - * <一句话功能简述> gfs功能实现类 - * <功能详细描述> - * @author chen - * @version [版本号,2016年9月8日] - * @see [相关类/方法] - * @since [产品/模块版本] - */ -@Service(value = "gfsService") -public class GfsServiceImpl implements IGfsService { - - /** gfs目录树形查询 */ - private getTreeDataByPath getFolder = new getTreeDataByPath(); - - /** 数据迁移实现 */ - private CopyData copydata = new CopyData(); - - /** Volume信息查询 */ - private VolumeInfo volumeInfo = new VolumeInfo(); - - @Override - public FolderNode getFolder(String path) { - FolderNode result = getFolder.findByPath(path); - return result; - } - - @Override - public int copyFolder(List srcFolders, String dstFolder, String name) - throws Exception { - int status = 0 ; - if (null != srcFolders) { - - for (String string : srcFolders) { - status = copydata.copyFolderFiles(string, dstFolder, name); - } - } - return status; - } - - /* (non-Javadoc) - * @see com.platform.service.IGfsService#getAllVolume() - */ - @Override - public List getAllVolumes() throws Exception { - List volumeList = new ArrayList<>(); - List volumeNameList = volumeInfo.showAllVolumeName(); - if (null == volumeNameList) { - return null; - } - for (String volumeName : volumeNameList) { - VolumeEntity volume = new VolumeEntity(); - volume.setName(volumeName); - List path = volumeInfo.getVolumeMountPoint(volumeName); - //默认加载第一个路径 - if (null != path && path.size() > 0) { - volume.setPath(path.get(0)); - } - volume.setAllSize(volumeInfo.getVolumeAllSize(volumeName)); - volume.setUsedSize(volumeInfo.getVolumeUseSize(volumeName)); - //TODO 查询brick-- - //返回 ip:path - List brickStrs = volumeInfo.getVolumeBricks(volumeName); - //brick已用大小: - Map usedSize = volumeInfo.getVolumebricksDataSize(volumeName); - Map availableSize = volumeInfo.getVolumebricksAvailableSize(volumeName); - List brickList = new ArrayList(); - for (String brickIpPath : brickStrs) { - Brick b = new Brick(); - String ipAndpath[] = brickIpPath.split(":"); - String brickip = ipAndpath[0]; - String brickpath = ipAndpath[1]; - //iP , path , - b.setIp(brickip); - b.setPath(brickpath); - b.setAvailableSize(availableSize.get(brickIpPath)); - b.setUsedSize(usedSize.get(brickIpPath)); - brickList.add(b); - } - volume.setBrick(brickList); - if (null != volume.getPath()) { -// 获得 folder 目录 - volume.setFolder(getFolder(volume.getPath())); - } - volumeList.add(volume); - } - return volumeList; - } - - @Override - public VolumeEntity getOneVolume(String volumeName) throws Exception { - VolumeEntity volume = new VolumeEntity(); - volume.setName(volumeName); - List path = volumeInfo.getVolumeMountPoint(volumeName); - if (null != path && path.size() > 0) { - volume.setPath(path.get(0)); - } - volume.setAllSize(volumeInfo.getVolumeAllSize(volumeName)); - volume.setUsedSize(volumeInfo.getVolumeUseSize(volumeName)); -// volume.setBrick(brick); - if (null != volume.getPath()) { - volume.setFolder(getFolder(path.get(0))); - } - return volume; - } - - @Override - public int moveData(String volumeName, String srcPath, String dstPath) - throws Exception { - - int result = copydata.copyFolderFiles(srcPath, dstPath, "app"); - return result; - } - - @Override - public int deleteData(String volumeName, String srcPath) throws Exception { - // TODO Auto-generated method stub - return 0; - } - -} + +/** + * 文件名 : GfsServiceImpl.java + * 版权 : <版权/公司名> + * 描述 : <描述> + * @author chen + * 版本 : <版本> + * 修改时间: 2016年9月8日 + * 修改内容: <修改内容> + */ +package com.platform.service.impl; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import org.springframework.stereotype.Service; + +import com.platform.entities.Brick; +import com.platform.entities.FolderNode; +import com.platform.entities.VolumeEntity; +import com.platform.glusterfs.CopyData; +import com.platform.glusterfs.GetTreeData; +import com.platform.glusterfs.VolumeInfo; +import com.platform.service.IGfsService; +import com.platform.utils.CacheTreeData; +import com.platform.utils.ThreadVolume; +import com.platform.utils.getTreeDataByPath; + +/** + * <一句话功能简述> gfs功能实现类 + * <功能详细描述> + * @author chen + * @version [版本号,2016年9月8日] + * @see [相关类/方法] + * @since [产品/模块版本] + */ +@Service(value = "gfsService") +public class GfsServiceImpl implements IGfsService { + + /** gfs目录树形查询 */ + private getTreeDataByPath getFolder = new getTreeDataByPath(); + + /** 数据迁移实现 */ + private CopyData copydata = new CopyData(); + + /** Volume信息查询 */ + private VolumeInfo volumeInfo = new VolumeInfo(); + + @Override + public FolderNode getFolder(String path) { + FolderNode result = getFolder.findByPath(path); + return result; + } + + @Override + public int copyFolder(List srcFolders, String dstFolder, String name) + throws Exception { + int status = 0 ; + if (null != srcFolders) { + + for (String string : srcFolders) { + status = copydata.copyFolderFilesAnyway(string, dstFolder, name); + } + } + return status; + } + + /* (non-Javadoc) + * @see com.platform.service.IGfsService#getAllVolume() + */ + @Override + public List getAllVolumes() throws Exception { + List volumeList = CacheTreeData.getVolumeList(); + if (null == volumeList) { + return new ArrayList(); + } + for (VolumeEntity volume : volumeList) { +// VolumeEntity volume = new VolumeEntity(); +// volume.setName(volumeName); +// List path = volumeInfo.getVolumeMountPoint(volumeName); +// //默认加载第一个路径 +// if (null != path && path.size() > 0) { +// volume.setPath(path.get(0)); +// } +// volume.setAllSize(volumeInfo.getVolumeAllSize(volumeName)); +// volume.setUsedSize(volumeInfo.getVolumeUseSize(volumeName)); +// //TODO 查询brick-- +// //返回 ip:path +// List brickStrs = volumeInfo.getVolumeBricks(volumeName); +// //brick已用大小: +// Map usedSize = volumeInfo.getVolumebricksDataSize(volumeName); +// Map availableSize = volumeInfo.getVolumebricksAvailableSize(volumeName); +// +// +// List brickList = new ArrayList(); +// for (String brickIpPath : brickStrs) { +// Brick b = new Brick(); +// String ipAndpath[] = brickIpPath.split(":"); +// String brickip = ipAndpath[0]; +// String brickpath = ipAndpath[1]; +// //iP , path , +// b.setIp(brickip); +// b.setPath(brickpath); +// b.setAvailableSize(availableSize.get(brickIpPath)); +// b.setUsedSize(usedSize.get(brickIpPath)); +// brickList.add(b); +// } +// volume.setBrick(brickList); + if (null != volume.getPath()) { +// 获得 folder 目录 + List list = new ArrayList(); + FolderNode currNode = getFolder(volume.getPath()); + if (null != currNode && null != currNode.getChildNodes()) { + list.addAll(currNode.getChildNodes()); + } + volume.setFolder(list); + } + } + return volumeList; + } + + @Override + public VolumeEntity getOneVolume(String volumeName) throws Exception { + VolumeEntity volume = new VolumeEntity(); + volume.setName(volumeName); + List path = volumeInfo.getVolumeMountPoint(volumeName); + if (null != path && path.size() > 0) { + volume.setPath(path.get(0)); + } + volume.setAllSize(volumeInfo.getVolumeAvailableSize(volumeName)); + volume.setUsedSize(volumeInfo.getVolumeUseSize(volumeName)); +// volume.setBrick(brick); + if (null != volume.getPath()) { + List list = new ArrayList(); + if (null != path && path.size() > 0) { + FolderNode currNode = getFolder(path.get(0)); + if (null != currNode && null != currNode.getChildNodes()) { + list.addAll(currNode.getChildNodes()); + } + } + volume.setFolder(list); + } + return volume; + } + + @Override + public int moveData(String volumeName, String srcPath, String dstPath) + throws Exception { + + int result = copydata.copyFolderFilesAnyway(srcPath, dstPath, "app"); + return result; + } + + @Override + public int deleteData(String volumeName, String srcPath) throws Exception { + // TODO Auto-generated method stub + return 0; + } + +} diff --git a/src/com/platform/service/impl/MoveDataServiceImpl.java b/src/com/platform/service/impl/MoveDataServiceImpl.java new file mode 100644 index 00000000..511676a7 --- /dev/null +++ b/src/com/platform/service/impl/MoveDataServiceImpl.java @@ -0,0 +1,141 @@ +package com.platform.service.impl; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import javax.annotation.Resource; + +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.stereotype.Component; +import org.springframework.stereotype.Service; + +import com.platform.dao.DataInfoDao; +import com.platform.dao.DataInfoMoveTmpDao; +import com.platform.entities.DataInfoEntity; +import com.platform.entities.DataInfoEntityMoveTmp; +import com.platform.glusterfs.CheckoutMD5; +import com.platform.glusterfs.CopyData; +import com.platform.glusterfs.ShowData; +import com.platform.service.IMoveDataService; +import com.platform.utils.Bean2MapUtils; +import com.platform.utils.Constant; +import com.platform.utils.DateForm; + +@Component +@Service(value = "moveDataService") +public class MoveDataServiceImpl implements IMoveDataService{ + + @Resource(name = "dataInfoDao") + private DataInfoDao dataInfoDao; + + /** + * 迁移 + */ + CopyData copy = new CopyData(); + + /** + * MD5校验 + */ + CheckoutMD5 check = new CheckoutMD5(); + + @Resource(name = "dataInfoMoveTmpDao") + private DataInfoMoveTmpDao dataInfoMoveTmpDao; + + /** + * 查看数据 + */ + ShowData show = new ShowData(); + + @Override + public boolean moveData(List data, String dstPath) throws Exception { + boolean isSuccess = false; + String tailPath = ""; + if (null != data) { + //XXX/320198_16/1,or XXX/320122KFQ_15/1 ---> /320198_16/1, or /320122KFQ_15/1 + List exist = dataInfoMoveTmpDao.findAll(); + List existIds = new ArrayList(); + if (null != exist) { + for (DataInfoEntityMoveTmp dataInfoEntityMoveTmp : exist) { + if ("0".equals(dataInfoEntityMoveTmp.getCompleteStatus()) || "1".equals(dataInfoEntityMoveTmp.getCompleteStatus())) { + if (null != dataInfoEntityMoveTmp.getDataPath()) { + existIds.add(dataInfoEntityMoveTmp.getDataPath()); + } + } + } + } + Pattern pattern = Pattern.compile("\\/\\d+[a-z]*[A-Z]*_\\d+\\/\\d*\\/*$"); + // 末尾 含有 / + Pattern pattern2 = Pattern.compile("\\/$"); + Matcher matcher2 = pattern2.matcher(dstPath); + //去掉 最后 的 / 符合 + if (matcher2.find()) { + dstPath = dstPath.substring(0, dstPath.length()-1); + } + List moveList = new ArrayList(); + for (DataInfoEntity dataInfoEntity : data) { + if (existIds.contains(dataInfoEntity.getDataPath())) { + continue; + } + //TODO 正则:取出 data 的后面 的 路径,eg: XXX/320198_16/1,or XXX/320122KFQ_15/1) + Matcher matcher = pattern.matcher(dataInfoEntity.getDataPath()); + // tailPath 第一个字符是 / 符号 + if (matcher.find()) { + tailPath = matcher.group(); + } + String finalDestPath = dstPath + tailPath; + DataInfoEntityMoveTmp dataMove = new DataInfoEntityMoveTmp(); + dataMove.setSystemCode(dataInfoEntity.getSystemCode()); + dataMove.setRegionalismCode(dataInfoEntity.getRegionalismCode()); + dataMove.setDstPath(finalDestPath); + dataMove.setLastTime(DateForm.date2StringBysecond(new Date())); + moveList.add(dataMove); + } + if (moveList.size() > 0) { + dataInfoMoveTmpDao.insertBatch(moveList); + isSuccess = true; + } + } + return isSuccess; + } + + @Override + public List findAll() throws Exception { + List result = new ArrayList(); + try { + result = dataInfoMoveTmpDao.findAll(); + + } catch (Exception e) { + System.err.println(e); + } + return result; + } + + @Override + public int delete(DataInfoEntityMoveTmp dataMove) throws Exception { + int result = dataInfoMoveTmpDao.remove(dataMove.getId()); + return result; + } + + + @Override + public int save(DataInfoEntityMoveTmp data) throws Exception { + dataInfoMoveTmpDao.save(data); + return 0; + } + + @Override + public int insertBatch(List list) throws Exception { + // TODO Auto-generated method stub + return 0; + } + + @Override + public int update(DataInfoEntityMoveTmp data) throws Exception { + int result = dataInfoMoveTmpDao.update(data); + return result; + } + +} diff --git a/src/com/platform/service/thread/ThreadMoveData.java b/src/com/platform/service/thread/ThreadMoveData.java new file mode 100644 index 00000000..b7e2f867 --- /dev/null +++ b/src/com/platform/service/thread/ThreadMoveData.java @@ -0,0 +1,158 @@ +package com.platform.service.thread; + +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.annotation.Resource; + +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.stereotype.Component; +import org.springframework.stereotype.Service; + +import com.platform.dao.DataInfoDao; +import com.platform.dao.DataInfoMoveTmpDao; +import com.platform.dao.GatherOracleDao; +import com.platform.entities.DataInfoEntity; +import com.platform.entities.DataInfoEntityMoveTmp; +import com.platform.entities.GatherOracleInfo; +import com.platform.glusterfs.CheckoutMD5; +import com.platform.glusterfs.CopyData; +import com.platform.glusterfs.ShowData; +import com.platform.service.DataInfoService; +import com.platform.service.DataInfoServiceImp; +import com.platform.service.IMoveDataService; +import com.platform.service.impl.MoveDataServiceImpl; +import com.platform.utils.Bean2MapUtils; +import com.platform.utils.Constant; +import com.platform.utils.DateForm; + +@Component +public class ThreadMoveData{ + + @Resource(name = "dataInfoDao") + private DataInfoDao dataInfoDao; + + /** + * 迁移 + */ + CopyData copy = new CopyData(); + + /** + * MD5校验 + */ + CheckoutMD5 check = new CheckoutMD5(); + + @Resource(name = "dataInfoMoveTmpDao") + private DataInfoMoveTmpDao dataInfoMoveTmpDao; + + /** + * 查看数据 + */ + ShowData show = new ShowData(); + + /** + * : 实时更新数据库--根据查询到的 正则迁移的数据 + */ + public ThreadMoveData() { + } + + //5秒 + @Scheduled(fixedDelay = 5000) + public void doSomething() { + + try { + List result = null; + //查询 表 move_data_tmp + result = dataInfoMoveTmpDao.findAll(); + if (null != result) { + //gfs 获取size, + int rsize = result.size(); + boolean isNoMove = true; + //该循环必须 循环每个,不能有 break; + // rate:大小:假的,待换成真实比例 + double realRate = 0.00; + for (int i = 0; i < rsize; i++) { + DataInfoEntityMoveTmp dataMove = result.get(i); + //如果拷贝进度超过20分钟未进行-- 判断为 迁移失败。 + // "1" :正在上传,0:等待 迁移, 2:成功 3:失败 + if ("1".equals(dataMove.getCompleteStatus())) { + long nowTime = new Date().getTime(); + long timelong = nowTime - DateForm.string2DateBysecond(dataMove.getLastTime()).getTime(); + if (timelong > 1000*60*20) { + dataMove.setCompleteStatus("3"); + dataInfoMoveTmpDao.update(dataMove); + } + isNoMove = false; + // 查询大小:。//gfs 获取size, + long srcSize = show.getFolderSize(dataMove.getDataPath()); + long dstSize = show.getFolderSize(dataMove.getDstPath()); + if (srcSize > 0 && dstSize > 0) { + realRate = dstSize / srcSize * 100; + dataMove.setRate((int) realRate); + dataMove.setLastTime(DateForm.date2StringBysecond(new Date())); + } + + } + if("1".equals(dataMove.getCompleteStatus()) &&dataMove.getRate() > 0){ + //传输完毕:进行校验 + if (realRate == 100) { + //TODO 进行MD5校验 + int resl = check.checkoutMD5Folder(dataMove.getDataPath(), dataMove.getDstPath()); + //TODO 校验成功--则删除数据库记录 + if(resl == 1){ + //校验成功--修改 数据库记录-- + dataMove.setCompleteStatus("2"); + dataMove.setLastTime(DateForm.date2StringBysecond(new Date())); + dataInfoMoveTmpDao.update(dataMove); + //TODO 新增 一条数据-到-dataInfo + DataInfoEntity data = (DataInfoEntity) Bean2MapUtils.convertMap( + DataInfoEntity.class, Bean2MapUtils.convertBean(dataMove)); + data.setDataPath(dataMove.getDstPath()); + data.setYear(dataMove.getYear()+" (迁移完成时间 " + DateForm.date2StringByMin(new Date())+")"); + dataInfoDao.save(data); + } + else { + // 3:表示 迁移失败 + dataMove.setCompleteStatus("3"); + } + } + dataMove.setLastTime(DateForm.date2StringBysecond(new Date())); + dataInfoMoveTmpDao.update(dataMove); + } + } + //循环 完了, 确定没有上传的 ,没有正在上传的 + if (isNoMove) { + //查询 表 move_data_tmp + result = dataInfoMoveTmpDao.findAll(); + if (null != result) { + + int tmpsize = result.size(); + // 上传下一个后 + for (int i = 0; i < tmpsize; i++) { + DataInfoEntityMoveTmp next2move = result.get(i); + //如果是 待 迁移状态的 + if ("0".equals(next2move.getCompleteStatus())) { + //待迁移的数据 -- 开始迁移 + copy.copyFolderFilesAnyway(next2move.getDataPath(), next2move.getDstPath(), "app"); + // "1" :正在上传,0:等待 迁移, 2:成功 3:失败 + next2move.setCompleteStatus("1"); + next2move.setLastTime(DateForm.date2StringBysecond(new Date())); + //更新sql + dataInfoMoveTmpDao.update(next2move); + break; + } + } + } + } + } + + Thread.sleep(Constant.update_dataInfo_sleep_time); + } catch (Exception e) { + System.err.println(e); + } + + } + +} diff --git a/src/com/platform/service/thread/TreadMoveData2Start.java b/src/com/platform/service/thread/TreadMoveData2Start.java new file mode 100644 index 00000000..91f9bb92 --- /dev/null +++ b/src/com/platform/service/thread/TreadMoveData2Start.java @@ -0,0 +1,47 @@ +package com.platform.service.thread; + +import java.util.List; + +import javax.annotation.Resource; + +import org.springframework.stereotype.Service; + +import com.platform.dao.DataInfoMoveTmpDao; +import com.platform.entities.DataInfoEntityMoveTmp; +import com.platform.service.IMoveDataService; +import com.platform.service.impl.MoveDataServiceImpl; +import com.platform.utils.Constant; + +public class TreadMoveData2Start extends Thread{ + + + private IMoveDataService dataInfoMove= new MoveDataServiceImpl(); + + public TreadMoveData2Start() { + } + + @Override + public void run() { + boolean isBreak = false; + while(true){ + if (isBreak) { + break; + } + try { + List resultlist = dataInfoMove.findAll(); + for (DataInfoEntityMoveTmp moveEntity : resultlist) { + if ("1".equals(moveEntity.getCompleteStatus())) { + moveEntity.setCompleteStatus("3"); + dataInfoMove.update(moveEntity); + } + } + isBreak = true; + Thread.sleep(Constant.update_dataInfo_sleep_time); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } + +} diff --git a/src/com/platform/utils/CacheTreeData.java b/src/com/platform/utils/CacheTreeData.java index e1c6eb69..6d6caa1b 100644 --- a/src/com/platform/utils/CacheTreeData.java +++ b/src/com/platform/utils/CacheTreeData.java @@ -1,19 +1,39 @@ -package com.platform.utils; - -import java.util.List; - -import com.platform.entities.FolderNode; - -public class CacheTreeData { - - private static List folders = null; - - public static List getFolders() { - return folders; - } - - public static void setFolders(List folders) { - CacheTreeData.folders = folders; - } - -} +package com.platform.utils; + +import java.util.List; +import java.util.Map; + +import com.platform.entities.FolderNode; +import com.platform.entities.VolumeEntity; + +public class CacheTreeData { + + private static List folders = null; + + private static List volumeList = null; + + public static List getFolders() { + return folders; + } + + public static void setFolders(List folders) { + CacheTreeData.folders = folders; + } + + /** + * @return the volumeList + */ + public static List getVolumeList() { + return volumeList; + } + + /** + * @param volumeList the volumeList to set + */ + public static void setVolumeList(List volumeList) { + CacheTreeData.volumeList = volumeList; + } + +} + + diff --git a/src/com/platform/utils/ConfigsLoader.java b/src/com/platform/utils/ConfigsLoader.java index 56745ce0..9f3880df 100644 --- a/src/com/platform/utils/ConfigsLoader.java +++ b/src/com/platform/utils/ConfigsLoader.java @@ -1,74 +1,76 @@ -package com.platform.utils; - -import java.util.Properties; - -import javax.servlet.ServletContextEvent; -import javax.servlet.ServletContextListener; - -public class ConfigsLoader implements ServletContextListener { - private static ConfigPropertyReader cReader = null; - - @Override - public void contextDestroyed(ServletContextEvent sEvent) { - // TODO Auto-generated method stub - Configs.CONSOLE_LOGGER.info("系统停止.."); - } - - @SuppressWarnings("static-access") - @Override - public void contextInitialized(ServletContextEvent sEvent) { - // TODO Auto-generated method stub - Configs.CONSOLE_LOGGER.info("系统初始化.."); - String contextPath = sEvent.getServletContext().getRealPath("/") - + "WEB-INF/config/config.properties"; - this.cReader = ConfigPropertyReader.Builder(contextPath); - init(); - new ThreadVolume("").start(); - } - - public static void init() { - Properties properties = cReader.getProperties(); - - Configs.KUBE_MASTER_URL = properties.getProperty("kubeMasterUrl"); - - Configs.COLLECT_USER_NAME = properties.getProperty("collect-user-name"); - - Configs.COLLECT_PASSWORD = properties.getProperty("collect-password"); - - Configs.COLLECT_SERVICE_NAME = properties - .getProperty("collect-service-name"); - - Configs.GATHER_USER_NAME = properties.getProperty("gather-user-name"); - - Configs.GATHER_USER_PASSWORD = properties - .getProperty("gather-user-password"); - - Configs.GATHER_PORT = properties.getProperty("gather-port"); - - Configs.GATHER_SERVICE_NAME = properties - .getProperty("gather-service-name"); - - Configs.TABLE_SUFFIX = properties.getProperty("table-suffix"); - - Configs.EXTRACT_LOG_LOCALTION = properties - .getProperty("extract-log-localtion"); - - Configs.GATHER_TABLESPACE_NAME = properties - .getProperty("gather-tablespace-name"); - - Configs.GATHER_TABLESPACE_PATH = properties - .getProperty("gather-tablespace-path"); - - Configs.GATHER_TABLE_PASSWORD=properties.getProperty("gather-table-user-password"); - } - - public ConfigPropertyReader getcReader() { - return cReader; - } - - @SuppressWarnings("static-access") - public void setcReader(ConfigPropertyReader cReader) { - this.cReader = cReader; - } - -} +package com.platform.utils; + +import java.util.Properties; + +import javax.servlet.ServletContextEvent; +import javax.servlet.ServletContextListener; + +import com.platform.service.thread.ThreadMoveData; + +public class ConfigsLoader implements ServletContextListener { + private static ConfigPropertyReader cReader = null; + + @Override + public void contextDestroyed(ServletContextEvent sEvent) { + // TODO Auto-generated method stub + Configs.CONSOLE_LOGGER.info("系统停止.."); + } + + @SuppressWarnings("static-access") + @Override + public void contextInitialized(ServletContextEvent sEvent) { + // TODO Auto-generated method stub + Configs.CONSOLE_LOGGER.info("系统初始化.."); + String contextPath = sEvent.getServletContext().getRealPath("/") + + "WEB-INF/config/config.properties"; + this.cReader = ConfigPropertyReader.Builder(contextPath); + init(); + new ThreadVolume("").start(); + } + + public static void init() { + Properties properties = cReader.getProperties(); + + Configs.KUBE_MASTER_URL = properties.getProperty("kubeMasterUrl"); + + Configs.COLLECT_USER_NAME = properties.getProperty("collect-user-name"); + + Configs.COLLECT_PASSWORD = properties.getProperty("collect-password"); + + Configs.COLLECT_SERVICE_NAME = properties + .getProperty("collect-service-name"); + + Configs.GATHER_USER_NAME = properties.getProperty("gather-user-name"); + + Configs.GATHER_USER_PASSWORD = properties + .getProperty("gather-user-password"); + + Configs.GATHER_PORT = properties.getProperty("gather-port"); + + Configs.GATHER_SERVICE_NAME = properties + .getProperty("gather-service-name"); + + Configs.TABLE_SUFFIX = properties.getProperty("table-suffix"); + + Configs.EXTRACT_LOG_LOCALTION = properties + .getProperty("extract-log-localtion"); + + Configs.GATHER_TABLESPACE_NAME = properties + .getProperty("gather-tablespace-name"); + + Configs.GATHER_TABLESPACE_PATH = properties + .getProperty("gather-tablespace-path"); + + Configs.GATHER_TABLE_PASSWORD=properties.getProperty("gather-table-user-password"); + } + + public ConfigPropertyReader getcReader() { + return cReader; + } + + @SuppressWarnings("static-access") + public void setcReader(ConfigPropertyReader cReader) { + this.cReader = cReader; + } + +} diff --git a/src/com/platform/utils/Constant.java b/src/com/platform/utils/Constant.java index 957eb4ae..2e4656a4 100644 --- a/src/com/platform/utils/Constant.java +++ b/src/com/platform/utils/Constant.java @@ -1,32 +1,45 @@ -package com.platform.utils; - - -public class Constant { - public static String rootUser = "root"; - public static String rootPasswd = "root"; - public static String hostIp = "192.168.0.110"; -// public static String hostIp = "192.168.1.105"; - public static int port = 22; - public static String glusterPeerStatus = "gluster peer status"; - public static String glusterVolumeInfo = "gluster volume info "; - public static String df = "df -k "; - public static String peerincluster_connected="PeerinCluster(Connected)"; - public static String peerincluster_disconnected="PeerinCluster(Disconnected)"; - public static String distributed="distributed"; - public static String replica="replica"; - public static String stripe="stripe"; - public static String noVolume="No volumes present"; - public static GanymedSSH ganymedSSH=new GanymedSSH(hostIp, rootUser, rootPasswd, port); - public static String fileGetTreeData="./WEB-INF/config/getTreedata.sh"; - - /** - * volume 获取的线程休眠时间 - */ - public final static int get_volume_sleep_time = 300000; - - /** - * volume 获取的线程休眠时间 - */ - public final static int update_dataInfo_sleep_time = 3000; - -} + +package com.platform.utils; + + +public class Constant { + public static String rootUser = "root"; + public static String rootPasswd = "root"; + public static String hostIp = "192.168.0.116"; + // public static String hostIp = "192.168.1.105"; + public static int port = 22; + public static String glusterPeerStatus = "gluster peer status"; + public static String glusterVolumeInfo = "gluster volume info "; + public static String df = "df -k "; + public static String peerincluster_connected = "PeerinCluster(Connected)"; + public static String peerincluster_disconnected = "PeerinCluster(Disconnected)"; + public static String peerNotinCluster = "PeerNotinCluster"; + public static String distributed = "distributed"; + public static String replica = "replica"; + public static String stripe = "stripe"; + public static String noVolume = "No volumes present"; + public static String success = "success"; + public static String failed = "failed"; + public static String noSuchFile = "No such file or directory"; + public static GanymedSSH ganymedSSH = new GanymedSSH(hostIp, rootUser, rootPasswd, port); + public static String fileGetTreeData = "WebContent\\WEB-INF\\config\\getTreedata.sh"; + public static String strGetTreeData = "function ergodic(){\n " + + "for file in \\`ls \\$1\\`\n do\n if [ \"\\$file\" != \"app\" -a -d \\$1\\\"/\\\"\\$file ]\n " + + "then\n ergodic \\$1\"/\"\\$file\n else\n local path=\\$1\"/\"\\$file\n " + + "echo \\$path \n fi\n done\n}\n\nIFS=\\$\\'\\n\\' " + + "#这个必须要,否则会在文件名中有空格时出错\nINIT_PATH=\".\";\nergodic \\$1\n"; + + + + + /** + * volume 获取的线程休眠时间 + */ + public final static int get_volume_sleep_time = 300000; + + /** + * volume 获取的线程休眠时间 + */ + public final static int update_dataInfo_sleep_time = 3000; + +} diff --git a/src/com/platform/utils/DateForm.java b/src/com/platform/utils/DateForm.java new file mode 100644 index 00000000..c6531466 --- /dev/null +++ b/src/com/platform/utils/DateForm.java @@ -0,0 +1,137 @@ +package com.platform.utils; + +import java.text.DateFormat; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Date; + +public class DateForm { + + private static final String date_format_second = "yyyy-MM-dd HH:mm:ss"; + + private static final String date_format_second_non = "yyyy-MM-dd_HH-mm-ss"; + + private static final String data_format_min = "yyyy-MM-dd HH:mm"; + + private static final String data_format_day = "yyyy-MM-dd"; + + private static ThreadLocal threadLocal_second = new ThreadLocal(); + + private static ThreadLocal threadLocal_second_non = new ThreadLocal(); + + private static ThreadLocal threadLocal_min = new ThreadLocal(); + + private static ThreadLocal threadLocal_day = new ThreadLocal(); + + public static String date2StringBysecond(Date date) { + if (date == null) { + return null; + } + DateFormat format = threadLocal_second.get(); + if(format == null){ + format = new SimpleDateFormat(date_format_second); + threadLocal_second.set(format); + } + return format.format(date); + } + + public static String date2StringBysecondNon(Date date) { + if (date == null) { + return null; + } + DateFormat format = threadLocal_second_non.get(); + if(format == null){ + format = new SimpleDateFormat(date_format_second_non); + threadLocal_second_non.set(format); + } + return format.format(date); + } + + public static String date2StringByMin(Date date) { + if (date == null) { + return null; + } + DateFormat format = threadLocal_min.get(); + if(format == null){ + format = new SimpleDateFormat(data_format_min); + threadLocal_min.set(format); + } + return format.format(date); + } + + public static String date2StringByDay(Date date) { + if (date == null) { + return null; + } + DateFormat format = threadLocal_day.get(); + if(format == null){ + format = new SimpleDateFormat(data_format_day); + threadLocal_day.set(format); + } + return format.format(date); + } + + public static Date string2DateBysecond(String date) { + if (date == null) { + return null; + } + date = date.trim(); + if (date.isEmpty()) { + return null; + } + DateFormat format = threadLocal_second.get(); + try { + if(format == null){ + format = new SimpleDateFormat(date_format_second); + threadLocal_second.set(format); + } + return format.parse(date); + } catch (ParseException e) { + e.printStackTrace(); + } + return null; + } + + public static Date string2DateByMin(String date) { + if (date == null) { + return null; + } + date = date.trim(); + if (date.isEmpty()) { + return null; + } + DateFormat format = threadLocal_min.get(); + try { + if(format == null){ + format = new SimpleDateFormat(data_format_min); + threadLocal_min.set(format); + } + return format.parse(date); + } catch (ParseException e) { + e.printStackTrace(); + } + return null; + } + + public static Date string2DateByDay(String date) { + if (date == null) { + return null; + } + date = date.trim(); + if (date.isEmpty()) { + return null; + } + DateFormat format = threadLocal_day.get(); + try { + if(format == null){ + format = new SimpleDateFormat(data_format_day); + threadLocal_day.set(format); + } + return format.parse(date); + } catch (ParseException e) { + e.printStackTrace(); + } + return null; + } + +} diff --git a/src/com/platform/utils/FileOperateHelper.java b/src/com/platform/utils/FileOperateHelper.java index d2eed1b5..3236c597 100644 --- a/src/com/platform/utils/FileOperateHelper.java +++ b/src/com/platform/utils/FileOperateHelper.java @@ -7,6 +7,8 @@ import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStreamReader; +import org.junit.Test; + /** * 文件读写操作帮助类 * @@ -65,14 +67,18 @@ public class FileOperateHelper { * @param path * @return */ + @SuppressWarnings("resource") public static String fileReaderAndendline(String path) { + StringBuffer sb = new StringBuffer(); String tempString = ""; try { File file = new File(path); if (!file.exists()) + return ""; + FileInputStream fis = new FileInputStream(file); BufferedReader br = new BufferedReader(new InputStreamReader(fis)); while ((tempString = br.readLine()) != null) { @@ -83,4 +89,7 @@ public class FileOperateHelper { } return sb.toString(); } + + + } diff --git a/src/com/platform/utils/GanymedSSH.java b/src/com/platform/utils/GanymedSSH.java index cae4f452..31598f93 100644 --- a/src/com/platform/utils/GanymedSSH.java +++ b/src/com/platform/utils/GanymedSSH.java @@ -1,267 +1,268 @@ -package com.platform.utils; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.apache.log4j.Logger; -import org.apache.log4j.PropertyConfigurator; - -import ch.ethz.ssh2.Connection; -import ch.ethz.ssh2.Session; -import ch.ethz.ssh2.StreamGobbler; - -import ch.ethz.ssh2.*; - - - -public class GanymedSSH { - public static Logger log = Logger.getLogger(GanymedSSH.class); - Connection conn; - - public boolean status = true;// 锟角凤拷锟斤拷锟街达拷锟斤拷锟斤拷锟阶刺� - - public GanymedSSH() { - // TODO Auto-generated constructor stub - - } - - public GanymedSSH(String host, String username, String password, int port) { - // TODO Auto-generated constructor stub - try { - conn = getOpenedConnection(host, username, password, port); - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - - } - - - public Connection getOpenedConnection(String host, String username, String password, int port) - throws IOException { - - conn = new Connection(host, port); - conn.connect(); // make sure the connection is opened - boolean isAuthenticated = conn.authenticateWithPassword(username, password); - if (isAuthenticated == false) - throw new IOException("Authentication failed."); - return conn; - } - - public void execCmdNoWaitAcquiescent(String cmd) { - String host=Constant.hostIp; - String username=Constant.rootUser; - String password=Constant.rootPasswd; - int port=Constant.port; - - Session sess = null; - try { - conn = getOpenedConnection(host, username, password, port); - sess = conn.openSession(); - // 执锟斤拷cmd - sess.execCommand(cmd); - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } finally { - sess.close(); - - } - } - - public void execCmdNoWait(String host, String username, String password, int port, String cmd) { - - Session sess = null; - try { - conn = getOpenedConnection(host, username, password, port); - sess = conn.openSession(); - // 执锟斤拷cmd - sess.execCommand(cmd); - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } finally { - sess.close(); - - } - } - - public List execCmdWaitAcquiescent(String cmd) { - String host=Constant.hostIp; - String username=Constant.rootUser; - String password=Constant.rootPasswd; - int port=Constant.port; - List reStrings = new ArrayList(); - - Session sess = null; - try { - - sess = conn.openSession(); - // 执锟斤拷cmd - sess.execCommand(cmd); - - InputStream stdout = new StreamGobbler(sess.getStdout()); - InputStream stderr = new StreamGobbler(sess.getStderr()); - BufferedReader stdoutReader = new BufferedReader(new InputStreamReader(stdout)); - BufferedReader stderrReader = new BufferedReader(new InputStreamReader(stderr)); - while (true) { - String line = stdoutReader.readLine(); - - if (line != null) { -// System.out.println(line); - reStrings.add(line); - } else { - break; - } - } - if(reStrings.size()==0){ - while (true) { - String line = stderrReader.readLine(); - - if (line != null) { -// System.out.println(line); - reStrings.add(line); - } else { - break; - } - } - } - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } finally { - sess.close(); - - } - return reStrings; - } - - public List execCmdWait(String host, String username, String password, int port, String cmd) { - List reStrings = new ArrayList(); - - Session sess = null; - try { - - sess = conn.openSession(); - // 执锟斤拷cmd - sess.execCommand(cmd); - - InputStream stdout = new StreamGobbler(sess.getStdout()); - InputStream stderr = new StreamGobbler(sess.getStderr()); - BufferedReader stdoutReader = new BufferedReader(new InputStreamReader(stdout)); - BufferedReader stderrReader = new BufferedReader(new InputStreamReader(stderr)); - while (true) { - String line = stdoutReader.readLine(); - - if (line != null) { -// System.out.println(line); - reStrings.add(line); - } else { - break; - } - } - if(reStrings.size()==0){ - while (true) { - String line = stderrReader.readLine(); - - if (line != null) { -// System.out.println(line); - reStrings.add(line); - } else { - break; - } - } - } - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } finally { - sess.close(); - - } - return reStrings; - } - - public Map execMD5cmd(String host, String username, String password, int port, String cmd, - String prefix) { - Map md5 = new HashMap(); - - - Session sess = null; - try { - - sess = conn.openSession(); - // 执锟斤拷cmd - sess.execCommand(cmd); - InputStream stdout = new StreamGobbler(sess.getStdout()); - - @SuppressWarnings("resource") - BufferedReader br = new BufferedReader(new InputStreamReader(stdout)); - while (true) { - String line = br.readLine(); - if (line != null) { - String[] lines = line.split(" "); - String key = lines[1].replace(prefix, ""); - String value = lines[0]; - md5.put(key, value); - // System.out.println(key+"\t"+value); - } else { - break; - } - - } - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } finally { - sess.close(); - - } - return md5; - } - - public String execGetSize(String cmd) { - status = false; - String str_size = "0"; - Session sess = null; - try { - - // 执锟斤拷cmd - sess = conn.openSession(); - sess.execCommand(cmd); - InputStream stdout = new StreamGobbler(sess.getStdout()); - - @SuppressWarnings("resource") - BufferedReader br = new BufferedReader(new InputStreamReader(stdout)); - while (true) { - String line = br.readLine(); - if (line != null) { - // String[] lines=line.split(" "); - // str_size=lines[0]; - - str_size = line; - } else { - break; - } - - } - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } finally { - sess.close(); - } - status = true; - return str_size; - } - public static void main(String[] args) { - PropertyConfigurator.configure("log4j.properties"); - } - -} + +package com.platform.utils; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.apache.log4j.Logger; +import org.apache.log4j.PropertyConfigurator; + +import ch.ethz.ssh2.Connection; +import ch.ethz.ssh2.Session; +import ch.ethz.ssh2.StreamGobbler; + +import ch.ethz.ssh2.*; + + + +public class GanymedSSH { + public static Logger log = Logger.getLogger(GanymedSSH.class); + Connection conn; + + public boolean status = true;// 锟角凤拷锟斤拷锟街达拷锟斤拷锟斤拷锟阶刺� + + public GanymedSSH() { + // TODO Auto-generated constructor stub + + } + + public GanymedSSH(String host, String username, String password, int port) { + // TODO Auto-generated constructor stub + try { + conn = getOpenedConnection(host, username, password, port); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + + + public Connection getOpenedConnection(String host, String username, String password, int port) + throws IOException { + + conn = new Connection(host, port); + conn.connect(); // make sure the connection is opened + boolean isAuthenticated = conn.authenticateWithPassword(username, password); + if (isAuthenticated == false) + throw new IOException("Authentication failed."); + return conn; + } + + public void execCmdNoWaitAcquiescent(String cmd) { + String host=Constant.hostIp; + String username=Constant.rootUser; + String password=Constant.rootPasswd; + int port=Constant.port; + + Session sess = null; + try { + + sess = conn.openSession(); + // 执锟斤拷cmd + sess.execCommand(cmd); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } finally { + sess.close(); + + } + } + + public void execCmdNoWait(String host, String username, String password, int port, String cmd) { + + Session sess = null; + try { + conn = getOpenedConnection(host, username, password, port); + sess = conn.openSession(); + // 执锟斤拷cmd + sess.execCommand(cmd); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } finally { + sess.close(); + + } + } + + public List execCmdWaitAcquiescent(String cmd) { + String host=Constant.hostIp; + String username=Constant.rootUser; + String password=Constant.rootPasswd; + int port=Constant.port; + List reStrings = new ArrayList(); + + Session sess = null; + try { + + sess = conn.openSession(); + // 执锟斤拷cmd + sess.execCommand(cmd); + + InputStream stdout = new StreamGobbler(sess.getStdout()); + InputStream stderr = new StreamGobbler(sess.getStderr()); + BufferedReader stdoutReader = new BufferedReader(new InputStreamReader(stdout)); + BufferedReader stderrReader = new BufferedReader(new InputStreamReader(stderr)); + while (true) { + String line = stderrReader.readLine(); + + if (line != null) { +// System.out.println(line); + reStrings.add(line); + } else { + break; + } + } + + if(reStrings.size()==0){ + while (true) { + String line = stdoutReader.readLine(); + + if (line != null) { +// System.out.println(line); + reStrings.add(line); + } else { + break; + } + } + } + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } finally { + sess.close(); + + } + return reStrings; + } + + public List execCmdWait(String host, String username, String password, int port, String cmd) { + List reStrings = new ArrayList(); + + Session sess = null; + try { + + sess = conn.openSession(); + // 执锟斤拷cmd + sess.execCommand(cmd); + + InputStream stdout = new StreamGobbler(sess.getStdout()); + InputStream stderr = new StreamGobbler(sess.getStderr()); + BufferedReader stdoutReader = new BufferedReader(new InputStreamReader(stdout)); + BufferedReader stderrReader = new BufferedReader(new InputStreamReader(stderr)); + while (true) { + String line = stdoutReader.readLine(); + + if (line != null) { +// System.out.println(line); + reStrings.add(line); + } else { + break; + } + } + if(reStrings.size()==0){ + while (true) { + String line = stderrReader.readLine(); + + if (line != null) { +// System.out.println(line); + reStrings.add(line); + } else { + break; + } + } + } + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } finally { + sess.close(); + + } + return reStrings; + } + + public Map execMD5cmd(String cmd) { + Map md5 = new HashMap(); + + + Session sess = null; + try { + + sess = conn.openSession(); + // 执锟斤拷cmd + sess.execCommand(cmd); + + InputStream stdout = new StreamGobbler(sess.getStdout()); + InputStream stderr = new StreamGobbler(sess.getStderr()); + BufferedReader stdoutReader = new BufferedReader(new InputStreamReader(stdout)); + BufferedReader stderrReader = new BufferedReader(new InputStreamReader(stderr)); + while (true) { + String line = stdoutReader.readLine(); + + if (line != null) { + String[] lines = line.split(" "); + String key = lines[1].trim(); + String value = lines[0].trim(); + md5.put(key, value); + } else { + break; + } + } + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } finally { + sess.close(); + + } + return md5; + } + + public String execGetSize(String cmd) { + status = false; + String str_size = "0"; + Session sess = null; + try { + + // 执锟斤拷cmd + sess = conn.openSession(); + sess.execCommand(cmd); + InputStream stdout = new StreamGobbler(sess.getStdout()); + + @SuppressWarnings("resource") + BufferedReader br = new BufferedReader(new InputStreamReader(stdout)); + while (true) { + String line = br.readLine(); + if (line != null) { + // String[] lines=line.split(" "); + // str_size=lines[0]; + + str_size = line; + } else { + break; + } + + } + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } finally { + sess.close(); + } + status = true; + return str_size; + } + public static void main(String[] args) { + PropertyConfigurator.configure("log4j.properties"); + } + +} diff --git a/src/com/platform/utils/Support.java b/src/com/platform/utils/Support.java new file mode 100644 index 00000000..1b4cdc92 --- /dev/null +++ b/src/com/platform/utils/Support.java @@ -0,0 +1,31 @@ + +/** + * 文件名 : Support.java + * 版权 : <版权/公司名> + * 描述 : <描述> + * @author liliy + * 版本 : <版本> + * 修改时间: 2016年9月12日 + * 修改内容: <修改内容> + */ +package com.platform.utils; + +import java.util.regex.Pattern; + +/** + * <一句话功能简述> + * <功能详细描述> + * @author liliy + * @version [版本号,2016年9月12日] + * @see [相关类/方法] + * @since [产品/模块版本] + */ + +public class Support { + public static boolean checkIP(String str) { + Pattern pattern = Pattern + .compile("^((\\d|[1-9]\\d|1\\d\\d|2[0-4]\\d|25[0-5]" + + "|[*])\\.){3}(\\d|[1-9]\\d|1\\d\\d|2[0-4]\\d|25[0-5]|[*])$"); + return pattern.matcher(str).matches(); + } +} diff --git a/src/com/platform/utils/ThreadMoveData.java b/src/com/platform/utils/ThreadMoveData.java deleted file mode 100644 index e05c07b1..00000000 --- a/src/com/platform/utils/ThreadMoveData.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.platform.utils; - -public class ThreadMoveData extends Thread { - - /** - * : 实时更新数据库--根据查询到的 正则迁移的数据 - */ - public ThreadMoveData() { - // TODO Auto-generated constructor stub - } - - /* (non-Javadoc) - * @see java.lang.Thread#run() - * - */ - @Override - public void run() { - // TODO Auto-generated method stub - super.run(); - //查询 表 move_data_tmp - - - - - try { - Thread.sleep(Constant.update_dataInfo_sleep_time); - } catch (InterruptedException e) { - } - } - -} diff --git a/src/com/platform/utils/ThreadVolume.java b/src/com/platform/utils/ThreadVolume.java index b7d49086..1170c58d 100644 --- a/src/com/platform/utils/ThreadVolume.java +++ b/src/com/platform/utils/ThreadVolume.java @@ -2,9 +2,14 @@ package com.platform.utils; import java.util.ArrayList; import java.util.List; +import java.util.Map; +import org.springframework.stereotype.Service; + +import com.platform.entities.Brick; import com.platform.entities.FolderNode; import com.platform.entities.VolumeEntity; +import com.platform.glusterfs.ClusterInfo; import com.platform.glusterfs.GetTreeData; import com.platform.glusterfs.VolumeInfo; @@ -18,6 +23,8 @@ public class ThreadVolume extends Thread implements Runnable{ /** Volume信息查询 */ private VolumeInfo volumeInfo = new VolumeInfo(); + private ClusterInfo cluster = new ClusterInfo(); + public ThreadVolume() { // TODO Auto-generated constructor stub } @@ -35,26 +42,70 @@ public class ThreadVolume extends Thread implements Runnable{ public void run() { super.run(); while(true){ - List folderlist = new ArrayList(); - //查询 volume name - List volumeNameList = volumeInfo.showAllVolumeName(); - if (null != volumeNameList) { - for (String volumeName : volumeNameList) { - VolumeEntity volume = new VolumeEntity(); - volume.setName(volumeName); - List path = volumeInfo.getVolumeMountPoint(volumeName); - //默认加载第一个路径 - if (null != path && path.size() > 0) { - //装入 folder: - //查询 每个 volume 下的 folder - FolderNode foldertmp = gfsTree.getDatas(path.get(0)); - folderlist.add(foldertmp); + try { + List folderlist = new ArrayList(); + List volumeList = new ArrayList(); + // brick状态 map集合 + Map brickStatusMap = cluster.showClusterInfo(); + + //查询 volume name + List volumeNameList = volumeInfo.showAllVolumeName(); + if (null != volumeNameList) { + for (String volumeName : volumeNameList) { + VolumeEntity volume = new VolumeEntity(); + volume.setName(volumeName); + List path = volumeInfo.getVolumeMountPoint(volumeName); + //默认加载第一个路径 + if (null != path && path.size() > 0) { + volume.setPath(path.get(0)); + } + volume.setAllSize(volumeInfo.getVolumeAvailableSize(volumeName)); + volume.setUsedSize(volumeInfo.getVolumeUseSize(volumeName)); + //TODO 查询brick-- + //返回 ip:path + List brickStrs = volumeInfo.getVolumeBricks(volumeName); + //brick已用大小: + Map usedSize = volumeInfo.getVolumebricksDataSize(volumeName); + Map availableSize = volumeInfo.getVolumebricksAvailableSize(volumeName); + + List brickList = new ArrayList(); + for (String brickIpPath : brickStrs) { + Brick b = new Brick(); + String ipAndpath[] = brickIpPath.split(":"); + String brickip = ipAndpath[0]; + String brickpath = ipAndpath[1]; + //iP , path , + b.setIp(brickip); + if(brickStatusMap==null || brickStatusMap.size()==0){ + b.setStatus(false); + }else if (brickStatusMap.containsKey(brickip)) { + b.setStatus(true); + } + else { + b.setStatus(false); + } + b.setPath(brickpath); + b.setAvailableSize(availableSize.get(brickIpPath)); + b.setUsedSize(usedSize.get(brickIpPath)); + brickList.add(b); + } + volume.setBrick(brickList); + + + //默认加载第一个路径 + if (null != path && path.size() > 0) { + //装入 folder: + //查询 每个 volume 下的 folder + FolderNode foldertmp = gfsTree.getDatas(path.get(0)); + folderlist.add(foldertmp); + } + volumeList.add(volume); } } - } - //TODO 更新folder 目录 - CacheTreeData.setFolders(folderlist); - try { + //TODO 更新folder 目录 + CacheTreeData.setFolders(folderlist); + CacheTreeData.setVolumeList(volumeList); + Thread.sleep(Constant.get_volume_sleep_time); } catch (InterruptedException e) { } diff --git a/src/com/platform/websocket/SystemWebSocketHandler.java b/src/com/platform/websocket/SystemWebSocketHandler.java new file mode 100644 index 00000000..dd6e3ddd --- /dev/null +++ b/src/com/platform/websocket/SystemWebSocketHandler.java @@ -0,0 +1,51 @@ +package com.platform.websocket; + +import org.springframework.web.socket.CloseStatus; +import org.springframework.web.socket.TextMessage; +import org.springframework.web.socket.WebSocketHandler; +import org.springframework.web.socket.WebSocketMessage; +import org.springframework.web.socket.WebSocketSession; + +public class SystemWebSocketHandler implements WebSocketHandler { + + @Override + public void afterConnectionClosed(WebSocketSession arg0, CloseStatus arg1) + throws Exception { + // TODO Auto-generated method stub + + } + + @Override + public void afterConnectionEstablished(WebSocketSession arg0) + throws Exception { + // TODO Auto-generated method stub + + } + + @Override + public void handleMessage(WebSocketSession arg0, WebSocketMessage arg1) + throws Exception { + // TODO Auto-generated method stub + TextMessage returnMessage = new TextMessage("received at server"); + sendMessageToUsers(returnMessage); + System.out.println("接到请求"); + } + + @Override + public void handleTransportError(WebSocketSession arg0, Throwable arg1) + throws Exception { + // TODO Auto-generated method stub + + } + + @Override + public boolean supportsPartialMessages() { + // TODO Auto-generated method stub + return false; + } + + public void sendMessageToUsers(TextMessage message) { + + } + +} diff --git a/src/com/platform/websocket/WebSocketConfig.java b/src/com/platform/websocket/WebSocketConfig.java new file mode 100644 index 00000000..f9af5d89 --- /dev/null +++ b/src/com/platform/websocket/WebSocketConfig.java @@ -0,0 +1,28 @@ +package com.platform.websocket; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.config.annotation.EnableWebMvc; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; +import org.springframework.web.socket.WebSocketHandler; +import org.springframework.web.socket.config.annotation.EnableWebSocket; +import org.springframework.web.socket.config.annotation.WebSocketConfigurer; +import org.springframework.web.socket.config.annotation.WebSocketHandlerRegistry; + + +@Configuration +@EnableWebMvc +@EnableWebSocket +public class WebSocketConfig extends WebMvcConfigurerAdapter implements WebSocketConfigurer { + + @Override + public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) { + // TODO Auto-generated method stub + registry.addHandler(myHandler(), "/webSocketServer"); + } + + @Bean + public WebSocketHandler myHandler() { + return new SystemWebSocketHandler(); + } +} diff --git a/test/com/platform/test/TestConnectOralce.java b/test/com/platform/test/TestConnectOralce.java new file mode 100644 index 00000000..ef3f7b0e --- /dev/null +++ b/test/com/platform/test/TestConnectOralce.java @@ -0,0 +1,29 @@ +package com.platform.test; + +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.SQLException; + +import com.platform.utils.Configs; + +public class TestConnectOralce { + + public static void main(String[] args) { + // TODO Auto-generated method stub + try{ + Class.forName("oracle.jdbc.driver.OracleDriver"); + Configs.CONSOLE_LOGGER.info("Oracle驱动加载成功"); + }catch(Exception e){ + System.out.println(e); + } + String url = "jdbc:oracle:thin:@192.168.0.110:60758:orcl"; + try { + Connection conn = DriverManager.getConnection(url, "system", "oracle"); + System.out.println("连接成功"); + } catch (SQLException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + +} diff --git a/test/com/platform/test/TestController.java b/test/com/platform/test/TestController.java index 662ee505..94e8aaf0 100644 --- a/test/com/platform/test/TestController.java +++ b/test/com/platform/test/TestController.java @@ -35,8 +35,8 @@ public class TestController { @ResponseBody public List getJson(HttpServletRequest res, HttpServletResponse req) { List list = new ArrayList(); - list.add(new User("lisi", 1, "")); - list.add(new User("zhansan", 2, "")); + list.add(new User("lisi", 1, "男")); + list.add(new User("zhansan", 2, "男")); return list; } diff --git a/test/com/platform/test/TestEncodeInfoDao.java b/test/com/platform/test/TestEncodeInfoDao.java index 8e729bf5..3ad7d492 100644 --- a/test/com/platform/test/TestEncodeInfoDao.java +++ b/test/com/platform/test/TestEncodeInfoDao.java @@ -32,26 +32,26 @@ public class TestEncodeInfoDao extends SMBasedTest { @Test public void testGetEncodeNameByCode() { String result = eiDao.getEncodeNameByCode("1", testTableName); - Assert.assertTrue(result.equals("Ԥִϵͳ")); + Assert.assertTrue(result.equals("预算执行系统")); } @Test public void testGetEncodeCodeByName() { List result = eiDao - .getEncodeCodeByName("Ԥִϵͳ", testTableName); + .getEncodeCodeByName("预算执行系统", testTableName); Assert.assertTrue(result.size() > 0); } @Test public void testUpdateEncodeNameByCode() { int result = eiDao - .updateEncodeNameByCode("3", "һ廯ƽ̨", testTableName); + .updateEncodeNameByCode("3", "财政一体化平台", testTableName); Assert.assertTrue(result > 0); } @Test public void testInsertEncodeEntity() { - int result = eiDao.insertEncodeEntity(new EncodedInfoEntity("˰ϵͳ", + int result = eiDao.insertEncodeEntity(new EncodedInfoEntity("非税收入系统", "4"), testTableName); Assert.assertTrue(result == 1); } diff --git a/test/com/platform/test/TestEncodeService.java b/test/com/platform/test/TestEncodeService.java index 3b4f40c6..a790ebe4 100644 --- a/test/com/platform/test/TestEncodeService.java +++ b/test/com/platform/test/TestEncodeService.java @@ -24,11 +24,11 @@ public class TestEncodeService extends SMBasedTest { @Test public void testGetEncodeNameByCode() { String result = eis.getEncodeNameByCode("2", testTableName); - Assert.assertTrue(result.equals("Ԥ")); + Assert.assertTrue(result.equals("部门预算")); } /** - * + * 事务测试 */ @Test public void testDeleteEncodeByCode() {