Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

added launcher script and logging config.

  • Loading branch information...
commit 45d4602a488930b42b66f056efbae0ceb6f74cab 1 parent e26df10
@carlosdotdanger authored
View
53 bin/pooper.sh
@@ -0,0 +1,53 @@
+#!/bin/bash
+# resolve links - $0 may be a softlink
+this="${BASH_SOURCE-$0}"
+while [ -h "$this" ]; do
+ ls=`ls -ld "$this"`
+ link=`expr "$ls" : '.*-> \(.*\)$'`
+ if expr "$link" : '.*/.*' > /dev/null; then
+ this="$link"
+ else
+ this=`dirname "$this"`/"$link"
+ fi
+done
+
+# convert relative path to absolute path
+bin=`dirname "$this"`
+script=`basename "$this"`
+bin=`unset CDPATH; cd "$bin"; pwd`
+this="$bin/$script"
+POOPER_HOME=`cd $bin/..;pwd`
+POOPER_JAR="$POOPER_HOME/HadooperPooper.jar"
+unset CDPATH
+cd $bin
+
+JAVA="java"
+
+if [ -z "$POOPER_CONFIG" ] ; then
+ if [ -f ~/.ec2/pooper.properties ] ; then
+ POOPER_CONFIG=~/.ec2/pooper.properties
+ else
+ if [ -f "$POOPER_HOME/config/pooper.properties" ] ; then
+ POOPER_CONFIG="$POOPER_HOME/config/pooper.properties"
+ fi
+ fi
+fi
+
+POOPER_LIB="$POOPER_HOME/lib"
+#theincessant aws log messages will make you mental if you don't have this.
+
+if [ -z $CLASSPATH ] ; then
+ CLASSPATH="."
+fi
+
+for jar in $POOPER_LIB/*.jar ; do
+ CLASSPATH=$CLASSPATH:$jar
+done
+
+JAVA_OPTS="-Dlogging.config=$POOPER_HOME/config/log4j.properties"
+JAVA_OPTS="$JAVA_OPTS -Dclasspath=$CLASSPATH"
+JAVA_OPTS="$JAVA_OPTS -Dpooper.config=$POOPER_CONFIG"
+
+COMMAND="$JAVA $JAVA_OPTS -jar $POOPER_JAR $1 $2 $3 $4 $5 $6"
+
+exec $COMMAND
View
11 build.xml
@@ -71,5 +71,16 @@
nbproject/build-impl.xml file.
-->
+ <target name="-post-jar">
+ <copy todir="${dist.dir}/bin">
+ <fileset dir="bin">
+ </fileset>
+ </copy>
+ <copy todir="${dist.dir}/config">
+ <fileset dir="config">
+ </fileset>
+ </copy>
+ <chmod file="${dist.dir}/bin/pooper.sh" perm="755"/>
+ </target>
</project>
View
4 config/log4j.properties
@@ -0,0 +1,4 @@
+log4j.rootLogger=WARN, A1
+log4j.appender.A1=org.apache.log4j.ConsoleAppender
+log4j.appender.A1.layout=org.apache.log4j.PatternLayout
+log4j.appender.A1.layout.ConversionPattern=%d [%t] %-5p %c - %m%n
View
9 nbproject/project.properties
@@ -30,7 +30,8 @@ includes=**
jar.compress=false
javac.classpath=\
${libs.aws.classpath}:\
- ${libs.commons-codec.classpath}
+ ${libs.commons-codec.classpath}:\
+ ${libs.log4j.classpath}
# Space-separated list of extra javac options
javac.compilerargs=
javac.deprecation=false
@@ -61,16 +62,14 @@ meta.inf.dir=${src.dir}/META-INF
platform.active=default_platform
run.classpath=\
${javac.classpath}:\
- ${build.classes.dir}:\
- ${build.classes.dir}/data
+ ${build.classes.dir}
# Space-separated list of JVM arguments used when running the project
# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value
# or test-sys-prop.name=value to set system properties for unit tests):
run.jvmargs=-Dpooper.config=/Users/cory/.ec2/pooper.properties
run.test.classpath=\
${javac.test.classpath}:\
- ${build.test.classes.dir}:\
- ${build.classes.dir}/data
+ ${build.test.classes.dir}
source.encoding=UTF-8
src.dir=src
test.src.dir=test
View
5 src/com/lunabeat/pooper/Main.java
@@ -9,7 +9,7 @@
import com.lunabeat.dooper.ClusterConfig.ConfigException;
import com.lunabeat.pooper.commands.AppCommand;
import java.io.IOException;
-import java.util.ArrayList;
+import org.apache.log4j.PropertyConfigurator;
/**
*
@@ -26,6 +26,9 @@ public static void main(String[] args) {
}
System.exit(1);
}
+ if(System.getProperty("logging.config") != null){
+ PropertyConfigurator.configure(System.getProperty("logging.config"));
+ }
String configPath = System.getProperty("pooper.config",DEFAULT_CONFIG_PATH);
try{
View
34 src/com/lunabeat/pooper/commands/AppCommand.java
@@ -16,15 +16,19 @@
import java.io.IOException;
import java.util.Collections;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
/**
*
* @author cory
*/
public class AppCommand {
+ private static final Log LOG = LogFactory.getLog(AppCommand.class.getName());
private static final Map<String, CommandInfo> COMMANDS = initCommands();
private ClusterConfig _config;
@@ -146,28 +150,38 @@ private void checkCommandArgs(String commandName ,CommandInfo cInfo, String[] ar
private void listClusters() {
Map<String,Map<String,List<Instance>>> out = ClusterList.getClusterMap(_config);
- System.out.println("found clusters:");
+ System.out.println("found running clusters:");
+ HashSet<String> emptyClusters = new HashSet<String>();
for(String clustername:out.keySet()){
- System.out.println(clustername);
+ //System.out.println(clustername);
+ boolean empty = true;
for(String group: out.get(clustername).keySet()){
if(out.get(clustername).get(group).size() < 1)
- System.out.println("\t"+group+" (empty)");
- else
- System.out.println("\t"+group);
+ emptyClusters.add(group.replace(HadoopCluster.MASTER_SUFFIX, ""));
+ else{
+ System.out.println(group+" ("+out.get(clustername).get(group).size()+")");
+ empty = false;
+ }
for(Instance i: out.get(clustername).get(group)){
StringBuilder sb = new StringBuilder("\t");
sb.append(i.getInstanceId());
sb.append("\t");
- sb.append(i.getPublicDnsName());
- sb.append("\t");
- sb.append(i.getState().getName());
- sb.append("\t");
sb.append(i.getInstanceType());
sb.append("\t");
- sb.append(i.getLaunchTime().toString());
+ sb.append(i.getState().getName());
+ //sb.append("\t");
+ //sb.append(i.getPublicDnsName());
System.out.println(sb.toString());
}
+ if(!empty)
+ System.out.println();
}
+ if(!empty)
+ System.out.println("-----------");
+ }
+ System.out.println("Found empty cluster security groups:");
+ for(String s:emptyClusters){
+ System.out.println("\t"+s);
}
}
View
4 src/log4j.properties
@@ -0,0 +1,4 @@
+log4j.rootLogger=WARN, A1
+log4j.appender.A1=org.apache.log4j.ConsoleAppender
+log4j.appender.A1.layout=org.apache.log4j.PatternLayout
+log4j.appender.A1.layout.ConversionPattern=%d [%t] %-5p %c - %m%n
Please sign in to comment.
Something went wrong with that request. Please try again.