Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

WHIRR-722: Improve user and system level logging capability

  • Loading branch information...
commit 4fe7718af1d0266490113ccc28adeca3db7ee3ad 1 parent 4c45b6f
@ggear ggear authored
View
2  CHANGES.txt
@@ -6,6 +6,8 @@ Release 0.9.0 (Unreleased Changes)
IMPROVEMENTS
+ WHIRR-722. Improve user and system level logging capability. (graham)
+
WHIRR-721. Improve robustness of volume device detection. (graham)
BUG FIXES
View
14 conf/log4j-cli.xml
@@ -23,13 +23,6 @@
-->
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"
debug="false">
-
- <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
- <param name="Threshold" value="INFO" />
- <layout class="org.apache.log4j.PatternLayout">
- <param name="ConversionPattern" value="%m%n"/>
- </layout>
- </appender>
<appender name="ROLLINGFILE" class="org.apache.log4j.DailyRollingFileAppender">
<param name="File" value="whirr.log" />
@@ -41,10 +34,8 @@
</layout>
</appender>
- <logger name="org.apache.whirr" additivity="false">
- <level value="DEBUG" />
- <appender-ref ref="CONSOLE" />
- <appender-ref ref="ROLLINGFILE" />
+ <logger name="org.apache.whirr">
+ <level value="INFO" />
</logger>
<logger name="jclouds.compute">
@@ -60,7 +51,6 @@
</logger>
<root>
- <priority value="INFO" />
<appender-ref ref="ROLLINGFILE" />
</root>
View
18 core/src/main/java/org/apache/whirr/ClusterSpec.java
@@ -196,7 +196,9 @@
KERBEROS_REALM(String.class, false, "Kerberos realm to use in security configuration"),
- AWS_EC2_PLACEMENT_GROUP(String.class, false, "If given, use this existing EC2 placement group. (aws-ec2 specific option)");
+ AWS_EC2_PLACEMENT_GROUP(String.class, false, "If given, use this existing EC2 placement group. (aws-ec2 specific option)"),
+
+ QUIET(Boolean.class, false, "Adjust user level, console logging verbosity.");
private Class<?> type;
private boolean multipleArguments;
@@ -329,6 +331,8 @@ public static ClusterSpec withNoDefaults(Configuration conf)
private Map<String,Node> byonNodes;
+ private boolean isQuiet;
+
public ClusterSpec() throws ConfigurationException {
this(new PropertiesConfiguration());
}
@@ -404,6 +408,8 @@ public ClusterSpec(Configuration userConfig, boolean loadDefaults, Map<String,No
setByonNodes(byonNodes);
+ setQuiet(config.getBoolean(Property.QUIET.getConfigName(), Boolean.FALSE));
+
Map<String, List<String>> fr = new HashMap<String, List<String>>();
String firewallPrefix = Property.FIREWALL_RULES.getConfigName();
Pattern firewallRuleKeyPattern = Pattern.compile("^".concat(Pattern.quote(firewallPrefix).concat("(?:\\.(.+))?$")));
@@ -609,6 +615,10 @@ public String getBlobStoreProvider() {
}
return blobStoreProvider;
}
+
+ public boolean isQuiet() {
+ return isQuiet;
+ }
/**
* Probably jclouds should provide a similar mechanism
@@ -981,6 +991,10 @@ public void setByonNodes(Map<String,Node> byonNodes) {
this.byonNodes = byonNodes;
}
+ public void setQuiet(boolean isQuiet) {
+ this.isQuiet = isQuiet;
+ }
+
public void setVersion(String version) {
this.version = version;
}
@@ -1106,7 +1120,7 @@ public int hashCode() {
getByonNodes()
);
}
-
+
public String toString() {
return Objects.toStringHelper(this).omitNullValues()
.add("instanceTemplates", getInstanceTemplates())
View
19 core/src/main/java/org/apache/whirr/command/AbstractClusterCommand.java
@@ -80,17 +80,19 @@ public AbstractClusterCommand(String name, String description, ClusterController
.describedAs("config.properties")
.ofType(String.class);
- parser.accepts("quiet", "Be less verbose");
-
this.factory = factory;
this.stateStoreFactory = stateStoreFactory;
optionSpecs = Maps.newHashMap();
for (Property property : EnumSet.allOf(Property.class)) {
- ArgumentAcceptingOptionSpec<?> spec = parser
- .accepts(property.getSimpleName(), property.getDescription())
- .withRequiredArg()
- .ofType(property.getType());
+ ArgumentAcceptingOptionSpec<?> spec = null;
+ if (property.getType().equals(Boolean.class)) {
+ spec = parser.accepts(property.getSimpleName(), property.getDescription()).withOptionalArg()
+ .ofType(property.getType());
+ } else {
+ spec = parser.accepts(property.getSimpleName(), property.getDescription()).withRequiredArg()
+ .ofType(property.getType());
+ }
if (property.hasMultipleArguments()) {
spec.withValuesSeparatedBy(',');
}
@@ -112,6 +114,9 @@ protected ClusterSpec getClusterSpec(OptionSet optionSet) throws ConfigurationEx
} else {
value = optionSet.valueOf(option);
}
+ if (value == null && property.getType().equals(Boolean.class) && optionSet.has(property.getSimpleName())) {
+ value = Boolean.TRUE.toString();
+ }
if (value != null) {
optionsConfig.setProperty(property.getConfigName(), value);
}
@@ -165,7 +170,7 @@ protected ClusterStateStore createClusterStateStore(ClusterSpec spec) {
protected void printProviderInfo(PrintStream out, PrintStream err,
ClusterSpec clusterSpec, OptionSet optionSet) {
- if (!optionSet.has("quiet")) {
+ if (!clusterSpec.isQuiet()) {
out.println(String.format("Running on provider %s using identity %s", clusterSpec.getProvider(), clusterSpec.getIdentity()));
}
}
View
49 core/src/test/java/org/apache/whirr/command/AbstractClusterCommandTest.java
@@ -48,14 +48,61 @@ public int run(InputStream in, PrintStream out, PrintStream err,
};
Map<String, File> keys = KeyPair.generateTemporaryFiles();
- OptionSet optionSet = clusterCommand.parser.parse(
+ OptionSet optionSet = clusterCommand.parser.parse("--quiet",
"--service-name", "overridden-test-service",
"--config", "whirr-override-test.properties",
"--private-key-file", keys.get("private").getAbsolutePath()
);
ClusterSpec clusterSpec = clusterCommand.getClusterSpec(optionSet);
+ assertThat(optionSet.has("quiet"), is(true));
+ assertThat(clusterSpec.isQuiet(), is(true));
assertThat(clusterSpec.getServiceName(), is("overridden-test-service"));
assertThat(clusterSpec.getClusterName(), is("test-cluster"));
+
+ optionSet = clusterCommand.parser.parse("--quiet", "true",
+ "--service-name", "overridden-test-service",
+ "--config", "whirr-override-test.properties",
+ "--private-key-file", keys.get("private").getAbsolutePath()
+ );
+ clusterSpec = clusterCommand.getClusterSpec(optionSet);
+ assertThat(optionSet.has("quiet"), is(true));
+ assertThat(clusterSpec.isQuiet(), is(true));
+ assertThat(clusterSpec.getServiceName(), is("overridden-test-service"));
+ assertThat(clusterSpec.getClusterName(), is("test-cluster"));
+
+ optionSet = clusterCommand.parser.parse("--quiet", "false",
+ "--service-name", "overridden-test-service",
+ "--config", "whirr-override-test.properties",
+ "--private-key-file", keys.get("private").getAbsolutePath()
+ );
+ clusterSpec = clusterCommand.getClusterSpec(optionSet);
+ assertThat(optionSet.has("quiet"), is(true));
+ assertThat(clusterSpec.isQuiet(), is(false));
+ assertThat(clusterSpec.getServiceName(), is("overridden-test-service"));
+ assertThat(clusterSpec.getClusterName(), is("test-cluster"));
+
+ optionSet = clusterCommand.parser.parse("--quiet", "some-value",
+ "--service-name", "overridden-test-service",
+ "--config", "whirr-override-test.properties",
+ "--private-key-file", keys.get("private").getAbsolutePath()
+ );
+ clusterSpec = clusterCommand.getClusterSpec(optionSet);
+ assertThat(optionSet.has("quiet"), is(true));
+ assertThat(clusterSpec.isQuiet(), is(false));
+ assertThat(clusterSpec.getServiceName(), is("overridden-test-service"));
+ assertThat(clusterSpec.getClusterName(), is("test-cluster"));
+
+ optionSet = clusterCommand.parser.parse(
+ "--service-name", "overridden-test-service",
+ "--config", "whirr-override-test.properties",
+ "--private-key-file", keys.get("private").getAbsolutePath()
+ );
+ clusterSpec = clusterCommand.getClusterSpec(optionSet);
+ assertThat(optionSet.has("quiet"), is(false));
+ assertThat(clusterSpec.isQuiet(), is(false));
+ assertThat(clusterSpec.getServiceName(), is("overridden-test-service"));
+ assertThat(clusterSpec.getClusterName(), is("test-cluster"));
+
}
/**
View
10 src/site/xdoc/configuration-guide.xml
@@ -88,6 +88,16 @@ xsi:schemaLocation="http://maven.apache.org/XDOC/2.0 http://maven.apache.org/xsd
<td>Whether or not to automatically terminate all nodes when cluster
launch fails for some reason.</td>
</tr>
+ <tr valign="top">
+ <td>
+ <tt>whirr.quiet</tt>
+ </td>
+ <td>
+ <tt>--quiet</tt>
+ </td>
+ <td>false</td>
+ <td>Adjust user level, console logging verbosity. System level logs controlled via <tt>conf/log4j-cli.xml</tt>.</td>
+ </tr>
</table>
<subsection name="Instance Templates Options"></subsection>
<table border="0">
Please sign in to comment.
Something went wrong with that request. Please try again.