Permalink
Browse files

init commit

  • Loading branch information...
zhihuij committed Apr 11, 2012
0 parents commit 635c92c765a96838705dddb486d12556ad529366
Showing with 5,183 additions and 0 deletions.
  1. +5 −0 .gitignore
  2. +20 −0 MIT-LICENSE.txt
  3. +33 −0 README
  4. +166 −0 build.xml
  5. BIN doc/user manual.pdf
  6. +208 −0 doc/user manual.tex
  7. BIN lib/event-0.0.1.jar
  8. BIN lib/jgrapht-jdk1.6.jar
  9. BIN lib/jline-0.9.94.jar
  10. BIN lib/zookeeper-3.3.4.jar
  11. +49 −0 pom.xml
  12. +34 −0 sample/xmpp.properties
  13. +83 −0 src/main/bin/auto-slave.sh
  14. +80 −0 src/main/bin/ganger.sh
  15. +7 −0 src/main/bin/launch.sh
  16. +22 −0 src/main/java/com/netease/automate/exception/AutomateException.java
  17. +22 −0 src/main/java/com/netease/automate/exception/ExecuteOsCmdException.java
  18. +17 −0 src/main/java/com/netease/automate/exception/IllegalConfigException.java
  19. +22 −0 src/main/java/com/netease/automate/exception/PackageNotLaunchedException.java
  20. +14 −0 src/main/java/com/netease/automate/exception/ProcessLaunchedException.java
  21. +14 −0 src/main/java/com/netease/automate/exception/ProcessNotLaunchedException.java
  22. +14 −0 src/main/java/com/netease/automate/exception/SlaveOfflineException.java
  23. +22 −0 src/main/java/com/netease/automate/exception/ZooKeeperException.java
  24. +388 −0 src/main/java/com/netease/automate/master/AutoMaster.java
  25. +151 −0 src/main/java/com/netease/automate/master/MasterConsole.java
  26. +47 −0 src/main/java/com/netease/automate/master/SlaveActionWatcher.java
  27. +77 −0 src/main/java/com/netease/automate/master/SlaveStatusWatcher.java
  28. +121 −0 src/main/java/com/netease/automate/master/action/AbstractAction.java
  29. +16 −0 src/main/java/com/netease/automate/master/action/Action.java
  30. +54 −0 src/main/java/com/netease/automate/master/action/ActionFactory.java
  31. +17 −0 src/main/java/com/netease/automate/master/action/ActionOrder.java
  32. +48 −0 src/main/java/com/netease/automate/master/action/DeployAction.java
  33. +58 −0 src/main/java/com/netease/automate/master/action/LaunchAction.java
  34. +62 −0 src/main/java/com/netease/automate/master/action/RestartAction.java
  35. +31 −0 src/main/java/com/netease/automate/master/action/StatusAction.java
  36. +55 −0 src/main/java/com/netease/automate/master/action/StopAction.java
  37. +138 −0 src/main/java/com/netease/automate/master/entity/AbstractProcess.java
  38. +13 −0 src/main/java/com/netease/automate/master/entity/Entity.java
  39. +92 −0 src/main/java/com/netease/automate/master/entity/PackageSupervisor.java
  40. +124 −0 src/main/java/com/netease/automate/master/entity/RootProcess.java
  41. +78 −0 src/main/java/com/netease/automate/master/entity/RuntimeProcess.java
  42. +55 −0 src/main/java/com/netease/automate/master/event/EventTypes.java
  43. +52 −0 src/main/java/com/netease/automate/master/event/EventWatcher.java
  44. +28 −0 src/main/java/com/netease/automate/master/event/ProcessEventContext.java
  45. +54 −0 src/main/java/com/netease/automate/master/event/ProcessEventHandler.java
  46. +23 −0 src/main/java/com/netease/automate/master/task/AddTask.java
  47. +55 −0 src/main/java/com/netease/automate/master/task/CommonPackageTask.java
  48. +25 −0 src/main/java/com/netease/automate/master/task/DeleteTask.java
  49. +12 −0 src/main/java/com/netease/automate/master/task/Task.java
  50. +22 −0 src/main/java/com/netease/automate/master/task/TaskFactory.java
  51. +43 −0 src/main/java/com/netease/automate/master/task/ZKMessageTask.java
  52. +12 −0 src/main/java/com/netease/automate/meta/ActionStatus.java
  53. +49 −0 src/main/java/com/netease/automate/meta/Config.java
  54. +60 −0 src/main/java/com/netease/automate/meta/Global.java
  55. +54 −0 src/main/java/com/netease/automate/meta/MasterMeta.java
  56. +70 −0 src/main/java/com/netease/automate/meta/MessageMeta.java
  57. +166 −0 src/main/java/com/netease/automate/meta/PackageMeta.java
  58. +71 −0 src/main/java/com/netease/automate/meta/ProcessMeta.java
  59. +20 −0 src/main/java/com/netease/automate/meta/ProcessStatus.java
  60. +260 −0 src/main/java/com/netease/automate/meta/ProjectMeta.java
  61. +12 −0 src/main/java/com/netease/automate/meta/SlaveStatus.java
  62. +67 −0 src/main/java/com/netease/automate/meta/SlaveTarget.java
  63. +386 −0 src/main/java/com/netease/automate/slave/AutoSlave.java
  64. +179 −0 src/main/java/com/netease/automate/slave/ProcessHolder.java
  65. +42 −0 src/main/java/com/netease/automate/slave/SlaveMessageWatcher.java
  66. +46 −0 src/main/java/com/netease/automate/utils/JsonUtils.java
  67. +27 −0 src/main/java/com/netease/automate/utils/LogUtils.java
  68. +75 −0 src/main/java/com/netease/automate/utils/Tree.java
  69. +129 −0 src/main/java/com/netease/automate/utils/TreeNode.java
  70. +212 −0 src/main/java/com/netease/automate/utils/Utils.java
  71. +8 −0 src/main/resources/log4j.properties
  72. +157 −0 src/test/java/com/netease/automate/test/master/ConfigMetaTest.java
  73. +50 −0 src/test/java/com/netease/automate/test/master/PackageDependenceTest.java
  74. +42 −0 src/test/java/com/netease/automate/test/master/ProcessTreeTest.java
  75. +50 −0 src/test/java/com/netease/automate/test/master/TopologicalOrderTest.java
  76. +48 −0 src/test/java/com/netease/automate/test/utils/JsonUtilsTest.java
  77. +19 −0 src/test/java/com/netease/automate/test/utils/PatternTest.java
  78. +101 −0 src/test/java/com/netease/automate/test/utils/WatcherTest.java
