You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@storm.apache.org by pt...@apache.org on 2015/06/03 19:35:18 UTC

[04/50] [abbrv] storm git commit: add documentation for using Java enums in Flux YAML files

add documentation for using Java enums in Flux YAML files


Project: http://git-wip-us.apache.org/repos/asf/storm/repo
Commit: http://git-wip-us.apache.org/repos/asf/storm/commit/85e53e91
Tree: http://git-wip-us.apache.org/repos/asf/storm/tree/85e53e91
Diff: http://git-wip-us.apache.org/repos/asf/storm/diff/85e53e91

Branch: refs/heads/master
Commit: 85e53e918437550ff9878a9712eb45055523042e
Parents: cdcb738
Author: P. Taylor Goetz <pt...@gmail.com>
Authored: Mon Mar 30 21:31:05 2015 -0400
Committer: P. Taylor Goetz <pt...@gmail.com>
Committed: Mon Mar 30 21:31:05 2015 -0400

----------------------------------------------------------------------
 README.md | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/storm/blob/85e53e91/README.md
----------------------------------------------------------------------
diff --git a/README.md b/README.md
index 580b7dd..3f6bdc1 100644
--- a/README.md
+++ b/README.md
@@ -389,6 +389,39 @@ The signatures of the corresponding methods are as follows:
 Arguments passed to configuration methods work much the same way as constructor arguments, and support references as
 well.
 
+### Using Java `enum`s in Contructor Arguments, References, Properties and Configuration Methods
+You can easily use Java `enum` values as arguments in a Flux YAML file, simply by referencing the name of the `enum`.
+
+For example, [Storm's HDFS module]() includes the following `enum` definition (simplified for brevity):
+
+```java
+public static enum Units {
+    KB, MB, GB, TB
+}
+```
+
+And the `org.apache.storm.hdfs.bolt.rotation.FileSizeRotationPolicy` class has the following constructor:
+
+```java
+public FileSizeRotationPolicy(float count, Units units)
+
+```
+The following Flux `component` definition could be used to call the constructor:
+
+```yaml
+  - id: "rotationPolicy"
+    className: "org.apache.storm.hdfs.bolt.rotation.FileSizeRotationPolicy"
+    constructorArgs:
+      - 5.0
+      - MB
+```
+
+The above definition is functionally equivalent to the following Java code:
+
+```java
+// rotate files when they reach 5MB
+FileRotationPolicy rotationPolicy = new FileSizeRotationPolicy(5.0f, Units.MB);
+```
 
 ## Topology Config
 The `config` section is simply a map of Storm topology configuration parameters that will be passed to the