Added goal to stop services
git-svn-id: https://hyracks.googlecode.com/svn/branches/hyracks_hadoop_compat_changes@469 123451ca-8445-de46-9d55-352943316053
diff --git a/hyracks-examples/text-example/textapp/pom.xml b/hyracks-examples/text-example/textapp/pom.xml
index b4b81ac..fdf5bc7 100644
--- a/hyracks-examples/text-example/textapp/pom.xml
+++ b/hyracks-examples/text-example/textapp/pom.xml
@@ -96,6 +96,13 @@
<harFile>${project.build.directory}/textapp-${project.version}-app-assembly.zip</harFile>
</configuration>
</execution>
+ <execution>
+ <id>stop-services</id>
+ <phase>post-integration-test</phase>
+ <goals>
+ <goal>stop-services</goal>
+ </goals>
+ </execution>
</executions>
</plugin>
<plugin>
@@ -145,4 +152,4 @@
<scope>test</scope>
</dependency>
</dependencies>
-</project>
\ No newline at end of file
+</project>
diff --git a/hyracks-maven-plugin/src/main/java/edu/uci/ics/hyracks/maven/plugin/HyracksCCStartMojo.java b/hyracks-maven-plugin/src/main/java/edu/uci/ics/hyracks/maven/plugin/HyracksCCStartMojo.java
index d13ea29..5808909 100644
--- a/hyracks-maven-plugin/src/main/java/edu/uci/ics/hyracks/maven/plugin/HyracksCCStartMojo.java
+++ b/hyracks-maven-plugin/src/main/java/edu/uci/ics/hyracks/maven/plugin/HyracksCCStartMojo.java
@@ -38,11 +38,7 @@
}
String args = cmdLineBuffer.toString();
final Process proc = launch(new File(hyracksServerHome, makeScriptName(HYRACKS_CC_SCRIPT)), args);
- Runtime.getRuntime().addShutdownHook(new Thread() {
- public void run() {
- proc.destroy();
- }
- });
+ HyracksServiceRegistry.INSTANCE.addServiceProcess(proc);
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
diff --git a/hyracks-maven-plugin/src/main/java/edu/uci/ics/hyracks/maven/plugin/HyracksNCStartMojo.java b/hyracks-maven-plugin/src/main/java/edu/uci/ics/hyracks/maven/plugin/HyracksNCStartMojo.java
index df598fb..2f1a268 100644
--- a/hyracks-maven-plugin/src/main/java/edu/uci/ics/hyracks/maven/plugin/HyracksNCStartMojo.java
+++ b/hyracks-maven-plugin/src/main/java/edu/uci/ics/hyracks/maven/plugin/HyracksNCStartMojo.java
@@ -59,11 +59,7 @@
}
String args = cmdLineBuffer.toString();
final Process proc = launch(new File(hyracksServerHome, makeScriptName(HYRACKS_NC_SCRIPT)), args);
- Runtime.getRuntime().addShutdownHook(new Thread() {
- public void run() {
- proc.destroy();
- }
- });
+ HyracksServiceRegistry.INSTANCE.addServiceProcess(proc);
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
diff --git a/hyracks-maven-plugin/src/main/java/edu/uci/ics/hyracks/maven/plugin/HyracksServiceRegistry.java b/hyracks-maven-plugin/src/main/java/edu/uci/ics/hyracks/maven/plugin/HyracksServiceRegistry.java
new file mode 100644
index 0000000..6ea5a64
--- /dev/null
+++ b/hyracks-maven-plugin/src/main/java/edu/uci/ics/hyracks/maven/plugin/HyracksServiceRegistry.java
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2009-2010 by The Regents of the University of California
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * you may obtain a copy of the License from
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package edu.uci.ics.hyracks.maven.plugin;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class HyracksServiceRegistry {
+ public static HyracksServiceRegistry INSTANCE = new HyracksServiceRegistry();
+
+ private final List<Process> serviceProcesses;
+
+ private HyracksServiceRegistry() {
+ serviceProcesses = new ArrayList<Process>();
+ Runtime.getRuntime().addShutdownHook(new Thread() {
+ @Override
+ public void run() {
+ destroyAll();
+ }
+ });
+ }
+
+ public synchronized void addServiceProcess(Process process) {
+ serviceProcesses.add(process);
+ }
+
+ public synchronized void destroyAll() {
+ for (Process p : serviceProcesses) {
+ try {
+ p.destroy();
+ } catch (Exception e) {
+ }
+ }
+ serviceProcesses.clear();
+ }
+}
\ No newline at end of file
diff --git a/hyracks-maven-plugin/src/main/java/edu/uci/ics/hyracks/maven/plugin/HyracksStopServicesMojo.java b/hyracks-maven-plugin/src/main/java/edu/uci/ics/hyracks/maven/plugin/HyracksStopServicesMojo.java
new file mode 100644
index 0000000..eaf40fc
--- /dev/null
+++ b/hyracks-maven-plugin/src/main/java/edu/uci/ics/hyracks/maven/plugin/HyracksStopServicesMojo.java
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2009-2010 by The Regents of the University of California
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * you may obtain a copy of the License from
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package edu.uci.ics.hyracks.maven.plugin;
+
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+
+/**
+ * @goal stop-services
+ */
+public class HyracksStopServicesMojo extends AbstractHyracksMojo {
+ @Override
+ public void execute() throws MojoExecutionException, MojoFailureException {
+ getLog().info("Stopping Hyracks Services");
+ HyracksServiceRegistry.INSTANCE.destroyAll();
+ }
+}
\ No newline at end of file