@@ -0,0 +1,5 @@
.svn
.classpath
.project
.settings
target
@@ -0,0 +1,20 @@
Copyright (c) 2012 NetEase, Inc.
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
33 README
@@ -0,0 +1,33 @@
Ganger - A simple automate tool.
==================================================
What is Ganger
--------------------------------------
Ganger is a simple automate tool. It can automate deploy packages, launch
target processes, update packages deployment(kill the old process and launch
the new one), restart target processes and monitor the status of target
process.
It saves your time for development, and make it easier to deploy your systems
on many target machines simultaneously.
Features
--------------------------------------
automatation: help you do some automate tasks, for example: deploy packages,
start processes, stop processes and update deployments etc.
(Note: deploy action *ONLY* support compressed binary executables(.tar.gz)
currently.)
lifecycle management: you can start, stop, restart or update the target
process.
dependence management: we organize the package as a directed graph with no
cycles, when a process of a package crashed or started, the processes of the
package which depend on it will be notified. Automate action will operate on
packages as the topological order of the dependence graph(or reverse order for
actions similar to #stop#).
status monitor: monitor the target process's status.
166 build.xml
@@ -0,0 +1,166 @@
<?xml version="1.0" ?>
<project name="Automate" default="release" basedir=".">
<property name="src.dir" value="${basedir}/src" />
<property name="java.lib.dir" value="D:/Program Files/Java/jdk1.6.0_19/lib" />
<property name="build.dir" value="${basedir}/build" />
<property name="classes.dir" value="${basedir}/target/classes" />
<property name="dist.dir" value="${basedir}/target/dist" />
<property name="lib.dir" value="${basedir}/lib" />
<property name="jar-master.file" value="auto-master.jar" />
<property name="jar-slave.file" value="auto-slave.jar" />
<property name="main.dir" value="${src.dir}/main" />
<property name="target.dir" value="${basedir}/target" />
<property name="dependency.dir" value="${target.dir}/dependency" />
<property name="release.out.dir" value="${target.dir}/release" />
<property name="release.name" value="automate-1.0.0" />
<property name="release.master.name" value="auto-master-1.0.0" />
<property name="release.slave.name" value="auto-slave-1.0.0" />
<path id="compile.classpath">
<fileset dir="${java.lib.dir}">
<include name="tools.jar" />
</fileset>
</path>
<patternset id="no.java">
<exclude name="**/*.java" />
</patternset>
<patternset id="has.java">
<include name="**/*.java" />
</patternset>
<target name="init">
<mkdir dir="${classes.dir}" />
<mkdir dir="${dist.dir}" />
<copy todir="${classes.dir}">
<fileset dir="${src.dir}">
<patternset refid="has.java" />
</fileset>
</copy>
</target>
<target name="clean">
<delete dir="${build.dir}" />
<delete dir="${dist.dir}" />
<echo level="info">clean successfully~</echo>
</target>
<target name="compile" depends="init">
<javac srcdir="${src.dir}" destdir="${classes.dir}" debug="true" verbose="${verbose}" includeAntRuntime="no">
<classpath refid="compile.classpath" />
</javac>
</target>
<target name="auto-master">
<jar jarfile="${dist.dir}/${jar-master.file}">
<fileset dir="${classes.dir}">
<exclude name="**/slave/" />
</fileset>
<manifest>
<attribute name="Main-Class" value="com.netease.automate.master.AutoMaster" />
<attribute name="Built-By" value="Netease" />
</manifest>
</jar>
</target>
<target name="auto-slave">
<jar jarfile="${dist.dir}/${jar-slave.file}">
<fileset dir="${classes.dir}">
<exclude name="**/master/" />
<exclude name="**/task/" />
</fileset>
<manifest>
<attribute name="Main-Class" value="com.netease.automate.master.AutoSlave" />
<attribute name="Built-By" value="Netease" />
</manifest>
</jar>
</target>
<target name="release">
<delete file="${release.out.dir}/${release.master.name}.tar.gz" />
<delete file="${release.out.dir}/${release.slave.name}.tar.gz" />
<property name="release.master.dir" value="${release.out.dir}/${release.master.name}" />
<property name="release.slave.dir" value="${release.out.dir}/${release.slave.name}" />
<delete dir="${release.master.dir}" />
<mkdir dir="${release.master.dir}" />
<delete dir="${release.slave.dir}" />
<mkdir dir="${release.slave.dir}" />
<!-- Make & copy bin and resources. -->
<copy todir="${release.master.dir}">
<fileset dir="${main.dir}">
<exclude name="**/java/" />
<exclude name="**/*slave.sh" />
<exclude name="**/*launch.sh" />
</fileset>
</copy>
<copy todir="${release.slave.dir}">
<fileset dir="${main.dir}">
<exclude name="**/java/" />
<exclude name="**/*master.sh" />
<exclude name="**/ganger.sh" />
</fileset>
</copy>
<delete dir="${dist.dir}" />
<mkdir dir="${dist.dir}" />
<jar jarfile="${dist.dir}/${jar-master.file}">
<fileset dir="${classes.dir}">
<exclude name="**/slave/" />
<exclude name="**/*.sh" />
</fileset>
<manifest>
<attribute name="Main-Class" value="com.netease.automate.master.AutoMaster" />
<attribute name="Built-By" value="Netease" />
</manifest>
</jar>
<jar jarfile="${dist.dir}/${jar-slave.file}">
<fileset dir="${classes.dir}">
<exclude name="**/master/" />
<exclude name="**/task/" />
<exclude name="**/*.sh" />
</fileset>
<manifest>
<attribute name="Main-Class" value="com.netease.automate.master.AutoSlave" />
<attribute name="Built-By" value="Netease" />
</manifest>
</jar>
<mkdir dir="${release.master.dir}/lib" />
<copy todir="${release.master.dir}/lib">
<fileset dir="${dependency.dir}" />
<fileset dir="${dist.dir}">
<exclude name="**/*slave.jar" />
</fileset>
<fileset dir="${lib.dir}" />
</copy>
<mkdir dir="${release.master.dir}/sample" />
<copy todir="${release.master.dir}/sample">
<fileset dir="${basedir}/sample" />
</copy>
<mkdir dir="${release.slave.dir}/lib" />
<copy todir="${release.slave.dir}/lib">
<fileset dir="${dependency.dir}" />
<fileset dir="${dist.dir}">
<exclude name="**/*master.jar" />
</fileset>
<fileset dir="${lib.dir}">
<exclude name="**/event*" />
<exclude name="**/jline*" />
</fileset>
</copy>
<tar tarfile="${release.out.dir}/${release.master.name}.tar.gz" basedir="${release.out.dir}/" includes="*master*/**/*" compression="gzip" longfile="gnu" />
<tar tarfile="${release.out.dir}/${release.slave.name}.tar.gz" basedir="${release.out.dir}/" includes="*slave*/**/*" compression="gzip" longfile="gnu" />
</target>
</project>
Binary file not shown.
Oops, something went wrong.

0 comments on commit 635c92c

Please sign in to comment.